OSDN Git Service

f94778b9b79a899dcabe8d02ead8b5693a70f5a1
[pf3gnuchains/gcc-fork.git] / gcc / config / h8300 / h8300.md
1 ;; GCC machine description for Hitachi H8/300
2 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 ;; 2001, 2002 Free Software Foundation, Inc.
4
5 ;;   Contributed by Steve Chamberlain (sac@cygnus.com),
6 ;;   Jim Wilson (wilson@cygnus.com), and Doug Evans (dje@cygnus.com).
7
8 ;; This file is part of GNU CC.
9
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)
13 ;; any later version.
14
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.
19
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.
24
25 ;; Some of the extend instructions accept a general_operand_src, which
26 ;; allows all the normal memory addressing modes.  The length computations
27 ;; don't take this into account.  The lengths in the MD file should be
28 ;; "worst case" and then be adjusted to their correct values by
29 ;; h8300_adjust_insn_length.
30
31 ;; On the H8/300H and H8/S, adds/subs operate on the 32bit "er"
32 ;; registers.  Right now GCC doesn't expose the "e" half to the
33 ;; compiler, so using add/subs for addhi and subhi is safe.  Long
34 ;; term, we want to expose the "e" half to the compiler (gives us 8
35 ;; more 16bit registers).  At that point addhi and subhi can't use
36 ;; adds/subs.
37
38 ;; There's currently no way to have a insv/extzv expander for the H8/300H
39 ;; because word_mode is different for the H8/300 and H8/300H.
40
41 ;; Shifts/rotates by small constants should be handled by special
42 ;; patterns so we get the length and cc status correct.
43
44 ;; Bitfield operations no longer accept memory operands.  We need
45 ;; to add variants which operate on memory back to the MD.
46
47 ;; ??? Implement remaining bit ops available on the h8300
48
49 ;; ----------------------------------------------------------------------
50 ;; ATTRIBUTES
51 ;; ----------------------------------------------------------------------
52
53 (define_attr "cpu" "h8300,h8300h"
54   (const (symbol_ref "cpu_type")))
55
56 (define_attr "type" "branch,arith"
57   (const_string "arith"))
58
59 ;; The size of instructions in bytes.
60
61 (define_attr "length" ""
62   (cond [(eq_attr "type" "branch")
63          (if_then_else (and (ge (minus (pc) (match_dup 0))
64                                 (const_int -120))
65                             (le (minus (pc) (match_dup 0))
66                                 (const_int 120)))
67                        (const_int 2)
68                        (if_then_else (and (eq_attr "cpu" "h8300h")
69                                           (and (ge (minus (pc) (match_dup 0))
70                                                    (const_int -32000))
71                                                (le (minus (pc) (match_dup 0))
72                                                    (const_int 32000))))
73                                      (const_int 4)
74                                      (const_int 6)))]
75         (const_int 200)))
76
77 ;; The necessity of instruction length adjustment.
78
79 (define_attr "adjust_length" "yes,no"
80   (cond [(eq_attr "type" "branch") (const_string "no")]
81         (const_string "yes")))
82
83 ;; Condition code settings.
84 ;;
85 ;; none - insn does not affect cc
86 ;; none_0hit - insn does not affect cc but it does modify operand 0
87 ;;      This attribute is used to keep track of when operand 0 changes.
88 ;;      See the description of NOTICE_UPDATE_CC for more info.
89 ;; set_znv - insn sets z,n,v to usable values (like a tst insn); c is unknown.
90 ;; set_zn  - insn sets z,n to usable values; v,c are unknown.
91 ;; compare - compare instruction
92 ;; clobber - value of cc is unknown
93
94 (define_attr "cc" "none,none_0hit,set_znv,set_zn,compare,clobber"
95   (const_string "clobber"))
96 \f
97 ;; ----------------------------------------------------------------------
98 ;; MOVE INSTRUCTIONS
99 ;; ----------------------------------------------------------------------
100
101 ;; movqi
102
103 (define_insn "pushqi1_h8300"
104   [(parallel [(set (reg:HI 7)
105                    (plus:HI (reg:HI 7) (const_int -2)))
106               (set (mem:QI (plus:HI (reg:HI 7) (const_int -1)))
107                    (match_operand:QI 0 "register_operand" "r"))])]
108   "TARGET_H8300"
109   "mov.w\\t%T0,@-r7"
110   [(set_attr "length" "2")
111    (set_attr "cc" "clobber")])
112
113 (define_insn "pushqi1_h8300hs"
114   [(parallel [(set (reg:SI 7)
115                    (plus:SI (reg:SI 7) (const_int -4)))
116               (set (mem:QI (plus:SI (reg:SI 7) (const_int -3)))
117                    (match_operand:QI 0 "register_operand" "r"))])]
118   "TARGET_H8300H || TARGET_H8300S"
119   "mov.l\\t%S0,@-er7"
120   [(set_attr "length" "4")
121    (set_attr "cc" "clobber")])
122
123 (define_expand "pushqi1"
124   [(use (match_operand:QI 0 "register_operand" ""))]
125   ""
126   "
127 {
128   if (TARGET_H8300)
129     emit_insn (gen_pushqi1_h8300 (operands[0]));
130   else
131     emit_insn (gen_pushqi1_h8300hs (operands[0]));
132   DONE;
133 }")
134
135 (define_insn ""
136   [(set (match_operand:QI 0 "general_operand_dst" "=r,r ,<,r,r,m")
137         (match_operand:QI 1 "general_operand_src" " I,r>,r,n,m,r"))]
138   "TARGET_H8300
139    && (register_operand (operands[0], QImode)
140        || register_operand (operands[1], QImode))"
141   "@
142    sub.b        %X0,%X0
143    mov.b        %R1,%X0
144    mov.b        %X1,%R0
145    mov.b        %R1,%X0
146    mov.b        %R1,%X0
147    mov.b        %X1,%R0"
148   [(set_attr "length" "2,2,2,2,4,4")
149    (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
150
151 (define_insn ""
152   [(set (match_operand:QI 0 "general_operand_dst" "=r,r ,<,r,r,m")
153         (match_operand:QI 1 "general_operand_src" " I,r>,r,n,m,r"))]
154   "(TARGET_H8300H || TARGET_H8300S)
155    && (register_operand (operands[0], QImode)
156        || register_operand (operands[1], QImode))"
157   "@
158    sub.b        %X0,%X0
159    mov.b        %R1,%X0
160    mov.b        %X1,%R0
161    mov.b        %R1,%X0
162    mov.b        %R1,%X0
163    mov.b        %X1,%R0"
164   [(set_attr "length" "2,2,2,2,8,8")
165    (set_attr "cc" "set_zn,set_znv,set_znv,clobber,set_znv,set_znv")])
166
167 (define_expand "movqi"
168   [(set (match_operand:QI 0 "general_operand_dst" "")
169         (match_operand:QI 1 "general_operand_src" ""))]
170   ""
171   "
172 {
173   /* One of the ops has to be in a register.  */
174   if (!register_operand (operand0, QImode)
175       && !register_operand (operand1, QImode))
176     {
177       operands[1] = copy_to_mode_reg (QImode, operand1);
178     }
179 }")
180
181 (define_insn "movstrictqi"
182   [(set (strict_low_part (match_operand:QI 0 "general_operand_dst" "+r,r,r,r"))
183                          (match_operand:QI 1 "general_operand_src" "I,r,n,m"))]
184   ""
185   "@
186    sub.b        %X0,%X0
187    mov.b        %X1,%X0
188    mov.b        %R1,%X0
189    mov.b        %R1,%X0"
190   [(set_attr_alternative "length"
191      [(const_int 2) (const_int 2) (const_int 2)
192       (if_then_else (eq_attr "cpu" "h8300") (const_int 4) (const_int 8))])
193    (set_attr "cc" "set_zn,set_znv,set_znv,set_znv")])
194
195 ;; movhi
196
197 (define_expand "pushhi1_h8300"
198   [(set (mem:QI (pre_dec:HI (reg:HI 7)))
199         (match_operand:QI 0 "register_operand" ""))]
200   "TARGET_H8300"
201   "")
202
203 (define_insn "pushhi1_h8300hs"
204   [(parallel [(set (reg:SI 7)
205                    (plus:SI (reg:SI 7) (const_int -4)))
206               (set (mem:HI (plus:SI (reg:SI 7) (const_int -2)))
207                    (match_operand:HI 0 "register_operand" "r"))])]
208   "TARGET_H8300H || TARGET_H8300S"
209   "mov.l\\t%S0,@-er7"
210   [(set_attr "length" "4")
211    (set_attr "cc" "clobber")])
212
213 (define_expand "pushhi1"
214   [(use (match_operand:QI 0 "register_operand" ""))]
215   ""
216   "
217 {
218   if (TARGET_H8300)
219     emit_insn (gen_pushhi1_h8300 (operands[0]));
220   else
221     emit_insn (gen_pushhi1_h8300hs (operands[0]));
222   DONE;
223 }")
224
225 (define_insn ""
226   [(set (match_operand:HI 0 "general_operand_dst" "=r,r,<,r,r,m")
227         (match_operand:HI 1 "general_operand_src" "I,r>,r,i,m,r"))]
228   "TARGET_H8300
229    && (register_operand (operands[0], HImode)
230        || register_operand (operands[1], HImode))
231    && !(GET_CODE (operands[0]) == MEM
232         && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
233         && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
234         && GET_CODE (operands[1]) == REG
235         && REGNO (XEXP (XEXP (operands[0], 0), 0)) == REGNO (operands[1]))"
236   "@
237    sub.w        %T0,%T0
238    mov.w        %T1,%T0
239    mov.w        %T1,%T0
240    mov.w        %T1,%T0
241    mov.w        %T1,%T0
242    mov.w        %T1,%T0"
243   [(set_attr "length" "2,2,2,4,4,4")
244    (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
245
246 (define_insn ""
247   [(set (match_operand:HI 0 "general_operand_dst" "=r,r,<,r,r,m")
248         (match_operand:HI 1 "general_operand_src" "I,r>,r,i,m,r"))]
249   "(TARGET_H8300H || TARGET_H8300S)
250    && (register_operand (operands[0], HImode)
251        || register_operand (operands[1], HImode))"
252   "@
253    sub.w        %T0,%T0
254    mov.w        %T1,%T0
255    mov.w        %T1,%T0
256    mov.w        %T1,%T0
257    mov.w        %T1,%T0
258    mov.w        %T1,%T0"
259   [(set_attr "length" "2,2,2,4,8,8")
260    (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
261
262 (define_expand "movhi"
263   [(set (match_operand:HI 0 "general_operand_dst" "")
264         (match_operand:HI 1 "general_operand_src" ""))]
265   ""
266   "
267 {
268   /* One of the ops has to be in a register.  */
269   if (!register_operand (operand1, HImode)
270       && !register_operand (operand0, HImode))
271     {
272       operands[1] = copy_to_mode_reg (HImode, operand1);
273     }
274 }")
275
276 (define_insn "movstricthi"
277   [(set (strict_low_part (match_operand:HI 0 "general_operand_dst" "+r,r,r,r"))
278                          (match_operand:HI 1 "general_operand_src" "I,r,i,m"))]
279   ""
280   "@
281    sub.w        %T0,%T0
282    mov.w        %T1,%T0
283    mov.w        %T1,%T0
284    mov.w        %T1,%T0"
285   [(set_attr_alternative "length"
286      [(const_int 2) (const_int 2) (const_int 4)
287       (if_then_else (eq_attr "cpu" "h8300") (const_int 4) (const_int 8))])
288    (set_attr "cc" "set_zn,set_znv,set_znv,set_znv")])
289
290 ;; movsi
291
292 (define_expand "movsi"
293   [(set (match_operand:SI 0 "general_operand_dst" "")
294         (match_operand:SI 1 "general_operand_src" ""))]
295   ""
296   "
297 {
298   if (TARGET_H8300)
299     {
300       if (do_movsi (operands))
301         DONE;
302     }
303   else
304     {
305       /* One of the ops has to be in a register.  */
306       if (!register_operand (operand1, SImode)
307           && !register_operand (operand0, SImode))
308         {
309           operands[1] = copy_to_mode_reg (SImode, operand1);
310         }
311     }
312 }")
313
314 (define_expand "movsf"
315   [(set (match_operand:SF 0 "general_operand_dst" "")
316         (match_operand:SF 1 "general_operand_src" ""))]
317   ""
318   "
319 {
320   if (TARGET_H8300)
321     {
322       if (do_movsi (operands))
323         DONE;
324     }
325   else
326     {
327       /* One of the ops has to be in a register.  */
328       if (!register_operand (operand1, SFmode)
329           && !register_operand (operand0, SFmode))
330         {
331           operands[1] = copy_to_mode_reg (SFmode, operand1);
332         }
333     }
334 }")
335
336 (define_insn "movsi_h8300"
337   [(set (match_operand:SI 0 "general_operand_dst" "=r,r,r,o,<,r")
338         (match_operand:SI 1 "general_operand_src" "I,r,io,r,r,>"))]
339   "TARGET_H8300
340    && (register_operand (operands[0], SImode)
341        || register_operand (operands[1], SImode))"
342   "*
343 {
344   int rn = -1;
345   switch (which_alternative)
346     {
347     case 0:
348       return \"sub.w    %e0,%e0\;sub.w  %f0,%f0\";
349     case 1:
350       if (REGNO (operands[0]) < REGNO (operands[1]))
351         return \"mov.w  %e1,%e0\;mov.w  %f1,%f0\";
352       else
353         return \"mov.w  %f1,%f0\;mov.w  %e1,%e0\";
354     case 2:
355       /* Make sure we don't trample the register we index with.  */
356       if (GET_CODE (operands[1]) == MEM)
357         {
358           rtx inside = XEXP (operands[1], 0);
359           if (REG_P (inside))
360             {
361               rn = REGNO (inside);
362             }
363           else if (GET_CODE (inside) == PLUS)
364             {
365               rtx lhs = XEXP (inside, 0);
366               rtx rhs = XEXP (inside, 1);
367               if (REG_P (lhs)) rn = REGNO (lhs);
368               if (REG_P (rhs)) rn = REGNO (rhs);
369             }
370         }
371       if (rn == REGNO (operands[0]))
372         {
373           /* Move the second word first.  */
374           return \"mov.w        %f1,%f0\;mov.w  %e1,%e0\";
375         }
376       else
377         {
378           /* See if either half is zero.  If so, use sub.w to clear
379              that half.  */
380           if (GET_CODE (operands[1]) == CONST_INT)
381             {
382               if ((INTVAL (operands[1]) & 0xffff) == 0)
383                 return \"mov.w  %e1,%e0\;sub.w  %f0,%f0\";
384               if (((INTVAL (operands[1]) >> 16) & 0xffff) == 0)
385                 return \"sub.w  %e0,%e0\;mov.w  %f1,%f0\";
386             }
387           return \"mov.w        %e1,%e0\;mov.w  %f1,%f0\";
388         }
389     case 3:
390       return \"mov.w    %e1,%e0\;mov.w  %f1,%f0\";
391     case 4:
392       return \"mov.w    %f1,%T0\;mov.w  %e1,%T0\";
393     case 5:
394       return \"mov.w    %T1,%e0\;mov.w  %T1,%f0\";
395     default:
396       abort();
397     }
398 }"
399   [(set_attr "length" "4,4,8,8,4,4")
400    (set_attr "cc" "clobber")])
401
402 (define_insn "movsf_h8300"
403   [(set (match_operand:SF 0 "general_operand_dst" "=r,r,r,o,<,r")
404         (match_operand:SF 1 "general_operand_src" "I,r,io,r,r,>"))]
405   "TARGET_H8300
406    && (register_operand (operands[0], SFmode)
407        || register_operand (operands[1], SFmode))"
408   "*
409 {
410   /* Copy of the movsi stuff.  */
411   int rn = -1;
412   switch (which_alternative)
413     {
414     case 0:
415       return \"sub.w    %e0,%e0\;sub.w  %f0,%f0\";
416     case 1:
417       if (REGNO (operands[0]) < REGNO (operands[1]))
418         return \"mov.w  %e1,%e0\;mov.w  %f1,%f0\";
419       else
420         return \"mov.w  %f1,%f0\;mov.w  %e1,%e0\";
421     case 2:
422       /* Make sure we don't trample the register we index with.  */
423       if (GET_CODE (operands[1]) == MEM)
424         {
425           rtx inside = XEXP (operands[1], 0);
426           if (REG_P (inside))
427             {
428               rn = REGNO (inside);
429             }
430           else if (GET_CODE (inside) == PLUS)
431             {
432               rtx lhs = XEXP (inside, 0);
433               rtx rhs = XEXP (inside, 1);
434               if (REG_P (lhs)) rn = REGNO (lhs);
435               if (REG_P (rhs)) rn = REGNO (rhs);
436             }
437         }
438       if (rn == REGNO (operands[0]))
439         /* Move the second word first.  */
440         return \"mov.w  %f1,%f0\;mov.w  %e1,%e0\";
441       else
442         /* Move the first word first.  */
443         return \"mov.w  %e1,%e0\;mov.w  %f1,%f0\";
444
445     case 3:
446       return \"mov.w    %e1,%e0\;mov.w  %f1,%f0\";
447     case 4:
448       return \"mov.w    %f1,%T0\;mov.w  %e1,%T0\";
449     case 5:
450       return \"mov.w    %T1,%e0\;mov.w  %T1,%f0\";
451     default:
452       abort();
453     }
454 }"
455   [(set_attr "length" "4,4,8,8,4,4")
456    (set_attr "cc" "clobber")])
457
458 (define_insn "movsi_h8300hs"
459   [(set (match_operand:SI 0 "general_operand_dst" "=r,r,r,r,m,<,r,*a,*a,r")
460         (match_operand:SI 1 "general_operand_src" "I,r,i,m,r,r,>,I,r,*a"))]
461   "(TARGET_H8300S || TARGET_H8300H)
462    && (register_operand (operands[0], SImode)
463        || register_operand (operands[1], SImode))
464    && !(GET_CODE (operands[0]) == MEM
465         && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
466         && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
467         && GET_CODE (operands[1]) == REG
468         && REGNO (XEXP (XEXP (operands[0], 0), 0)) == REGNO (operands[1]))"
469   "*
470 {
471   switch (which_alternative)
472     {
473     case 0:
474       return \"sub.l    %S0,%S0\";
475     case 7:
476       return \"clrmac\";
477     case 8:
478       return \"clrmac\;ldmac %1,macl\";
479     case 9:
480       return \"stmac    macl,%0\";
481     default:
482       if (GET_CODE (operands[1]) == CONST_INT)
483         {
484           int val = INTVAL (operands[1]);
485
486           /* Look for constants which can be made by adding an 8-bit
487              number to zero in one of the two low bytes.  */
488           if (val == (val & 0xff))
489             {
490               operands[1] = GEN_INT ((char) val & 0xff);
491               return \"sub.l\\t%S0,%S0\;add.b\\t%1,%w0\";
492             }
493
494           if (val == (val & 0xff00))
495             {
496               operands[1] = GEN_INT ((char) (val >> 8) & 0xff);
497               return \"sub.l\\t%S0,%S0\;add.b\\t%1,%x0\";
498             }
499
500           /* Look for constants that can be obtained by subs, inc, and
501              dec to 0.  */
502           switch (val & 0xffffffff)
503             {
504             case 0xffffffff:
505               return \"sub.l\\t%S0,%S0\;subs\\t#1,%S0\";
506             case 0xfffffffe:
507               return \"sub.l\\t%S0,%S0\;subs\\t#2,%S0\";
508             case 0xfffffffc:
509               return \"sub.l\\t%S0,%S0\;subs\\t#4,%S0\";
510
511             case 0x0000ffff:
512               return \"sub.l\\t%S0,%S0\;dec.w\\t#1,%f0\";
513             case 0x0000fffe:
514               return \"sub.l\\t%S0,%S0\;dec.w\\t#2,%f0\";
515
516             case 0xffff0000:
517               return \"sub.l\\t%S0,%S0\;dec.w\\t#1,%e0\";
518             case 0xfffe0000:
519               return \"sub.l\\t%S0,%S0\;dec.w\\t#2,%e0\";
520
521             case 0x00010000:
522               return \"sub.l\\t%S0,%S0\;inc.w\\t#1,%e0\";
523             case 0x00020000:
524               return \"sub.l\\t%S0,%S0\;inc.w\\t#2,%e0\";
525             }
526         }
527     }
528    return \"mov.l       %S1,%S0\";
529 }"
530   [(set_attr "length" "2,2,10,10,10,4,4,2,6,4")
531    (set_attr "cc" "set_zn,set_znv,clobber,set_znv,set_znv,set_znv,set_znv,none_0hit,none_0hit,set_znv")])
532
533 (define_insn "movsf_h8300h"
534   [(set (match_operand:SF 0 "general_operand_dst" "=r,r,r,m,<,r")
535         (match_operand:SF 1 "general_operand_src" "I,r,im,r,r,>"))]
536   "(TARGET_H8300H || TARGET_H8300S)
537    && (register_operand (operands[0], SFmode)
538        || register_operand (operands[1], SFmode))"
539   "@
540    sub.l        %S0,%S0
541    mov.l        %S1,%S0
542    mov.l        %S1,%S0
543    mov.l        %S1,%S0
544    mov.l        %S1,%S0
545    mov.l        %S1,%S0"
546   [(set_attr "length" "2,2,10,10,4,4")
547    (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
548 \f
549 ;; ----------------------------------------------------------------------
550 ;; TEST INSTRUCTIONS
551 ;; ----------------------------------------------------------------------
552
553 (define_insn ""
554   [(set (cc0) (zero_extract:HI (match_operand:QI 0 "bit_memory_operand" "r,U")
555                                (const_int 1)
556                                (match_operand 1 "const_int_operand" "n,n")))]
557   "TARGET_H8300"
558   "btst %Z1,%Y0"
559   [(set_attr "length" "2,4")
560    (set_attr "cc" "set_zn,set_zn")])
561
562 (define_insn ""
563   [(set (cc0) (zero_extract:HI (match_operand:HI 0 "register_operand" "r")
564                                (const_int 1)
565                                (match_operand 1 "const_int_operand" "n")))]
566   "TARGET_H8300"
567   "btst %Z1,%Y0"
568   [(set_attr "length" "2")
569    (set_attr "cc" "set_zn")])
570
571 (define_insn ""
572   [(set (cc0) (zero_extract:SI (match_operand:QI 0 "bit_memory_operand" "r,U")
573                                (const_int 1)
574                                (match_operand 1 "const_int_operand" "n,n")))]
575   "TARGET_H8300H || TARGET_H8300S"
576   "btst %Z1,%Y0"
577   [(set_attr "length" "2,8")
578    (set_attr "cc" "set_zn,set_zn")])
579
580 (define_insn ""
581   [(set (cc0) (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
582                                (const_int 1)
583                                (match_operand 1 "const_int_operand" "n")))]
584   "(TARGET_H8300H || TARGET_H8300S)
585    && INTVAL (operands[1]) <= 15"
586   "btst %Z1,%Y0"
587   [(set_attr "length" "2")
588    (set_attr "cc" "set_zn")])
589
590 (define_insn "tstqi"
591   [(set (cc0) (match_operand:QI 0 "register_operand" "r"))]
592   ""
593   "mov.b        %X0,%X0"
594   [(set_attr "length" "2")
595    (set_attr "cc" "set_znv")])
596
597 (define_insn "tsthi"
598   [(set (cc0) (match_operand:HI 0 "register_operand" "r"))]
599   ""
600   "mov.w        %T0,%T0"
601   [(set_attr "length" "2")
602    (set_attr "cc" "set_znv")])
603
604 (define_insn "tstsi"
605   [(set (cc0) (match_operand:SI 0 "register_operand" "r"))]
606   "TARGET_H8300H || TARGET_H8300S"
607   "mov.l        %S0,%S0"
608   [(set_attr "length" "2")
609    (set_attr "cc" "set_znv")])
610
611 (define_insn "cmpqi"
612   [(set (cc0)
613         (compare:QI (match_operand:QI 0 "register_operand" "r")
614                     (match_operand:QI 1 "nonmemory_operand" "rn")))]
615   ""
616   "cmp.b        %X1,%X0"
617   [(set_attr "length" "2")
618    (set_attr "cc" "compare")])
619
620 (define_expand "cmphi"
621   [(set (cc0)
622         (compare:HI (match_operand:HI 0 "register_operand" "")
623                     (match_operand:HI 1 "nonmemory_operand" "")))]
624   ""
625   "
626 {
627   /* Force operand1 into a register if we're compiling
628      for the H8/300.  */
629   if (GET_CODE (operands[1]) != REG && TARGET_H8300)
630     operands[1] = force_reg (HImode, operands[1]);
631 }")
632
633 (define_insn ""
634   [(set (cc0)
635         (compare:HI (match_operand:HI 0 "register_operand" "r")
636                     (match_operand:HI 1 "register_operand" "r")))]
637   "TARGET_H8300"
638   "cmp.w        %T1,%T0"
639   [(set_attr "length" "2")
640    (set_attr "cc" "compare")])
641
642 (define_insn ""
643   [(set (cc0)
644         (compare:HI (match_operand:HI 0 "register_operand" "r,r")
645                     (match_operand:HI 1 "nonmemory_operand" "r,n")))]
646   "TARGET_H8300H || TARGET_H8300S"
647   "cmp.w        %T1,%T0"
648   [(set_attr "length" "2,4")
649    (set_attr "cc" "compare,compare")])
650
651 (define_insn "cmpsi"
652   [(set (cc0)
653         (compare:SI (match_operand:SI 0 "register_operand" "r,r")
654                     (match_operand:SI 1 "nonmemory_operand" "r,i")))]
655   "TARGET_H8300H || TARGET_H8300S"
656   "cmp.l        %S1,%S0"
657   [(set_attr "length" "2,6")
658    (set_attr "cc" "compare,compare")])
659 \f
660 ;; ----------------------------------------------------------------------
661 ;; ADD INSTRUCTIONS
662 ;; ----------------------------------------------------------------------
663
664 (define_insn "addqi3"
665   [(set (match_operand:QI 0 "register_operand" "=r")
666         (plus:QI (match_operand:QI 1 "register_operand" "%0")
667                  (match_operand:QI 2 "nonmemory_operand" "rn")))]
668   ""
669   "add.b        %X2,%X0"
670   [(set_attr "length" "2")
671    (set_attr "cc" "set_zn")])
672
673 (define_expand "addhi3"
674   [(set (match_operand:HI 0 "register_operand" "")
675         (plus:HI (match_operand:HI 1 "register_operand" "")
676                  (match_operand:HI 2 "nonmemory_operand" "")))]
677   ""
678   "")
679
680 (define_insn ""
681   [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,&r")
682         (plus:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,g")
683                  (match_operand:HI 2 "nonmemory_operand" "L,N,n,r,r")))]
684   "TARGET_H8300"
685   "@
686    adds %2,%T0
687    subs %G2,%T0
688    add.b        %s2,%s0\;addx   %t2,%t0
689    add.w        %T2,%T0
690    mov.w        %T1,%T0\;add.w  %T2,%T0"
691   [(set_attr "length" "2,2,4,2,6")
692    (set_attr "cc" "none_0hit,none_0hit,clobber,set_zn,set_zn")])
693
694 (define_insn ""
695   [(set (match_operand:HI 0 "register_operand" "=r,r,r,r")
696         (plus:HI (match_operand:HI 1 "register_operand" "%0,0,0,0")
697                  (match_operand:HI 2 "nonmemory_operand" "L,N,n,r")))]
698   "TARGET_H8300H || TARGET_H8300S"
699   "@
700    adds %2,%S0
701    subs %G2,%S0
702    add.w        %T2,%T0
703    add.w        %T2,%T0"
704   [(set_attr "length" "2,2,4,2")
705    (set_attr "cc" "none_0hit,none_0hit,set_zn,set_zn")])
706
707 (define_split
708   [(set (match_operand:HI 0 "register_operand" "")
709         (plus:HI (match_dup 0)
710                  (match_operand:HI 1 "two_insn_adds_subs_operand" "")))]
711   ""
712   [(const_int 0)]
713   "split_adds_subs (HImode, operands); DONE;")
714
715 (define_expand "addsi3"
716   [(set (match_operand:SI 0 "register_operand" "")
717         (plus:SI (match_operand:SI 1 "register_operand" "")
718                  (match_operand:SI 2 "nonmemory_operand" "")))]
719   ""
720   "")
721
722 (define_insn "addsi_h8300"
723   [(set (match_operand:SI 0 "register_operand" "=r,r,&r")
724         (plus:SI (match_operand:SI 1 "register_operand" "%0,0,r")
725                  (match_operand:SI 2 "nonmemory_operand" "n,r,r")))]
726   "TARGET_H8300"
727   "@
728    add  %w2,%w0\;addx   %x2,%x0\;addx   %y2,%y0\;addx   %z2,%z0
729    add.w        %f2,%f0\;addx   %y2,%y0\;addx   %z2,%z0
730    mov.w        %f1,%f0\;mov.w  %e1,%e0\;add.w  %f2,%f0\;addx   %y2,%y0\;addx   %z2,%z0"
731   [(set_attr "length" "8,6,10")
732    (set_attr "cc" "clobber")])
733
734 (define_insn "addsi_h8300h"
735   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
736         (plus:SI (match_operand:SI 1 "register_operand" "%0,0,0,0")
737                  (match_operand:SI 2 "nonmemory_operand" "L,N,i,r")))]
738   "TARGET_H8300H || TARGET_H8300S"
739   "@
740    adds %2,%S0
741    subs %G2,%S0
742    add.l        %S2,%S0
743    add.l        %S2,%S0"
744   [(set_attr "length" "2,2,6,2")
745    (set_attr "cc" "none_0hit,none_0hit,set_zn,set_zn")])
746
747 (define_split
748   [(set (match_operand:SI 0 "register_operand" "")
749         (plus:SI (match_dup 0)
750                  (match_operand:SI 1 "two_insn_adds_subs_operand" "")))]
751   "TARGET_H8300H || TARGET_H8300S"
752   [(const_int 0)]
753   "split_adds_subs (SImode, operands); DONE;")
754
755 ;; ----------------------------------------------------------------------
756 ;; SUBTRACT INSTRUCTIONS
757 ;; ----------------------------------------------------------------------
758
759 (define_insn "subqi3"
760   [(set (match_operand:QI 0 "register_operand" "=r,r")
761         (minus:QI (match_operand:QI 1 "register_operand" "0,0")
762                   (match_operand:QI 2 "nonmemory_operand" "r,n")))]
763   ""
764   "@
765    sub.b        %X2,%X0
766    add.b        %G2,%X0"
767   [(set_attr "length" "2")
768    (set_attr "cc" "set_zn")])
769
770 (define_expand "subhi3"
771   [(set (match_operand:HI 0 "register_operand" "")
772         (minus:HI (match_operand:HI 1 "general_operand" "")
773                   (match_operand:HI 2 "nonmemory_operand" "")))]
774   ""
775   "")
776
777 (define_insn ""
778   [(set (match_operand:HI 0 "register_operand" "=r,&r")
779         (minus:HI (match_operand:HI 1 "general_operand" "0,0")
780                   (match_operand:HI 2 "nonmemory_operand" "r,n")))]
781   "TARGET_H8300"
782   "@
783    sub.w        %T2,%T0
784    add.b        %E2,%s0\;addx   %F2,%t0"
785   [(set_attr "length" "2,4")
786    (set_attr "cc" "set_zn,clobber")])
787
788 (define_insn ""
789   [(set (match_operand:HI 0 "register_operand" "=r,&r")
790         (minus:HI (match_operand:HI 1 "general_operand" "0,0")
791                   (match_operand:HI 2 "nonmemory_operand" "r,n")))]
792   "TARGET_H8300H || TARGET_H8300S"
793   "@
794    sub.w        %T2,%T0
795    sub.w        %T2,%T0"
796   [(set_attr "length" "2,4")
797    (set_attr "cc" "set_zn,set_zn")])
798
799 (define_expand "subsi3"
800   [(set (match_operand:SI 0 "register_operand" "")
801         (minus:SI (match_operand:SI 1 "register_operand" "")
802                   (match_operand:SI 2 "nonmemory_operand" "")))]
803   ""
804   "")
805
806 (define_insn "subsi3_h8300"
807   [(set (match_operand:SI 0 "register_operand" "=r")
808         (minus:SI (match_operand:SI 1 "register_operand" "0")
809                   (match_operand:SI 2 "register_operand" "r")))]
810   "TARGET_H8300"
811   "sub.w        %f2,%f0\;subx   %y2,%y0\;subx   %z2,%z0"
812   [(set_attr "length" "6")
813    (set_attr "cc" "clobber")])
814
815 (define_insn "subsi3_h8300h"
816   [(set (match_operand:SI 0 "register_operand" "=r,r")
817         (minus:SI (match_operand:SI 1 "general_operand" "0,0")
818                   (match_operand:SI 2 "nonmemory_operand" "r,i")))]
819   "TARGET_H8300H || TARGET_H8300S"
820   "@
821    sub.l        %S2,%S0
822    sub.l        %S2,%S0"
823   [(set_attr "length" "2,6")
824    (set_attr "cc" "set_zn,set_zn")])
825 \f
826 ;; ----------------------------------------------------------------------
827 ;; MULTIPLY INSTRUCTIONS
828 ;; ----------------------------------------------------------------------
829
830 ;; Note that the H8/300 can only handle umulqihi3.
831
832 (define_insn "mulqihi3"
833   [(set (match_operand:HI 0 "register_operand" "=r")
834         (mult:HI (sign_extend:HI (match_operand:QI 1 "general_operand" "%0"))
835                  (sign_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
836   "TARGET_H8300H || TARGET_H8300S"
837   "mulxs.b      %X2,%T0"
838   [(set_attr "length" "4")
839    (set_attr "cc" "set_zn")])
840
841 (define_insn "mulhisi3"
842   [(set (match_operand:SI 0 "register_operand" "=r")
843         (mult:SI (sign_extend:SI (match_operand:HI 1 "general_operand" "%0"))
844                  (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
845   "TARGET_H8300H || TARGET_H8300S"
846   "mulxs.w      %T2,%S0"
847   [(set_attr "length" "4")
848    (set_attr "cc" "set_zn")])
849
850 (define_insn "umulqihi3"
851   [(set (match_operand:HI 0 "register_operand" "=r")
852         (mult:HI (zero_extend:HI (match_operand:QI 1 "general_operand" "%0"))
853                  (zero_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
854   ""
855   "mulxu        %X2,%T0"
856   [(set_attr "length" "2")
857    (set_attr "cc" "none_0hit")])
858
859 (define_insn "umulhisi3"
860   [(set (match_operand:SI 0 "register_operand" "=r")
861         (mult:SI (zero_extend:SI (match_operand:HI 1 "general_operand" "%0"))
862                  (zero_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
863   "TARGET_H8300H || TARGET_H8300S"
864   "mulxu.w      %T2,%S0"
865   [(set_attr "length" "2")
866    (set_attr "cc" "none_0hit")])
867
868 ;; This is a "bridge" instruction.  Combine can't cram enough insns
869 ;; together to crate a MAC instruction directly, but it can create
870 ;; this instruction, which then allows combine to create the real
871 ;; MAC insn.
872 ;;
873 ;; Unfortunately, if combine doesn't create a MAC instruction, this
874 ;; insn must generate reasonably correct code.  Egad.
875 (define_insn ""
876   [(set (match_operand:SI 0 "register_operand" "=a")
877         (mult:SI
878           (sign_extend:SI
879             (mem:HI (post_inc:SI (match_operand:SI 1 "register_operand" "r"))))
880           (sign_extend:SI
881             (mem:HI (post_inc:SI (match_operand:SI 2 "register_operand" "r"))))))]
882   "TARGET_MAC"
883   "clrmac\;mac  @%2+,@%1+"
884   [(set_attr "length" "6")
885    (set_attr "cc" "none_0hit")])
886
887 (define_insn ""
888   [(set (match_operand:SI 0 "register_operand" "=a")
889         (plus:SI (mult:SI
890           (sign_extend:SI (mem:HI
891             (post_inc:SI (match_operand:SI 1 "register_operand" "r"))))
892           (sign_extend:SI (mem:HI
893             (post_inc:SI (match_operand:SI 2 "register_operand" "r")))))
894               (match_operand:SI 3 "register_operand" "0")))]
895   "TARGET_MAC"
896   "mac  @%2+,@%1+"
897   [(set_attr "length" "4")
898    (set_attr "cc" "none_0hit")])
899
900 ;; ----------------------------------------------------------------------
901 ;; DIVIDE/MOD INSTRUCTIONS
902 ;; ----------------------------------------------------------------------
903
904 (define_insn "udivmodqi4"
905   [(set (match_operand:QI 0 "register_operand" "=r")
906         (truncate:QI
907           (udiv:HI
908             (match_operand:HI 1 "general_operand" "0")
909             (zero_extend:HI (match_operand:QI 2 "register_operand" "r")))))
910    (set (match_operand:QI 3 "register_operand" "=r")
911         (truncate:QI
912           (umod:HI
913             (match_dup 1)
914             (zero_extend:HI (match_dup 2)))))]
915   "TARGET_H8300H || TARGET_H8300S"
916   "*
917 {
918   if (find_reg_note (insn, REG_UNUSED, operands[3]))
919     return \"divxu.b\\t%X2,%T0\";
920   else
921     return \"divxu.b\\t%X2,%T0\;mov.b\\t%t0,%s3\";
922 }"
923   [(set_attr "length" "4")
924    (set_attr "cc" "clobber")])
925
926 (define_insn "divmodqi4"
927   [(set (match_operand:QI 0 "register_operand" "=r")
928         (truncate:QI
929           (div:HI
930             (match_operand:HI 1 "general_operand" "0")
931             (sign_extend:HI (match_operand:QI 2 "register_operand" "r")))))
932    (set (match_operand:QI 3 "register_operand" "=r")
933         (truncate:QI
934           (mod:HI
935             (match_dup 1)
936             (sign_extend:HI (match_dup 2)))))]
937   "TARGET_H8300H || TARGET_H8300S"
938   "*
939 {
940   if (find_reg_note (insn, REG_UNUSED, operands[3]))
941     return \"divxs.b\\t%X2,%T0\";
942   else
943     return \"divxs.b\\t%X2,%T0\;mov.b\\t%t0,%s3\";
944 }"
945   [(set_attr "length" "6")
946    (set_attr "cc" "clobber")])
947
948 (define_insn "udivmodhi4"
949   [(set (match_operand:HI 0 "register_operand" "=r")
950         (truncate:HI
951           (udiv:SI
952             (match_operand:SI 1 "general_operand" "0")
953             (zero_extend:SI (match_operand:HI 2 "register_operand" "r")))))
954    (set (match_operand:HI 3 "register_operand" "=r")
955         (truncate:HI
956           (umod:SI
957             (match_dup 1)
958             (zero_extend:SI (match_dup 2)))))]
959   "TARGET_H8300H || TARGET_H8300S"
960   "*
961 {
962   if (find_reg_note (insn, REG_UNUSED, operands[3]))
963     return \"divxu.w\\t%T2,%S0\";
964   else
965     return \"divxu.w\\t%T2,%S0\;mov.w\\t%e0,%f3\";
966 }"
967   [(set_attr "length" "4")
968    (set_attr "cc" "clobber")])
969
970 (define_insn "divmodhi4"
971   [(set (match_operand:HI 0 "register_operand" "=r")
972         (truncate:HI
973           (div:SI
974             (match_operand:SI 1 "general_operand" "0")
975             (sign_extend:SI (match_operand:HI 2 "register_operand" "r")))))
976    (set (match_operand:HI 3 "register_operand" "=r")
977         (truncate:HI
978           (mod:SI
979             (match_dup 1)
980             (sign_extend:SI (match_dup 2)))))]
981   "TARGET_H8300H || TARGET_H8300S"
982   "*
983 {
984   if (find_reg_note (insn, REG_UNUSED, operands[3]))
985     return \"divxs.w\\t%T2,%S0\";
986   else
987     return \"divxs.w\\t%T2,%S0\;mov.w\\t%e0,%f3\";
988 }"
989   [(set_attr "length" "6")
990    (set_attr "cc" "clobber")])
991 \f
992 ;; ----------------------------------------------------------------------
993 ;; AND INSTRUCTIONS
994 ;; ----------------------------------------------------------------------
995
996 (define_insn ""
997   [(set (match_operand:QI 0 "bit_operand" "=r,U")
998         (and:QI (match_operand:QI 1 "bit_operand" "%0,0")
999                 (match_operand:QI 2 "nonmemory_operand" "rn,O")))]
1000   "register_operand (operands[0], QImode) || o_operand (operands[2], QImode)"
1001   "@
1002    and  %X2,%X0
1003    bclr %W2,%R0"
1004   [(set_attr "length" "2,8")
1005    (set_attr "adjust_length" "no")
1006    (set_attr "cc" "set_znv,none_0hit")])
1007
1008 (define_expand "andqi3"
1009   [(set (match_operand:QI 0 "bit_operand" "")
1010         (and:QI (match_operand:QI 1 "bit_operand" "")
1011                 (match_operand:QI 2 "nonmemory_operand" "")))]
1012   ""
1013   "
1014 {
1015   if (fix_bit_operand (operands, 'O', AND))
1016     DONE;
1017 }")
1018
1019 (define_expand "andhi3"
1020   [(set (match_operand:HI 0 "register_operand" "")
1021         (and:HI (match_operand:HI 1 "register_operand" "")
1022                 (match_operand:HI 2 "nonmemory_operand" "")))]
1023   ""
1024   "")
1025
1026 (define_insn ""
1027   [(set (match_operand:HI 0 "register_operand" "=r")
1028         (and:HI (match_operand:HI 1 "register_operand" "%0")
1029                 (match_operand:HI 2 "nonmemory_operand" "rn")))]
1030   "TARGET_H8300"
1031   "* return output_logical_op (HImode, AND, operands);"
1032   [(set_attr "length" "4")
1033    (set_attr "cc" "clobber")])
1034
1035 (define_insn ""
1036   [(set (match_operand:HI 0 "register_operand" "=r,r")
1037         (and:HI (match_operand:HI 1 "register_operand" "%0,0")
1038                 (match_operand:HI 2 "nonmemory_operand" "r,n")))]
1039   "TARGET_H8300H || TARGET_H8300S"
1040   "* return output_logical_op (HImode, AND, operands);"
1041   [(set_attr "length" "2,4")
1042    (set_attr "cc" "set_znv,clobber")])
1043
1044 (define_insn "*andorhi3"
1045   [(set (match_operand:HI 0 "register_operand" "=r")
1046         (ior:HI (and:HI (match_operand:HI 2 "register_operand" "r")
1047                         (match_operand:HI 3 "const_int_operand" "n"))
1048         (match_operand:HI 1 "register_operand" "0")))]
1049   "exact_log2 (INTVAL (operands[3]) & 0xffff) != -1"
1050   "*
1051 {
1052   operands[3] = GEN_INT (INTVAL (operands[3]) & 0xffff);
1053   if (INTVAL (operands[3]) > 128)
1054     {
1055       operands[3] = GEN_INT (INTVAL (operands[3]) >> 8);
1056       return \"bld\\t%V3,%t2\;bst\\t%V3,%t0\";
1057     }
1058   return \"bld\\t%V3,%s2\;bst\\t%V3,%s0\";
1059 }"
1060   [(set_attr "length" "4")
1061    (set_attr "cc" "clobber")])
1062
1063 (define_expand "andsi3"
1064   [(set (match_operand:SI 0 "register_operand" "")
1065         (and:SI (match_operand:SI 1 "register_operand" "")
1066                 (match_operand:SI 2 "nonmemory_operand" "")))]
1067   ""
1068   "")
1069
1070 (define_insn ""
1071   [(set (match_operand:SI 0 "register_operand" "=r")
1072         (and:SI (match_operand:SI 1 "register_operand" "%0")
1073                 (match_operand:SI 2 "nonmemory_operand" "rn")))]
1074   "TARGET_H8300"
1075   "* return output_logical_op (SImode, AND, operands);"
1076   [(set_attr "length" "8")
1077    (set_attr "cc" "clobber")])
1078
1079 (define_insn ""
1080   [(set (match_operand:SI 0 "register_operand" "=r,r")
1081         (and:SI (match_operand:SI 1 "register_operand" "%0,0")
1082                 (match_operand:SI 2 "nonmemory_operand" "r,n")))]
1083   "TARGET_H8300H || TARGET_H8300S"
1084   "* return output_logical_op (SImode, AND, operands);"
1085   [(set_attr "length" "4,6")
1086    (set_attr "cc" "set_znv,clobber")])
1087
1088 ;; ----------------------------------------------------------------------
1089 ;; OR INSTRUCTIONS
1090 ;; ----------------------------------------------------------------------
1091
1092 (define_insn ""
1093   [(set (match_operand:QI 0 "bit_operand" "=r,U")
1094         (ior:QI (match_operand:QI 1 "bit_operand" "%0,0")
1095                 (match_operand:QI 2 "nonmemory_operand" "rn,n")))]
1096   "register_operand (operands[0], QImode)
1097    || (GET_CODE (operands[2]) == CONST_INT
1098        && exact_log2 (INTVAL (operands[2]) & 0xff) != -1)"
1099   "*
1100 {
1101   switch (which_alternative)
1102     {
1103     case 0:
1104       return \"or\t%X2,%X0\";
1105     case 1:
1106       operands[2] = GEN_INT (INTVAL (operands[2]) & 0xff);
1107       return \"bset\t%V2,%R0\";
1108     default:
1109       abort ();
1110     }
1111 }"
1112   [(set_attr "length" "2,8")
1113    (set_attr "adjust_length" "no")
1114    (set_attr "cc" "set_znv,none_0hit")])
1115
1116 (define_expand "iorqi3"
1117   [(set (match_operand:QI 0 "bit_operand" "")
1118         (ior:QI (match_operand:QI 1 "bit_operand" "")
1119                 (match_operand:QI 2 "nonmemory_operand" "")))]
1120   ""
1121   "
1122 {
1123   if (fix_bit_operand (operands, 'P', IOR))
1124     DONE;
1125 }")
1126
1127 (define_expand "iorhi3"
1128   [(set (match_operand:HI 0 "general_operand" "")
1129         (ior:HI (match_operand:HI 1 "general_operand" "")
1130                 (match_operand:HI 2 "general_operand" "")))]
1131   ""
1132   "")
1133
1134 (define_insn ""
1135   [(set (match_operand:HI 0 "general_operand" "=r,r")
1136         (ior:HI (match_operand:HI 1 "general_operand" "%0,0")
1137                 (match_operand:HI 2 "general_operand" "J,rn")))]
1138   "TARGET_H8300"
1139   "* return output_logical_op (HImode, IOR, operands);"
1140   [(set_attr "length" "2,4")
1141    (set_attr "cc" "clobber,clobber")])
1142
1143 (define_insn ""
1144   [(set (match_operand:HI 0 "general_operand" "=r,r,r")
1145         (ior:HI (match_operand:HI 1 "general_operand" "%0,0,0")
1146                 (match_operand:HI 2 "general_operand" "J,r,n")))]
1147   "TARGET_H8300H || TARGET_H8300S"
1148   "* return output_logical_op (HImode, IOR, operands);"
1149   [(set_attr "length" "2,2,4")
1150    (set_attr "cc" "clobber,set_znv,clobber")])
1151
1152 (define_expand "iorsi3"
1153   [(set (match_operand:SI 0 "register_operand" "")
1154         (ior:SI (match_operand:SI 1 "register_operand" "")
1155                 (match_operand:SI 2 "nonmemory_operand" "")))]
1156   ""
1157   "")
1158
1159 (define_insn ""
1160   [(set (match_operand:SI 0 "register_operand" "=r,r")
1161         (ior:SI (match_operand:SI 1 "register_operand" "%0,0")
1162                 (match_operand:SI 2 "nonmemory_operand" "J,rn")))]
1163   "TARGET_H8300"
1164   "* return output_logical_op (SImode, IOR, operands);"
1165   [(set_attr "length" "2,8")
1166    (set_attr "cc" "clobber,clobber")])
1167
1168 (define_insn ""
1169   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1170         (ior:SI (match_operand:SI 1 "register_operand" "%0,0,0")
1171                 (match_operand:SI 2 "nonmemory_operand" "J,r,n")))]
1172   "TARGET_H8300H || TARGET_H8300S"
1173   "* return output_logical_op (SImode, IOR, operands);"
1174   [(set_attr "length" "2,4,6")
1175    (set_attr "cc" "clobber,set_znv,clobber")])
1176
1177 ;; ----------------------------------------------------------------------
1178 ;; XOR INSTRUCTIONS
1179 ;; ----------------------------------------------------------------------
1180
1181 (define_insn ""
1182   [(set (match_operand:QI 0 "bit_operand" "=r,U")
1183         (xor:QI (match_operand:QI 1 "bit_operand" "%0,0")
1184                 (match_operand:QI 2 "nonmemory_operand" "rn,n")))]
1185   "register_operand (operands[0], QImode)
1186    || (GET_CODE (operands[2]) == CONST_INT
1187        && exact_log2 (INTVAL (operands[2]) & 0xff) != -1)"
1188   "*
1189 {
1190   switch (which_alternative)
1191     {
1192     case 0:
1193       return \"xor\t%X2,%X0\";
1194     case 1:
1195       operands[2] = GEN_INT (INTVAL (operands[2]) & 0xff);
1196       return \"bnot\t%V2,%R0\";
1197     default:
1198       abort ();
1199     }
1200 }"
1201   [(set_attr "length" "2,8")
1202    (set_attr "adjust_length" "no")
1203    (set_attr "cc" "set_znv,none_0hit")])
1204
1205 (define_expand "xorqi3"
1206   [(set (match_operand:QI 0 "bit_operand" "")
1207         (xor:QI (match_operand:QI 1 "bit_operand" "")
1208                 (match_operand:QI 2 "nonmemory_operand" "")))]
1209   ""
1210   "
1211 {
1212   if (fix_bit_operand (operands, 'O', XOR))
1213     DONE;
1214 }")
1215
1216 (define_expand "xorhi3"
1217   [(set (match_operand:HI 0 "register_operand" "")
1218         (xor:HI (match_operand:HI 1 "general_operand" "")
1219                 (match_operand:HI 2 "nonmemory_operand" "")))]
1220   ""
1221   "")
1222
1223 (define_insn ""
1224   [(set (match_operand:HI 0 "register_operand" "=r,r")
1225         (xor:HI (match_operand:HI 1 "general_operand" "%0,0")
1226                 (match_operand:HI 2 "nonmemory_operand" "J,rn")))]
1227   "TARGET_H8300"
1228   "* return output_logical_op (HImode, XOR, operands);"
1229   [(set_attr "length" "2,4")
1230    (set_attr "cc" "clobber,clobber")])
1231
1232 (define_insn ""
1233   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
1234         (xor:HI (match_operand:HI 1 "general_operand" "%0,0,0")
1235                 (match_operand:HI 2 "nonmemory_operand" "J,r,n")))]
1236   "TARGET_H8300H || TARGET_H8300S"
1237   "* return output_logical_op (HImode, XOR, operands);"
1238   [(set_attr "length" "2,2,4")
1239    (set_attr "cc" "clobber,set_znv,clobber")])
1240
1241 (define_expand "xorsi3"
1242   [(set (match_operand:SI 0 "register_operand" "")
1243         (xor:SI (match_operand:SI 1 "register_operand" "")
1244                 (match_operand:SI 2 "nonmemory_operand" "")))]
1245   ""
1246   "")
1247
1248 (define_insn ""
1249   [(set (match_operand:SI 0 "register_operand" "=r,r")
1250         (xor:SI (match_operand:SI 1 "register_operand" "%0,0")
1251                 (match_operand:SI 2 "nonmemory_operand" "J,rn")))]
1252   "TARGET_H8300"
1253   "* return output_logical_op (SImode, XOR, operands);"
1254   [(set_attr "length" "2,8")
1255    (set_attr "cc" "clobber,clobber")])
1256
1257 (define_insn ""
1258   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1259         (xor:SI (match_operand:SI 1 "register_operand" "%0,0,0")
1260                 (match_operand:SI 2 "nonmemory_operand" "J,r,n")))]
1261   "TARGET_H8300H || TARGET_H8300S"
1262   "* return output_logical_op (SImode, XOR, operands);"
1263   [(set_attr "length" "2,4,6")
1264    (set_attr "cc" "clobber,set_znv,clobber")])
1265 \f
1266 ;; ----------------------------------------------------------------------
1267 ;; NEGATION INSTRUCTIONS
1268 ;; ----------------------------------------------------------------------
1269
1270 (define_insn "negqi2"
1271   [(set (match_operand:QI 0 "register_operand" "=r")
1272         (neg:QI (match_operand:QI 1 "register_operand" "0")))]
1273   ""
1274   "neg  %X0"
1275   [(set_attr "length" "2")
1276    (set_attr "cc" "set_zn")])
1277
1278 (define_expand "neghi2"
1279   [(set (match_operand:HI 0 "register_operand" "")
1280         (neg:HI (match_operand:HI 1 "register_operand" "")))]
1281   ""
1282   "
1283 {
1284   if (TARGET_H8300)
1285     {
1286       emit_insn (gen_neghi2_h8300 (operands[0], operands[1]));
1287       DONE;
1288     }
1289 }")
1290
1291 (define_expand "neghi2_h8300"
1292   [(set (match_dup 2)
1293         (not:HI (match_operand:HI 1 "register_operand" "")))
1294    (set (match_dup 2) (plus:HI (match_dup 2) (const_int 1)))
1295    (set (match_operand:HI 0 "register_operand" "")
1296         (match_dup 2))]
1297   ""
1298   "{ operands[2] = gen_reg_rtx (HImode); }")
1299
1300 (define_insn "neghi2_h8300h"
1301   [(set (match_operand:HI 0 "register_operand" "=r")
1302         (neg:HI (match_operand:HI 1 "register_operand" "0")))]
1303   "TARGET_H8300H || TARGET_H8300S"
1304   "neg  %T0"
1305   [(set_attr "length" "2")
1306    (set_attr "cc" "set_zn")])
1307
1308 (define_expand "negsi2"
1309   [(set (match_operand:SI 0 "register_operand" "")
1310         (neg:SI (match_operand:SI 1 "register_operand" "")))]
1311   ""
1312   "
1313 {
1314   if (TARGET_H8300)
1315     {
1316       emit_insn (gen_negsi2_h8300 (operands[0], operands[1]));
1317       DONE;
1318     }
1319 }")
1320
1321 (define_expand "negsi2_h8300"
1322   [(set (match_dup 2)
1323         (not:SI (match_operand:SI 1 "register_operand" "")))
1324    (set (match_dup 2) (plus:SI (match_dup 2) (const_int 1)))
1325    (set (match_operand:SI 0 "register_operand" "")
1326         (match_dup 2))]
1327   ""
1328   "{ operands[2] = gen_reg_rtx(SImode); }")
1329
1330 (define_insn "negsi2_h8300h"
1331   [(set (match_operand:SI 0 "register_operand" "=r")
1332         (neg:SI (match_operand:SI 1 "register_operand" "0")))]
1333   "TARGET_H8300H || TARGET_H8300S"
1334   "neg  %S0"
1335   [(set_attr "length" "2")
1336    (set_attr "cc" "set_zn")])
1337
1338 ;; ----------------------------------------------------------------------
1339 ;; NOT INSTRUCTIONS
1340 ;; ----------------------------------------------------------------------
1341
1342 (define_insn "one_cmplqi2"
1343   [(set (match_operand:QI 0 "register_operand" "=r")
1344         (not:QI (match_operand:QI 1 "general_operand" "0")))]
1345   ""
1346   "not  %X0"
1347   [(set_attr "length" "2")
1348    (set_attr "cc" "set_znv")])
1349
1350 (define_insn "one_cmplhi2"
1351   [(set (match_operand:HI 0 "register_operand" "=r")
1352         (not:HI (match_operand:HI 1 "general_operand" "0")))]
1353   ""
1354   "*
1355 {
1356   if (TARGET_H8300)
1357     return \"not        %s0\;not        %t0\";
1358   else
1359     return \"not        %T0\";
1360 }"
1361   [(set_attr "cc" "clobber")
1362    (set (attr "length")
1363         (if_then_else (eq (symbol_ref "TARGET_H8300H || TARGET_H8300S")
1364                           (const_int 0))
1365                       (const_int 4)
1366                       (const_int 2)))])
1367
1368 (define_insn "one_cmplsi2"
1369   [(set (match_operand:SI 0 "register_operand" "=r")
1370         (not:SI (match_operand:SI 1 "general_operand" "0")))]
1371   ""
1372   "*
1373 {
1374   if (TARGET_H8300)
1375     return \"not        %w0\;not        %x0\;not        %y0\;not        %z0\";
1376   else
1377     return \"not        %S0\";
1378 }"
1379   [(set_attr "cc" "clobber")
1380    (set (attr "length")
1381         (if_then_else (eq (symbol_ref "TARGET_H8300H || TARGET_H8300S")
1382                           (const_int 0))
1383                       (const_int 8)
1384                       (const_int 2)))])
1385 \f
1386 ;; ----------------------------------------------------------------------
1387 ;; JUMP INSTRUCTIONS
1388 ;; ----------------------------------------------------------------------
1389
1390 ;; Conditional jump instructions
1391
1392 (define_expand "ble"
1393   [(set (pc)
1394         (if_then_else (le (cc0)
1395                           (const_int 0))
1396                       (label_ref (match_operand 0 "" ""))
1397                       (pc)))]
1398   ""
1399   "")
1400
1401 (define_expand "bleu"
1402   [(set (pc)
1403         (if_then_else (leu (cc0)
1404                            (const_int 0))
1405                       (label_ref (match_operand 0 "" ""))
1406                       (pc)))]
1407   ""
1408   "")
1409
1410 (define_expand "bge"
1411   [(set (pc)
1412         (if_then_else (ge (cc0)
1413                           (const_int 0))
1414                       (label_ref (match_operand 0 "" ""))
1415                       (pc)))]
1416   ""
1417   "")
1418
1419 (define_expand "bgeu"
1420   [(set (pc)
1421         (if_then_else (geu (cc0)
1422                            (const_int 0))
1423                       (label_ref (match_operand 0 "" ""))
1424                       (pc)))]
1425   ""
1426   "")
1427
1428 (define_expand "blt"
1429   [(set (pc)
1430         (if_then_else (lt (cc0)
1431                           (const_int 0))
1432                       (label_ref (match_operand 0 "" ""))
1433                       (pc)))]
1434   ""
1435   "")
1436
1437 (define_expand "bltu"
1438   [(set (pc)
1439         (if_then_else (ltu (cc0)
1440                            (const_int 0))
1441                       (label_ref (match_operand 0 "" ""))
1442                       (pc)))]
1443   ""
1444   "")
1445
1446 (define_expand "bgt"
1447   [(set (pc)
1448         (if_then_else (gt (cc0)
1449                           (const_int 0))
1450                       (label_ref (match_operand 0 "" ""))
1451                       (pc)))]
1452   ""
1453   "")
1454
1455 (define_expand "bgtu"
1456   [(set (pc)
1457         (if_then_else (gtu (cc0)
1458                            (const_int 0))
1459                       (label_ref (match_operand 0 "" ""))
1460                       (pc)))]
1461   ""
1462   "")
1463
1464 (define_expand "beq"
1465   [(set (pc)
1466         (if_then_else (eq (cc0)
1467                           (const_int 0))
1468                       (label_ref (match_operand 0 "" ""))
1469                       (pc)))]
1470   ""
1471   "")
1472
1473 (define_expand "bne"
1474   [(set (pc)
1475         (if_then_else (ne (cc0)
1476                           (const_int 0))
1477                       (label_ref (match_operand 0 "" ""))
1478                       (pc)))]
1479   ""
1480   "")
1481
1482 (define_insn "branch_true"
1483   [(set (pc)
1484         (if_then_else (match_operator 1 "comparison_operator"
1485                                       [(cc0) (const_int 0)])
1486                       (label_ref (match_operand 0 "" ""))
1487                       (pc)))]
1488   ""
1489   "*
1490 {
1491   if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
1492       && (GET_CODE (operands[1]) == GT
1493           || GET_CODE (operands[1]) == GE
1494           || GET_CODE (operands[1]) == LE
1495           || GET_CODE (operands[1]) == LT))
1496     {
1497       cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
1498       return 0;
1499     }
1500
1501   if (get_attr_length (insn) == 2)
1502     return \"b%j1       %l0\";
1503   else if (get_attr_length (insn) == 4)
1504     return \"b%j1       %l0:16\";
1505   else
1506     return \"b%k1       .Lh8BR%=\;jmp   @%l0\\n.Lh8BR%=:\";
1507 }"
1508  [(set_attr "type" "branch")
1509    (set_attr "cc" "none")])
1510
1511 (define_insn "branch_false"
1512   [(set (pc)
1513         (if_then_else (match_operator 1 "comparison_operator"
1514                                       [(cc0) (const_int 0)])
1515                       (pc)
1516                       (label_ref (match_operand 0 "" ""))))]
1517   ""
1518   "*
1519 {
1520   if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
1521       && (GET_CODE (operands[1]) == GT
1522           || GET_CODE (operands[1]) == GE
1523           || GET_CODE (operands[1]) == LE
1524           || GET_CODE (operands[1]) == LT))
1525     {
1526       cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
1527       return 0;
1528     }
1529
1530   if (get_attr_length (insn) == 2)
1531     return \"b%k1       %l0\";
1532   else if (get_attr_length (insn) == 4)
1533     return \"b%k1       %l0:16\";
1534   else
1535     return \"b%j1       .Lh8BR%=\;jmp   @%l0\\n.Lh8BR%=:\";
1536 }"
1537   [(set_attr "type" "branch")
1538    (set_attr "cc" "none")])
1539
1540 ;; Unconditional and other jump instructions.
1541
1542 (define_insn "jump"
1543   [(set (pc)
1544         (label_ref (match_operand 0 "" "")))]
1545   ""
1546   "*
1547 {
1548   if (get_attr_length (insn) == 2)
1549     return \"bra        %l0\";
1550   else if (get_attr_length (insn) == 4)
1551     return \"bra        %l0:16\";
1552   else
1553     return \"jmp        @%l0\";
1554 }"
1555   [(set_attr "type" "branch")
1556    (set_attr "cc" "none")])
1557
1558 ;; This is a define expand, because pointers may be either 16 or 32 bits.
1559
1560 (define_expand "tablejump"
1561   [(parallel [(set (pc) (match_operand 0 "register_operand" ""))
1562               (use (label_ref (match_operand 1 "" "")))])]
1563   ""
1564   "")
1565
1566 (define_insn "tablejump_h8300"
1567   [(set (pc) (match_operand:HI 0 "register_operand" "r"))
1568    (use (label_ref (match_operand 1 "" "")))]
1569   "TARGET_H8300"
1570   "jmp  @%0"
1571   [(set_attr "cc" "none")
1572    (set_attr "length" "2")])
1573
1574 (define_insn "tablejump_h8300h"
1575   [(set (pc) (match_operand:SI 0 "register_operand" "r"))
1576    (use (label_ref (match_operand 1 "" "")))]
1577   "TARGET_H8300H || TARGET_H8300S"
1578   "jmp  @%0"
1579   [(set_attr "cc" "none")
1580    (set_attr "length" "2")])
1581
1582 ;; This is a define expand, because pointers may be either 16 or 32 bits.
1583
1584 (define_expand "indirect_jump"
1585   [(set (pc) (match_operand 0 "jump_address_operand" ""))]
1586   ""
1587   "")
1588
1589 (define_insn "indirect_jump_h8300"
1590   [(set (pc) (match_operand:HI 0 "jump_address_operand" "Vr"))]
1591   "TARGET_H8300"
1592   "jmp  @%0"
1593   [(set_attr "cc" "none")
1594    (set_attr "length" "2")])
1595
1596 (define_insn "indirect_jump_h8300h"
1597   [(set (pc) (match_operand:SI 0 "jump_address_operand" "Vr"))]
1598   "TARGET_H8300H || TARGET_H8300S"
1599   "jmp @%0"
1600   [(set_attr "cc" "none")
1601    (set_attr "length" "2")])
1602
1603 ;; Call subroutine with no return value.
1604
1605 ;; ??? Even though we use HImode here, this works on the H8/300H and H8/S.
1606
1607 (define_insn "call"
1608   [(call (match_operand:QI 0 "call_insn_operand" "or")
1609          (match_operand:HI 1 "general_operand" "g"))]
1610   ""
1611   "*
1612 {
1613   if (GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
1614       && SYMBOL_REF_FLAG (XEXP (operands[0], 0)))
1615     return \"jsr\\t@%0:8\";
1616   else
1617     return \"jsr\\t%0\";
1618 }"
1619   [(set_attr "cc" "clobber")
1620    (set (attr "length")
1621      (if_then_else (match_operand:QI 0 "small_call_insn_operand" "")
1622                    (const_int 4)
1623                    (const_int 8)))])
1624
1625 ;; Call subroutine, returning value in operand 0
1626 ;; (which must be a hard register).
1627
1628 ;; ??? Even though we use HImode here, this works on the H8/300H and H8/S.
1629
1630 (define_insn "call_value"
1631   [(set (match_operand 0 "" "=r")
1632         (call (match_operand:QI 1 "call_insn_operand" "or")
1633               (match_operand:HI 2 "general_operand" "g")))]
1634   ""
1635   "*
1636 {
1637   if (GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
1638       && SYMBOL_REF_FLAG (XEXP (operands[1], 0)))
1639     return \"jsr\\t@%1:8\";
1640   else
1641     return \"jsr\\t%1\";
1642 }"
1643   [(set_attr "cc" "clobber")
1644    (set (attr "length")
1645      (if_then_else (match_operand:QI 0 "small_call_insn_operand" "")
1646                    (const_int 4)
1647                    (const_int 8)))])
1648
1649 (define_insn "nop"
1650   [(const_int 0)]
1651   ""
1652   "nop"
1653   [(set_attr "cc" "none")
1654    (set_attr "length" "2")])
1655 \f
1656 ;; ----------------------------------------------------------------------
1657 ;; EXTEND INSTRUCTIONS
1658 ;; ----------------------------------------------------------------------
1659
1660 (define_expand "zero_extendqihi2"
1661   [(set (match_operand:HI 0 "register_operand" "")
1662         (zero_extend:HI (match_operand:QI 1 "general_operand_src" "")))]
1663   ""
1664   "")
1665
1666 (define_insn ""
1667   [(set (match_operand:HI 0 "register_operand" "=r,r")
1668         (zero_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
1669   "TARGET_H8300"
1670   "@
1671   mov.b #0,%t0
1672   mov.b %R1,%s0\;mov.b  #0,%t0"
1673   [(set_attr "length" "2,10")
1674    (set_attr "cc" "clobber,clobber")])
1675
1676 (define_insn ""
1677   [(set (match_operand:HI 0 "register_operand" "=r,r")
1678         (zero_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
1679   "TARGET_H8300H || TARGET_H8300S"
1680   "@
1681   extu.w        %T0
1682   mov.b %R1,%s0\;extu.w %T0"
1683   [(set_attr "length" "2,10")
1684    (set_attr "cc" "set_znv,set_znv")])
1685
1686 ;; The compiler can synthesize a 300H variant of this which is
1687 ;; just as efficient as one that we'd create
1688 (define_insn "zero_extendqisi2"
1689   [(set (match_operand:SI 0 "register_operand" "=r,r")
1690         (zero_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
1691   "TARGET_H8300"
1692   "@
1693   mov.b #0,%x0\;sub.w   %e0,%e0
1694   mov.b %R1,%w0\;mov.b  #0,%x0\;sub.w   %e0,%e0"
1695   [(set_attr "length" "4,6")
1696    (set_attr "cc" "clobber,clobber")])
1697
1698 (define_expand "zero_extendhisi2"
1699   [(set (match_operand:SI 0 "register_operand" "")
1700         (zero_extend:SI (match_operand:HI 1 "register_operand" "")))]
1701   ""
1702   "")
1703
1704 ;; %e prints the high part of a CONST_INT, not the low part.  Arggh.
1705 (define_insn ""
1706   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1707         (zero_extend:SI (match_operand:HI 1 "general_operand_src" "0,i,g>")))]
1708   "TARGET_H8300"
1709   "@
1710   sub.w %e0,%e0
1711   mov.w %f1,%f0\;sub.w  %e0,%e0
1712   mov.w %e1,%f0\;sub.w  %e0,%e0"
1713   [(set_attr "length" "2,4,4")
1714    (set_attr "cc" "clobber,clobber,clobber")])
1715
1716 (define_insn ""
1717   [(set (match_operand:SI 0 "register_operand" "=r")
1718         (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))]
1719   "TARGET_H8300H || TARGET_H8300S"
1720   "extu.l       %S0"
1721   [(set_attr "length" "2")
1722    (set_attr "cc" "set_znv")])
1723
1724 (define_expand "extendqihi2"
1725   [(set (match_operand:HI 0 "register_operand" "")
1726         (sign_extend:HI (match_operand:QI 1 "register_operand" "")))]
1727   ""
1728   "")
1729
1730 (define_insn ""
1731   [(set (match_operand:HI 0 "register_operand" "=r,r")
1732         (sign_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
1733   "TARGET_H8300"
1734   "@
1735   bld   #7,%s0\;subx    %t0,%t0
1736   mov.b %R1,%s0\;bld    #7,%s0\;subx    %t0,%t0"
1737   [(set_attr "length" "4,8")
1738    (set_attr "cc" "clobber,clobber")])
1739
1740 (define_insn ""
1741   [(set (match_operand:HI 0 "register_operand" "=r")
1742         (sign_extend:HI (match_operand:QI 1 "register_operand" "0")))]
1743   "TARGET_H8300H || TARGET_H8300S"
1744   "exts.w       %T0"
1745   [(set_attr "length" "2")
1746    (set_attr "cc" "set_znv")])
1747
1748 ;; The compiler can synthesize a 300H variant of this which is
1749 ;; just as efficient as one that we'd create
1750 (define_insn "extendqisi2"
1751   [(set (match_operand:SI 0 "register_operand" "=r,r")
1752         (sign_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
1753   "TARGET_H8300"
1754   "@
1755   bld   #7,%w0\;subx    %x0,%x0\;subx   %y0,%y0\;subx   %z0,%z0
1756   mov.b %R1,%w0\;bld    #7,%w0\;subx    %x0,%x0\;subx   %y0,%y0\;subx   %z0,%z0"
1757   [(set_attr "length" "8,10")
1758    (set_attr "cc" "clobber,clobber")])
1759
1760 (define_expand "extendhisi2"
1761   [(set (match_operand:SI 0 "register_operand" "")
1762         (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
1763   ""
1764   "")
1765
1766 (define_insn ""
1767   [(set (match_operand:SI 0 "register_operand" "=r,r")
1768         (sign_extend:SI (match_operand:HI 1 "general_operand_src" "0,g>")))]
1769   "TARGET_H8300"
1770   "@
1771   bld   #7,%x0\;subx    %y0,%y0\;subx   %z0,%z0
1772   mov.w %T1,%f0\;bld    #7,%x0\;subx    %y0,%y0\;subx   %z0,%z0"
1773   [(set_attr "length" "6,8")
1774    (set_attr "cc" "clobber,clobber")])
1775
1776 (define_insn ""
1777   [(set (match_operand:SI 0 "register_operand" "=r")
1778         (sign_extend:SI (match_operand:HI 1 "register_operand" "0")))]
1779   "TARGET_H8300H || TARGET_H8300S"
1780   "exts.l       %S0"
1781   [(set_attr "length" "2")
1782    (set_attr "cc" "set_znv")])
1783 \f
1784 ;; ----------------------------------------------------------------------
1785 ;; SHIFTS
1786 ;; ----------------------------------------------------------------------
1787 ;;
1788 ;; We make some attempt to provide real efficient shifting.  One example is
1789 ;; doing an 8 bit shift of a 16 bit value by moving a byte reg into the other
1790 ;; reg and moving 0 into the former reg.
1791 ;;
1792 ;; We also try to achieve this in a uniform way.  IE: We don't try to achieve
1793 ;; this in both rtl and at insn emit time.  Ideally, we'd use rtl as that would
1794 ;; give the optimizer more cracks at the code.  However, we wish to do things
1795 ;; like optimizing shifting the sign bit to bit 0 by rotating the other way.
1796 ;; There is rtl to handle this (rotate + and), but the H8/300 doesn't handle
1797 ;; 16 bit rotates.  Also, if we emit complicated rtl, combine may not be able
1798 ;; to detect cases it can optimize.
1799 ;;
1800 ;; For these and other fuzzy reasons, I've decided to go the less pretty but
1801 ;; easier "do it at insn emit time" route.
1802
1803 ;; QI BIT SHIFTS
1804
1805 (define_expand "ashlqi3"
1806   [(set (match_operand:QI 0 "register_operand" "")
1807         (ashift:QI (match_operand:QI 1 "register_operand" "")
1808                    (match_operand:QI 2 "nonmemory_operand" "")))]
1809   ""
1810   "if (expand_a_shift (QImode, ASHIFT, operands)) DONE; else FAIL;")
1811
1812 (define_expand "ashrqi3"
1813   [(set (match_operand:QI 0 "register_operand" "")
1814         (ashiftrt:QI (match_operand:QI 1 "register_operand" "")
1815                      (match_operand:QI 2 "nonmemory_operand" "")))]
1816   ""
1817   "if (expand_a_shift (QImode, ASHIFTRT, operands)) DONE; else FAIL;")
1818
1819 (define_expand "lshrqi3"
1820   [(set (match_operand:QI 0 "register_operand" "")
1821         (lshiftrt:QI (match_operand:QI 1 "register_operand" "")
1822                      (match_operand:QI 2 "nonmemory_operand" "")))]
1823   ""
1824   "if (expand_a_shift (QImode, LSHIFTRT, operands)) DONE; else FAIL;")
1825
1826 (define_insn ""
1827   [(set (match_operand:QI 0 "register_operand" "=r,r")
1828         (match_operator:QI 3 "nshift_operator"
1829                         [ (match_operand:QI 1 "register_operand" "0,0")
1830                           (match_operand:QI 2 "nonmemory_operand" "KM,rn")]))
1831    (clobber (match_scratch:QI 4 "=X,&r"))]
1832   ""
1833   "* return output_a_shift (insn, operands);"
1834   [(set_attr "length" "20")
1835    (set_attr "cc" "clobber")])
1836
1837 ;; HI BIT SHIFTS
1838
1839 (define_expand "ashlhi3"
1840   [(set (match_operand:HI 0 "register_operand" "")
1841         (ashift:HI (match_operand:HI 1 "nonmemory_operand" "")
1842                    (match_operand:QI 2 "nonmemory_operand" "")))]
1843   ""
1844   "if (expand_a_shift (HImode, ASHIFT, operands)) DONE; else FAIL;")
1845
1846 (define_expand "lshrhi3"
1847   [(set (match_operand:HI 0 "register_operand" "")
1848         (lshiftrt:HI (match_operand:HI 1 "general_operand" "")
1849                      (match_operand:QI 2 "nonmemory_operand" "")))]
1850   ""
1851   "if (expand_a_shift (HImode, LSHIFTRT, operands)) DONE; else FAIL;")
1852
1853 (define_expand "ashrhi3"
1854   [(set (match_operand:HI 0 "register_operand" "")
1855         (ashiftrt:HI (match_operand:HI 1 "register_operand" "")
1856                      (match_operand:QI 2 "nonmemory_operand" "")))]
1857   ""
1858   "if (expand_a_shift (HImode, ASHIFTRT, operands)) DONE; else FAIL;")
1859
1860 (define_insn ""
1861   [(set (match_operand:HI 0 "register_operand" "=r,r")
1862         (match_operator:HI 3 "nshift_operator"
1863                         [ (match_operand:HI 1 "register_operand" "0,0")
1864                           (match_operand:QI 2 "nonmemory_operand" "KM,rn")]))
1865    (clobber (match_scratch:QI 4 "=X,&r"))]
1866   ""
1867   "* return output_a_shift (insn, operands);"
1868   [(set_attr "length" "20")
1869    (set_attr "cc" "clobber")])
1870
1871 ;;  SI BIT SHIFTS
1872
1873 (define_expand "ashlsi3"
1874   [(set (match_operand:SI 0 "register_operand" "")
1875         (ashift:SI
1876          (match_operand:SI 1 "general_operand" "")
1877          (match_operand:QI 2 "nonmemory_operand" "")))]
1878   ""
1879   "if (expand_a_shift (SImode, ASHIFT, operands)) DONE; else FAIL;")
1880
1881 (define_expand "lshrsi3"
1882   [(set (match_operand:SI 0 "register_operand" "")
1883         (lshiftrt:SI
1884          (match_operand:SI 1 "general_operand" "")
1885          (match_operand:QI 2 "nonmemory_operand" "")))]
1886   ""
1887   "if (expand_a_shift (SImode, LSHIFTRT, operands)) DONE; else FAIL;")
1888
1889 (define_expand "ashrsi3"
1890   [(set (match_operand:SI 0 "register_operand" "")
1891         (ashiftrt:SI
1892          (match_operand:SI 1 "general_operand" "")
1893          (match_operand:QI 2 "nonmemory_operand" "")))]
1894   ""
1895   "if (expand_a_shift (SImode, ASHIFTRT, operands)) DONE; else FAIL;")
1896
1897 (define_insn ""
1898   [(set (match_operand:SI 0 "register_operand" "=r,r")
1899         (match_operator:SI 3 "nshift_operator"
1900                         [ (match_operand:SI 1 "register_operand" "0,0")
1901                           (match_operand:QI 2 "nonmemory_operand" "K,rn")]))
1902    (clobber (match_scratch:QI 4 "=X,&r"))]
1903   ""
1904   "* return output_a_shift (insn, operands);"
1905   [(set_attr "length" "20")
1906    (set_attr "cc" "clobber")])
1907 \f
1908 ;; ----------------------------------------------------------------------
1909 ;; ROTATIONS
1910 ;; ----------------------------------------------------------------------
1911
1912 (define_expand "rotlqi3"
1913   [(set (match_operand:QI 0 "register_operand" "")
1914         (rotate:QI (match_operand:QI 1 "register_operand" "")
1915                    (match_operand:QI 2 "nonmemory_operand" "")))]
1916   ""
1917   "if (expand_a_rotate (ROTATE, operands)) DONE; else FAIL;")
1918
1919 (define_insn "*rotlqi3_1"
1920   [(set (match_operand:QI 0 "register_operand" "=r")
1921         (rotate:QI (match_operand:QI 1 "register_operand" "0")
1922                    (match_operand:QI 2 "immediate_operand" "")))]
1923   ""
1924   "* return emit_a_rotate (ROTATE, operands);"
1925   [(set_attr "length" "20")
1926    (set_attr "cc" "clobber")])
1927
1928 (define_expand "rotlhi3"
1929   [(set (match_operand:HI 0 "register_operand" "")
1930         (rotate:HI (match_operand:HI 1 "register_operand" "")
1931                    (match_operand:QI 2 "nonmemory_operand" "")))]
1932   ""
1933   "if (expand_a_rotate (ROTATE, operands)) DONE; else FAIL;")
1934
1935 (define_insn "*rotlhi3_1"
1936   [(set (match_operand:HI 0 "register_operand" "=r")
1937         (rotate:HI (match_operand:HI 1 "register_operand" "0")
1938                    (match_operand:QI 2 "immediate_operand" "")))]
1939   ""
1940   "* return emit_a_rotate (ROTATE, operands);"
1941   [(set_attr "length" "20")
1942    (set_attr "cc" "clobber")])
1943
1944 (define_expand "rotlsi3"
1945   [(set (match_operand:SI 0 "register_operand" "")
1946         (rotate:SI (match_operand:SI 1 "register_operand" "")
1947                    (match_operand:QI 2 "nonmemory_operand" "")))]
1948   "TARGET_H8300H || TARGET_H8300S"
1949   "if (expand_a_rotate (ROTATE, operands)) DONE; else FAIL;")
1950
1951 (define_insn "*rotlsi3_1"
1952   [(set (match_operand:SI 0 "register_operand" "=r")
1953         (rotate:SI (match_operand:SI 1 "register_operand" "0")
1954                    (match_operand:QI 2 "immediate_operand" "")))]
1955   "TARGET_H8300H || TARGET_H8300S"
1956   "* return emit_a_rotate (ROTATE, operands);"
1957   [(set_attr "length" "20")
1958    (set_attr "cc" "clobber")])
1959 \f
1960 ;; -----------------------------------------------------------------
1961 ;; BIT FIELDS
1962 ;; -----------------------------------------------------------------
1963 ;; The H8/300 has given 1/8th of its opcode space to bitfield
1964 ;; instructions so let's use them as well as we can.
1965
1966 ;; You'll never believe all these patterns perform one basic action --
1967 ;; load a bit from the source, optionally invert the bit, then store it
1968 ;; in the destination (which is known to be zero).
1969 ;;
1970 ;; Combine obviously need some work to better identify this situation and
1971 ;; canonicalize the form better.
1972
1973 ;;
1974 ;; Normal loads with a 16bit destination.
1975 ;;
1976
1977 (define_insn ""
1978   [(set (match_operand:HI 0 "register_operand" "=&r")
1979         (zero_extract:HI (match_operand:HI 1 "register_operand" "r")
1980                          (const_int 1)
1981                          (match_operand:HI 2 "immediate_operand" "n")))]
1982   "TARGET_H8300"
1983   "sub.w        %0,%0\;bld      %Z2,%Y1\;bst    #0,%X0"
1984   [(set_attr "cc" "clobber")
1985    (set_attr "length" "6")])
1986
1987 ;;
1988 ;; Inverted loads with a 16bit destination.
1989 ;;
1990
1991 (define_insn ""
1992   [(set (match_operand:HI 0 "register_operand" "=&r")
1993         (zero_extract:HI (xor:HI (match_operand:HI 1 "register_operand" "r")
1994                                  (match_operand:HI 3 "p_operand" "P"))
1995                          (const_int 1)
1996                          (match_operand:HI 2 "const_int_operand" "n")))]
1997   "TARGET_H8300
1998    && (1 << INTVAL (operands[2])) == INTVAL (operands[3])"
1999   "sub.w        %0,%0\;bild     %Z2,%Y1\;bst    #0,%X0"
2000   [(set_attr "cc" "clobber")
2001    (set_attr "length" "8")])
2002
2003 ;;
2004 ;; Normal loads with a 32bit destination.
2005 ;;
2006 ;; Yes, all three cases are needed.
2007 ;;
2008 (define_insn ""
2009   [(set (match_operand:SI 0 "register_operand" "=&r")
2010         (zero_extract:SI (match_operand:HI 1 "register_operand" "r")
2011                          (const_int 1)
2012                          (match_operand:HI 2 "const_int_operand" "n")))]
2013   ""
2014   "* return output_simode_bld (0, 0, operands);"
2015   [(set_attr "cc" "clobber")
2016    (set (attr "length")
2017         (if_then_else (eq (symbol_ref "TARGET_H8300H || TARGET_H8300S")
2018                           (const_int 0))
2019                       (const_int 10)
2020                       (const_int 8)))])
2021
2022 (define_insn ""
2023   [(set (match_operand:SI 0 "register_operand" "=&r")
2024         (and:SI (zero_extend:SI
2025                    (lshiftrt:QI
2026                      (match_operand:QI 1 "bit_operand" "Ur")
2027                      (match_operand:QI 2 "const_int_operand" "n")))
2028                 (const_int 1)))]
2029   ""
2030   "* return output_simode_bld (0, 0, operands);"
2031   [(set_attr "cc" "clobber")
2032    (set (attr "length")
2033         (if_then_else (eq (symbol_ref "TARGET_H8300H || TARGET_H8300S")
2034                           (const_int 0))
2035                       (const_int 10)
2036                       (const_int 8)))])
2037
2038 (define_insn ""
2039   [(set (match_operand:SI 0 "register_operand" "=&r")
2040         (and:SI (zero_extend:SI
2041                    (lshiftrt:HI
2042                       (match_operand:HI 1 "bit_operand" "Ur")
2043                       (match_operand:HI 2 "const_int_operand" "n")))
2044                 (const_int 1)))]
2045   ""
2046   "* return output_simode_bld (0, 0, operands);"
2047   [(set_attr "cc" "clobber")
2048    (set (attr "length")
2049         (if_then_else (eq (symbol_ref "TARGET_H8300H || TARGET_H8300S")
2050                           (const_int 0))
2051                       (const_int 10)
2052                       (const_int 8)))])
2053
2054 ;;
2055 ;; Inverted loads with a 32bit destination.
2056 ;;
2057 ;; Yes, all five cases are needed.
2058 ;;
2059 (define_insn ""
2060   [(set (match_operand:SI 0 "register_operand" "=&r")
2061         (and:SI (not:SI
2062                   (zero_extend:SI
2063                     (lshiftrt:HI (match_operand:HI 1 "bit_operand" "Ur")
2064                                  (match_operand:HI 2 "const_int_operand" "n"))))
2065                 (const_int 1)))]
2066   ""
2067   "* return output_simode_bld (1, 0, operands);"
2068   [(set_attr "cc" "clobber")
2069    (set (attr "length")
2070         (if_then_else (eq (symbol_ref "TARGET_H8300H || TARGET_H8300S")
2071                           (const_int 0))
2072                       (const_int 10)
2073                       (const_int 8)))])
2074
2075 (define_insn ""
2076   [(set (match_operand:SI 0 "register_operand" "=&r")
2077         (and:SI (not:SI
2078                   (zero_extend:SI
2079                     (lshiftrt:QI (match_operand:QI 1 "bit_operand" "Ur")
2080                                  (match_operand:QI 2 "const_int_operand" "n"))))
2081                 (const_int 1)))]
2082   ""
2083   "* return output_simode_bld (1, 0, operands);"
2084   [(set_attr "cc" "clobber")
2085    (set (attr "length")
2086         (if_then_else (eq (symbol_ref "TARGET_H8300H || TARGET_H8300S")
2087                           (const_int 0))
2088                       (const_int 10)
2089                       (const_int 8)))])
2090
2091 (define_insn ""
2092   [(set (match_operand:SI 0 "register_operand" "=&r")
2093         (and:SI (not:SI
2094                   (subreg:SI
2095                      (lshiftrt:HI
2096                         (match_operand:HI 1 "bit_operand" "Ur")
2097                         (match_operand:HI 2 "const_int_operand" "n")) 0))
2098                 (const_int 1)))]
2099   "1"
2100   "* return output_simode_bld (1, 0, operands);"
2101   [(set_attr "cc" "clobber")
2102    (set (attr "length")
2103         (if_then_else (eq (symbol_ref "TARGET_H8300H || TARGET_H8300S")
2104                           (const_int 0))
2105                       (const_int 10)
2106                       (const_int 8)))])
2107
2108 (define_insn ""
2109   [(set (match_operand:SI 0 "register_operand" "=&r")
2110         (and:SI (not:SI
2111                   (subreg:SI
2112                      (lshiftrt:QI
2113                         (match_operand:QI 1 "bit_operand" "Ur")
2114                         (match_operand:QI 2 "const_int_operand" "n")) 0))
2115                 (const_int 1)))]
2116   "1"
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")
2121                           (const_int 0))
2122                       (const_int 10)
2123                       (const_int 8)))])
2124
2125 (define_insn ""
2126   [(set (match_operand:SI 0 "register_operand" "=&r")
2127         (zero_extract:SI (xor:HI (match_operand:HI 1 "register_operand" "r")
2128                                  (match_operand:HI 3 "p_operand" "P"))
2129                          (const_int 1)
2130                          (match_operand:HI 2 "const_int_operand" "n")))]
2131   "(1 << INTVAL (operands[2])) == INTVAL (operands[3])"
2132   "sub.w        %0,%0\;bild     %Z2,%Y1\;bst    #0,%X0"
2133   [(set_attr "cc" "clobber")
2134    (set_attr "length" "8")])
2135
2136 (define_expand "insv"
2137   [(set (zero_extract:HI (match_operand:HI 0 "general_operand" "")
2138                          (match_operand:HI 1 "general_operand" "")
2139                          (match_operand:HI 2 "general_operand" ""))
2140         (match_operand:HI 3 "general_operand" ""))]
2141   "TARGET_H8300"
2142   "
2143 {
2144   /* We only have single bit bitfield instructions.  */
2145   if (INTVAL (operands[1]) != 1)
2146     FAIL;
2147
2148   /* For now, we don't allow memory operands.  */
2149   if (GET_CODE (operands[0]) == MEM
2150       || GET_CODE (operands[3]) == MEM)
2151     FAIL;
2152 }")
2153
2154 (define_insn ""
2155   [(set (zero_extract:HI (match_operand:HI 0 "register_operand" "+r")
2156                          (const_int 1)
2157                          (match_operand:HI 1 "immediate_operand" "n"))
2158         (match_operand:HI 2 "register_operand" "r"))]
2159   ""
2160   "bld  #0,%R2\;bst     %Z1,%Y0 ; i1"
2161   [(set_attr "cc" "clobber")
2162    (set_attr "length" "4")])
2163
2164 (define_expand "extzv"
2165   [(set (match_operand:HI 0 "register_operand" "")
2166         (zero_extract:HI (match_operand:HI 1 "bit_operand" "")
2167                          (match_operand:HI 2 "general_operand" "")
2168                          (match_operand:HI 3 "general_operand" "")))]
2169   "TARGET_H8300"
2170   "
2171 {
2172   /* We only have single bit bitfield instructions.  */
2173   if (INTVAL (operands[2]) != 1)
2174     FAIL;
2175
2176   /* For now, we don't allow memory operands.  */
2177   if (GET_CODE (operands[1]) == MEM)
2178     FAIL;
2179 }")
2180
2181 ;; BAND, BOR, and BXOR patterns
2182
2183 (define_insn ""
2184   [(set (match_operand:HI 0 "bit_operand" "=Ur")
2185         (match_operator:HI 4 "bit_operator"
2186            [(zero_extract:HI (match_operand:HI 1 "register_operand" "r")
2187                              (const_int 1)
2188                              (match_operand:HI 2 "immediate_operand" "n"))
2189             (match_operand:HI 3 "bit_operand" "0")]))]
2190   ""
2191   "bld  %Z2,%Y1\;%b4    #0,%R0\;bst     #0,%R0; bl1"
2192   [(set_attr "cc" "clobber")
2193    (set_attr "length" "6")
2194    (set_attr "adjust_length" "no")])
2195
2196 (define_insn ""
2197   [(set (match_operand:HI 0 "bit_operand" "=Ur")
2198         (match_operator:HI 5 "bit_operator"
2199            [(zero_extract:HI (match_operand:HI 1 "register_operand" "r")
2200                              (const_int 1)
2201                              (match_operand:HI 2 "immediate_operand" "n"))
2202             (zero_extract:HI (match_operand:HI 3 "register_operand" "r")
2203                              (const_int 1)
2204                              (match_operand:HI 4 "immediate_operand" "n"))]))]
2205   ""
2206   "bld  %Z2,%Y1\;%b5    %Z4,%Y3\;bst    #0,%R0; bl3"
2207   [(set_attr "cc" "clobber")
2208    (set_attr "length" "6")
2209    (set_attr "adjust_length" "no")])
2210 \f
2211 ;; -----------------------------------------------------------------
2212 ;; COMBINE PATTERNS
2213 ;; -----------------------------------------------------------------
2214
2215 (define_insn ""
2216   [(set (match_operand:HI 0 "register_operand" "=r")
2217         (ior:HI
2218            (zero_extend:HI (match_operand:QI 1 "register_operand" "r"))
2219            (match_operand:HI 2 "register_operand" "0")))]
2220   "REG_P (operands[0])
2221    && REG_P (operands[1])
2222    && REGNO (operands[0]) != REGNO (operands[1])"
2223   "or\\t%X1,%s0"
2224   [(set_attr "cc" "clobber")
2225    (set_attr "length" "2")])
2226
2227 (define_insn ""
2228   [(set (match_operand:SI 0 "register_operand" "=r")
2229         (ior:SI
2230            (zero_extend:SI (match_operand:HI 1 "register_operand" "r"))
2231            (match_operand:SI 2 "register_operand" "0")))]
2232   "(TARGET_H8300H || TARGET_H8300S)
2233    && REG_P (operands[0])
2234    && REG_P (operands[1])
2235    && (REGNO (operands[0]) != REGNO (operands[1]))"
2236   "or.w\\t%T1,%f0"
2237   [(set_attr "cc" "clobber")
2238    (set_attr "length" "2")])
2239
2240 (define_insn ""
2241   [(set (match_operand:SI 0 "register_operand" "=r")
2242         (ior:SI
2243            (zero_extend:SI (match_operand:QI 1 "register_operand" "r"))
2244            (match_operand:SI 2 "register_operand" "0")))]
2245   "REG_P (operands[0])
2246    && REG_P (operands[1])
2247    && REGNO (operands[0]) != REGNO (operands[1])"
2248   "or\\t%X1,%s0"
2249   [(set_attr "cc" "clobber")
2250    (set_attr "length" "2")])
2251
2252 (define_insn ""
2253   [(set (match_operand:HI 0 "register_operand" "=r")
2254         (xor:HI
2255            (zero_extend:HI (match_operand:QI 1 "register_operand" "r"))
2256            (match_operand:HI 2 "register_operand" "0")))]
2257   "REG_P (operands[0])
2258    && REG_P (operands[1])
2259    && REGNO (operands[0]) != REGNO (operands[1])"
2260   "xor\\t%X1,%s0"
2261   [(set_attr "cc" "clobber")
2262    (set_attr "length" "2")])
2263
2264 (define_insn ""
2265   [(set (match_operand:SI 0 "register_operand" "=r")
2266         (xor:SI
2267            (zero_extend:SI (match_operand:HI 1 "register_operand" "r"))
2268            (match_operand:SI 2 "register_operand" "0")))]
2269   "(TARGET_H8300H || TARGET_H8300S)
2270    && REG_P (operands[0])
2271    && REG_P (operands[1])
2272    && (REGNO (operands[0]) != REGNO (operands[1]))"
2273   "xor.w\\t%T1,%f0"
2274   [(set_attr "cc" "clobber")
2275    (set_attr "length" "2")])
2276
2277 (define_insn ""
2278   [(set (match_operand:SI 0 "register_operand" "=r")
2279         (xor:SI
2280            (zero_extend:SI (match_operand:QI 1 "register_operand" "r"))
2281            (match_operand:SI 2 "register_operand" "0")))]
2282   "REG_P (operands[0])
2283    && REG_P (operands[1])
2284    && REGNO (operands[0]) != REGNO (operands[1])"
2285   "xor\\t%X1,%s0"
2286   [(set_attr "cc" "clobber")
2287    (set_attr "length" "2")])
2288
2289 (define_insn ""
2290   [(set (match_operand:HI 0 "register_operand" "=r")
2291         (ior:HI
2292            (zero_extend:HI (match_operand:QI 1 "register_operand" "0"))
2293            (ashift:HI (match_operand:HI 2 "register_operand" "r")
2294                       (const_int 8))))]
2295   "REG_P (operands[0])
2296    && REG_P (operands[2])
2297    && REGNO (operands[0]) != REGNO (operands[2])"
2298   "mov.b\\t%s2,%t0"
2299   [(set_attr "cc" "clobber")
2300    (set_attr "length" "2")])
2301
2302 (define_insn ""
2303   [(set (match_operand:SI 0 "register_operand" "=r")
2304         (ior:SI
2305            (zero_extend:SI (match_operand:HI 1 "register_operand" "0"))
2306            (ashift:SI (match_operand:SI 2 "register_operand" "r")
2307                       (const_int 16))))]
2308   "(TARGET_H8300H || TARGET_H8300S)
2309    && REG_P (operands[0])
2310    && REG_P (operands[2])
2311    && (REGNO (operands[0]) != REGNO (operands[2]))"
2312   "mov.w\\t%f2,%e0"
2313   [(set_attr "cc" "clobber")
2314    (set_attr "length" "2")])