1 ;; GCC machine description for Renesas H8/300
2 ;; Copyright (C) 1992-2018 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 seq = final_sequence;
2412 final_scan_insn (seq->insn (1), asm_out_file, optimize, 1, & seen);
2413 final_scan_insn (seq->insn (0), asm_out_file, optimize, 1, & seen);
2414 seq->insn (1)->set_deleted ();
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_FLAGS (XEXP (operands[0], 0)) & SYMBOL_FLAG_FUNCVEC_FUNCTION))
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_FLAGS (XEXP (operands[1], 0)) & SYMBOL_FLAG_FUNCVEC_FUNCTION))
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 && UINTVAL (operands[3]) == ((HOST_WIDE_INT_M1U << INTVAL (operands[2]))
3920 "&& reload_completed"
3921 [(parallel [(set (match_dup 5)
3922 (ashift:HI (match_dup 5)
3924 (clobber (match_dup 4))])
3926 (zero_extend:SI (match_dup 5)))]
3928 operands[5] = gen_rtx_REG (HImode, REGNO (operands[0]));
3931 ;; Accept (A >> 30) & 2 and the like.
3933 (define_insn "*andsi3_lshiftrt_n_sb"
3934 [(set (match_operand:SI 0 "register_operand" "=r")
3935 (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
3936 (match_operand:SI 2 "const_int_operand" "n"))
3937 (match_operand:SI 3 "single_one_operand" "n")))]
3938 "(TARGET_H8300H || TARGET_H8300S)
3939 && exact_log2 (INTVAL (operands[3])) < 16
3940 && INTVAL (operands[2]) + exact_log2 (INTVAL (operands[3])) == 31"
3942 operands[3] = GEN_INT (exact_log2 (INTVAL (operands[3])));
3943 return "shll.l\\t%S0\;xor.l\\t%S0,%S0\;bst\\t%Z3,%Y0";
3945 [(set_attr "length" "8")])
3947 (define_insn_and_split "*andsi3_lshiftrt_9_sb"
3948 [(set (match_operand:SI 0 "register_operand" "=r")
3949 (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
3951 (const_int 4194304)))]
3952 "TARGET_H8300H || TARGET_H8300S"
3954 "&& reload_completed"
3956 (and:SI (lshiftrt:SI (match_dup 0)
3959 (parallel [(set (match_dup 0)
3960 (ashift:SI (match_dup 0)
3962 (clobber (scratch:QI))])]
3967 (define_insn "*addsi3_upper"
3968 [(set (match_operand:SI 0 "register_operand" "=r")
3969 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
3971 (match_operand:SI 2 "register_operand" "0")))]
3972 "TARGET_H8300H || TARGET_H8300S"
3974 [(set_attr "length" "2")])
3976 (define_insn "*addsi3_lshiftrt_16_zexthi"
3977 [(set (match_operand:SI 0 "register_operand" "=r")
3978 (plus:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3980 (zero_extend:SI (match_operand:HI 2 "register_operand" "0"))))]
3981 "TARGET_H8300H || TARGET_H8300S"
3982 "add.w\\t%e1,%f0\;xor.w\\t%e0,%e0\;rotxl.w\\t%e0"
3983 [(set_attr "length" "6")])
3985 (define_insn_and_split "*addsi3_and_r_1"
3986 [(set (match_operand:SI 0 "register_operand" "=r")
3987 (plus:SI (and:SI (match_operand:SI 1 "register_operand" "r")
3989 (match_operand:SI 2 "register_operand" "0")))]
3990 "TARGET_H8300H || TARGET_H8300S"
3992 "&& reload_completed"
3993 [(set (cc0) (compare (zero_extract:SI (match_dup 1)
3998 (if_then_else (eq (cc0)
4000 (label_ref (match_dup 3))
4003 (plus:SI (match_dup 2)
4007 operands[3] = gen_label_rtx ();
4010 (define_insn_and_split "*addsi3_and_not_r_1"
4011 [(set (match_operand:SI 0 "register_operand" "=r")
4012 (plus:SI (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
4014 (match_operand:SI 2 "register_operand" "0")))]
4015 "TARGET_H8300H || TARGET_H8300S"
4017 "&& reload_completed"
4018 [(set (cc0) (compare (zero_extract:SI (match_dup 1)
4023 (if_then_else (ne (cc0)
4025 (label_ref (match_dup 3))
4028 (plus:SI (match_dup 2)
4032 operands[3] = gen_label_rtx ();
4037 (define_insn "*ixorhi3_zext"
4038 [(set (match_operand:HI 0 "register_operand" "=r")
4039 (match_operator:HI 1 "iorxor_operator"
4040 [(zero_extend:HI (match_operand:QI 2 "register_operand" "r"))
4041 (match_operand:HI 3 "register_operand" "0")]))]
4044 [(set_attr "length" "2")])
4048 (define_insn "*ixorsi3_zext_qi"
4049 [(set (match_operand:SI 0 "register_operand" "=r")
4050 (match_operator:SI 1 "iorxor_operator"
4051 [(zero_extend:SI (match_operand:QI 2 "register_operand" "r"))
4052 (match_operand:SI 3 "register_operand" "0")]))]
4055 [(set_attr "length" "2")])
4057 (define_insn "*ixorsi3_zext_hi"
4058 [(set (match_operand:SI 0 "register_operand" "=r")
4059 (match_operator:SI 1 "iorxor_operator"
4060 [(zero_extend:SI (match_operand:HI 2 "register_operand" "r"))
4061 (match_operand:SI 3 "register_operand" "0")]))]
4062 "TARGET_H8300H || TARGET_H8300S"
4064 [(set_attr "length" "2")])
4066 (define_insn "*ixorsi3_ashift_16"
4067 [(set (match_operand:SI 0 "register_operand" "=r")
4068 (match_operator:SI 1 "iorxor_operator"
4069 [(ashift:SI (match_operand:SI 2 "register_operand" "r")
4071 (match_operand:SI 3 "register_operand" "0")]))]
4072 "TARGET_H8300H || TARGET_H8300S"
4074 [(set_attr "length" "2")])
4076 (define_insn "*ixorsi3_lshiftrt_16"
4077 [(set (match_operand:SI 0 "register_operand" "=r")
4078 (match_operator:SI 1 "iorxor_operator"
4079 [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
4081 (match_operand:SI 3 "register_operand" "0")]))]
4082 "TARGET_H8300H || TARGET_H8300S"
4084 [(set_attr "length" "2")])
4088 (define_insn "*iorhi3_ashift_8"
4089 [(set (match_operand:HI 0 "register_operand" "=r")
4090 (ior:HI (ashift:HI (match_operand:HI 1 "register_operand" "r")
4092 (match_operand:HI 2 "register_operand" "0")))]
4095 [(set_attr "length" "2")])
4097 (define_insn "*iorhi3_lshiftrt_8"
4098 [(set (match_operand:HI 0 "register_operand" "=r")
4099 (ior:HI (lshiftrt:HI (match_operand:HI 1 "register_operand" "r")
4101 (match_operand:HI 2 "register_operand" "0")))]
4104 [(set_attr "length" "2")])
4106 (define_insn "*iorhi3_two_qi"
4107 [(set (match_operand:HI 0 "register_operand" "=r")
4108 (ior:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "0"))
4109 (ashift:HI (match_operand:HI 2 "register_operand" "r")
4113 [(set_attr "length" "2")])
4115 (define_insn "*iorhi3_two_qi_mem"
4116 [(set (match_operand:HI 0 "register_operand" "=&r")
4117 (ior:HI (zero_extend:HI (match_operand:QI 1 "memory_operand" "m"))
4118 (ashift:HI (subreg:HI (match_operand:QI 2 "memory_operand" "m") 0)
4121 "mov.b\\t%X2,%t0\;mov.b\\t%X1,%s0"
4122 [(set_attr "length" "16")])
4125 [(set (match_operand:HI 0 "register_operand" "")
4126 (ior:HI (zero_extend:HI (match_operand:QI 1 "memory_operand" ""))
4127 (ashift:HI (subreg:HI (match_operand:QI 2 "memory_operand" "") 0)
4129 "(TARGET_H8300H || TARGET_H8300S)
4131 && byte_accesses_mergeable_p (XEXP (operands[2], 0), XEXP (operands[1], 0))"
4135 operands[3] = gen_rtx_MEM (HImode, XEXP (operands[2], 0));
4140 (define_insn "*iorsi3_two_hi"
4141 [(set (match_operand:SI 0 "register_operand" "=r")
4142 (ior:SI (zero_extend:SI (match_operand:HI 1 "register_operand" "0"))
4143 (ashift:SI (match_operand:SI 2 "register_operand" "r")
4145 "TARGET_H8300H || TARGET_H8300S"
4147 [(set_attr "length" "2")])
4149 (define_insn_and_split "*iorsi3_two_qi_zext"
4150 [(set (match_operand:SI 0 "register_operand" "=&r")
4151 (ior:SI (zero_extend:SI (match_operand:QI 1 "memory_operand" "m"))
4152 (and:SI (ashift:SI (subreg:SI (match_operand:QI 2 "memory_operand" "m") 0)
4154 (const_int 65280))))]
4155 "TARGET_H8300H || TARGET_H8300S"
4157 "&& reload_completed"
4159 (ior:HI (zero_extend:HI (match_dup 1))
4160 (ashift:HI (subreg:HI (match_dup 2) 0)
4163 (zero_extend:SI (match_dup 3)))]
4165 operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));
4168 (define_insn "*iorsi3_e2f"
4169 [(set (match_operand:SI 0 "register_operand" "=r")
4170 (ior:SI (and:SI (match_operand:SI 1 "register_operand" "0")
4172 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
4174 "TARGET_H8300H || TARGET_H8300S"
4176 [(set_attr "length" "2")])
4178 (define_insn_and_split "*iorsi3_two_qi_sext"
4179 [(set (match_operand:SI 0 "register_operand" "=r")
4180 (ior:SI (zero_extend:SI (match_operand:QI 1 "register_operand" "0"))
4181 (ashift:SI (sign_extend:SI (match_operand:QI 2 "register_operand" "r"))
4183 "TARGET_H8300H || TARGET_H8300S"
4185 "&& reload_completed"
4187 (ior:HI (zero_extend:HI (match_dup 1))
4188 (ashift:HI (match_dup 4)
4191 (sign_extend:SI (match_dup 3)))]
4193 operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));
4194 operands[4] = gen_rtx_REG (HImode, REGNO (operands[2]));
4197 (define_insn "*iorsi3_w"
4198 [(set (match_operand:SI 0 "register_operand" "=r,&r")
4199 (ior:SI (and:SI (match_operand:SI 1 "register_operand" "0,0")
4201 (zero_extend:SI (match_operand:QI 2 "general_operand_src" "r,g>"))))]
4202 "TARGET_H8300H || TARGET_H8300S"
4204 [(set_attr "length" "2,8")])
4206 (define_insn "*iorsi3_ashift_31"
4207 [(set (match_operand:SI 0 "register_operand" "=&r")
4208 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
4210 (match_operand:SI 2 "register_operand" "0")))]
4211 "TARGET_H8300H || TARGET_H8300S"
4212 "rotxl.l\\t%S0\;bor\\t#0,%w1\;rotxr.l\\t%S0"
4213 [(set_attr "length" "6")
4214 (set_attr "cc" "set_znv")])
4216 (define_insn "*iorsi3_and_ashift"
4217 [(set (match_operand:SI 0 "register_operand" "=r")
4218 (ior:SI (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
4219 (match_operand:SI 2 "const_int_operand" "n"))
4220 (match_operand:SI 3 "single_one_operand" "n"))
4221 (match_operand:SI 4 "register_operand" "0")))]
4222 "(TARGET_H8300H || TARGET_H8300S)
4223 && (INTVAL (operands[3]) & ~0xffff) == 0"
4225 rtx srcpos = GEN_INT (exact_log2 (INTVAL (operands[3]))
4226 - INTVAL (operands[2]));
4227 rtx dstpos = GEN_INT (exact_log2 (INTVAL (operands[3])));
4228 operands[2] = srcpos;
4229 operands[3] = dstpos;
4230 return "bld\\t%Z2,%Y1\;bor\\t%Z3,%Y0\;bst\\t%Z3,%Y0";
4232 [(set_attr "length" "6")])
4234 (define_insn "*iorsi3_and_lshiftrt"
4235 [(set (match_operand:SI 0 "register_operand" "=r")
4236 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4237 (match_operand:SI 2 "const_int_operand" "n"))
4238 (match_operand:SI 3 "single_one_operand" "n"))
4239 (match_operand:SI 4 "register_operand" "0")))]
4240 "(TARGET_H8300H || TARGET_H8300S)
4241 && ((INTVAL (operands[3]) << INTVAL (operands[2])) & ~0xffff) == 0"
4243 rtx srcpos = GEN_INT (exact_log2 (INTVAL (operands[3]))
4244 + INTVAL (operands[2]));
4245 rtx dstpos = GEN_INT (exact_log2 (INTVAL (operands[3])));
4246 operands[2] = srcpos;
4247 operands[3] = dstpos;
4248 return "bld\\t%Z2,%Y1\;bor\\t%Z3,%Y0\;bst\\t%Z3,%Y0";
4250 [(set_attr "length" "6")])
4252 (define_insn "*iorsi3_zero_extract"
4253 [(set (match_operand:SI 0 "register_operand" "=r")
4254 (ior:SI (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
4256 (match_operand:SI 2 "const_int_operand" "n"))
4257 (match_operand:SI 3 "register_operand" "0")))]
4258 "(TARGET_H8300H || TARGET_H8300S) && INTVAL (operands[2]) < 16"
4259 "bld\\t%Z2,%Y1\;bor\\t#0,%w0\;bst\\t#0,%w0"
4260 [(set_attr "length" "6")])
4262 (define_insn "*iorsi3_and_lshiftrt_n_sb"
4263 [(set (match_operand:SI 0 "register_operand" "=r")
4264 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4267 (match_operand:SI 2 "register_operand" "0")))]
4268 "TARGET_H8300H || TARGET_H8300S"
4269 "rotl.l\\t%S1\;rotr.l\\t%S1\;bor\\t#1,%w0\;bst\\t#1,%w0"
4270 [(set_attr "length" "8")])
4272 (define_insn "*iorsi3_and_lshiftrt_9_sb"
4273 [(set (match_operand:SI 0 "register_operand" "=r")
4274 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4276 (const_int 4194304))
4277 (match_operand:SI 2 "register_operand" "0")))
4278 (clobber (match_scratch:HI 3 "=&r"))]
4279 "TARGET_H8300H || TARGET_H8300S"
4281 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4282 return "shll.l\\t%S1\;xor.w\\t%T3,%T3\;bst\\t#6,%s3\;or.w\\t%T3,%e0";
4284 return "rotl.l\\t%S1\;rotr.l\\t%S1\;xor.w\\t%T3,%T3\;bst\\t#6,%s3\;or.w\\t%T3,%e0";
4286 [(set_attr "length" "10")])
4288 ;; Used to OR the exponent of a float.
4290 (define_insn "*iorsi3_shift"
4291 [(set (match_operand:SI 0 "register_operand" "=r")
4292 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
4294 (match_operand:SI 2 "register_operand" "0")))
4295 (clobber (match_scratch:SI 3 "=&r"))]
4296 "TARGET_H8300H || TARGET_H8300S"
4300 [(set (match_operand:SI 0 "register_operand" "")
4301 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
4304 (clobber (match_operand:SI 2 "register_operand" ""))]
4305 "(TARGET_H8300H || TARGET_H8300S)
4306 && epilogue_completed
4307 && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
4308 && REGNO (operands[0]) != REGNO (operands[1])"
4309 [(parallel [(set (match_dup 3)
4310 (ashift:HI (match_dup 3)
4312 (clobber (scratch:QI))])
4314 (ior:SI (ashift:SI (match_dup 1)
4318 operands[3] = gen_rtx_REG (HImode, REGNO (operands[1]));
4322 [(set (match_operand:SI 0 "register_operand" "")
4323 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
4326 (clobber (match_operand:SI 2 "register_operand" ""))]
4327 "(TARGET_H8300H || TARGET_H8300S)
4328 && epilogue_completed
4329 && !(find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
4330 && REGNO (operands[0]) != REGNO (operands[1]))"
4333 (parallel [(set (match_dup 3)
4334 (ashift:HI (match_dup 3)
4336 (clobber (scratch:QI))])
4338 (ior:SI (ashift:SI (match_dup 2)
4342 operands[3] = gen_rtx_REG (HImode, REGNO (operands[2]));
4345 (define_insn "*iorsi2_and_1_lshiftrt_1"
4346 [(set (match_operand:SI 0 "register_operand" "=r")
4347 (ior:SI (and:SI (match_operand:SI 1 "register_operand" "0")
4349 (lshiftrt:SI (match_dup 1)
4351 "TARGET_H8300H || TARGET_H8300S"
4352 "shlr.l\\t%S0\;bor\\t#0,%w0\;bst\\t#0,%w0"
4353 [(set_attr "length" "6")])
4355 (define_insn_and_split "*iorsi3_ashift_16_ashift_24"
4356 [(set (match_operand:SI 0 "register_operand" "=r")
4357 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
4359 (ashift:SI (match_operand:SI 2 "register_operand" "r")
4361 "TARGET_H8300H || TARGET_H8300S"
4363 "&& reload_completed"
4365 (ior:HI (ashift:HI (match_dup 4)
4368 (parallel [(set (match_dup 0)
4369 (ashift:SI (match_dup 0)
4371 (clobber (scratch:QI))])]
4373 operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));
4374 operands[4] = gen_rtx_REG (HImode, REGNO (operands[2]));
4377 (define_insn_and_split "*iorsi3_ashift_16_ashift_24_mem"
4378 [(set (match_operand:SI 0 "register_operand" "=&r")
4379 (ior:SI (and:SI (ashift:SI (subreg:SI (match_operand:QI 1 "memory_operand" "m") 0)
4381 (const_int 16711680))
4382 (ashift:SI (subreg:SI (match_operand:QI 2 "memory_operand" "m") 0)
4384 "TARGET_H8300H || TARGET_H8300S"
4386 "&& reload_completed"
4388 (ior:HI (zero_extend:HI (match_dup 1))
4389 (ashift:HI (subreg:HI (match_dup 2) 0)
4391 (parallel [(set (match_dup 0)
4392 (ashift:SI (match_dup 0)
4394 (clobber (scratch:QI))])]
4396 operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));
4399 ;; Used to add the exponent of a float.
4401 (define_insn "*addsi3_shift"
4402 [(set (match_operand:SI 0 "register_operand" "=r")
4403 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
4404 (const_int 8388608))
4405 (match_operand:SI 2 "register_operand" "0")))
4406 (clobber (match_scratch:SI 3 "=&r"))]
4407 "TARGET_H8300H || TARGET_H8300S"
4411 [(set (match_operand:SI 0 "register_operand" "")
4412 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
4413 (const_int 8388608))
4415 (clobber (match_operand:SI 2 "register_operand" ""))]
4416 "(TARGET_H8300H || TARGET_H8300S)
4417 && epilogue_completed
4418 && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
4419 && REGNO (operands[0]) != REGNO (operands[1])"
4420 [(parallel [(set (match_dup 3)
4421 (ashift:HI (match_dup 3)
4423 (clobber (scratch:QI))])
4425 (plus:SI (mult:SI (match_dup 1)
4429 operands[3] = gen_rtx_REG (HImode, REGNO (operands[1]));
4433 [(set (match_operand:SI 0 "register_operand" "")
4434 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
4435 (const_int 8388608))
4437 (clobber (match_operand:SI 2 "register_operand" ""))]
4438 "(TARGET_H8300H || TARGET_H8300S)
4439 && epilogue_completed
4440 && !(find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
4441 && REGNO (operands[0]) != REGNO (operands[1]))"
4444 (parallel [(set (match_dup 3)
4445 (ashift:HI (match_dup 3)
4447 (clobber (scratch:QI))])
4449 (plus:SI (mult:SI (match_dup 2)
4453 operands[3] = gen_rtx_REG (HImode, REGNO (operands[2]));
4458 (define_insn_and_split "*ashiftsi_sextqi_7"
4459 [(set (match_operand:SI 0 "register_operand" "=r")
4460 (ashift:SI (sign_extend:SI (match_operand:QI 1 "register_operand" "0"))
4462 "TARGET_H8300H || TARGET_H8300S"
4464 "&& reload_completed"
4465 [(parallel [(set (match_dup 2)
4466 (ashift:HI (match_dup 2)
4468 (clobber (scratch:QI))])
4470 (sign_extend:SI (match_dup 2)))
4471 (parallel [(set (match_dup 0)
4472 (ashiftrt:SI (match_dup 0)
4474 (clobber (scratch:QI))])]
4476 operands[2] = gen_rtx_REG (HImode, REGNO (operands[0]));
4479 ;; Storing a part of HImode to QImode.
4482 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
4483 (subreg:QI (lshiftrt:HI (match_operand:HI 1 "register_operand" "r")
4487 [(set_attr "cc" "set_znv")
4488 (set_attr "length" "8")])
4490 ;; Storing a part of SImode to QImode.
4493 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
4494 (subreg:QI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4498 [(set_attr "cc" "set_znv")
4499 (set_attr "length" "8")])
4502 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
4503 (subreg:QI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4505 (clobber (match_scratch:SI 2 "=&r"))]
4506 "TARGET_H8300H || TARGET_H8300S"
4507 "mov.w\\t%e1,%f2\;mov.b\\t%w2,%R0"
4508 [(set_attr "cc" "set_znv")
4509 (set_attr "length" "10")])
4512 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
4513 (subreg:QI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4515 (clobber (match_scratch:SI 2 "=&r"))]
4516 "TARGET_H8300H || TARGET_H8300S"
4517 "mov.w\\t%e1,%f2\;mov.b\\t%x2,%R0"
4518 [(set_attr "cc" "set_znv")
4519 (set_attr "length" "10")])
4521 (define_insn_and_split ""
4523 (if_then_else (eq (zero_extract:SI (subreg:SI (match_operand:QI 0 "register_operand" "") 0)
4527 (label_ref (match_operand 1 "" ""))
4532 [(set (cc0) (compare (match_dup 0)
4535 (if_then_else (ge (cc0)
4537 (label_ref (match_dup 1))
4541 (define_insn_and_split ""
4543 (if_then_else (ne (zero_extract:SI (subreg:SI (match_operand:QI 0 "register_operand" "") 0)
4547 (label_ref (match_operand 1 "" ""))
4552 [(set (cc0) (compare (match_dup 0)
4555 (if_then_else (lt (cc0)
4557 (label_ref (match_dup 1))
4561 ;; -----------------------------------------------------------------
4562 ;; PEEPHOLE PATTERNS
4563 ;; -----------------------------------------------------------------
4565 ;; Convert (A >> B) & C to (A & 255) >> B if C == 255 >> B.
4568 [(parallel [(set (match_operand:HI 0 "register_operand" "")
4569 (lshiftrt:HI (match_dup 0)
4570 (match_operand:HI 1 "const_int_operand" "")))
4571 (clobber (match_operand:HI 2 "" ""))])
4573 (and:HI (match_dup 0)
4574 (match_operand:HI 3 "const_int_operand" "")))]
4575 "INTVAL (operands[3]) == (255 >> INTVAL (operands[1]))"
4577 (and:HI (match_dup 0)
4579 (parallel [(set (match_dup 0)
4580 (lshiftrt:HI (match_dup 0) (match_dup 1)))
4581 (clobber (match_dup 2))])]
4584 ;; Convert (A << B) & C to (A & 255) << B if C == 255 << B.
4587 [(parallel [(set (match_operand:HI 0 "register_operand" "")
4588 (ashift:HI (match_dup 0)
4589 (match_operand:HI 1 "const_int_operand" "")))
4590 (clobber (match_operand:HI 2 "" ""))])
4592 (and:HI (match_dup 0)
4593 (match_operand:HI 3 "const_int_operand" "")))]
4594 "INTVAL (operands[3]) == (255 << INTVAL (operands[1]))"
4596 (and:HI (match_dup 0)
4598 (parallel [(set (match_dup 0)
4599 (ashift:HI (match_dup 0) (match_dup 1)))
4600 (clobber (match_dup 2))])]
4603 ;; Convert (A >> B) & C to (A & 255) >> B if C == 255 >> B.
4606 [(parallel [(set (match_operand:SI 0 "register_operand" "")
4607 (lshiftrt:SI (match_dup 0)
4608 (match_operand:SI 1 "const_int_operand" "")))
4609 (clobber (match_operand:SI 2 "" ""))])
4611 (and:SI (match_dup 0)
4612 (match_operand:SI 3 "const_int_operand" "")))]
4613 "INTVAL (operands[3]) == (255 >> INTVAL (operands[1]))"
4615 (and:SI (match_dup 0)
4617 (parallel [(set (match_dup 0)
4618 (lshiftrt:SI (match_dup 0) (match_dup 1)))
4619 (clobber (match_dup 2))])]
4622 ;; Convert (A << B) & C to (A & 255) << B if C == 255 << B.
4625 [(parallel [(set (match_operand:SI 0 "register_operand" "")
4626 (ashift:SI (match_dup 0)
4627 (match_operand:SI 1 "const_int_operand" "")))
4628 (clobber (match_operand:SI 2 "" ""))])
4630 (and:SI (match_dup 0)
4631 (match_operand:SI 3 "const_int_operand" "")))]
4632 "INTVAL (operands[3]) == (255 << INTVAL (operands[1]))"
4634 (and:SI (match_dup 0)
4636 (parallel [(set (match_dup 0)
4637 (ashift:SI (match_dup 0) (match_dup 1)))
4638 (clobber (match_dup 2))])]
4641 ;; Convert (A >> B) & C to (A & 65535) >> B if C == 65535 >> B.
4644 [(parallel [(set (match_operand:SI 0 "register_operand" "")
4645 (lshiftrt:SI (match_dup 0)
4646 (match_operand:SI 1 "const_int_operand" "")))
4647 (clobber (match_operand:SI 2 "" ""))])
4649 (and:SI (match_dup 0)
4650 (match_operand:SI 3 "const_int_operand" "")))]
4651 "INTVAL (operands[3]) == (65535 >> INTVAL (operands[1]))"
4653 (and:SI (match_dup 0)
4655 (parallel [(set (match_dup 0)
4656 (lshiftrt:SI (match_dup 0) (match_dup 1)))
4657 (clobber (match_dup 2))])]
4660 ;; Convert (A << B) & C to (A & 65535) << B if C == 65535 << B.
4663 [(parallel [(set (match_operand:SI 0 "register_operand" "")
4664 (ashift:SI (match_dup 0)
4665 (match_operand:SI 1 "const_int_operand" "")))
4666 (clobber (match_operand:SI 2 "" ""))])
4668 (and:SI (match_dup 0)
4669 (match_operand:SI 3 "const_int_operand" "")))]
4670 "INTVAL (operands[3]) == (65535 << INTVAL (operands[1]))"
4672 (and:SI (match_dup 0)
4674 (parallel [(set (match_dup 0)
4675 (ashift:SI (match_dup 0) (match_dup 1)))
4676 (clobber (match_dup 2))])]
4679 ;; Convert a QImode push into an SImode push so that the
4680 ;; define_peephole2 below can cram multiple pushes into one stm.l.
4683 [(parallel [(set (reg:SI SP_REG)
4684 (plus:SI (reg:SI SP_REG) (const_int -4)))
4685 (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int -3)))
4686 (match_operand:QI 0 "register_operand" ""))])]
4687 "TARGET_H8300S && !TARGET_NORMAL_MODE && REGNO (operands[0]) != SP_REG"
4688 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4691 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));
4695 [(parallel [(set (reg:HI SP_REG)
4696 (plus:HI (reg:HI SP_REG) (const_int -4)))
4697 (set (mem:QI (plus:HI (reg:HI SP_REG) (const_int -3)))
4698 (match_operand:QI 0 "register_operand" ""))])]
4699 "TARGET_H8300S && TARGET_NORMAL_MODE && REGNO (operands[0]) != SP_REG"
4700 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4703 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));
4706 ;; Convert a HImode push into an SImode push so that the
4707 ;; define_peephole2 below can cram multiple pushes into one stm.l.
4710 [(parallel [(set (reg:SI SP_REG)
4711 (plus:SI (reg:SI SP_REG) (const_int -4)))
4712 (set (mem:HI (plus:SI (reg:SI SP_REG) (const_int -2)))
4713 (match_operand:HI 0 "register_operand" ""))])]
4714 "TARGET_H8300S && !TARGET_NORMAL_MODE && REGNO (operands[0]) != SP_REG"
4715 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4718 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));
4722 [(parallel [(set (reg:HI SP_REG)
4723 (plus:HI (reg:HI SP_REG) (const_int -4)))
4724 (set (mem:HI (plus:HI (reg:HI SP_REG) (const_int -2)))
4725 (match_operand:HI 0 "register_operand" ""))])]
4726 "TARGET_H8300S && TARGET_NORMAL_MODE && REGNO (operands[0]) != SP_REG"
4727 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4730 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));
4733 ;; Cram four pushes into stm.l.
4736 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4737 (match_operand:SI 0 "register_operand" ""))
4738 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4739 (match_operand:SI 1 "register_operand" ""))
4740 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4741 (match_operand:SI 2 "register_operand" ""))
4742 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4743 (match_operand:SI 3 "register_operand" ""))]
4744 "TARGET_H8300S && !TARGET_NORMAL_MODE
4745 && (REGNO_REG_CLASS (REGNO (operands[3])) == GENERAL_REGS
4746 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4747 && REGNO (operands[2]) == REGNO (operands[0]) + 2
4748 && REGNO (operands[3]) == REGNO (operands[0]) + 3
4749 && (TARGET_H8300SX || REGNO (operands[0]) == 0))"
4750 [(parallel [(set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
4752 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
4754 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -12)))
4756 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -16)))
4758 (set (reg:SI SP_REG)
4759 (plus:SI (reg:SI SP_REG)
4760 (const_int -16)))])]
4764 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4765 (match_operand:SI 0 "register_operand" ""))
4766 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4767 (match_operand:SI 1 "register_operand" ""))
4768 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4769 (match_operand:SI 2 "register_operand" ""))
4770 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4771 (match_operand:SI 3 "register_operand" ""))]
4772 "TARGET_H8300S && TARGET_NORMAL_MODE
4773 && (REGNO_REG_CLASS (REGNO (operands[3])) == GENERAL_REGS
4774 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4775 && REGNO (operands[2]) == REGNO (operands[0]) + 2
4776 && REGNO (operands[3]) == REGNO (operands[0]) + 3
4777 && (TARGET_H8300SX || REGNO (operands[0]) == 0))"
4778 [(parallel [(set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
4780 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
4782 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
4784 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -16)))
4786 (set (reg:HI SP_REG)
4787 (plus:HI (reg:HI SP_REG)
4788 (const_int -16)))])]
4791 ;; Cram three pushes into stm.l.
4794 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4795 (match_operand:SI 0 "register_operand" ""))
4796 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4797 (match_operand:SI 1 "register_operand" ""))
4798 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4799 (match_operand:SI 2 "register_operand" ""))]
4800 "TARGET_H8300S && !TARGET_NORMAL_MODE
4801 && (REGNO_REG_CLASS (REGNO (operands[2])) == GENERAL_REGS
4802 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4803 && REGNO (operands[2]) == REGNO (operands[0]) + 2
4804 && (TARGET_H8300SX || (REGNO (operands[0]) & 3) == 0))"
4805 [(parallel [(set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
4807 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
4809 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -12)))
4811 (set (reg:SI SP_REG)
4812 (plus:SI (reg:SI SP_REG)
4813 (const_int -12)))])]
4817 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4818 (match_operand:SI 0 "register_operand" ""))
4819 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4820 (match_operand:SI 1 "register_operand" ""))
4821 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4822 (match_operand:SI 2 "register_operand" ""))]
4823 "TARGET_H8300S && TARGET_NORMAL_MODE
4824 && (REGNO_REG_CLASS (REGNO (operands[2])) == GENERAL_REGS
4825 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4826 && REGNO (operands[2]) == REGNO (operands[0]) + 2
4827 && (TARGET_H8300SX || (REGNO (operands[0]) & 3) == 0))"
4828 [(parallel [(set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
4830 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
4832 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
4834 (set (reg:HI SP_REG)
4835 (plus:HI (reg:HI SP_REG)
4836 (const_int -12)))])]
4839 ;; Cram two pushes into stm.l.
4842 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4843 (match_operand:SI 0 "register_operand" ""))
4844 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4845 (match_operand:SI 1 "register_operand" ""))]
4846 "TARGET_H8300S && !TARGET_NORMAL_MODE
4847 && (REGNO_REG_CLASS (REGNO (operands[1])) == GENERAL_REGS
4848 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4849 && (TARGET_H8300SX || (REGNO (operands[0]) & 1) == 0))"
4850 [(parallel [(set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
4852 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
4854 (set (reg:SI SP_REG)
4855 (plus:SI (reg:SI SP_REG)
4860 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4861 (match_operand:SI 0 "register_operand" ""))
4862 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4863 (match_operand:SI 1 "register_operand" ""))]
4864 "TARGET_H8300S && TARGET_NORMAL_MODE
4865 && (REGNO_REG_CLASS (REGNO (operands[1])) == GENERAL_REGS
4866 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4867 && (TARGET_H8300SX || (REGNO (operands[0]) & 1) == 0))"
4868 [(parallel [(set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
4870 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
4872 (set (reg:HI SP_REG)
4873 (plus:HI (reg:HI SP_REG)
4880 ;; add.w r7,r0 (6 bytes)
4885 ;; adds #2,r0 (4 bytes)
4888 [(set (match_operand:HI 0 "register_operand" "")
4889 (match_operand:HI 1 "const_int_operand" ""))
4891 (plus:HI (match_dup 0)
4892 (match_operand:HI 2 "register_operand" "")))]
4893 "REG_P (operands[0]) && REG_P (operands[2])
4894 && REGNO (operands[0]) != REGNO (operands[2])
4895 && (satisfies_constraint_J (operands[1])
4896 || satisfies_constraint_L (operands[1])
4897 || satisfies_constraint_N (operands[1]))"
4901 (plus:HI (match_dup 0)
4909 ;; add.l er7,er0 (6 bytes)
4914 ;; adds #4,er0 (4 bytes)
4917 [(set (match_operand:SI 0 "register_operand" "")
4918 (match_operand:SI 1 "const_int_operand" ""))
4920 (plus:SI (match_dup 0)
4921 (match_operand:SI 2 "register_operand" "")))]
4922 "(TARGET_H8300H || TARGET_H8300S)
4923 && REG_P (operands[0]) && REG_P (operands[2])
4924 && REGNO (operands[0]) != REGNO (operands[2])
4925 && (satisfies_constraint_L (operands[1])
4926 || satisfies_constraint_N (operands[1]))"
4930 (plus:SI (match_dup 0)
4937 ;; add.l #10,er0 (takes 8 bytes)
4943 ;; add.l er7,er0 (takes 6 bytes)
4946 [(set (match_operand:SI 0 "register_operand" "")
4947 (match_operand:SI 1 "register_operand" ""))
4949 (plus:SI (match_dup 0)
4950 (match_operand:SI 2 "const_int_operand" "")))]
4951 "(TARGET_H8300H || TARGET_H8300S)
4952 && REG_P (operands[0]) && REG_P (operands[1])
4953 && REGNO (operands[0]) != REGNO (operands[1])
4954 && !satisfies_constraint_L (operands[2])
4955 && !satisfies_constraint_N (operands[2])
4956 && ((INTVAL (operands[2]) & 0xff) == INTVAL (operands[2])
4957 || (INTVAL (operands[2]) & 0xff00) == INTVAL (operands[2])
4958 || INTVAL (operands[2]) == 0xffff
4959 || INTVAL (operands[2]) == 0xfffe)"
4963 (plus:SI (match_dup 0)
4979 [(set (match_operand:HI 0 "register_operand" "")
4980 (plus:HI (match_dup 0)
4981 (match_operand 1 "incdec_operand" "")))
4982 (set (cc0) (compare (match_dup 0)
4985 (if_then_else (match_operator 3 "eqne_operator"
4986 [(cc0) (const_int 0)])
4987 (label_ref (match_operand 2 "" ""))
4989 "TARGET_H8300H || TARGET_H8300S"
4990 [(set (match_operand:HI 0 "register_operand" "")
4991 (unspec:HI [(match_dup 0)
4994 (set (cc0) (compare (match_dup 0)
4997 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4998 (label_ref (match_dup 2))
5002 ;; The SImode version of the previous pattern.
5005 [(set (match_operand:SI 0 "register_operand" "")
5006 (plus:SI (match_dup 0)
5007 (match_operand 1 "incdec_operand" "")))
5008 (set (cc0) (compare (match_dup 0)
5011 (if_then_else (match_operator 3 "eqne_operator"
5012 [(cc0) (const_int 0)])
5013 (label_ref (match_operand 2 "" ""))
5015 "TARGET_H8300H || TARGET_H8300S"
5016 [(set (match_operand:SI 0 "register_operand" "")
5017 (unspec:SI [(match_dup 0)
5020 (set (cc0) (compare (match_dup 0)
5023 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5024 (label_ref (match_dup 2))
5029 [(parallel [(set (cc0)
5030 (compare (zero_extract:SI (match_operand:QI 0 "register_operand" "")
5034 (clobber (scratch:QI))])
5036 (if_then_else (match_operator 1 "eqne_operator"
5037 [(cc0) (const_int 0)])
5038 (label_ref (match_operand 2 "" ""))
5040 "TARGET_H8300H || TARGET_H8300S"
5041 [(set (cc0) (compare (match_dup 0)
5044 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5045 (label_ref (match_dup 2))
5048 operands[3] = ((GET_CODE (operands[1]) == EQ)
5049 ? gen_rtx_GE (VOIDmode, cc0_rtx, const0_rtx)
5050 : gen_rtx_LT (VOIDmode, cc0_rtx, const0_rtx));
5053 ;; The next three peephole2's will try to transform
5055 ;; mov.b A,r0l (or mov.l A,er0)
5062 ;; and.b #CST,r0l (if CST is not 255)
5065 [(set (match_operand:QI 0 "register_operand" "")
5066 (match_operand:QI 1 "general_operand" ""))
5067 (set (match_operand:SI 2 "register_operand" "")
5068 (and:SI (match_dup 2)
5070 "(TARGET_H8300H || TARGET_H8300S)
5071 && !reg_overlap_mentioned_p (operands[2], operands[1])
5072 && REGNO (operands[0]) == REGNO (operands[2])"
5075 (set (strict_low_part (match_dup 0))
5080 [(set (match_operand:SI 0 "register_operand" "")
5081 (match_operand:SI 1 "general_operand" ""))
5083 (and:SI (match_dup 0)
5085 "(TARGET_H8300H || TARGET_H8300S)
5086 && !reg_overlap_mentioned_p (operands[0], operands[1])
5087 && !(GET_CODE (operands[1]) == MEM && !offsettable_memref_p (operands[1]))
5088 && !(GET_CODE (operands[1]) == MEM && MEM_VOLATILE_P (operands[1]))"
5091 (set (strict_low_part (match_dup 2))
5094 operands[2] = gen_lowpart (QImode, operands[0]);
5095 operands[3] = gen_lowpart (QImode, operands[1]);
5099 [(set (match_operand 0 "register_operand" "")
5100 (match_operand 1 "general_operand" ""))
5101 (set (match_operand:SI 2 "register_operand" "")
5102 (and:SI (match_dup 2)
5103 (match_operand:SI 3 "const_int_qi_operand" "")))]
5104 "(TARGET_H8300H || TARGET_H8300S)
5105 && (GET_MODE (operands[0]) == QImode
5106 || GET_MODE (operands[0]) == HImode
5107 || GET_MODE (operands[0]) == SImode)
5108 && GET_MODE (operands[0]) == GET_MODE (operands[1])
5109 && REGNO (operands[0]) == REGNO (operands[2])
5110 && !reg_overlap_mentioned_p (operands[2], operands[1])
5111 && !(GET_MODE (operands[1]) != QImode
5112 && GET_CODE (operands[1]) == MEM
5113 && !offsettable_memref_p (operands[1]))
5114 && !(GET_MODE (operands[1]) != QImode
5115 && GET_CODE (operands[1]) == MEM
5116 && MEM_VOLATILE_P (operands[1]))"
5119 (set (strict_low_part (match_dup 4))
5122 (and:SI (match_dup 2)
5125 operands[4] = gen_lowpart (QImode, operands[0]);
5126 operands[5] = gen_lowpart (QImode, operands[1]);
5127 operands[6] = GEN_INT (~0xff | INTVAL (operands[3]));
5131 [(set (match_operand:SI 0 "register_operand" "")
5132 (match_operand:SI 1 "register_operand" ""))
5134 (and:SI (match_dup 0)
5135 (const_int 65280)))]
5136 "(TARGET_H8300H || TARGET_H8300S)
5137 && !reg_overlap_mentioned_p (operands[0], operands[1])"
5140 (set (zero_extract:SI (match_dup 0)
5143 (lshiftrt:SI (match_dup 1)
5147 ;; If a load of mem:SI is followed by an AND that turns off the upper
5148 ;; half, then we can load mem:HI instead.
5151 [(set (match_operand:SI 0 "register_operand" "")
5152 (match_operand:SI 1 "memory_operand" ""))
5154 (and:SI (match_dup 0)
5155 (match_operand:SI 2 "const_int_operand" "")))]
5156 "(TARGET_H8300H || TARGET_H8300S)
5157 && !MEM_VOLATILE_P (operands[1])
5158 && offsettable_memref_p (operands[1])
5159 && (INTVAL (operands[2]) & ~0xffff) == 0
5160 && INTVAL (operands[2]) != 255"
5164 (and:SI (match_dup 0)
5167 operands[3] = gen_lowpart (HImode, operands[0]);
5168 operands[4] = gen_lowpart (HImode, operands[1]);
5171 ;; Convert a memory comparison to a move if there is a scratch register.
5174 [(match_scratch:QI 1 "r")
5176 (compare (match_operand:QI 0 "memory_operand" "")
5181 (set (cc0) (compare (match_dup 1)
5186 [(match_scratch:HI 1 "r")
5188 (compare (match_operand:HI 0 "memory_operand" "")
5190 "TARGET_H8300H || TARGET_H8300S"
5193 (set (cc0) (compare (match_dup 1)
5198 [(match_scratch:SI 1 "r")
5200 (compare (match_operand:SI 0 "memory_operand" "")
5202 "TARGET_H8300H || TARGET_H8300S"
5205 (set (cc0) (compare (match_dup 1)
5210 ;; (compare (reg:HI) (const_int)) takes 4 bytes, so we try to achieve
5211 ;; the equivalent with shorter sequences. Here is the summary. Cases
5212 ;; are grouped for each define_peephole2.
5214 ;; reg const_int use insn
5215 ;; --------------------------------------------------------
5216 ;; dead -2 eq/ne inc.l
5217 ;; dead -1 eq/ne inc.l
5218 ;; dead 1 eq/ne dec.l
5219 ;; dead 2 eq/ne dec.l
5221 ;; dead 1 ge/lt shar.l
5222 ;; dead 3 (H8S) ge/lt shar.l
5224 ;; dead 1 geu/ltu shar.l
5225 ;; dead 3 (H8S) geu/ltu shar.l
5227 ;; ---- 255 ge/lt mov.b
5229 ;; ---- 255 geu/ltu mov.b
5243 (compare (match_operand:HI 0 "register_operand" "")
5244 (match_operand:HI 1 "incdec_operand" "")))
5246 (if_then_else (match_operator 3 "eqne_operator"
5247 [(cc0) (const_int 0)])
5248 (label_ref (match_operand 2 "" ""))
5250 "(TARGET_H8300H || TARGET_H8300S)
5251 && INTVAL (operands[1]) != 0
5252 && peep2_reg_dead_p (1, operands[0])"
5254 (unspec:HI [(match_dup 0)
5257 (set (cc0) (compare (match_dup 0)
5260 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5261 (label_ref (match_dup 2))
5264 operands[4] = GEN_INT (- INTVAL (operands[1]));
5279 (compare (match_operand:HI 0 "register_operand" "")
5280 (match_operand:HI 1 "const_int_operand" "")))
5282 (if_then_else (match_operator 2 "gtle_operator"
5283 [(cc0) (const_int 0)])
5284 (label_ref (match_operand 3 "" ""))
5286 "(TARGET_H8300H || TARGET_H8300S)
5287 && peep2_reg_dead_p (1, operands[0])
5288 && (INTVAL (operands[1]) == 1
5289 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
5290 [(parallel [(set (match_dup 0)
5291 (ashiftrt:HI (match_dup 0)
5293 (clobber (scratch:QI))])
5294 (set (cc0) (compare (match_dup 0)
5297 (if_then_else (match_dup 2)
5298 (label_ref (match_dup 3))
5301 operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
5316 (compare (match_operand:HI 0 "register_operand" "")
5317 (match_operand:HI 1 "const_int_operand" "")))
5319 (if_then_else (match_operator 2 "gtuleu_operator"
5320 [(cc0) (const_int 0)])
5321 (label_ref (match_operand 3 "" ""))
5323 "(TARGET_H8300H || TARGET_H8300S)
5324 && peep2_reg_dead_p (1, operands[0])
5325 && (INTVAL (operands[1]) == 1
5326 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
5327 [(parallel [(set (match_dup 0)
5328 (ashiftrt:HI (match_dup 0)
5330 (clobber (scratch:QI))])
5331 (set (cc0) (compare (match_dup 0)
5334 (if_then_else (match_dup 5)
5335 (label_ref (match_dup 3))
5338 operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
5339 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
5340 VOIDmode, cc0_rtx, const0_rtx);
5355 (compare (match_operand:HI 0 "register_operand" "")
5358 (if_then_else (match_operator 1 "gtle_operator"
5359 [(cc0) (const_int 0)])
5360 (label_ref (match_operand 2 "" ""))
5362 "TARGET_H8300H || TARGET_H8300S"
5363 [(set (cc0) (compare (and:HI (match_dup 0)
5367 (if_then_else (match_dup 1)
5368 (label_ref (match_dup 2))
5384 (compare (match_operand:HI 0 "register_operand" "")
5387 (if_then_else (match_operator 1 "gtuleu_operator"
5388 [(cc0) (const_int 0)])
5389 (label_ref (match_operand 2 "" ""))
5391 "TARGET_H8300H || TARGET_H8300S"
5392 [(set (cc0) (compare (and:HI (match_dup 0)
5396 (if_then_else (match_dup 3)
5397 (label_ref (match_dup 2))
5400 operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[1]) == GTU ? NE : EQ,
5401 VOIDmode, cc0_rtx, const0_rtx);
5404 ;; (compare (reg:SI) (const_int)) takes 6 bytes, so we try to achieve
5405 ;; the equivalent with shorter sequences. Here is the summary. Cases
5406 ;; are grouped for each define_peephole2.
5408 ;; reg const_int use insn
5409 ;; --------------------------------------------------------
5410 ;; live -2 eq/ne copy and inc.l
5411 ;; live -1 eq/ne copy and inc.l
5412 ;; live 1 eq/ne copy and dec.l
5413 ;; live 2 eq/ne copy and dec.l
5415 ;; dead -2 eq/ne inc.l
5416 ;; dead -1 eq/ne inc.l
5417 ;; dead 1 eq/ne dec.l
5418 ;; dead 2 eq/ne dec.l
5420 ;; dead -131072 eq/ne inc.w and test
5421 ;; dead -65536 eq/ne inc.w and test
5422 ;; dead 65536 eq/ne dec.w and test
5423 ;; dead 131072 eq/ne dec.w and test
5425 ;; dead 0x000000?? except 1 and 2 eq/ne xor.b and test
5426 ;; dead 0x0000??00 eq/ne xor.b and test
5427 ;; dead 0x0000ffff eq/ne not.w and test
5429 ;; dead 0xffffff?? except -1 and -2 eq/ne xor.b and not.l
5430 ;; dead 0xffff??ff eq/ne xor.b and not.l
5431 ;; dead 0x40000000 (H8S) eq/ne rotl.l and dec.l
5432 ;; dead 0x80000000 eq/ne rotl.l and dec.l
5434 ;; live 1 ge/lt copy and shar.l
5435 ;; live 3 (H8S) ge/lt copy and shar.l
5437 ;; live 1 geu/ltu copy and shar.l
5438 ;; live 3 (H8S) geu/ltu copy and shar.l
5440 ;; dead 1 ge/lt shar.l
5441 ;; dead 3 (H8S) ge/lt shar.l
5443 ;; dead 1 geu/ltu shar.l
5444 ;; dead 3 (H8S) geu/ltu shar.l
5446 ;; dead 3 (H8/300H) ge/lt and.b and test
5447 ;; dead 7 ge/lt and.b and test
5448 ;; dead 15 ge/lt and.b and test
5449 ;; dead 31 ge/lt and.b and test
5450 ;; dead 63 ge/lt and.b and test
5451 ;; dead 127 ge/lt and.b and test
5452 ;; dead 255 ge/lt and.b and test
5454 ;; dead 3 (H8/300H) geu/ltu and.b and test
5455 ;; dead 7 geu/ltu and.b and test
5456 ;; dead 15 geu/ltu and.b and test
5457 ;; dead 31 geu/ltu and.b and test
5458 ;; dead 63 geu/ltu and.b and test
5459 ;; dead 127 geu/ltu and.b and test
5460 ;; dead 255 geu/ltu and.b and test
5462 ;; ---- 65535 ge/lt mov.w
5464 ;; ---- 65535 geu/ltu mov.w
5478 (compare (match_operand:SI 0 "register_operand" "")
5479 (match_operand:SI 1 "incdec_operand" "")))
5481 (if_then_else (match_operator 3 "eqne_operator"
5482 [(cc0) (const_int 0)])
5483 (label_ref (match_operand 2 "" ""))
5485 "(TARGET_H8300H || TARGET_H8300S)
5486 && INTVAL (operands[1]) != 0
5487 && peep2_reg_dead_p (1, operands[0])"
5489 (unspec:SI [(match_dup 0)
5492 (set (cc0) (compare (match_dup 0)
5495 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5496 (label_ref (match_dup 2))
5499 operands[4] = GEN_INT (- INTVAL (operands[1]));
5514 (compare (match_operand:SI 0 "register_operand" "")
5515 (match_operand:SI 1 "const_int_operand" "")))
5517 (if_then_else (match_operator 3 "eqne_operator"
5518 [(cc0) (const_int 0)])
5519 (label_ref (match_operand 2 "" ""))
5521 "(TARGET_H8300H || TARGET_H8300S)
5522 && peep2_reg_dead_p (1, operands[0])
5523 && (INTVAL (operands[1]) == -131072
5524 || INTVAL (operands[1]) == -65536
5525 || INTVAL (operands[1]) == 65536
5526 || INTVAL (operands[1]) == 131072)"
5528 (plus:SI (match_dup 0)
5530 (set (cc0) (compare (match_dup 0)
5533 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5534 (label_ref (match_dup 2))
5537 operands[4] = GEN_INT (- INTVAL (operands[1]));
5553 (compare (match_operand:SI 0 "register_operand" "")
5554 (match_operand:SI 1 "const_int_operand" "")))
5556 (if_then_else (match_operator 3 "eqne_operator"
5557 [(cc0) (const_int 0)])
5558 (label_ref (match_operand 2 "" ""))
5560 "(TARGET_H8300H || TARGET_H8300S)
5561 && peep2_reg_dead_p (1, operands[0])
5562 && ((INTVAL (operands[1]) & 0x00ff) == INTVAL (operands[1])
5563 || (INTVAL (operands[1]) & 0xff00) == INTVAL (operands[1])
5564 || INTVAL (operands[1]) == 0x0000ffff)
5565 && INTVAL (operands[1]) != 0
5566 && INTVAL (operands[1]) != 1
5567 && INTVAL (operands[1]) != 2"
5569 (xor:SI (match_dup 0)
5571 (set (cc0) (compare (match_dup 0)
5574 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5575 (label_ref (match_dup 2))
5592 (compare (match_operand:SI 0 "register_operand" "")
5593 (match_operand:SI 1 "const_int_operand" "")))
5595 (if_then_else (match_operator 3 "eqne_operator"
5596 [(cc0) (const_int 0)])
5597 (label_ref (match_operand 2 "" ""))
5599 "(TARGET_H8300H || TARGET_H8300S)
5600 && peep2_reg_dead_p (1, operands[0])
5601 && ((INTVAL (operands[1]) | 0x00ff) == -1
5602 || (INTVAL (operands[1]) | 0xff00) == -1)
5603 && INTVAL (operands[1]) != -1
5604 && INTVAL (operands[1]) != -2"
5606 (xor:SI (match_dup 0)
5609 (not:SI (match_dup 0)))
5610 (set (cc0) (compare (match_dup 0)
5613 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5614 (label_ref (match_dup 2))
5617 operands[4] = GEN_INT (INTVAL (operands[1]) ^ -1);
5622 ;; cmp.l #-2147483648,er0
5633 (compare (match_operand:SI 0 "register_operand" "")
5634 (match_operand:SI 1 "const_int_operand" "")))
5636 (if_then_else (match_operator 3 "eqne_operator"
5637 [(cc0) (const_int 0)])
5638 (label_ref (match_operand 2 "" ""))
5640 "(TARGET_H8300H || TARGET_H8300S)
5641 && peep2_reg_dead_p (1, operands[0])
5642 && (INTVAL (operands[1]) == -2147483647 - 1
5643 || (TARGET_H8300S && INTVAL (operands[1]) == 1073741824))"
5645 (rotate:SI (match_dup 0)
5648 (unspec:SI [(match_dup 0)
5651 (set (cc0) (compare (match_dup 0)
5654 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5655 (label_ref (match_dup 2))
5658 operands[4] = GEN_INT (INTVAL (operands[1]) == -2147483647 - 1 ? 1 : 2);
5672 ;; We avoid this transformation if we see more than one copy of the
5673 ;; same compare insn immediately before this one.
5676 [(match_scratch:SI 4 "r")
5678 (compare (match_operand:SI 0 "register_operand" "")
5679 (match_operand:SI 1 "const_int_operand" "")))
5681 (if_then_else (match_operator 2 "gtle_operator"
5682 [(cc0) (const_int 0)])
5683 (label_ref (match_operand 3 "" ""))
5685 "(TARGET_H8300H || TARGET_H8300S)
5686 && !peep2_reg_dead_p (1, operands[0])
5687 && (INTVAL (operands[1]) == 1
5688 || (TARGET_H8300S && INTVAL (operands[1]) == 3))
5689 && !same_cmp_preceding_p (insn)"
5692 (parallel [(set (match_dup 4)
5693 (ashiftrt:SI (match_dup 4)
5695 (clobber (scratch:QI))])
5696 (set (cc0) (compare (match_dup 4)
5699 (if_then_else (match_dup 2)
5700 (label_ref (match_dup 3))
5703 operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
5717 ;; We avoid this transformation if we see more than one copy of the
5718 ;; same compare insn immediately before this one.
5721 [(match_scratch:SI 4 "r")
5723 (compare (match_operand:SI 0 "register_operand" "")
5724 (match_operand:SI 1 "const_int_operand" "")))
5726 (if_then_else (match_operator 2 "gtuleu_operator"
5727 [(cc0) (const_int 0)])
5728 (label_ref (match_operand 3 "" ""))
5730 "(TARGET_H8300H || TARGET_H8300S)
5731 && !peep2_reg_dead_p (1, operands[0])
5732 && (INTVAL (operands[1]) == 1
5733 || (TARGET_H8300S && INTVAL (operands[1]) == 3))
5734 && !same_cmp_preceding_p (insn)"
5737 (parallel [(set (match_dup 4)
5738 (ashiftrt:SI (match_dup 4)
5740 (clobber (scratch:QI))])
5741 (set (cc0) (compare (match_dup 4)
5744 (if_then_else (match_dup 6)
5745 (label_ref (match_dup 3))
5748 operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
5749 operands[6] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
5750 VOIDmode, cc0_rtx, const0_rtx);
5765 (compare (match_operand:SI 0 "register_operand" "")
5766 (match_operand:SI 1 "const_int_operand" "")))
5768 (if_then_else (match_operator 2 "gtle_operator"
5769 [(cc0) (const_int 0)])
5770 (label_ref (match_operand 3 "" ""))
5772 "(TARGET_H8300H || TARGET_H8300S)
5773 && peep2_reg_dead_p (1, operands[0])
5774 && (INTVAL (operands[1]) == 1
5775 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
5776 [(parallel [(set (match_dup 0)
5777 (ashiftrt:SI (match_dup 0)
5779 (clobber (scratch:QI))])
5780 (set (cc0) (compare (match_dup 0)
5783 (if_then_else (match_dup 2)
5784 (label_ref (match_dup 3))
5787 operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
5802 (compare (match_operand:SI 0 "register_operand" "")
5803 (match_operand:SI 1 "const_int_operand" "")))
5805 (if_then_else (match_operator 2 "gtuleu_operator"
5806 [(cc0) (const_int 0)])
5807 (label_ref (match_operand 3 "" ""))
5809 "(TARGET_H8300H || TARGET_H8300S)
5810 && peep2_reg_dead_p (1, operands[0])
5811 && (INTVAL (operands[1]) == 1
5812 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
5813 [(parallel [(set (match_dup 0)
5814 (ashiftrt:SI (match_dup 0)
5816 (clobber (scratch:QI))])
5817 (set (cc0) (compare (match_dup 0)
5820 (if_then_else (match_dup 5)
5821 (label_ref (match_dup 3))
5824 operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
5825 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
5826 VOIDmode, cc0_rtx, const0_rtx);
5842 (compare (match_operand:SI 0 "register_operand" "")
5843 (match_operand:SI 1 "const_int_operand" "")))
5845 (if_then_else (match_operator 2 "gtle_operator"
5846 [(cc0) (const_int 0)])
5847 (label_ref (match_operand 3 "" ""))
5849 "(TARGET_H8300H || TARGET_H8300S)
5850 && peep2_reg_dead_p (1, operands[0])
5851 && (INTVAL (operands[1]) == 3
5852 || INTVAL (operands[1]) == 7
5853 || INTVAL (operands[1]) == 15
5854 || INTVAL (operands[1]) == 31
5855 || INTVAL (operands[1]) == 63
5856 || INTVAL (operands[1]) == 127
5857 || INTVAL (operands[1]) == 255)"
5859 (and:SI (match_dup 0)
5861 (set (cc0) (compare (match_dup 0)
5864 (if_then_else (match_dup 2)
5865 (label_ref (match_dup 3))
5868 operands[4] = GEN_INT (~INTVAL (operands[1]));
5884 (compare (match_operand:SI 0 "register_operand" "")
5885 (match_operand:SI 1 "const_int_operand" "")))
5887 (if_then_else (match_operator 2 "gtuleu_operator"
5888 [(cc0) (const_int 0)])
5889 (label_ref (match_operand 3 "" ""))
5891 "(TARGET_H8300H || TARGET_H8300S)
5892 && peep2_reg_dead_p (1, operands[0])
5893 && ((TARGET_H8300H && INTVAL (operands[1]) == 3)
5894 || INTVAL (operands[1]) == 7
5895 || INTVAL (operands[1]) == 15
5896 || INTVAL (operands[1]) == 31
5897 || INTVAL (operands[1]) == 63
5898 || INTVAL (operands[1]) == 127
5899 || INTVAL (operands[1]) == 255)"
5901 (and:SI (match_dup 0)
5903 (set (cc0) (compare (match_dup 0)
5906 (if_then_else (match_dup 5)
5907 (label_ref (match_dup 3))
5910 operands[4] = GEN_INT (~INTVAL (operands[1]));
5911 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
5912 VOIDmode, cc0_rtx, const0_rtx);
5927 (compare (match_operand:SI 0 "register_operand" "")
5930 (if_then_else (match_operator 1 "gtle_operator"
5931 [(cc0) (const_int 0)])
5932 (label_ref (match_operand 2 "" ""))
5934 "TARGET_H8300H || TARGET_H8300S"
5935 [(set (cc0) (compare (and:SI (match_dup 0)
5939 (if_then_else (match_dup 1)
5940 (label_ref (match_dup 2))
5956 (compare (match_operand:SI 0 "register_operand" "")
5959 (if_then_else (match_operator 1 "gtuleu_operator"
5960 [(cc0) (const_int 0)])
5961 (label_ref (match_operand 2 "" ""))
5963 "TARGET_H8300H || TARGET_H8300S"
5964 [(set (cc0) (compare (and:SI (match_dup 0)
5968 (if_then_else (match_dup 3)
5969 (label_ref (match_dup 2))
5972 operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[1]) == GTU ? NE : EQ,
5973 VOIDmode, cc0_rtx, const0_rtx);
5987 ;; We avoid this transformation if we see more than one copy of the
5988 ;; same compare insn.
5991 [(match_scratch:SI 4 "r")
5993 (compare (match_operand:SI 0 "register_operand" "")
5994 (match_operand:SI 1 "incdec_operand" "")))
5996 (if_then_else (match_operator 3 "eqne_operator"
5997 [(cc0) (const_int 0)])
5998 (label_ref (match_operand 2 "" ""))
6000 "(TARGET_H8300H || TARGET_H8300S)
6001 && INTVAL (operands[1]) != 0
6002 && !peep2_reg_dead_p (1, operands[0])
6003 && !same_cmp_following_p (insn)"
6007 (unspec:SI [(match_dup 4)
6010 (set (cc0) (compare (match_dup 4)
6013 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
6014 (label_ref (match_dup 2))
6017 operands[5] = GEN_INT (- INTVAL (operands[1]));
6019 ;; Narrow the mode of testing if possible.
6022 [(set (match_operand:HI 0 "register_operand" "")
6023 (and:HI (match_dup 0)
6024 (match_operand:HI 1 "const_int_qi_operand" "")))
6025 (set (cc0) (compare (match_dup 0)
6028 (if_then_else (match_operator 3 "eqne_operator"
6029 [(cc0) (const_int 0)])
6030 (label_ref (match_operand 2 "" ""))
6032 "peep2_reg_dead_p (2, operands[0])"
6034 (and:QI (match_dup 4)
6036 (set (cc0) (compare (match_dup 4)
6039 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
6040 (label_ref (match_dup 2))
6043 operands[4] = gen_rtx_REG (QImode, REGNO (operands[0]));
6044 operands[5] = gen_int_mode (INTVAL (operands[1]), QImode);
6048 [(set (match_operand:SI 0 "register_operand" "")
6049 (and:SI (match_dup 0)
6050 (match_operand:SI 1 "const_int_qi_operand" "")))
6051 (set (cc0) (compare (match_dup 0)
6054 (if_then_else (match_operator 3 "eqne_operator"
6055 [(cc0) (const_int 0)])
6056 (label_ref (match_operand 2 "" ""))
6058 "peep2_reg_dead_p (2, operands[0])"
6060 (and:QI (match_dup 4)
6062 (set (cc0) (compare (match_dup 4)
6065 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
6066 (label_ref (match_dup 2))
6069 operands[4] = gen_rtx_REG (QImode, REGNO (operands[0]));
6070 operands[5] = gen_int_mode (INTVAL (operands[1]), QImode);
6074 [(set (match_operand:SI 0 "register_operand" "")
6075 (and:SI (match_dup 0)
6076 (match_operand:SI 1 "const_int_hi_operand" "")))
6077 (set (cc0) (compare (match_dup 0)
6080 (if_then_else (match_operator 3 "eqne_operator"
6081 [(cc0) (const_int 0)])
6082 (label_ref (match_operand 2 "" ""))
6084 "peep2_reg_dead_p (2, operands[0])"
6086 (and:HI (match_dup 4)
6088 (set (cc0) (compare (match_dup 4)
6091 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
6092 (label_ref (match_dup 2))
6095 operands[4] = gen_rtx_REG (HImode, REGNO (operands[0]));
6096 operands[5] = gen_int_mode (INTVAL (operands[1]), HImode);
6100 [(set (match_operand:SI 0 "register_operand" "")
6101 (and:SI (match_dup 0)
6102 (match_operand:SI 1 "const_int_qi_operand" "")))
6104 (xor:SI (match_dup 0)
6105 (match_operand:SI 2 "const_int_qi_operand" "")))
6106 (set (cc0) (compare (match_dup 0)
6109 (if_then_else (match_operator 4 "eqne_operator"
6110 [(cc0) (const_int 0)])
6111 (label_ref (match_operand 3 "" ""))
6113 "peep2_reg_dead_p (3, operands[0])
6114 && (~INTVAL (operands[1]) & INTVAL (operands[2])) == 0"
6116 (and:QI (match_dup 5)
6119 (xor:QI (match_dup 5)
6121 (set (cc0) (compare (match_dup 5)
6124 (if_then_else (match_op_dup 4 [(cc0) (const_int 0)])
6125 (label_ref (match_dup 3))
6128 operands[5] = gen_rtx_REG (QImode, REGNO (operands[0]));
6129 operands[6] = gen_int_mode (INTVAL (operands[1]), QImode);
6130 operands[7] = gen_int_mode (INTVAL (operands[2]), QImode);
6133 ;; These triggers right at the end of allocation of locals in the
6134 ;; prologue (and possibly at other places).
6136 ;; stack adjustment of -4, generate one push
6138 ;; before : 6 bytes, 10 clocks
6139 ;; after : 4 bytes, 10 clocks
6142 [(set (reg:SI SP_REG)
6143 (plus:SI (reg:SI SP_REG)
6145 (set (mem:SI (reg:SI SP_REG))
6146 (match_operand:SI 0 "register_operand" ""))]
6147 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE
6148 && REGNO (operands[0]) != SP_REG"
6149 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
6153 ;; stack adjustment of -12, generate one push
6155 ;; before : 10 bytes, 14 clocks
6156 ;; after : 8 bytes, 14 clocks
6159 [(set (reg:SI SP_REG)
6160 (plus:SI (reg:SI SP_REG)
6162 (set (mem:SI (reg:SI SP_REG))
6163 (match_operand:SI 0 "register_operand" ""))]
6164 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE
6165 && REGNO (operands[0]) != SP_REG"
6166 [(set (reg:SI SP_REG)
6167 (plus:SI (reg:SI SP_REG)
6169 (set (reg:SI SP_REG)
6170 (plus:SI (reg:SI SP_REG)
6172 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
6186 ;; if "reg" dies at the end of the sequence.
6189 [(set (match_operand 0 "register_operand" "")
6190 (match_operand 1 "memory_operand" ""))
6192 (match_operator 2 "h8sx_binary_memory_operator"
6194 (match_operand 3 "h8300_src_operand" "")]))
6195 (set (match_operand 4 "memory_operand" "")
6197 "0 /* Disable because it breaks compiling fp-bit.c. */
6199 && peep2_reg_dead_p (3, operands[0])
6200 && !reg_overlap_mentioned_p (operands[0], operands[3])
6201 && !reg_overlap_mentioned_p (operands[0], operands[4])
6202 && h8sx_mergeable_memrefs_p (operands[4], operands[1])"
6206 operands[5] = shallow_copy_rtx (operands[2]);
6207 XEXP (operands[5], 0) = operands[1];
6219 ;; if "reg" dies in the second insn.
6222 [(set (match_operand 0 "register_operand" "")
6223 (match_operand 1 "h8300_src_operand" ""))
6224 (set (match_operand 2 "h8300_dst_operand" "")
6225 (match_operator 3 "h8sx_binary_memory_operator"
6226 [(match_operand 4 "h8300_dst_operand" "")
6228 "0 /* Disable because it breaks compiling fp-bit.c. */
6230 && peep2_reg_dead_p (2, operands[0])
6231 && !reg_overlap_mentioned_p (operands[0], operands[4])"
6235 operands[5] = shallow_copy_rtx (operands[3]);
6236 XEXP (operands[5], 1) = operands[1];
6249 ;; if "reg" dies at the end of the sequence.
6252 [(set (match_operand 0 "register_operand" "")
6253 (match_operand 1 "memory_operand" ""))
6255 (match_operator 2 "h8sx_unary_memory_operator"
6257 (set (match_operand 3 "memory_operand" "")
6260 && peep2_reg_dead_p (3, operands[0])
6261 && !reg_overlap_mentioned_p (operands[0], operands[3])
6262 && h8sx_mergeable_memrefs_p (operands[3], operands[1])"
6266 operands[4] = shallow_copy_rtx (operands[2]);
6267 XEXP (operands[4], 0) = operands[1];
6279 ;; if "reg" dies in the comparison.
6282 [(set (match_operand 0 "register_operand" "")
6283 (match_operand 1 "h8300_dst_operand" ""))
6285 (compare (match_dup 0)
6286 (match_operand 2 "h8300_src_operand" "")))]
6288 && peep2_reg_dead_p (2, operands[0])
6289 && !reg_overlap_mentioned_p (operands[0], operands[2])
6290 && operands[2] != const0_rtx"
6292 (compare (match_dup 1)
6295 ;; Likewise for the second operand.
6298 [(set (match_operand 0 "register_operand" "")
6299 (match_operand 1 "h8300_src_operand" ""))
6301 (compare (match_operand 2 "h8300_dst_operand" "")
6304 && peep2_reg_dead_p (2, operands[0])
6305 && !reg_overlap_mentioned_p (operands[0], operands[2])"
6307 (compare (match_dup 2)
6310 ;; Combine two moves.
6313 [(set (match_operand 0 "register_operand" "")
6314 (match_operand 1 "h8300_src_operand" ""))
6315 (set (match_operand 2 "h8300_dst_operand" "")
6318 && peep2_reg_dead_p (2, operands[0])
6319 && !reg_overlap_mentioned_p (operands[0], operands[2])"