1 ;; GCC machine description for Hitachi H8/300
2 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 ;; 2001 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 GNU CC.
10 ;; GNU CC 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 ;; GNU CC 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 GNU CC; 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 ;; The original PO technology requires these to be ordered by speed,
26 ;; so that assigner will pick the fastest.
28 ;; See file "rtl.def" for documentation on define_insn, match_*, et. al.
30 (define_attr "cpu" "h8300,h8300h"
31 (const (symbol_ref "cpu_type")))
33 ;; Many logical operations should have "bit" variants if only one
34 ;; bit is going to be operated on.
36 ;; (and (logical op) (const_int X))
37 ;; If const_int only specifies a few bits (like a single byte in a 4 byte
38 ;; operation, then it's more efficient to only apply the and and logical_op
39 ;; to the bits we care about.
41 ;; Some of the extend instructions accept a general_operand_src, which
42 ;; allows all the normal memory addressing modes. The length computations
43 ;; don't take this into account. The lengths in the MD file should be
44 ;; "worst case" and then be adjusted to their correct values by
45 ;; h8300_adjust_insn_length.
47 ;; On the h8300h, adds/subs operate on the 32bit "er" registers. Right
48 ;; now GCC doesn't expose the "e" half to the compiler, so using add/subs
49 ;; for addhi and subhi is safe.
50 ;; Long term, we want to expose the "e" half to the compiler (gives us
51 ;; 8 more 16bit registers). At that point addhi and subhi can't use adds/subs.
53 ;; There's currently no way to have a insv/extzv expander for the H8/300H
54 ;; because word_mode is different for the H8/300 and H8/300H.
56 ;; Shifts/rotates by small constants should be handled by special
57 ;; patterns so we get the length and cc status correct.
59 ;; Bitfield operations no longer accept memory operands. We need
60 ;; to add variants which operate on memory back to the MD.
62 ;; ??? Implement remaining bit ops available on the h8300
64 (define_attr "type" "branch,arith"
65 (const_string "arith"))
67 ;; The size of instructions in bytes.
69 (define_attr "length" ""
70 (cond [(eq_attr "type" "branch")
71 (if_then_else (and (ge (minus (pc) (match_dup 0))
73 (le (minus (pc) (match_dup 0))
76 (if_then_else (and (eq_attr "cpu" "h8300h")
77 (and (ge (minus (pc) (match_dup 0))
79 (le (minus (pc) (match_dup 0))
85 ;; The necessity of instruction length adjustment.
87 (define_attr "adjust_length" "yes,no"
88 (cond [(eq_attr "type" "branch") (const_string "no")]
89 (const_string "yes")))
91 ;; Condition code settings.
92 ;; none - insn does not affect cc
93 ;; none_0hit - insn does not affect cc but it does modify operand 0
94 ;; This attribute is used to keep track of when operand 0 changes.
95 ;; See the description of NOTICE_UPDATE_CC for more info.
96 ;; set_znv - insn sets z,n,v to usable values (like a tst insn); c is unknown.
97 ;; set_zn - insn sets z,n to usable values; v,c are unknown.
98 ;; compare - compare instruction
99 ;; clobber - value of cc is unknown
100 (define_attr "cc" "none,none_0hit,set_znv,set_zn,compare,clobber"
101 (const_string "clobber"))
103 ;; ----------------------------------------------------------------------
105 ;; ----------------------------------------------------------------------
109 (define_insn "pushqi1_h8300"
110 [(parallel [(set (reg:HI 7)
111 (plus:HI (reg:HI 7) (const_int -2)))
112 (set (mem:QI (plus:HI (reg:HI 7) (const_int -1)))
113 (match_operand:QI 0 "register_operand" "r"))])]
116 [(set_attr "length" "2")
117 (set_attr "cc" "clobber")])
119 (define_insn "pushqi1_h8300hs"
120 [(parallel [(set (reg:SI 7)
121 (plus:SI (reg:SI 7) (const_int -4)))
122 (set (mem:QI (plus:SI (reg:SI 7) (const_int -3)))
123 (match_operand:QI 0 "register_operand" "r"))])]
124 "TARGET_H8300H || TARGET_H8300S"
126 [(set_attr "length" "4")
127 (set_attr "cc" "clobber")])
129 (define_expand "pushqi1"
130 [(use (match_operand:QI 0 "register_operand" "r"))]
135 emit_insn (gen_pushqi1_h8300 (operands[0]));
137 emit_insn (gen_pushqi1_h8300hs (operands[0]));
142 [(set (match_operand:QI 0 "general_operand_dst" "=r,r ,<,r,r,m")
143 (match_operand:QI 1 "general_operand_src" " I,r>,r,n,m,r"))]
145 && (register_operand (operands[0], QImode)
146 || register_operand (operands[1], QImode))"
154 [(set_attr "length" "2,2,2,2,4,4")
155 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
158 [(set (match_operand:QI 0 "general_operand_dst" "=r,r ,<,r,r,m")
159 (match_operand:QI 1 "general_operand_src" " I,r>,r,n,m,r"))]
160 "(TARGET_H8300H || TARGET_H8300S)
161 && (register_operand (operands[0], QImode)
162 || register_operand (operands[1], QImode))"
170 [(set_attr "length" "2,2,2,2,8,8")
171 (set_attr "cc" "set_zn,set_znv,set_znv,clobber,set_znv,set_znv")])
173 (define_expand "movqi"
174 [(set (match_operand:QI 0 "general_operand_dst" "")
175 (match_operand:QI 1 "general_operand_src" ""))]
179 /* One of the ops has to be in a register. */
180 if (!register_operand (operand0, QImode)
181 && !register_operand (operand1, QImode))
183 operands[1] = copy_to_mode_reg (QImode, operand1);
187 (define_insn "movstrictqi"
188 [(set (strict_low_part (match_operand:QI 0 "general_operand_dst" "+r,r,r,r"))
189 (match_operand:QI 1 "general_operand_src" "I,r,n,m"))]
196 [(set_attr_alternative "length"
197 [(const_int 2) (const_int 2) (const_int 2)
198 (if_then_else (eq_attr "cpu" "h8300") (const_int 4) (const_int 8))])
199 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv")])
203 (define_expand "pushhi1_h8300"
204 [(set (mem:QI (pre_dec:HI (reg:HI 7)))
205 (match_operand:QI 0 "register_operand" "r"))]
209 (define_insn "pushhi1_h8300hs"
210 [(parallel [(set (reg:SI 7)
211 (plus:SI (reg:SI 7) (const_int -4)))
212 (set (mem:HI (plus:SI (reg:SI 7) (const_int -2)))
213 (match_operand:HI 0 "register_operand" "r"))])]
214 "TARGET_H8300H || TARGET_H8300S"
216 [(set_attr "length" "4")
217 (set_attr "cc" "clobber")])
219 (define_expand "pushhi1"
220 [(use (match_operand:QI 0 "register_operand" "r"))]
225 emit_insn (gen_pushhi1_h8300 (operands[0]));
227 emit_insn (gen_pushhi1_h8300hs (operands[0]));
232 [(set (match_operand:HI 0 "general_operand_dst" "=r,r,<,r,r,m")
233 (match_operand:HI 1 "general_operand_src" "I,r>,r,i,m,r"))]
235 && (register_operand (operands[0], HImode)
236 || register_operand (operands[1], HImode))
237 && !(GET_CODE (operands[0]) == MEM
238 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
239 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
240 && GET_CODE (operands[1]) == REG
241 && REGNO (XEXP (XEXP (operands[0], 0), 0)) == REGNO (operands[1]))"
249 [(set_attr "length" "2,2,2,4,4,4")
250 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
253 [(set (match_operand:HI 0 "general_operand_dst" "=r,r,<,r,r,m")
254 (match_operand:HI 1 "general_operand_src" "I,r>,r,i,m,r"))]
255 "(TARGET_H8300H || TARGET_H8300S)
256 && (register_operand (operands[0], HImode)
257 || register_operand (operands[1], HImode))"
265 [(set_attr "length" "2,2,2,4,8,8")
266 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
268 (define_expand "movhi"
269 [(set (match_operand:HI 0 "general_operand_dst" "")
270 (match_operand:HI 1 "general_operand_src" ""))]
274 /* One of the ops has to be in a register. */
275 if (!register_operand (operand1, HImode)
276 && !register_operand (operand0, HImode))
278 operands[1] = copy_to_mode_reg (HImode, operand1);
282 (define_insn "movstricthi"
283 [(set (strict_low_part (match_operand:HI 0 "general_operand_dst" "+r,r,r,r"))
284 (match_operand:HI 1 "general_operand_src" "I,r,i,m"))]
291 [(set_attr_alternative "length"
292 [(const_int 2) (const_int 2) (const_int 4)
293 (if_then_else (eq_attr "cpu" "h8300") (const_int 4) (const_int 8))])
294 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv")])
298 (define_expand "movsi"
299 [(set (match_operand:SI 0 "general_operand_dst" "")
300 (match_operand:SI 1 "general_operand_src" ""))]
306 if (do_movsi (operands))
311 /* One of the ops has to be in a register. */
312 if (!register_operand (operand1, SImode)
313 && !register_operand (operand0, SImode))
315 operands[1] = copy_to_mode_reg (SImode, operand1);
320 (define_expand "movsf"
321 [(set (match_operand:SF 0 "general_operand_dst" "")
322 (match_operand:SF 1 "general_operand_src" ""))]
328 if (do_movsi (operands))
333 /* One of the ops has to be in a register. */
334 if (!register_operand (operand1, SFmode)
335 && !register_operand (operand0, SFmode))
337 operands[1] = copy_to_mode_reg (SFmode, operand1);
342 (define_insn "movsi_h8300"
343 [(set (match_operand:SI 0 "general_operand_dst" "=r,r,r,o,<,r")
344 (match_operand:SI 1 "general_operand_src" "I,r,io,r,r,>"))]
346 && (register_operand (operands[0], SImode)
347 || register_operand (operands[1], SImode))"
351 switch (which_alternative)
354 return \"sub.w %e0,%e0\;sub.w %f0,%f0\";
356 if (REGNO (operands[0]) < REGNO (operands[1]))
357 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
359 return \"mov.w %f1,%f0\;mov.w %e1,%e0\";
361 /* Make sure we don't trample the register we index with. */
362 if (GET_CODE (operands[1]) == MEM)
364 rtx inside = XEXP (operands[1], 0);
369 else if (GET_CODE (inside) == PLUS)
371 rtx lhs = XEXP (inside, 0);
372 rtx rhs = XEXP (inside, 1);
373 if (REG_P (lhs)) rn = REGNO (lhs);
374 if (REG_P (rhs)) rn = REGNO (rhs);
377 if (rn == REGNO (operands[0]))
379 /* Move the second word first. */
380 return \"mov.w %f1,%f0\;mov.w %e1,%e0\";
384 /* See if either half is zero. If so, use sub.w to clear
386 if (GET_CODE (operands[1]) == CONST_INT)
388 if ((INTVAL (operands[1]) & 0xffff) == 0)
389 return \"mov.w %e1,%e0\;sub.w %f0,%f0\";
390 if (((INTVAL (operands[1]) >> 16) & 0xffff) == 0)
391 return \"sub.w %e0,%e0\;mov.w %f1,%f0\";
393 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
396 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
398 return \"mov.w %f1,%T0\;mov.w %e1,%T0\";
400 return \"mov.w %T1,%e0\;mov.w %T1,%f0\";
405 [(set_attr "length" "4,4,8,8,4,4")
406 (set_attr "cc" "clobber")])
408 (define_insn "movsf_h8300"
409 [(set (match_operand:SF 0 "general_operand_dst" "=r,r,r,o,<,r")
410 (match_operand:SF 1 "general_operand_src" "I,r,io,r,r,>"))]
412 && (register_operand (operands[0], SFmode)
413 || register_operand (operands[1], SFmode))"
416 /* Copy of the movsi stuff. */
418 switch (which_alternative)
421 return \"sub.w %e0,%e0\;sub.w %f0,%f0\";
423 if (REGNO (operands[0]) < REGNO (operands[1]))
424 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
426 return \"mov.w %f1,%f0\;mov.w %e1,%e0\";
428 /* Make sure we don't trample the register we index with. */
429 if (GET_CODE (operands[1]) == MEM)
431 rtx inside = XEXP (operands[1], 0);
436 else if (GET_CODE (inside) == PLUS)
438 rtx lhs = XEXP (inside, 0);
439 rtx rhs = XEXP (inside, 1);
440 if (REG_P (lhs)) rn = REGNO (lhs);
441 if (REG_P (rhs)) rn = REGNO (rhs);
444 if (rn == REGNO (operands[0]))
445 /* Move the second word first. */
446 return \"mov.w %f1,%f0\;mov.w %e1,%e0\";
448 /* Move the first word first. */
449 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
452 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
454 return \"mov.w %f1,%T0\;mov.w %e1,%T0\";
456 return \"mov.w %T1,%e0\;mov.w %T1,%f0\";
461 [(set_attr "length" "4,4,8,8,4,4")
462 (set_attr "cc" "clobber")])
464 (define_insn "movsi_h8300hs"
465 [(set (match_operand:SI 0 "general_operand_dst" "=r,r,r,r,m,<,r,*a,*a,r")
466 (match_operand:SI 1 "general_operand_src" "I,r,i,m,r,r,>,I,r,*a"))]
467 "(TARGET_H8300S || TARGET_H8300H)
468 && (register_operand (operands[0], SImode)
469 || register_operand (operands[1], SImode))
470 && !(GET_CODE (operands[0]) == MEM
471 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
472 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
473 && GET_CODE (operands[1]) == REG
474 && REGNO (XEXP (XEXP (operands[0], 0), 0)) == REGNO (operands[1]))"
477 switch (which_alternative)
480 return \"sub.l %S0,%S0\";
484 return \"clrmac\;ldmac %1,macl\";
486 return \"stmac macl,%0\";
488 if (GET_CODE (operands[1]) == CONST_INT)
490 int val = INTVAL (operands[1]);
492 /* Look for constants which can be made by adding an 8-bit
493 number to zero in one of the two low bytes. */
494 if (val == (val & 0xff))
496 operands[1] = GEN_INT ((char) val & 0xff);
497 return \"sub.l\\t%S0,%S0\;add.b\\t%1,%w0\";
500 if (val == (val & 0xff00))
502 operands[1] = GEN_INT ((char) (val >> 8) & 0xff);
503 return \"sub.l\\t%S0,%S0\;add.b\\t%1,%x0\";
506 /* Look for constants that can be obtained by subs, inc, and
508 switch (val & 0xffffffff)
511 return \"sub.l\\t%S0,%S0\;subs\\t#1,%S0\";
513 return \"sub.l\\t%S0,%S0\;subs\\t#2,%S0\";
515 return \"sub.l\\t%S0,%S0\;subs\\t#4,%S0\";
518 return \"sub.l\\t%S0,%S0\;dec.w\\t#1,%f0\";
520 return \"sub.l\\t%S0,%S0\;dec.w\\t#2,%f0\";
523 return \"sub.l\\t%S0,%S0\;dec.w\\t#1,%e0\";
525 return \"sub.l\\t%S0,%S0\;dec.w\\t#2,%e0\";
528 return \"sub.l\\t%S0,%S0\;inc.w\\t#1,%e0\";
530 return \"sub.l\\t%S0,%S0\;inc.w\\t#2,%e0\";
534 return \"mov.l %S1,%S0\";
536 [(set_attr "length" "2,2,10,10,10,4,4,2,6,4")
537 (set_attr "cc" "set_zn,set_znv,clobber,set_znv,set_znv,set_znv,set_znv,none_0hit,none_0hit,set_znv")])
539 (define_insn "movsf_h8300h"
540 [(set (match_operand:SF 0 "general_operand_dst" "=r,r,r,m,<,r")
541 (match_operand:SF 1 "general_operand_src" "I,r,im,r,r,>"))]
542 "(TARGET_H8300H || TARGET_H8300S)
543 && (register_operand (operands[0], SFmode)
544 || register_operand (operands[1], SFmode))"
552 [(set_attr "length" "2,2,10,10,4,4")
553 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
555 ;; ----------------------------------------------------------------------
557 ;; ----------------------------------------------------------------------
560 [(set (cc0) (zero_extract:QI (match_operand:QI 0 "bit_memory_operand" "r,U")
562 (match_operand:QI 1 "const_int_operand" "n,n")))]
565 [(set_attr "length" "2,8")
566 (set_attr "cc" "set_zn,set_zn")])
569 [(set (cc0) (zero_extract:HI (match_operand:QI 0 "bit_memory_operand" "r,U")
571 (match_operand:QI 1 "const_int_operand" "n,n")))]
574 [(set_attr "length" "2,8")
575 (set_attr "cc" "set_zn,set_zn")])
578 [(set (cc0) (zero_extract:SI (match_operand:QI 0 "bit_memory_operand" "r,U")
580 (match_operand:QI 1 "const_int_operand" "n,n")))]
583 [(set_attr "length" "2,8")
584 (set_attr "cc" "set_zn,set_zn")])
587 [(set (cc0) (zero_extract:QI (match_operand:HI 0 "register_operand" "r")
589 (match_operand:HI 1 "const_int_operand" "n")))]
592 [(set_attr "length" "2")
593 (set_attr "cc" "set_zn")])
596 [(set (cc0) (zero_extract:HI (match_operand:HI 0 "register_operand" "r")
598 (match_operand:HI 1 "const_int_operand" "n")))]
601 [(set_attr "length" "2")
602 (set_attr "cc" "set_zn")])
605 [(set (cc0) (zero_extract:SI (match_operand:HI 0 "register_operand" "r")
607 (match_operand:HI 1 "const_int_operand" "n")))]
610 [(set_attr "length" "2")
611 (set_attr "cc" "set_zn")])
614 [(set (cc0) (match_operand:QI 0 "register_operand" "r"))]
617 [(set_attr "length" "2")
618 (set_attr "cc" "set_znv")])
621 [(set (cc0) (match_operand:HI 0 "register_operand" "r"))]
624 [(set_attr "length" "2")
625 (set_attr "cc" "set_znv")])
628 [(set (cc0) (match_operand:SI 0 "register_operand" "r"))]
629 "TARGET_H8300H || TARGET_H8300S"
631 [(set_attr "length" "2")
632 (set_attr "cc" "set_znv")])
636 (compare:QI (match_operand:QI 0 "register_operand" "r")
637 (match_operand:QI 1 "nonmemory_operand" "rn")))]
640 [(set_attr "length" "2")
641 (set_attr "cc" "compare")])
643 (define_expand "cmphi"
645 (compare:HI (match_operand:HI 0 "register_operand" "")
646 (match_operand:HI 1 "nonmemory_operand" "")))]
650 /* Force operand1 into a register if we're compiling
652 if (GET_CODE (operands[1]) != REG && TARGET_H8300)
653 operands[1] = force_reg (HImode, operands[1]);
658 (compare:HI (match_operand:HI 0 "register_operand" "r")
659 (match_operand:HI 1 "register_operand" "r")))]
662 [(set_attr "length" "2")
663 (set_attr "cc" "compare")])
667 (compare:HI (match_operand:HI 0 "register_operand" "r,r")
668 (match_operand:HI 1 "nonmemory_operand" "r,n")))]
669 "TARGET_H8300H || TARGET_H8300S"
671 [(set_attr "length" "2,4")
672 (set_attr "cc" "compare,compare")])
676 (compare:SI (match_operand:SI 0 "register_operand" "r,r")
677 (match_operand:SI 1 "nonmemory_operand" "r,i")))]
678 "TARGET_H8300H || TARGET_H8300S"
680 [(set_attr "length" "2,6")
681 (set_attr "cc" "compare,compare")])
683 ;; ----------------------------------------------------------------------
685 ;; ----------------------------------------------------------------------
687 (define_insn "addqi3"
688 [(set (match_operand:QI 0 "register_operand" "=r")
689 (plus:QI (match_operand:QI 1 "register_operand" "%0")
690 (match_operand:QI 2 "nonmemory_operand" "rn")))]
693 [(set_attr "length" "2")
694 (set_attr "cc" "set_zn")])
696 (define_expand "addhi3"
697 [(set (match_operand:HI 0 "register_operand" "")
698 (plus:HI (match_operand:HI 1 "register_operand" "")
699 (match_operand:HI 2 "nonmemory_operand" "")))]
704 [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,&r")
705 (plus:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,g")
706 (match_operand:HI 2 "nonmemory_operand" "L,N,n,r,r")))]
711 add.b %s2,%s0\;addx %t2,%t0
713 mov.w %T1,%T0\;add.w %T2,%T0"
714 [(set_attr "length" "2,2,4,2,6")
715 (set_attr "cc" "none_0hit,none_0hit,clobber,set_zn,set_zn")])
718 [(set (match_operand:HI 0 "register_operand" "=r,r,r,r")
719 (plus:HI (match_operand:HI 1 "register_operand" "%0,0,0,0")
720 (match_operand:HI 2 "nonmemory_operand" "L,N,n,r")))]
721 "TARGET_H8300H || TARGET_H8300S"
727 [(set_attr "length" "2,2,4,2")
728 (set_attr "cc" "none_0hit,none_0hit,set_zn,set_zn")])
731 [(set (match_operand:HI 0 "register_operand" "")
732 (plus:HI (match_dup 0)
733 (match_operand:HI 1 "two_insn_adds_subs_operand" "")))]
736 "split_adds_subs (HImode, operands); DONE;")
738 (define_expand "addsi3"
739 [(set (match_operand:SI 0 "register_operand" "")
740 (plus:SI (match_operand:SI 1 "register_operand" "")
741 (match_operand:SI 2 "nonmemory_operand" "")))]
745 (define_insn "addsi_h8300"
746 [(set (match_operand:SI 0 "register_operand" "=r,r,&r")
747 (plus:SI (match_operand:SI 1 "register_operand" "%0,0,r")
748 (match_operand:SI 2 "nonmemory_operand" "n,r,r")))]
751 add %w2,%w0\;addx %x2,%x0\;addx %y2,%y0\;addx %z2,%z0
752 add.w %f2,%f0\;addx %y2,%y0\;addx %z2,%z0
753 mov.w %f1,%f0\;mov.w %e1,%e0\;add.w %f2,%f0\;addx %y2,%y0\;addx %z2,%z0"
754 [(set_attr "length" "8,6,10")
755 (set_attr "cc" "clobber")])
757 (define_insn "addsi_h8300h"
758 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
759 (plus:SI (match_operand:SI 1 "register_operand" "%0,0,0,0")
760 (match_operand:SI 2 "nonmemory_operand" "L,N,i,r")))]
761 "TARGET_H8300H || TARGET_H8300S"
767 [(set_attr "length" "2,2,6,2")
768 (set_attr "cc" "none_0hit,none_0hit,set_zn,set_zn")])
771 [(set (match_operand:SI 0 "register_operand" "")
772 (plus:SI (match_dup 0)
773 (match_operand:SI 1 "two_insn_adds_subs_operand" "")))]
774 "TARGET_H8300H || TARGET_H8300S"
776 "split_adds_subs (SImode, operands); DONE;")
778 ;; ----------------------------------------------------------------------
779 ;; SUBTRACT INSTRUCTIONS
780 ;; ----------------------------------------------------------------------
782 (define_insn "subqi3"
783 [(set (match_operand:QI 0 "register_operand" "=r,r")
784 (minus:QI (match_operand:QI 1 "register_operand" "0,0")
785 (match_operand:QI 2 "nonmemory_operand" "r,n")))]
790 [(set_attr "length" "2")
791 (set_attr "cc" "set_zn")])
793 (define_expand "subhi3"
794 [(set (match_operand:HI 0 "register_operand" "")
795 (minus:HI (match_operand:HI 1 "general_operand" "")
796 (match_operand:HI 2 "nonmemory_operand" "")))]
801 [(set (match_operand:HI 0 "register_operand" "=r,&r")
802 (minus:HI (match_operand:HI 1 "general_operand" "0,0")
803 (match_operand:HI 2 "nonmemory_operand" "r,n")))]
807 add.b %E2,%s0\;addx %F2,%t0"
808 [(set_attr "length" "2,4")
809 (set_attr "cc" "set_zn,clobber")])
812 [(set (match_operand:HI 0 "register_operand" "=r,&r")
813 (minus:HI (match_operand:HI 1 "general_operand" "0,0")
814 (match_operand:HI 2 "nonmemory_operand" "r,n")))]
815 "TARGET_H8300H || TARGET_H8300S"
819 [(set_attr "length" "2,4")
820 (set_attr "cc" "set_zn,set_zn")])
822 (define_expand "subsi3"
823 [(set (match_operand:SI 0 "register_operand" "")
824 (minus:SI (match_operand:SI 1 "register_operand" "")
825 (match_operand:SI 2 "nonmemory_operand" "")))]
829 (define_insn "subsi3_h8300"
830 [(set (match_operand:SI 0 "register_operand" "=r")
831 (minus:SI (match_operand:SI 1 "register_operand" "0")
832 (match_operand:SI 2 "register_operand" "r")))]
834 "sub.w %f2,%f0\;subx %y2,%y0\;subx %z2,%z0"
835 [(set_attr "length" "6")
836 (set_attr "cc" "clobber")])
838 (define_insn "subsi3_h8300h"
839 [(set (match_operand:SI 0 "register_operand" "=r,r")
840 (minus:SI (match_operand:SI 1 "general_operand" "0,0")
841 (match_operand:SI 2 "nonmemory_operand" "r,i")))]
842 "TARGET_H8300H || TARGET_H8300S"
846 [(set_attr "length" "2,6")
847 (set_attr "cc" "set_zn,set_zn")])
849 ;; ----------------------------------------------------------------------
850 ;; MULTIPLY INSTRUCTIONS
851 ;; ----------------------------------------------------------------------
853 ;; Note that the H8/300 can only handle umulqihi3.
855 (define_insn "mulqihi3"
856 [(set (match_operand:HI 0 "register_operand" "=r")
857 (mult:HI (sign_extend:HI (match_operand:QI 1 "general_operand" "%0"))
858 (sign_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
859 "TARGET_H8300H || TARGET_H8300S"
861 [(set_attr "length" "4")
862 (set_attr "cc" "set_zn")])
864 (define_insn "mulhisi3"
865 [(set (match_operand:SI 0 "register_operand" "=r")
866 (mult:SI (sign_extend:SI (match_operand:HI 1 "general_operand" "%0"))
867 (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
868 "TARGET_H8300H || TARGET_H8300S"
870 [(set_attr "length" "4")
871 (set_attr "cc" "set_zn")])
873 (define_insn "umulqihi3"
874 [(set (match_operand:HI 0 "register_operand" "=r")
875 (mult:HI (zero_extend:HI (match_operand:QI 1 "general_operand" "%0"))
876 (zero_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
879 [(set_attr "length" "2")
880 (set_attr "cc" "none_0hit")])
882 (define_insn "umulhisi3"
883 [(set (match_operand:SI 0 "register_operand" "=r")
884 (mult:SI (zero_extend:SI (match_operand:HI 1 "general_operand" "%0"))
885 (zero_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
886 "TARGET_H8300H || TARGET_H8300S"
888 [(set_attr "length" "2")
889 (set_attr "cc" "none_0hit")])
891 ;; This is a "bridge" instruction. Combine can't cram enough insns
892 ;; together to crate a MAC instruction directly, but it can create
893 ;; this instruction, which then allows combine to create the real
896 ;; Unfortunately, if combine doesn't create a MAC instruction, this
897 ;; insn must generate reasonably correct code. Egad.
899 [(set (match_operand:SI 0 "register_operand" "=a")
902 (mem:HI (post_inc:SI (match_operand:SI 1 "register_operand" "r"))))
904 (mem:HI (post_inc:SI (match_operand:SI 2 "register_operand" "r"))))))]
906 "clrmac\;mac @%2+,@%1+"
907 [(set_attr "length" "6")
908 (set_attr "cc" "none_0hit")])
911 [(set (match_operand:SI 0 "register_operand" "=a")
913 (sign_extend:SI (mem:HI
914 (post_inc:SI (match_operand:SI 1 "register_operand" "r"))))
915 (sign_extend:SI (mem:HI
916 (post_inc:SI (match_operand:SI 2 "register_operand" "r")))))
917 (match_operand:SI 3 "register_operand" "0")))]
920 [(set_attr "length" "4")
921 (set_attr "cc" "none_0hit")])
923 ;; ----------------------------------------------------------------------
924 ;; DIVIDE/MOD INSTRUCTIONS
925 ;; ----------------------------------------------------------------------
927 (define_insn "udivmodqi4"
928 [(set (match_operand:QI 0 "register_operand" "=r")
931 (match_operand:HI 1 "general_operand" "0")
932 (zero_extend:HI (match_operand:QI 2 "register_operand" "r")))))
933 (set (match_operand:QI 3 "register_operand" "=r")
937 (zero_extend:HI (match_dup 2)))))]
938 "TARGET_H8300H || TARGET_H8300S"
941 if (find_reg_note (insn, REG_UNUSED, operands[3]))
942 return \"divxu.b\\t%X2,%T0\";
944 return \"divxu.b\\t%X2,%T0\;mov.b\\t%t0,%s3\";
946 [(set_attr "length" "4")
947 (set_attr "cc" "clobber")])
949 (define_insn "divmodqi4"
950 [(set (match_operand:QI 0 "register_operand" "=r")
953 (match_operand:HI 1 "general_operand" "0")
954 (sign_extend:HI (match_operand:QI 2 "register_operand" "r")))))
955 (set (match_operand:QI 3 "register_operand" "=r")
959 (sign_extend:HI (match_dup 2)))))]
960 "TARGET_H8300H || TARGET_H8300S"
963 if (find_reg_note (insn, REG_UNUSED, operands[3]))
964 return \"divxs.b\\t%X2,%T0\";
966 return \"divxs.b\\t%X2,%T0\;mov.b\\t%t0,%s3\";
968 [(set_attr "length" "6")
969 (set_attr "cc" "clobber")])
971 (define_insn "udivmodhi4"
972 [(set (match_operand:HI 0 "register_operand" "=r")
975 (match_operand:SI 1 "general_operand" "0")
976 (zero_extend:SI (match_operand:HI 2 "register_operand" "r")))))
977 (set (match_operand:HI 3 "register_operand" "=r")
981 (zero_extend:SI (match_dup 2)))))]
982 "TARGET_H8300H || TARGET_H8300S"
985 if (find_reg_note (insn, REG_UNUSED, operands[3]))
986 return \"divxu.w\\t%T2,%S0\";
988 return \"divxu.w\\t%T2,%S0\;mov.w\\t%e0,%f3\";
990 [(set_attr "length" "4")
991 (set_attr "cc" "clobber")])
993 (define_insn "divmodhi4"
994 [(set (match_operand:HI 0 "register_operand" "=r")
997 (match_operand:SI 1 "general_operand" "0")
998 (sign_extend:SI (match_operand:HI 2 "register_operand" "r")))))
999 (set (match_operand:HI 3 "register_operand" "=r")
1003 (sign_extend:SI (match_dup 2)))))]
1004 "TARGET_H8300H || TARGET_H8300S"
1007 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1008 return \"divxs.w\\t%T2,%S0\";
1010 return \"divxs.w\\t%T2,%S0\;mov.w\\t%e0,%f3\";
1012 [(set_attr "length" "6")
1013 (set_attr "cc" "clobber")])
1015 ;; ----------------------------------------------------------------------
1017 ;; ----------------------------------------------------------------------
1020 [(set (match_operand:QI 0 "bit_operand" "=r,U")
1021 (and:QI (match_operand:QI 1 "bit_operand" "%0,0")
1022 (match_operand:QI 2 "nonmemory_operand" "rn,O")))]
1023 "register_operand (operands[0], QImode) || o_operand (operands[2], QImode)"
1027 [(set_attr "length" "2,8")
1028 (set_attr "adjust_length" "no")
1029 (set_attr "cc" "set_znv,none_0hit")])
1031 (define_expand "andqi3"
1032 [(set (match_operand:QI 0 "bit_operand" "")
1033 (and:QI (match_operand:QI 1 "bit_operand" "")
1034 (match_operand:QI 2 "nonmemory_operand" "")))]
1038 if (fix_bit_operand (operands, 'O', AND))
1042 (define_expand "andhi3"
1043 [(set (match_operand:HI 0 "register_operand" "")
1044 (and:HI (match_operand:HI 1 "register_operand" "")
1045 (match_operand:HI 2 "nonmemory_operand" "")))]
1050 [(set (match_operand:HI 0 "register_operand" "=r")
1051 (and:HI (match_operand:HI 1 "register_operand" "%0")
1052 (match_operand:HI 2 "nonmemory_operand" "rn")))]
1054 "* return output_logical_op (HImode, AND, operands);"
1055 [(set_attr "length" "4")
1056 (set_attr "cc" "clobber")])
1059 [(set (match_operand:HI 0 "register_operand" "=r,r")
1060 (and:HI (match_operand:HI 1 "register_operand" "%0,0")
1061 (match_operand:HI 2 "nonmemory_operand" "r,n")))]
1062 "TARGET_H8300H || TARGET_H8300S"
1063 "* return output_logical_op (HImode, AND, operands);"
1064 [(set_attr "length" "2,4")
1065 (set_attr "cc" "set_znv,clobber")])
1067 (define_insn "*andorhi3"
1068 [(set (match_operand:HI 0 "register_operand" "=r")
1069 (ior:HI (and:HI (match_operand:HI 2 "register_operand" "r")
1070 (match_operand:HI 3 "p_operand" "P"))
1071 (match_operand:HI 1 "register_operand" "0")))]
1075 if (INTVAL (operands[3]) > 128)
1077 operands[3] = GEN_INT (INTVAL (operands[3]) >> 8);
1078 return \"bld\\t%V3,%t2\;bst\\t%V3,%t0\";
1080 return \"bld\\t%V3,%s2\;bst\\t%V3,%s0\";
1082 [(set_attr "length" "4")
1083 (set_attr "cc" "clobber")])
1085 (define_expand "andsi3"
1086 [(set (match_operand:SI 0 "register_operand" "")
1087 (and:SI (match_operand:SI 1 "register_operand" "")
1088 (match_operand:SI 2 "nonmemory_operand" "")))]
1093 [(set (match_operand:SI 0 "register_operand" "=r")
1094 (and:SI (match_operand:SI 1 "register_operand" "%0")
1095 (match_operand:SI 2 "nonmemory_operand" "rn")))]
1097 "* return output_logical_op (SImode, AND, operands);"
1098 [(set_attr "length" "8")
1099 (set_attr "cc" "clobber")])
1102 [(set (match_operand:SI 0 "register_operand" "=r,r")
1103 (and:SI (match_operand:SI 1 "register_operand" "%0,0")
1104 (match_operand:SI 2 "nonmemory_operand" "r,n")))]
1105 "TARGET_H8300H || TARGET_H8300S"
1106 "* return output_logical_op (SImode, AND, operands);"
1107 [(set_attr "length" "4,6")
1108 (set_attr "cc" "set_znv,clobber")])
1110 ;; ----------------------------------------------------------------------
1112 ;; ----------------------------------------------------------------------
1115 [(set (match_operand:QI 0 "bit_operand" "=r,U")
1116 (ior:QI (match_operand:QI 1 "bit_operand" "%0,0")
1117 (match_operand:QI 2 "nonmemory_operand" "rn,P")))]
1118 "register_operand (operands[0], QImode) || p_operand (operands[2], QImode)"
1122 [(set_attr "length" "2,8")
1123 (set_attr "adjust_length" "no")
1124 (set_attr "cc" "set_znv,none_0hit")])
1126 (define_expand "iorqi3"
1127 [(set (match_operand:QI 0 "bit_operand" "")
1128 (ior:QI (match_operand:QI 1 "bit_operand" "")
1129 (match_operand:QI 2 "nonmemory_operand" "")))]
1133 if (fix_bit_operand (operands, 'P', IOR))
1137 (define_expand "iorhi3"
1138 [(set (match_operand:HI 0 "general_operand" "")
1139 (ior:HI (match_operand:HI 1 "general_operand" "")
1140 (match_operand:HI 2 "general_operand" "")))]
1145 [(set (match_operand:HI 0 "general_operand" "=r,r")
1146 (ior:HI (match_operand:HI 1 "general_operand" "%0,0")
1147 (match_operand:HI 2 "general_operand" "J,rn")))]
1149 "* return output_logical_op (HImode, IOR, operands);"
1150 [(set_attr "length" "2,4")
1151 (set_attr "cc" "clobber,clobber")])
1154 [(set (match_operand:HI 0 "general_operand" "=r,r,r")
1155 (ior:HI (match_operand:HI 1 "general_operand" "%0,0,0")
1156 (match_operand:HI 2 "general_operand" "J,r,n")))]
1157 "TARGET_H8300H || TARGET_H8300S"
1158 "* return output_logical_op (HImode, IOR, operands);"
1159 [(set_attr "length" "2,2,4")
1160 (set_attr "cc" "clobber,set_znv,clobber")])
1162 (define_expand "iorsi3"
1163 [(set (match_operand:SI 0 "register_operand" "")
1164 (ior:SI (match_operand:SI 1 "register_operand" "")
1165 (match_operand:SI 2 "nonmemory_operand" "")))]
1170 [(set (match_operand:SI 0 "register_operand" "=r,r")
1171 (ior:SI (match_operand:SI 1 "register_operand" "%0,0")
1172 (match_operand:SI 2 "nonmemory_operand" "J,rn")))]
1174 "* return output_logical_op (SImode, IOR, operands);"
1175 [(set_attr "length" "2,8")
1176 (set_attr "cc" "clobber,clobber")])
1179 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1180 (ior:SI (match_operand:SI 1 "register_operand" "%0,0,0")
1181 (match_operand:SI 2 "nonmemory_operand" "J,r,n")))]
1182 "TARGET_H8300H || TARGET_H8300S"
1183 "* return output_logical_op (SImode, IOR, operands);"
1184 [(set_attr "length" "2,4,6")
1185 (set_attr "cc" "clobber,set_znv,clobber")])
1187 ;; ----------------------------------------------------------------------
1189 ;; ----------------------------------------------------------------------
1192 [(set (match_operand:QI 0 "bit_operand" "=r,U")
1193 (xor:QI (match_operand:QI 1 "bit_operand" "%0,0")
1194 (match_operand:QI 2 "nonmemory_operand" "rn,P")))]
1195 "register_operand (operands[0], QImode) || p_operand (operands[2], QImode)"
1199 [(set_attr "length" "2,8")
1200 (set_attr "adjust_length" "no")
1201 (set_attr "cc" "set_znv,none_0hit")])
1203 (define_expand "xorqi3"
1204 [(set (match_operand:QI 0 "bit_operand" "")
1205 (xor:QI (match_operand:QI 1 "bit_operand" "")
1206 (match_operand:QI 2 "nonmemory_operand" "")))]
1210 if (fix_bit_operand (operands, 'O', XOR))
1214 (define_expand "xorhi3"
1215 [(set (match_operand:HI 0 "register_operand" "")
1216 (xor:HI (match_operand:HI 1 "general_operand" "")
1217 (match_operand:HI 2 "nonmemory_operand" "")))]
1222 [(set (match_operand:HI 0 "register_operand" "=r,r")
1223 (xor:HI (match_operand:HI 1 "general_operand" "%0,0")
1224 (match_operand:HI 2 "nonmemory_operand" "J,rn")))]
1226 "* return output_logical_op (HImode, XOR, operands);"
1227 [(set_attr "length" "2,4")
1228 (set_attr "cc" "clobber,clobber")])
1231 [(set (match_operand:HI 0 "register_operand" "=r,r,r")
1232 (xor:HI (match_operand:HI 1 "general_operand" "%0,0,0")
1233 (match_operand:HI 2 "nonmemory_operand" "J,r,n")))]
1234 "TARGET_H8300H || TARGET_H8300S"
1235 "* return output_logical_op (HImode, XOR, operands);"
1236 [(set_attr "length" "2,2,4")
1237 (set_attr "cc" "clobber,set_znv,clobber")])
1239 (define_expand "xorsi3"
1240 [(set (match_operand:SI 0 "register_operand" "")
1241 (xor:SI (match_operand:SI 1 "register_operand" "")
1242 (match_operand:SI 2 "nonmemory_operand" "")))]
1247 [(set (match_operand:SI 0 "register_operand" "=r,r")
1248 (xor:SI (match_operand:SI 1 "register_operand" "%0,0")
1249 (match_operand:SI 2 "nonmemory_operand" "J,rn")))]
1251 "* return output_logical_op (SImode, XOR, operands);"
1252 [(set_attr "length" "2,8")
1253 (set_attr "cc" "clobber,clobber")])
1256 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1257 (xor:SI (match_operand:SI 1 "register_operand" "%0,0,0")
1258 (match_operand:SI 2 "nonmemory_operand" "J,r,n")))]
1259 "TARGET_H8300H || TARGET_H8300S"
1260 "* return output_logical_op (SImode, XOR, operands);"
1261 [(set_attr "length" "2,4,6")
1262 (set_attr "cc" "clobber,set_znv,clobber")])
1264 ;; ----------------------------------------------------------------------
1265 ;; NEGATION INSTRUCTIONS
1266 ;; ----------------------------------------------------------------------
1268 (define_insn "negqi2"
1269 [(set (match_operand:QI 0 "register_operand" "=r")
1270 (neg:QI (match_operand:QI 1 "general_operand" "0")))]
1273 [(set_attr "length" "2")
1274 (set_attr "cc" "set_zn")])
1276 (define_expand "neghi2"
1277 [(set (match_operand:HI 0 "register_operand" "=r")
1278 (neg:HI (match_operand:HI 1 "general_operand" "0")))]
1284 emit_insn (gen_neghi2_h8300 (operands[0], operands[1]));
1289 (define_expand "neghi2_h8300"
1291 (not:HI (match_operand:HI 1 "register_operand" "r")))
1292 (set (match_dup 2) (plus:HI (match_dup 2) (const_int 1)))
1293 (set (match_operand:HI 0 "register_operand" "=r")
1296 "{ operands[2] = gen_reg_rtx (HImode); }")
1298 (define_insn "neghi2_h8300h"
1299 [(set (match_operand:HI 0 "register_operand" "=r")
1300 (neg:HI (match_operand:HI 1 "general_operand" "0")))]
1301 "TARGET_H8300H || TARGET_H8300S"
1303 [(set_attr "length" "2")
1304 (set_attr "cc" "set_zn")])
1306 (define_expand "negsi2"
1307 [(set (match_operand:SI 0 "register_operand" "=r")
1308 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
1314 emit_insn (gen_negsi2_h8300 (operands[0], operands[1]));
1319 (define_expand "negsi2_h8300"
1321 (not:SI (match_operand:SI 1 "register_operand" "r")))
1322 (set (match_dup 2) (plus:SI (match_dup 2) (const_int 1)))
1323 (set (match_operand:SI 0 "register_operand" "=r")
1326 "{ operands[2] = gen_reg_rtx(SImode); }")
1328 (define_insn "negsi2_h8300h"
1329 [(set (match_operand:SI 0 "register_operand" "=r")
1330 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
1331 "TARGET_H8300H || TARGET_H8300S"
1333 [(set_attr "length" "2")
1334 (set_attr "cc" "set_zn")])
1336 ;; ----------------------------------------------------------------------
1338 ;; ----------------------------------------------------------------------
1340 (define_insn "one_cmplqi2"
1341 [(set (match_operand:QI 0 "register_operand" "=r")
1342 (not:QI (match_operand:QI 1 "general_operand" "0")))]
1345 [(set_attr "length" "2")
1346 (set_attr "cc" "set_znv")])
1348 (define_insn "one_cmplhi2"
1349 [(set (match_operand:HI 0 "register_operand" "=r")
1350 (not:HI (match_operand:HI 1 "general_operand" "0")))]
1355 return \"not %s0\;not %t0\";
1359 [(set_attr "cc" "clobber")
1360 (set (attr "length")
1361 (if_then_else (eq (symbol_ref "TARGET_H8300H || TARGET_H8300S")
1366 (define_insn "one_cmplsi2"
1367 [(set (match_operand:SI 0 "register_operand" "=r")
1368 (not:SI (match_operand:SI 1 "general_operand" "0")))]
1373 return \"not %w0\;not %x0\;not %y0\;not %z0\";
1377 [(set_attr "cc" "clobber")
1378 (set (attr "length")
1379 (if_then_else (eq (symbol_ref "TARGET_H8300H || TARGET_H8300S")
1384 ;; ----------------------------------------------------------------------
1385 ;; JUMP INSTRUCTIONS
1386 ;; ----------------------------------------------------------------------
1388 ;; Conditional jump instructions
1390 (define_expand "ble"
1392 (if_then_else (le (cc0)
1394 (label_ref (match_operand 0 "" ""))
1399 (define_expand "bleu"
1401 (if_then_else (leu (cc0)
1403 (label_ref (match_operand 0 "" ""))
1408 (define_expand "bge"
1410 (if_then_else (ge (cc0)
1412 (label_ref (match_operand 0 "" ""))
1417 (define_expand "bgeu"
1419 (if_then_else (geu (cc0)
1421 (label_ref (match_operand 0 "" ""))
1426 (define_expand "blt"
1428 (if_then_else (lt (cc0)
1430 (label_ref (match_operand 0 "" ""))
1435 (define_expand "bltu"
1437 (if_then_else (ltu (cc0)
1439 (label_ref (match_operand 0 "" ""))
1444 (define_expand "bgt"
1446 (if_then_else (gt (cc0)
1448 (label_ref (match_operand 0 "" ""))
1453 (define_expand "bgtu"
1455 (if_then_else (gtu (cc0)
1457 (label_ref (match_operand 0 "" ""))
1462 (define_expand "beq"
1464 (if_then_else (eq (cc0)
1466 (label_ref (match_operand 0 "" ""))
1471 (define_expand "bne"
1473 (if_then_else (ne (cc0)
1475 (label_ref (match_operand 0 "" ""))
1480 (define_insn "branch_true"
1482 (if_then_else (match_operator 1 "comparison_operator"
1483 [(cc0) (const_int 0)])
1484 (label_ref (match_operand 0 "" ""))
1489 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
1490 && (GET_CODE (operands[1]) == GT
1491 || GET_CODE (operands[1]) == GE
1492 || GET_CODE (operands[1]) == LE
1493 || GET_CODE (operands[1]) == LT))
1495 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
1499 if (get_attr_length (insn) == 2)
1500 return \"b%j1 %l0\";
1501 else if (get_attr_length (insn) == 4)
1502 return \"b%j1 %l0:16\";
1504 return \"b%k1 .Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:\";
1506 [(set_attr "type" "branch")
1507 (set_attr "cc" "none")])
1509 (define_insn "branch_false"
1511 (if_then_else (match_operator 1 "comparison_operator"
1512 [(cc0) (const_int 0)])
1514 (label_ref (match_operand 0 "" ""))))]
1518 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
1519 && (GET_CODE (operands[1]) == GT
1520 || GET_CODE (operands[1]) == GE
1521 || GET_CODE (operands[1]) == LE
1522 || GET_CODE (operands[1]) == LT))
1524 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
1528 if (get_attr_length (insn) == 2)
1529 return \"b%k1 %l0\";
1530 else if (get_attr_length (insn) == 4)
1531 return \"b%k1 %l0:16\";
1533 return \"b%j1 .Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:\";
1535 [(set_attr "type" "branch")
1536 (set_attr "cc" "none")])
1538 ;; Unconditional and other jump instructions.
1542 (label_ref (match_operand 0 "" "")))]
1546 if (get_attr_length (insn) == 2)
1548 else if (get_attr_length (insn) == 4)
1549 return \"bra %l0:16\";
1551 return \"jmp @%l0\";
1553 [(set_attr "type" "branch")
1554 (set_attr "cc" "none")])
1556 ;; This is a define expand, because pointers may be either 16 or 32 bits.
1558 (define_expand "tablejump"
1559 [(parallel [(set (pc) (match_operand 0 "register_operand" "r"))
1560 (use (label_ref (match_operand 1 "" "")))])]
1564 (define_insn "tablejump_h8300"
1565 [(set (pc) (match_operand:HI 0 "register_operand" "r"))
1566 (use (label_ref (match_operand 1 "" "")))]
1569 [(set_attr "cc" "none")
1570 (set_attr "length" "2")])
1572 (define_insn "tablejump_h8300h"
1573 [(set (pc) (match_operand:SI 0 "register_operand" "r"))
1574 (use (label_ref (match_operand 1 "" "")))]
1575 "TARGET_H8300H || TARGET_H8300S"
1577 [(set_attr "cc" "none")
1578 (set_attr "length" "2")])
1580 ;; This is a define expand, because pointers may be either 16 or 32 bits.
1582 (define_expand "indirect_jump"
1583 [(set (pc) (match_operand 0 "jump_address_operand" ""))]
1587 (define_insn "indirect_jump_h8300"
1588 [(set (pc) (match_operand:HI 0 "jump_address_operand" "Vr"))]
1591 [(set_attr "cc" "none")
1592 (set_attr "length" "2")])
1594 (define_insn "indirect_jump_h8300h"
1595 [(set (pc) (match_operand:SI 0 "jump_address_operand" "Vr"))]
1596 "TARGET_H8300H || TARGET_H8300S"
1598 [(set_attr "cc" "none")
1599 (set_attr "length" "2")])
1601 ;; Call subroutine with no return value.
1603 ;; ??? Even though we use HImode here, this works for the 300h.
1606 [(call (match_operand:QI 0 "call_insn_operand" "or")
1607 (match_operand:HI 1 "general_operand" "g"))]
1611 if (GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
1612 && SYMBOL_REF_FLAG (XEXP (operands[0], 0)))
1613 return \"jsr\\t@%0:8\";
1615 return \"jsr\\t%0\";
1617 [(set_attr "cc" "clobber")
1618 (set (attr "length")
1619 (if_then_else (match_operand:QI 0 "small_call_insn_operand" "")
1623 ;; Call subroutine, returning value in operand 0
1624 ;; (which must be a hard register).
1626 ;; ??? Even though we use HImode here, this works on the 300h.
1628 (define_insn "call_value"
1629 [(set (match_operand 0 "" "=r")
1630 (call (match_operand:QI 1 "call_insn_operand" "or")
1631 (match_operand:HI 2 "general_operand" "g")))]
1635 if (GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
1636 && SYMBOL_REF_FLAG (XEXP (operands[1], 0)))
1637 return \"jsr\\t@%1:8\";
1639 return \"jsr\\t%1\";
1641 [(set_attr "cc" "clobber")
1642 (set (attr "length")
1643 (if_then_else (match_operand:QI 0 "small_call_insn_operand" "")
1651 [(set_attr "cc" "none")
1652 (set_attr "length" "2")])
1654 ;; ----------------------------------------------------------------------
1655 ;; EXTEND INSTRUCTIONS
1656 ;; ----------------------------------------------------------------------
1658 (define_expand "zero_extendqihi2"
1659 [(set (match_operand:HI 0 "register_operand" "")
1660 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "")))]
1665 [(set (match_operand:HI 0 "register_operand" "=r,r")
1666 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
1670 mov.b %R1,%s0\;mov.b #0,%t0"
1671 [(set_attr "length" "2,10")
1672 (set_attr "cc" "clobber,clobber")])
1675 [(set (match_operand:HI 0 "register_operand" "=r,r")
1676 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
1677 "TARGET_H8300H || TARGET_H8300S"
1680 mov.b %R1,%s0\;extu.w %T0"
1681 [(set_attr "length" "2,10")
1682 (set_attr "cc" "set_znv,set_znv")])
1684 ;; The compiler can synthesize a 300H variant of this which is
1685 ;; just as efficient as one that we'd create
1686 (define_insn "zero_extendqisi2"
1687 [(set (match_operand:SI 0 "register_operand" "=r,r")
1688 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
1691 mov.b #0,%x0\;sub.w %e0,%e0
1692 mov.b %R1,%w0\;mov.b #0,%x0\;sub.w %e0,%e0"
1693 [(set_attr "length" "4,6")
1694 (set_attr "cc" "clobber,clobber")])
1696 (define_expand "zero_extendhisi2"
1697 [(set (match_operand:SI 0 "register_operand" "")
1698 (zero_extend:SI (match_operand:HI 1 "register_operand" "")))]
1702 ;; %e prints the high part of a CONST_INT, not the low part. Arggh.
1704 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1705 (zero_extend:SI (match_operand:HI 1 "general_operand_src" "0,i,g>")))]
1709 mov.w %f1,%f0\;sub.w %e0,%e0
1710 mov.w %e1,%f0\;sub.w %e0,%e0"
1711 [(set_attr "length" "2,4,4")
1712 (set_attr "cc" "clobber,clobber,clobber")])
1715 [(set (match_operand:SI 0 "register_operand" "=r")
1716 (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))]
1717 "TARGET_H8300H || TARGET_H8300S"
1719 [(set_attr "length" "2")
1720 (set_attr "cc" "set_znv")])
1722 (define_expand "extendqihi2"
1723 [(set (match_operand:HI 0 "register_operand" "")
1724 (sign_extend:HI (match_operand:QI 1 "register_operand" "")))]
1729 [(set (match_operand:HI 0 "register_operand" "=r,r")
1730 (sign_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
1733 bld #7,%s0\;subx %t0,%t0
1734 mov.b %R1,%s0\;bld #7,%s0\;subx %t0,%t0"
1735 [(set_attr "length" "4,6")
1736 (set_attr "cc" "clobber,clobber")])
1739 [(set (match_operand:HI 0 "register_operand" "=r")
1740 (sign_extend:HI (match_operand:QI 1 "register_operand" "0")))]
1741 "TARGET_H8300H || TARGET_H8300S"
1743 [(set_attr "length" "2")
1744 (set_attr "cc" "set_znv")])
1746 ;; The compiler can synthesize a 300H variant of this which is
1747 ;; just as efficient as one that we'd create
1748 (define_insn "extendqisi2"
1749 [(set (match_operand:SI 0 "register_operand" "=r,r")
1750 (sign_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
1753 bld #7,%w0\;subx %x0,%x0\;subx %y0,%y0\;subx %z0,%z0
1754 mov.b %R1,%w0\;bld #7,%w0\;subx %x0,%x0\;subx %y0,%y0\;subx %z0,%z0"
1755 [(set_attr "length" "8,10")
1756 (set_attr "cc" "clobber,clobber")])
1758 (define_expand "extendhisi2"
1759 [(set (match_operand:SI 0 "register_operand" "")
1760 (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
1765 [(set (match_operand:SI 0 "register_operand" "=r,r")
1766 (sign_extend:SI (match_operand:HI 1 "general_operand_src" "0,g>")))]
1769 bld #7,%x0\;subx %y0,%y0\;subx %z0,%z0
1770 mov.w %T1,%f0\;bld #7,%x0\;subx %y0,%y0\;subx %z0,%z0"
1771 [(set_attr "length" "6,8")
1772 (set_attr "cc" "clobber,clobber")])
1775 [(set (match_operand:SI 0 "register_operand" "=r")
1776 (sign_extend:SI (match_operand:HI 1 "register_operand" "0")))]
1777 "TARGET_H8300H || TARGET_H8300S"
1779 [(set_attr "length" "2")
1780 (set_attr "cc" "set_znv")])
1782 ;; ----------------------------------------------------------------------
1784 ;; ----------------------------------------------------------------------
1786 ;; We make some attempt to provide real efficient shifting. One example is
1787 ;; doing an 8 bit shift of a 16 bit value by moving a byte reg into the other
1788 ;; reg and moving 0 into the former reg.
1790 ;; We also try to achieve this in a uniform way. IE: We don't try to achieve
1791 ;; this in both rtl and at insn emit time. Ideally, we'd use rtl as that would
1792 ;; give the optimizer more cracks at the code. However, we wish to do things
1793 ;; like optimizing shifting the sign bit to bit 0 by rotating the other way.
1794 ;; There is rtl to handle this (rotate + and), but the H8/300 doesn't handle
1795 ;; 16 bit rotates. Also, if we emit complicated rtl, combine may not be able
1796 ;; to detect cases it can optimize.
1798 ;; For these and other fuzzy reasons, I've decided to go the less pretty but
1799 ;; easier "do it at insn emit time" route.
1803 (define_expand "ashlqi3"
1804 [(set (match_operand:QI 0 "register_operand" "")
1805 (ashift:QI (match_operand:QI 1 "register_operand" "")
1806 (match_operand:QI 2 "nonmemory_operand" "")))]
1808 "if (expand_a_shift (QImode, ASHIFT, operands)) DONE; else FAIL;")
1810 (define_expand "ashrqi3"
1811 [(set (match_operand:QI 0 "register_operand" "")
1812 (ashiftrt:QI (match_operand:QI 1 "register_operand" "")
1813 (match_operand:QI 2 "nonmemory_operand" "")))]
1815 "if (expand_a_shift (QImode, ASHIFTRT, operands)) DONE; else FAIL;")
1817 (define_expand "lshrqi3"
1818 [(set (match_operand:QI 0 "register_operand" "")
1819 (lshiftrt:QI (match_operand:QI 1 "register_operand" "")
1820 (match_operand:QI 2 "nonmemory_operand" "")))]
1822 "if (expand_a_shift (QImode, LSHIFTRT, operands)) DONE; else FAIL;")
1825 [(set (match_operand:QI 0 "register_operand" "=r,r")
1826 (match_operator:QI 3 "nshift_operator"
1827 [ (match_operand:QI 1 "register_operand" "0,0")
1828 (match_operand:QI 2 "nonmemory_operand" "KM,rn")]))
1829 (clobber (match_scratch:QI 4 "=X,&r"))]
1831 "* return emit_a_shift (insn, operands);"
1832 [(set_attr "length" "20")
1833 (set_attr "cc" "clobber")])
1837 (define_expand "ashlhi3"
1838 [(set (match_operand:HI 0 "register_operand" "")
1839 (ashift:HI (match_operand:HI 1 "nonmemory_operand" "")
1840 (match_operand:QI 2 "nonmemory_operand" "")))]
1842 "if (expand_a_shift (HImode, ASHIFT, operands)) DONE; else FAIL;")
1844 (define_expand "lshrhi3"
1845 [(set (match_operand:HI 0 "register_operand" "")
1846 (lshiftrt:HI (match_operand:HI 1 "general_operand" "")
1847 (match_operand:QI 2 "nonmemory_operand" "")))]
1849 "if (expand_a_shift (HImode, LSHIFTRT, operands)) DONE; else FAIL;")
1851 (define_expand "ashrhi3"
1852 [(set (match_operand:HI 0 "register_operand" "")
1853 (ashiftrt:HI (match_operand:HI 1 "register_operand" "")
1854 (match_operand:QI 2 "nonmemory_operand" "")))]
1856 "if (expand_a_shift (HImode, ASHIFTRT, operands)) DONE; else FAIL;")
1859 [(set (match_operand:HI 0 "register_operand" "=r,r")
1860 (match_operator:HI 3 "nshift_operator"
1861 [ (match_operand:HI 1 "register_operand" "0,0")
1862 (match_operand:QI 2 "nonmemory_operand" "KM,rn")]))
1863 (clobber (match_scratch:QI 4 "=X,&r"))]
1865 "* return emit_a_shift (insn, operands);"
1866 [(set_attr "length" "20")
1867 (set_attr "cc" "clobber")])
1871 (define_expand "ashlsi3"
1872 [(set (match_operand:SI 0 "register_operand" "")
1874 (match_operand:SI 1 "general_operand" "")
1875 (match_operand:QI 2 "nonmemory_operand" "")))]
1877 "if (expand_a_shift (SImode, ASHIFT, operands)) DONE; else FAIL;")
1879 (define_expand "lshrsi3"
1880 [(set (match_operand:SI 0 "register_operand" "")
1882 (match_operand:SI 1 "general_operand" "")
1883 (match_operand:QI 2 "nonmemory_operand" "")))]
1885 "if (expand_a_shift (SImode, LSHIFTRT, operands)) DONE; else FAIL;")
1887 (define_expand "ashrsi3"
1888 [(set (match_operand:SI 0 "register_operand" "")
1890 (match_operand:SI 1 "general_operand" "")
1891 (match_operand:QI 2 "nonmemory_operand" "")))]
1893 "if (expand_a_shift (SImode, ASHIFTRT, operands)) DONE; else FAIL;")
1896 [(set (match_operand:SI 0 "register_operand" "=r,r")
1897 (match_operator:SI 3 "nshift_operator"
1898 [ (match_operand:SI 1 "register_operand" "0,0")
1899 (match_operand:QI 2 "nonmemory_operand" "K,rn")]))
1900 (clobber (match_scratch:QI 4 "=X,&r"))]
1902 "* return emit_a_shift (insn, operands);"
1903 [(set_attr "length" "20")
1904 (set_attr "cc" "clobber")])
1906 ;; ----------------------------------------------------------------------
1908 ;; ----------------------------------------------------------------------
1910 (define_expand "rotlqi3"
1911 [(set (match_operand:QI 0 "register_operand" "")
1912 (rotate:QI (match_operand:QI 1 "register_operand" "")
1913 (match_operand:QI 2 "nonmemory_operand" "")))]
1915 "if (expand_a_rotate (ROTATE, operands)) DONE; else FAIL;")
1917 (define_insn "*rotlqi3_1"
1918 [(set (match_operand:QI 0 "register_operand" "=r")
1919 (rotate:QI (match_operand:QI 1 "register_operand" "0")
1920 (match_operand:QI 2 "immediate_operand" "")))]
1922 "* return emit_a_rotate (ROTATE, operands);"
1923 [(set_attr "length" "20")
1924 (set_attr "cc" "clobber")])
1926 (define_expand "rotlhi3"
1927 [(set (match_operand:HI 0 "register_operand" "")
1928 (rotate:HI (match_operand:HI 1 "register_operand" "")
1929 (match_operand:QI 2 "nonmemory_operand" "")))]
1931 "if (expand_a_rotate (ROTATE, operands)) DONE; else FAIL;")
1933 (define_insn "*rotlhi3_1"
1934 [(set (match_operand:HI 0 "register_operand" "=r")
1935 (rotate:HI (match_operand:HI 1 "register_operand" "0")
1936 (match_operand:QI 2 "immediate_operand" "")))]
1938 "* return emit_a_rotate (ROTATE, operands);"
1939 [(set_attr "length" "20")
1940 (set_attr "cc" "clobber")])
1942 (define_expand "rotlsi3"
1943 [(set (match_operand:SI 0 "register_operand" "")
1944 (rotate:SI (match_operand:SI 1 "register_operand" "")
1945 (match_operand:QI 2 "nonmemory_operand" "")))]
1946 "TARGET_H8300H || TARGET_H8300S"
1947 "if (expand_a_rotate (ROTATE, operands)) DONE; else FAIL;")
1949 (define_insn "*rotlsi3_1"
1950 [(set (match_operand:SI 0 "register_operand" "=r")
1951 (rotate:SI (match_operand:SI 1 "register_operand" "0")
1952 (match_operand:QI 2 "immediate_operand" "")))]
1953 "TARGET_H8300H || TARGET_H8300S"
1954 "* return emit_a_rotate (ROTATE, operands);"
1955 [(set_attr "length" "20")
1956 (set_attr "cc" "clobber")])
1958 ;; -----------------------------------------------------------------
1960 ;; -----------------------------------------------------------------
1961 ;; The H8/300 has given 1/8th of its opcode space to bitfield
1962 ;; instructions so let's use them as well as we can.
1964 ;; You'll never believe all these patterns perform one basic action --
1965 ;; load a bit from the source, optionally invert the bit, then store it
1966 ;; in the destination (which is known to be zero).
1968 ;; Combine obviously need some work to better identify this situation and
1969 ;; canonicalize the form better.
1972 ;; Normal loads with a 16bit destination.
1974 ;; Yes, both cases are needed.
1977 [(set (match_operand:HI 0 "register_operand" "=&r")
1978 (zero_extract:HI (match_operand:HI 1 "register_operand" "r")
1980 (match_operand:HI 2 "immediate_operand" "n")))]
1982 "sub.w %0,%0\;bld %Z2,%Y1\;bst #0,%X0"
1983 [(set_attr "cc" "clobber")
1984 (set_attr "length" "6")])
1987 [(set (match_operand:HI 0 "register_operand" "=&r")
1988 (subreg:HI (zero_extract:SI
1989 (match_operand:HI 1 "register_operand" "r")
1991 (match_operand:HI 2 "immediate_operand" "n")) 2))]
1993 "sub.w %0,%0\;bld %Z2,%Y1\;bst #0,%X0"
1994 [(set_attr "cc" "clobber")
1995 (set_attr "length" "6")])
1998 ;; Inverted loads with a 16bit destination.
2000 ;; Yes, all four cases are needed.
2004 [(set (match_operand:HI 0 "register_operand" "=&r")
2005 (zero_extract:HI (xor:HI (match_operand:HI 1 "register_operand" "r")
2006 (match_operand:HI 3 "p_operand" "P"))
2008 (match_operand:HI 2 "const_int_operand" "n")))]
2009 "(1 << INTVAL (operands[2])) == INTVAL (operands[3])"
2010 "sub.w %0,%0\;bild %Z2,%Y1\;bst #0,%X0"
2011 [(set_attr "cc" "clobber")
2012 (set_attr "length" "8")])
2015 [(set (match_operand:HI 0 "register_operand" "=&r")
2018 (match_operand:HI 1 "bit_operand" "Ur")
2019 (match_operand:HI 2 "const_int_operand" "n")))
2022 "sub.w %0,%0\;bild %Z2,%Y1\;bst #0,%X0"
2023 [(set_attr "cc" "clobber")
2024 (set_attr "length" "8")])
2027 [(set (match_operand:HI 0 "register_operand" "=&r")
2031 (match_operand:SI 1 "register_operand" "Ur")
2032 (match_operand:SI 2 "const_int_operand" "n")) 2))
2034 "INTVAL (operands[2]) < 16"
2035 "sub.w %0,%0\;bild %Z2,%Y1\;bst #0,%X0"
2036 [(set_attr "cc" "clobber")
2037 (set_attr "length" "8")])
2040 [(set (match_operand:HI 0 "register_operand" "=&r")
2044 (match_operand:SI 1 "bit_operand" "Ur")
2045 (match_operand:SI 2 "const_int_operand" "n")) 0))
2047 "(TARGET_H8300H || TARGET_H8300S)
2048 && INTVAL (operands[2]) < 16"
2049 "sub.w %0,%0\;bild %Z2,%Y1\;bst #0,%X0"
2050 [(set_attr "cc" "clobber")
2051 (set_attr "length" "8")])
2054 ;; Normal loads with a 32bit destination.
2056 ;; Yes, all three cases are needed.
2059 [(set (match_operand:SI 0 "register_operand" "=&r")
2060 (zero_extract:SI (match_operand:HI 1 "register_operand" "r")
2062 (match_operand:HI 2 "const_int_operand" "n")))]
2064 "* return output_simode_bld (0, 0, operands);"
2065 [(set_attr "cc" "clobber")
2066 (set (attr "length")
2067 (if_then_else (eq (symbol_ref "TARGET_H8300H || TARGET_H8300S")
2073 [(set (match_operand:SI 0 "register_operand" "=&r")
2074 (and:SI (zero_extend:SI
2076 (match_operand:QI 1 "bit_operand" "Ur")
2077 (match_operand:QI 2 "const_int_operand" "n")))
2080 "* return output_simode_bld (0, 0, operands);"
2081 [(set_attr "cc" "clobber")
2082 (set (attr "length")
2083 (if_then_else (eq (symbol_ref "TARGET_H8300H || TARGET_H8300S")
2089 [(set (match_operand:SI 0 "register_operand" "=&r")
2090 (and:SI (zero_extend:SI
2092 (match_operand:HI 1 "bit_operand" "Ur")
2093 (match_operand:HI 2 "const_int_operand" "n")))
2096 "* return output_simode_bld (0, 0, operands);"
2097 [(set_attr "cc" "clobber")
2098 (set (attr "length")
2099 (if_then_else (eq (symbol_ref "TARGET_H8300H || TARGET_H8300S")
2105 ;; Inverted loads with a 32bit destination.
2107 ;; Yes, all five cases are needed.
2110 [(set (match_operand:SI 0 "register_operand" "=&r")
2113 (lshiftrt:HI (match_operand:HI 1 "bit_operand" "Ur")
2114 (match_operand:HI 2 "const_int_operand" "n"))))
2117 "* return output_simode_bld (1, 0, operands);"
2118 [(set_attr "cc" "clobber")
2119 (set (attr "length")
2120 (if_then_else (eq (symbol_ref "TARGET_H8300H || TARGET_H8300S")
2126 [(set (match_operand:SI 0 "register_operand" "=&r")
2129 (lshiftrt:QI (match_operand:QI 1 "bit_operand" "Ur")
2130 (match_operand:QI 2 "const_int_operand" "n"))))
2133 "* return output_simode_bld (1, 0, operands);"
2134 [(set_attr "cc" "clobber")
2135 (set (attr "length")
2136 (if_then_else (eq (symbol_ref "TARGET_H8300H || TARGET_H8300S")
2142 [(set (match_operand:SI 0 "register_operand" "=&r")
2146 (match_operand:HI 1 "bit_operand" "Ur")
2147 (match_operand:HI 2 "const_int_operand" "n")) 0))
2150 "* return output_simode_bld (1, 0, operands);"
2151 [(set_attr "cc" "clobber")
2152 (set (attr "length")
2153 (if_then_else (eq (symbol_ref "TARGET_H8300H || TARGET_H8300S")
2159 [(set (match_operand:SI 0 "register_operand" "=&r")
2163 (match_operand:QI 1 "bit_operand" "Ur")
2164 (match_operand:QI 2 "const_int_operand" "n")) 0))
2167 "* return output_simode_bld (1, 0, operands);"
2168 [(set_attr "cc" "clobber")
2169 (set (attr "length")
2170 (if_then_else (eq (symbol_ref "TARGET_H8300H || TARGET_H8300S")
2176 [(set (match_operand:SI 0 "register_operand" "=&r")
2177 (zero_extract:SI (xor:HI (match_operand:HI 1 "register_operand" "r")
2178 (match_operand:HI 3 "p_operand" "P"))
2180 (match_operand:HI 2 "const_int_operand" "n")))]
2181 "(1 << INTVAL (operands[2])) == INTVAL (operands[3])"
2182 "sub.w %0,%0\;bild %Z2,%Y1\;bst #0,%X0"
2183 [(set_attr "cc" "clobber")
2184 (set_attr "length" "8")])
2186 (define_expand "insv"
2187 [(set (zero_extract:HI (match_operand:HI 0 "general_operand" "")
2188 (match_operand:HI 1 "general_operand" "")
2189 (match_operand:HI 2 "general_operand" ""))
2190 (match_operand:HI 3 "general_operand" ""))]
2194 /* We only have single bit bitfield instructions. */
2195 if (INTVAL (operands[1]) != 1)
2198 /* For now, we don't allow memory operands. */
2199 if (GET_CODE (operands[0]) == MEM
2200 || GET_CODE (operands[3]) == MEM)
2205 [(set (zero_extract:HI (match_operand:HI 0 "register_operand" "+r")
2207 (match_operand:HI 1 "immediate_operand" "n"))
2208 (match_operand:HI 2 "register_operand" "r"))]
2210 "bld #0,%R2\;bst %Z1,%Y0 ; i1"
2211 [(set_attr "cc" "clobber")
2212 (set_attr "length" "4")])
2214 (define_expand "extzv"
2215 [(set (match_operand:HI 0 "register_operand" "")
2216 (zero_extract:HI (match_operand:HI 1 "bit_operand" "")
2217 (match_operand:HI 2 "general_operand" "")
2218 (match_operand:HI 3 "general_operand" "")))]
2222 /* We only have single bit bitfield instructions. */
2223 if (INTVAL (operands[2]) != 1)
2226 /* For now, we don't allow memory operands. */
2227 if (GET_CODE (operands[1]) == MEM)
2231 ;; BAND, BOR, and BXOR patterns
2234 [(set (match_operand:HI 0 "bit_operand" "=Ur")
2235 (match_operator:HI 4 "bit_operator"
2236 [(zero_extract:HI (match_operand:HI 1 "register_operand" "r")
2238 (match_operand:HI 2 "immediate_operand" "n"))
2239 (match_operand:HI 3 "bit_operand" "0")]))]
2241 "bld %Z2,%Y1\;%b4 #0,%R0\;bst #0,%R0; bl1"
2242 [(set_attr "cc" "clobber")
2243 (set_attr "length" "6")
2244 (set_attr "adjust_length" "no")])
2247 [(set (match_operand:HI 0 "bit_operand" "=Ur")
2248 (match_operator:HI 5 "bit_operator"
2249 [(zero_extract:HI (match_operand:HI 1 "register_operand" "r")
2251 (match_operand:HI 2 "immediate_operand" "n"))
2252 (zero_extract:HI (match_operand:HI 3 "register_operand" "r")
2254 (match_operand:HI 4 "immediate_operand" "n"))]))]
2256 "bld %Z2,%Y1\;%b5 %Z4,%Y3\;bst #0,%R0; bl3"
2257 [(set_attr "cc" "clobber")
2258 (set_attr "length" "6")
2259 (set_attr "adjust_length" "no")])
2261 ;; -----------------------------------------------------------------
2263 ;; -----------------------------------------------------------------
2266 [(set (match_operand:HI 0 "register_operand" "=r")
2268 (zero_extend:HI (match_operand:QI 1 "register_operand" "r"))
2269 (match_operand:HI 2 "register_operand" "0")))]
2270 "REG_P (operands[0])
2271 && REG_P (operands[1])
2272 && REGNO (operands[0]) != REGNO (operands[1])"
2274 [(set_attr "cc" "clobber")
2275 (set_attr "length" "2")])
2278 [(set (match_operand:SI 0 "register_operand" "=r")
2280 (zero_extend:SI (match_operand:HI 1 "register_operand" "r"))
2281 (match_operand:SI 2 "register_operand" "0")))]
2282 "(TARGET_H8300H || TARGET_H8300S)
2283 && REG_P (operands[0])
2284 && REG_P (operands[1])
2285 && (REGNO (operands[0]) != REGNO (operands[1]))"
2287 [(set_attr "cc" "clobber")
2288 (set_attr "length" "2")])
2291 [(set (match_operand:SI 0 "register_operand" "=r")
2293 (zero_extend:SI (match_operand:QI 1 "register_operand" "r"))
2294 (match_operand:SI 2 "register_operand" "0")))]
2295 "REG_P (operands[0])
2296 && REG_P (operands[1])
2297 && REGNO (operands[0]) != REGNO (operands[1])"
2299 [(set_attr "cc" "clobber")
2300 (set_attr "length" "2")])
2303 [(set (match_operand:HI 0 "register_operand" "=r")
2305 (zero_extend:HI (match_operand:QI 1 "register_operand" "r"))
2306 (match_operand:HI 2 "register_operand" "0")))]
2307 "REG_P (operands[0])
2308 && REG_P (operands[1])
2309 && REGNO (operands[0]) != REGNO (operands[1])"
2311 [(set_attr "cc" "clobber")
2312 (set_attr "length" "2")])
2315 [(set (match_operand:SI 0 "register_operand" "=r")
2317 (zero_extend:SI (match_operand:HI 1 "register_operand" "r"))
2318 (match_operand:SI 2 "register_operand" "0")))]
2319 "(TARGET_H8300H || TARGET_H8300S)
2320 && REG_P (operands[0])
2321 && REG_P (operands[1])
2322 && (REGNO (operands[0]) != REGNO (operands[1]))"
2324 [(set_attr "cc" "clobber")
2325 (set_attr "length" "2")])
2328 [(set (match_operand:SI 0 "register_operand" "=r")
2330 (zero_extend:SI (match_operand:QI 1 "register_operand" "r"))
2331 (match_operand:SI 2 "register_operand" "0")))]
2332 "REG_P (operands[0])
2333 && REG_P (operands[1])
2334 && REGNO (operands[0]) != REGNO (operands[1])"
2336 [(set_attr "cc" "clobber")
2337 (set_attr "length" "2")])
2340 [(set (match_operand:HI 0 "register_operand" "=r")
2342 (zero_extend:HI (match_operand:QI 1 "register_operand" "0"))
2343 (ashift:HI (match_operand:HI 2 "register_operand" "r")
2345 "REG_P (operands[0])
2346 && REG_P (operands[2])
2347 && REGNO (operands[0]) != REGNO (operands[2])"
2349 [(set_attr "cc" "clobber")
2350 (set_attr "length" "2")])
2353 [(set (match_operand:SI 0 "register_operand" "=r")
2355 (zero_extend:SI (match_operand:HI 1 "register_operand" "0"))
2356 (ashift:SI (match_operand:SI 2 "register_operand" "r")
2358 "(TARGET_H8300H || TARGET_H8300S)
2359 && REG_P (operands[0])
2360 && REG_P (operands[2])
2361 && (REGNO (operands[0]) != REGNO (operands[2]))"
2363 [(set_attr "cc" "clobber")
2364 (set_attr "length" "2")])