1 ;; GCC machine description for Hitachi H8/300
2 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 ;; 2001, 2002, 2003 Free Software Foundation, Inc.
5 ;; Contributed by Steve Chamberlain (sac@cygnus.com),
6 ;; Jim Wilson (wilson@cygnus.com), and Doug Evans (dje@cygnus.com).
8 ;; This file is part of GCC.
10 ;; GCC is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GCC is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GCC; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
25 ;; We compute exact length on each instruction for most of the time.
26 ;; In some case, most notably bit operations that may involve memory
27 ;; operands, the lengths in this file are "worst case".
29 ;; On the H8/300H and H8S, adds/subs operate on the 32bit "er"
30 ;; registers. Right now GCC doesn't expose the "e" half to the
31 ;; compiler, so using add/subs for addhi and subhi is safe. Long
32 ;; term, we want to expose the "e" half to the compiler (gives us 8
33 ;; more 16bit registers). At that point addhi and subhi can't use
36 ;; There's currently no way to have an insv/extzv expander for the H8/300H
37 ;; because word_mode is different for the H8/300 and H8/300H.
39 ;; Shifts/rotates by small constants should be handled by special
40 ;; patterns so we get the length and cc status correct.
42 ;; Bitfield operations no longer accept memory operands. We need
43 ;; to add variants which operate on memory back to the MD.
45 ;; ??? Implement remaining bit ops available on the h8300
47 ;; ----------------------------------------------------------------------
49 ;; ----------------------------------------------------------------------
63 ;; ----------------------------------------------------------------------
65 ;; ----------------------------------------------------------------------
67 (define_attr "cpu" "h8300,h8300h"
68 (const (symbol_ref "cpu_type")))
70 (define_attr "type" "branch,arith"
71 (const_string "arith"))
73 ;; The size of instructions in bytes.
75 (define_attr "length" ""
76 (cond [(eq_attr "type" "branch")
77 (if_then_else (and (ge (minus (match_dup 0) (pc))
79 (le (minus (match_dup 0) (pc))
82 (if_then_else (and (eq_attr "cpu" "h8300h")
83 (and (ge (minus (pc) (match_dup 0))
85 (le (minus (pc) (match_dup 0))
91 ;; Condition code settings.
93 ;; none - insn does not affect cc
94 ;; none_0hit - insn does not affect cc but it does modify operand 0
95 ;; This attribute is used to keep track of when operand 0 changes.
96 ;; See the description of NOTICE_UPDATE_CC for more info.
97 ;; set_znv - insn sets z,n,v to usable values (like a tst insn); c is unknown.
98 ;; set_zn - insn sets z,n to usable values; v,c are unknown.
99 ;; compare - compare instruction
100 ;; clobber - value of cc is unknown
102 (define_attr "cc" "none,none_0hit,set_znv,set_zn,compare,clobber"
103 (const_string "clobber"))
105 ;; Provide the maximum length of an assembly instruction in an asm
106 ;; statement. The maximum length of 14 bytes is achieved on H8SX.
108 (define_asm_attributes
109 [(set (attr "length")
110 (cond [(ne (symbol_ref "TARGET_H8300") (const_int 0)) (const_int 4)
111 (ne (symbol_ref "TARGET_H8300H") (const_int 0)) (const_int 10)
112 (ne (symbol_ref "TARGET_H8300S") (const_int 0)) (const_int 10)]
115 ;; ----------------------------------------------------------------------
117 ;; ----------------------------------------------------------------------
121 (define_insn "pushqi1_h8300"
122 [(parallel [(set (reg:HI SP_REG)
123 (plus:HI (reg:HI SP_REG) (const_int -2)))
124 (set (mem:QI (plus:HI (reg:HI SP_REG) (const_int -1)))
125 (match_operand:QI 0 "register_operand" "r"))])]
127 && operands[0] != stack_pointer_rtx"
129 [(set_attr "length" "2")
130 (set_attr "cc" "clobber")])
132 (define_insn "pushqi1_h8300hs"
133 [(parallel [(set (reg:SI SP_REG)
134 (plus:SI (reg:SI SP_REG) (const_int -4)))
135 (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int -3)))
136 (match_operand:QI 0 "register_operand" "r"))])]
137 "(TARGET_H8300H || TARGET_H8300S)
138 && operands[0] != stack_pointer_rtx"
140 [(set_attr "length" "4")
141 (set_attr "cc" "clobber")])
143 (define_insn "pushqi1_h8300hs_normal"
144 [(parallel [(set (reg:HI SP_REG)
145 (plus:HI (reg:HI SP_REG) (const_int -4)))
146 (set (mem:QI (plus:HI (reg:HI SP_REG) (const_int -3)))
147 (match_operand:QI 0 "register_operand" "r"))])]
148 "(TARGET_H8300H || TARGET_H8300S)
149 && operands[0] != stack_pointer_rtx"
151 [(set_attr "length" "4")
152 (set_attr "cc" "clobber")])
154 (define_expand "pushqi1"
155 [(use (match_operand:QI 0 "register_operand" ""))]
160 emit_insn (gen_pushqi1_h8300 (operands[0]));
161 else if (!TARGET_NORMAL_MODE)
162 emit_insn (gen_pushqi1_h8300hs (operands[0]));
164 emit_insn (gen_pushqi1_h8300hs_normal (operands[0]));
168 (define_insn "*movqi_h8300"
169 [(set (match_operand:QI 0 "general_operand_dst" "=r,r ,<,r,r,m")
170 (match_operand:QI 1 "general_operand_src" " I,r>,r,n,m,r"))]
172 && (register_operand (operands[0], QImode)
173 || register_operand (operands[1], QImode))"
181 [(set_attr "length" "2,2,2,2,4,4")
182 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
184 (define_insn "*movqi_h8300hs"
185 [(set (match_operand:QI 0 "general_operand_dst" "=r,r ,<,r,r,m")
186 (match_operand:QI 1 "general_operand_src" " I,r>,r,n,m,r"))]
187 "(TARGET_H8300H || TARGET_H8300S)
188 && (register_operand (operands[0], QImode)
189 || register_operand (operands[1], QImode))"
197 [(set (attr "length")
198 (symbol_ref "compute_mov_length (operands)"))
199 (set_attr "cc" "set_zn,set_znv,set_znv,clobber,set_znv,set_znv")])
201 (define_expand "movqi"
202 [(set (match_operand:QI 0 "general_operand_dst" "")
203 (match_operand:QI 1 "general_operand_src" ""))]
207 /* One of the ops has to be in a register. */
208 if (!register_operand (operand0, QImode)
209 && !register_operand (operand1, QImode))
211 operands[1] = copy_to_mode_reg (QImode, operand1);
215 (define_insn "movstrictqi"
216 [(set (strict_low_part (match_operand:QI 0 "general_operand_dst" "+r,r,r,r"))
217 (match_operand:QI 1 "general_operand_src" "I,r,n,m"))]
224 [(set (attr "length")
225 (symbol_ref "compute_mov_length (operands)"))
226 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv")])
230 (define_expand "pushhi1_h8300"
231 [(set (mem:HI (pre_dec:HI (reg:HI SP_REG)))
232 (match_operand:HI 0 "register_operand" ""))]
234 && operands[0] != stack_pointer_rtx"
237 (define_insn "pushhi1_h8300hs"
238 [(parallel [(set (reg:SI SP_REG)
239 (plus:SI (reg:SI SP_REG) (const_int -4)))
240 (set (mem:HI (plus:SI (reg:SI SP_REG) (const_int -2)))
241 (match_operand:HI 0 "register_operand" "r"))])]
242 "(TARGET_H8300H || TARGET_H8300S)
243 && operands[0] != stack_pointer_rtx"
245 [(set_attr "length" "4")
246 (set_attr "cc" "clobber")])
248 (define_insn "pushhi1_h8300hs_normal"
249 [(parallel [(set (reg:HI SP_REG)
250 (plus:HI (reg:HI SP_REG) (const_int -4)))
251 (set (mem:HI (plus:HI (reg:HI SP_REG) (const_int -2)))
252 (match_operand:HI 0 "register_operand" "r"))])]
253 "(TARGET_H8300H || TARGET_H8300S)
254 && operands[0] != stack_pointer_rtx"
256 [(set_attr "length" "4")
257 (set_attr "cc" "clobber")])
259 (define_expand "pushhi1"
260 [(use (match_operand:HI 0 "register_operand" ""))]
265 emit_insn (gen_pushhi1_h8300 (operands[0]));
266 else if (!TARGET_NORMAL_MODE)
267 emit_insn (gen_pushhi1_h8300hs (operands[0]));
269 emit_insn (gen_pushhi1_h8300hs_normal (operands[0]));
273 (define_insn "*movhi_h8300"
274 [(set (match_operand:HI 0 "general_operand_dst" "=r,r,<,r,r,m")
275 (match_operand:HI 1 "general_operand_src" "I,r>,r,i,m,r"))]
277 && (register_operand (operands[0], HImode)
278 || register_operand (operands[1], HImode))
279 && !(GET_CODE (operands[0]) == MEM
280 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
281 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
282 && GET_CODE (operands[1]) == REG
283 && REGNO (XEXP (XEXP (operands[0], 0), 0)) == REGNO (operands[1]))"
291 [(set (attr "length")
292 (symbol_ref "compute_mov_length (operands)"))
293 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
295 (define_insn "*movhi_h8300hs"
296 [(set (match_operand:HI 0 "general_operand_dst" "=r,r,<,r,r,m")
297 (match_operand:HI 1 "general_operand_src" "I,r>,r,i,m,r"))]
298 "(TARGET_H8300H || TARGET_H8300S)
299 && (register_operand (operands[0], HImode)
300 || register_operand (operands[1], HImode))"
308 [(set (attr "length")
309 (symbol_ref "compute_mov_length (operands)"))
310 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
312 (define_expand "movhi"
313 [(set (match_operand:HI 0 "general_operand_dst" "")
314 (match_operand:HI 1 "general_operand_src" ""))]
318 /* One of the ops has to be in a register. */
319 if (!register_operand (operand1, HImode)
320 && !register_operand (operand0, HImode))
322 operands[1] = copy_to_mode_reg (HImode, operand1);
326 (define_insn "movstricthi"
327 [(set (strict_low_part (match_operand:HI 0 "general_operand_dst" "+r,r,r,r"))
328 (match_operand:HI 1 "general_operand_src" "I,r,i,m"))]
335 [(set (attr "length")
336 (symbol_ref "compute_mov_length (operands)"))
337 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv")])
341 (define_expand "movsi"
342 [(set (match_operand:SI 0 "general_operand_dst" "")
343 (match_operand:SI 1 "general_operand_src" ""))]
349 if (do_movsi (operands))
354 /* One of the ops has to be in a register. */
355 if (!register_operand (operand1, SImode)
356 && !register_operand (operand0, SImode))
358 operands[1] = copy_to_mode_reg (SImode, operand1);
363 (define_expand "movsf"
364 [(set (match_operand:SF 0 "general_operand_dst" "")
365 (match_operand:SF 1 "general_operand_src" ""))]
371 if (do_movsi (operands))
376 /* One of the ops has to be in a register. */
377 if (!register_operand (operand1, SFmode)
378 && !register_operand (operand0, SFmode))
380 operands[1] = copy_to_mode_reg (SFmode, operand1);
385 (define_insn "*movsi_h8300"
386 [(set (match_operand:SI 0 "general_operand_dst" "=r,r,r,o,<,r")
387 (match_operand:SI 1 "general_operand_src" "I,r,io,r,r,>"))]
389 && (register_operand (operands[0], SImode)
390 || register_operand (operands[1], SImode))"
393 unsigned int rn = -1;
394 switch (which_alternative)
397 return \"sub.w %e0,%e0\;sub.w %f0,%f0\";
399 if (REGNO (operands[0]) < REGNO (operands[1]))
400 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
402 return \"mov.w %f1,%f0\;mov.w %e1,%e0\";
404 /* Make sure we don't trample the register we index with. */
405 if (GET_CODE (operands[1]) == MEM)
407 rtx inside = XEXP (operands[1], 0);
412 else if (GET_CODE (inside) == PLUS)
414 rtx lhs = XEXP (inside, 0);
415 rtx rhs = XEXP (inside, 1);
416 if (REG_P (lhs)) rn = REGNO (lhs);
417 if (REG_P (rhs)) rn = REGNO (rhs);
420 if (rn == REGNO (operands[0]))
422 /* Move the second word first. */
423 return \"mov.w %f1,%f0\;mov.w %e1,%e0\";
427 if (GET_CODE (operands[1]) == CONST_INT)
429 /* If either half is zero, use sub.w to clear that
431 if ((INTVAL (operands[1]) & 0xffff) == 0)
432 return \"mov.w %e1,%e0\;sub.w %f0,%f0\";
433 if (((INTVAL (operands[1]) >> 16) & 0xffff) == 0)
434 return \"sub.w %e0,%e0\;mov.w %f1,%f0\";
435 /* If the upper half and the lower half are the same,
436 copy one half to the other. */
437 if ((INTVAL (operands[1]) & 0xffff)
438 == ((INTVAL (operands[1]) >> 16) & 0xffff))
439 return \"mov.w\\t%e1,%e0\;mov.w\\t%e0,%f0\";
441 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
444 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
446 return \"mov.w %f1,%T0\;mov.w %e1,%T0\";
448 return \"mov.w %T1,%e0\;mov.w %T1,%f0\";
453 [(set (attr "length")
454 (symbol_ref "compute_mov_length (operands)"))
455 (set_attr "cc" "clobber")])
457 (define_insn "*movsf_h8300"
458 [(set (match_operand:SF 0 "general_operand_dst" "=r,r,r,o,<,r")
459 (match_operand:SF 1 "general_operand_src" "G,r,io,r,r,>"))]
461 && (register_operand (operands[0], SFmode)
462 || register_operand (operands[1], SFmode))"
465 /* Copy of the movsi stuff. */
466 unsigned int rn = -1;
467 switch (which_alternative)
470 return \"sub.w %e0,%e0\;sub.w %f0,%f0\";
472 if (REGNO (operands[0]) < REGNO (operands[1]))
473 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
475 return \"mov.w %f1,%f0\;mov.w %e1,%e0\";
477 /* Make sure we don't trample the register we index with. */
478 if (GET_CODE (operands[1]) == MEM)
480 rtx inside = XEXP (operands[1], 0);
485 else if (GET_CODE (inside) == PLUS)
487 rtx lhs = XEXP (inside, 0);
488 rtx rhs = XEXP (inside, 1);
489 if (REG_P (lhs)) rn = REGNO (lhs);
490 if (REG_P (rhs)) rn = REGNO (rhs);
493 if (rn == REGNO (operands[0]))
494 /* Move the second word first. */
495 return \"mov.w %f1,%f0\;mov.w %e1,%e0\";
497 /* Move the first word first. */
498 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
501 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
503 return \"mov.w %f1,%T0\;mov.w %e1,%T0\";
505 return \"mov.w %T1,%e0\;mov.w %T1,%f0\";
510 [(set (attr "length")
511 (symbol_ref "compute_mov_length (operands)"))
512 (set_attr "cc" "clobber")])
514 (define_insn "*movsi_h8300hs"
515 [(set (match_operand:SI 0 "general_operand_dst" "=r,r,r,<,r,r,m,*a,*a,r")
516 (match_operand:SI 1 "general_operand_src" "I,r,i,r,>,m,r,I,r,*a"))]
517 "(TARGET_H8300S || TARGET_H8300H)
518 && (register_operand (operands[0], SImode)
519 || register_operand (operands[1], SImode))
520 && !(GET_CODE (operands[0]) == MEM
521 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
522 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
523 && GET_CODE (operands[1]) == REG
524 && REGNO (XEXP (XEXP (operands[0], 0), 0)) == REGNO (operands[1]))"
527 switch (which_alternative)
530 return \"sub.l %S0,%S0\";
534 return \"clrmac\;ldmac %1,macl\";
536 return \"stmac macl,%0\";
538 if (GET_CODE (operands[1]) == CONST_INT)
540 int val = INTVAL (operands[1]);
542 /* Look for constants which can be made by adding an 8-bit
543 number to zero in one of the two low bytes. */
544 if (val == (val & 0xff))
546 operands[1] = GEN_INT ((char) val & 0xff);
547 return \"sub.l\\t%S0,%S0\;add.b\\t%1,%w0\";
550 if (val == (val & 0xff00))
552 operands[1] = GEN_INT ((char) (val >> 8) & 0xff);
553 return \"sub.l\\t%S0,%S0\;add.b\\t%1,%x0\";
556 /* Look for constants that can be obtained by subs, inc, and
558 switch (val & 0xffffffff)
561 return \"sub.l\\t%S0,%S0\;subs\\t#1,%S0\";
563 return \"sub.l\\t%S0,%S0\;subs\\t#2,%S0\";
565 return \"sub.l\\t%S0,%S0\;subs\\t#4,%S0\";
568 return \"sub.l\\t%S0,%S0\;dec.w\\t#1,%f0\";
570 return \"sub.l\\t%S0,%S0\;dec.w\\t#2,%f0\";
573 return \"sub.l\\t%S0,%S0\;dec.w\\t#1,%e0\";
575 return \"sub.l\\t%S0,%S0\;dec.w\\t#2,%e0\";
578 return \"sub.l\\t%S0,%S0\;inc.w\\t#1,%e0\";
580 return \"sub.l\\t%S0,%S0\;inc.w\\t#2,%e0\";
584 return \"mov.l %S1,%S0\";
586 [(set (attr "length")
587 (symbol_ref "compute_mov_length (operands)"))
588 (set_attr "cc" "set_zn,set_znv,clobber,set_znv,set_znv,set_znv,set_znv,none_0hit,none_0hit,set_znv")])
590 (define_insn "*movsf_h8300h"
591 [(set (match_operand:SF 0 "general_operand_dst" "=r,r,r,m,<,r")
592 (match_operand:SF 1 "general_operand_src" "G,r,im,r,r,>"))]
593 "(TARGET_H8300H || TARGET_H8300S)
594 && (register_operand (operands[0], SFmode)
595 || register_operand (operands[1], SFmode))"
603 [(set (attr "length")
604 (symbol_ref "compute_mov_length (operands)"))
605 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
607 ;; ----------------------------------------------------------------------
609 ;; ----------------------------------------------------------------------
612 [(set (cc0) (zero_extract:HI (match_operand:QI 0 "bit_memory_operand" "r,U")
614 (match_operand 1 "const_int_operand" "n,n")))]
617 [(set_attr "length" "2,4")
618 (set_attr "cc" "set_zn,set_zn")])
621 [(set (cc0) (zero_extract:HI (match_operand:HI 0 "register_operand" "r")
623 (match_operand 1 "const_int_operand" "n")))]
626 [(set_attr "length" "2")
627 (set_attr "cc" "set_zn")])
629 (define_insn_and_split "*tst_extzv_1_n"
631 (zero_extract:SI (match_operand:QI 0 "general_operand_src" "r,U,mn>")
633 (match_operand 1 "const_int_operand" "n,n,n")))
634 (clobber (match_scratch:QI 2 "=X,X,&r"))]
635 "(TARGET_H8300H || TARGET_H8300S)"
641 && !EXTRA_CONSTRAINT (operands[0], 'U')"
644 (parallel [(set (cc0) (zero_extract:SI (match_dup 2)
647 (clobber (scratch:QI))])]
649 [(set_attr "length" "2,8,10")
650 (set_attr "cc" "set_zn,set_zn,set_zn")])
653 [(set (cc0) (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
655 (match_operand 1 "const_int_operand" "n")))]
656 "(TARGET_H8300H || TARGET_H8300S)
657 && INTVAL (operands[1]) <= 15"
659 [(set_attr "length" "2")
660 (set_attr "cc" "set_zn")])
662 (define_insn_and_split "*tstsi_upper_bit"
664 (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
666 (match_operand 1 "const_int_operand" "n")))
667 (clobber (match_scratch:SI 2 "=&r"))]
668 "(TARGET_H8300H || TARGET_H8300S)
669 && INTVAL (operands[1]) >= 16"
671 "&& reload_completed"
673 (ior:SI (and:SI (match_dup 2)
675 (lshiftrt:SI (match_dup 0)
678 (zero_extract:SI (match_dup 2)
681 "operands[3] = GEN_INT (INTVAL (operands[1]) - 16);")
683 (define_insn "*tstsi_variable_bit"
685 (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
687 (and:SI (match_operand:SI 1 "register_operand" "r")
689 "TARGET_H8300H || TARGET_H8300S"
691 [(set_attr "length" "2")
692 (set_attr "cc" "set_zn")])
694 (define_insn_and_split "*tstsi_variable_bit_qi"
696 (zero_extract:SI (zero_extend:SI (match_operand:QI 0 "general_operand_src" "r,U,mn>"))
698 (and:SI (match_operand:SI 1 "register_operand" "r,r,r")
700 (clobber (match_scratch:QI 2 "=X,X,&r"))]
701 "(TARGET_H8300H || TARGET_H8300S)"
707 && !EXTRA_CONSTRAINT (operands[0], 'U')"
710 (parallel [(set (cc0) (zero_extract:SI (zero_extend:SI (match_dup 2))
712 (and:SI (match_dup 1)
714 (clobber (scratch:QI))])]
716 [(set_attr "length" "2,8,10")
717 (set_attr "cc" "set_zn,set_zn,set_zn")])
720 [(set (cc0) (match_operand:QI 0 "register_operand" "r"))]
723 [(set_attr "length" "2")
724 (set_attr "cc" "set_znv")])
727 [(set (cc0) (match_operand:HI 0 "register_operand" "r"))]
730 [(set_attr "length" "2")
731 (set_attr "cc" "set_znv")])
735 (and:HI (match_operand:HI 0 "register_operand" "r")
739 [(set_attr "length" "2")
740 (set_attr "cc" "set_znv")])
743 [(set (cc0) (match_operand:SI 0 "register_operand" "r"))]
744 "TARGET_H8300H || TARGET_H8300S"
746 [(set_attr "length" "2")
747 (set_attr "cc" "set_znv")])
751 (and:SI (match_operand:SI 0 "register_operand" "r")
752 (const_int -65536)))]
755 [(set_attr "length" "2")
756 (set_attr "cc" "set_znv")])
760 (compare (match_operand:QI 0 "register_operand" "r")
761 (match_operand:QI 1 "nonmemory_operand" "rn")))]
764 [(set_attr "length" "2")
765 (set_attr "cc" "compare")])
767 (define_expand "cmphi"
769 (compare (match_operand:HI 0 "register_operand" "")
770 (match_operand:HI 1 "nonmemory_operand" "")))]
774 /* Force operand1 into a register if we're compiling
776 if (GET_CODE (operands[1]) != REG && TARGET_H8300)
777 operands[1] = force_reg (HImode, operands[1]);
780 (define_insn "*cmphi_h8300"
782 (compare (match_operand:HI 0 "register_operand" "r")
783 (match_operand:HI 1 "register_operand" "r")))]
786 [(set_attr "length" "2")
787 (set_attr "cc" "compare")])
789 (define_insn "*cmphi_h8300hs"
791 (compare (match_operand:HI 0 "register_operand" "r,r")
792 (match_operand:HI 1 "nonmemory_operand" "r,n")))]
793 "TARGET_H8300H || TARGET_H8300S"
795 [(set_attr "length" "2,4")
796 (set_attr "cc" "compare,compare")])
800 (compare (match_operand:SI 0 "register_operand" "r,r")
801 (match_operand:SI 1 "nonmemory_operand" "r,i")))]
802 "TARGET_H8300H || TARGET_H8300S"
804 [(set_attr "length" "2,6")
805 (set_attr "cc" "compare,compare")])
807 ;; ----------------------------------------------------------------------
809 ;; ----------------------------------------------------------------------
811 (define_insn "addqi3"
812 [(set (match_operand:QI 0 "register_operand" "=r")
813 (plus:QI (match_operand:QI 1 "register_operand" "%0")
814 (match_operand:QI 2 "nonmemory_operand" "rn")))]
817 [(set_attr "length" "2")
818 (set_attr "cc" "set_zn")])
820 (define_expand "addhi3"
821 [(set (match_operand:HI 0 "register_operand" "")
822 (plus:HI (match_operand:HI 1 "register_operand" "")
823 (match_operand:HI 2 "nonmemory_operand" "")))]
827 (define_insn "*addhi3_h8300"
828 [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r")
829 (plus:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0")
830 (match_operand:HI 2 "nonmemory_operand" "L,N,J,n,r")))]
836 add.b %s2,%s0\;addx %t2,%t0
838 [(set_attr "length" "2,2,2,4,2")
839 (set_attr "cc" "none_0hit,none_0hit,clobber,clobber,set_zn")])
841 ;; This splitter is very important to make the stack adjustment
842 ;; interrupt-safe. The combination of add.b and addx is unsafe!
844 ;; We apply this split after the peephole2 pass so that we won't end
845 ;; up creating too many adds/subs when a scratch register is
846 ;; available, which is actually a common case because stack unrolling
847 ;; tends to happen immediately after a function call.
850 [(set (match_operand:HI 0 "stack_pointer_operand" "")
851 (plus:HI (match_dup 0)
852 (match_operand 1 "const_int_gt_2_operand" "")))]
853 "TARGET_H8300 && flow2_completed"
855 "split_adds_subs (HImode, operands); DONE;")
858 [(match_scratch:HI 2 "r")
859 (set (match_operand:HI 0 "stack_pointer_operand" "")
860 (plus:HI (match_dup 0)
861 (match_operand:HI 1 "const_int_ge_8_operand" "")))]
866 (plus:HI (match_dup 0)
870 (define_insn "*addhi3_h8300hs"
871 [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r")
872 (plus:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0")
873 (match_operand:HI 2 "nonmemory_operand" "L,N,J,n,r")))]
874 "TARGET_H8300H || TARGET_H8300S"
881 [(set_attr "length" "2,2,2,4,2")
882 (set_attr "cc" "none_0hit,none_0hit,clobber,set_zn,set_zn")])
884 (define_insn "*addhi3_incdec"
885 [(set (match_operand:HI 0 "register_operand" "=r,r")
886 (unspec:HI [(match_operand:HI 1 "register_operand" "0,0")
887 (match_operand:HI 2 "incdec_operand" "M,O")]
889 "TARGET_H8300H || TARGET_H8300S"
893 [(set_attr "length" "2,2")
894 (set_attr "cc" "set_zn,set_zn")])
897 [(set (match_operand:HI 0 "register_operand" "")
898 (plus:HI (match_dup 0)
899 (match_operand:HI 1 "two_insn_adds_subs_operand" "")))]
902 "split_adds_subs (HImode, operands); DONE;")
904 (define_expand "addsi3"
905 [(set (match_operand:SI 0 "register_operand" "")
906 (plus:SI (match_operand:SI 1 "register_operand" "")
907 (match_operand:SI 2 "nonmemory_operand" "")))]
911 (define_insn "addsi_h8300"
912 [(set (match_operand:SI 0 "register_operand" "=r,r")
913 (plus:SI (match_operand:SI 1 "register_operand" "%0,0")
914 (match_operand:SI 2 "nonmemory_operand" "n,r")))]
916 "* return output_plussi (operands);"
917 [(set (attr "length")
918 (symbol_ref "compute_plussi_length (operands)"))
920 (symbol_ref "compute_plussi_cc (operands)"))])
922 (define_insn "addsi_h8300h"
923 [(set (match_operand:SI 0 "register_operand" "=r,r")
924 (plus:SI (match_operand:SI 1 "register_operand" "%0,0")
925 (match_operand:SI 2 "nonmemory_operand" "i,r")))]
926 "TARGET_H8300H || TARGET_H8300S"
927 "* return output_plussi (operands);"
928 [(set (attr "length")
929 (symbol_ref "compute_plussi_length (operands)"))
931 (symbol_ref "compute_plussi_cc (operands)"))])
933 (define_insn "*addsi3_incdec"
934 [(set (match_operand:SI 0 "register_operand" "=r,r")
935 (unspec:SI [(match_operand:SI 1 "register_operand" "0,0")
936 (match_operand:SI 2 "incdec_operand" "M,O")]
938 "TARGET_H8300H || TARGET_H8300S"
942 [(set_attr "length" "2,2")
943 (set_attr "cc" "set_zn,set_zn")])
946 [(set (match_operand:SI 0 "register_operand" "")
947 (plus:SI (match_dup 0)
948 (match_operand:SI 1 "two_insn_adds_subs_operand" "")))]
949 "TARGET_H8300H || TARGET_H8300S"
951 "split_adds_subs (SImode, operands); DONE;")
953 ;; ----------------------------------------------------------------------
954 ;; SUBTRACT INSTRUCTIONS
955 ;; ----------------------------------------------------------------------
957 (define_insn "subqi3"
958 [(set (match_operand:QI 0 "register_operand" "=r")
959 (minus:QI (match_operand:QI 1 "register_operand" "0")
960 (match_operand:QI 2 "register_operand" "r")))]
963 [(set_attr "length" "2")
964 (set_attr "cc" "set_zn")])
966 (define_expand "subhi3"
967 [(set (match_operand:HI 0 "register_operand" "")
968 (minus:HI (match_operand:HI 1 "general_operand" "")
969 (match_operand:HI 2 "nonmemory_operand" "")))]
974 [(set (match_operand:HI 0 "register_operand" "=r,&r")
975 (minus:HI (match_operand:HI 1 "general_operand" "0,0")
976 (match_operand:HI 2 "nonmemory_operand" "r,n")))]
980 add.b %E2,%s0\;addx %F2,%t0"
981 [(set_attr "length" "2,4")
982 (set_attr "cc" "set_zn,clobber")])
985 [(set (match_operand:HI 0 "register_operand" "=r,&r")
986 (minus:HI (match_operand:HI 1 "general_operand" "0,0")
987 (match_operand:HI 2 "nonmemory_operand" "r,n")))]
988 "TARGET_H8300H || TARGET_H8300S"
992 [(set_attr "length" "2,4")
993 (set_attr "cc" "set_zn,set_zn")])
995 (define_expand "subsi3"
996 [(set (match_operand:SI 0 "register_operand" "")
997 (minus:SI (match_operand:SI 1 "register_operand" "")
998 (match_operand:SI 2 "nonmemory_operand" "")))]
1002 (define_insn "subsi3_h8300"
1003 [(set (match_operand:SI 0 "register_operand" "=r")
1004 (minus:SI (match_operand:SI 1 "register_operand" "0")
1005 (match_operand:SI 2 "register_operand" "r")))]
1007 "sub.w %f2,%f0\;subx %y2,%y0\;subx %z2,%z0"
1008 [(set_attr "length" "6")
1009 (set_attr "cc" "clobber")])
1011 (define_insn "subsi3_h8300h"
1012 [(set (match_operand:SI 0 "register_operand" "=r,r")
1013 (minus:SI (match_operand:SI 1 "general_operand" "0,0")
1014 (match_operand:SI 2 "nonmemory_operand" "r,i")))]
1015 "TARGET_H8300H || TARGET_H8300S"
1019 [(set_attr "length" "2,6")
1020 (set_attr "cc" "set_zn,set_zn")])
1022 ;; ----------------------------------------------------------------------
1023 ;; MULTIPLY INSTRUCTIONS
1024 ;; ----------------------------------------------------------------------
1026 ;; Note that the H8/300 can only handle umulqihi3.
1028 (define_insn "mulqihi3"
1029 [(set (match_operand:HI 0 "register_operand" "=r")
1030 (mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "%0"))
1031 (sign_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
1032 "TARGET_H8300H || TARGET_H8300S"
1034 [(set_attr "length" "4")
1035 (set_attr "cc" "set_zn")])
1037 (define_insn "mulhisi3"
1038 [(set (match_operand:SI 0 "register_operand" "=r")
1039 (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" "%0"))
1040 (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
1041 "TARGET_H8300H || TARGET_H8300S"
1043 [(set_attr "length" "4")
1044 (set_attr "cc" "set_zn")])
1046 (define_insn "umulqihi3"
1047 [(set (match_operand:HI 0 "register_operand" "=r")
1048 (mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "%0"))
1049 (zero_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
1052 [(set_attr "length" "2")
1053 (set_attr "cc" "none_0hit")])
1055 (define_insn "umulhisi3"
1056 [(set (match_operand:SI 0 "register_operand" "=r")
1057 (mult:SI (zero_extend:SI (match_operand:HI 1 "register_operand" "%0"))
1058 (zero_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
1059 "TARGET_H8300H || TARGET_H8300S"
1061 [(set_attr "length" "2")
1062 (set_attr "cc" "none_0hit")])
1064 ;; This is a "bridge" instruction. Combine can't cram enough insns
1065 ;; together to crate a MAC instruction directly, but it can create
1066 ;; this instruction, which then allows combine to create the real
1069 ;; Unfortunately, if combine doesn't create a MAC instruction, this
1070 ;; insn must generate reasonably correct code. Egad.
1072 [(set (match_operand:SI 0 "register_operand" "=a")
1075 (mem:HI (post_inc:SI (match_operand:SI 1 "register_operand" "r"))))
1077 (mem:HI (post_inc:SI (match_operand:SI 2 "register_operand" "r"))))))]
1079 "clrmac\;mac @%2+,@%1+"
1080 [(set_attr "length" "6")
1081 (set_attr "cc" "none_0hit")])
1084 [(set (match_operand:SI 0 "register_operand" "=a")
1086 (sign_extend:SI (mem:HI
1087 (post_inc:SI (match_operand:SI 1 "register_operand" "r"))))
1088 (sign_extend:SI (mem:HI
1089 (post_inc:SI (match_operand:SI 2 "register_operand" "r")))))
1090 (match_operand:SI 3 "register_operand" "0")))]
1093 [(set_attr "length" "4")
1094 (set_attr "cc" "none_0hit")])
1096 ;; ----------------------------------------------------------------------
1097 ;; DIVIDE/MOD INSTRUCTIONS
1098 ;; ----------------------------------------------------------------------
1100 (define_insn "udivmodqi4"
1101 [(set (match_operand:QI 0 "register_operand" "=r")
1104 (match_operand:HI 1 "register_operand" "0")
1105 (zero_extend:HI (match_operand:QI 2 "register_operand" "r")))))
1106 (set (match_operand:QI 3 "register_operand" "=r")
1110 (zero_extend:HI (match_dup 2)))))]
1114 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1115 return \"divxu.b\\t%X2,%T0\";
1117 return \"divxu.b\\t%X2,%T0\;mov.b\\t%t0,%s3\";
1119 [(set_attr "length" "4")
1120 (set_attr "cc" "clobber")])
1122 (define_insn "divmodqi4"
1123 [(set (match_operand:QI 0 "register_operand" "=r")
1126 (match_operand:HI 1 "register_operand" "0")
1127 (sign_extend:HI (match_operand:QI 2 "register_operand" "r")))))
1128 (set (match_operand:QI 3 "register_operand" "=r")
1132 (sign_extend:HI (match_dup 2)))))]
1133 "TARGET_H8300H || TARGET_H8300S"
1136 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1137 return \"divxs.b\\t%X2,%T0\";
1139 return \"divxs.b\\t%X2,%T0\;mov.b\\t%t0,%s3\";
1141 [(set_attr "length" "6")
1142 (set_attr "cc" "clobber")])
1144 (define_insn "udivmodhi4"
1145 [(set (match_operand:HI 0 "register_operand" "=r")
1148 (match_operand:SI 1 "register_operand" "0")
1149 (zero_extend:SI (match_operand:HI 2 "register_operand" "r")))))
1150 (set (match_operand:HI 3 "register_operand" "=r")
1154 (zero_extend:SI (match_dup 2)))))]
1155 "TARGET_H8300H || TARGET_H8300S"
1158 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1159 return \"divxu.w\\t%T2,%S0\";
1161 return \"divxu.w\\t%T2,%S0\;mov.w\\t%e0,%f3\";
1163 [(set_attr "length" "4")
1164 (set_attr "cc" "clobber")])
1166 (define_insn "divmodhi4"
1167 [(set (match_operand:HI 0 "register_operand" "=r")
1170 (match_operand:SI 1 "register_operand" "0")
1171 (sign_extend:SI (match_operand:HI 2 "register_operand" "r")))))
1172 (set (match_operand:HI 3 "register_operand" "=r")
1176 (sign_extend:SI (match_dup 2)))))]
1177 "TARGET_H8300H || TARGET_H8300S"
1180 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1181 return \"divxs.w\\t%T2,%S0\";
1183 return \"divxs.w\\t%T2,%S0\;mov.w\\t%e0,%f3\";
1185 [(set_attr "length" "6")
1186 (set_attr "cc" "clobber")])
1188 ;; ----------------------------------------------------------------------
1190 ;; ----------------------------------------------------------------------
1193 [(set (match_operand:QI 0 "bit_operand" "=r,U")
1194 (and:QI (match_operand:QI 1 "bit_operand" "%0,0")
1195 (match_operand:QI 2 "nonmemory_operand" "rn,n")))]
1196 "register_operand (operands[0], QImode)
1197 || single_zero_operand (operands[2], QImode)"
1201 [(set_attr "length" "2,8")
1202 (set_attr "cc" "set_znv,none_0hit")])
1204 (define_expand "andqi3"
1205 [(set (match_operand:QI 0 "bit_operand" "")
1206 (and:QI (match_operand:QI 1 "bit_operand" "")
1207 (match_operand:QI 2 "nonmemory_operand" "")))]
1211 if (fix_bit_operand (operands, 0, AND))
1215 (define_expand "andhi3"
1216 [(set (match_operand:HI 0 "register_operand" "")
1217 (and:HI (match_operand:HI 1 "register_operand" "")
1218 (match_operand:HI 2 "nonmemory_operand" "")))]
1222 (define_insn "*andorqi3"
1223 [(set (match_operand:QI 0 "register_operand" "=r")
1224 (ior:QI (and:QI (match_operand:QI 2 "register_operand" "r")
1225 (match_operand:QI 3 "single_one_operand" "n"))
1226 (match_operand:QI 1 "register_operand" "0")))]
1228 "bld\\t%V3,%X2\;bor\\t%V3,%X0\;bst\\t%V3,%X0"
1229 [(set_attr "length" "6")
1230 (set_attr "cc" "clobber")])
1232 (define_insn "*andorhi3"
1233 [(set (match_operand:HI 0 "register_operand" "=r")
1234 (ior:HI (and:HI (match_operand:HI 2 "register_operand" "r")
1235 (match_operand:HI 3 "single_one_operand" "n"))
1236 (match_operand:HI 1 "register_operand" "0")))]
1240 operands[3] = GEN_INT (INTVAL (operands[3]) & 0xffff);
1241 if (INTVAL (operands[3]) > 128)
1243 operands[3] = GEN_INT (INTVAL (operands[3]) >> 8);
1244 return \"bld\\t%V3,%t2\;bor\\t%V3,%t0\;bst\\t%V3,%t0\";
1246 return \"bld\\t%V3,%s2\;bor\\t%V3,%s0\;bst\\t%V3,%s0\";
1248 [(set_attr "length" "6")
1249 (set_attr "cc" "clobber")])
1251 (define_insn "*andorsi3"
1252 [(set (match_operand:SI 0 "register_operand" "=r")
1253 (ior:SI (and:SI (match_operand:SI 2 "register_operand" "r")
1254 (match_operand:SI 3 "single_one_operand" "n"))
1255 (match_operand:SI 1 "register_operand" "0")))]
1256 "(INTVAL (operands[3]) & 0xffff) != 0"
1259 operands[3] = GEN_INT (INTVAL (operands[3]) & 0xffff);
1260 if (INTVAL (operands[3]) > 128)
1262 operands[3] = GEN_INT (INTVAL (operands[3]) >> 8);
1263 return \"bld\\t%V3,%x2\;bor\\t%V3,%x0\;bst\\t%V3,%x0\";
1265 return \"bld\\t%V3,%w2\;bor\\t%V3,%w0\;bst\\t%V3,%w0\";
1267 [(set_attr "length" "6")
1268 (set_attr "cc" "clobber")])
1270 (define_insn "*andorsi3_shift_8"
1271 [(set (match_operand:SI 0 "register_operand" "=r")
1272 (ior:SI (and:SI (ashift:SI (match_operand:SI 2 "register_operand" "r")
1275 (match_operand:SI 1 "register_operand" "0")))]
1278 [(set_attr "length" "2")
1279 (set_attr "cc" "clobber")])
1281 (define_expand "andsi3"
1282 [(set (match_operand:SI 0 "register_operand" "")
1283 (and:SI (match_operand:SI 1 "register_operand" "")
1284 (match_operand:SI 2 "nonmemory_operand" "")))]
1288 ;; ----------------------------------------------------------------------
1290 ;; ----------------------------------------------------------------------
1293 [(set (match_operand:QI 0 "bit_operand" "=r,U")
1294 (ior:QI (match_operand:QI 1 "bit_operand" "%0,0")
1295 (match_operand:QI 2 "nonmemory_operand" "rn,n")))]
1296 "register_operand (operands[0], QImode)
1297 || single_one_operand (operands[2], QImode)"
1301 [(set_attr "length" "2,8")
1302 (set_attr "cc" "set_znv,none_0hit")])
1304 (define_expand "iorqi3"
1305 [(set (match_operand:QI 0 "bit_operand" "")
1306 (ior:QI (match_operand:QI 1 "bit_operand" "")
1307 (match_operand:QI 2 "nonmemory_operand" "")))]
1311 if (fix_bit_operand (operands, 1, IOR))
1315 (define_expand "iorhi3"
1316 [(set (match_operand:HI 0 "register_operand" "")
1317 (ior:HI (match_operand:HI 1 "register_operand" "")
1318 (match_operand:HI 2 "nonmemory_operand" "")))]
1322 (define_expand "iorsi3"
1323 [(set (match_operand:SI 0 "register_operand" "")
1324 (ior:SI (match_operand:SI 1 "register_operand" "")
1325 (match_operand:SI 2 "nonmemory_operand" "")))]
1329 ;; ----------------------------------------------------------------------
1331 ;; ----------------------------------------------------------------------
1334 [(set (match_operand:QI 0 "bit_operand" "=r,U")
1335 (xor:QI (match_operand:QI 1 "bit_operand" "%0,0")
1336 (match_operand:QI 2 "nonmemory_operand" "rn,n")))]
1337 "register_operand (operands[0], QImode)
1338 || single_one_operand (operands[2], QImode)"
1342 [(set_attr "length" "2,8")
1343 (set_attr "cc" "set_znv,none_0hit")])
1345 (define_expand "xorqi3"
1346 [(set (match_operand:QI 0 "bit_operand" "")
1347 (xor:QI (match_operand:QI 1 "bit_operand" "")
1348 (match_operand:QI 2 "nonmemory_operand" "")))]
1352 if (fix_bit_operand (operands, 1, XOR))
1356 (define_expand "xorhi3"
1357 [(set (match_operand:HI 0 "register_operand" "")
1358 (xor:HI (match_operand:HI 1 "register_operand" "")
1359 (match_operand:HI 2 "nonmemory_operand" "")))]
1363 (define_expand "xorsi3"
1364 [(set (match_operand:SI 0 "register_operand" "")
1365 (xor:SI (match_operand:SI 1 "register_operand" "")
1366 (match_operand:SI 2 "nonmemory_operand" "")))]
1370 ;; ----------------------------------------------------------------------
1371 ;; {AND,IOR,XOR}{HI3,SI3} PATTERNS
1372 ;; ----------------------------------------------------------------------
1375 [(set (match_operand:HI 0 "register_operand" "=r")
1376 (match_operator:HI 3 "bit_operator"
1377 [(match_operand:HI 1 "register_operand" "%0")
1378 (match_operand:HI 2 "nonmemory_operand" "rn")]))]
1380 "* return output_logical_op (HImode, operands);"
1381 [(set (attr "length")
1382 (symbol_ref "compute_logical_op_length (HImode, operands)"))
1384 (symbol_ref "compute_logical_op_cc (HImode, operands)"))])
1387 [(set (match_operand:SI 0 "register_operand" "=r")
1388 (match_operator:SI 3 "bit_operator"
1389 [(match_operand:SI 1 "register_operand" "%0")
1390 (match_operand:SI 2 "nonmemory_operand" "rn")]))]
1392 "* return output_logical_op (SImode, operands);"
1393 [(set (attr "length")
1394 (symbol_ref "compute_logical_op_length (SImode, operands)"))
1396 (symbol_ref "compute_logical_op_cc (SImode, operands)"))])
1398 ;; ----------------------------------------------------------------------
1399 ;; NEGATION INSTRUCTIONS
1400 ;; ----------------------------------------------------------------------
1402 (define_insn "negqi2"
1403 [(set (match_operand:QI 0 "register_operand" "=r")
1404 (neg:QI (match_operand:QI 1 "register_operand" "0")))]
1407 [(set_attr "length" "2")
1408 (set_attr "cc" "set_zn")])
1410 (define_expand "neghi2"
1411 [(set (match_operand:HI 0 "register_operand" "")
1412 (neg:HI (match_operand:HI 1 "register_operand" "")))]
1418 emit_insn (gen_neghi2_h8300 (operands[0], operands[1]));
1423 (define_expand "neghi2_h8300"
1425 (not:HI (match_operand:HI 1 "register_operand" "")))
1426 (set (match_dup 2) (plus:HI (match_dup 2) (const_int 1)))
1427 (set (match_operand:HI 0 "register_operand" "")
1430 "operands[2] = gen_reg_rtx (HImode);")
1432 (define_insn "neghi2_h8300h"
1433 [(set (match_operand:HI 0 "register_operand" "=r")
1434 (neg:HI (match_operand:HI 1 "register_operand" "0")))]
1435 "TARGET_H8300H || TARGET_H8300S"
1437 [(set_attr "length" "2")
1438 (set_attr "cc" "set_zn")])
1440 (define_expand "negsi2"
1441 [(set (match_operand:SI 0 "register_operand" "")
1442 (neg:SI (match_operand:SI 1 "register_operand" "")))]
1448 emit_insn (gen_negsi2_h8300 (operands[0], operands[1]));
1453 (define_expand "negsi2_h8300"
1455 (not:SI (match_operand:SI 1 "register_operand" "")))
1456 (set (match_dup 2) (plus:SI (match_dup 2) (const_int 1)))
1457 (set (match_operand:SI 0 "register_operand" "")
1460 "operands[2] = gen_reg_rtx (SImode);")
1462 (define_insn "negsi2_h8300h"
1463 [(set (match_operand:SI 0 "register_operand" "=r")
1464 (neg:SI (match_operand:SI 1 "register_operand" "0")))]
1465 "TARGET_H8300H || TARGET_H8300S"
1467 [(set_attr "length" "2")
1468 (set_attr "cc" "set_zn")])
1470 (define_expand "negsf2"
1471 [(set (match_operand:SF 0 "register_operand" "")
1472 (neg:SF (match_operand:SF 1 "register_operand" "")))]
1476 (define_insn "*negsf2_h8300"
1477 [(set (match_operand:SF 0 "register_operand" "=r")
1478 (neg:SF (match_operand:SF 1 "register_operand" "0")))]
1481 [(set_attr "cc" "clobber")
1482 (set_attr "length" "2")])
1484 (define_insn "*negsf2_h8300hs"
1485 [(set (match_operand:SF 0 "register_operand" "=r")
1486 (neg:SF (match_operand:SF 1 "register_operand" "0")))]
1487 "TARGET_H8300H || TARGET_H8300S"
1488 "xor.w\\t#32768,%e0"
1489 [(set_attr "cc" "clobber")
1490 (set_attr "length" "4")])
1492 ;; ----------------------------------------------------------------------
1493 ;; ABSOLUTE VALUE INSTRUCTIONS
1494 ;; ----------------------------------------------------------------------
1496 (define_expand "abssf2"
1497 [(set (match_operand:SF 0 "register_operand" "")
1498 (abs:SF (match_operand:SF 1 "register_operand" "")))]
1502 (define_insn "*abssf2_h8300"
1503 [(set (match_operand:SF 0 "register_operand" "=r")
1504 (abs:SF (match_operand:SF 1 "register_operand" "0")))]
1507 [(set_attr "cc" "clobber")
1508 (set_attr "length" "2")])
1510 (define_insn "*abssf2_h8300hs"
1511 [(set (match_operand:SF 0 "register_operand" "=r")
1512 (abs:SF (match_operand:SF 1 "register_operand" "0")))]
1513 "TARGET_H8300H || TARGET_H8300S"
1514 "and.w\\t#32767,%e0"
1515 [(set_attr "cc" "clobber")
1516 (set_attr "length" "4")])
1518 ;; ----------------------------------------------------------------------
1520 ;; ----------------------------------------------------------------------
1522 (define_insn "one_cmplqi2"
1523 [(set (match_operand:QI 0 "register_operand" "=r")
1524 (not:QI (match_operand:QI 1 "register_operand" "0")))]
1527 [(set_attr "length" "2")
1528 (set_attr "cc" "set_znv")])
1530 (define_expand "one_cmplhi2"
1531 [(set (match_operand:HI 0 "register_operand" "=r")
1532 (not:HI (match_operand:HI 1 "register_operand" "0")))]
1537 [(set (match_operand:HI 0 "register_operand" "=r")
1538 (not:HI (match_operand:HI 1 "register_operand" "0")))]
1541 [(set_attr "cc" "clobber")
1542 (set_attr "length" "4")])
1545 [(set (match_operand:HI 0 "register_operand" "=r")
1546 (not:HI (match_operand:HI 1 "register_operand" "0")))]
1547 "TARGET_H8300H || TARGET_H8300S"
1549 [(set_attr "cc" "set_znv")
1550 (set_attr "length" "2")])
1552 (define_expand "one_cmplsi2"
1553 [(set (match_operand:SI 0 "register_operand" "=r")
1554 (not:SI (match_operand:SI 1 "register_operand" "0")))]
1559 [(set (match_operand:SI 0 "register_operand" "=r")
1560 (not:SI (match_operand:SI 1 "register_operand" "0")))]
1562 "not %w0\;not %x0\;not %y0\;not %z0"
1563 [(set_attr "cc" "clobber")
1564 (set_attr "length" "8")])
1567 [(set (match_operand:SI 0 "register_operand" "=r")
1568 (not:SI (match_operand:SI 1 "register_operand" "0")))]
1569 "TARGET_H8300H || TARGET_H8300S"
1571 [(set_attr "cc" "set_znv")
1572 (set_attr "length" "2")])
1574 ;; ----------------------------------------------------------------------
1575 ;; JUMP INSTRUCTIONS
1576 ;; ----------------------------------------------------------------------
1578 ;; Conditional jump instructions
1580 (define_expand "ble"
1582 (if_then_else (le (cc0)
1584 (label_ref (match_operand 0 "" ""))
1589 (define_expand "bleu"
1591 (if_then_else (leu (cc0)
1593 (label_ref (match_operand 0 "" ""))
1598 (define_expand "bge"
1600 (if_then_else (ge (cc0)
1602 (label_ref (match_operand 0 "" ""))
1607 (define_expand "bgeu"
1609 (if_then_else (geu (cc0)
1611 (label_ref (match_operand 0 "" ""))
1616 (define_expand "blt"
1618 (if_then_else (lt (cc0)
1620 (label_ref (match_operand 0 "" ""))
1625 (define_expand "bltu"
1627 (if_then_else (ltu (cc0)
1629 (label_ref (match_operand 0 "" ""))
1634 (define_expand "bgt"
1636 (if_then_else (gt (cc0)
1638 (label_ref (match_operand 0 "" ""))
1643 (define_expand "bgtu"
1645 (if_then_else (gtu (cc0)
1647 (label_ref (match_operand 0 "" ""))
1652 (define_expand "beq"
1654 (if_then_else (eq (cc0)
1656 (label_ref (match_operand 0 "" ""))
1661 (define_expand "bne"
1663 (if_then_else (ne (cc0)
1665 (label_ref (match_operand 0 "" ""))
1670 (define_insn "branch_true"
1672 (if_then_else (match_operator 1 "comparison_operator"
1673 [(cc0) (const_int 0)])
1674 (label_ref (match_operand 0 "" ""))
1679 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
1680 && (GET_CODE (operands[1]) == GT
1681 || GET_CODE (operands[1]) == GE
1682 || GET_CODE (operands[1]) == LE
1683 || GET_CODE (operands[1]) == LT))
1685 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
1689 if (get_attr_length (insn) == 2)
1690 return \"b%j1 %l0\";
1691 else if (get_attr_length (insn) == 4)
1692 return \"b%j1 %l0:16\";
1694 return \"b%k1 .Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:\";
1696 [(set_attr "type" "branch")
1697 (set_attr "cc" "none")])
1699 (define_insn "branch_false"
1701 (if_then_else (match_operator 1 "comparison_operator"
1702 [(cc0) (const_int 0)])
1704 (label_ref (match_operand 0 "" ""))))]
1708 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
1709 && (GET_CODE (operands[1]) == GT
1710 || GET_CODE (operands[1]) == GE
1711 || GET_CODE (operands[1]) == LE
1712 || GET_CODE (operands[1]) == LT))
1714 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
1718 if (get_attr_length (insn) == 2)
1719 return \"b%k1 %l0\";
1720 else if (get_attr_length (insn) == 4)
1721 return \"b%k1 %l0:16\";
1723 return \"b%j1 .Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:\";
1725 [(set_attr "type" "branch")
1726 (set_attr "cc" "none")])
1728 ;; Unconditional and other jump instructions.
1732 (label_ref (match_operand 0 "" "")))]
1736 if (get_attr_length (insn) == 2)
1738 else if (get_attr_length (insn) == 4)
1739 return \"bra %l0:16\";
1741 return \"jmp @%l0\";
1743 [(set_attr "type" "branch")
1744 (set_attr "cc" "none")])
1746 ;; This is a define expand, because pointers may be either 16 or 32 bits.
1748 (define_expand "tablejump"
1749 [(parallel [(set (pc) (match_operand 0 "register_operand" ""))
1750 (use (label_ref (match_operand 1 "" "")))])]
1754 (define_insn "*tablejump_h8300"
1755 [(set (pc) (match_operand:HI 0 "register_operand" "r"))
1756 (use (label_ref (match_operand 1 "" "")))]
1759 [(set_attr "cc" "none")
1760 (set_attr "length" "2")])
1762 (define_insn "*tablejump_h8300hs_advanced"
1763 [(set (pc) (match_operand:SI 0 "register_operand" "r"))
1764 (use (label_ref (match_operand 1 "" "")))]
1765 "TARGET_H8300H || TARGET_H8300S"
1767 [(set_attr "cc" "none")
1768 (set_attr "length" "2")])
1770 (define_insn "*tablejump_h8300hs_normal"
1771 [(set (pc) (match_operand:HI 0 "register_operand" "r"))
1772 (use (label_ref (match_operand 1 "" "")))]
1773 "(TARGET_H8300H || TARGET_H8300S) && TARGET_NORMAL_MODE"
1775 [(set_attr "cc" "none")
1776 (set_attr "length" "2")])
1778 ;; This is a define expand, because pointers may be either 16 or 32 bits.
1780 (define_expand "indirect_jump"
1781 [(set (pc) (match_operand 0 "jump_address_operand" ""))]
1785 (define_insn "*indirect_jump_h8300"
1786 [(set (pc) (match_operand:HI 0 "jump_address_operand" "Vr"))]
1789 [(set_attr "cc" "none")
1790 (set_attr "length" "2")])
1792 (define_insn "*indirect_jump_h8300hs_advanced"
1793 [(set (pc) (match_operand:SI 0 "jump_address_operand" "Vr"))]
1794 "TARGET_H8300H || TARGET_H8300S"
1796 [(set_attr "cc" "none")
1797 (set_attr "length" "2")])
1799 (define_insn "*indirect_jump_h8300hs_normal"
1800 [(set (pc) (match_operand:HI 0 "jump_address_operand" "Vr"))]
1801 "(TARGET_H8300H || TARGET_H8300S) && TARGET_NORMAL_MODE"
1803 [(set_attr "cc" "none")
1804 (set_attr "length" "2")])
1806 ;; Call subroutine with no return value.
1808 ;; ??? Even though we use HImode here, this works on the H8/300H and H8S.
1811 [(call (match_operand:QI 0 "call_insn_operand" "or")
1812 (match_operand:HI 1 "general_operand" "g"))]
1816 if (GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
1817 && SYMBOL_REF_FLAG (XEXP (operands[0], 0)))
1818 return \"jsr\\t@%0:8\";
1820 return \"jsr\\t%0\";
1822 [(set_attr "cc" "clobber")
1823 (set (attr "length")
1824 (if_then_else (match_operand:QI 0 "small_call_insn_operand" "")
1828 ;; Call subroutine, returning value in operand 0
1829 ;; (which must be a hard register).
1831 ;; ??? Even though we use HImode here, this works on the H8/300H and H8S.
1833 (define_insn "call_value"
1834 [(set (match_operand 0 "" "=r")
1835 (call (match_operand:QI 1 "call_insn_operand" "or")
1836 (match_operand:HI 2 "general_operand" "g")))]
1840 if (GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
1841 && SYMBOL_REF_FLAG (XEXP (operands[1], 0)))
1842 return \"jsr\\t@%1:8\";
1844 return \"jsr\\t%1\";
1846 [(set_attr "cc" "clobber")
1847 (set (attr "length")
1848 (if_then_else (match_operand:QI 0 "small_call_insn_operand" "")
1856 [(set_attr "cc" "none")
1857 (set_attr "length" "2")])
1859 ;; ----------------------------------------------------------------------
1860 ;; PROLOGUE/EPILOGUE-RELATED INSTRUCTIONS
1861 ;; ----------------------------------------------------------------------
1863 (define_expand "push_h8300"
1864 [(set (mem:HI (pre_dec:HI (reg:HI SP_REG)))
1865 (match_operand:HI 0 "register_operand" ""))]
1870 (define_expand "push_h8300hs"
1871 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
1872 (match_operand:SI 0 "register_operand" ""))]
1873 "TARGET_H8300H && TARGET_H8300S"
1876 (define_expand "push_h8300hs_normal"
1877 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
1878 (match_operand:SI 0 "register_operand" ""))]
1879 "TARGET_NORMAL_MODE"
1882 (define_expand "pop_h8300"
1883 [(set (match_operand:HI 0 "register_operand" "")
1884 (mem:HI (post_inc:HI (reg:HI SP_REG))))]
1888 (define_expand "pop_h8300hs"
1889 [(set (match_operand:SI 0 "register_operand" "")
1890 (mem:SI (post_inc:SI (reg:SI SP_REG))))]
1891 "TARGET_H8300H && TARGET_H8300S"
1894 (define_expand "pop_h8300hs_normal"
1895 [(set (match_operand:SI 0 "register_operand" "")
1896 (mem:SI (post_inc:HI (reg:HI SP_REG))))]
1897 "TARGET_NORMAL_MODE"
1900 (define_insn "stm_h8300s_2_advanced"
1902 [(set (reg:SI SP_REG)
1903 (plus:SI (reg:SI SP_REG) (const_int -8)))
1904 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
1905 (match_operand:SI 0 "register_operand" ""))
1906 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
1907 (match_operand:SI 1 "register_operand" ""))])]
1908 "TARGET_H8300S && !TARGET_NORMAL_MODE
1909 && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
1910 || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
1911 || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
1912 "stm.l\\t%S0-%S1,@-er7"
1913 [(set_attr "cc" "none")
1914 (set_attr "length" "4")])
1916 (define_insn "stm_h8300s_2_normal"
1918 [(set (reg:HI SP_REG)
1919 (plus:HI (reg:HI SP_REG) (const_int -8)))
1920 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
1921 (match_operand:SI 0 "register_operand" ""))
1922 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
1923 (match_operand:SI 1 "register_operand" ""))])]
1924 "TARGET_H8300S && TARGET_NORMAL_MODE
1925 && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
1926 || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
1927 || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
1928 "stm.l\\t%S0-%S1,@-er7"
1929 [(set_attr "cc" "none")
1930 (set_attr "length" "4")])
1932 (define_expand "stm_h8300s_2"
1933 [(use (match_operand:SI 0 "register_operand" ""))
1934 (use (match_operand:SI 1 "register_operand" ""))]
1936 && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
1937 || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
1938 || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
1941 if (!TARGET_NORMAL_MODE)
1942 emit_insn (gen_stm_h8300s_2_advanced (operands[0], operands[1]));
1944 emit_insn (gen_stm_h8300s_2_normal (operands[0], operands[1]));
1948 (define_insn "stm_h8300s_3_advanced"
1950 [(set (reg:SI SP_REG)
1951 (plus:SI (reg:SI SP_REG) (const_int -12)))
1952 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
1953 (match_operand:SI 0 "register_operand" ""))
1954 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
1955 (match_operand:SI 1 "register_operand" ""))
1956 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -12)))
1957 (match_operand:SI 2 "register_operand" ""))])]
1958 "TARGET_H8300S && !TARGET_NORMAL_MODE
1959 && ((REGNO (operands[0]) == 0
1960 && REGNO (operands[1]) == 1
1961 && REGNO (operands[2]) == 2)
1962 || (REGNO (operands[0]) == 4
1963 && REGNO (operands[1]) == 5
1964 && REGNO (operands[2]) == 6))"
1965 "stm.l\\t%S0-%S2,@-er7"
1966 [(set_attr "cc" "none")
1967 (set_attr "length" "4")])
1969 (define_insn "stm_h8300s_3_normal"
1971 [(set (reg:HI SP_REG)
1972 (plus:HI (reg:HI SP_REG) (const_int -12)))
1973 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
1974 (match_operand:SI 0 "register_operand" ""))
1975 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
1976 (match_operand:SI 1 "register_operand" ""))
1977 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
1978 (match_operand:SI 2 "register_operand" ""))])]
1979 "TARGET_H8300S && TARGET_NORMAL_MODE
1980 && ((REGNO (operands[0]) == 0
1981 && REGNO (operands[1]) == 1
1982 && REGNO (operands[2]) == 2)
1983 || (REGNO (operands[0]) == 4
1984 && REGNO (operands[1]) == 5
1985 && REGNO (operands[2]) == 6))"
1986 "stm.l\\t%S0-%S2,@-er7"
1987 [(set_attr "cc" "none")
1988 (set_attr "length" "4")])
1990 (define_expand "stm_h8300s_3"
1991 [(use (match_operand:SI 0 "register_operand" ""))
1992 (use (match_operand:SI 1 "register_operand" ""))
1993 (use (match_operand:SI 2 "register_operand" ""))]
1995 && ((REGNO (operands[0]) == 0
1996 && REGNO (operands[1]) == 1
1997 && REGNO (operands[2]) == 2)
1998 || (REGNO (operands[0]) == 4
1999 && REGNO (operands[1]) == 5
2000 && REGNO (operands[2]) == 6))"
2003 if (!TARGET_NORMAL_MODE)
2004 emit_insn (gen_stm_h8300s_3_advanced (operands[0], operands[1],
2007 emit_insn (gen_stm_h8300s_3_normal (operands[0], operands[1],
2012 (define_insn "stm_h8300s_4_advanced"
2014 [(set (reg:SI SP_REG)
2015 (plus:SI (reg:SI SP_REG) (const_int -16)))
2016 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
2017 (match_operand:SI 0 "register_operand" ""))
2018 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
2019 (match_operand:SI 1 "register_operand" ""))
2020 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -12)))
2021 (match_operand:SI 2 "register_operand" ""))
2022 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -16)))
2023 (match_operand:SI 3 "register_operand" ""))])]
2024 "TARGET_H8300S && !TARGET_NORMAL_MODE
2025 && REGNO (operands[0]) == 0
2026 && REGNO (operands[1]) == 1
2027 && REGNO (operands[2]) == 2
2028 && REGNO (operands[3]) == 3"
2029 "stm.l\\t%S0-%S3,@-er7"
2030 [(set_attr "cc" "none")
2031 (set_attr "length" "4")])
2033 (define_insn "stm_h8300s_4_normal"
2035 [(set (reg:HI SP_REG)
2036 (plus:HI (reg:HI SP_REG) (const_int -16)))
2037 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
2038 (match_operand:SI 0 "register_operand" ""))
2039 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
2040 (match_operand:SI 1 "register_operand" ""))
2041 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
2042 (match_operand:SI 2 "register_operand" ""))
2043 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -16)))
2044 (match_operand:SI 3 "register_operand" ""))])]
2045 "TARGET_H8300S && TARGET_NORMAL_MODE
2046 && REGNO (operands[0]) == 0
2047 && REGNO (operands[1]) == 1
2048 && REGNO (operands[2]) == 2
2049 && REGNO (operands[3]) == 3"
2050 "stm.l\\t%S0-%S3,@-er7"
2051 [(set_attr "cc" "none")
2052 (set_attr "length" "4")])
2054 (define_expand "stm_h8300s_4"
2055 [(use (match_operand:SI 0 "register_operand" ""))
2056 (use (match_operand:SI 1 "register_operand" ""))
2057 (use (match_operand:SI 2 "register_operand" ""))
2058 (use (match_operand:SI 3 "register_operand" ""))]
2060 && REGNO (operands[0]) == 0
2061 && REGNO (operands[1]) == 1
2062 && REGNO (operands[2]) == 2
2063 && REGNO (operands[3]) == 3"
2066 if (!TARGET_NORMAL_MODE)
2067 emit_insn (gen_stm_h8300s_4_advanced (operands[0], operands[1],
2068 operands[2], operands[3]));
2070 emit_insn (gen_stm_h8300s_4_normal (operands[0], operands[1],
2071 operands[2], operands[3]));
2075 (define_insn "ldm_h8300s_2_advanced"
2077 [(set (reg:SI SP_REG)
2078 (plus:SI (reg:SI SP_REG) (const_int 8)))
2079 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int 4)))
2080 (match_operand:SI 0 "register_operand" ""))
2081 (set (mem:SI (reg:SI SP_REG))
2082 (match_operand:SI 1 "register_operand" ""))])]
2083 "TARGET_H8300S && !TARGET_NORMAL_MODE
2084 && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
2085 || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
2086 || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
2087 "ldm.l\\t@er7+,%S0-%S1"
2088 [(set_attr "cc" "none")
2089 (set_attr "length" "4")])
2091 (define_insn "ldm_h8300s_2_normal"
2093 [(set (reg:SI SP_REG)
2094 (plus:SI (reg:SI SP_REG) (const_int 8)))
2095 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int 4)))
2096 (match_operand:SI 0 "register_operand" ""))
2097 (set (mem:SI (reg:SI SP_REG))
2098 (match_operand:SI 1 "register_operand" ""))])]
2099 "TARGET_H8300S && TARGET_NORMAL_MODE
2100 && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
2101 || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
2102 || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
2103 "ldm.l\\t@er7+,%S0-%S1"
2104 [(set_attr "cc" "none")
2105 (set_attr "length" "4")])
2107 (define_expand "ldm_h8300s_2"
2108 [(use (match_operand:SI 0 "register_operand" ""))
2109 (use (match_operand:SI 1 "register_operand" ""))]
2111 && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
2112 || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
2113 || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
2116 if (!TARGET_NORMAL_MODE)
2117 emit_insn (gen_ldm_h8300s_2_advanced (operands[0], operands[1]));
2119 emit_insn (gen_ldm_h8300s_2_normal (operands[0], operands[1]));
2123 (define_insn "ldm_h8300s_3_advanced"
2125 [(set (reg:SI SP_REG)
2126 (plus:SI (reg:SI SP_REG) (const_int 12)))
2127 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int 8)))
2128 (match_operand:SI 0 "register_operand" ""))
2129 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int 4)))
2130 (match_operand:SI 1 "register_operand" ""))
2131 (set (mem:SI (reg:SI SP_REG))
2132 (match_operand:SI 2 "register_operand" ""))])]
2133 "TARGET_H8300S && !TARGET_NORMAL_MODE
2134 && ((REGNO (operands[0]) == 0
2135 && REGNO (operands[1]) == 1
2136 && REGNO (operands[2]) == 2)
2137 || (REGNO (operands[0]) == 4
2138 && REGNO (operands[1]) == 5
2139 && REGNO (operands[2]) == 6))"
2140 "ldm.l\\t@er7+,%S0-%S2"
2141 [(set_attr "cc" "none")
2142 (set_attr "length" "4")])
2144 (define_insn "ldm_h8300s_3_normal"
2146 [(set (reg:HI SP_REG)
2147 (plus:HI (reg:HI SP_REG) (const_int 12)))
2148 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int 8)))
2149 (match_operand:SI 0 "register_operand" ""))
2150 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int 4)))
2151 (match_operand:SI 1 "register_operand" ""))
2152 (set (mem:SI (reg:HI SP_REG))
2153 (match_operand:SI 2 "register_operand" ""))])]
2154 "TARGET_H8300S && TARGET_NORMAL_MODE
2155 && ((REGNO (operands[0]) == 0
2156 && REGNO (operands[1]) == 1
2157 && REGNO (operands[2]) == 2)
2158 || (REGNO (operands[0]) == 4
2159 && REGNO (operands[1]) == 5
2160 && REGNO (operands[2]) == 6))"
2161 "ldm.l\\t@er7+,%S0-%S2"
2162 [(set_attr "cc" "none")
2163 (set_attr "length" "4")])
2165 (define_expand "ldm_h8300s_3"
2166 [(use (match_operand:SI 0 "register_operand" ""))
2167 (use (match_operand:SI 1 "register_operand" ""))
2168 (use (match_operand:SI 2 "register_operand" ""))]
2170 && ((REGNO (operands[0]) == 0
2171 && REGNO (operands[1]) == 1
2172 && REGNO (operands[2]) == 2)
2173 || (REGNO (operands[0]) == 4
2174 && REGNO (operands[1]) == 5
2175 && REGNO (operands[2]) == 6))"
2178 if (!TARGET_NORMAL_MODE)
2179 emit_insn (gen_ldm_h8300s_3_advanced (operands[0], operands[1],
2182 emit_insn (gen_ldm_h8300s_3_normal (operands[0], operands[1],
2187 (define_insn "ldm_h8300s_4_advanced"
2189 [(set (reg:SI SP_REG)
2190 (plus:SI (reg:SI SP_REG) (const_int 16)))
2191 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int 12)))
2192 (match_operand:SI 0 "register_operand" ""))
2193 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int 8)))
2194 (match_operand:SI 1 "register_operand" ""))
2195 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int 4)))
2196 (match_operand:SI 2 "register_operand" ""))
2197 (set (mem:SI (reg:SI SP_REG))
2198 (match_operand:SI 3 "register_operand" ""))])]
2199 "TARGET_H8300S && !TARGET_NORMAL_MODE
2200 && REGNO (operands[0]) == 0
2201 && REGNO (operands[1]) == 1
2202 && REGNO (operands[2]) == 2
2203 && REGNO (operands[3]) == 3"
2204 "ldm.l\\t@er7+,%S0-%S3"
2205 [(set_attr "cc" "none")
2206 (set_attr "length" "4")])
2208 (define_insn "ldm_h8300s_4_normal"
2210 [(set (reg:HI SP_REG)
2211 (plus:HI (reg:HI SP_REG) (const_int 16)))
2212 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int 12)))
2213 (match_operand:SI 0 "register_operand" ""))
2214 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int 8)))
2215 (match_operand:SI 1 "register_operand" ""))
2216 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int 4)))
2217 (match_operand:SI 2 "register_operand" ""))
2218 (set (mem:SI (reg:HI SP_REG))
2219 (match_operand:SI 3 "register_operand" ""))])]
2220 "TARGET_H8300S && !TARGET_NORMAL_MODE
2221 && REGNO (operands[0]) == 0
2222 && REGNO (operands[1]) == 1
2223 && REGNO (operands[2]) == 2
2224 && REGNO (operands[3]) == 3"
2225 "ldm.l\\t@er7+,%S0-%S3"
2226 [(set_attr "cc" "none")
2227 (set_attr "length" "4")])
2229 (define_expand "ldm_h8300s_4"
2230 [(use (match_operand:SI 0 "register_operand" ""))
2231 (use (match_operand:SI 1 "register_operand" ""))
2232 (use (match_operand:SI 2 "register_operand" ""))
2233 (use (match_operand:SI 3 "register_operand" ""))]
2234 "TARGET_H8300S && !TARGET_NORMAL_MODE
2235 && REGNO (operands[0]) == 0
2236 && REGNO (operands[1]) == 1
2237 && REGNO (operands[2]) == 2
2238 && REGNO (operands[3]) == 3"
2241 if (!TARGET_NORMAL_MODE)
2242 emit_insn (gen_ldm_h8300s_4_advanced (operands[0], operands[1],
2243 operands[2], operands[3]));
2245 emit_insn (gen_ldm_h8300s_4_normal (operands[0], operands[1],
2246 operands[2], operands[3]));
2250 (define_expand "return"
2252 "h8300_can_use_return_insn_p ()"
2255 (define_insn "*return_1"
2260 if (h8300_current_function_interrupt_function_p ())
2265 [(set_attr "cc" "none")
2266 (set_attr "length" "2")])
2268 (define_expand "prologue"
2271 "h8300_expand_prologue (); DONE;")
2273 (define_expand "epilogue"
2276 "h8300_expand_epilogue ();")
2278 (define_insn "monitor_prologue"
2279 [(unspec_volatile [(const_int 0)] UNSPEC_MONITOR)]
2284 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\";
2285 else if (TARGET_H8300H)
2286 return \"mov.l\\ter0,@-er7\;stc\\tccr,r0l\;mov.b\\tr0l,@(4,er7)\;mov.l\\t@er7+,er0\;orc\\t#128,ccr\";
2287 else if (TARGET_H8300S)
2288 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\";
2291 [(set_attr "length" "20")
2292 (set_attr "cc" "clobber")])
2294 ;; ----------------------------------------------------------------------
2295 ;; EXTEND INSTRUCTIONS
2296 ;; ----------------------------------------------------------------------
2298 (define_expand "zero_extendqihi2"
2299 [(set (match_operand:HI 0 "register_operand" "")
2300 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "")))]
2304 (define_insn "*zero_extendqihi2_h8300"
2305 [(set (match_operand:HI 0 "register_operand" "=r,r")
2306 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2311 [(set_attr "length" "2,10")
2312 (set_attr "cc" "clobber,clobber")])
2314 (define_insn "*zero_extendqihi2_h8300hs"
2315 [(set (match_operand:HI 0 "register_operand" "=r,r")
2316 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2317 "TARGET_H8300H || TARGET_H8300S"
2321 [(set_attr "length" "2,10")
2322 (set_attr "cc" "set_znv,set_znv")])
2324 ;; Split the zero extension of a general operand (actually a memory
2325 ;; operand) into a load of the operand and the actual zero extension
2326 ;; so that 1) the length will be accurate, and 2) the zero extensions
2327 ;; appearing at the end of basic blocks may be merged.
2330 [(set (match_operand:HI 0 "register_operand" "")
2331 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "")))]
2336 (zero_extend:HI (match_dup 2)))]
2337 "operands[2] = gen_rtx_REG (QImode, REGNO (operands[0]));")
2339 (define_expand "zero_extendqisi2"
2340 [(set (match_operand:SI 0 "register_operand" "")
2341 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "")))]
2345 (define_insn "*zero_extendqisi2_h8300"
2346 [(set (match_operand:SI 0 "register_operand" "=r,r")
2347 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2350 mov.b #0,%x0\;sub.w %e0,%e0
2351 mov.b %R1,%w0\;mov.b #0,%x0\;sub.w %e0,%e0"
2352 [(set_attr "length" "4,8")
2353 (set_attr "cc" "clobber,clobber")])
2355 (define_insn "*zero_extendqisi2_h8300hs"
2356 [(set (match_operand:SI 0 "register_operand" "=r,r")
2357 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2358 "TARGET_H8300H || TARGET_H8300S"
2362 [(set (match_operand:SI 0 "register_operand" "")
2363 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "")))]
2364 "(TARGET_H8300H || TARGET_H8300S)
2365 && reg_overlap_mentioned_p (operands[0], operands[1])
2366 && reload_completed"
2370 (zero_extend:HI (match_dup 2)))
2372 (zero_extend:SI (match_dup 3)))]
2373 "operands[2] = gen_lowpart (QImode, operands[0]);
2374 operands[3] = gen_lowpart (HImode, operands[0]);")
2377 [(set (match_operand:SI 0 "register_operand" "")
2378 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "")))]
2379 "(TARGET_H8300H || TARGET_H8300S)
2380 && !reg_overlap_mentioned_p (operands[0], operands[1])
2381 && reload_completed"
2384 (set (strict_low_part (match_dup 2))
2386 "operands[2] = gen_rtx_REG (QImode, REGNO (operands[0]));")
2388 (define_expand "zero_extendhisi2"
2389 [(set (match_operand:SI 0 "register_operand" "")
2390 (zero_extend:SI (match_operand:HI 1 "register_operand" "")))]
2394 ;; %e prints the high part of a CONST_INT, not the low part. Arggh.
2395 (define_insn "*zero_extendhisi2_h8300"
2396 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
2397 (zero_extend:SI (match_operand:HI 1 "general_operand_src" "0,i,g>")))]
2401 mov.w %f1,%f0\;sub.w %e0,%e0
2402 mov.w %e1,%f0\;sub.w %e0,%e0"
2403 [(set_attr "length" "2,4,6")
2404 (set_attr "cc" "clobber,clobber,clobber")])
2407 [(set (match_operand:SI 0 "register_operand" "=r")
2408 (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))]
2409 "TARGET_H8300H || TARGET_H8300S"
2411 [(set_attr "length" "2")
2412 (set_attr "cc" "set_znv")])
2414 (define_expand "extendqihi2"
2415 [(set (match_operand:HI 0 "register_operand" "")
2416 (sign_extend:HI (match_operand:QI 1 "register_operand" "")))]
2421 [(set (match_operand:HI 0 "register_operand" "=r,r")
2422 (sign_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2425 bld #7,%s0\;subx %t0,%t0
2426 mov.b %R1,%s0\;bld #7,%s0\;subx %t0,%t0"
2427 [(set_attr "length" "4,8")
2428 (set_attr "cc" "clobber,clobber")])
2431 [(set (match_operand:HI 0 "register_operand" "=r")
2432 (sign_extend:HI (match_operand:QI 1 "register_operand" "0")))]
2433 "TARGET_H8300H || TARGET_H8300S"
2435 [(set_attr "length" "2")
2436 (set_attr "cc" "set_znv")])
2438 (define_expand "extendqisi2"
2439 [(set (match_operand:SI 0 "register_operand" "=r,r")
2440 (sign_extend:SI (match_operand:QI 1 "register_operand" "")))]
2444 (define_insn "*extendqisi2_h8300"
2445 [(set (match_operand:SI 0 "register_operand" "")
2446 (sign_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2449 bld #7,%w0\;subx %x0,%x0\;subx %y0,%y0\;subx %z0,%z0
2450 mov.b %R1,%w0\;bld #7,%w0\;subx %x0,%x0\;subx %y0,%y0\;subx %z0,%z0"
2451 [(set_attr "length" "8,12")
2452 (set_attr "cc" "clobber,clobber")])
2454 ;; The following pattern is needed because without the pattern, the
2455 ;; combiner would split (sign_extend:SI (reg:QI)) into into two 24-bit
2456 ;; shifts, one ashift and one ashiftrt.
2458 (define_insn_and_split "*extendqisi2_h8300hs"
2459 [(set (match_operand:SI 0 "register_operand" "=r")
2460 (sign_extend:SI (match_operand:QI 1 "register_operand" "0")))]
2461 "(TARGET_H8300H || TARGET_H8300S)"
2463 "&& reload_completed"
2465 (sign_extend:HI (match_dup 1)))
2467 (sign_extend:SI (match_dup 2)))]
2468 "operands[2] = gen_rtx_REG (HImode, REGNO (operands[0]));")
2470 (define_expand "extendhisi2"
2471 [(set (match_operand:SI 0 "register_operand" "")
2472 (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
2476 (define_insn "*extendhisi2_h8300"
2477 [(set (match_operand:SI 0 "register_operand" "=r,r")
2478 (sign_extend:SI (match_operand:HI 1 "general_operand_src" "0,g>")))]
2481 bld #7,%x0\;subx %y0,%y0\;subx %z0,%z0
2482 mov.w %T1,%f0\;bld #7,%x0\;subx %y0,%y0\;subx %z0,%z0"
2483 [(set_attr "length" "6,10")
2484 (set_attr "cc" "clobber,clobber")])
2487 [(set (match_operand:SI 0 "register_operand" "=r")
2488 (sign_extend:SI (match_operand:HI 1 "register_operand" "0")))]
2489 "TARGET_H8300H || TARGET_H8300S"
2491 [(set_attr "length" "2")
2492 (set_attr "cc" "set_znv")])
2494 ;; ----------------------------------------------------------------------
2496 ;; ----------------------------------------------------------------------
2498 ;; We make some attempt to provide real efficient shifting. One example is
2499 ;; doing an 8 bit shift of a 16 bit value by moving a byte reg into the other
2500 ;; reg and moving 0 into the former reg.
2502 ;; We also try to achieve this in a uniform way. IE: We don't try to achieve
2503 ;; this in both rtl and at insn emit time. Ideally, we'd use rtl as that would
2504 ;; give the optimizer more cracks at the code. However, we wish to do things
2505 ;; like optimizing shifting the sign bit to bit 0 by rotating the other way.
2506 ;; There is rtl to handle this (rotate + and), but the H8/300 doesn't handle
2507 ;; 16 bit rotates. Also, if we emit complicated rtl, combine may not be able
2508 ;; to detect cases it can optimize.
2510 ;; For these and other fuzzy reasons, I've decided to go the less pretty but
2511 ;; easier "do it at insn emit time" route.
2515 (define_expand "ashlqi3"
2516 [(set (match_operand:QI 0 "register_operand" "")
2517 (ashift:QI (match_operand:QI 1 "register_operand" "")
2518 (match_operand:QI 2 "nonmemory_operand" "")))]
2520 "expand_a_shift (QImode, ASHIFT, operands); DONE;")
2522 (define_expand "ashrqi3"
2523 [(set (match_operand:QI 0 "register_operand" "")
2524 (ashiftrt:QI (match_operand:QI 1 "register_operand" "")
2525 (match_operand:QI 2 "nonmemory_operand" "")))]
2527 "expand_a_shift (QImode, ASHIFTRT, operands); DONE;")
2529 (define_expand "lshrqi3"
2530 [(set (match_operand:QI 0 "register_operand" "")
2531 (lshiftrt:QI (match_operand:QI 1 "register_operand" "")
2532 (match_operand:QI 2 "nonmemory_operand" "")))]
2534 "expand_a_shift (QImode, LSHIFTRT, operands); DONE;")
2537 [(set (match_operand:QI 0 "register_operand" "=r,r")
2538 (match_operator:QI 3 "nshift_operator"
2539 [ (match_operand:QI 1 "register_operand" "0,0")
2540 (match_operand:QI 2 "nonmemory_operand" "R,rn")]))
2541 (clobber (match_scratch:QI 4 "=X,&r"))]
2543 "* return output_a_shift (operands);"
2544 [(set (attr "length")
2545 (symbol_ref "compute_a_shift_length (insn, operands)"))
2547 (symbol_ref "compute_a_shift_cc (insn, operands)"))])
2551 (define_expand "ashlhi3"
2552 [(set (match_operand:HI 0 "register_operand" "")
2553 (ashift:HI (match_operand:HI 1 "nonmemory_operand" "")
2554 (match_operand:QI 2 "nonmemory_operand" "")))]
2556 "expand_a_shift (HImode, ASHIFT, operands); DONE;")
2558 (define_expand "lshrhi3"
2559 [(set (match_operand:HI 0 "register_operand" "")
2560 (lshiftrt:HI (match_operand:HI 1 "general_operand" "")
2561 (match_operand:QI 2 "nonmemory_operand" "")))]
2563 "expand_a_shift (HImode, LSHIFTRT, operands); DONE;")
2565 (define_expand "ashrhi3"
2566 [(set (match_operand:HI 0 "register_operand" "")
2567 (ashiftrt:HI (match_operand:HI 1 "register_operand" "")
2568 (match_operand:QI 2 "nonmemory_operand" "")))]
2570 "expand_a_shift (HImode, ASHIFTRT, operands); DONE;")
2573 [(set (match_operand:HI 0 "register_operand" "=r,r")
2574 (match_operator:HI 3 "nshift_operator"
2575 [ (match_operand:HI 1 "register_operand" "0,0")
2576 (match_operand:QI 2 "nonmemory_operand" "S,rn")]))
2577 (clobber (match_scratch:QI 4 "=X,&r"))]
2579 "* return output_a_shift (operands);"
2580 [(set (attr "length")
2581 (symbol_ref "compute_a_shift_length (insn, operands)"))
2583 (symbol_ref "compute_a_shift_cc (insn, operands)"))])
2587 (define_expand "ashlsi3"
2588 [(set (match_operand:SI 0 "register_operand" "")
2589 (ashift:SI (match_operand:SI 1 "general_operand" "")
2590 (match_operand:QI 2 "nonmemory_operand" "")))]
2592 "expand_a_shift (SImode, ASHIFT, operands); DONE;")
2594 (define_expand "lshrsi3"
2595 [(set (match_operand:SI 0 "register_operand" "")
2596 (lshiftrt:SI (match_operand:SI 1 "general_operand" "")
2597 (match_operand:QI 2 "nonmemory_operand" "")))]
2599 "expand_a_shift (SImode, LSHIFTRT, operands); DONE;")
2601 (define_expand "ashrsi3"
2602 [(set (match_operand:SI 0 "register_operand" "")
2603 (ashiftrt:SI (match_operand:SI 1 "general_operand" "")
2604 (match_operand:QI 2 "nonmemory_operand" "")))]
2606 "expand_a_shift (SImode, ASHIFTRT, operands); DONE;")
2609 [(set (match_operand:SI 0 "register_operand" "=r,r")
2610 (match_operator:SI 3 "nshift_operator"
2611 [ (match_operand:SI 1 "register_operand" "0,0")
2612 (match_operand:QI 2 "nonmemory_operand" "T,rn")]))
2613 (clobber (match_scratch:QI 4 "=X,&r"))]
2615 "* return output_a_shift (operands);"
2616 [(set (attr "length")
2617 (symbol_ref "compute_a_shift_length (insn, operands)"))
2619 (symbol_ref "compute_a_shift_cc (insn, operands)"))])
2621 ;; Split a variable shift into a loop. If the register containing
2622 ;; the shift count dies, then we just use that register.
2626 [(set (match_operand 0 "register_operand" "")
2627 (match_operator 2 "nshift_operator"
2629 (match_operand:QI 1 "register_operand" "")]))
2630 (clobber (match_operand:QI 3 "register_operand" ""))])]
2632 && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))"
2636 (if_then_else (le (cc0) (const_int 0))
2637 (label_ref (match_dup 5))
2642 (match_op_dup 2 [(match_dup 0) (const_int 1)]))
2643 (clobber (scratch:QI))])
2645 (plus:QI (match_dup 1) (const_int -1)))
2649 (if_then_else (ne (cc0) (const_int 0))
2650 (label_ref (match_dup 4))
2653 "operands[4] = gen_label_rtx ();
2654 operands[5] = gen_label_rtx ();")
2658 [(set (match_operand 0 "register_operand" "")
2659 (match_operator 2 "nshift_operator"
2661 (match_operand:QI 1 "register_operand" "")]))
2662 (clobber (match_operand:QI 3 "register_operand" ""))])]
2664 && !find_regno_note (insn, REG_DEAD, REGNO (operands[1]))"
2670 (if_then_else (le (cc0) (const_int 0))
2671 (label_ref (match_dup 5))
2676 (match_op_dup 2 [(match_dup 0) (const_int 1)]))
2677 (clobber (scratch:QI))])
2679 (plus:QI (match_dup 3) (const_int -1)))
2683 (if_then_else (ne (cc0) (const_int 0))
2684 (label_ref (match_dup 4))
2687 "operands[4] = gen_label_rtx ();
2688 operands[5] = gen_label_rtx ();")
2690 ;; ----------------------------------------------------------------------
2692 ;; ----------------------------------------------------------------------
2694 (define_expand "rotlqi3"
2695 [(set (match_operand:QI 0 "register_operand" "")
2696 (rotate:QI (match_operand:QI 1 "register_operand" "")
2697 (match_operand:QI 2 "nonmemory_operand" "")))]
2699 "if (expand_a_rotate (ROTATE, operands)) DONE; else FAIL;")
2701 (define_insn "*rotlqi3_1"
2702 [(set (match_operand:QI 0 "register_operand" "=r")
2703 (rotate:QI (match_operand:QI 1 "register_operand" "0")
2704 (match_operand:QI 2 "immediate_operand" "")))]
2706 "* return output_a_rotate (ROTATE, operands);"
2707 [(set (attr "length")
2708 (symbol_ref "compute_a_rotate_length (operands)"))
2709 (set_attr "cc" "clobber")])
2711 (define_expand "rotlhi3"
2712 [(set (match_operand:HI 0 "register_operand" "")
2713 (rotate:HI (match_operand:HI 1 "register_operand" "")
2714 (match_operand:QI 2 "nonmemory_operand" "")))]
2716 "if (expand_a_rotate (ROTATE, operands)) DONE; else FAIL;")
2718 (define_insn "*rotlhi3_1"
2719 [(set (match_operand:HI 0 "register_operand" "=r")
2720 (rotate:HI (match_operand:HI 1 "register_operand" "0")
2721 (match_operand:QI 2 "immediate_operand" "")))]
2723 "* return output_a_rotate (ROTATE, operands);"
2724 [(set (attr "length")
2725 (symbol_ref "compute_a_rotate_length (operands)"))
2726 (set_attr "cc" "clobber")])
2728 (define_expand "rotlsi3"
2729 [(set (match_operand:SI 0 "register_operand" "")
2730 (rotate:SI (match_operand:SI 1 "register_operand" "")
2731 (match_operand:QI 2 "nonmemory_operand" "")))]
2732 "TARGET_H8300H || TARGET_H8300S"
2733 "if (expand_a_rotate (ROTATE, operands)) DONE; else FAIL;")
2735 (define_insn "*rotlsi3_1"
2736 [(set (match_operand:SI 0 "register_operand" "=r")
2737 (rotate:SI (match_operand:SI 1 "register_operand" "0")
2738 (match_operand:QI 2 "immediate_operand" "")))]
2739 "TARGET_H8300H || TARGET_H8300S"
2740 "* return output_a_rotate (ROTATE, operands);"
2741 [(set (attr "length")
2742 (symbol_ref "compute_a_rotate_length (operands)"))
2743 (set_attr "cc" "clobber")])
2745 ;; -----------------------------------------------------------------
2747 ;; -----------------------------------------------------------------
2748 ;; The H8/300 has given 1/8th of its opcode space to bitfield
2749 ;; instructions so let's use them as well as we can.
2751 ;; You'll never believe all these patterns perform one basic action --
2752 ;; load a bit from the source, optionally invert the bit, then store it
2753 ;; in the destination (which is known to be zero).
2755 ;; Combine obviously need some work to better identify this situation and
2756 ;; canonicalize the form better.
2759 ;; Normal loads with a 16bit destination.
2763 [(set (match_operand:HI 0 "register_operand" "=&r")
2764 (zero_extract:HI (match_operand:HI 1 "register_operand" "r")
2766 (match_operand:HI 2 "immediate_operand" "n")))]
2768 "sub.w %0,%0\;bld %Z2,%Y1\;bst #0,%X0"
2769 [(set_attr "cc" "clobber")
2770 (set_attr "length" "6")])
2773 ;; Inverted loads with a 16bit destination.
2777 [(set (match_operand:HI 0 "register_operand" "=&r")
2778 (zero_extract:HI (xor:HI (match_operand:HI 1 "register_operand" "r")
2779 (match_operand:HI 3 "const_int_operand" "n"))
2781 (match_operand:HI 2 "const_int_operand" "n")))]
2783 && (1 << INTVAL (operands[2])) == INTVAL (operands[3])"
2784 "sub.w %0,%0\;bild %Z2,%Y1\;bst #0,%X0"
2785 [(set_attr "cc" "clobber")
2786 (set_attr "length" "8")])
2789 ;; Normal loads with a 32bit destination.
2792 (define_insn "*extzv_1_r_h8300"
2793 [(set (match_operand:SI 0 "register_operand" "=&r")
2794 (zero_extract:SI (match_operand:HI 1 "register_operand" "r")
2796 (match_operand 2 "const_int_operand" "n")))]
2798 && INTVAL (operands[2]) < 16"
2799 "* return output_simode_bld (0, operands);"
2800 [(set_attr "cc" "clobber")
2801 (set_attr "length" "8")])
2803 (define_insn "*extzv_1_r_h8300hs"
2804 [(set (match_operand:SI 0 "register_operand" "=r,r")
2805 (zero_extract:SI (match_operand:SI 1 "register_operand" "?0,r")
2807 (match_operand 2 "const_int_operand" "n,n")))]
2808 "(TARGET_H8300H || TARGET_H8300S)
2809 && INTVAL (operands[2]) < 16"
2810 "* return output_simode_bld (0, operands);"
2811 [(set_attr "cc" "set_znv,set_znv")
2812 (set_attr "length" "8,6")])
2815 ;; Inverted loads with a 32bit destination.
2818 (define_insn "*extzv_1_r_inv_h8300"
2819 [(set (match_operand:SI 0 "register_operand" "=&r")
2820 (zero_extract:SI (xor:HI (match_operand:HI 1 "register_operand" "r")
2821 (match_operand:HI 3 "const_int_operand" "n"))
2823 (match_operand 2 "const_int_operand" "n")))]
2825 && INTVAL (operands[2]) < 16
2826 && (1 << INTVAL (operands[2])) == INTVAL (operands[3])"
2827 "* return output_simode_bld (1, operands);"
2828 [(set_attr "cc" "clobber")
2829 (set_attr "length" "8")])
2831 (define_insn "*extzv_1_r_inv_h8300hs"
2832 [(set (match_operand:SI 0 "register_operand" "=r,r")
2833 (zero_extract:SI (xor:SI (match_operand:SI 1 "register_operand" "?0,r")
2834 (match_operand 3 "const_int_operand" "n,n"))
2836 (match_operand 2 "const_int_operand" "n,n")))]
2837 "(TARGET_H8300H || TARGET_H8300S)
2838 && INTVAL (operands[2]) < 16
2839 && (1 << INTVAL (operands[2])) == INTVAL (operands[3])"
2840 "* return output_simode_bld (1, operands);"
2841 [(set_attr "cc" "set_znv,set_znv")
2842 (set_attr "length" "8,6")])
2844 (define_expand "insv"
2845 [(set (zero_extract:HI (match_operand:HI 0 "general_operand" "")
2846 (match_operand:HI 1 "general_operand" "")
2847 (match_operand:HI 2 "general_operand" ""))
2848 (match_operand:HI 3 "general_operand" ""))]
2852 /* We only have single bit bit-field instructions. */
2853 if (INTVAL (operands[1]) != 1)
2856 /* For now, we don't allow memory operands. */
2857 if (GET_CODE (operands[0]) == MEM
2858 || GET_CODE (operands[3]) == MEM)
2863 [(set (zero_extract:HI (match_operand:HI 0 "register_operand" "+r")
2865 (match_operand:HI 1 "immediate_operand" "n"))
2866 (match_operand:HI 2 "register_operand" "r"))]
2868 "bld #0,%R2\;bst %Z1,%Y0 ; i1"
2869 [(set_attr "cc" "clobber")
2870 (set_attr "length" "4")])
2872 (define_expand "extzv"
2873 [(set (match_operand:HI 0 "register_operand" "")
2874 (zero_extract:HI (match_operand:HI 1 "bit_operand" "")
2875 (match_operand:HI 2 "general_operand" "")
2876 (match_operand:HI 3 "general_operand" "")))]
2880 /* We only have single bit bit-field instructions. */
2881 if (INTVAL (operands[2]) != 1)
2884 /* For now, we don't allow memory operands. */
2885 if (GET_CODE (operands[1]) == MEM)
2889 ;; BAND, BOR, and BXOR patterns
2892 [(set (match_operand:HI 0 "bit_operand" "=Ur")
2893 (match_operator:HI 4 "bit_operator"
2894 [(zero_extract:HI (match_operand:HI 1 "register_operand" "r")
2896 (match_operand:HI 2 "immediate_operand" "n"))
2897 (match_operand:HI 3 "bit_operand" "0")]))]
2899 "bld %Z2,%Y1\;b%c4 #0,%R0\;bst #0,%R0; bl1"
2900 [(set_attr "cc" "clobber")
2901 (set_attr "length" "6")])
2904 [(set (match_operand:HI 0 "bit_operand" "=Ur")
2905 (match_operator:HI 5 "bit_operator"
2906 [(zero_extract:HI (match_operand:HI 1 "register_operand" "r")
2908 (match_operand:HI 2 "immediate_operand" "n"))
2909 (zero_extract:HI (match_operand:HI 3 "register_operand" "r")
2911 (match_operand:HI 4 "immediate_operand" "n"))]))]
2913 "bld %Z2,%Y1\;b%c5 %Z4,%Y3\;bst #0,%R0; bl3"
2914 [(set_attr "cc" "clobber")
2915 (set_attr "length" "6")])
2917 ;; -----------------------------------------------------------------
2919 ;; -----------------------------------------------------------------
2923 (define_insn "*insv_si_1_n"
2924 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
2926 (match_operand:SI 1 "const_int_operand" "n"))
2927 (match_operand:SI 2 "register_operand" "r"))]
2928 "(TARGET_H8300H || TARGET_H8300S)
2929 && INTVAL (operands[1]) < 16"
2930 "bld\\t#0,%w2\;bst\\t%Z1,%Y0"
2931 [(set_attr "cc" "clobber")
2932 (set_attr "length" "4")])
2934 (define_insn "*insv_si_1_n_lshiftrt"
2935 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
2937 (match_operand:SI 1 "const_int_operand" "n"))
2938 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
2939 (match_operand:SI 3 "const_int_operand" "n")))]
2940 "(TARGET_H8300H || TARGET_H8300S)
2941 && INTVAL (operands[1]) < 16
2942 && INTVAL (operands[3]) < 16"
2943 "bld\\t%Z3,%Y2\;bst\\t%Z1,%Y0"
2944 [(set_attr "cc" "clobber")
2945 (set_attr "length" "4")])
2947 (define_insn "*insv_si_1_n_lshiftrt_16"
2948 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
2950 (match_operand:SI 1 "const_int_operand" "n"))
2951 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
2953 "(TARGET_H8300H || TARGET_H8300S)
2954 && INTVAL (operands[1]) < 16"
2955 "rotr.w\\t%e2\;rotl.w\\t%e2\;bst\\t%Z1,%Y0"
2956 [(set_attr "cc" "clobber")
2957 (set_attr "length" "6")])
2959 (define_insn "*insv_si_8_8"
2960 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
2963 (match_operand:SI 1 "register_operand" "r"))]
2964 "TARGET_H8300H || TARGET_H8300S"
2966 [(set_attr "cc" "clobber")
2967 (set_attr "length" "2")])
2969 (define_insn "*insv_si_8_8_lshiftrt_8"
2970 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
2973 (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
2975 "TARGET_H8300H || TARGET_H8300S"
2977 [(set_attr "cc" "clobber")
2978 (set_attr "length" "2")])
2982 (define_insn "*extzv_8_8"
2983 [(set (match_operand:SI 0 "register_operand" "=r,r")
2984 (zero_extract:SI (match_operand:SI 1 "register_operand" "?0,r")
2987 "TARGET_H8300H || TARGET_H8300S"
2989 mov.b\\t%x1,%w0\;extu.w\\t%f0\;extu.l\\t%S0
2990 sub.l\\t%S0,%S0\;mov.b\\t%x1,%w0"
2991 [(set_attr "cc" "set_znv,clobber")
2992 (set_attr "length" "6,4")])
2994 (define_insn "*extzv_8_16"
2995 [(set (match_operand:SI 0 "register_operand" "=r")
2996 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
2999 "TARGET_H8300H || TARGET_H8300S"
3000 "mov.w\\t%e1,%f0\;extu.w\\t%f0\;extu.l\\t%S0"
3001 [(set_attr "cc" "set_znv")
3002 (set_attr "length" "6")])
3004 (define_insn "*extzv_16_8"
3005 [(set (match_operand:SI 0 "register_operand" "=r")
3006 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
3009 (clobber (match_scratch:SI 2 "=&r"))]
3011 "mov.w\\t%e1,%f2\;mov.b\\t%x1,%w0\;mov.b\\t%w2,%x0\;extu.l\\t%S0"
3012 [(set_attr "length" "8")
3013 (set_attr "cc" "set_znv")])
3015 ;; Extract the exponent of a float.
3017 (define_insn_and_split "*extzv_8_23"
3018 [(set (match_operand:SI 0 "register_operand" "=r")
3019 (zero_extract:SI (match_operand:SI 1 "register_operand" "0")
3022 "(TARGET_H8300H || TARGET_H8300S)"
3024 "&& reload_completed"
3025 [(parallel [(set (match_dup 0)
3026 (ashift:SI (match_dup 0)
3028 (clobber (scratch:QI))])
3029 (parallel [(set (match_dup 0)
3030 (lshiftrt:SI (match_dup 0)
3032 (clobber (scratch:QI))])]
3037 ;; ((SImode) HImode) << 15
3039 (define_insn_and_split "*twoshifts_l16_r1"
3040 [(set (match_operand:SI 0 "register_operand" "=r")
3041 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
3043 (const_int 2147450880)))]
3044 "(TARGET_H8300H || TARGET_H8300S)"
3046 "&& reload_completed"
3047 [(parallel [(set (match_dup 0)
3048 (ashift:SI (match_dup 0)
3050 (clobber (scratch:QI))])
3051 (parallel [(set (match_dup 0)
3052 (lshiftrt:SI (match_dup 0)
3054 (clobber (scratch:QI))])]
3057 ;; Transform (SImode << B) & 0xffff into (SImode) (HImode << B).
3059 (define_insn_and_split "*andsi3_ashift_n_lower"
3060 [(set (match_operand:SI 0 "register_operand" "=r,r")
3061 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "0,0")
3062 (match_operand:QI 2 "const_int_operand" "S,n"))
3063 (match_operand:SI 3 "const_int_operand" "n,n")))
3064 (clobber (match_scratch:QI 4 "=X,&r"))]
3065 "(TARGET_H8300H || TARGET_H8300S)
3066 && INTVAL (operands[2]) <= 15
3067 && INTVAL (operands[3]) == ((-1 << INTVAL (operands[2])) & 0xffff)"
3069 "&& reload_completed"
3070 [(parallel [(set (match_dup 5)
3071 (ashift:HI (match_dup 5)
3073 (clobber (match_dup 4))])
3075 (zero_extend:SI (match_dup 5)))]
3076 "operands[5] = gen_rtx_REG (HImode, REGNO (operands[0]));")
3078 ;; Accept (A >> 30) & 2 and the like.
3080 (define_insn "*andsi3_lshiftrt_n_sb"
3081 [(set (match_operand:SI 0 "register_operand" "=r")
3082 (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
3083 (match_operand:SI 2 "const_int_operand" "n"))
3084 (match_operand:SI 3 "single_one_operand" "n")))]
3085 "(TARGET_H8300H || TARGET_H8300S)
3086 && exact_log2 (INTVAL (operands[3])) < 16
3087 && INTVAL (operands[2]) + exact_log2 (INTVAL (operands[3])) == 31"
3090 operands[3] = GEN_INT (exact_log2 (INTVAL (operands[3])));
3091 return \"shll.l\\t%S0\;xor.l\\t%S0,%S0\;bst\\t%Z3,%Y0\";
3093 [(set_attr "length" "8")
3094 (set_attr "cc" "clobber")])
3096 (define_insn_and_split "*andsi3_lshiftrt_9_sb"
3097 [(set (match_operand:SI 0 "register_operand" "=r")
3098 (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
3100 (const_int 4194304)))]
3101 "(TARGET_H8300H || TARGET_H8300S)"
3103 "&& reload_completed"
3105 (and:SI (lshiftrt:SI (match_dup 0)
3108 (parallel [(set (match_dup 0)
3109 (ashift:SI (match_dup 0)
3111 (clobber (scratch:QI))])]
3116 (define_insn "*addsi3_upper"
3117 [(set (match_operand:SI 0 "register_operand" "=r")
3118 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
3120 (match_operand:SI 2 "register_operand" "0")))]
3121 "TARGET_H8300H || TARGET_H8300S"
3123 [(set_attr "length" "2")
3124 (set_attr "cc" "clobber")])
3126 (define_insn "*addsi3_lshiftrt_16_zexthi"
3127 [(set (match_operand:SI 0 "register_operand" "=r")
3128 (plus:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3130 (zero_extend:SI (match_operand:HI 2 "register_operand" "0"))))]
3131 "TARGET_H8300H || TARGET_H8300S"
3132 "add.w\\t%e1,%f0\;xor.w\\t%e0,%e0\;rotxl.w\\t%e0"
3133 [(set_attr "cc" "clobber")
3134 (set_attr "length" "6")])
3136 (define_insn_and_split "*addsi3_and_r_1"
3137 [(set (match_operand:SI 0 "register_operand" "=r")
3138 (plus:SI (and:SI (match_operand:SI 1 "register_operand" "r")
3140 (match_operand:SI 2 "register_operand" "0")))]
3141 "(TARGET_H8300H || TARGET_H8300S)"
3143 "&& reload_completed"
3145 (zero_extract:SI (match_dup 1)
3149 (if_then_else (eq (cc0)
3151 (label_ref (match_dup 3))
3154 (plus:SI (match_dup 2)
3157 "operands[3] = gen_label_rtx ();")
3159 (define_insn_and_split "*addsi3_and_not_r_1"
3160 [(set (match_operand:SI 0 "register_operand" "=r")
3161 (plus:SI (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
3163 (match_operand:SI 2 "register_operand" "0")))]
3164 "(TARGET_H8300H || TARGET_H8300S)"
3166 "&& reload_completed"
3168 (zero_extract:SI (match_dup 1)
3172 (if_then_else (ne (cc0)
3174 (label_ref (match_dup 3))
3177 (plus:SI (match_dup 2)
3180 "operands[3] = gen_label_rtx ();")
3184 (define_insn "*ixorhi3_zext"
3185 [(set (match_operand:HI 0 "register_operand" "=r")
3186 (match_operator:HI 1 "iorxor_operator"
3187 [(zero_extend:HI (match_operand:QI 2 "register_operand" "r"))
3188 (match_operand:HI 3 "register_operand" "0")]))]
3191 [(set_attr "cc" "clobber")
3192 (set_attr "length" "2")])
3196 (define_insn "*ixorsi3_zext_qi"
3197 [(set (match_operand:SI 0 "register_operand" "=r")
3198 (match_operator:SI 1 "iorxor_operator"
3199 [(zero_extend:SI (match_operand:QI 2 "register_operand" "r"))
3200 (match_operand:SI 3 "register_operand" "0")]))]
3203 [(set_attr "cc" "clobber")
3204 (set_attr "length" "2")])
3206 (define_insn "*ixorsi3_zext_hi"
3207 [(set (match_operand:SI 0 "register_operand" "=r")
3208 (match_operator:SI 1 "iorxor_operator"
3209 [(zero_extend:SI (match_operand:HI 2 "register_operand" "r"))
3210 (match_operand:SI 3 "register_operand" "0")]))]
3211 "TARGET_H8300H || TARGET_H8300S"
3213 [(set_attr "cc" "clobber")
3214 (set_attr "length" "2")])
3216 (define_insn "*ixorsi3_ashift_16"
3217 [(set (match_operand:SI 0 "register_operand" "=r")
3218 (match_operator:SI 1 "iorxor_operator"
3219 [(ashift:SI (match_operand:SI 2 "register_operand" "r")
3221 (match_operand:SI 3 "register_operand" "0")]))]
3222 "TARGET_H8300H || TARGET_H8300S"
3224 [(set_attr "cc" "clobber")
3225 (set_attr "length" "2")])
3227 (define_insn "*ixorsi3_lshiftrt_16"
3228 [(set (match_operand:SI 0 "register_operand" "=r")
3229 (match_operator:SI 1 "iorxor_operator"
3230 [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
3232 (match_operand:SI 3 "register_operand" "0")]))]
3233 "TARGET_H8300H || TARGET_H8300S"
3235 [(set_attr "cc" "clobber")
3236 (set_attr "length" "2")])
3240 (define_insn "*iorhi3_ashift_8"
3241 [(set (match_operand:HI 0 "register_operand" "=r")
3242 (ior:HI (ashift:HI (match_operand:HI 1 "register_operand" "r")
3244 (match_operand:HI 2 "register_operand" "0")))]
3247 [(set_attr "cc" "clobber")
3248 (set_attr "length" "2")])
3250 (define_insn "*iorhi3_lshiftrt_8"
3251 [(set (match_operand:HI 0 "register_operand" "=r")
3252 (ior:HI (lshiftrt:HI (match_operand:HI 1 "register_operand" "r")
3254 (match_operand:HI 2 "register_operand" "0")))]
3257 [(set_attr "cc" "clobber")
3258 (set_attr "length" "2")])
3260 (define_insn "*iorhi3_two_qi"
3261 [(set (match_operand:HI 0 "register_operand" "=r")
3262 (ior:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "0"))
3263 (ashift:HI (match_operand:HI 2 "register_operand" "r")
3267 [(set_attr "cc" "clobber")
3268 (set_attr "length" "2")])
3270 (define_insn "*iorhi3_two_qi_mem"
3271 [(set (match_operand:HI 0 "register_operand" "=&r")
3272 (ior:HI (zero_extend:HI (match_operand:QI 1 "memory_operand" "m"))
3273 (ashift:HI (subreg:HI (match_operand:QI 2 "memory_operand" "m") 0)
3276 "mov.b\\t%X2,%t0\;mov.b\\t%X1,%s0"
3277 [(set_attr "cc" "clobber")
3278 (set_attr "length" "16")])
3281 [(set (match_operand:HI 0 "register_operand" "")
3282 (ior:HI (zero_extend:HI (match_operand:QI 1 "memory_operand" ""))
3283 (ashift:HI (subreg:HI (match_operand:QI 2 "memory_operand" "") 0)
3285 "(TARGET_H8300H || TARGET_H8300S)
3287 && byte_accesses_mergeable_p (XEXP (operands[2], 0), XEXP (operands[1], 0))"
3290 "operands[3] = gen_rtx_MEM (HImode, XEXP (operands[2], 0));")
3294 (define_insn "*iorsi3_two_hi"
3295 [(set (match_operand:SI 0 "register_operand" "=r")
3296 (ior:SI (zero_extend:SI (match_operand:HI 1 "register_operand" "0"))
3297 (ashift:SI (match_operand:SI 2 "register_operand" "r")
3299 "TARGET_H8300H || TARGET_H8300S"
3301 [(set_attr "cc" "clobber")
3302 (set_attr "length" "2")])
3304 (define_insn_and_split "*iorsi3_two_qi_zext"
3305 [(set (match_operand:SI 0 "register_operand" "=&r")
3306 (ior:SI (zero_extend:SI (match_operand:QI 1 "memory_operand" "m"))
3308 (and:SI (ashift:SI (subreg:SI (match_operand:QI 2 "memory_operand" "m") 0)
3310 (const_int 65280))))]
3311 "(TARGET_H8300H || TARGET_H8300S)"
3313 "&& reload_completed"
3315 (ior:HI (zero_extend:HI (match_dup 1))
3316 (ashift:HI (subreg:HI (match_dup 2) 0)
3319 (zero_extend:SI (match_dup 3)))]
3320 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));")
3322 (define_insn "*iorsi3_e2f"
3323 [(set (match_operand:SI 0 "register_operand" "=r")
3324 (ior:SI (and:SI (match_operand:SI 1 "register_operand" "0")
3326 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
3328 "TARGET_H8300H || TARGET_H8300S"
3330 [(set_attr "length" "2")
3331 (set_attr "cc" "clobber")])
3333 (define_insn_and_split "*iorsi3_two_qi_sext"
3334 [(set (match_operand:SI 0 "register_operand" "=r")
3335 (ior:SI (zero_extend:SI (match_operand:QI 1 "register_operand" "0"))
3336 (ashift:SI (sign_extend:SI (match_operand:QI 2 "register_operand" "r"))
3338 "(TARGET_H8300H || TARGET_H8300S)"
3340 "&& reload_completed"
3342 (ior:HI (zero_extend:HI (match_dup 1))
3343 (ashift:HI (match_dup 4)
3346 (sign_extend:SI (match_dup 3)))]
3347 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));
3348 operands[4] = gen_rtx_REG (HImode, REGNO (operands[2]));")
3350 (define_insn "*iorsi3_w"
3351 [(set (match_operand:SI 0 "register_operand" "=r,&r")
3352 (ior:SI (and:SI (match_operand:SI 1 "register_operand" "0,0")
3354 (zero_extend:SI (match_operand:QI 2 "general_operand_src" "r,g>"))))]
3355 "TARGET_H8300H || TARGET_H8300S"
3357 [(set_attr "length" "2,8")
3358 (set_attr "cc" "clobber,clobber")])
3360 (define_insn "*iorsi3_ashift_31"
3361 [(set (match_operand:SI 0 "register_operand" "=&r")
3362 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
3364 (match_operand:SI 2 "register_operand" "0")))]
3365 "TARGET_H8300H || TARGET_H8300S"
3366 "rotxl.l\\t%S0\;bor\\t#0,%w1\;rotxr.l\\t%S0"
3367 [(set_attr "length" "6")
3368 (set_attr "cc" "set_znv")])
3370 (define_insn "*iorsi3_and_ashift"
3371 [(set (match_operand:SI 0 "register_operand" "=r")
3372 (ior:SI (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
3373 (match_operand:SI 2 "const_int_operand" "n"))
3374 (match_operand:SI 3 "single_one_operand" "n"))
3375 (match_operand:SI 4 "register_operand" "0")))]
3376 "(TARGET_H8300H || TARGET_H8300S)
3377 && (INTVAL (operands[3]) & ~0xffff) == 0"
3380 rtx srcpos = GEN_INT (exact_log2 (INTVAL (operands[3]))
3381 - INTVAL (operands[2]));
3382 rtx dstpos = GEN_INT (exact_log2 (INTVAL (operands[3])));
3383 operands[2] = srcpos;
3384 operands[3] = dstpos;
3385 return \"bld\\t%Z2,%Y1\;bor\\t%Z3,%Y0\;bst\\t%Z3,%Y0\";
3387 [(set_attr "length" "6")
3388 (set_attr "cc" "clobber")])
3390 (define_insn "*iorsi3_and_lshiftrt"
3391 [(set (match_operand:SI 0 "register_operand" "=r")
3392 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3393 (match_operand:SI 2 "const_int_operand" "n"))
3394 (match_operand:SI 3 "single_one_operand" "n"))
3395 (match_operand:SI 4 "register_operand" "0")))]
3396 "(TARGET_H8300H || TARGET_H8300S)
3397 && ((INTVAL (operands[3]) << INTVAL (operands[2])) & ~0xffff) == 0"
3400 rtx srcpos = GEN_INT (exact_log2 (INTVAL (operands[3]))
3401 + INTVAL (operands[2]));
3402 rtx dstpos = GEN_INT (exact_log2 (INTVAL (operands[3])));
3403 operands[2] = srcpos;
3404 operands[3] = dstpos;
3405 return \"bld\\t%Z2,%Y1\;bor\\t%Z3,%Y0\;bst\\t%Z3,%Y0\";
3407 [(set_attr "length" "6")
3408 (set_attr "cc" "clobber")])
3410 (define_insn "*iorsi3_zero_extract"
3411 [(set (match_operand:SI 0 "register_operand" "=r")
3412 (ior:SI (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
3414 (match_operand:SI 2 "const_int_operand" "n"))
3415 (match_operand:SI 3 "register_operand" "0")))]
3416 "(TARGET_H8300H || TARGET_H8300S)
3417 && INTVAL (operands[2]) < 16"
3418 "bld\\t%Z2,%Y1\;bor\\t#0,%w0\;bst\\t#0,%w0"
3419 [(set_attr "length" "6")
3420 (set_attr "cc" "clobber")])
3422 (define_insn "*iorsi3_and_lshiftrt_n_sb"
3423 [(set (match_operand:SI 0 "register_operand" "=r")
3424 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3427 (match_operand:SI 2 "register_operand" "0")))]
3428 "(TARGET_H8300H || TARGET_H8300S)"
3429 "rotl.l\\t%S1\;rotr.l\\t%S1\;bor\\t#1,%w0\;bst\\t#1,%w0"
3430 [(set_attr "length" "8")
3431 (set_attr "cc" "clobber")])
3433 (define_insn "*iorsi3_and_lshiftrt_9_sb"
3434 [(set (match_operand:SI 0 "register_operand" "=r")
3435 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3437 (const_int 4194304))
3438 (match_operand:SI 2 "register_operand" "0")))
3439 (clobber (match_scratch:HI 3 "=&r"))]
3440 "(TARGET_H8300H || TARGET_H8300S)"
3443 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3444 return \"shll.l\\t%S1\;xor.w\\t%T3,%T3\;bst\\t#6,%s3\;or.w\\t%T3,%e0\";
3446 return \"rotl.l\\t%S1\;rotr.l\\t%S1\;xor.w\\t%T3,%T3\;bst\\t#6,%s3\;or.w\\t%T3,%e0\";
3448 [(set_attr "length" "10")
3449 (set_attr "cc" "clobber")])
3451 ;; Used to OR the exponent of a float.
3453 (define_insn "*iorsi3_shift"
3454 [(set (match_operand:SI 0 "register_operand" "=r")
3455 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
3457 (match_operand:SI 2 "register_operand" "0")))
3458 (clobber (match_scratch:SI 3 "=&r"))]
3459 "TARGET_H8300H || TARGET_H8300S"
3464 [(set (match_operand:SI 0 "register_operand" "")
3465 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
3468 (clobber (match_operand:SI 2 "register_operand" ""))])]
3469 "(TARGET_H8300H || TARGET_H8300S)
3471 && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
3472 && REGNO (operands[0]) != REGNO (operands[1])"
3473 [(parallel [(set (match_dup 3)
3474 (ashift:HI (match_dup 3)
3476 (clobber (scratch:QI))])
3478 (ior:SI (ashift:SI (match_dup 1)
3481 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[1]));")
3485 [(set (match_operand:SI 0 "register_operand" "")
3486 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
3489 (clobber (match_operand:SI 2 "register_operand" ""))])]
3490 "(TARGET_H8300H || TARGET_H8300S)
3492 && !(find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
3493 && REGNO (operands[0]) != REGNO (operands[1]))"
3496 (parallel [(set (match_dup 3)
3497 (ashift:HI (match_dup 3)
3499 (clobber (scratch:QI))])
3501 (ior:SI (ashift:SI (match_dup 2)
3504 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[2]));")
3506 (define_insn "*iorsi2_and_1_lshiftrt_1"
3507 [(set (match_operand:SI 0 "register_operand" "=r")
3508 (ior:SI (and:SI (match_operand:SI 1 "register_operand" "0")
3510 (lshiftrt:SI (match_dup 1)
3512 "TARGET_H8300H || TARGET_H8300S"
3513 "shlr.l\\t%S0\;bor\\t#0,%w0\;bst\\t#0,%w0"
3514 [(set_attr "length" "6")
3515 (set_attr "cc" "clobber")])
3517 (define_insn_and_split "*iorsi3_ashift_16_ashift_24"
3518 [(set (match_operand:SI 0 "register_operand" "=r")
3519 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
3521 (ashift:SI (match_operand:SI 2 "register_operand" "r")
3523 "(TARGET_H8300H || TARGET_H8300S)"
3525 "&& reload_completed"
3527 (ior:HI (ashift:HI (match_dup 4)
3530 (parallel [(set (match_dup 0)
3531 (ashift:SI (match_dup 0)
3533 (clobber (scratch:QI))])]
3534 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));
3535 operands[4] = gen_rtx_REG (HImode, REGNO (operands[2]));")
3537 (define_insn_and_split "*iorsi3_ashift_16_ashift_24_mem"
3538 [(set (match_operand:SI 0 "register_operand" "=&r")
3539 (ior:SI (and:SI (ashift:SI (subreg:SI (match_operand:QI 1 "memory_operand" "m") 0)
3541 (const_int 16711680))
3542 (ashift:SI (subreg:SI (match_operand:QI 2 "memory_operand" "m") 0)
3544 "(TARGET_H8300H || TARGET_H8300S)"
3546 "&& reload_completed"
3548 (ior:HI (zero_extend:HI (match_dup 1))
3549 (ashift:HI (subreg:HI (match_dup 2) 0)
3551 (parallel [(set (match_dup 0)
3552 (ashift:SI (match_dup 0)
3554 (clobber (scratch:QI))])]
3555 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));")
3557 ;; Used to add the exponent of a float.
3559 (define_insn "*addsi3_shift"
3560 [(set (match_operand:SI 0 "register_operand" "=r")
3561 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
3562 (const_int 8388608))
3563 (match_operand:SI 2 "register_operand" "0")))
3564 (clobber (match_scratch:SI 3 "=&r"))]
3565 "TARGET_H8300H || TARGET_H8300S"
3570 [(set (match_operand:SI 0 "register_operand" "")
3571 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
3572 (const_int 8388608))
3574 (clobber (match_operand:SI 2 "register_operand" ""))])]
3575 "(TARGET_H8300H || TARGET_H8300S)
3577 && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
3578 && REGNO (operands[0]) != REGNO (operands[1])"
3579 [(parallel [(set (match_dup 3)
3580 (ashift:HI (match_dup 3)
3582 (clobber (scratch:QI))])
3584 (plus:SI (mult:SI (match_dup 1)
3587 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[1]));")
3591 [(set (match_operand:SI 0 "register_operand" "")
3592 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
3593 (const_int 8388608))
3595 (clobber (match_operand:SI 2 "register_operand" ""))])]
3596 "(TARGET_H8300H || TARGET_H8300S)
3598 && !(find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
3599 && REGNO (operands[0]) != REGNO (operands[1]))"
3602 (parallel [(set (match_dup 3)
3603 (ashift:HI (match_dup 3)
3605 (clobber (scratch:QI))])
3607 (plus:SI (mult:SI (match_dup 2)
3610 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[2]));")
3614 (define_insn_and_split "*ashiftsi_sextqi_7"
3615 [(set (match_operand:SI 0 "register_operand" "=r")
3616 (ashift:SI (sign_extend:SI (match_operand:QI 1 "register_operand" "0"))
3618 "(TARGET_H8300H || TARGET_H8300S)"
3620 "&& reload_completed"
3621 [(parallel [(set (match_dup 2)
3622 (ashift:HI (match_dup 2)
3624 (clobber (scratch:QI))])
3626 (sign_extend:SI (match_dup 2)))
3627 (parallel [(set (match_dup 0)
3628 (ashiftrt:SI (match_dup 0)
3630 (clobber (scratch:QI))])]
3631 "operands[2] = gen_rtx_REG (HImode, REGNO (operands[0]));")
3633 ;; Storing a part of HImode to QImode.
3636 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
3637 (subreg:QI (lshiftrt:HI (match_operand:HI 1 "register_operand" "r")
3641 [(set_attr "cc" "set_znv")
3642 (set_attr "length" "8")])
3644 ;; Storing a part of SImode to QImode.
3647 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
3648 (subreg:QI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3652 [(set_attr "cc" "set_znv")
3653 (set_attr "length" "8")])
3656 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
3657 (subreg:QI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3659 (clobber (match_scratch:SI 2 "=&r"))]
3660 "TARGET_H8300H || TARGET_H8300S"
3661 "mov.w\\t%e1,%f2\;mov.b\\t%w2,%R0"
3662 [(set_attr "cc" "set_znv")
3663 (set_attr "length" "10")])
3666 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
3667 (subreg:QI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3669 (clobber (match_scratch:SI 2 "=&r"))]
3670 "TARGET_H8300H || TARGET_H8300S"
3671 "mov.w\\t%e1,%f2\;mov.b\\t%x2,%R0"
3672 [(set_attr "cc" "set_znv")
3673 (set_attr "length" "10")])
3675 (define_insn_and_split ""
3677 (if_then_else (eq (zero_extract:SI (subreg:SI (match_operand:QI 0 "register_operand" "") 0)
3681 (label_ref (match_operand 1 "" ""))
3689 (if_then_else (ge (cc0)
3691 (label_ref (match_dup 1))
3695 (define_insn_and_split ""
3697 (if_then_else (ne (zero_extract:SI (subreg:SI (match_operand:QI 0 "register_operand" "") 0)
3701 (label_ref (match_operand 1 "" ""))
3709 (if_then_else (lt (cc0)
3711 (label_ref (match_dup 1))
3715 ;; -----------------------------------------------------------------
3716 ;; PEEPHOLE PATTERNS
3717 ;; -----------------------------------------------------------------
3719 ;; Convert (A >> B) & C to (A & 255) >> B if C == 255 >> B.
3723 [(set (match_operand:HI 0 "register_operand" "")
3724 (lshiftrt:HI (match_dup 0)
3725 (match_operand:HI 1 "const_int_operand" "")))
3726 (clobber (match_operand:HI 2 "" ""))])
3728 (and:HI (match_dup 0)
3729 (match_operand:HI 3 "const_int_operand" "")))]
3730 "INTVAL (operands[3]) == (255 >> INTVAL (operands[1]))"
3732 (and:HI (match_dup 0)
3736 (lshiftrt:HI (match_dup 0)
3738 (clobber (match_dup 2))])]
3741 ;; Convert (A << B) & C to (A & 255) << B if C == 255 << B.
3745 [(set (match_operand:HI 0 "register_operand" "")
3746 (ashift:HI (match_dup 0)
3747 (match_operand:HI 1 "const_int_operand" "")))
3748 (clobber (match_operand:HI 2 "" ""))])
3750 (and:HI (match_dup 0)
3751 (match_operand:HI 3 "const_int_operand" "")))]
3752 "INTVAL (operands[3]) == (255 << INTVAL (operands[1]))"
3754 (and:HI (match_dup 0)
3758 (ashift:HI (match_dup 0)
3760 (clobber (match_dup 2))])]
3763 ;; Convert (A >> B) & C to (A & 255) >> B if C == 255 >> B.
3767 [(set (match_operand:SI 0 "register_operand" "")
3768 (lshiftrt:SI (match_dup 0)
3769 (match_operand:SI 1 "const_int_operand" "")))
3770 (clobber (match_operand:SI 2 "" ""))])
3772 (and:SI (match_dup 0)
3773 (match_operand:SI 3 "const_int_operand" "")))]
3774 "INTVAL (operands[3]) == (255 >> INTVAL (operands[1]))"
3776 (and:SI (match_dup 0)
3780 (lshiftrt:SI (match_dup 0)
3782 (clobber (match_dup 2))])]
3785 ;; Convert (A << B) & C to (A & 255) << B if C == 255 << B.
3789 [(set (match_operand:SI 0 "register_operand" "")
3790 (ashift:SI (match_dup 0)
3791 (match_operand:SI 1 "const_int_operand" "")))
3792 (clobber (match_operand:SI 2 "" ""))])
3794 (and:SI (match_dup 0)
3795 (match_operand:SI 3 "const_int_operand" "")))]
3796 "INTVAL (operands[3]) == (255 << INTVAL (operands[1]))"
3798 (and:SI (match_dup 0)
3802 (ashift:SI (match_dup 0)
3804 (clobber (match_dup 2))])]
3807 ;; Convert (A >> B) & C to (A & 65535) >> B if C == 65535 >> B.
3811 [(set (match_operand:SI 0 "register_operand" "")
3812 (lshiftrt:SI (match_dup 0)
3813 (match_operand:SI 1 "const_int_operand" "")))
3814 (clobber (match_operand:SI 2 "" ""))])
3816 (and:SI (match_dup 0)
3817 (match_operand:SI 3 "const_int_operand" "")))]
3818 "INTVAL (operands[3]) == (65535 >> INTVAL (operands[1]))"
3820 (and:SI (match_dup 0)
3824 (lshiftrt:SI (match_dup 0)
3826 (clobber (match_dup 2))])]
3829 ;; Convert (A << B) & C to (A & 65535) << B if C == 65535 << B.
3833 [(set (match_operand:SI 0 "register_operand" "")
3834 (ashift:SI (match_dup 0)
3835 (match_operand:SI 1 "const_int_operand" "")))
3836 (clobber (match_operand:SI 2 "" ""))])
3838 (and:SI (match_dup 0)
3839 (match_operand:SI 3 "const_int_operand" "")))]
3840 "INTVAL (operands[3]) == (65535 << INTVAL (operands[1]))"
3842 (and:SI (match_dup 0)
3846 (ashift:SI (match_dup 0)
3848 (clobber (match_dup 2))])]
3851 ;; Convert a QImode push into an SImode push so that the
3852 ;; define_peephole2 below can cram multiple pushes into one stm.l.
3855 [(parallel [(set (reg:SI SP_REG)
3856 (plus:SI (reg:SI SP_REG) (const_int -4)))
3857 (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int -3)))
3858 (match_operand:QI 0 "register_operand" ""))])]
3859 "TARGET_H8300S && !TARGET_NORMAL_MODE"
3860 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
3862 "operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
3865 [(parallel [(set (reg:HI SP_REG)
3866 (plus:HI (reg:HI SP_REG) (const_int -4)))
3867 (set (mem:QI (plus:HI (reg:HI SP_REG) (const_int -3)))
3868 (match_operand:QI 0 "register_operand" ""))])]
3869 "TARGET_H8300S && TARGET_NORMAL_MODE"
3870 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
3872 "operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
3874 ;; Convert a HImode push into an SImode push so that the
3875 ;; define_peephole2 below can cram multiple pushes into one stm.l.
3878 [(parallel [(set (reg:SI SP_REG)
3879 (plus:SI (reg:SI SP_REG) (const_int -4)))
3880 (set (mem:HI (plus:SI (reg:SI SP_REG) (const_int -2)))
3881 (match_operand:HI 0 "register_operand" ""))])]
3882 "TARGET_H8300S && !TARGET_NORMAL_MODE"
3883 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
3885 "operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
3888 [(parallel [(set (reg:HI SP_REG)
3889 (plus:HI (reg:HI SP_REG) (const_int -4)))
3890 (set (mem:HI (plus:HI (reg:HI SP_REG) (const_int -2)))
3891 (match_operand:HI 0 "register_operand" ""))])]
3892 "TARGET_H8300S && TARGET_NORMAL_MODE"
3893 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
3895 "operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
3897 ;; Cram four pushes into stm.l.
3900 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
3901 (match_operand:SI 0 "register_operand" ""))
3902 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
3903 (match_operand:SI 1 "register_operand" ""))
3904 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
3905 (match_operand:SI 2 "register_operand" ""))
3906 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
3907 (match_operand:SI 3 "register_operand" ""))]
3908 "TARGET_H8300S && !TARGET_NORMAL_MODE
3909 && REGNO (operands[0]) == 0
3910 && REGNO (operands[1]) == 1
3911 && REGNO (operands[2]) == 2
3912 && REGNO (operands[3]) == 3"
3913 [(parallel [(set (reg:SI SP_REG)
3914 (plus:SI (reg:SI SP_REG)
3916 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
3918 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
3920 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -12)))
3922 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -16)))
3927 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
3928 (match_operand:SI 0 "register_operand" ""))
3929 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
3930 (match_operand:SI 1 "register_operand" ""))
3931 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
3932 (match_operand:SI 2 "register_operand" ""))
3933 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
3934 (match_operand:SI 3 "register_operand" ""))]
3935 "TARGET_H8300S && TARGET_NORMAL_MODE
3936 && REGNO (operands[0]) == 0
3937 && REGNO (operands[1]) == 1
3938 && REGNO (operands[2]) == 2
3939 && REGNO (operands[3]) == 3"
3940 [(parallel [(set (reg:HI SP_REG)
3941 (plus:HI (reg:HI SP_REG)
3943 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
3945 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
3947 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
3949 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -16)))
3953 ;; Cram three pushes into stm.l.
3956 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
3957 (match_operand:SI 0 "register_operand" ""))
3958 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
3959 (match_operand:SI 1 "register_operand" ""))
3960 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
3961 (match_operand:SI 2 "register_operand" ""))]
3962 "TARGET_H8300S && !TARGET_NORMAL_MODE
3963 && ((REGNO (operands[0]) == 0
3964 && REGNO (operands[1]) == 1
3965 && REGNO (operands[2]) == 2)
3966 || (REGNO (operands[0]) == 4
3967 && REGNO (operands[1]) == 5
3968 && REGNO (operands[2]) == 6))"
3969 [(parallel [(set (reg:SI SP_REG)
3970 (plus:SI (reg:SI SP_REG)
3972 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
3974 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
3976 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -12)))
3981 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
3982 (match_operand:SI 0 "register_operand" ""))
3983 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
3984 (match_operand:SI 1 "register_operand" ""))
3985 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
3986 (match_operand:SI 2 "register_operand" ""))]
3987 "TARGET_H8300S && TARGET_NORMAL_MODE
3988 && ((REGNO (operands[0]) == 0
3989 && REGNO (operands[1]) == 1
3990 && REGNO (operands[2]) == 2)
3991 || (REGNO (operands[0]) == 4
3992 && REGNO (operands[1]) == 5
3993 && REGNO (operands[2]) == 6))"
3994 [(parallel [(set (reg:HI SP_REG)
3995 (plus:HI (reg:HI SP_REG)
3997 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
3999 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
4001 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
4005 ;; Cram two pushes into stm.l.
4008 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4009 (match_operand:SI 0 "register_operand" ""))
4010 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4011 (match_operand:SI 1 "register_operand" ""))]
4012 "TARGET_H8300S && !TARGET_NORMAL_MODE
4013 && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
4014 || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
4015 || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
4016 [(parallel [(set (reg:SI SP_REG)
4017 (plus:SI (reg:SI SP_REG)
4019 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
4021 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
4026 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4027 (match_operand:SI 0 "register_operand" ""))
4028 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4029 (match_operand:SI 1 "register_operand" ""))]
4030 "TARGET_H8300S && TARGET_NORMAL_MODE
4031 && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
4032 || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
4033 || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
4034 [(parallel [(set (reg:HI SP_REG)
4035 (plus:HI (reg:HI SP_REG)
4037 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
4039 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
4046 ;; add.w r7,r0 (6 bytes)
4051 ;; adds #2,r0 (4 bytes)
4054 [(set (match_operand:HI 0 "register_operand" "")
4055 (match_operand:HI 1 "const_int_operand" ""))
4057 (plus:HI (match_dup 0)
4058 (match_operand:HI 2 "register_operand" "")))]
4059 "REG_P (operands[0]) && REG_P (operands[2])
4060 && REGNO (operands[0]) != REGNO (operands[2])
4061 && (CONST_OK_FOR_J (INTVAL (operands[1]))
4062 || CONST_OK_FOR_L (INTVAL (operands[1]))
4063 || CONST_OK_FOR_N (INTVAL (operands[1])))"
4067 (plus:HI (match_dup 0)
4075 ;; add.l er7,er0 (6 bytes)
4080 ;; adds #4,er0 (4 bytes)
4083 [(set (match_operand:SI 0 "register_operand" "")
4084 (match_operand:SI 1 "const_int_operand" ""))
4086 (plus:SI (match_dup 0)
4087 (match_operand:SI 2 "register_operand" "")))]
4088 "(TARGET_H8300H || TARGET_H8300S)
4089 && REG_P (operands[0]) && REG_P (operands[2])
4090 && REGNO (operands[0]) != REGNO (operands[2])
4091 && (CONST_OK_FOR_L (INTVAL (operands[1]))
4092 || CONST_OK_FOR_N (INTVAL (operands[1])))"
4096 (plus:SI (match_dup 0)
4103 ;; add.l #10,er0 (takes 8 bytes)
4109 ;; add.l er7,er0 (takes 6 bytes)
4112 [(set (match_operand:SI 0 "register_operand" "")
4113 (match_operand:SI 1 "register_operand" ""))
4115 (plus:SI (match_dup 0)
4116 (match_operand:SI 2 "const_int_operand" "")))]
4117 "(TARGET_H8300H || TARGET_H8300S)
4118 && REG_P (operands[0]) && REG_P (operands[1])
4119 && REGNO (operands[0]) != REGNO (operands[1])
4120 && !CONST_OK_FOR_L (INTVAL (operands[2]))
4121 && !CONST_OK_FOR_N (INTVAL (operands[2]))
4122 && ((INTVAL (operands[2]) & 0xff) == INTVAL (operands[2])
4123 || (INTVAL (operands[2]) & 0xff00) == INTVAL (operands[2])
4124 || INTVAL (operands[2]) == 0xffff
4125 || INTVAL (operands[2]) == 0xfffe)"
4129 (plus:SI (match_dup 0)
4145 [(set (match_operand:HI 0 "register_operand" "")
4146 (plus:HI (match_dup 0)
4147 (match_operand 1 "incdec_operand" "")))
4151 (if_then_else (match_operator 3 "eqne_operator"
4152 [(cc0) (const_int 0)])
4153 (label_ref (match_operand 2 "" ""))
4155 "TARGET_H8300H || TARGET_H8300S"
4156 [(set (match_operand:HI 0 "register_operand" "")
4157 (unspec:HI [(match_dup 0)
4163 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4164 (label_ref (match_dup 2))
4168 ;; The SImode version of the previous pattern.
4171 [(set (match_operand:SI 0 "register_operand" "")
4172 (plus:SI (match_dup 0)
4173 (match_operand 1 "incdec_operand" "")))
4177 (if_then_else (match_operator 3 "eqne_operator"
4178 [(cc0) (const_int 0)])
4179 (label_ref (match_operand 2 "" ""))
4181 "TARGET_H8300H || TARGET_H8300S"
4182 [(set (match_operand:SI 0 "register_operand" "")
4183 (unspec:SI [(match_dup 0)
4189 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4190 (label_ref (match_dup 2))
4195 [(parallel [(set (cc0)
4196 (zero_extract:SI (match_operand:QI 0 "register_operand" "")
4199 (clobber (scratch:QI))])
4201 (if_then_else (match_operator 1 "eqne_operator"
4202 [(cc0) (const_int 0)])
4203 (label_ref (match_operand 2 "" ""))
4205 "(TARGET_H8300H || TARGET_H8300S)"
4209 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4210 (label_ref (match_dup 2))
4212 "operands[3] = ((GET_CODE (operands[1]) == EQ)
4213 ? gen_rtx_GE (VOIDmode, cc0_rtx, const0_rtx)
4214 : gen_rtx_LT (VOIDmode, cc0_rtx, const0_rtx));")
4216 ;; The next three peephole2's will try to transform
4218 ;; mov.b A,r0l (or mov.l A,er0)
4225 ;; and.b #CST,r0l (if CST is not 255)
4228 [(set (match_operand:QI 0 "register_operand" "")
4229 (match_operand:QI 1 "general_operand" ""))
4230 (set (match_operand:SI 2 "register_operand" "")
4231 (and:SI (match_dup 2)
4233 "(TARGET_H8300H || TARGET_H8300S)
4234 && !reg_overlap_mentioned_p (operands[2], operands[1])
4235 && REGNO (operands[0]) == REGNO (operands[2])"
4238 (set (strict_low_part (match_dup 0))
4243 [(set (match_operand:SI 0 "register_operand" "")
4244 (match_operand:SI 1 "general_operand" ""))
4246 (and:SI (match_dup 0)
4248 "(TARGET_H8300H || TARGET_H8300S)
4249 && !reg_overlap_mentioned_p (operands[0], operands[1])
4250 && !(GET_CODE (operands[1]) == MEM && MEM_VOLATILE_P (operands[1]))"
4253 (set (strict_low_part (match_dup 2))
4255 "operands[2] = gen_lowpart (QImode, operands[0]);
4256 operands[3] = gen_lowpart (QImode, operands[1]);")
4259 [(set (match_operand 0 "register_operand" "")
4260 (match_operand 1 "general_operand" ""))
4261 (set (match_operand:SI 2 "register_operand" "")
4262 (and:SI (match_dup 2)
4263 (match_operand:SI 3 "const_int_qi_operand" "")))]
4264 "(TARGET_H8300H || TARGET_H8300S)
4265 && (GET_MODE (operands[0]) == QImode
4266 || GET_MODE (operands[0]) == HImode
4267 || GET_MODE (operands[0]) == SImode)
4268 && GET_MODE (operands[0]) == GET_MODE (operands[1])
4269 && REGNO (operands[0]) == REGNO (operands[2])
4270 && !reg_overlap_mentioned_p (operands[2], operands[1])
4271 && !(GET_MODE (operands[1]) != QImode
4272 && GET_CODE (operands[1]) == MEM
4273 && MEM_VOLATILE_P (operands[1]))"
4276 (set (strict_low_part (match_dup 4))
4279 (and:SI (match_dup 2)
4281 "operands[4] = gen_lowpart (QImode, operands[0]);
4282 operands[5] = gen_lowpart (QImode, operands[1]);
4283 operands[6] = GEN_INT (~0xff | INTVAL (operands[3]));")
4286 [(set (match_operand:SI 0 "register_operand" "")
4287 (match_operand:SI 1 "register_operand" ""))
4289 (and:SI (match_dup 0)
4290 (const_int 65280)))]
4291 "(TARGET_H8300H || TARGET_H8300S)
4292 && !reg_overlap_mentioned_p (operands[0], operands[1])"
4295 (set (zero_extract:SI (match_dup 0)
4298 (lshiftrt:SI (match_dup 1)
4302 ;; If a load of mem:SI is followed by an AND that turns off the upper
4303 ;; half, then we can load mem:HI instead.
4306 [(set (match_operand:SI 0 "register_operand" "")
4307 (match_operand:SI 1 "memory_operand" ""))
4309 (and:SI (match_dup 0)
4310 (match_operand:SI 2 "const_int_operand" "")))]
4311 "(TARGET_H8300H || TARGET_H8300S)
4312 && !MEM_VOLATILE_P (operands[1])
4313 && (INTVAL (operands[2]) & ~0xffff) == 0
4314 && INTVAL (operands[2]) != 255"
4318 (and:SI (match_dup 0)
4320 "operands[3] = gen_lowpart (HImode, operands[0]);
4321 operands[4] = gen_lowpart (HImode, operands[1]);")
4323 ;; (compare (reg:HI) (const_int)) takes 4 bytes, so we try to achieve
4324 ;; the equivalent with shorter sequences. Here is the summary. Cases
4325 ;; are grouped for each define_peephole2.
4327 ;; reg const_int use insn
4328 ;; --------------------------------------------------------
4329 ;; dead -2 eq/ne inc.l
4330 ;; dead -1 eq/ne inc.l
4331 ;; dead 1 eq/ne dec.l
4332 ;; dead 2 eq/ne dec.l
4334 ;; dead 1 geu/ltu shar.l
4335 ;; dead 3 (H8S) geu/ltu shar.l
4337 ;; ---- 255 geu/ltu mov.b
4351 (compare (match_operand:HI 0 "register_operand" "")
4352 (match_operand:HI 1 "incdec_operand" "")))
4354 (if_then_else (match_operator 3 "eqne_operator"
4355 [(cc0) (const_int 0)])
4356 (label_ref (match_operand 2 "" ""))
4358 "(TARGET_H8300H || TARGET_H8300S)
4359 && peep2_reg_dead_p (1, operands[0])"
4361 (unspec:HI [(match_dup 0)
4367 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4368 (label_ref (match_dup 2))
4370 "operands[4] = GEN_INT (- INTVAL (operands[1]));")
4384 (compare (match_operand:HI 0 "register_operand" "")
4385 (match_operand:HI 1 "const_int_operand" "")))
4387 (if_then_else (match_operator 2 "gtle_operator"
4388 [(cc0) (const_int 0)])
4389 (label_ref (match_operand 3 "" ""))
4391 "(TARGET_H8300H || TARGET_H8300S)
4392 && peep2_reg_dead_p (1, operands[0])
4393 && (INTVAL (operands[1]) == 1
4394 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
4395 [(parallel [(set (match_dup 0)
4396 (ashiftrt:HI (match_dup 0)
4398 (clobber (scratch:QI))])
4402 (if_then_else (match_dup 4)
4403 (label_ref (match_dup 3))
4405 "switch (GET_CODE (operands[2]))
4408 operands[4] = gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx);
4411 operands[4] = gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx);
4414 operands[4] = operands[2];
4417 operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
4431 (compare (match_operand:HI 0 "register_operand" "")
4434 (if_then_else (match_operator 1 "gtle_operator"
4435 [(cc0) (const_int 0)])
4436 (label_ref (match_operand 2 "" ""))
4438 "TARGET_H8300H || TARGET_H8300S"
4440 (and:HI (match_dup 0)
4443 (if_then_else (match_dup 3)
4444 (label_ref (match_dup 2))
4446 "switch (GET_CODE (operands[1]))
4449 operands[3] = gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx);
4452 operands[3] = gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx);
4455 operands[3] = operands[1];
4459 ;; (compare (reg:SI) (const_int)) takes 6 bytes, so we try to achieve
4460 ;; the equivalent with shorter sequences. Here is the summary. Cases
4461 ;; are grouped for each define_peephole2.
4463 ;; reg const_int use insn
4464 ;; --------------------------------------------------------
4465 ;; live -2 eq/ne copy and inc.l
4466 ;; live -1 eq/ne copy and inc.l
4467 ;; live 1 eq/ne copy and dec.l
4468 ;; live 2 eq/ne copy and dec.l
4470 ;; dead -2 eq/ne inc.l
4471 ;; dead -1 eq/ne inc.l
4472 ;; dead 1 eq/ne dec.l
4473 ;; dead 2 eq/ne dec.l
4475 ;; dead -131072 eq/ne inc.w and test
4476 ;; dead -65536 eq/ne inc.w and test
4477 ;; dead 65536 eq/ne dec.w and test
4478 ;; dead 131072 eq/ne dec.w and test
4480 ;; dead 0x000000?? except 1 and 2 eq/ne xor.b and test
4481 ;; dead 0x0000??00 eq/ne xor.b and test
4482 ;; dead 0x0000ffff eq/ne not.w and test
4484 ;; dead 0xffffff?? except -1 and -2 eq/ne xor.b and not.l
4485 ;; dead 0xffff??ff eq/ne xor.b and not.l
4486 ;; dead 0x40000000 (H8S) eq/ne rotl.l and dec.l
4487 ;; dead 0x80000000 eq/ne rotl.l and dec.l
4489 ;; live 1 geu/ltu copy and shar.l
4490 ;; live 3 (H8S) geu/ltu copy and shar.l
4492 ;; dead 1 geu/ltu shar.l
4493 ;; dead 3 (H8S) geu/ltu shar.l
4495 ;; dead 3 (H8/300H) geu/ltu and.b and test
4496 ;; dead 7 geu/ltu and.b and test
4497 ;; dead 15 geu/ltu and.b and test
4498 ;; dead 31 geu/ltu and.b and test
4499 ;; dead 63 geu/ltu and.b and test
4500 ;; dead 127 geu/ltu and.b and test
4501 ;; dead 255 geu/ltu and.b and test
4503 ;; dead 65535 geu/ltu mov.w
4505 ;; For a small constant, it is cheaper to actually do the subtraction
4506 ;; and then test the register.
4510 (compare (match_operand:SI 0 "register_operand" "")
4511 (match_operand:SI 1 "incdec_operand" "")))
4513 (if_then_else (match_operator 3 "eqne_operator"
4514 [(cc0) (const_int 0)])
4515 (label_ref (match_operand 2 "" ""))
4517 "(TARGET_H8300H || TARGET_H8300S)
4518 && peep2_reg_dead_p (1, operands[0])"
4520 (unspec:SI [(match_dup 0)
4526 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4527 (label_ref (match_dup 2))
4529 "operands[4] = GEN_INT (- INTVAL (operands[1]));")
4533 (compare (match_operand:SI 0 "register_operand" "")
4534 (match_operand:SI 1 "const_int_operand" "")))
4536 (if_then_else (match_operator 3 "eqne_operator"
4537 [(cc0) (const_int 0)])
4538 (label_ref (match_operand 2 "" ""))
4540 "(TARGET_H8300H || TARGET_H8300S)
4541 && peep2_reg_dead_p (1, operands[0])
4542 && (INTVAL (operands[1]) == -131072
4543 || INTVAL (operands[1]) == -65536
4544 || INTVAL (operands[1]) == 65536
4545 || INTVAL (operands[1]) == 131072)"
4547 (plus:SI (match_dup 0)
4552 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4553 (label_ref (match_dup 2))
4555 "operands[4] = GEN_INT (- INTVAL (operands[1]));")
4557 ;; For certain (in)equality comparisons against a constant, we can
4558 ;; XOR the register with the constant, and test the register against
4563 (compare (match_operand:SI 0 "register_operand" "")
4564 (match_operand:SI 1 "const_int_operand" "")))
4566 (if_then_else (match_operator 3 "eqne_operator"
4567 [(cc0) (const_int 0)])
4568 (label_ref (match_operand 2 "" ""))
4570 "(TARGET_H8300H || TARGET_H8300S)
4571 && peep2_reg_dead_p (1, operands[0])
4572 && ((INTVAL (operands[1]) & 0x00ff) == INTVAL (operands[1])
4573 || (INTVAL (operands[1]) & 0xff00) == INTVAL (operands[1])
4574 || INTVAL (operands[1]) == 0x0000ffff)
4575 && INTVAL (operands[1]) != 1
4576 && INTVAL (operands[1]) != 2"
4578 (xor:SI (match_dup 0)
4583 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4584 (label_ref (match_dup 2))
4590 (compare (match_operand:SI 0 "register_operand" "")
4591 (match_operand:SI 1 "const_int_operand" "")))
4593 (if_then_else (match_operator 3 "eqne_operator"
4594 [(cc0) (const_int 0)])
4595 (label_ref (match_operand 2 "" ""))
4597 "(TARGET_H8300H || TARGET_H8300S)
4598 && peep2_reg_dead_p (1, operands[0])
4599 && ((INTVAL (operands[1]) | 0x00ff) == -1
4600 || (INTVAL (operands[1]) | 0xff00) == -1)
4601 && INTVAL (operands[1]) != -1
4602 && INTVAL (operands[1]) != -2"
4604 (xor:SI (match_dup 0)
4607 (not:SI (match_dup 0)))
4611 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4612 (label_ref (match_dup 2))
4614 "operands[4] = GEN_INT (INTVAL (operands[1]) ^ -1);")
4618 (compare (match_operand:SI 0 "register_operand" "")
4619 (match_operand:SI 1 "const_int_operand" "")))
4621 (if_then_else (match_operator 3 "eqne_operator"
4622 [(cc0) (const_int 0)])
4623 (label_ref (match_operand 2 "" ""))
4625 "(TARGET_H8300H || TARGET_H8300S)
4626 && peep2_reg_dead_p (1, operands[0])
4627 && (INTVAL (operands[1]) == -2147483647 - 1
4628 || (TARGET_H8300S && INTVAL (operands[1]) == 1073741824))"
4630 (rotate:SI (match_dup 0)
4633 (unspec:SI [(match_dup 0)
4639 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4640 (label_ref (match_dup 2))
4642 "operands[4] = GEN_INT (INTVAL (operands[1]) == -2147483647 - 1 ? 1 : 2);")
4655 ;; We avoid this transformation if we see more than one copy of the
4656 ;; same compare insn immediately before this one.
4659 [(match_scratch:SI 4 "r")
4661 (compare (match_operand:SI 0 "register_operand" "")
4662 (match_operand:SI 1 "const_int_operand" "")))
4664 (if_then_else (match_operator 2 "gtle_operator"
4665 [(cc0) (const_int 0)])
4666 (label_ref (match_operand 3 "" ""))
4668 "(TARGET_H8300H || TARGET_H8300S)
4669 && !peep2_reg_dead_p (1, operands[0])
4670 && (INTVAL (operands[1]) == 1
4671 || (TARGET_H8300S && INTVAL (operands[1]) == 3))
4672 && !same_cmp_preceding_p (insn)"
4675 (parallel [(set (match_dup 4)
4676 (ashiftrt:SI (match_dup 4)
4678 (clobber (scratch:QI))])
4682 (if_then_else (match_dup 5)
4683 (label_ref (match_dup 3))
4685 "switch (GET_CODE (operands[2]))
4688 operands[5] = gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx);
4691 operands[5] = gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx);
4694 operands[5] = operands[2];
4697 operands[6] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
4711 (compare (match_operand:SI 0 "register_operand" "")
4712 (match_operand:SI 1 "const_int_operand" "")))
4714 (if_then_else (match_operator 2 "gtle_operator"
4715 [(cc0) (const_int 0)])
4716 (label_ref (match_operand 3 "" ""))
4718 "(TARGET_H8300H || TARGET_H8300S)
4719 && peep2_reg_dead_p (1, operands[0])
4720 && (INTVAL (operands[1]) == 1
4721 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
4722 [(parallel [(set (match_dup 0)
4723 (ashiftrt:SI (match_dup 0)
4725 (clobber (scratch:QI))])
4729 (if_then_else (match_dup 4)
4730 (label_ref (match_dup 3))
4732 "switch (GET_CODE (operands[2]))
4735 operands[4] = gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx);
4738 operands[4] = gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx);
4741 operands[4] = operands[2];
4744 operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
4759 (compare (match_operand:SI 0 "register_operand" "")
4760 (match_operand:SI 1 "const_int_operand" "")))
4762 (if_then_else (match_operator 2 "gtle_operator"
4763 [(cc0) (const_int 0)])
4764 (label_ref (match_operand 3 "" ""))
4766 "(TARGET_H8300H || TARGET_H8300S)
4767 && peep2_reg_dead_p (1, operands[0])
4768 && ((TARGET_H8300H && INTVAL (operands[1]) == 3)
4769 || INTVAL (operands[1]) == 7
4770 || INTVAL (operands[1]) == 15
4771 || INTVAL (operands[1]) == 31
4772 || INTVAL (operands[1]) == 63
4773 || INTVAL (operands[1]) == 127
4774 || INTVAL (operands[1]) == 255)"
4776 (and:SI (match_dup 0)
4781 (if_then_else (match_dup 4)
4782 (label_ref (match_dup 3))
4784 "switch (GET_CODE (operands[2]))
4787 operands[4] = gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx);
4790 operands[4] = gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx);
4793 operands[4] = operands[2];
4796 operands[5] = GEN_INT (~INTVAL (operands[1]));")
4798 ;; Transform A <= 65535 to (A & 0xffff0000) == 0.
4802 (compare (match_operand:SI 0 "register_operand" "")
4805 (if_then_else (match_operator 1 "gtle_operator"
4806 [(cc0) (const_int 0)])
4807 (label_ref (match_operand 2 "" ""))
4809 "TARGET_H8300H || TARGET_H8300S"
4811 (and:SI (match_dup 0)
4812 (const_int -65536)))
4814 (if_then_else (match_dup 3)
4815 (label_ref (match_dup 2))
4817 "switch (GET_CODE (operands[1]))
4820 operands[3] = gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx);
4823 operands[3] = gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx);
4826 operands[3] = operands[1];
4830 ;; For constants like -1, -2, 1, 2, it is still cheaper to make a copy
4831 ;; of the register being tested, do the subtraction on the copy, and
4832 ;; then test the copy. We avoid this transformation if we see more
4833 ;; than one copy of the same compare insn.
4836 [(match_scratch:SI 4 "r")
4838 (compare (match_operand:SI 0 "register_operand" "")
4839 (match_operand:SI 1 "incdec_operand" "")))
4841 (if_then_else (match_operator 3 "eqne_operator"
4842 [(cc0) (const_int 0)])
4843 (label_ref (match_operand 2 "" ""))
4845 "(TARGET_H8300H || TARGET_H8300S)
4846 && !peep2_reg_dead_p (1, operands[0])
4847 && !same_cmp_following_p (insn)"
4851 (unspec:SI [(match_dup 4)
4857 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4858 (label_ref (match_dup 2))
4860 "operands[5] = GEN_INT (- INTVAL (operands[1]));")
4862 ;; Narrow the mode of testing if possible.
4865 [(set (match_operand:HI 0 "register_operand" "")
4866 (and:HI (match_dup 0)
4867 (match_operand:HI 1 "const_int_qi_operand" "")))
4871 (if_then_else (match_operator 3 "eqne_operator"
4872 [(cc0) (const_int 0)])
4873 (label_ref (match_operand 2 "" ""))
4875 "peep2_reg_dead_p (2, operands[0])"
4877 (and:QI (match_dup 4)
4882 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4883 (label_ref (match_dup 2))
4885 "operands[4] = gen_rtx_REG (QImode, REGNO (operands[0]));
4886 operands[5] = gen_int_mode (INTVAL (operands[1]), QImode);")
4889 [(set (match_operand:SI 0 "register_operand" "")
4890 (and:SI (match_dup 0)
4891 (match_operand:SI 1 "const_int_qi_operand" "")))
4895 (if_then_else (match_operator 3 "eqne_operator"
4896 [(cc0) (const_int 0)])
4897 (label_ref (match_operand 2 "" ""))
4899 "peep2_reg_dead_p (2, operands[0])"
4901 (and:QI (match_dup 4)
4906 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4907 (label_ref (match_dup 2))
4909 "operands[4] = gen_rtx_REG (QImode, REGNO (operands[0]));
4910 operands[5] = gen_int_mode (INTVAL (operands[1]), QImode);")
4913 [(set (match_operand:SI 0 "register_operand" "")
4914 (and:SI (match_dup 0)
4915 (match_operand:SI 1 "const_int_hi_operand" "")))
4919 (if_then_else (match_operator 3 "eqne_operator"
4920 [(cc0) (const_int 0)])
4921 (label_ref (match_operand 2 "" ""))
4923 "peep2_reg_dead_p (2, operands[0])"
4925 (and:HI (match_dup 4)
4930 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4931 (label_ref (match_dup 2))
4933 "operands[4] = gen_rtx_REG (HImode, REGNO (operands[0]));
4934 operands[5] = gen_int_mode (INTVAL (operands[1]), HImode);")
4937 [(set (match_operand:SI 0 "register_operand" "")
4938 (and:SI (match_dup 0)
4939 (match_operand:SI 1 "const_int_qi_operand" "")))
4941 (xor:SI (match_dup 0)
4942 (match_operand:SI 2 "const_int_qi_operand" "")))
4946 (if_then_else (match_operator 4 "eqne_operator"
4947 [(cc0) (const_int 0)])
4948 (label_ref (match_operand 3 "" ""))
4950 "peep2_reg_dead_p (3, operands[0])
4951 && (~INTVAL (operands[1]) & INTVAL (operands[2])) == 0"
4953 (and:QI (match_dup 5)
4956 (xor:QI (match_dup 5)
4961 (if_then_else (match_op_dup 4 [(cc0) (const_int 0)])
4962 (label_ref (match_dup 3))
4964 "operands[5] = gen_rtx_REG (QImode, REGNO (operands[0]));
4965 operands[6] = gen_int_mode (INTVAL (operands[1]), QImode);
4966 operands[7] = gen_int_mode (INTVAL (operands[2]), QImode);")