]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/h8300/h8300.md
* config/h8300/h8300.md (two peephole2's): New.
[thirdparty/gcc.git] / gcc / config / h8300 / h8300.md
1 ;; GCC machine description for Renesas H8/300
2 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 ;; 2001, 2002, 2003, 2004 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 GCC.
9
10 ;; GCC is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GCC is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GCC; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;; We compute exact length on each instruction for most of the time.
26 ;; In some case, most notably bit operations that may involve memory
27 ;; operands, the lengths in this file are "worst case".
28
29 ;; On the H8/300H and H8S, adds/subs operate on the 32bit "er"
30 ;; registers. Right now GCC doesn't expose the "e" half to the
31 ;; compiler, so using add/subs for addhi and subhi is safe. Long
32 ;; term, we want to expose the "e" half to the compiler (gives us 8
33 ;; more 16bit registers). At that point addhi and subhi can't use
34 ;; adds/subs.
35
36 ;; There's currently no way to have an insv/extzv expander for the H8/300H
37 ;; because word_mode is different for the H8/300 and H8/300H.
38
39 ;; Shifts/rotates by small constants should be handled by special
40 ;; patterns so we get the length and cc status correct.
41
42 ;; Bitfield operations no longer accept memory operands. We need
43 ;; to add variants which operate on memory back to the MD.
44
45 ;; ??? Implement remaining bit ops available on the h8300
46
47 ;; ----------------------------------------------------------------------
48 ;; CONSTANTS
49 ;; ----------------------------------------------------------------------
50
51 (define_constants
52 [(UNSPEC_INCDEC 0)
53 (UNSPEC_MONITOR 1)])
54
55 (define_constants
56 [(R0_REG 0)
57 (SC_REG 3)
58 (HFP_REG 6)
59 (SP_REG 7)
60 (MAC_REG 8)
61 (AP_REG 9)
62 (RAP_REG 10)
63 (FP_REG 11)])
64
65 ;; ----------------------------------------------------------------------
66 ;; ATTRIBUTES
67 ;; ----------------------------------------------------------------------
68
69 (define_attr "cpu" "h8300,h8300h"
70 (const (symbol_ref "cpu_type")))
71
72 (define_attr "type" "branch,arith"
73 (const_string "arith"))
74
75 ;; The size of instructions in bytes.
76
77 (define_attr "length" ""
78 (cond [(eq_attr "type" "branch")
79 (if_then_else (and (ge (minus (match_dup 0) (pc))
80 (const_int -126))
81 (le (minus (match_dup 0) (pc))
82 (const_int 126)))
83 (const_int 2)
84 (if_then_else (and (eq_attr "cpu" "h8300h")
85 (and (ge (minus (pc) (match_dup 0))
86 (const_int -32000))
87 (le (minus (pc) (match_dup 0))
88 (const_int 32000))))
89 (const_int 4)
90 (const_int 6)))]
91 (const_int 200)))
92
93 ;; Condition code settings.
94 ;;
95 ;; none - insn does not affect cc
96 ;; none_0hit - insn does not affect cc but it does modify operand 0
97 ;; This attribute is used to keep track of when operand 0 changes.
98 ;; See the description of NOTICE_UPDATE_CC for more info.
99 ;; set_znv - insn sets z,n,v to usable values (like a tst insn); c is unknown.
100 ;; set_zn - insn sets z,n to usable values; v,c are unknown.
101 ;; compare - compare instruction
102 ;; clobber - value of cc is unknown
103
104 (define_attr "cc" "none,none_0hit,set_znv,set_zn,compare,clobber"
105 (const_string "clobber"))
106
107 ;; Provide the maximum length of an assembly instruction in an asm
108 ;; statement. The maximum length of 14 bytes is achieved on H8SX.
109
110 (define_asm_attributes
111 [(set (attr "length")
112 (cond [(ne (symbol_ref "TARGET_H8300") (const_int 0)) (const_int 4)
113 (ne (symbol_ref "TARGET_H8300H") (const_int 0)) (const_int 10)
114 (ne (symbol_ref "TARGET_H8300S") (const_int 0)) (const_int 10)]
115 (const_int 14)))])
116 \f
117 ;; ----------------------------------------------------------------------
118 ;; MOVE INSTRUCTIONS
119 ;; ----------------------------------------------------------------------
120
121 ;; movqi
122
123 (define_insn "pushqi1_h8300"
124 [(parallel [(set (reg:HI SP_REG)
125 (plus:HI (reg:HI SP_REG) (const_int -2)))
126 (set (mem:QI (plus:HI (reg:HI SP_REG) (const_int -1)))
127 (match_operand:QI 0 "register_operand" "r"))])]
128 "TARGET_H8300
129 && operands[0] != stack_pointer_rtx"
130 "mov.w\\t%T0,@-r7"
131 [(set_attr "length" "2")
132 (set_attr "cc" "clobber")])
133
134 (define_insn "pushqi1_h8300hs"
135 [(parallel [(set (reg:SI SP_REG)
136 (plus:SI (reg:SI SP_REG) (const_int -4)))
137 (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int -3)))
138 (match_operand:QI 0 "register_operand" "r"))])]
139 "(TARGET_H8300H || TARGET_H8300S)
140 && operands[0] != stack_pointer_rtx"
141 "mov.l\\t%S0,@-er7"
142 [(set_attr "length" "4")
143 (set_attr "cc" "clobber")])
144
145 (define_insn "pushqi1_h8300hs_normal"
146 [(parallel [(set (reg:HI SP_REG)
147 (plus:HI (reg:HI SP_REG) (const_int -4)))
148 (set (mem:QI (plus:HI (reg:HI SP_REG) (const_int -3)))
149 (match_operand:QI 0 "register_operand" "r"))])]
150 "(TARGET_H8300H || TARGET_H8300S)
151 && operands[0] != stack_pointer_rtx"
152 "mov.l\\t%S0,@-er7"
153 [(set_attr "length" "4")
154 (set_attr "cc" "clobber")])
155
156 (define_expand "pushqi1"
157 [(match_operand:QI 0 "register_operand" "")]
158 ""
159 "
160 {
161 if (TARGET_H8300)
162 emit_insn (gen_pushqi1_h8300 (operands[0]));
163 else if (!TARGET_NORMAL_MODE)
164 emit_insn (gen_pushqi1_h8300hs (operands[0]));
165 else
166 emit_insn (gen_pushqi1_h8300hs_normal (operands[0]));
167 DONE;
168 }")
169
170 (define_insn "*movqi_h8300"
171 [(set (match_operand:QI 0 "general_operand_dst" "=r,r ,<,r,r,m")
172 (match_operand:QI 1 "general_operand_src" " I,r>,r,n,m,r"))]
173 "TARGET_H8300
174 && (register_operand (operands[0], QImode)
175 || register_operand (operands[1], QImode))"
176 "@
177 sub.b %X0,%X0
178 mov.b %R1,%X0
179 mov.b %X1,%R0
180 mov.b %R1,%X0
181 mov.b %R1,%X0
182 mov.b %X1,%R0"
183 [(set_attr "length" "2,2,2,2,4,4")
184 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
185
186 (define_insn "*movqi_h8300hs"
187 [(set (match_operand:QI 0 "general_operand_dst" "=r,r ,<,r,r,m")
188 (match_operand:QI 1 "general_operand_src" " I,r>,r,n,m,r"))]
189 "(TARGET_H8300H || TARGET_H8300S)
190 && (register_operand (operands[0], QImode)
191 || register_operand (operands[1], QImode))"
192 "@
193 sub.b %X0,%X0
194 mov.b %R1,%X0
195 mov.b %X1,%R0
196 mov.b %R1,%X0
197 mov.b %R1,%X0
198 mov.b %X1,%R0"
199 [(set (attr "length")
200 (symbol_ref "compute_mov_length (operands)"))
201 (set_attr "cc" "set_zn,set_znv,set_znv,clobber,set_znv,set_znv")])
202
203 (define_expand "movqi"
204 [(set (match_operand:QI 0 "general_operand_dst" "")
205 (match_operand:QI 1 "general_operand_src" ""))]
206 ""
207 "
208 {
209 /* One of the ops has to be in a register. */
210 if (!register_operand (operand0, QImode)
211 && !register_operand (operand1, QImode))
212 {
213 operands[1] = copy_to_mode_reg (QImode, operand1);
214 }
215 }")
216
217 (define_insn "movstrictqi"
218 [(set (strict_low_part
219 (match_operand:QI 0 "register_operand" "+r,r,r,r,r"))
220 (match_operand:QI 1 "general_operand_src" " I,r,n,>,m"))]
221 ""
222 "@
223 sub.b %X0,%X0
224 mov.b %X1,%X0
225 mov.b %R1,%X0
226 mov.b %X1,%X0
227 mov.b %R1,%X0"
228 [(set (attr "length")
229 (symbol_ref "compute_mov_length (operands)"))
230 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv")])
231
232 ;; movhi
233
234 (define_expand "pushhi1_h8300"
235 [(set (mem:HI (pre_dec:HI (reg:HI SP_REG)))
236 (match_operand:HI 0 "register_operand" ""))]
237 "TARGET_H8300
238 && operands[0] != stack_pointer_rtx"
239 "")
240
241 (define_insn "pushhi1_h8300hs"
242 [(parallel [(set (reg:SI SP_REG)
243 (plus:SI (reg:SI SP_REG) (const_int -4)))
244 (set (mem:HI (plus:SI (reg:SI SP_REG) (const_int -2)))
245 (match_operand:HI 0 "register_operand" "r"))])]
246 "(TARGET_H8300H || TARGET_H8300S)
247 && operands[0] != stack_pointer_rtx"
248 "mov.l\\t%S0,@-er7"
249 [(set_attr "length" "4")
250 (set_attr "cc" "clobber")])
251
252 (define_insn "pushhi1_h8300hs_normal"
253 [(parallel [(set (reg:HI SP_REG)
254 (plus:HI (reg:HI SP_REG) (const_int -4)))
255 (set (mem:HI (plus:HI (reg:HI SP_REG) (const_int -2)))
256 (match_operand:HI 0 "register_operand" "r"))])]
257 "(TARGET_H8300H || TARGET_H8300S)
258 && operands[0] != stack_pointer_rtx"
259 "mov.l\\t%S0,@-er7"
260 [(set_attr "length" "4")
261 (set_attr "cc" "clobber")])
262
263 (define_expand "pushhi1"
264 [(match_operand:HI 0 "register_operand" "")]
265 ""
266 "
267 {
268 if (TARGET_H8300)
269 emit_insn (gen_pushhi1_h8300 (operands[0]));
270 else if (!TARGET_NORMAL_MODE)
271 emit_insn (gen_pushhi1_h8300hs (operands[0]));
272 else
273 emit_insn (gen_pushhi1_h8300hs_normal (operands[0]));
274 DONE;
275 }")
276
277 (define_insn "*movhi_h8300"
278 [(set (match_operand:HI 0 "general_operand_dst" "=r,r,<,r,r,m")
279 (match_operand:HI 1 "general_operand_src" "I,r>,r,i,m,r"))]
280 "TARGET_H8300
281 && (register_operand (operands[0], HImode)
282 || register_operand (operands[1], HImode))
283 && !(GET_CODE (operands[0]) == MEM
284 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
285 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
286 && GET_CODE (operands[1]) == REG
287 && REGNO (XEXP (XEXP (operands[0], 0), 0)) == REGNO (operands[1]))"
288 "@
289 sub.w %T0,%T0
290 mov.w %T1,%T0
291 mov.w %T1,%T0
292 mov.w %T1,%T0
293 mov.w %T1,%T0
294 mov.w %T1,%T0"
295 [(set (attr "length")
296 (symbol_ref "compute_mov_length (operands)"))
297 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
298
299 (define_insn "*movhi_h8300hs"
300 [(set (match_operand:HI 0 "general_operand_dst" "=r,r,<,r,r,m")
301 (match_operand:HI 1 "general_operand_src" "I,r>,r,i,m,r"))]
302 "(TARGET_H8300H || TARGET_H8300S)
303 && (register_operand (operands[0], HImode)
304 || register_operand (operands[1], HImode))"
305 "@
306 sub.w %T0,%T0
307 mov.w %T1,%T0
308 mov.w %T1,%T0
309 mov.w %T1,%T0
310 mov.w %T1,%T0
311 mov.w %T1,%T0"
312 [(set (attr "length")
313 (symbol_ref "compute_mov_length (operands)"))
314 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
315
316 (define_expand "movhi"
317 [(set (match_operand:HI 0 "general_operand_dst" "")
318 (match_operand:HI 1 "general_operand_src" ""))]
319 ""
320 "
321 {
322 /* One of the ops has to be in a register. */
323 if (!register_operand (operand1, HImode)
324 && !register_operand (operand0, HImode))
325 {
326 operands[1] = copy_to_mode_reg (HImode, operand1);
327 }
328 }")
329
330 (define_insn "movstricthi"
331 [(set (strict_low_part
332 (match_operand:HI 0 "register_operand" "+r,r,r,r,r"))
333 (match_operand:HI 1 "general_operand_src" " I,r,i,>,m"))]
334 ""
335 "@
336 sub.w %T0,%T0
337 mov.w %T1,%T0
338 mov.w %T1,%T0
339 mov.w %T1,%T0
340 mov.w %T1,%T0"
341 [(set (attr "length")
342 (symbol_ref "compute_mov_length (operands)"))
343 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv")])
344
345 ;; movsi
346
347 (define_expand "movsi"
348 [(set (match_operand:SI 0 "general_operand_dst" "")
349 (match_operand:SI 1 "general_operand_src" ""))]
350 ""
351 "
352 {
353 if (TARGET_H8300)
354 {
355 if (h8300_expand_movsi (operands))
356 DONE;
357 }
358 else
359 {
360 /* One of the ops has to be in a register. */
361 if (!register_operand (operand1, SImode)
362 && !register_operand (operand0, SImode))
363 {
364 operands[1] = copy_to_mode_reg (SImode, operand1);
365 }
366 }
367 }")
368
369 (define_expand "movsf"
370 [(set (match_operand:SF 0 "general_operand_dst" "")
371 (match_operand:SF 1 "general_operand_src" ""))]
372 ""
373 "
374 {
375 if (TARGET_H8300)
376 {
377 if (h8300_expand_movsi (operands))
378 DONE;
379 }
380 else
381 {
382 /* One of the ops has to be in a register. */
383 if (!register_operand (operand1, SFmode)
384 && !register_operand (operand0, SFmode))
385 {
386 operands[1] = copy_to_mode_reg (SFmode, operand1);
387 }
388 }
389 }")
390
391 (define_insn "*movsi_h8300"
392 [(set (match_operand:SI 0 "general_operand_dst" "=r,r,r,o,<,r")
393 (match_operand:SI 1 "general_operand_src" "I,r,io,r,r,>"))]
394 "TARGET_H8300
395 && (register_operand (operands[0], SImode)
396 || register_operand (operands[1], SImode))"
397 "*
398 {
399 unsigned int rn = -1;
400 switch (which_alternative)
401 {
402 case 0:
403 return \"sub.w %e0,%e0\;sub.w %f0,%f0\";
404 case 1:
405 if (REGNO (operands[0]) < REGNO (operands[1]))
406 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
407 else
408 return \"mov.w %f1,%f0\;mov.w %e1,%e0\";
409 case 2:
410 /* Make sure we don't trample the register we index with. */
411 if (GET_CODE (operands[1]) == MEM)
412 {
413 rtx inside = XEXP (operands[1], 0);
414 if (REG_P (inside))
415 {
416 rn = REGNO (inside);
417 }
418 else if (GET_CODE (inside) == PLUS)
419 {
420 rtx lhs = XEXP (inside, 0);
421 rtx rhs = XEXP (inside, 1);
422 if (REG_P (lhs)) rn = REGNO (lhs);
423 if (REG_P (rhs)) rn = REGNO (rhs);
424 }
425 }
426 if (rn == REGNO (operands[0]))
427 {
428 /* Move the second word first. */
429 return \"mov.w %f1,%f0\;mov.w %e1,%e0\";
430 }
431 else
432 {
433 if (GET_CODE (operands[1]) == CONST_INT)
434 {
435 /* If either half is zero, use sub.w to clear that
436 half. */
437 if ((INTVAL (operands[1]) & 0xffff) == 0)
438 return \"mov.w %e1,%e0\;sub.w %f0,%f0\";
439 if (((INTVAL (operands[1]) >> 16) & 0xffff) == 0)
440 return \"sub.w %e0,%e0\;mov.w %f1,%f0\";
441 /* If the upper half and the lower half are the same,
442 copy one half to the other. */
443 if ((INTVAL (operands[1]) & 0xffff)
444 == ((INTVAL (operands[1]) >> 16) & 0xffff))
445 return \"mov.w\\t%e1,%e0\;mov.w\\t%e0,%f0\";
446 }
447 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
448 }
449 case 3:
450 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
451 case 4:
452 return \"mov.w %f1,%T0\;mov.w %e1,%T0\";
453 case 5:
454 return \"mov.w %T1,%e0\;mov.w %T1,%f0\";
455 default:
456 abort ();
457 }
458 }"
459 [(set (attr "length")
460 (symbol_ref "compute_mov_length (operands)"))
461 (set_attr "cc" "clobber")])
462
463 (define_insn "*movsf_h8300"
464 [(set (match_operand:SF 0 "general_operand_dst" "=r,r,r,o,<,r")
465 (match_operand:SF 1 "general_operand_src" "G,r,io,r,r,>"))]
466 "TARGET_H8300
467 && (register_operand (operands[0], SFmode)
468 || register_operand (operands[1], SFmode))"
469 "*
470 {
471 /* Copy of the movsi stuff. */
472 unsigned int rn = -1;
473 switch (which_alternative)
474 {
475 case 0:
476 return \"sub.w %e0,%e0\;sub.w %f0,%f0\";
477 case 1:
478 if (REGNO (operands[0]) < REGNO (operands[1]))
479 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
480 else
481 return \"mov.w %f1,%f0\;mov.w %e1,%e0\";
482 case 2:
483 /* Make sure we don't trample the register we index with. */
484 if (GET_CODE (operands[1]) == MEM)
485 {
486 rtx inside = XEXP (operands[1], 0);
487 if (REG_P (inside))
488 {
489 rn = REGNO (inside);
490 }
491 else if (GET_CODE (inside) == PLUS)
492 {
493 rtx lhs = XEXP (inside, 0);
494 rtx rhs = XEXP (inside, 1);
495 if (REG_P (lhs)) rn = REGNO (lhs);
496 if (REG_P (rhs)) rn = REGNO (rhs);
497 }
498 }
499 if (rn == REGNO (operands[0]))
500 /* Move the second word first. */
501 return \"mov.w %f1,%f0\;mov.w %e1,%e0\";
502 else
503 /* Move the first word first. */
504 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
505
506 case 3:
507 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
508 case 4:
509 return \"mov.w %f1,%T0\;mov.w %e1,%T0\";
510 case 5:
511 return \"mov.w %T1,%e0\;mov.w %T1,%f0\";
512 default:
513 abort ();
514 }
515 }"
516 [(set (attr "length")
517 (symbol_ref "compute_mov_length (operands)"))
518 (set_attr "cc" "clobber")])
519
520 (define_insn "*movsi_h8300hs"
521 [(set (match_operand:SI 0 "general_operand_dst" "=r,r,r,<,r,r,m,*a,*a,r")
522 (match_operand:SI 1 "general_operand_src" "I,r,i,r,>,m,r,I,r,*a"))]
523 "(TARGET_H8300S || TARGET_H8300H)
524 && (register_operand (operands[0], SImode)
525 || register_operand (operands[1], SImode))
526 && !(GET_CODE (operands[0]) == MEM
527 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
528 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
529 && GET_CODE (operands[1]) == REG
530 && REGNO (XEXP (XEXP (operands[0], 0), 0)) == REGNO (operands[1]))"
531 "*
532 {
533 switch (which_alternative)
534 {
535 case 0:
536 return \"sub.l %S0,%S0\";
537 case 7:
538 return \"clrmac\";
539 case 8:
540 return \"clrmac\;ldmac %1,macl\";
541 case 9:
542 return \"stmac macl,%0\";
543 default:
544 if (GET_CODE (operands[1]) == CONST_INT)
545 {
546 int val = INTVAL (operands[1]);
547
548 /* Look for constants which can be made by adding an 8-bit
549 number to zero in one of the two low bytes. */
550 if (val == (val & 0xff))
551 {
552 operands[1] = GEN_INT ((char) val & 0xff);
553 return \"sub.l\\t%S0,%S0\;add.b\\t%1,%w0\";
554 }
555
556 if (val == (val & 0xff00))
557 {
558 operands[1] = GEN_INT ((char) (val >> 8) & 0xff);
559 return \"sub.l\\t%S0,%S0\;add.b\\t%1,%x0\";
560 }
561
562 /* Look for constants that can be obtained by subs, inc, and
563 dec to 0. */
564 switch (val & 0xffffffff)
565 {
566 case 0xffffffff:
567 return \"sub.l\\t%S0,%S0\;subs\\t#1,%S0\";
568 case 0xfffffffe:
569 return \"sub.l\\t%S0,%S0\;subs\\t#2,%S0\";
570 case 0xfffffffc:
571 return \"sub.l\\t%S0,%S0\;subs\\t#4,%S0\";
572
573 case 0x0000ffff:
574 return \"sub.l\\t%S0,%S0\;dec.w\\t#1,%f0\";
575 case 0x0000fffe:
576 return \"sub.l\\t%S0,%S0\;dec.w\\t#2,%f0\";
577
578 case 0xffff0000:
579 return \"sub.l\\t%S0,%S0\;dec.w\\t#1,%e0\";
580 case 0xfffe0000:
581 return \"sub.l\\t%S0,%S0\;dec.w\\t#2,%e0\";
582
583 case 0x00010000:
584 return \"sub.l\\t%S0,%S0\;inc.w\\t#1,%e0\";
585 case 0x00020000:
586 return \"sub.l\\t%S0,%S0\;inc.w\\t#2,%e0\";
587 }
588 }
589 }
590 return \"mov.l %S1,%S0\";
591 }"
592 [(set (attr "length")
593 (symbol_ref "compute_mov_length (operands)"))
594 (set_attr "cc" "set_zn,set_znv,clobber,set_znv,set_znv,set_znv,set_znv,none_0hit,none_0hit,set_znv")])
595
596 (define_insn "*movsf_h8300hs"
597 [(set (match_operand:SF 0 "general_operand_dst" "=r,r,r,m,<,r")
598 (match_operand:SF 1 "general_operand_src" "G,r,im,r,r,>"))]
599 "(TARGET_H8300H || TARGET_H8300S)
600 && (register_operand (operands[0], SFmode)
601 || register_operand (operands[1], SFmode))"
602 "@
603 sub.l %S0,%S0
604 mov.l %S1,%S0
605 mov.l %S1,%S0
606 mov.l %S1,%S0
607 mov.l %S1,%S0
608 mov.l %S1,%S0"
609 [(set (attr "length")
610 (symbol_ref "compute_mov_length (operands)"))
611 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
612 \f
613 ;; ----------------------------------------------------------------------
614 ;; TEST INSTRUCTIONS
615 ;; ----------------------------------------------------------------------
616
617 (define_insn ""
618 [(set (cc0) (zero_extract:HI (match_operand:QI 0 "bit_memory_operand" "r,U")
619 (const_int 1)
620 (match_operand 1 "const_int_operand" "n,n")))]
621 "TARGET_H8300"
622 "btst %Z1,%Y0"
623 [(set_attr "length" "2,4")
624 (set_attr "cc" "set_zn,set_zn")])
625
626 (define_insn ""
627 [(set (cc0) (zero_extract:HI (match_operand:HI 0 "register_operand" "r")
628 (const_int 1)
629 (match_operand 1 "const_int_operand" "n")))]
630 "TARGET_H8300"
631 "btst %Z1,%Y0"
632 [(set_attr "length" "2")
633 (set_attr "cc" "set_zn")])
634
635 (define_insn_and_split "*tst_extzv_1_n"
636 [(set (cc0)
637 (zero_extract:SI (match_operand:QI 0 "general_operand_src" "r,U,mn>")
638 (const_int 1)
639 (match_operand 1 "const_int_operand" "n,n,n")))
640 (clobber (match_scratch:QI 2 "=X,X,&r"))]
641 "(TARGET_H8300H || TARGET_H8300S)"
642 "@
643 btst\\t%Z1,%Y0
644 btst\\t%Z1,%Y0
645 #"
646 "&& reload_completed
647 && !EXTRA_CONSTRAINT (operands[0], 'U')"
648 [(set (match_dup 2)
649 (match_dup 0))
650 (parallel [(set (cc0) (zero_extract:SI (match_dup 2)
651 (const_int 1)
652 (match_dup 1)))
653 (clobber (scratch:QI))])]
654 ""
655 [(set_attr "length" "2,8,10")
656 (set_attr "cc" "set_zn,set_zn,set_zn")])
657
658 (define_insn ""
659 [(set (cc0) (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
660 (const_int 1)
661 (match_operand 1 "const_int_operand" "n")))]
662 "(TARGET_H8300H || TARGET_H8300S)
663 && INTVAL (operands[1]) <= 15"
664 "btst %Z1,%Y0"
665 [(set_attr "length" "2")
666 (set_attr "cc" "set_zn")])
667
668 (define_insn_and_split "*tstsi_upper_bit"
669 [(set (cc0)
670 (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
671 (const_int 1)
672 (match_operand 1 "const_int_operand" "n")))
673 (clobber (match_scratch:SI 2 "=&r"))]
674 "(TARGET_H8300H || TARGET_H8300S)
675 && INTVAL (operands[1]) >= 16"
676 "#"
677 "&& reload_completed"
678 [(set (match_dup 2)
679 (ior:SI (and:SI (match_dup 2)
680 (const_int -65536))
681 (lshiftrt:SI (match_dup 0)
682 (const_int 16))))
683 (set (cc0)
684 (zero_extract:SI (match_dup 2)
685 (const_int 1)
686 (match_dup 3)))]
687 "operands[3] = GEN_INT (INTVAL (operands[1]) - 16);")
688
689 (define_insn "*tstsi_variable_bit"
690 [(set (cc0)
691 (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
692 (const_int 1)
693 (and:SI (match_operand:SI 1 "register_operand" "r")
694 (const_int 7))))]
695 "TARGET_H8300H || TARGET_H8300S"
696 "btst %w1,%w0"
697 [(set_attr "length" "2")
698 (set_attr "cc" "set_zn")])
699
700 (define_insn_and_split "*tstsi_variable_bit_qi"
701 [(set (cc0)
702 (zero_extract:SI (zero_extend:SI (match_operand:QI 0 "general_operand_src" "r,U,mn>"))
703 (const_int 1)
704 (and:SI (match_operand:SI 1 "register_operand" "r,r,r")
705 (const_int 7))))
706 (clobber (match_scratch:QI 2 "=X,X,&r"))]
707 "(TARGET_H8300H || TARGET_H8300S)"
708 "@
709 btst\\t%w1,%X0
710 btst\\t%w1,%X0
711 #"
712 "&& reload_completed
713 && !EXTRA_CONSTRAINT (operands[0], 'U')"
714 [(set (match_dup 2)
715 (match_dup 0))
716 (parallel [(set (cc0) (zero_extract:SI (zero_extend:SI (match_dup 2))
717 (const_int 1)
718 (and:SI (match_dup 1)
719 (const_int 7))))
720 (clobber (scratch:QI))])]
721 ""
722 [(set_attr "length" "2,8,10")
723 (set_attr "cc" "set_zn,set_zn,set_zn")])
724
725 (define_insn "tstqi"
726 [(set (cc0) (match_operand:QI 0 "register_operand" "r"))]
727 ""
728 "mov.b %X0,%X0"
729 [(set_attr "length" "2")
730 (set_attr "cc" "set_znv")])
731
732 (define_insn "tsthi"
733 [(set (cc0) (match_operand:HI 0 "register_operand" "r"))]
734 ""
735 "mov.w %T0,%T0"
736 [(set_attr "length" "2")
737 (set_attr "cc" "set_znv")])
738
739 (define_insn "*tsthi_upper"
740 [(set (cc0)
741 (and:HI (match_operand:HI 0 "register_operand" "r")
742 (const_int -256)))]
743 ""
744 "mov.b %t0,%t0"
745 [(set_attr "length" "2")
746 (set_attr "cc" "set_znv")])
747
748 (define_insn "tstsi"
749 [(set (cc0) (match_operand:SI 0 "register_operand" "r"))]
750 "TARGET_H8300H || TARGET_H8300S"
751 "mov.l %S0,%S0"
752 [(set_attr "length" "2")
753 (set_attr "cc" "set_znv")])
754
755 (define_insn "*tstsi_upper"
756 [(set (cc0)
757 (and:SI (match_operand:SI 0 "register_operand" "r")
758 (const_int -65536)))]
759 ""
760 "mov.w %e0,%e0"
761 [(set_attr "length" "2")
762 (set_attr "cc" "set_znv")])
763
764 (define_insn "cmpqi"
765 [(set (cc0)
766 (compare (match_operand:QI 0 "register_operand" "r")
767 (match_operand:QI 1 "nonmemory_operand" "rn")))]
768 ""
769 "cmp.b %X1,%X0"
770 [(set_attr "length" "2")
771 (set_attr "cc" "compare")])
772
773 (define_expand "cmphi"
774 [(set (cc0)
775 (compare (match_operand:HI 0 "register_operand" "")
776 (match_operand:HI 1 "nonmemory_operand" "")))]
777 ""
778 "
779 {
780 /* Force operand1 into a register if we're compiling
781 for the H8/300. */
782 if (GET_CODE (operands[1]) != REG && TARGET_H8300)
783 operands[1] = force_reg (HImode, operands[1]);
784 }")
785
786 (define_insn "*cmphi_h8300"
787 [(set (cc0)
788 (compare (match_operand:HI 0 "register_operand" "r")
789 (match_operand:HI 1 "register_operand" "r")))]
790 "TARGET_H8300"
791 "cmp.w %T1,%T0"
792 [(set_attr "length" "2")
793 (set_attr "cc" "compare")])
794
795 (define_insn "*cmphi_h8300hs"
796 [(set (cc0)
797 (compare (match_operand:HI 0 "register_operand" "r,r")
798 (match_operand:HI 1 "nonmemory_operand" "r,n")))]
799 "TARGET_H8300H || TARGET_H8300S"
800 "cmp.w %T1,%T0"
801 [(set_attr "length" "2,4")
802 (set_attr "cc" "compare,compare")])
803
804 (define_insn "cmpsi"
805 [(set (cc0)
806 (compare (match_operand:SI 0 "register_operand" "r,r")
807 (match_operand:SI 1 "nonmemory_operand" "r,i")))]
808 "TARGET_H8300H || TARGET_H8300S"
809 "cmp.l %S1,%S0"
810 [(set_attr "length" "2,6")
811 (set_attr "cc" "compare,compare")])
812 \f
813 ;; ----------------------------------------------------------------------
814 ;; ADD INSTRUCTIONS
815 ;; ----------------------------------------------------------------------
816
817 (define_insn "addqi3"
818 [(set (match_operand:QI 0 "register_operand" "=r")
819 (plus:QI (match_operand:QI 1 "register_operand" "%0")
820 (match_operand:QI 2 "nonmemory_operand" "rn")))]
821 ""
822 "add.b %X2,%X0"
823 [(set_attr "length" "2")
824 (set_attr "cc" "set_zn")])
825
826 (define_expand "addhi3"
827 [(set (match_operand:HI 0 "register_operand" "")
828 (plus:HI (match_operand:HI 1 "register_operand" "")
829 (match_operand:HI 2 "nonmemory_operand" "")))]
830 ""
831 "")
832
833 (define_insn "*addhi3_h8300"
834 [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r")
835 (plus:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0")
836 (match_operand:HI 2 "nonmemory_operand" "L,N,J,n,r")))]
837 "TARGET_H8300"
838 "@
839 adds %2,%T0
840 subs %G2,%T0
841 add.b %t2,%t0
842 add.b %s2,%s0\;addx %t2,%t0
843 add.w %T2,%T0"
844 [(set_attr "length" "2,2,2,4,2")
845 (set_attr "cc" "none_0hit,none_0hit,clobber,clobber,set_zn")])
846
847 ;; This splitter is very important to make the stack adjustment
848 ;; interrupt-safe. The combination of add.b and addx is unsafe!
849 ;;
850 ;; We apply this split after the peephole2 pass so that we won't end
851 ;; up creating too many adds/subs when a scratch register is
852 ;; available, which is actually a common case because stack unrolling
853 ;; tends to happen immediately after a function call.
854
855 (define_split
856 [(set (match_operand:HI 0 "stack_pointer_operand" "")
857 (plus:HI (match_dup 0)
858 (match_operand 1 "const_int_gt_2_operand" "")))]
859 "TARGET_H8300 && flow2_completed"
860 [(const_int 0)]
861 "split_adds_subs (HImode, operands); DONE;")
862
863 (define_peephole2
864 [(match_scratch:HI 2 "r")
865 (set (match_operand:HI 0 "stack_pointer_operand" "")
866 (plus:HI (match_dup 0)
867 (match_operand:HI 1 "const_int_ge_8_operand" "")))]
868 "TARGET_H8300"
869 [(set (match_dup 2)
870 (match_dup 1))
871 (set (match_dup 0)
872 (plus:HI (match_dup 0)
873 (match_dup 2)))]
874 "")
875
876 (define_insn "*addhi3_h8300hs"
877 [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r")
878 (plus:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0")
879 (match_operand:HI 2 "nonmemory_operand" "L,N,J,n,r")))]
880 "TARGET_H8300H || TARGET_H8300S"
881 "@
882 adds %2,%S0
883 subs %G2,%S0
884 add.b %t2,%t0
885 add.w %T2,%T0
886 add.w %T2,%T0"
887 [(set_attr "length" "2,2,2,4,2")
888 (set_attr "cc" "none_0hit,none_0hit,clobber,set_zn,set_zn")])
889
890 (define_insn "*addhi3_incdec"
891 [(set (match_operand:HI 0 "register_operand" "=r,r")
892 (unspec:HI [(match_operand:HI 1 "register_operand" "0,0")
893 (match_operand:HI 2 "incdec_operand" "M,O")]
894 UNSPEC_INCDEC))]
895 "TARGET_H8300H || TARGET_H8300S"
896 "@
897 inc.w %2,%T0
898 dec.w %G2,%T0"
899 [(set_attr "length" "2,2")
900 (set_attr "cc" "set_zn,set_zn")])
901
902 (define_split
903 [(set (match_operand:HI 0 "register_operand" "")
904 (plus:HI (match_dup 0)
905 (match_operand:HI 1 "two_insn_adds_subs_operand" "")))]
906 ""
907 [(const_int 0)]
908 "split_adds_subs (HImode, operands); DONE;")
909
910 (define_expand "addsi3"
911 [(set (match_operand:SI 0 "register_operand" "")
912 (plus:SI (match_operand:SI 1 "register_operand" "")
913 (match_operand:SI 2 "nonmemory_operand" "")))]
914 ""
915 "")
916
917 (define_insn "*addsi_h8300"
918 [(set (match_operand:SI 0 "register_operand" "=r,r")
919 (plus:SI (match_operand:SI 1 "register_operand" "%0,0")
920 (match_operand:SI 2 "nonmemory_operand" "n,r")))]
921 "TARGET_H8300"
922 "* return output_plussi (operands);"
923 [(set (attr "length")
924 (symbol_ref "compute_plussi_length (operands)"))
925 (set (attr "cc")
926 (symbol_ref "compute_plussi_cc (operands)"))])
927
928 (define_insn "*addsi_h8300hs"
929 [(set (match_operand:SI 0 "register_operand" "=r,r")
930 (plus:SI (match_operand:SI 1 "register_operand" "%0,0")
931 (match_operand:SI 2 "nonmemory_operand" "i,r")))]
932 "TARGET_H8300H || TARGET_H8300S"
933 "* return output_plussi (operands);"
934 [(set (attr "length")
935 (symbol_ref "compute_plussi_length (operands)"))
936 (set (attr "cc")
937 (symbol_ref "compute_plussi_cc (operands)"))])
938
939 (define_insn "*addsi3_incdec"
940 [(set (match_operand:SI 0 "register_operand" "=r,r")
941 (unspec:SI [(match_operand:SI 1 "register_operand" "0,0")
942 (match_operand:SI 2 "incdec_operand" "M,O")]
943 UNSPEC_INCDEC))]
944 "TARGET_H8300H || TARGET_H8300S"
945 "@
946 inc.l %2,%S0
947 dec.l %G2,%S0"
948 [(set_attr "length" "2,2")
949 (set_attr "cc" "set_zn,set_zn")])
950
951 (define_split
952 [(set (match_operand:SI 0 "register_operand" "")
953 (plus:SI (match_dup 0)
954 (match_operand:SI 1 "two_insn_adds_subs_operand" "")))]
955 "TARGET_H8300H || TARGET_H8300S"
956 [(const_int 0)]
957 "split_adds_subs (SImode, operands); DONE;")
958
959 ;; ----------------------------------------------------------------------
960 ;; SUBTRACT INSTRUCTIONS
961 ;; ----------------------------------------------------------------------
962
963 (define_insn "subqi3"
964 [(set (match_operand:QI 0 "register_operand" "=r")
965 (minus:QI (match_operand:QI 1 "register_operand" "0")
966 (match_operand:QI 2 "register_operand" "r")))]
967 ""
968 "sub.b %X2,%X0"
969 [(set_attr "length" "2")
970 (set_attr "cc" "set_zn")])
971
972 (define_expand "subhi3"
973 [(set (match_operand:HI 0 "register_operand" "")
974 (minus:HI (match_operand:HI 1 "general_operand" "")
975 (match_operand:HI 2 "nonmemory_operand" "")))]
976 ""
977 "")
978
979 (define_insn "*subhi3_h8300"
980 [(set (match_operand:HI 0 "register_operand" "=r,r")
981 (minus:HI (match_operand:HI 1 "general_operand" "0,0")
982 (match_operand:HI 2 "nonmemory_operand" "r,n")))]
983 "TARGET_H8300"
984 "@
985 sub.w %T2,%T0
986 add.b %E2,%s0\;addx %F2,%t0"
987 [(set_attr "length" "2,4")
988 (set_attr "cc" "set_zn,clobber")])
989
990 (define_insn "*subhi3_h8300hs"
991 [(set (match_operand:HI 0 "register_operand" "=r,r")
992 (minus:HI (match_operand:HI 1 "general_operand" "0,0")
993 (match_operand:HI 2 "nonmemory_operand" "r,n")))]
994 "TARGET_H8300H || TARGET_H8300S"
995 "@
996 sub.w %T2,%T0
997 sub.w %T2,%T0"
998 [(set_attr "length" "2,4")
999 (set_attr "cc" "set_zn,set_zn")])
1000
1001 (define_expand "subsi3"
1002 [(set (match_operand:SI 0 "register_operand" "")
1003 (minus:SI (match_operand:SI 1 "register_operand" "")
1004 (match_operand:SI 2 "nonmemory_operand" "")))]
1005 ""
1006 "")
1007
1008 (define_insn "*subsi3_h8300"
1009 [(set (match_operand:SI 0 "register_operand" "=r")
1010 (minus:SI (match_operand:SI 1 "register_operand" "0")
1011 (match_operand:SI 2 "register_operand" "r")))]
1012 "TARGET_H8300"
1013 "sub.w %f2,%f0\;subx %y2,%y0\;subx %z2,%z0"
1014 [(set_attr "length" "6")
1015 (set_attr "cc" "clobber")])
1016
1017 (define_insn "*subsi3_h8300hs"
1018 [(set (match_operand:SI 0 "register_operand" "=r,r")
1019 (minus:SI (match_operand:SI 1 "general_operand" "0,0")
1020 (match_operand:SI 2 "nonmemory_operand" "r,i")))]
1021 "TARGET_H8300H || TARGET_H8300S"
1022 "@
1023 sub.l %S2,%S0
1024 sub.l %S2,%S0"
1025 [(set_attr "length" "2,6")
1026 (set_attr "cc" "set_zn,set_zn")])
1027 \f
1028 ;; ----------------------------------------------------------------------
1029 ;; MULTIPLY INSTRUCTIONS
1030 ;; ----------------------------------------------------------------------
1031
1032 ;; Note that the H8/300 can only handle umulqihi3.
1033
1034 (define_insn "mulqihi3"
1035 [(set (match_operand:HI 0 "register_operand" "=r")
1036 (mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "%0"))
1037 (sign_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
1038 "TARGET_H8300H || TARGET_H8300S"
1039 "mulxs.b %X2,%T0"
1040 [(set_attr "length" "4")
1041 (set_attr "cc" "set_zn")])
1042
1043 (define_insn "mulhisi3"
1044 [(set (match_operand:SI 0 "register_operand" "=r")
1045 (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" "%0"))
1046 (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
1047 "TARGET_H8300H || TARGET_H8300S"
1048 "mulxs.w %T2,%S0"
1049 [(set_attr "length" "4")
1050 (set_attr "cc" "set_zn")])
1051
1052 (define_insn "umulqihi3"
1053 [(set (match_operand:HI 0 "register_operand" "=r")
1054 (mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "%0"))
1055 (zero_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
1056 ""
1057 "mulxu %X2,%T0"
1058 [(set_attr "length" "2")
1059 (set_attr "cc" "none_0hit")])
1060
1061 (define_insn "umulhisi3"
1062 [(set (match_operand:SI 0 "register_operand" "=r")
1063 (mult:SI (zero_extend:SI (match_operand:HI 1 "register_operand" "%0"))
1064 (zero_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
1065 "TARGET_H8300H || TARGET_H8300S"
1066 "mulxu.w %T2,%S0"
1067 [(set_attr "length" "2")
1068 (set_attr "cc" "none_0hit")])
1069
1070 ;; This is a "bridge" instruction. Combine can't cram enough insns
1071 ;; together to crate a MAC instruction directly, but it can create
1072 ;; this instruction, which then allows combine to create the real
1073 ;; MAC insn.
1074 ;;
1075 ;; Unfortunately, if combine doesn't create a MAC instruction, this
1076 ;; insn must generate reasonably correct code. Egad.
1077 (define_insn ""
1078 [(set (match_operand:SI 0 "register_operand" "=a")
1079 (mult:SI
1080 (sign_extend:SI
1081 (mem:HI (post_inc:SI (match_operand:SI 1 "register_operand" "r"))))
1082 (sign_extend:SI
1083 (mem:HI (post_inc:SI (match_operand:SI 2 "register_operand" "r"))))))]
1084 "TARGET_MAC"
1085 "clrmac\;mac @%2+,@%1+"
1086 [(set_attr "length" "6")
1087 (set_attr "cc" "none_0hit")])
1088
1089 (define_insn ""
1090 [(set (match_operand:SI 0 "register_operand" "=a")
1091 (plus:SI (mult:SI
1092 (sign_extend:SI (mem:HI
1093 (post_inc:SI (match_operand:SI 1 "register_operand" "r"))))
1094 (sign_extend:SI (mem:HI
1095 (post_inc:SI (match_operand:SI 2 "register_operand" "r")))))
1096 (match_operand:SI 3 "register_operand" "0")))]
1097 "TARGET_MAC"
1098 "mac @%2+,@%1+"
1099 [(set_attr "length" "4")
1100 (set_attr "cc" "none_0hit")])
1101
1102 ;; ----------------------------------------------------------------------
1103 ;; DIVIDE/MOD INSTRUCTIONS
1104 ;; ----------------------------------------------------------------------
1105
1106 (define_insn "udivmodqi4"
1107 [(set (match_operand:QI 0 "register_operand" "=r")
1108 (truncate:QI
1109 (udiv:HI
1110 (match_operand:HI 1 "register_operand" "0")
1111 (zero_extend:HI (match_operand:QI 2 "register_operand" "r")))))
1112 (set (match_operand:QI 3 "register_operand" "=r")
1113 (truncate:QI
1114 (umod:HI
1115 (match_dup 1)
1116 (zero_extend:HI (match_dup 2)))))]
1117 ""
1118 "*
1119 {
1120 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1121 return \"divxu.b\\t%X2,%T0\";
1122 else
1123 return \"divxu.b\\t%X2,%T0\;mov.b\\t%t0,%s3\";
1124 }"
1125 [(set_attr "length" "4")
1126 (set_attr "cc" "clobber")])
1127
1128 (define_insn "divmodqi4"
1129 [(set (match_operand:QI 0 "register_operand" "=r")
1130 (truncate:QI
1131 (div:HI
1132 (match_operand:HI 1 "register_operand" "0")
1133 (sign_extend:HI (match_operand:QI 2 "register_operand" "r")))))
1134 (set (match_operand:QI 3 "register_operand" "=r")
1135 (truncate:QI
1136 (mod:HI
1137 (match_dup 1)
1138 (sign_extend:HI (match_dup 2)))))]
1139 "TARGET_H8300H || TARGET_H8300S"
1140 "*
1141 {
1142 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1143 return \"divxs.b\\t%X2,%T0\";
1144 else
1145 return \"divxs.b\\t%X2,%T0\;mov.b\\t%t0,%s3\";
1146 }"
1147 [(set_attr "length" "6")
1148 (set_attr "cc" "clobber")])
1149
1150 (define_insn "udivmodhi4"
1151 [(set (match_operand:HI 0 "register_operand" "=r")
1152 (truncate:HI
1153 (udiv:SI
1154 (match_operand:SI 1 "register_operand" "0")
1155 (zero_extend:SI (match_operand:HI 2 "register_operand" "r")))))
1156 (set (match_operand:HI 3 "register_operand" "=r")
1157 (truncate:HI
1158 (umod:SI
1159 (match_dup 1)
1160 (zero_extend:SI (match_dup 2)))))]
1161 "TARGET_H8300H || TARGET_H8300S"
1162 "*
1163 {
1164 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1165 return \"divxu.w\\t%T2,%S0\";
1166 else
1167 return \"divxu.w\\t%T2,%S0\;mov.w\\t%e0,%f3\";
1168 }"
1169 [(set_attr "length" "4")
1170 (set_attr "cc" "clobber")])
1171
1172 (define_insn "divmodhi4"
1173 [(set (match_operand:HI 0 "register_operand" "=r")
1174 (truncate:HI
1175 (div:SI
1176 (match_operand:SI 1 "register_operand" "0")
1177 (sign_extend:SI (match_operand:HI 2 "register_operand" "r")))))
1178 (set (match_operand:HI 3 "register_operand" "=r")
1179 (truncate:HI
1180 (mod:SI
1181 (match_dup 1)
1182 (sign_extend:SI (match_dup 2)))))]
1183 "TARGET_H8300H || TARGET_H8300S"
1184 "*
1185 {
1186 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1187 return \"divxs.w\\t%T2,%S0\";
1188 else
1189 return \"divxs.w\\t%T2,%S0\;mov.w\\t%e0,%f3\";
1190 }"
1191 [(set_attr "length" "6")
1192 (set_attr "cc" "clobber")])
1193 \f
1194 ;; ----------------------------------------------------------------------
1195 ;; AND INSTRUCTIONS
1196 ;; ----------------------------------------------------------------------
1197
1198 (define_insn "*andqi3_1"
1199 [(set (match_operand:QI 0 "bit_operand" "=r,U")
1200 (and:QI (match_operand:QI 1 "bit_operand" "%0,0")
1201 (match_operand:QI 2 "nonmemory_operand" "rn,n")))]
1202 "register_operand (operands[0], QImode)
1203 || single_zero_operand (operands[2], QImode)"
1204 "@
1205 and %X2,%X0
1206 bclr %W2,%R0"
1207 [(set_attr "length" "2,8")
1208 (set_attr "cc" "set_znv,none_0hit")])
1209
1210 (define_expand "andqi3"
1211 [(set (match_operand:QI 0 "bit_operand" "")
1212 (and:QI (match_operand:QI 1 "bit_operand" "")
1213 (match_operand:QI 2 "nonmemory_operand" "")))]
1214 ""
1215 "
1216 {
1217 if (fix_bit_operand (operands, 0, AND))
1218 DONE;
1219 }")
1220
1221 (define_expand "andhi3"
1222 [(set (match_operand:HI 0 "register_operand" "")
1223 (and:HI (match_operand:HI 1 "register_operand" "")
1224 (match_operand:HI 2 "nonmemory_operand" "")))]
1225 ""
1226 "")
1227
1228 (define_insn "*andorqi3"
1229 [(set (match_operand:QI 0 "register_operand" "=r")
1230 (ior:QI (and:QI (match_operand:QI 2 "register_operand" "r")
1231 (match_operand:QI 3 "single_one_operand" "n"))
1232 (match_operand:QI 1 "register_operand" "0")))]
1233 ""
1234 "bld\\t%V3,%X2\;bor\\t%V3,%X0\;bst\\t%V3,%X0"
1235 [(set_attr "length" "6")
1236 (set_attr "cc" "clobber")])
1237
1238 (define_insn "*andorhi3"
1239 [(set (match_operand:HI 0 "register_operand" "=r")
1240 (ior:HI (and:HI (match_operand:HI 2 "register_operand" "r")
1241 (match_operand:HI 3 "single_one_operand" "n"))
1242 (match_operand:HI 1 "register_operand" "0")))]
1243 ""
1244 "*
1245 {
1246 operands[3] = GEN_INT (INTVAL (operands[3]) & 0xffff);
1247 if (INTVAL (operands[3]) > 128)
1248 {
1249 operands[3] = GEN_INT (INTVAL (operands[3]) >> 8);
1250 return \"bld\\t%V3,%t2\;bor\\t%V3,%t0\;bst\\t%V3,%t0\";
1251 }
1252 return \"bld\\t%V3,%s2\;bor\\t%V3,%s0\;bst\\t%V3,%s0\";
1253 }"
1254 [(set_attr "length" "6")
1255 (set_attr "cc" "clobber")])
1256
1257 (define_insn "*andorsi3"
1258 [(set (match_operand:SI 0 "register_operand" "=r")
1259 (ior:SI (and:SI (match_operand:SI 2 "register_operand" "r")
1260 (match_operand:SI 3 "single_one_operand" "n"))
1261 (match_operand:SI 1 "register_operand" "0")))]
1262 "(INTVAL (operands[3]) & 0xffff) != 0"
1263 "*
1264 {
1265 operands[3] = GEN_INT (INTVAL (operands[3]) & 0xffff);
1266 if (INTVAL (operands[3]) > 128)
1267 {
1268 operands[3] = GEN_INT (INTVAL (operands[3]) >> 8);
1269 return \"bld\\t%V3,%x2\;bor\\t%V3,%x0\;bst\\t%V3,%x0\";
1270 }
1271 return \"bld\\t%V3,%w2\;bor\\t%V3,%w0\;bst\\t%V3,%w0\";
1272 }"
1273 [(set_attr "length" "6")
1274 (set_attr "cc" "clobber")])
1275
1276 (define_insn "*andorsi3_shift_8"
1277 [(set (match_operand:SI 0 "register_operand" "=r")
1278 (ior:SI (and:SI (ashift:SI (match_operand:SI 2 "register_operand" "r")
1279 (const_int 8))
1280 (const_int 65280))
1281 (match_operand:SI 1 "register_operand" "0")))]
1282 ""
1283 "or.b\\t%w2,%x0"
1284 [(set_attr "length" "2")
1285 (set_attr "cc" "clobber")])
1286
1287 (define_expand "andsi3"
1288 [(set (match_operand:SI 0 "register_operand" "")
1289 (and:SI (match_operand:SI 1 "register_operand" "")
1290 (match_operand:SI 2 "nonmemory_operand" "")))]
1291 ""
1292 "")
1293
1294 ;; ----------------------------------------------------------------------
1295 ;; OR INSTRUCTIONS
1296 ;; ----------------------------------------------------------------------
1297
1298 (define_insn "*iorqi3_1"
1299 [(set (match_operand:QI 0 "bit_operand" "=r,U")
1300 (ior:QI (match_operand:QI 1 "bit_operand" "%0,0")
1301 (match_operand:QI 2 "nonmemory_operand" "rn,n")))]
1302 "register_operand (operands[0], QImode)
1303 || single_one_operand (operands[2], QImode)"
1304 "@
1305 or\\t%X2,%X0
1306 bset\\t%V2,%R0"
1307 [(set_attr "length" "2,8")
1308 (set_attr "cc" "set_znv,none_0hit")])
1309
1310 (define_expand "iorqi3"
1311 [(set (match_operand:QI 0 "bit_operand" "")
1312 (ior:QI (match_operand:QI 1 "bit_operand" "")
1313 (match_operand:QI 2 "nonmemory_operand" "")))]
1314 ""
1315 "
1316 {
1317 if (fix_bit_operand (operands, 1, IOR))
1318 DONE;
1319 }")
1320
1321 (define_expand "iorhi3"
1322 [(set (match_operand:HI 0 "register_operand" "")
1323 (ior:HI (match_operand:HI 1 "register_operand" "")
1324 (match_operand:HI 2 "nonmemory_operand" "")))]
1325 ""
1326 "")
1327
1328 (define_expand "iorsi3"
1329 [(set (match_operand:SI 0 "register_operand" "")
1330 (ior:SI (match_operand:SI 1 "register_operand" "")
1331 (match_operand:SI 2 "nonmemory_operand" "")))]
1332 ""
1333 "")
1334
1335 ;; ----------------------------------------------------------------------
1336 ;; XOR INSTRUCTIONS
1337 ;; ----------------------------------------------------------------------
1338
1339 (define_insn "*xorqi3_1"
1340 [(set (match_operand:QI 0 "bit_operand" "=r,U")
1341 (xor:QI (match_operand:QI 1 "bit_operand" "%0,0")
1342 (match_operand:QI 2 "nonmemory_operand" "rn,n")))]
1343 "register_operand (operands[0], QImode)
1344 || single_one_operand (operands[2], QImode)"
1345 "@
1346 xor\\t%X2,%X0
1347 bnot\\t%V2,%R0"
1348 [(set_attr "length" "2,8")
1349 (set_attr "cc" "set_znv,none_0hit")])
1350
1351 (define_expand "xorqi3"
1352 [(set (match_operand:QI 0 "bit_operand" "")
1353 (xor:QI (match_operand:QI 1 "bit_operand" "")
1354 (match_operand:QI 2 "nonmemory_operand" "")))]
1355 ""
1356 "
1357 {
1358 if (fix_bit_operand (operands, 1, XOR))
1359 DONE;
1360 }")
1361
1362 (define_expand "xorhi3"
1363 [(set (match_operand:HI 0 "register_operand" "")
1364 (xor:HI (match_operand:HI 1 "register_operand" "")
1365 (match_operand:HI 2 "nonmemory_operand" "")))]
1366 ""
1367 "")
1368
1369 (define_expand "xorsi3"
1370 [(set (match_operand:SI 0 "register_operand" "")
1371 (xor:SI (match_operand:SI 1 "register_operand" "")
1372 (match_operand:SI 2 "nonmemory_operand" "")))]
1373 ""
1374 "")
1375
1376 ;; ----------------------------------------------------------------------
1377 ;; {AND,IOR,XOR}{HI3,SI3} PATTERNS
1378 ;; ----------------------------------------------------------------------
1379
1380 (define_insn "*logicalhi3"
1381 [(set (match_operand:HI 0 "register_operand" "=r")
1382 (match_operator:HI 3 "bit_operator"
1383 [(match_operand:HI 1 "register_operand" "%0")
1384 (match_operand:HI 2 "nonmemory_operand" "rn")]))]
1385 ""
1386 "* return output_logical_op (HImode, operands);"
1387 [(set (attr "length")
1388 (symbol_ref "compute_logical_op_length (HImode, operands)"))
1389 (set (attr "cc")
1390 (symbol_ref "compute_logical_op_cc (HImode, operands)"))])
1391
1392 (define_insn "*logicalsi3"
1393 [(set (match_operand:SI 0 "register_operand" "=r")
1394 (match_operator:SI 3 "bit_operator"
1395 [(match_operand:SI 1 "register_operand" "%0")
1396 (match_operand:SI 2 "nonmemory_operand" "rn")]))]
1397 ""
1398 "* return output_logical_op (SImode, operands);"
1399 [(set (attr "length")
1400 (symbol_ref "compute_logical_op_length (SImode, operands)"))
1401 (set (attr "cc")
1402 (symbol_ref "compute_logical_op_cc (SImode, operands)"))])
1403 \f
1404 ;; ----------------------------------------------------------------------
1405 ;; NEGATION INSTRUCTIONS
1406 ;; ----------------------------------------------------------------------
1407
1408 (define_insn "negqi2"
1409 [(set (match_operand:QI 0 "register_operand" "=r")
1410 (neg:QI (match_operand:QI 1 "register_operand" "0")))]
1411 ""
1412 "neg %X0"
1413 [(set_attr "length" "2")
1414 (set_attr "cc" "set_zn")])
1415
1416 (define_expand "neghi2"
1417 [(set (match_operand:HI 0 "register_operand" "")
1418 (neg:HI (match_operand:HI 1 "register_operand" "")))]
1419 ""
1420 "
1421 {
1422 if (TARGET_H8300)
1423 {
1424 emit_insn (gen_neghi2_h8300 (operands[0], operands[1]));
1425 DONE;
1426 }
1427 }")
1428
1429 (define_expand "neghi2_h8300"
1430 [(set (match_dup 2)
1431 (not:HI (match_operand:HI 1 "register_operand" "")))
1432 (set (match_dup 2) (plus:HI (match_dup 2) (const_int 1)))
1433 (set (match_operand:HI 0 "register_operand" "")
1434 (match_dup 2))]
1435 ""
1436 "operands[2] = gen_reg_rtx (HImode);")
1437
1438 (define_insn "*neghi2_h8300hs"
1439 [(set (match_operand:HI 0 "register_operand" "=r")
1440 (neg:HI (match_operand:HI 1 "register_operand" "0")))]
1441 "TARGET_H8300H || TARGET_H8300S"
1442 "neg %T0"
1443 [(set_attr "length" "2")
1444 (set_attr "cc" "set_zn")])
1445
1446 (define_expand "negsi2"
1447 [(set (match_operand:SI 0 "register_operand" "")
1448 (neg:SI (match_operand:SI 1 "register_operand" "")))]
1449 ""
1450 "
1451 {
1452 if (TARGET_H8300)
1453 {
1454 emit_insn (gen_negsi2_h8300 (operands[0], operands[1]));
1455 DONE;
1456 }
1457 }")
1458
1459 (define_expand "negsi2_h8300"
1460 [(set (match_dup 2)
1461 (not:SI (match_operand:SI 1 "register_operand" "")))
1462 (set (match_dup 2) (plus:SI (match_dup 2) (const_int 1)))
1463 (set (match_operand:SI 0 "register_operand" "")
1464 (match_dup 2))]
1465 ""
1466 "operands[2] = gen_reg_rtx (SImode);")
1467
1468 (define_insn "*negsi2_h8300hs"
1469 [(set (match_operand:SI 0 "register_operand" "=r")
1470 (neg:SI (match_operand:SI 1 "register_operand" "0")))]
1471 "TARGET_H8300H || TARGET_H8300S"
1472 "neg %S0"
1473 [(set_attr "length" "2")
1474 (set_attr "cc" "set_zn")])
1475
1476 (define_expand "negsf2"
1477 [(set (match_operand:SF 0 "register_operand" "")
1478 (neg:SF (match_operand:SF 1 "register_operand" "")))]
1479 ""
1480 "")
1481
1482 (define_insn "*negsf2_h8300"
1483 [(set (match_operand:SF 0 "register_operand" "=r")
1484 (neg:SF (match_operand:SF 1 "register_operand" "0")))]
1485 "TARGET_H8300"
1486 "xor.b\\t#128,%z0"
1487 [(set_attr "cc" "clobber")
1488 (set_attr "length" "2")])
1489
1490 (define_insn "*negsf2_h8300hs"
1491 [(set (match_operand:SF 0 "register_operand" "=r")
1492 (neg:SF (match_operand:SF 1 "register_operand" "0")))]
1493 "TARGET_H8300H || TARGET_H8300S"
1494 "xor.w\\t#32768,%e0"
1495 [(set_attr "cc" "clobber")
1496 (set_attr "length" "4")])
1497 \f
1498 ;; ----------------------------------------------------------------------
1499 ;; ABSOLUTE VALUE INSTRUCTIONS
1500 ;; ----------------------------------------------------------------------
1501
1502 (define_expand "abssf2"
1503 [(set (match_operand:SF 0 "register_operand" "")
1504 (abs:SF (match_operand:SF 1 "register_operand" "")))]
1505 ""
1506 "")
1507
1508 (define_insn "*abssf2_h8300"
1509 [(set (match_operand:SF 0 "register_operand" "=r")
1510 (abs:SF (match_operand:SF 1 "register_operand" "0")))]
1511 "TARGET_H8300"
1512 "and.b\\t#127,%z0"
1513 [(set_attr "cc" "clobber")
1514 (set_attr "length" "2")])
1515
1516 (define_insn "*abssf2_h8300hs"
1517 [(set (match_operand:SF 0 "register_operand" "=r")
1518 (abs:SF (match_operand:SF 1 "register_operand" "0")))]
1519 "TARGET_H8300H || TARGET_H8300S"
1520 "and.w\\t#32767,%e0"
1521 [(set_attr "cc" "clobber")
1522 (set_attr "length" "4")])
1523 \f
1524 ;; ----------------------------------------------------------------------
1525 ;; NOT INSTRUCTIONS
1526 ;; ----------------------------------------------------------------------
1527
1528 (define_insn "one_cmplqi2"
1529 [(set (match_operand:QI 0 "register_operand" "=r")
1530 (not:QI (match_operand:QI 1 "register_operand" "0")))]
1531 ""
1532 "not %X0"
1533 [(set_attr "length" "2")
1534 (set_attr "cc" "set_znv")])
1535
1536 (define_expand "one_cmplhi2"
1537 [(set (match_operand:HI 0 "register_operand" "=r")
1538 (not:HI (match_operand:HI 1 "register_operand" "0")))]
1539 ""
1540 "")
1541
1542 (define_insn "*one_cmplhi2_h8300"
1543 [(set (match_operand:HI 0 "register_operand" "=r")
1544 (not:HI (match_operand:HI 1 "register_operand" "0")))]
1545 "TARGET_H8300"
1546 "not %s0\;not %t0"
1547 [(set_attr "cc" "clobber")
1548 (set_attr "length" "4")])
1549
1550 (define_insn "*one_cmplhi2_h8300hs"
1551 [(set (match_operand:HI 0 "register_operand" "=r")
1552 (not:HI (match_operand:HI 1 "register_operand" "0")))]
1553 "TARGET_H8300H || TARGET_H8300S"
1554 "not %T0"
1555 [(set_attr "cc" "set_znv")
1556 (set_attr "length" "2")])
1557
1558 (define_expand "one_cmplsi2"
1559 [(set (match_operand:SI 0 "register_operand" "=r")
1560 (not:SI (match_operand:SI 1 "register_operand" "0")))]
1561 ""
1562 "")
1563
1564 (define_insn "*one_complsi2_h8300"
1565 [(set (match_operand:SI 0 "register_operand" "=r")
1566 (not:SI (match_operand:SI 1 "register_operand" "0")))]
1567 "TARGET_H8300"
1568 "not %w0\;not %x0\;not %y0\;not %z0"
1569 [(set_attr "cc" "clobber")
1570 (set_attr "length" "8")])
1571
1572 (define_insn "*one_complsi2_h8300hs"
1573 [(set (match_operand:SI 0 "register_operand" "=r")
1574 (not:SI (match_operand:SI 1 "register_operand" "0")))]
1575 "TARGET_H8300H || TARGET_H8300S"
1576 "not %S0"
1577 [(set_attr "cc" "set_znv")
1578 (set_attr "length" "2")])
1579 \f
1580 ;; ----------------------------------------------------------------------
1581 ;; JUMP INSTRUCTIONS
1582 ;; ----------------------------------------------------------------------
1583
1584 ;; Conditional jump instructions
1585
1586 (define_expand "ble"
1587 [(set (pc)
1588 (if_then_else (le (cc0)
1589 (const_int 0))
1590 (label_ref (match_operand 0 "" ""))
1591 (pc)))]
1592 ""
1593 "")
1594
1595 (define_expand "bleu"
1596 [(set (pc)
1597 (if_then_else (leu (cc0)
1598 (const_int 0))
1599 (label_ref (match_operand 0 "" ""))
1600 (pc)))]
1601 ""
1602 "")
1603
1604 (define_expand "bge"
1605 [(set (pc)
1606 (if_then_else (ge (cc0)
1607 (const_int 0))
1608 (label_ref (match_operand 0 "" ""))
1609 (pc)))]
1610 ""
1611 "")
1612
1613 (define_expand "bgeu"
1614 [(set (pc)
1615 (if_then_else (geu (cc0)
1616 (const_int 0))
1617 (label_ref (match_operand 0 "" ""))
1618 (pc)))]
1619 ""
1620 "")
1621
1622 (define_expand "blt"
1623 [(set (pc)
1624 (if_then_else (lt (cc0)
1625 (const_int 0))
1626 (label_ref (match_operand 0 "" ""))
1627 (pc)))]
1628 ""
1629 "")
1630
1631 (define_expand "bltu"
1632 [(set (pc)
1633 (if_then_else (ltu (cc0)
1634 (const_int 0))
1635 (label_ref (match_operand 0 "" ""))
1636 (pc)))]
1637 ""
1638 "")
1639
1640 (define_expand "bgt"
1641 [(set (pc)
1642 (if_then_else (gt (cc0)
1643 (const_int 0))
1644 (label_ref (match_operand 0 "" ""))
1645 (pc)))]
1646 ""
1647 "")
1648
1649 (define_expand "bgtu"
1650 [(set (pc)
1651 (if_then_else (gtu (cc0)
1652 (const_int 0))
1653 (label_ref (match_operand 0 "" ""))
1654 (pc)))]
1655 ""
1656 "")
1657
1658 (define_expand "beq"
1659 [(set (pc)
1660 (if_then_else (eq (cc0)
1661 (const_int 0))
1662 (label_ref (match_operand 0 "" ""))
1663 (pc)))]
1664 ""
1665 "")
1666
1667 (define_expand "bne"
1668 [(set (pc)
1669 (if_then_else (ne (cc0)
1670 (const_int 0))
1671 (label_ref (match_operand 0 "" ""))
1672 (pc)))]
1673 ""
1674 "")
1675
1676 (define_insn "branch_true"
1677 [(set (pc)
1678 (if_then_else (match_operator 1 "comparison_operator"
1679 [(cc0) (const_int 0)])
1680 (label_ref (match_operand 0 "" ""))
1681 (pc)))]
1682 ""
1683 "*
1684 {
1685 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
1686 && (GET_CODE (operands[1]) == GT
1687 || GET_CODE (operands[1]) == GE
1688 || GET_CODE (operands[1]) == LE
1689 || GET_CODE (operands[1]) == LT))
1690 {
1691 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
1692 return 0;
1693 }
1694
1695 if (get_attr_length (insn) == 2)
1696 return \"b%j1 %l0\";
1697 else if (get_attr_length (insn) == 4)
1698 return \"b%j1 %l0:16\";
1699 else
1700 return \"b%k1 .Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:\";
1701 }"
1702 [(set_attr "type" "branch")
1703 (set_attr "cc" "none")])
1704
1705 (define_insn "branch_false"
1706 [(set (pc)
1707 (if_then_else (match_operator 1 "comparison_operator"
1708 [(cc0) (const_int 0)])
1709 (pc)
1710 (label_ref (match_operand 0 "" ""))))]
1711 ""
1712 "*
1713 {
1714 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
1715 && (GET_CODE (operands[1]) == GT
1716 || GET_CODE (operands[1]) == GE
1717 || GET_CODE (operands[1]) == LE
1718 || GET_CODE (operands[1]) == LT))
1719 {
1720 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
1721 return 0;
1722 }
1723
1724 if (get_attr_length (insn) == 2)
1725 return \"b%k1 %l0\";
1726 else if (get_attr_length (insn) == 4)
1727 return \"b%k1 %l0:16\";
1728 else
1729 return \"b%j1 .Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:\";
1730 }"
1731 [(set_attr "type" "branch")
1732 (set_attr "cc" "none")])
1733
1734 ;; Unconditional and other jump instructions.
1735
1736 (define_insn "jump"
1737 [(set (pc)
1738 (label_ref (match_operand 0 "" "")))]
1739 ""
1740 "*
1741 {
1742 if (get_attr_length (insn) == 2)
1743 return \"bra %l0\";
1744 else if (get_attr_length (insn) == 4)
1745 return \"bra %l0:16\";
1746 else
1747 return \"jmp @%l0\";
1748 }"
1749 [(set_attr "type" "branch")
1750 (set_attr "cc" "none")])
1751
1752 ;; This is a define expand, because pointers may be either 16 or 32 bits.
1753
1754 (define_expand "tablejump"
1755 [(parallel [(set (pc) (match_operand 0 "register_operand" ""))
1756 (use (label_ref (match_operand 1 "" "")))])]
1757 ""
1758 "")
1759
1760 (define_insn "*tablejump_h8300"
1761 [(set (pc) (match_operand:HI 0 "register_operand" "r"))
1762 (use (label_ref (match_operand 1 "" "")))]
1763 "TARGET_H8300"
1764 "jmp @%0"
1765 [(set_attr "cc" "none")
1766 (set_attr "length" "2")])
1767
1768 (define_insn "*tablejump_h8300hs_advanced"
1769 [(set (pc) (match_operand:SI 0 "register_operand" "r"))
1770 (use (label_ref (match_operand 1 "" "")))]
1771 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE"
1772 "jmp @%0"
1773 [(set_attr "cc" "none")
1774 (set_attr "length" "2")])
1775
1776 (define_insn "*tablejump_h8300hs_normal"
1777 [(set (pc) (match_operand:HI 0 "register_operand" "r"))
1778 (use (label_ref (match_operand 1 "" "")))]
1779 "(TARGET_H8300H || TARGET_H8300S) && TARGET_NORMAL_MODE"
1780 "jmp @%S0"
1781 [(set_attr "cc" "none")
1782 (set_attr "length" "2")])
1783
1784 ;; This is a define expand, because pointers may be either 16 or 32 bits.
1785
1786 (define_expand "indirect_jump"
1787 [(set (pc) (match_operand 0 "jump_address_operand" ""))]
1788 ""
1789 "")
1790
1791 (define_insn "*indirect_jump_h8300"
1792 [(set (pc) (match_operand:HI 0 "jump_address_operand" "Vr"))]
1793 "TARGET_H8300"
1794 "jmp @%0"
1795 [(set_attr "cc" "none")
1796 (set_attr "length" "2")])
1797
1798 (define_insn "*indirect_jump_h8300hs_advanced"
1799 [(set (pc) (match_operand:SI 0 "jump_address_operand" "Vr"))]
1800 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE"
1801 "jmp @%0"
1802 [(set_attr "cc" "none")
1803 (set_attr "length" "2")])
1804
1805 (define_insn "*indirect_jump_h8300hs_normal"
1806 [(set (pc) (match_operand:HI 0 "jump_address_operand" "Vr"))]
1807 "(TARGET_H8300H || TARGET_H8300S) && TARGET_NORMAL_MODE"
1808 "jmp @%S0"
1809 [(set_attr "cc" "none")
1810 (set_attr "length" "2")])
1811
1812 ;; Call subroutine with no return value.
1813
1814 ;; ??? Even though we use HImode here, this works on the H8/300H and H8S.
1815
1816 (define_insn "call"
1817 [(call (match_operand:QI 0 "call_insn_operand" "or")
1818 (match_operand:HI 1 "general_operand" "g"))]
1819 ""
1820 "*
1821 {
1822 if (GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
1823 && SYMBOL_REF_FLAG (XEXP (operands[0], 0)))
1824 return \"jsr\\t@%0:8\";
1825 else
1826 return \"jsr\\t%0\";
1827 }"
1828 [(set_attr "cc" "clobber")
1829 (set (attr "length")
1830 (if_then_else (match_operand:QI 0 "small_call_insn_operand" "")
1831 (const_int 2)
1832 (const_int 4)))])
1833
1834 ;; Call subroutine, returning value in operand 0
1835 ;; (which must be a hard register).
1836
1837 ;; ??? Even though we use HImode here, this works on the H8/300H and H8S.
1838
1839 (define_insn "call_value"
1840 [(set (match_operand 0 "" "=r")
1841 (call (match_operand:QI 1 "call_insn_operand" "or")
1842 (match_operand:HI 2 "general_operand" "g")))]
1843 ""
1844 "*
1845 {
1846 if (GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
1847 && SYMBOL_REF_FLAG (XEXP (operands[1], 0)))
1848 return \"jsr\\t@%1:8\";
1849 else
1850 return \"jsr\\t%1\";
1851 }"
1852 [(set_attr "cc" "clobber")
1853 (set (attr "length")
1854 (if_then_else (match_operand:QI 0 "small_call_insn_operand" "")
1855 (const_int 2)
1856 (const_int 4)))])
1857
1858 (define_insn "nop"
1859 [(const_int 0)]
1860 ""
1861 "nop"
1862 [(set_attr "cc" "none")
1863 (set_attr "length" "2")])
1864 \f
1865 ;; ----------------------------------------------------------------------
1866 ;; PROLOGUE/EPILOGUE-RELATED INSTRUCTIONS
1867 ;; ----------------------------------------------------------------------
1868
1869 (define_expand "push_h8300"
1870 [(set (mem:HI (pre_dec:HI (reg:HI SP_REG)))
1871 (match_operand:HI 0 "register_operand" ""))]
1872 "TARGET_H8300"
1873 "")
1874
1875 (define_expand "push_h8300hs_advanced"
1876 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
1877 (match_operand:SI 0 "register_operand" ""))]
1878 "TARGET_H8300H && TARGET_H8300S && !TARGET_NORMAL_MODE"
1879 "")
1880
1881 (define_expand "push_h8300hs_normal"
1882 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
1883 (match_operand:SI 0 "register_operand" ""))]
1884 "TARGET_H8300H && TARGET_H8300S && TARGET_NORMAL_MODE"
1885 "")
1886
1887 (define_expand "pop_h8300"
1888 [(set (match_operand:HI 0 "register_operand" "")
1889 (mem:HI (post_inc:HI (reg:HI SP_REG))))]
1890 "TARGET_H8300"
1891 "")
1892
1893 (define_expand "pop_h8300hs_advanced"
1894 [(set (match_operand:SI 0 "register_operand" "")
1895 (mem:SI (post_inc:SI (reg:SI SP_REG))))]
1896 "TARGET_H8300H && TARGET_H8300S && !TARGET_NORMAL_MODE"
1897 "")
1898
1899 (define_expand "pop_h8300hs_normal"
1900 [(set (match_operand:SI 0 "register_operand" "")
1901 (mem:SI (post_inc:HI (reg:HI SP_REG))))]
1902 "TARGET_H8300H && TARGET_H8300S && TARGET_NORMAL_MODE"
1903 "")
1904
1905 (define_insn "stm_h8300s_2_advanced"
1906 [(parallel
1907 [(set (reg:SI SP_REG)
1908 (plus:SI (reg:SI SP_REG) (const_int -8)))
1909 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
1910 (match_operand:SI 0 "register_operand" ""))
1911 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
1912 (match_operand:SI 1 "register_operand" ""))])]
1913 "TARGET_H8300S && !TARGET_NORMAL_MODE
1914 && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
1915 || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
1916 || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
1917 "stm.l\\t%S0-%S1,@-er7"
1918 [(set_attr "cc" "none")
1919 (set_attr "length" "4")])
1920
1921 (define_insn "stm_h8300s_2_normal"
1922 [(parallel
1923 [(set (reg:HI SP_REG)
1924 (plus:HI (reg:HI SP_REG) (const_int -8)))
1925 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
1926 (match_operand:SI 0 "register_operand" ""))
1927 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
1928 (match_operand:SI 1 "register_operand" ""))])]
1929 "TARGET_H8300S && TARGET_NORMAL_MODE
1930 && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
1931 || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
1932 || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
1933 "stm.l\\t%S0-%S1,@-er7"
1934 [(set_attr "cc" "none")
1935 (set_attr "length" "4")])
1936
1937 (define_expand "stm_h8300s_2"
1938 [(match_operand:SI 0 "register_operand" "")
1939 (match_operand:SI 1 "register_operand" "")]
1940 "TARGET_H8300S
1941 && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
1942 || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
1943 || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
1944 "
1945 {
1946 if (!TARGET_NORMAL_MODE)
1947 emit_insn (gen_stm_h8300s_2_advanced (operands[0], operands[1]));
1948 else
1949 emit_insn (gen_stm_h8300s_2_normal (operands[0], operands[1]));
1950 DONE;
1951 }")
1952
1953 (define_insn "stm_h8300s_3_advanced"
1954 [(parallel
1955 [(set (reg:SI SP_REG)
1956 (plus:SI (reg:SI SP_REG) (const_int -12)))
1957 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
1958 (match_operand:SI 0 "register_operand" ""))
1959 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
1960 (match_operand:SI 1 "register_operand" ""))
1961 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -12)))
1962 (match_operand:SI 2 "register_operand" ""))])]
1963 "TARGET_H8300S && !TARGET_NORMAL_MODE
1964 && ((REGNO (operands[0]) == 0
1965 && REGNO (operands[1]) == 1
1966 && REGNO (operands[2]) == 2)
1967 || (REGNO (operands[0]) == 4
1968 && REGNO (operands[1]) == 5
1969 && REGNO (operands[2]) == 6))"
1970 "stm.l\\t%S0-%S2,@-er7"
1971 [(set_attr "cc" "none")
1972 (set_attr "length" "4")])
1973
1974 (define_insn "stm_h8300s_3_normal"
1975 [(parallel
1976 [(set (reg:HI SP_REG)
1977 (plus:HI (reg:HI SP_REG) (const_int -12)))
1978 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
1979 (match_operand:SI 0 "register_operand" ""))
1980 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
1981 (match_operand:SI 1 "register_operand" ""))
1982 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
1983 (match_operand:SI 2 "register_operand" ""))])]
1984 "TARGET_H8300S && TARGET_NORMAL_MODE
1985 && ((REGNO (operands[0]) == 0
1986 && REGNO (operands[1]) == 1
1987 && REGNO (operands[2]) == 2)
1988 || (REGNO (operands[0]) == 4
1989 && REGNO (operands[1]) == 5
1990 && REGNO (operands[2]) == 6))"
1991 "stm.l\\t%S0-%S2,@-er7"
1992 [(set_attr "cc" "none")
1993 (set_attr "length" "4")])
1994
1995 (define_expand "stm_h8300s_3"
1996 [(match_operand:SI 0 "register_operand" "")
1997 (match_operand:SI 1 "register_operand" "")
1998 (match_operand:SI 2 "register_operand" "")]
1999 "TARGET_H8300S
2000 && ((REGNO (operands[0]) == 0
2001 && REGNO (operands[1]) == 1
2002 && REGNO (operands[2]) == 2)
2003 || (REGNO (operands[0]) == 4
2004 && REGNO (operands[1]) == 5
2005 && REGNO (operands[2]) == 6))"
2006 "
2007 {
2008 if (!TARGET_NORMAL_MODE)
2009 emit_insn (gen_stm_h8300s_3_advanced (operands[0], operands[1],
2010 operands[2]));
2011 else
2012 emit_insn (gen_stm_h8300s_3_normal (operands[0], operands[1],
2013 operands[2]));
2014 DONE;
2015 }")
2016
2017 (define_insn "stm_h8300s_4_advanced"
2018 [(parallel
2019 [(set (reg:SI SP_REG)
2020 (plus:SI (reg:SI SP_REG) (const_int -16)))
2021 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
2022 (match_operand:SI 0 "register_operand" ""))
2023 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
2024 (match_operand:SI 1 "register_operand" ""))
2025 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -12)))
2026 (match_operand:SI 2 "register_operand" ""))
2027 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -16)))
2028 (match_operand:SI 3 "register_operand" ""))])]
2029 "TARGET_H8300S && !TARGET_NORMAL_MODE
2030 && REGNO (operands[0]) == 0
2031 && REGNO (operands[1]) == 1
2032 && REGNO (operands[2]) == 2
2033 && REGNO (operands[3]) == 3"
2034 "stm.l\\t%S0-%S3,@-er7"
2035 [(set_attr "cc" "none")
2036 (set_attr "length" "4")])
2037
2038 (define_insn "stm_h8300s_4_normal"
2039 [(parallel
2040 [(set (reg:HI SP_REG)
2041 (plus:HI (reg:HI SP_REG) (const_int -16)))
2042 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
2043 (match_operand:SI 0 "register_operand" ""))
2044 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
2045 (match_operand:SI 1 "register_operand" ""))
2046 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
2047 (match_operand:SI 2 "register_operand" ""))
2048 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -16)))
2049 (match_operand:SI 3 "register_operand" ""))])]
2050 "TARGET_H8300S && TARGET_NORMAL_MODE
2051 && REGNO (operands[0]) == 0
2052 && REGNO (operands[1]) == 1
2053 && REGNO (operands[2]) == 2
2054 && REGNO (operands[3]) == 3"
2055 "stm.l\\t%S0-%S3,@-er7"
2056 [(set_attr "cc" "none")
2057 (set_attr "length" "4")])
2058
2059 (define_expand "stm_h8300s_4"
2060 [(match_operand:SI 0 "register_operand" "")
2061 (match_operand:SI 1 "register_operand" "")
2062 (match_operand:SI 2 "register_operand" "")
2063 (match_operand:SI 3 "register_operand" "")]
2064 "TARGET_H8300S
2065 && REGNO (operands[0]) == 0
2066 && REGNO (operands[1]) == 1
2067 && REGNO (operands[2]) == 2
2068 && REGNO (operands[3]) == 3"
2069 "
2070 {
2071 if (!TARGET_NORMAL_MODE)
2072 emit_insn (gen_stm_h8300s_4_advanced (operands[0], operands[1],
2073 operands[2], operands[3]));
2074 else
2075 emit_insn (gen_stm_h8300s_4_normal (operands[0], operands[1],
2076 operands[2], operands[3]));
2077 DONE;
2078 }")
2079
2080 (define_insn "ldm_h8300s_2_advanced"
2081 [(parallel
2082 [(set (reg:SI SP_REG)
2083 (plus:SI (reg:SI SP_REG) (const_int 8)))
2084 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int 4)))
2085 (match_operand:SI 0 "register_operand" ""))
2086 (set (mem:SI (reg:SI SP_REG))
2087 (match_operand:SI 1 "register_operand" ""))])]
2088 "TARGET_H8300S && !TARGET_NORMAL_MODE
2089 && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
2090 || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
2091 || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
2092 "ldm.l\\t@er7+,%S0-%S1"
2093 [(set_attr "cc" "none")
2094 (set_attr "length" "4")])
2095
2096 (define_insn "ldm_h8300s_2_normal"
2097 [(parallel
2098 [(set (reg:HI SP_REG)
2099 (plus:HI (reg:HI SP_REG) (const_int 8)))
2100 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int 4)))
2101 (match_operand:SI 0 "register_operand" ""))
2102 (set (mem:SI (reg:HI SP_REG))
2103 (match_operand:SI 1 "register_operand" ""))])]
2104 "TARGET_H8300S && TARGET_NORMAL_MODE
2105 && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
2106 || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
2107 || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
2108 "ldm.l\\t@er7+,%S0-%S1"
2109 [(set_attr "cc" "none")
2110 (set_attr "length" "4")])
2111
2112 (define_expand "ldm_h8300s_2"
2113 [(match_operand:SI 0 "register_operand" "")
2114 (match_operand:SI 1 "register_operand" "")]
2115 "TARGET_H8300S
2116 && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
2117 || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
2118 || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
2119 "
2120 {
2121 if (!TARGET_NORMAL_MODE)
2122 emit_insn (gen_ldm_h8300s_2_advanced (operands[0], operands[1]));
2123 else
2124 emit_insn (gen_ldm_h8300s_2_normal (operands[0], operands[1]));
2125 DONE;
2126 }")
2127
2128 (define_insn "ldm_h8300s_3_advanced"
2129 [(parallel
2130 [(set (reg:SI SP_REG)
2131 (plus:SI (reg:SI SP_REG) (const_int 12)))
2132 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int 8)))
2133 (match_operand:SI 0 "register_operand" ""))
2134 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int 4)))
2135 (match_operand:SI 1 "register_operand" ""))
2136 (set (mem:SI (reg:SI SP_REG))
2137 (match_operand:SI 2 "register_operand" ""))])]
2138 "TARGET_H8300S && !TARGET_NORMAL_MODE
2139 && ((REGNO (operands[0]) == 0
2140 && REGNO (operands[1]) == 1
2141 && REGNO (operands[2]) == 2)
2142 || (REGNO (operands[0]) == 4
2143 && REGNO (operands[1]) == 5
2144 && REGNO (operands[2]) == 6))"
2145 "ldm.l\\t@er7+,%S0-%S2"
2146 [(set_attr "cc" "none")
2147 (set_attr "length" "4")])
2148
2149 (define_insn "ldm_h8300s_3_normal"
2150 [(parallel
2151 [(set (reg:HI SP_REG)
2152 (plus:HI (reg:HI SP_REG) (const_int 12)))
2153 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int 8)))
2154 (match_operand:SI 0 "register_operand" ""))
2155 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int 4)))
2156 (match_operand:SI 1 "register_operand" ""))
2157 (set (mem:SI (reg:HI SP_REG))
2158 (match_operand:SI 2 "register_operand" ""))])]
2159 "TARGET_H8300S && TARGET_NORMAL_MODE
2160 && ((REGNO (operands[0]) == 0
2161 && REGNO (operands[1]) == 1
2162 && REGNO (operands[2]) == 2)
2163 || (REGNO (operands[0]) == 4
2164 && REGNO (operands[1]) == 5
2165 && REGNO (operands[2]) == 6))"
2166 "ldm.l\\t@er7+,%S0-%S2"
2167 [(set_attr "cc" "none")
2168 (set_attr "length" "4")])
2169
2170 (define_expand "ldm_h8300s_3"
2171 [(match_operand:SI 0 "register_operand" "")
2172 (match_operand:SI 1 "register_operand" "")
2173 (match_operand:SI 2 "register_operand" "")]
2174 "TARGET_H8300S
2175 && ((REGNO (operands[0]) == 0
2176 && REGNO (operands[1]) == 1
2177 && REGNO (operands[2]) == 2)
2178 || (REGNO (operands[0]) == 4
2179 && REGNO (operands[1]) == 5
2180 && REGNO (operands[2]) == 6))"
2181 "
2182 {
2183 if (!TARGET_NORMAL_MODE)
2184 emit_insn (gen_ldm_h8300s_3_advanced (operands[0], operands[1],
2185 operands[2]));
2186 else
2187 emit_insn (gen_ldm_h8300s_3_normal (operands[0], operands[1],
2188 operands[2]));
2189 DONE;
2190 }")
2191
2192 (define_insn "ldm_h8300s_4_advanced"
2193 [(parallel
2194 [(set (reg:SI SP_REG)
2195 (plus:SI (reg:SI SP_REG) (const_int 16)))
2196 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int 12)))
2197 (match_operand:SI 0 "register_operand" ""))
2198 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int 8)))
2199 (match_operand:SI 1 "register_operand" ""))
2200 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int 4)))
2201 (match_operand:SI 2 "register_operand" ""))
2202 (set (mem:SI (reg:SI SP_REG))
2203 (match_operand:SI 3 "register_operand" ""))])]
2204 "TARGET_H8300S && !TARGET_NORMAL_MODE
2205 && REGNO (operands[0]) == 0
2206 && REGNO (operands[1]) == 1
2207 && REGNO (operands[2]) == 2
2208 && REGNO (operands[3]) == 3"
2209 "ldm.l\\t@er7+,%S0-%S3"
2210 [(set_attr "cc" "none")
2211 (set_attr "length" "4")])
2212
2213 (define_insn "ldm_h8300s_4_normal"
2214 [(parallel
2215 [(set (reg:HI SP_REG)
2216 (plus:HI (reg:HI SP_REG) (const_int 16)))
2217 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int 12)))
2218 (match_operand:SI 0 "register_operand" ""))
2219 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int 8)))
2220 (match_operand:SI 1 "register_operand" ""))
2221 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int 4)))
2222 (match_operand:SI 2 "register_operand" ""))
2223 (set (mem:SI (reg:HI SP_REG))
2224 (match_operand:SI 3 "register_operand" ""))])]
2225 "TARGET_H8300S && !TARGET_NORMAL_MODE
2226 && REGNO (operands[0]) == 0
2227 && REGNO (operands[1]) == 1
2228 && REGNO (operands[2]) == 2
2229 && REGNO (operands[3]) == 3"
2230 "ldm.l\\t@er7+,%S0-%S3"
2231 [(set_attr "cc" "none")
2232 (set_attr "length" "4")])
2233
2234 (define_expand "ldm_h8300s_4"
2235 [(match_operand:SI 0 "register_operand" "")
2236 (match_operand:SI 1 "register_operand" "")
2237 (match_operand:SI 2 "register_operand" "")
2238 (match_operand:SI 3 "register_operand" "")]
2239 "TARGET_H8300S && !TARGET_NORMAL_MODE
2240 && REGNO (operands[0]) == 0
2241 && REGNO (operands[1]) == 1
2242 && REGNO (operands[2]) == 2
2243 && REGNO (operands[3]) == 3"
2244 "
2245 {
2246 if (!TARGET_NORMAL_MODE)
2247 emit_insn (gen_ldm_h8300s_4_advanced (operands[0], operands[1],
2248 operands[2], operands[3]));
2249 else
2250 emit_insn (gen_ldm_h8300s_4_normal (operands[0], operands[1],
2251 operands[2], operands[3]));
2252 DONE;
2253 }")
2254
2255 (define_expand "return"
2256 [(return)]
2257 "h8300_can_use_return_insn_p ()"
2258 "")
2259
2260 (define_insn "*return_1"
2261 [(return)]
2262 "reload_completed"
2263 "*
2264 {
2265 if (h8300_current_function_interrupt_function_p ())
2266 return \"rte\";
2267 else
2268 return \"rts\";
2269 }"
2270 [(set_attr "cc" "none")
2271 (set_attr "length" "2")])
2272
2273 (define_expand "prologue"
2274 [(const_int 0)]
2275 ""
2276 "h8300_expand_prologue (); DONE;")
2277
2278 (define_expand "epilogue"
2279 [(return)]
2280 ""
2281 "h8300_expand_epilogue ();")
2282
2283 (define_insn "monitor_prologue"
2284 [(unspec_volatile [(const_int 0)] UNSPEC_MONITOR)]
2285 ""
2286 "*
2287 {
2288 if (TARGET_H8300)
2289 return \"subs\\t#2,r7\;mov.w\\tr0,@-r7\;stc\\tccr,r0l\;mov.b\tr0l,@(2,r7)\;mov.w\\t@r7+,r0\;orc\t#128,ccr\";
2290 else if (TARGET_H8300H)
2291 return \"mov.l\\ter0,@-er7\;stc\\tccr,r0l\;mov.b\\tr0l,@(4,er7)\;mov.l\\t@er7+,er0\;orc\\t#128,ccr\";
2292 else if (TARGET_H8300S)
2293 return \"stc\texr,@-er7\;mov.l\\ter0,@-er7\;stc\tccr,r0l\;mov.b\tr0l,@(6,er7)\;mov.l\\t@er7+,er0\;orc\t#128,ccr\";
2294 abort ();
2295 }"
2296 [(set_attr "length" "20")
2297 (set_attr "cc" "clobber")])
2298 \f
2299 ;; ----------------------------------------------------------------------
2300 ;; EXTEND INSTRUCTIONS
2301 ;; ----------------------------------------------------------------------
2302
2303 (define_expand "zero_extendqihi2"
2304 [(set (match_operand:HI 0 "register_operand" "")
2305 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "")))]
2306 ""
2307 "")
2308
2309 (define_insn "*zero_extendqihi2_h8300"
2310 [(set (match_operand:HI 0 "register_operand" "=r,r")
2311 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2312 "TARGET_H8300"
2313 "@
2314 mov.b #0,%t0
2315 #"
2316 [(set_attr "length" "2,10")
2317 (set_attr "cc" "clobber,clobber")])
2318
2319 (define_insn "*zero_extendqihi2_h8300hs"
2320 [(set (match_operand:HI 0 "register_operand" "=r,r")
2321 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2322 "TARGET_H8300H || TARGET_H8300S"
2323 "@
2324 extu.w %T0
2325 #"
2326 [(set_attr "length" "2,10")
2327 (set_attr "cc" "set_znv,set_znv")])
2328
2329 ;; Split the zero extension of a general operand (actually a memory
2330 ;; operand) into a load of the operand and the actual zero extension
2331 ;; so that 1) the length will be accurate, and 2) the zero extensions
2332 ;; appearing at the end of basic blocks may be merged.
2333
2334 (define_split
2335 [(set (match_operand:HI 0 "register_operand" "")
2336 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "")))]
2337 "reload_completed"
2338 [(set (match_dup 2)
2339 (match_dup 1))
2340 (set (match_dup 0)
2341 (zero_extend:HI (match_dup 2)))]
2342 "operands[2] = gen_rtx_REG (QImode, REGNO (operands[0]));")
2343
2344 (define_expand "zero_extendqisi2"
2345 [(set (match_operand:SI 0 "register_operand" "")
2346 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "")))]
2347 ""
2348 "")
2349
2350 (define_insn "*zero_extendqisi2_h8300"
2351 [(set (match_operand:SI 0 "register_operand" "=r,r")
2352 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2353 "TARGET_H8300"
2354 "@
2355 mov.b #0,%x0\;sub.w %e0,%e0
2356 mov.b %R1,%w0\;mov.b #0,%x0\;sub.w %e0,%e0"
2357 [(set_attr "length" "4,8")
2358 (set_attr "cc" "clobber,clobber")])
2359
2360 (define_insn "*zero_extendqisi2_h8300hs"
2361 [(set (match_operand:SI 0 "register_operand" "=r,r")
2362 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2363 "TARGET_H8300H || TARGET_H8300S"
2364 "#")
2365
2366 (define_split
2367 [(set (match_operand:SI 0 "register_operand" "")
2368 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "")))]
2369 "(TARGET_H8300H || TARGET_H8300S)
2370 && reg_overlap_mentioned_p (operands[0], operands[1])
2371 && reload_completed"
2372 [(set (match_dup 2)
2373 (match_dup 1))
2374 (set (match_dup 3)
2375 (zero_extend:HI (match_dup 2)))
2376 (set (match_dup 0)
2377 (zero_extend:SI (match_dup 3)))]
2378 "operands[2] = gen_lowpart (QImode, operands[0]);
2379 operands[3] = gen_lowpart (HImode, operands[0]);")
2380
2381 (define_split
2382 [(set (match_operand:SI 0 "register_operand" "")
2383 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "")))]
2384 "(TARGET_H8300H || TARGET_H8300S)
2385 && !reg_overlap_mentioned_p (operands[0], operands[1])
2386 && reload_completed"
2387 [(set (match_dup 0)
2388 (const_int 0))
2389 (set (strict_low_part (match_dup 2))
2390 (match_dup 1))]
2391 "operands[2] = gen_rtx_REG (QImode, REGNO (operands[0]));")
2392
2393 (define_expand "zero_extendhisi2"
2394 [(set (match_operand:SI 0 "register_operand" "")
2395 (zero_extend:SI (match_operand:HI 1 "register_operand" "")))]
2396 ""
2397 "")
2398
2399 ;; %e prints the high part of a CONST_INT, not the low part. Arggh.
2400 (define_insn "*zero_extendhisi2_h8300"
2401 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
2402 (zero_extend:SI (match_operand:HI 1 "general_operand_src" "0,i,g>")))]
2403 "TARGET_H8300"
2404 "@
2405 sub.w %e0,%e0
2406 mov.w %f1,%f0\;sub.w %e0,%e0
2407 mov.w %e1,%f0\;sub.w %e0,%e0"
2408 [(set_attr "length" "2,4,6")
2409 (set_attr "cc" "clobber,clobber,clobber")])
2410
2411 (define_insn "*zero_extendhisi2_h8300hs"
2412 [(set (match_operand:SI 0 "register_operand" "=r")
2413 (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))]
2414 "TARGET_H8300H || TARGET_H8300S"
2415 "extu.l %S0"
2416 [(set_attr "length" "2")
2417 (set_attr "cc" "set_znv")])
2418
2419 (define_expand "extendqihi2"
2420 [(set (match_operand:HI 0 "register_operand" "")
2421 (sign_extend:HI (match_operand:QI 1 "register_operand" "")))]
2422 ""
2423 "")
2424
2425 (define_insn "*extendqihi2_h8300"
2426 [(set (match_operand:HI 0 "register_operand" "=r,r")
2427 (sign_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2428 "TARGET_H8300"
2429 "@
2430 bld #7,%s0\;subx %t0,%t0
2431 mov.b %R1,%s0\;bld #7,%s0\;subx %t0,%t0"
2432 [(set_attr "length" "4,8")
2433 (set_attr "cc" "clobber,clobber")])
2434
2435 (define_insn "*extendqihi2_h8300hs"
2436 [(set (match_operand:HI 0 "register_operand" "=r")
2437 (sign_extend:HI (match_operand:QI 1 "register_operand" "0")))]
2438 "TARGET_H8300H || TARGET_H8300S"
2439 "exts.w %T0"
2440 [(set_attr "length" "2")
2441 (set_attr "cc" "set_znv")])
2442
2443 (define_expand "extendqisi2"
2444 [(set (match_operand:SI 0 "register_operand" "")
2445 (sign_extend:SI (match_operand:QI 1 "register_operand" "")))]
2446 ""
2447 "")
2448
2449 (define_insn "*extendqisi2_h8300"
2450 [(set (match_operand:SI 0 "register_operand" "")
2451 (sign_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2452 "TARGET_H8300"
2453 "@
2454 bld #7,%w0\;subx %x0,%x0\;subx %y0,%y0\;subx %z0,%z0
2455 mov.b %R1,%w0\;bld #7,%w0\;subx %x0,%x0\;subx %y0,%y0\;subx %z0,%z0"
2456 [(set_attr "length" "8,12")
2457 (set_attr "cc" "clobber,clobber")])
2458
2459 ;; The following pattern is needed because without the pattern, the
2460 ;; combiner would split (sign_extend:SI (reg:QI)) into into two 24-bit
2461 ;; shifts, one ashift and one ashiftrt.
2462
2463 (define_insn_and_split "*extendqisi2_h8300hs"
2464 [(set (match_operand:SI 0 "register_operand" "=r")
2465 (sign_extend:SI (match_operand:QI 1 "register_operand" "0")))]
2466 "(TARGET_H8300H || TARGET_H8300S)"
2467 "#"
2468 "&& reload_completed"
2469 [(set (match_dup 2)
2470 (sign_extend:HI (match_dup 1)))
2471 (set (match_dup 0)
2472 (sign_extend:SI (match_dup 2)))]
2473 "operands[2] = gen_rtx_REG (HImode, REGNO (operands[0]));")
2474
2475 (define_expand "extendhisi2"
2476 [(set (match_operand:SI 0 "register_operand" "")
2477 (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
2478 ""
2479 "")
2480
2481 (define_insn "*extendhisi2_h8300"
2482 [(set (match_operand:SI 0 "register_operand" "=r,r")
2483 (sign_extend:SI (match_operand:HI 1 "general_operand_src" "0,g>")))]
2484 "TARGET_H8300"
2485 "@
2486 bld #7,%x0\;subx %y0,%y0\;subx %z0,%z0
2487 mov.w %T1,%f0\;bld #7,%x0\;subx %y0,%y0\;subx %z0,%z0"
2488 [(set_attr "length" "6,10")
2489 (set_attr "cc" "clobber,clobber")])
2490
2491 (define_insn "*extendhisi2_h8300hs"
2492 [(set (match_operand:SI 0 "register_operand" "=r")
2493 (sign_extend:SI (match_operand:HI 1 "register_operand" "0")))]
2494 "TARGET_H8300H || TARGET_H8300S"
2495 "exts.l %S0"
2496 [(set_attr "length" "2")
2497 (set_attr "cc" "set_znv")])
2498 \f
2499 ;; ----------------------------------------------------------------------
2500 ;; SHIFTS
2501 ;; ----------------------------------------------------------------------
2502 ;;
2503 ;; We make some attempt to provide real efficient shifting. One example is
2504 ;; doing an 8 bit shift of a 16 bit value by moving a byte reg into the other
2505 ;; reg and moving 0 into the former reg.
2506 ;;
2507 ;; We also try to achieve this in a uniform way. IE: We don't try to achieve
2508 ;; this in both rtl and at insn emit time. Ideally, we'd use rtl as that would
2509 ;; give the optimizer more cracks at the code. However, we wish to do things
2510 ;; like optimizing shifting the sign bit to bit 0 by rotating the other way.
2511 ;; There is rtl to handle this (rotate + and), but the H8/300 doesn't handle
2512 ;; 16 bit rotates. Also, if we emit complicated rtl, combine may not be able
2513 ;; to detect cases it can optimize.
2514 ;;
2515 ;; For these and other fuzzy reasons, I've decided to go the less pretty but
2516 ;; easier "do it at insn emit time" route.
2517
2518 ;; QI BIT SHIFTS
2519
2520 (define_expand "ashlqi3"
2521 [(set (match_operand:QI 0 "register_operand" "")
2522 (ashift:QI (match_operand:QI 1 "register_operand" "")
2523 (match_operand:QI 2 "nonmemory_operand" "")))]
2524 ""
2525 "expand_a_shift (QImode, ASHIFT, operands); DONE;")
2526
2527 (define_expand "ashrqi3"
2528 [(set (match_operand:QI 0 "register_operand" "")
2529 (ashiftrt:QI (match_operand:QI 1 "register_operand" "")
2530 (match_operand:QI 2 "nonmemory_operand" "")))]
2531 ""
2532 "expand_a_shift (QImode, ASHIFTRT, operands); DONE;")
2533
2534 (define_expand "lshrqi3"
2535 [(set (match_operand:QI 0 "register_operand" "")
2536 (lshiftrt:QI (match_operand:QI 1 "register_operand" "")
2537 (match_operand:QI 2 "nonmemory_operand" "")))]
2538 ""
2539 "expand_a_shift (QImode, LSHIFTRT, operands); DONE;")
2540
2541 (define_insn "*shiftqi"
2542 [(set (match_operand:QI 0 "register_operand" "=r,r")
2543 (match_operator:QI 3 "nshift_operator"
2544 [ (match_operand:QI 1 "register_operand" "0,0")
2545 (match_operand:QI 2 "nonmemory_operand" "R,rn")]))
2546 (clobber (match_scratch:QI 4 "=X,&r"))]
2547 ""
2548 "* return output_a_shift (operands);"
2549 [(set (attr "length")
2550 (symbol_ref "compute_a_shift_length (insn, operands)"))
2551 (set (attr "cc")
2552 (symbol_ref "compute_a_shift_cc (insn, operands)"))])
2553
2554 ;; HI BIT SHIFTS
2555
2556 (define_expand "ashlhi3"
2557 [(set (match_operand:HI 0 "register_operand" "")
2558 (ashift:HI (match_operand:HI 1 "nonmemory_operand" "")
2559 (match_operand:QI 2 "nonmemory_operand" "")))]
2560 ""
2561 "expand_a_shift (HImode, ASHIFT, operands); DONE;")
2562
2563 (define_expand "lshrhi3"
2564 [(set (match_operand:HI 0 "register_operand" "")
2565 (lshiftrt:HI (match_operand:HI 1 "general_operand" "")
2566 (match_operand:QI 2 "nonmemory_operand" "")))]
2567 ""
2568 "expand_a_shift (HImode, LSHIFTRT, operands); DONE;")
2569
2570 (define_expand "ashrhi3"
2571 [(set (match_operand:HI 0 "register_operand" "")
2572 (ashiftrt:HI (match_operand:HI 1 "register_operand" "")
2573 (match_operand:QI 2 "nonmemory_operand" "")))]
2574 ""
2575 "expand_a_shift (HImode, ASHIFTRT, operands); DONE;")
2576
2577 (define_insn "*shifthi"
2578 [(set (match_operand:HI 0 "register_operand" "=r,r")
2579 (match_operator:HI 3 "nshift_operator"
2580 [ (match_operand:HI 1 "register_operand" "0,0")
2581 (match_operand:QI 2 "nonmemory_operand" "S,rn")]))
2582 (clobber (match_scratch:QI 4 "=X,&r"))]
2583 ""
2584 "* return output_a_shift (operands);"
2585 [(set (attr "length")
2586 (symbol_ref "compute_a_shift_length (insn, operands)"))
2587 (set (attr "cc")
2588 (symbol_ref "compute_a_shift_cc (insn, operands)"))])
2589
2590 ;; SI BIT SHIFTS
2591
2592 (define_expand "ashlsi3"
2593 [(set (match_operand:SI 0 "register_operand" "")
2594 (ashift:SI (match_operand:SI 1 "general_operand" "")
2595 (match_operand:QI 2 "nonmemory_operand" "")))]
2596 ""
2597 "expand_a_shift (SImode, ASHIFT, operands); DONE;")
2598
2599 (define_expand "lshrsi3"
2600 [(set (match_operand:SI 0 "register_operand" "")
2601 (lshiftrt:SI (match_operand:SI 1 "general_operand" "")
2602 (match_operand:QI 2 "nonmemory_operand" "")))]
2603 ""
2604 "expand_a_shift (SImode, LSHIFTRT, operands); DONE;")
2605
2606 (define_expand "ashrsi3"
2607 [(set (match_operand:SI 0 "register_operand" "")
2608 (ashiftrt:SI (match_operand:SI 1 "general_operand" "")
2609 (match_operand:QI 2 "nonmemory_operand" "")))]
2610 ""
2611 "expand_a_shift (SImode, ASHIFTRT, operands); DONE;")
2612
2613 (define_insn "*shiftsi"
2614 [(set (match_operand:SI 0 "register_operand" "=r,r")
2615 (match_operator:SI 3 "nshift_operator"
2616 [ (match_operand:SI 1 "register_operand" "0,0")
2617 (match_operand:QI 2 "nonmemory_operand" "T,rn")]))
2618 (clobber (match_scratch:QI 4 "=X,&r"))]
2619 ""
2620 "* return output_a_shift (operands);"
2621 [(set (attr "length")
2622 (symbol_ref "compute_a_shift_length (insn, operands)"))
2623 (set (attr "cc")
2624 (symbol_ref "compute_a_shift_cc (insn, operands)"))])
2625
2626 ;; Split a variable shift into a loop. If the register containing
2627 ;; the shift count dies, then we just use that register.
2628
2629 (define_split
2630 [(parallel
2631 [(set (match_operand 0 "register_operand" "")
2632 (match_operator 2 "nshift_operator"
2633 [(match_dup 0)
2634 (match_operand:QI 1 "register_operand" "")]))
2635 (clobber (match_operand:QI 3 "register_operand" ""))])]
2636 "flow2_completed
2637 && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))"
2638 [(set (cc0)
2639 (match_dup 1))
2640 (set (pc)
2641 (if_then_else (le (cc0) (const_int 0))
2642 (label_ref (match_dup 5))
2643 (pc)))
2644 (match_dup 4)
2645 (parallel
2646 [(set (match_dup 0)
2647 (match_op_dup 2 [(match_dup 0) (const_int 1)]))
2648 (clobber (scratch:QI))])
2649 (set (match_dup 1)
2650 (plus:QI (match_dup 1) (const_int -1)))
2651 (set (cc0)
2652 (match_dup 1))
2653 (set (pc)
2654 (if_then_else (ne (cc0) (const_int 0))
2655 (label_ref (match_dup 4))
2656 (pc)))
2657 (match_dup 5)]
2658 "operands[4] = gen_label_rtx ();
2659 operands[5] = gen_label_rtx ();")
2660
2661 (define_split
2662 [(parallel
2663 [(set (match_operand 0 "register_operand" "")
2664 (match_operator 2 "nshift_operator"
2665 [(match_dup 0)
2666 (match_operand:QI 1 "register_operand" "")]))
2667 (clobber (match_operand:QI 3 "register_operand" ""))])]
2668 "flow2_completed
2669 && !find_regno_note (insn, REG_DEAD, REGNO (operands[1]))"
2670 [(set (match_dup 3)
2671 (match_dup 1))
2672 (set (cc0)
2673 (match_dup 3))
2674 (set (pc)
2675 (if_then_else (le (cc0) (const_int 0))
2676 (label_ref (match_dup 5))
2677 (pc)))
2678 (match_dup 4)
2679 (parallel
2680 [(set (match_dup 0)
2681 (match_op_dup 2 [(match_dup 0) (const_int 1)]))
2682 (clobber (scratch:QI))])
2683 (set (match_dup 3)
2684 (plus:QI (match_dup 3) (const_int -1)))
2685 (set (cc0)
2686 (match_dup 3))
2687 (set (pc)
2688 (if_then_else (ne (cc0) (const_int 0))
2689 (label_ref (match_dup 4))
2690 (pc)))
2691 (match_dup 5)]
2692 "operands[4] = gen_label_rtx ();
2693 operands[5] = gen_label_rtx ();")
2694 \f
2695 ;; ----------------------------------------------------------------------
2696 ;; ROTATIONS
2697 ;; ----------------------------------------------------------------------
2698
2699 (define_expand "rotlqi3"
2700 [(set (match_operand:QI 0 "register_operand" "")
2701 (rotate:QI (match_operand:QI 1 "register_operand" "")
2702 (match_operand:QI 2 "nonmemory_operand" "")))]
2703 ""
2704 "if (expand_a_rotate (ROTATE, operands)) DONE; else FAIL;")
2705
2706 (define_insn "*rotlqi3_1"
2707 [(set (match_operand:QI 0 "register_operand" "=r")
2708 (rotate:QI (match_operand:QI 1 "register_operand" "0")
2709 (match_operand:QI 2 "immediate_operand" "")))]
2710 ""
2711 "* return output_a_rotate (ROTATE, operands);"
2712 [(set (attr "length")
2713 (symbol_ref "compute_a_rotate_length (operands)"))
2714 (set_attr "cc" "clobber")])
2715
2716 (define_expand "rotlhi3"
2717 [(set (match_operand:HI 0 "register_operand" "")
2718 (rotate:HI (match_operand:HI 1 "register_operand" "")
2719 (match_operand:QI 2 "nonmemory_operand" "")))]
2720 ""
2721 "if (expand_a_rotate (ROTATE, operands)) DONE; else FAIL;")
2722
2723 (define_insn "*rotlhi3_1"
2724 [(set (match_operand:HI 0 "register_operand" "=r")
2725 (rotate:HI (match_operand:HI 1 "register_operand" "0")
2726 (match_operand:QI 2 "immediate_operand" "")))]
2727 ""
2728 "* return output_a_rotate (ROTATE, operands);"
2729 [(set (attr "length")
2730 (symbol_ref "compute_a_rotate_length (operands)"))
2731 (set_attr "cc" "clobber")])
2732
2733 (define_expand "rotlsi3"
2734 [(set (match_operand:SI 0 "register_operand" "")
2735 (rotate:SI (match_operand:SI 1 "register_operand" "")
2736 (match_operand:QI 2 "nonmemory_operand" "")))]
2737 "TARGET_H8300H || TARGET_H8300S"
2738 "if (expand_a_rotate (ROTATE, operands)) DONE; else FAIL;")
2739
2740 (define_insn "*rotlsi3_1"
2741 [(set (match_operand:SI 0 "register_operand" "=r")
2742 (rotate:SI (match_operand:SI 1 "register_operand" "0")
2743 (match_operand:QI 2 "immediate_operand" "")))]
2744 "TARGET_H8300H || TARGET_H8300S"
2745 "* return output_a_rotate (ROTATE, operands);"
2746 [(set (attr "length")
2747 (symbol_ref "compute_a_rotate_length (operands)"))
2748 (set_attr "cc" "clobber")])
2749 \f
2750 ;; -----------------------------------------------------------------
2751 ;; BIT FIELDS
2752 ;; -----------------------------------------------------------------
2753 ;; The H8/300 has given 1/8th of its opcode space to bitfield
2754 ;; instructions so let's use them as well as we can.
2755
2756 ;; You'll never believe all these patterns perform one basic action --
2757 ;; load a bit from the source, optionally invert the bit, then store it
2758 ;; in the destination (which is known to be zero).
2759 ;;
2760 ;; Combine obviously need some work to better identify this situation and
2761 ;; canonicalize the form better.
2762
2763 ;;
2764 ;; Normal loads with a 16bit destination.
2765 ;;
2766
2767 (define_insn ""
2768 [(set (match_operand:HI 0 "register_operand" "=&r")
2769 (zero_extract:HI (match_operand:HI 1 "register_operand" "r")
2770 (const_int 1)
2771 (match_operand:HI 2 "immediate_operand" "n")))]
2772 "TARGET_H8300"
2773 "sub.w %0,%0\;bld %Z2,%Y1\;bst #0,%X0"
2774 [(set_attr "cc" "clobber")
2775 (set_attr "length" "6")])
2776
2777 ;;
2778 ;; Inverted loads with a 16bit destination.
2779 ;;
2780
2781 (define_insn ""
2782 [(set (match_operand:HI 0 "register_operand" "=&r")
2783 (zero_extract:HI (xor:HI (match_operand:HI 1 "register_operand" "r")
2784 (match_operand:HI 3 "const_int_operand" "n"))
2785 (const_int 1)
2786 (match_operand:HI 2 "const_int_operand" "n")))]
2787 "TARGET_H8300
2788 && (1 << INTVAL (operands[2])) == INTVAL (operands[3])"
2789 "sub.w %0,%0\;bild %Z2,%Y1\;bst #0,%X0"
2790 [(set_attr "cc" "clobber")
2791 (set_attr "length" "8")])
2792
2793 ;;
2794 ;; Normal loads with a 32bit destination.
2795 ;;
2796
2797 (define_insn "*extzv_1_r_h8300"
2798 [(set (match_operand:SI 0 "register_operand" "=&r")
2799 (zero_extract:SI (match_operand:HI 1 "register_operand" "r")
2800 (const_int 1)
2801 (match_operand 2 "const_int_operand" "n")))]
2802 "TARGET_H8300
2803 && INTVAL (operands[2]) < 16"
2804 "* return output_simode_bld (0, operands);"
2805 [(set_attr "cc" "clobber")
2806 (set_attr "length" "8")])
2807
2808 (define_insn "*extzv_1_r_h8300hs"
2809 [(set (match_operand:SI 0 "register_operand" "=r,r")
2810 (zero_extract:SI (match_operand:SI 1 "register_operand" "?0,r")
2811 (const_int 1)
2812 (match_operand 2 "const_int_operand" "n,n")))]
2813 "(TARGET_H8300H || TARGET_H8300S)
2814 && INTVAL (operands[2]) < 16"
2815 "* return output_simode_bld (0, operands);"
2816 [(set_attr "cc" "set_znv,set_znv")
2817 (set_attr "length" "8,6")])
2818
2819 ;;
2820 ;; Inverted loads with a 32bit destination.
2821 ;;
2822
2823 (define_insn "*extzv_1_r_inv_h8300"
2824 [(set (match_operand:SI 0 "register_operand" "=&r")
2825 (zero_extract:SI (xor:HI (match_operand:HI 1 "register_operand" "r")
2826 (match_operand:HI 3 "const_int_operand" "n"))
2827 (const_int 1)
2828 (match_operand 2 "const_int_operand" "n")))]
2829 "TARGET_H8300
2830 && INTVAL (operands[2]) < 16
2831 && (1 << INTVAL (operands[2])) == INTVAL (operands[3])"
2832 "* return output_simode_bld (1, operands);"
2833 [(set_attr "cc" "clobber")
2834 (set_attr "length" "8")])
2835
2836 (define_insn "*extzv_1_r_inv_h8300hs"
2837 [(set (match_operand:SI 0 "register_operand" "=r,r")
2838 (zero_extract:SI (xor:SI (match_operand:SI 1 "register_operand" "?0,r")
2839 (match_operand 3 "const_int_operand" "n,n"))
2840 (const_int 1)
2841 (match_operand 2 "const_int_operand" "n,n")))]
2842 "(TARGET_H8300H || TARGET_H8300S)
2843 && INTVAL (operands[2]) < 16
2844 && (1 << INTVAL (operands[2])) == INTVAL (operands[3])"
2845 "* return output_simode_bld (1, operands);"
2846 [(set_attr "cc" "set_znv,set_znv")
2847 (set_attr "length" "8,6")])
2848
2849 (define_expand "insv"
2850 [(set (zero_extract:HI (match_operand:HI 0 "general_operand" "")
2851 (match_operand:HI 1 "general_operand" "")
2852 (match_operand:HI 2 "general_operand" ""))
2853 (match_operand:HI 3 "general_operand" ""))]
2854 "TARGET_H8300"
2855 "
2856 {
2857 /* We only have single bit bit-field instructions. */
2858 if (INTVAL (operands[1]) != 1)
2859 FAIL;
2860
2861 /* For now, we don't allow memory operands. */
2862 if (GET_CODE (operands[0]) == MEM
2863 || GET_CODE (operands[3]) == MEM)
2864 FAIL;
2865 }")
2866
2867 (define_insn ""
2868 [(set (zero_extract:HI (match_operand:HI 0 "register_operand" "+r")
2869 (const_int 1)
2870 (match_operand:HI 1 "immediate_operand" "n"))
2871 (match_operand:HI 2 "register_operand" "r"))]
2872 ""
2873 "bld #0,%R2\;bst %Z1,%Y0 ; i1"
2874 [(set_attr "cc" "clobber")
2875 (set_attr "length" "4")])
2876
2877 (define_expand "extzv"
2878 [(set (match_operand:HI 0 "register_operand" "")
2879 (zero_extract:HI (match_operand:HI 1 "bit_operand" "")
2880 (match_operand:HI 2 "general_operand" "")
2881 (match_operand:HI 3 "general_operand" "")))]
2882 "TARGET_H8300"
2883 "
2884 {
2885 /* We only have single bit bit-field instructions. */
2886 if (INTVAL (operands[2]) != 1)
2887 FAIL;
2888
2889 /* For now, we don't allow memory operands. */
2890 if (GET_CODE (operands[1]) == MEM)
2891 FAIL;
2892 }")
2893
2894 ;; BAND, BOR, and BXOR patterns
2895
2896 (define_insn ""
2897 [(set (match_operand:HI 0 "bit_operand" "=Ur")
2898 (match_operator:HI 4 "bit_operator"
2899 [(zero_extract:HI (match_operand:HI 1 "register_operand" "r")
2900 (const_int 1)
2901 (match_operand:HI 2 "immediate_operand" "n"))
2902 (match_operand:HI 3 "bit_operand" "0")]))]
2903 ""
2904 "bld %Z2,%Y1\;b%c4 #0,%R0\;bst #0,%R0; bl1"
2905 [(set_attr "cc" "clobber")
2906 (set_attr "length" "6")])
2907
2908 (define_insn ""
2909 [(set (match_operand:HI 0 "bit_operand" "=Ur")
2910 (match_operator:HI 5 "bit_operator"
2911 [(zero_extract:HI (match_operand:HI 1 "register_operand" "r")
2912 (const_int 1)
2913 (match_operand:HI 2 "immediate_operand" "n"))
2914 (zero_extract:HI (match_operand:HI 3 "register_operand" "r")
2915 (const_int 1)
2916 (match_operand:HI 4 "immediate_operand" "n"))]))]
2917 ""
2918 "bld %Z2,%Y1\;b%c5 %Z4,%Y3\;bst #0,%R0; bl3"
2919 [(set_attr "cc" "clobber")
2920 (set_attr "length" "6")])
2921 \f
2922 ;; -----------------------------------------------------------------
2923 ;; COMBINE PATTERNS
2924 ;; -----------------------------------------------------------------
2925
2926 ;; insv:SI
2927
2928 (define_insn "*insv_si_1_n"
2929 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
2930 (const_int 1)
2931 (match_operand:SI 1 "const_int_operand" "n"))
2932 (match_operand:SI 2 "register_operand" "r"))]
2933 "(TARGET_H8300H || TARGET_H8300S)
2934 && INTVAL (operands[1]) < 16"
2935 "bld\\t#0,%w2\;bst\\t%Z1,%Y0"
2936 [(set_attr "cc" "clobber")
2937 (set_attr "length" "4")])
2938
2939 (define_insn "*insv_si_1_n_lshiftrt"
2940 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
2941 (const_int 1)
2942 (match_operand:SI 1 "const_int_operand" "n"))
2943 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
2944 (match_operand:SI 3 "const_int_operand" "n")))]
2945 "(TARGET_H8300H || TARGET_H8300S)
2946 && INTVAL (operands[1]) < 16
2947 && INTVAL (operands[3]) < 16"
2948 "bld\\t%Z3,%Y2\;bst\\t%Z1,%Y0"
2949 [(set_attr "cc" "clobber")
2950 (set_attr "length" "4")])
2951
2952 (define_insn "*insv_si_1_n_lshiftrt_16"
2953 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
2954 (const_int 1)
2955 (match_operand:SI 1 "const_int_operand" "n"))
2956 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
2957 (const_int 16)))]
2958 "(TARGET_H8300H || TARGET_H8300S)
2959 && INTVAL (operands[1]) < 16"
2960 "rotr.w\\t%e2\;rotl.w\\t%e2\;bst\\t%Z1,%Y0"
2961 [(set_attr "cc" "clobber")
2962 (set_attr "length" "6")])
2963
2964 (define_insn "*insv_si_8_8"
2965 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
2966 (const_int 8)
2967 (const_int 8))
2968 (match_operand:SI 1 "register_operand" "r"))]
2969 "TARGET_H8300H || TARGET_H8300S"
2970 "mov.b\\t%w1,%x0"
2971 [(set_attr "cc" "clobber")
2972 (set_attr "length" "2")])
2973
2974 (define_insn "*insv_si_8_8_lshiftrt_8"
2975 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
2976 (const_int 8)
2977 (const_int 8))
2978 (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
2979 (const_int 8)))]
2980 "TARGET_H8300H || TARGET_H8300S"
2981 "mov.b\\t%x1,%x0"
2982 [(set_attr "cc" "clobber")
2983 (set_attr "length" "2")])
2984
2985 ;; extzv:SI
2986
2987 (define_insn "*extzv_8_8"
2988 [(set (match_operand:SI 0 "register_operand" "=r,r")
2989 (zero_extract:SI (match_operand:SI 1 "register_operand" "?0,r")
2990 (const_int 8)
2991 (const_int 8)))]
2992 "TARGET_H8300H || TARGET_H8300S"
2993 "@
2994 mov.b\\t%x1,%w0\;extu.w\\t%f0\;extu.l\\t%S0
2995 sub.l\\t%S0,%S0\;mov.b\\t%x1,%w0"
2996 [(set_attr "cc" "set_znv,clobber")
2997 (set_attr "length" "6,4")])
2998
2999 (define_insn "*extzv_8_16"
3000 [(set (match_operand:SI 0 "register_operand" "=r")
3001 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
3002 (const_int 8)
3003 (const_int 16)))]
3004 "TARGET_H8300H || TARGET_H8300S"
3005 "mov.w\\t%e1,%f0\;extu.w\\t%f0\;extu.l\\t%S0"
3006 [(set_attr "cc" "set_znv")
3007 (set_attr "length" "6")])
3008
3009 (define_insn "*extzv_16_8"
3010 [(set (match_operand:SI 0 "register_operand" "=r")
3011 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
3012 (const_int 16)
3013 (const_int 8)))
3014 (clobber (match_scratch:SI 2 "=&r"))]
3015 "TARGET_H8300H"
3016 "mov.w\\t%e1,%f2\;mov.b\\t%x1,%w0\;mov.b\\t%w2,%x0\;extu.l\\t%S0"
3017 [(set_attr "length" "8")
3018 (set_attr "cc" "set_znv")])
3019
3020 ;; Extract the exponent of a float.
3021
3022 (define_insn_and_split "*extzv_8_23"
3023 [(set (match_operand:SI 0 "register_operand" "=r")
3024 (zero_extract:SI (match_operand:SI 1 "register_operand" "0")
3025 (const_int 8)
3026 (const_int 23)))]
3027 "(TARGET_H8300H || TARGET_H8300S)"
3028 "#"
3029 "&& reload_completed"
3030 [(parallel [(set (match_dup 0)
3031 (ashift:SI (match_dup 0)
3032 (const_int 1)))
3033 (clobber (scratch:QI))])
3034 (parallel [(set (match_dup 0)
3035 (lshiftrt:SI (match_dup 0)
3036 (const_int 24)))
3037 (clobber (scratch:QI))])]
3038 "")
3039
3040 ;; and:SI
3041
3042 ;; ((SImode) HImode) << 15
3043
3044 (define_insn_and_split "*twoshifts_l16_r1"
3045 [(set (match_operand:SI 0 "register_operand" "=r")
3046 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
3047 (const_int 15))
3048 (const_int 2147450880)))]
3049 "(TARGET_H8300H || TARGET_H8300S)"
3050 "#"
3051 "&& reload_completed"
3052 [(parallel [(set (match_dup 0)
3053 (ashift:SI (match_dup 0)
3054 (const_int 16)))
3055 (clobber (scratch:QI))])
3056 (parallel [(set (match_dup 0)
3057 (lshiftrt:SI (match_dup 0)
3058 (const_int 1)))
3059 (clobber (scratch:QI))])]
3060 "")
3061
3062 ;; Transform (SImode << B) & 0xffff into (SImode) (HImode << B).
3063
3064 (define_insn_and_split "*andsi3_ashift_n_lower"
3065 [(set (match_operand:SI 0 "register_operand" "=r,r")
3066 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "0,0")
3067 (match_operand:QI 2 "const_int_operand" "S,n"))
3068 (match_operand:SI 3 "const_int_operand" "n,n")))
3069 (clobber (match_scratch:QI 4 "=X,&r"))]
3070 "(TARGET_H8300H || TARGET_H8300S)
3071 && INTVAL (operands[2]) <= 15
3072 && INTVAL (operands[3]) == ((-1 << INTVAL (operands[2])) & 0xffff)"
3073 "#"
3074 "&& reload_completed"
3075 [(parallel [(set (match_dup 5)
3076 (ashift:HI (match_dup 5)
3077 (match_dup 2)))
3078 (clobber (match_dup 4))])
3079 (set (match_dup 0)
3080 (zero_extend:SI (match_dup 5)))]
3081 "operands[5] = gen_rtx_REG (HImode, REGNO (operands[0]));")
3082
3083 ;; Accept (A >> 30) & 2 and the like.
3084
3085 (define_insn "*andsi3_lshiftrt_n_sb"
3086 [(set (match_operand:SI 0 "register_operand" "=r")
3087 (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
3088 (match_operand:SI 2 "const_int_operand" "n"))
3089 (match_operand:SI 3 "single_one_operand" "n")))]
3090 "(TARGET_H8300H || TARGET_H8300S)
3091 && exact_log2 (INTVAL (operands[3])) < 16
3092 && INTVAL (operands[2]) + exact_log2 (INTVAL (operands[3])) == 31"
3093 "*
3094 {
3095 operands[3] = GEN_INT (exact_log2 (INTVAL (operands[3])));
3096 return \"shll.l\\t%S0\;xor.l\\t%S0,%S0\;bst\\t%Z3,%Y0\";
3097 }"
3098 [(set_attr "length" "8")
3099 (set_attr "cc" "clobber")])
3100
3101 (define_insn_and_split "*andsi3_lshiftrt_9_sb"
3102 [(set (match_operand:SI 0 "register_operand" "=r")
3103 (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
3104 (const_int 9))
3105 (const_int 4194304)))]
3106 "(TARGET_H8300H || TARGET_H8300S)"
3107 "#"
3108 "&& reload_completed"
3109 [(set (match_dup 0)
3110 (and:SI (lshiftrt:SI (match_dup 0)
3111 (const_int 25))
3112 (const_int 64)))
3113 (parallel [(set (match_dup 0)
3114 (ashift:SI (match_dup 0)
3115 (const_int 16)))
3116 (clobber (scratch:QI))])]
3117 "")
3118
3119 ;; plus:SI
3120
3121 (define_insn "*addsi3_upper"
3122 [(set (match_operand:SI 0 "register_operand" "=r")
3123 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
3124 (const_int 65536))
3125 (match_operand:SI 2 "register_operand" "0")))]
3126 "TARGET_H8300H || TARGET_H8300S"
3127 "add.w\\t%f1,%e0"
3128 [(set_attr "length" "2")
3129 (set_attr "cc" "clobber")])
3130
3131 (define_insn "*addsi3_lshiftrt_16_zexthi"
3132 [(set (match_operand:SI 0 "register_operand" "=r")
3133 (plus:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3134 (const_int 16))
3135 (zero_extend:SI (match_operand:HI 2 "register_operand" "0"))))]
3136 "TARGET_H8300H || TARGET_H8300S"
3137 "add.w\\t%e1,%f0\;xor.w\\t%e0,%e0\;rotxl.w\\t%e0"
3138 [(set_attr "cc" "clobber")
3139 (set_attr "length" "6")])
3140
3141 (define_insn_and_split "*addsi3_and_r_1"
3142 [(set (match_operand:SI 0 "register_operand" "=r")
3143 (plus:SI (and:SI (match_operand:SI 1 "register_operand" "r")
3144 (const_int 1))
3145 (match_operand:SI 2 "register_operand" "0")))]
3146 "(TARGET_H8300H || TARGET_H8300S)"
3147 "#"
3148 "&& reload_completed"
3149 [(set (cc0)
3150 (zero_extract:SI (match_dup 1)
3151 (const_int 1)
3152 (const_int 0)))
3153 (set (pc)
3154 (if_then_else (eq (cc0)
3155 (const_int 0))
3156 (label_ref (match_dup 3))
3157 (pc)))
3158 (set (match_dup 2)
3159 (plus:SI (match_dup 2)
3160 (const_int 1)))
3161 (match_dup 3)]
3162 "operands[3] = gen_label_rtx ();")
3163
3164 (define_insn_and_split "*addsi3_and_not_r_1"
3165 [(set (match_operand:SI 0 "register_operand" "=r")
3166 (plus:SI (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
3167 (const_int 1))
3168 (match_operand:SI 2 "register_operand" "0")))]
3169 "(TARGET_H8300H || TARGET_H8300S)"
3170 "#"
3171 "&& reload_completed"
3172 [(set (cc0)
3173 (zero_extract:SI (match_dup 1)
3174 (const_int 1)
3175 (const_int 0)))
3176 (set (pc)
3177 (if_then_else (ne (cc0)
3178 (const_int 0))
3179 (label_ref (match_dup 3))
3180 (pc)))
3181 (set (match_dup 2)
3182 (plus:SI (match_dup 2)
3183 (const_int 1)))
3184 (match_dup 3)]
3185 "operands[3] = gen_label_rtx ();")
3186
3187 ;; [ix]or:HI
3188
3189 (define_insn "*ixorhi3_zext"
3190 [(set (match_operand:HI 0 "register_operand" "=r")
3191 (match_operator:HI 1 "iorxor_operator"
3192 [(zero_extend:HI (match_operand:QI 2 "register_operand" "r"))
3193 (match_operand:HI 3 "register_operand" "0")]))]
3194 ""
3195 "%c1.b\\t%X2,%s0"
3196 [(set_attr "cc" "clobber")
3197 (set_attr "length" "2")])
3198
3199 ;; [ix]or:SI
3200
3201 (define_insn "*ixorsi3_zext_qi"
3202 [(set (match_operand:SI 0 "register_operand" "=r")
3203 (match_operator:SI 1 "iorxor_operator"
3204 [(zero_extend:SI (match_operand:QI 2 "register_operand" "r"))
3205 (match_operand:SI 3 "register_operand" "0")]))]
3206 ""
3207 "%c1.b\\t%X2,%w0"
3208 [(set_attr "cc" "clobber")
3209 (set_attr "length" "2")])
3210
3211 (define_insn "*ixorsi3_zext_hi"
3212 [(set (match_operand:SI 0 "register_operand" "=r")
3213 (match_operator:SI 1 "iorxor_operator"
3214 [(zero_extend:SI (match_operand:HI 2 "register_operand" "r"))
3215 (match_operand:SI 3 "register_operand" "0")]))]
3216 "TARGET_H8300H || TARGET_H8300S"
3217 "%c1.w\\t%T2,%f0"
3218 [(set_attr "cc" "clobber")
3219 (set_attr "length" "2")])
3220
3221 (define_insn "*ixorsi3_ashift_16"
3222 [(set (match_operand:SI 0 "register_operand" "=r")
3223 (match_operator:SI 1 "iorxor_operator"
3224 [(ashift:SI (match_operand:SI 2 "register_operand" "r")
3225 (const_int 16))
3226 (match_operand:SI 3 "register_operand" "0")]))]
3227 "TARGET_H8300H || TARGET_H8300S"
3228 "%c1.w\\t%f2,%e0"
3229 [(set_attr "cc" "clobber")
3230 (set_attr "length" "2")])
3231
3232 (define_insn "*ixorsi3_lshiftrt_16"
3233 [(set (match_operand:SI 0 "register_operand" "=r")
3234 (match_operator:SI 1 "iorxor_operator"
3235 [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
3236 (const_int 16))
3237 (match_operand:SI 3 "register_operand" "0")]))]
3238 "TARGET_H8300H || TARGET_H8300S"
3239 "%c1.w\\t%e2,%f0"
3240 [(set_attr "cc" "clobber")
3241 (set_attr "length" "2")])
3242
3243 ;; ior:HI
3244
3245 (define_insn "*iorhi3_ashift_8"
3246 [(set (match_operand:HI 0 "register_operand" "=r")
3247 (ior:HI (ashift:HI (match_operand:HI 1 "register_operand" "r")
3248 (const_int 8))
3249 (match_operand:HI 2 "register_operand" "0")))]
3250 ""
3251 "or.b\\t%s1,%t0"
3252 [(set_attr "cc" "clobber")
3253 (set_attr "length" "2")])
3254
3255 (define_insn "*iorhi3_lshiftrt_8"
3256 [(set (match_operand:HI 0 "register_operand" "=r")
3257 (ior:HI (lshiftrt:HI (match_operand:HI 1 "register_operand" "r")
3258 (const_int 8))
3259 (match_operand:HI 2 "register_operand" "0")))]
3260 ""
3261 "or.b\\t%t1,%s0"
3262 [(set_attr "cc" "clobber")
3263 (set_attr "length" "2")])
3264
3265 (define_insn "*iorhi3_two_qi"
3266 [(set (match_operand:HI 0 "register_operand" "=r")
3267 (ior:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "0"))
3268 (ashift:HI (match_operand:HI 2 "register_operand" "r")
3269 (const_int 8))))]
3270 ""
3271 "mov.b\\t%s2,%t0"
3272 [(set_attr "cc" "clobber")
3273 (set_attr "length" "2")])
3274
3275 (define_insn "*iorhi3_two_qi_mem"
3276 [(set (match_operand:HI 0 "register_operand" "=&r")
3277 (ior:HI (zero_extend:HI (match_operand:QI 1 "memory_operand" "m"))
3278 (ashift:HI (subreg:HI (match_operand:QI 2 "memory_operand" "m") 0)
3279 (const_int 8))))]
3280 ""
3281 "mov.b\\t%X2,%t0\;mov.b\\t%X1,%s0"
3282 [(set_attr "cc" "clobber")
3283 (set_attr "length" "16")])
3284
3285 (define_split
3286 [(set (match_operand:HI 0 "register_operand" "")
3287 (ior:HI (zero_extend:HI (match_operand:QI 1 "memory_operand" ""))
3288 (ashift:HI (subreg:HI (match_operand:QI 2 "memory_operand" "") 0)
3289 (const_int 8))))]
3290 "(TARGET_H8300H || TARGET_H8300S)
3291 && reload_completed
3292 && byte_accesses_mergeable_p (XEXP (operands[2], 0), XEXP (operands[1], 0))"
3293 [(set (match_dup 0)
3294 (match_dup 3))]
3295 "operands[3] = gen_rtx_MEM (HImode, XEXP (operands[2], 0));")
3296
3297 ;; ior:SI
3298
3299 (define_insn "*iorsi3_two_hi"
3300 [(set (match_operand:SI 0 "register_operand" "=r")
3301 (ior:SI (zero_extend:SI (match_operand:HI 1 "register_operand" "0"))
3302 (ashift:SI (match_operand:SI 2 "register_operand" "r")
3303 (const_int 16))))]
3304 "TARGET_H8300H || TARGET_H8300S"
3305 "mov.w\\t%f2,%e0"
3306 [(set_attr "cc" "clobber")
3307 (set_attr "length" "2")])
3308
3309 (define_insn_and_split "*iorsi3_two_qi_zext"
3310 [(set (match_operand:SI 0 "register_operand" "=&r")
3311 (ior:SI (zero_extend:SI (match_operand:QI 1 "memory_operand" "m"))
3312
3313 (and:SI (ashift:SI (subreg:SI (match_operand:QI 2 "memory_operand" "m") 0)
3314 (const_int 8))
3315 (const_int 65280))))]
3316 "(TARGET_H8300H || TARGET_H8300S)"
3317 "#"
3318 "&& reload_completed"
3319 [(set (match_dup 3)
3320 (ior:HI (zero_extend:HI (match_dup 1))
3321 (ashift:HI (subreg:HI (match_dup 2) 0)
3322 (const_int 8))))
3323 (set (match_dup 0)
3324 (zero_extend:SI (match_dup 3)))]
3325 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));")
3326
3327 (define_insn "*iorsi3_e2f"
3328 [(set (match_operand:SI 0 "register_operand" "=r")
3329 (ior:SI (and:SI (match_operand:SI 1 "register_operand" "0")
3330 (const_int -65536))
3331 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
3332 (const_int 16))))]
3333 "TARGET_H8300H || TARGET_H8300S"
3334 "mov.w\\t%e2,%f0"
3335 [(set_attr "length" "2")
3336 (set_attr "cc" "clobber")])
3337
3338 (define_insn_and_split "*iorsi3_two_qi_sext"
3339 [(set (match_operand:SI 0 "register_operand" "=r")
3340 (ior:SI (zero_extend:SI (match_operand:QI 1 "register_operand" "0"))
3341 (ashift:SI (sign_extend:SI (match_operand:QI 2 "register_operand" "r"))
3342 (const_int 8))))]
3343 "(TARGET_H8300H || TARGET_H8300S)"
3344 "#"
3345 "&& reload_completed"
3346 [(set (match_dup 3)
3347 (ior:HI (zero_extend:HI (match_dup 1))
3348 (ashift:HI (match_dup 4)
3349 (const_int 8))))
3350 (set (match_dup 0)
3351 (sign_extend:SI (match_dup 3)))]
3352 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));
3353 operands[4] = gen_rtx_REG (HImode, REGNO (operands[2]));")
3354
3355 (define_insn "*iorsi3_w"
3356 [(set (match_operand:SI 0 "register_operand" "=r,&r")
3357 (ior:SI (and:SI (match_operand:SI 1 "register_operand" "0,0")
3358 (const_int -256))
3359 (zero_extend:SI (match_operand:QI 2 "general_operand_src" "r,g>"))))]
3360 "TARGET_H8300H || TARGET_H8300S"
3361 "mov.b\\t%X2,%w0"
3362 [(set_attr "length" "2,8")
3363 (set_attr "cc" "clobber,clobber")])
3364
3365 (define_insn "*iorsi3_ashift_31"
3366 [(set (match_operand:SI 0 "register_operand" "=&r")
3367 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
3368 (const_int 31))
3369 (match_operand:SI 2 "register_operand" "0")))]
3370 "TARGET_H8300H || TARGET_H8300S"
3371 "rotxl.l\\t%S0\;bor\\t#0,%w1\;rotxr.l\\t%S0"
3372 [(set_attr "length" "6")
3373 (set_attr "cc" "set_znv")])
3374
3375 (define_insn "*iorsi3_and_ashift"
3376 [(set (match_operand:SI 0 "register_operand" "=r")
3377 (ior:SI (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
3378 (match_operand:SI 2 "const_int_operand" "n"))
3379 (match_operand:SI 3 "single_one_operand" "n"))
3380 (match_operand:SI 4 "register_operand" "0")))]
3381 "(TARGET_H8300H || TARGET_H8300S)
3382 && (INTVAL (operands[3]) & ~0xffff) == 0"
3383 "*
3384 {
3385 rtx srcpos = GEN_INT (exact_log2 (INTVAL (operands[3]))
3386 - INTVAL (operands[2]));
3387 rtx dstpos = GEN_INT (exact_log2 (INTVAL (operands[3])));
3388 operands[2] = srcpos;
3389 operands[3] = dstpos;
3390 return \"bld\\t%Z2,%Y1\;bor\\t%Z3,%Y0\;bst\\t%Z3,%Y0\";
3391 }"
3392 [(set_attr "length" "6")
3393 (set_attr "cc" "clobber")])
3394
3395 (define_insn "*iorsi3_and_lshiftrt"
3396 [(set (match_operand:SI 0 "register_operand" "=r")
3397 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3398 (match_operand:SI 2 "const_int_operand" "n"))
3399 (match_operand:SI 3 "single_one_operand" "n"))
3400 (match_operand:SI 4 "register_operand" "0")))]
3401 "(TARGET_H8300H || TARGET_H8300S)
3402 && ((INTVAL (operands[3]) << INTVAL (operands[2])) & ~0xffff) == 0"
3403 "*
3404 {
3405 rtx srcpos = GEN_INT (exact_log2 (INTVAL (operands[3]))
3406 + INTVAL (operands[2]));
3407 rtx dstpos = GEN_INT (exact_log2 (INTVAL (operands[3])));
3408 operands[2] = srcpos;
3409 operands[3] = dstpos;
3410 return \"bld\\t%Z2,%Y1\;bor\\t%Z3,%Y0\;bst\\t%Z3,%Y0\";
3411 }"
3412 [(set_attr "length" "6")
3413 (set_attr "cc" "clobber")])
3414
3415 (define_insn "*iorsi3_zero_extract"
3416 [(set (match_operand:SI 0 "register_operand" "=r")
3417 (ior:SI (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
3418 (const_int 1)
3419 (match_operand:SI 2 "const_int_operand" "n"))
3420 (match_operand:SI 3 "register_operand" "0")))]
3421 "(TARGET_H8300H || TARGET_H8300S)
3422 && INTVAL (operands[2]) < 16"
3423 "bld\\t%Z2,%Y1\;bor\\t#0,%w0\;bst\\t#0,%w0"
3424 [(set_attr "length" "6")
3425 (set_attr "cc" "clobber")])
3426
3427 (define_insn "*iorsi3_and_lshiftrt_n_sb"
3428 [(set (match_operand:SI 0 "register_operand" "=r")
3429 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3430 (const_int 30))
3431 (const_int 2))
3432 (match_operand:SI 2 "register_operand" "0")))]
3433 "(TARGET_H8300H || TARGET_H8300S)"
3434 "rotl.l\\t%S1\;rotr.l\\t%S1\;bor\\t#1,%w0\;bst\\t#1,%w0"
3435 [(set_attr "length" "8")
3436 (set_attr "cc" "clobber")])
3437
3438 (define_insn "*iorsi3_and_lshiftrt_9_sb"
3439 [(set (match_operand:SI 0 "register_operand" "=r")
3440 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3441 (const_int 9))
3442 (const_int 4194304))
3443 (match_operand:SI 2 "register_operand" "0")))
3444 (clobber (match_scratch:HI 3 "=&r"))]
3445 "(TARGET_H8300H || TARGET_H8300S)"
3446 "*
3447 {
3448 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3449 return \"shll.l\\t%S1\;xor.w\\t%T3,%T3\;bst\\t#6,%s3\;or.w\\t%T3,%e0\";
3450 else
3451 return \"rotl.l\\t%S1\;rotr.l\\t%S1\;xor.w\\t%T3,%T3\;bst\\t#6,%s3\;or.w\\t%T3,%e0\";
3452 }"
3453 [(set_attr "length" "10")
3454 (set_attr "cc" "clobber")])
3455
3456 ;; Used to OR the exponent of a float.
3457
3458 (define_insn "*iorsi3_shift"
3459 [(set (match_operand:SI 0 "register_operand" "=r")
3460 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
3461 (const_int 23))
3462 (match_operand:SI 2 "register_operand" "0")))
3463 (clobber (match_scratch:SI 3 "=&r"))]
3464 "TARGET_H8300H || TARGET_H8300S"
3465 "#")
3466
3467 (define_split
3468 [(parallel
3469 [(set (match_operand:SI 0 "register_operand" "")
3470 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
3471 (const_int 23))
3472 (match_dup 0)))
3473 (clobber (match_operand:SI 2 "register_operand" ""))])]
3474 "(TARGET_H8300H || TARGET_H8300S)
3475 && flow2_completed
3476 && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
3477 && REGNO (operands[0]) != REGNO (operands[1])"
3478 [(parallel [(set (match_dup 3)
3479 (ashift:HI (match_dup 3)
3480 (const_int 7)))
3481 (clobber (scratch:QI))])
3482 (set (match_dup 0)
3483 (ior:SI (ashift:SI (match_dup 1)
3484 (const_int 16))
3485 (match_dup 0)))]
3486 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[1]));")
3487
3488 (define_split
3489 [(parallel
3490 [(set (match_operand:SI 0 "register_operand" "")
3491 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
3492 (const_int 23))
3493 (match_dup 0)))
3494 (clobber (match_operand:SI 2 "register_operand" ""))])]
3495 "(TARGET_H8300H || TARGET_H8300S)
3496 && flow2_completed
3497 && !(find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
3498 && REGNO (operands[0]) != REGNO (operands[1]))"
3499 [(set (match_dup 2)
3500 (match_dup 1))
3501 (parallel [(set (match_dup 3)
3502 (ashift:HI (match_dup 3)
3503 (const_int 7)))
3504 (clobber (scratch:QI))])
3505 (set (match_dup 0)
3506 (ior:SI (ashift:SI (match_dup 2)
3507 (const_int 16))
3508 (match_dup 0)))]
3509 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[2]));")
3510
3511 (define_insn "*iorsi2_and_1_lshiftrt_1"
3512 [(set (match_operand:SI 0 "register_operand" "=r")
3513 (ior:SI (and:SI (match_operand:SI 1 "register_operand" "0")
3514 (const_int 1))
3515 (lshiftrt:SI (match_dup 1)
3516 (const_int 1))))]
3517 "TARGET_H8300H || TARGET_H8300S"
3518 "shlr.l\\t%S0\;bor\\t#0,%w0\;bst\\t#0,%w0"
3519 [(set_attr "length" "6")
3520 (set_attr "cc" "clobber")])
3521
3522 (define_insn_and_split "*iorsi3_ashift_16_ashift_24"
3523 [(set (match_operand:SI 0 "register_operand" "=r")
3524 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
3525 (const_int 16))
3526 (ashift:SI (match_operand:SI 2 "register_operand" "r")
3527 (const_int 24))))]
3528 "(TARGET_H8300H || TARGET_H8300S)"
3529 "#"
3530 "&& reload_completed"
3531 [(set (match_dup 3)
3532 (ior:HI (ashift:HI (match_dup 4)
3533 (const_int 8))
3534 (match_dup 3)))
3535 (parallel [(set (match_dup 0)
3536 (ashift:SI (match_dup 0)
3537 (const_int 16)))
3538 (clobber (scratch:QI))])]
3539 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));
3540 operands[4] = gen_rtx_REG (HImode, REGNO (operands[2]));")
3541
3542 (define_insn_and_split "*iorsi3_ashift_16_ashift_24_mem"
3543 [(set (match_operand:SI 0 "register_operand" "=&r")
3544 (ior:SI (and:SI (ashift:SI (subreg:SI (match_operand:QI 1 "memory_operand" "m") 0)
3545 (const_int 16))
3546 (const_int 16711680))
3547 (ashift:SI (subreg:SI (match_operand:QI 2 "memory_operand" "m") 0)
3548 (const_int 24))))]
3549 "(TARGET_H8300H || TARGET_H8300S)"
3550 "#"
3551 "&& reload_completed"
3552 [(set (match_dup 3)
3553 (ior:HI (zero_extend:HI (match_dup 1))
3554 (ashift:HI (subreg:HI (match_dup 2) 0)
3555 (const_int 8))))
3556 (parallel [(set (match_dup 0)
3557 (ashift:SI (match_dup 0)
3558 (const_int 16)))
3559 (clobber (scratch:QI))])]
3560 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));")
3561
3562 ;; Used to add the exponent of a float.
3563
3564 (define_insn "*addsi3_shift"
3565 [(set (match_operand:SI 0 "register_operand" "=r")
3566 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
3567 (const_int 8388608))
3568 (match_operand:SI 2 "register_operand" "0")))
3569 (clobber (match_scratch:SI 3 "=&r"))]
3570 "TARGET_H8300H || TARGET_H8300S"
3571 "#")
3572
3573 (define_split
3574 [(parallel
3575 [(set (match_operand:SI 0 "register_operand" "")
3576 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
3577 (const_int 8388608))
3578 (match_dup 0)))
3579 (clobber (match_operand:SI 2 "register_operand" ""))])]
3580 "(TARGET_H8300H || TARGET_H8300S)
3581 && flow2_completed
3582 && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
3583 && REGNO (operands[0]) != REGNO (operands[1])"
3584 [(parallel [(set (match_dup 3)
3585 (ashift:HI (match_dup 3)
3586 (const_int 7)))
3587 (clobber (scratch:QI))])
3588 (set (match_dup 0)
3589 (plus:SI (mult:SI (match_dup 1)
3590 (const_int 65536))
3591 (match_dup 0)))]
3592 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[1]));")
3593
3594 (define_split
3595 [(parallel
3596 [(set (match_operand:SI 0 "register_operand" "")
3597 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
3598 (const_int 8388608))
3599 (match_dup 0)))
3600 (clobber (match_operand:SI 2 "register_operand" ""))])]
3601 "(TARGET_H8300H || TARGET_H8300S)
3602 && flow2_completed
3603 && !(find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
3604 && REGNO (operands[0]) != REGNO (operands[1]))"
3605 [(set (match_dup 2)
3606 (match_dup 1))
3607 (parallel [(set (match_dup 3)
3608 (ashift:HI (match_dup 3)
3609 (const_int 7)))
3610 (clobber (scratch:QI))])
3611 (set (match_dup 0)
3612 (plus:SI (mult:SI (match_dup 2)
3613 (const_int 65536))
3614 (match_dup 0)))]
3615 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[2]));")
3616
3617 ;; ashift:SI
3618
3619 (define_insn_and_split "*ashiftsi_sextqi_7"
3620 [(set (match_operand:SI 0 "register_operand" "=r")
3621 (ashift:SI (sign_extend:SI (match_operand:QI 1 "register_operand" "0"))
3622 (const_int 7)))]
3623 "(TARGET_H8300H || TARGET_H8300S)"
3624 "#"
3625 "&& reload_completed"
3626 [(parallel [(set (match_dup 2)
3627 (ashift:HI (match_dup 2)
3628 (const_int 8)))
3629 (clobber (scratch:QI))])
3630 (set (match_dup 0)
3631 (sign_extend:SI (match_dup 2)))
3632 (parallel [(set (match_dup 0)
3633 (ashiftrt:SI (match_dup 0)
3634 (const_int 1)))
3635 (clobber (scratch:QI))])]
3636 "operands[2] = gen_rtx_REG (HImode, REGNO (operands[0]));")
3637
3638 ;; Storing a part of HImode to QImode.
3639
3640 (define_insn ""
3641 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
3642 (subreg:QI (lshiftrt:HI (match_operand:HI 1 "register_operand" "r")
3643 (const_int 8)) 1))]
3644 ""
3645 "mov.b\\t%t1,%R0"
3646 [(set_attr "cc" "set_znv")
3647 (set_attr "length" "8")])
3648
3649 ;; Storing a part of SImode to QImode.
3650
3651 (define_insn ""
3652 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
3653 (subreg:QI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3654 (const_int 8)) 3))]
3655 ""
3656 "mov.b\\t%x1,%R0"
3657 [(set_attr "cc" "set_znv")
3658 (set_attr "length" "8")])
3659
3660 (define_insn ""
3661 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
3662 (subreg:QI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3663 (const_int 16)) 3))
3664 (clobber (match_scratch:SI 2 "=&r"))]
3665 "TARGET_H8300H || TARGET_H8300S"
3666 "mov.w\\t%e1,%f2\;mov.b\\t%w2,%R0"
3667 [(set_attr "cc" "set_znv")
3668 (set_attr "length" "10")])
3669
3670 (define_insn ""
3671 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
3672 (subreg:QI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3673 (const_int 24)) 3))
3674 (clobber (match_scratch:SI 2 "=&r"))]
3675 "TARGET_H8300H || TARGET_H8300S"
3676 "mov.w\\t%e1,%f2\;mov.b\\t%x2,%R0"
3677 [(set_attr "cc" "set_znv")
3678 (set_attr "length" "10")])
3679
3680 (define_insn_and_split ""
3681 [(set (pc)
3682 (if_then_else (eq (zero_extract:SI (subreg:SI (match_operand:QI 0 "register_operand" "") 0)
3683 (const_int 1)
3684 (const_int 7))
3685 (const_int 0))
3686 (label_ref (match_operand 1 "" ""))
3687 (pc)))]
3688 ""
3689 "#"
3690 ""
3691 [(set (cc0)
3692 (match_dup 0))
3693 (set (pc)
3694 (if_then_else (ge (cc0)
3695 (const_int 0))
3696 (label_ref (match_dup 1))
3697 (pc)))]
3698 "")
3699
3700 (define_insn_and_split ""
3701 [(set (pc)
3702 (if_then_else (ne (zero_extract:SI (subreg:SI (match_operand:QI 0 "register_operand" "") 0)
3703 (const_int 1)
3704 (const_int 7))
3705 (const_int 0))
3706 (label_ref (match_operand 1 "" ""))
3707 (pc)))]
3708 ""
3709 "#"
3710 ""
3711 [(set (cc0)
3712 (match_dup 0))
3713 (set (pc)
3714 (if_then_else (lt (cc0)
3715 (const_int 0))
3716 (label_ref (match_dup 1))
3717 (pc)))]
3718 "")
3719 \f
3720 ;; -----------------------------------------------------------------
3721 ;; PEEPHOLE PATTERNS
3722 ;; -----------------------------------------------------------------
3723
3724 ;; Convert (A >> B) & C to (A & 255) >> B if C == 255 >> B.
3725
3726 (define_peephole2
3727 [(parallel
3728 [(set (match_operand:HI 0 "register_operand" "")
3729 (lshiftrt:HI (match_dup 0)
3730 (match_operand:HI 1 "const_int_operand" "")))
3731 (clobber (match_operand:HI 2 "" ""))])
3732 (set (match_dup 0)
3733 (and:HI (match_dup 0)
3734 (match_operand:HI 3 "const_int_operand" "")))]
3735 "INTVAL (operands[3]) == (255 >> INTVAL (operands[1]))"
3736 [(set (match_dup 0)
3737 (and:HI (match_dup 0)
3738 (const_int 255)))
3739 (parallel
3740 [(set (match_dup 0)
3741 (lshiftrt:HI (match_dup 0)
3742 (match_dup 1)))
3743 (clobber (match_dup 2))])]
3744 "")
3745
3746 ;; Convert (A << B) & C to (A & 255) << B if C == 255 << B.
3747
3748 (define_peephole2
3749 [(parallel
3750 [(set (match_operand:HI 0 "register_operand" "")
3751 (ashift:HI (match_dup 0)
3752 (match_operand:HI 1 "const_int_operand" "")))
3753 (clobber (match_operand:HI 2 "" ""))])
3754 (set (match_dup 0)
3755 (and:HI (match_dup 0)
3756 (match_operand:HI 3 "const_int_operand" "")))]
3757 "INTVAL (operands[3]) == (255 << INTVAL (operands[1]))"
3758 [(set (match_dup 0)
3759 (and:HI (match_dup 0)
3760 (const_int 255)))
3761 (parallel
3762 [(set (match_dup 0)
3763 (ashift:HI (match_dup 0)
3764 (match_dup 1)))
3765 (clobber (match_dup 2))])]
3766 "")
3767
3768 ;; Convert (A >> B) & C to (A & 255) >> B if C == 255 >> B.
3769
3770 (define_peephole2
3771 [(parallel
3772 [(set (match_operand:SI 0 "register_operand" "")
3773 (lshiftrt:SI (match_dup 0)
3774 (match_operand:SI 1 "const_int_operand" "")))
3775 (clobber (match_operand:SI 2 "" ""))])
3776 (set (match_dup 0)
3777 (and:SI (match_dup 0)
3778 (match_operand:SI 3 "const_int_operand" "")))]
3779 "INTVAL (operands[3]) == (255 >> INTVAL (operands[1]))"
3780 [(set (match_dup 0)
3781 (and:SI (match_dup 0)
3782 (const_int 255)))
3783 (parallel
3784 [(set (match_dup 0)
3785 (lshiftrt:SI (match_dup 0)
3786 (match_dup 1)))
3787 (clobber (match_dup 2))])]
3788 "")
3789
3790 ;; Convert (A << B) & C to (A & 255) << B if C == 255 << B.
3791
3792 (define_peephole2
3793 [(parallel
3794 [(set (match_operand:SI 0 "register_operand" "")
3795 (ashift:SI (match_dup 0)
3796 (match_operand:SI 1 "const_int_operand" "")))
3797 (clobber (match_operand:SI 2 "" ""))])
3798 (set (match_dup 0)
3799 (and:SI (match_dup 0)
3800 (match_operand:SI 3 "const_int_operand" "")))]
3801 "INTVAL (operands[3]) == (255 << INTVAL (operands[1]))"
3802 [(set (match_dup 0)
3803 (and:SI (match_dup 0)
3804 (const_int 255)))
3805 (parallel
3806 [(set (match_dup 0)
3807 (ashift:SI (match_dup 0)
3808 (match_dup 1)))
3809 (clobber (match_dup 2))])]
3810 "")
3811
3812 ;; Convert (A >> B) & C to (A & 65535) >> B if C == 65535 >> B.
3813
3814 (define_peephole2
3815 [(parallel
3816 [(set (match_operand:SI 0 "register_operand" "")
3817 (lshiftrt:SI (match_dup 0)
3818 (match_operand:SI 1 "const_int_operand" "")))
3819 (clobber (match_operand:SI 2 "" ""))])
3820 (set (match_dup 0)
3821 (and:SI (match_dup 0)
3822 (match_operand:SI 3 "const_int_operand" "")))]
3823 "INTVAL (operands[3]) == (65535 >> INTVAL (operands[1]))"
3824 [(set (match_dup 0)
3825 (and:SI (match_dup 0)
3826 (const_int 65535)))
3827 (parallel
3828 [(set (match_dup 0)
3829 (lshiftrt:SI (match_dup 0)
3830 (match_dup 1)))
3831 (clobber (match_dup 2))])]
3832 "")
3833
3834 ;; Convert (A << B) & C to (A & 65535) << B if C == 65535 << B.
3835
3836 (define_peephole2
3837 [(parallel
3838 [(set (match_operand:SI 0 "register_operand" "")
3839 (ashift:SI (match_dup 0)
3840 (match_operand:SI 1 "const_int_operand" "")))
3841 (clobber (match_operand:SI 2 "" ""))])
3842 (set (match_dup 0)
3843 (and:SI (match_dup 0)
3844 (match_operand:SI 3 "const_int_operand" "")))]
3845 "INTVAL (operands[3]) == (65535 << INTVAL (operands[1]))"
3846 [(set (match_dup 0)
3847 (and:SI (match_dup 0)
3848 (const_int 65535)))
3849 (parallel
3850 [(set (match_dup 0)
3851 (ashift:SI (match_dup 0)
3852 (match_dup 1)))
3853 (clobber (match_dup 2))])]
3854 "")
3855
3856 ;; Convert a QImode push into an SImode push so that the
3857 ;; define_peephole2 below can cram multiple pushes into one stm.l.
3858
3859 (define_peephole2
3860 [(parallel [(set (reg:SI SP_REG)
3861 (plus:SI (reg:SI SP_REG) (const_int -4)))
3862 (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int -3)))
3863 (match_operand:QI 0 "register_operand" ""))])]
3864 "TARGET_H8300S && !TARGET_NORMAL_MODE"
3865 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
3866 (match_dup 0))]
3867 "operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
3868
3869 (define_peephole2
3870 [(parallel [(set (reg:HI SP_REG)
3871 (plus:HI (reg:HI SP_REG) (const_int -4)))
3872 (set (mem:QI (plus:HI (reg:HI SP_REG) (const_int -3)))
3873 (match_operand:QI 0 "register_operand" ""))])]
3874 "TARGET_H8300S && TARGET_NORMAL_MODE"
3875 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
3876 (match_dup 0))]
3877 "operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
3878
3879 ;; Convert a HImode push into an SImode push so that the
3880 ;; define_peephole2 below can cram multiple pushes into one stm.l.
3881
3882 (define_peephole2
3883 [(parallel [(set (reg:SI SP_REG)
3884 (plus:SI (reg:SI SP_REG) (const_int -4)))
3885 (set (mem:HI (plus:SI (reg:SI SP_REG) (const_int -2)))
3886 (match_operand:HI 0 "register_operand" ""))])]
3887 "TARGET_H8300S && !TARGET_NORMAL_MODE"
3888 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
3889 (match_dup 0))]
3890 "operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
3891
3892 (define_peephole2
3893 [(parallel [(set (reg:HI SP_REG)
3894 (plus:HI (reg:HI SP_REG) (const_int -4)))
3895 (set (mem:HI (plus:HI (reg:HI SP_REG) (const_int -2)))
3896 (match_operand:HI 0 "register_operand" ""))])]
3897 "TARGET_H8300S && TARGET_NORMAL_MODE"
3898 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
3899 (match_dup 0))]
3900 "operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
3901
3902 ;; Cram four pushes into stm.l.
3903
3904 (define_peephole2
3905 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
3906 (match_operand:SI 0 "register_operand" ""))
3907 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
3908 (match_operand:SI 1 "register_operand" ""))
3909 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
3910 (match_operand:SI 2 "register_operand" ""))
3911 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
3912 (match_operand:SI 3 "register_operand" ""))]
3913 "TARGET_H8300S && !TARGET_NORMAL_MODE
3914 && REGNO (operands[0]) == 0
3915 && REGNO (operands[1]) == 1
3916 && REGNO (operands[2]) == 2
3917 && REGNO (operands[3]) == 3"
3918 [(parallel [(set (reg:SI SP_REG)
3919 (plus:SI (reg:SI SP_REG)
3920 (const_int -16)))
3921 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
3922 (match_dup 0))
3923 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
3924 (match_dup 1))
3925 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -12)))
3926 (match_dup 2))
3927 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -16)))
3928 (match_dup 3))])]
3929 "")
3930
3931 (define_peephole2
3932 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
3933 (match_operand:SI 0 "register_operand" ""))
3934 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
3935 (match_operand:SI 1 "register_operand" ""))
3936 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
3937 (match_operand:SI 2 "register_operand" ""))
3938 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
3939 (match_operand:SI 3 "register_operand" ""))]
3940 "TARGET_H8300S && TARGET_NORMAL_MODE
3941 && REGNO (operands[0]) == 0
3942 && REGNO (operands[1]) == 1
3943 && REGNO (operands[2]) == 2
3944 && REGNO (operands[3]) == 3"
3945 [(parallel [(set (reg:HI SP_REG)
3946 (plus:HI (reg:HI SP_REG)
3947 (const_int -16)))
3948 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
3949 (match_dup 0))
3950 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
3951 (match_dup 1))
3952 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
3953 (match_dup 2))
3954 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -16)))
3955 (match_dup 3))])]
3956 "")
3957
3958 ;; Cram three pushes into stm.l.
3959
3960 (define_peephole2
3961 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
3962 (match_operand:SI 0 "register_operand" ""))
3963 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
3964 (match_operand:SI 1 "register_operand" ""))
3965 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
3966 (match_operand:SI 2 "register_operand" ""))]
3967 "TARGET_H8300S && !TARGET_NORMAL_MODE
3968 && ((REGNO (operands[0]) == 0
3969 && REGNO (operands[1]) == 1
3970 && REGNO (operands[2]) == 2)
3971 || (REGNO (operands[0]) == 4
3972 && REGNO (operands[1]) == 5
3973 && REGNO (operands[2]) == 6))"
3974 [(parallel [(set (reg:SI SP_REG)
3975 (plus:SI (reg:SI SP_REG)
3976 (const_int -12)))
3977 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
3978 (match_dup 0))
3979 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
3980 (match_dup 1))
3981 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -12)))
3982 (match_dup 2))])]
3983 "")
3984
3985 (define_peephole2
3986 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
3987 (match_operand:SI 0 "register_operand" ""))
3988 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
3989 (match_operand:SI 1 "register_operand" ""))
3990 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
3991 (match_operand:SI 2 "register_operand" ""))]
3992 "TARGET_H8300S && TARGET_NORMAL_MODE
3993 && ((REGNO (operands[0]) == 0
3994 && REGNO (operands[1]) == 1
3995 && REGNO (operands[2]) == 2)
3996 || (REGNO (operands[0]) == 4
3997 && REGNO (operands[1]) == 5
3998 && REGNO (operands[2]) == 6))"
3999 [(parallel [(set (reg:HI SP_REG)
4000 (plus:HI (reg:HI SP_REG)
4001 (const_int -12)))
4002 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
4003 (match_dup 0))
4004 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
4005 (match_dup 1))
4006 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
4007 (match_dup 2))])]
4008 "")
4009
4010 ;; Cram two pushes into stm.l.
4011
4012 (define_peephole2
4013 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4014 (match_operand:SI 0 "register_operand" ""))
4015 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4016 (match_operand:SI 1 "register_operand" ""))]
4017 "TARGET_H8300S && !TARGET_NORMAL_MODE
4018 && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
4019 || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
4020 || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
4021 [(parallel [(set (reg:SI SP_REG)
4022 (plus:SI (reg:SI SP_REG)
4023 (const_int -8)))
4024 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
4025 (match_dup 0))
4026 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
4027 (match_dup 1))])]
4028 "")
4029
4030 (define_peephole2
4031 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4032 (match_operand:SI 0 "register_operand" ""))
4033 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4034 (match_operand:SI 1 "register_operand" ""))]
4035 "TARGET_H8300S && TARGET_NORMAL_MODE
4036 && ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
4037 || (REGNO (operands[0]) == 2 && REGNO (operands[1]) == 3)
4038 || (REGNO (operands[0]) == 4 && REGNO (operands[1]) == 5))"
4039 [(parallel [(set (reg:HI SP_REG)
4040 (plus:HI (reg:HI SP_REG)
4041 (const_int -8)))
4042 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
4043 (match_dup 0))
4044 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
4045 (match_dup 1))])]
4046 "")
4047
4048 ;; Turn
4049 ;;
4050 ;; mov.w #2,r0
4051 ;; add.w r7,r0 (6 bytes)
4052 ;;
4053 ;; into
4054 ;;
4055 ;; mov.w r7,r0
4056 ;; adds #2,r0 (4 bytes)
4057
4058 (define_peephole2
4059 [(set (match_operand:HI 0 "register_operand" "")
4060 (match_operand:HI 1 "const_int_operand" ""))
4061 (set (match_dup 0)
4062 (plus:HI (match_dup 0)
4063 (match_operand:HI 2 "register_operand" "")))]
4064 "REG_P (operands[0]) && REG_P (operands[2])
4065 && REGNO (operands[0]) != REGNO (operands[2])
4066 && (CONST_OK_FOR_J (INTVAL (operands[1]))
4067 || CONST_OK_FOR_L (INTVAL (operands[1]))
4068 || CONST_OK_FOR_N (INTVAL (operands[1])))"
4069 [(set (match_dup 0)
4070 (match_dup 2))
4071 (set (match_dup 0)
4072 (plus:HI (match_dup 0)
4073 (match_dup 1)))]
4074 "")
4075
4076 ;; Turn
4077 ;;
4078 ;; sub.l er0,er0
4079 ;; add.b #4,r0l
4080 ;; add.l er7,er0 (6 bytes)
4081 ;;
4082 ;; into
4083 ;;
4084 ;; mov.l er7,er0
4085 ;; adds #4,er0 (4 bytes)
4086
4087 (define_peephole2
4088 [(set (match_operand:SI 0 "register_operand" "")
4089 (match_operand:SI 1 "const_int_operand" ""))
4090 (set (match_dup 0)
4091 (plus:SI (match_dup 0)
4092 (match_operand:SI 2 "register_operand" "")))]
4093 "(TARGET_H8300H || TARGET_H8300S)
4094 && REG_P (operands[0]) && REG_P (operands[2])
4095 && REGNO (operands[0]) != REGNO (operands[2])
4096 && (CONST_OK_FOR_L (INTVAL (operands[1]))
4097 || CONST_OK_FOR_N (INTVAL (operands[1])))"
4098 [(set (match_dup 0)
4099 (match_dup 2))
4100 (set (match_dup 0)
4101 (plus:SI (match_dup 0)
4102 (match_dup 1)))]
4103 "")
4104
4105 ;; Turn
4106 ;;
4107 ;; mov.l er7,er0
4108 ;; add.l #10,er0 (takes 8 bytes)
4109 ;;
4110 ;; into
4111 ;;
4112 ;; sub.l er0,er0
4113 ;; add.b #10,r0l
4114 ;; add.l er7,er0 (takes 6 bytes)
4115
4116 (define_peephole2
4117 [(set (match_operand:SI 0 "register_operand" "")
4118 (match_operand:SI 1 "register_operand" ""))
4119 (set (match_dup 0)
4120 (plus:SI (match_dup 0)
4121 (match_operand:SI 2 "const_int_operand" "")))]
4122 "(TARGET_H8300H || TARGET_H8300S)
4123 && REG_P (operands[0]) && REG_P (operands[1])
4124 && REGNO (operands[0]) != REGNO (operands[1])
4125 && !CONST_OK_FOR_L (INTVAL (operands[2]))
4126 && !CONST_OK_FOR_N (INTVAL (operands[2]))
4127 && ((INTVAL (operands[2]) & 0xff) == INTVAL (operands[2])
4128 || (INTVAL (operands[2]) & 0xff00) == INTVAL (operands[2])
4129 || INTVAL (operands[2]) == 0xffff
4130 || INTVAL (operands[2]) == 0xfffe)"
4131 [(set (match_dup 0)
4132 (match_dup 2))
4133 (set (match_dup 0)
4134 (plus:SI (match_dup 0)
4135 (match_dup 1)))]
4136 "")
4137
4138 ;; Turn
4139 ;;
4140 ;; subs #1,er4
4141 ;; mov.w r4,r4
4142 ;; bne .L2028
4143 ;;
4144 ;; into
4145 ;;
4146 ;; dec.w #1,r4
4147 ;; bne .L2028
4148
4149 (define_peephole2
4150 [(set (match_operand:HI 0 "register_operand" "")
4151 (plus:HI (match_dup 0)
4152 (match_operand 1 "incdec_operand" "")))
4153 (set (cc0)
4154 (match_dup 0))
4155 (set (pc)
4156 (if_then_else (match_operator 3 "eqne_operator"
4157 [(cc0) (const_int 0)])
4158 (label_ref (match_operand 2 "" ""))
4159 (pc)))]
4160 "TARGET_H8300H || TARGET_H8300S"
4161 [(set (match_operand:HI 0 "register_operand" "")
4162 (unspec:HI [(match_dup 0)
4163 (match_dup 1)]
4164 UNSPEC_INCDEC))
4165 (set (cc0)
4166 (match_dup 0))
4167 (set (pc)
4168 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4169 (label_ref (match_dup 2))
4170 (pc)))]
4171 "")
4172
4173 ;; The SImode version of the previous pattern.
4174
4175 (define_peephole2
4176 [(set (match_operand:SI 0 "register_operand" "")
4177 (plus:SI (match_dup 0)
4178 (match_operand 1 "incdec_operand" "")))
4179 (set (cc0)
4180 (match_dup 0))
4181 (set (pc)
4182 (if_then_else (match_operator 3 "eqne_operator"
4183 [(cc0) (const_int 0)])
4184 (label_ref (match_operand 2 "" ""))
4185 (pc)))]
4186 "TARGET_H8300H || TARGET_H8300S"
4187 [(set (match_operand:SI 0 "register_operand" "")
4188 (unspec:SI [(match_dup 0)
4189 (match_dup 1)]
4190 UNSPEC_INCDEC))
4191 (set (cc0)
4192 (match_dup 0))
4193 (set (pc)
4194 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4195 (label_ref (match_dup 2))
4196 (pc)))]
4197 "")
4198
4199 (define_peephole2
4200 [(parallel [(set (cc0)
4201 (zero_extract:SI (match_operand:QI 0 "register_operand" "")
4202 (const_int 1)
4203 (const_int 7)))
4204 (clobber (scratch:QI))])
4205 (set (pc)
4206 (if_then_else (match_operator 1 "eqne_operator"
4207 [(cc0) (const_int 0)])
4208 (label_ref (match_operand 2 "" ""))
4209 (pc)))]
4210 "(TARGET_H8300H || TARGET_H8300S)"
4211 [(set (cc0)
4212 (match_dup 0))
4213 (set (pc)
4214 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4215 (label_ref (match_dup 2))
4216 (pc)))]
4217 "operands[3] = ((GET_CODE (operands[1]) == EQ)
4218 ? gen_rtx_GE (VOIDmode, cc0_rtx, const0_rtx)
4219 : gen_rtx_LT (VOIDmode, cc0_rtx, const0_rtx));")
4220
4221 ;; The next three peephole2's will try to transform
4222 ;;
4223 ;; mov.b A,r0l (or mov.l A,er0)
4224 ;; and.l #CST,er0
4225 ;;
4226 ;; into
4227 ;;
4228 ;; sub.l er0
4229 ;; mov.b A,r0l
4230 ;; and.b #CST,r0l (if CST is not 255)
4231
4232 (define_peephole2
4233 [(set (match_operand:QI 0 "register_operand" "")
4234 (match_operand:QI 1 "general_operand" ""))
4235 (set (match_operand:SI 2 "register_operand" "")
4236 (and:SI (match_dup 2)
4237 (const_int 255)))]
4238 "(TARGET_H8300H || TARGET_H8300S)
4239 && !reg_overlap_mentioned_p (operands[2], operands[1])
4240 && REGNO (operands[0]) == REGNO (operands[2])"
4241 [(set (match_dup 2)
4242 (const_int 0))
4243 (set (strict_low_part (match_dup 0))
4244 (match_dup 1))]
4245 "")
4246
4247 (define_peephole2
4248 [(set (match_operand:SI 0 "register_operand" "")
4249 (match_operand:SI 1 "general_operand" ""))
4250 (set (match_dup 0)
4251 (and:SI (match_dup 0)
4252 (const_int 255)))]
4253 "(TARGET_H8300H || TARGET_H8300S)
4254 && !reg_overlap_mentioned_p (operands[0], operands[1])
4255 && !(GET_CODE (operands[1]) == MEM && MEM_VOLATILE_P (operands[1]))"
4256 [(set (match_dup 0)
4257 (const_int 0))
4258 (set (strict_low_part (match_dup 2))
4259 (match_dup 3))]
4260 "operands[2] = gen_lowpart (QImode, operands[0]);
4261 operands[3] = gen_lowpart (QImode, operands[1]);")
4262
4263 (define_peephole2
4264 [(set (match_operand 0 "register_operand" "")
4265 (match_operand 1 "general_operand" ""))
4266 (set (match_operand:SI 2 "register_operand" "")
4267 (and:SI (match_dup 2)
4268 (match_operand:SI 3 "const_int_qi_operand" "")))]
4269 "(TARGET_H8300H || TARGET_H8300S)
4270 && (GET_MODE (operands[0]) == QImode
4271 || GET_MODE (operands[0]) == HImode
4272 || GET_MODE (operands[0]) == SImode)
4273 && GET_MODE (operands[0]) == GET_MODE (operands[1])
4274 && REGNO (operands[0]) == REGNO (operands[2])
4275 && !reg_overlap_mentioned_p (operands[2], operands[1])
4276 && !(GET_MODE (operands[1]) != QImode
4277 && GET_CODE (operands[1]) == MEM
4278 && MEM_VOLATILE_P (operands[1]))"
4279 [(set (match_dup 2)
4280 (const_int 0))
4281 (set (strict_low_part (match_dup 4))
4282 (match_dup 5))
4283 (set (match_dup 2)
4284 (and:SI (match_dup 2)
4285 (match_dup 6)))]
4286 "operands[4] = gen_lowpart (QImode, operands[0]);
4287 operands[5] = gen_lowpart (QImode, operands[1]);
4288 operands[6] = GEN_INT (~0xff | INTVAL (operands[3]));")
4289
4290 (define_peephole2
4291 [(set (match_operand:SI 0 "register_operand" "")
4292 (match_operand:SI 1 "register_operand" ""))
4293 (set (match_dup 0)
4294 (and:SI (match_dup 0)
4295 (const_int 65280)))]
4296 "(TARGET_H8300H || TARGET_H8300S)
4297 && !reg_overlap_mentioned_p (operands[0], operands[1])"
4298 [(set (match_dup 0)
4299 (const_int 0))
4300 (set (zero_extract:SI (match_dup 0)
4301 (const_int 8)
4302 (const_int 8))
4303 (lshiftrt:SI (match_dup 1)
4304 (const_int 8)))]
4305 "")
4306
4307 ;; If a load of mem:SI is followed by an AND that turns off the upper
4308 ;; half, then we can load mem:HI instead.
4309
4310 (define_peephole2
4311 [(set (match_operand:SI 0 "register_operand" "")
4312 (match_operand:SI 1 "memory_operand" ""))
4313 (set (match_dup 0)
4314 (and:SI (match_dup 0)
4315 (match_operand:SI 2 "const_int_operand" "")))]
4316 "(TARGET_H8300H || TARGET_H8300S)
4317 && !MEM_VOLATILE_P (operands[1])
4318 && (INTVAL (operands[2]) & ~0xffff) == 0
4319 && INTVAL (operands[2]) != 255"
4320 [(set (match_dup 3)
4321 (match_dup 4))
4322 (set (match_dup 0)
4323 (and:SI (match_dup 0)
4324 (match_dup 2)))]
4325 "operands[3] = gen_lowpart (HImode, operands[0]);
4326 operands[4] = gen_lowpart (HImode, operands[1]);")
4327
4328 ;; (compare (reg:HI) (const_int)) takes 4 bytes, so we try to achieve
4329 ;; the equivalent with shorter sequences. Here is the summary. Cases
4330 ;; are grouped for each define_peephole2.
4331 ;;
4332 ;; reg const_int use insn
4333 ;; --------------------------------------------------------
4334 ;; dead -2 eq/ne inc.l
4335 ;; dead -1 eq/ne inc.l
4336 ;; dead 1 eq/ne dec.l
4337 ;; dead 2 eq/ne dec.l
4338 ;;
4339 ;; dead 1 geu/ltu shar.l
4340 ;; dead 3 (H8S) geu/ltu shar.l
4341 ;;
4342 ;; ---- 255 geu/ltu mov.b
4343
4344 ;; Transform
4345 ;;
4346 ;; cmp.w #1,r0
4347 ;; bne .L1
4348 ;;
4349 ;; into
4350 ;;
4351 ;; dec.w #1,r0
4352 ;; bne .L1
4353
4354 (define_peephole2
4355 [(set (cc0)
4356 (compare (match_operand:HI 0 "register_operand" "")
4357 (match_operand:HI 1 "incdec_operand" "")))
4358 (set (pc)
4359 (if_then_else (match_operator 3 "eqne_operator"
4360 [(cc0) (const_int 0)])
4361 (label_ref (match_operand 2 "" ""))
4362 (pc)))]
4363 "(TARGET_H8300H || TARGET_H8300S)
4364 && peep2_reg_dead_p (1, operands[0])"
4365 [(set (match_dup 0)
4366 (unspec:HI [(match_dup 0)
4367 (match_dup 4)]
4368 UNSPEC_INCDEC))
4369 (set (cc0)
4370 (match_dup 0))
4371 (set (pc)
4372 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4373 (label_ref (match_dup 2))
4374 (pc)))]
4375 "operands[4] = GEN_INT (- INTVAL (operands[1]));")
4376
4377 ;; Transform
4378 ;;
4379 ;; cmp.w #1,r0
4380 ;; bhi .L1
4381 ;;
4382 ;; into
4383 ;;
4384 ;; shar.w r0
4385 ;; bne .L1
4386
4387 (define_peephole2
4388 [(set (cc0)
4389 (compare (match_operand:HI 0 "register_operand" "")
4390 (match_operand:HI 1 "const_int_operand" "")))
4391 (set (pc)
4392 (if_then_else (match_operator 2 "gtle_operator"
4393 [(cc0) (const_int 0)])
4394 (label_ref (match_operand 3 "" ""))
4395 (pc)))]
4396 "(TARGET_H8300H || TARGET_H8300S)
4397 && peep2_reg_dead_p (1, operands[0])
4398 && (INTVAL (operands[1]) == 1
4399 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
4400 [(parallel [(set (match_dup 0)
4401 (ashiftrt:HI (match_dup 0)
4402 (match_dup 5)))
4403 (clobber (scratch:QI))])
4404 (set (cc0)
4405 (match_dup 0))
4406 (set (pc)
4407 (if_then_else (match_dup 4)
4408 (label_ref (match_dup 3))
4409 (pc)))]
4410 "switch (GET_CODE (operands[2]))
4411 {
4412 case GTU:
4413 operands[4] = gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx);
4414 break;
4415 case LEU:
4416 operands[4] = gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx);
4417 break;
4418 default:
4419 operands[4] = operands[2];
4420 break;
4421 }
4422 operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
4423
4424 ;; Transform
4425 ;;
4426 ;; cmp.w #255,r0
4427 ;; bhi .L1
4428 ;;
4429 ;; into
4430 ;;
4431 ;; mov.b r0h,r0h
4432 ;; bne .L1
4433
4434 (define_peephole2
4435 [(set (cc0)
4436 (compare (match_operand:HI 0 "register_operand" "")
4437 (const_int 255)))
4438 (set (pc)
4439 (if_then_else (match_operator 1 "gtle_operator"
4440 [(cc0) (const_int 0)])
4441 (label_ref (match_operand 2 "" ""))
4442 (pc)))]
4443 "TARGET_H8300H || TARGET_H8300S"
4444 [(set (cc0)
4445 (and:HI (match_dup 0)
4446 (const_int -256)))
4447 (set (pc)
4448 (if_then_else (match_dup 3)
4449 (label_ref (match_dup 2))
4450 (pc)))]
4451 "switch (GET_CODE (operands[1]))
4452 {
4453 case GTU:
4454 operands[3] = gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx);
4455 break;
4456 case LEU:
4457 operands[3] = gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx);
4458 break;
4459 default:
4460 operands[3] = operands[1];
4461 break;
4462 }")
4463
4464 ;; (compare (reg:SI) (const_int)) takes 6 bytes, so we try to achieve
4465 ;; the equivalent with shorter sequences. Here is the summary. Cases
4466 ;; are grouped for each define_peephole2.
4467 ;;
4468 ;; reg const_int use insn
4469 ;; --------------------------------------------------------
4470 ;; live -2 eq/ne copy and inc.l
4471 ;; live -1 eq/ne copy and inc.l
4472 ;; live 1 eq/ne copy and dec.l
4473 ;; live 2 eq/ne copy and dec.l
4474 ;;
4475 ;; dead -2 eq/ne inc.l
4476 ;; dead -1 eq/ne inc.l
4477 ;; dead 1 eq/ne dec.l
4478 ;; dead 2 eq/ne dec.l
4479 ;;
4480 ;; dead -131072 eq/ne inc.w and test
4481 ;; dead -65536 eq/ne inc.w and test
4482 ;; dead 65536 eq/ne dec.w and test
4483 ;; dead 131072 eq/ne dec.w and test
4484 ;;
4485 ;; dead 0x000000?? except 1 and 2 eq/ne xor.b and test
4486 ;; dead 0x0000??00 eq/ne xor.b and test
4487 ;; dead 0x0000ffff eq/ne not.w and test
4488 ;;
4489 ;; dead 0xffffff?? except -1 and -2 eq/ne xor.b and not.l
4490 ;; dead 0xffff??ff eq/ne xor.b and not.l
4491 ;; dead 0x40000000 (H8S) eq/ne rotl.l and dec.l
4492 ;; dead 0x80000000 eq/ne rotl.l and dec.l
4493 ;;
4494 ;; live 1 geu/ltu copy and shar.l
4495 ;; live 3 (H8S) geu/ltu copy and shar.l
4496 ;;
4497 ;; dead 1 geu/ltu shar.l
4498 ;; dead 3 (H8S) geu/ltu shar.l
4499 ;;
4500 ;; dead 3 (H8/300H) geu/ltu and.b and test
4501 ;; dead 7 geu/ltu and.b and test
4502 ;; dead 15 geu/ltu and.b and test
4503 ;; dead 31 geu/ltu and.b and test
4504 ;; dead 63 geu/ltu and.b and test
4505 ;; dead 127 geu/ltu and.b and test
4506 ;; dead 255 geu/ltu and.b and test
4507 ;;
4508 ;; ---- 65535 geu/ltu mov.w
4509
4510 ;; For a small constant, it is cheaper to actually do the subtraction
4511 ;; and then test the register.
4512
4513 (define_peephole2
4514 [(set (cc0)
4515 (compare (match_operand:SI 0 "register_operand" "")
4516 (match_operand:SI 1 "incdec_operand" "")))
4517 (set (pc)
4518 (if_then_else (match_operator 3 "eqne_operator"
4519 [(cc0) (const_int 0)])
4520 (label_ref (match_operand 2 "" ""))
4521 (pc)))]
4522 "(TARGET_H8300H || TARGET_H8300S)
4523 && peep2_reg_dead_p (1, operands[0])"
4524 [(set (match_dup 0)
4525 (unspec:SI [(match_dup 0)
4526 (match_dup 4)]
4527 UNSPEC_INCDEC))
4528 (set (cc0)
4529 (match_dup 0))
4530 (set (pc)
4531 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4532 (label_ref (match_dup 2))
4533 (pc)))]
4534 "operands[4] = GEN_INT (- INTVAL (operands[1]));")
4535
4536 (define_peephole2
4537 [(set (cc0)
4538 (compare (match_operand:SI 0 "register_operand" "")
4539 (match_operand:SI 1 "const_int_operand" "")))
4540 (set (pc)
4541 (if_then_else (match_operator 3 "eqne_operator"
4542 [(cc0) (const_int 0)])
4543 (label_ref (match_operand 2 "" ""))
4544 (pc)))]
4545 "(TARGET_H8300H || TARGET_H8300S)
4546 && peep2_reg_dead_p (1, operands[0])
4547 && (INTVAL (operands[1]) == -131072
4548 || INTVAL (operands[1]) == -65536
4549 || INTVAL (operands[1]) == 65536
4550 || INTVAL (operands[1]) == 131072)"
4551 [(set (match_dup 0)
4552 (plus:SI (match_dup 0)
4553 (match_dup 4)))
4554 (set (cc0)
4555 (match_dup 0))
4556 (set (pc)
4557 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4558 (label_ref (match_dup 2))
4559 (pc)))]
4560 "operands[4] = GEN_INT (- INTVAL (operands[1]));")
4561
4562 ;; For certain (in)equality comparisons against a constant, we can
4563 ;; XOR the register with the constant, and test the register against
4564 ;; 0.
4565
4566 (define_peephole2
4567 [(set (cc0)
4568 (compare (match_operand:SI 0 "register_operand" "")
4569 (match_operand:SI 1 "const_int_operand" "")))
4570 (set (pc)
4571 (if_then_else (match_operator 3 "eqne_operator"
4572 [(cc0) (const_int 0)])
4573 (label_ref (match_operand 2 "" ""))
4574 (pc)))]
4575 "(TARGET_H8300H || TARGET_H8300S)
4576 && peep2_reg_dead_p (1, operands[0])
4577 && ((INTVAL (operands[1]) & 0x00ff) == INTVAL (operands[1])
4578 || (INTVAL (operands[1]) & 0xff00) == INTVAL (operands[1])
4579 || INTVAL (operands[1]) == 0x0000ffff)
4580 && INTVAL (operands[1]) != 1
4581 && INTVAL (operands[1]) != 2"
4582 [(set (match_dup 0)
4583 (xor:SI (match_dup 0)
4584 (match_dup 1)))
4585 (set (cc0)
4586 (match_dup 0))
4587 (set (pc)
4588 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4589 (label_ref (match_dup 2))
4590 (pc)))]
4591 "")
4592
4593 (define_peephole2
4594 [(set (cc0)
4595 (compare (match_operand:SI 0 "register_operand" "")
4596 (match_operand:SI 1 "const_int_operand" "")))
4597 (set (pc)
4598 (if_then_else (match_operator 3 "eqne_operator"
4599 [(cc0) (const_int 0)])
4600 (label_ref (match_operand 2 "" ""))
4601 (pc)))]
4602 "(TARGET_H8300H || TARGET_H8300S)
4603 && peep2_reg_dead_p (1, operands[0])
4604 && ((INTVAL (operands[1]) | 0x00ff) == -1
4605 || (INTVAL (operands[1]) | 0xff00) == -1)
4606 && INTVAL (operands[1]) != -1
4607 && INTVAL (operands[1]) != -2"
4608 [(set (match_dup 0)
4609 (xor:SI (match_dup 0)
4610 (match_dup 4)))
4611 (set (match_dup 0)
4612 (not:SI (match_dup 0)))
4613 (set (cc0)
4614 (match_dup 0))
4615 (set (pc)
4616 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4617 (label_ref (match_dup 2))
4618 (pc)))]
4619 "operands[4] = GEN_INT (INTVAL (operands[1]) ^ -1);")
4620
4621 (define_peephole2
4622 [(set (cc0)
4623 (compare (match_operand:SI 0 "register_operand" "")
4624 (match_operand:SI 1 "const_int_operand" "")))
4625 (set (pc)
4626 (if_then_else (match_operator 3 "eqne_operator"
4627 [(cc0) (const_int 0)])
4628 (label_ref (match_operand 2 "" ""))
4629 (pc)))]
4630 "(TARGET_H8300H || TARGET_H8300S)
4631 && peep2_reg_dead_p (1, operands[0])
4632 && (INTVAL (operands[1]) == -2147483647 - 1
4633 || (TARGET_H8300S && INTVAL (operands[1]) == 1073741824))"
4634 [(set (match_dup 0)
4635 (rotate:SI (match_dup 0)
4636 (match_dup 4)))
4637 (set (match_dup 0)
4638 (unspec:SI [(match_dup 0)
4639 (const_int -1)]
4640 UNSPEC_INCDEC))
4641 (set (cc0)
4642 (match_dup 0))
4643 (set (pc)
4644 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4645 (label_ref (match_dup 2))
4646 (pc)))]
4647 "operands[4] = GEN_INT (INTVAL (operands[1]) == -2147483647 - 1 ? 1 : 2);")
4648
4649 ;; Transform
4650 ;;
4651 ;; cmp.l #1,er0
4652 ;; bhi .L1
4653 ;;
4654 ;; into
4655 ;;
4656 ;; mov.l er0,er1
4657 ;; shar.l er1
4658 ;; bne .L1
4659
4660 ;; We avoid this transformation if we see more than one copy of the
4661 ;; same compare insn immediately before this one.
4662
4663 (define_peephole2
4664 [(match_scratch:SI 4 "r")
4665 (set (cc0)
4666 (compare (match_operand:SI 0 "register_operand" "")
4667 (match_operand:SI 1 "const_int_operand" "")))
4668 (set (pc)
4669 (if_then_else (match_operator 2 "gtle_operator"
4670 [(cc0) (const_int 0)])
4671 (label_ref (match_operand 3 "" ""))
4672 (pc)))]
4673 "(TARGET_H8300H || TARGET_H8300S)
4674 && !peep2_reg_dead_p (1, operands[0])
4675 && (INTVAL (operands[1]) == 1
4676 || (TARGET_H8300S && INTVAL (operands[1]) == 3))
4677 && !same_cmp_preceding_p (insn)"
4678 [(set (match_dup 4)
4679 (match_dup 0))
4680 (parallel [(set (match_dup 4)
4681 (ashiftrt:SI (match_dup 4)
4682 (match_dup 6)))
4683 (clobber (scratch:QI))])
4684 (set (cc0)
4685 (match_dup 4))
4686 (set (pc)
4687 (if_then_else (match_dup 5)
4688 (label_ref (match_dup 3))
4689 (pc)))]
4690 "switch (GET_CODE (operands[2]))
4691 {
4692 case GTU:
4693 operands[5] = gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx);
4694 break;
4695 case LEU:
4696 operands[5] = gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx);
4697 break;
4698 default:
4699 operands[5] = operands[2];
4700 break;
4701 }
4702 operands[6] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
4703
4704 ;; Transform
4705 ;;
4706 ;; cmp.l #1,er0
4707 ;; bhi .L1
4708 ;;
4709 ;; into
4710 ;;
4711 ;; shar.l er0
4712 ;; bne .L1
4713
4714 (define_peephole2
4715 [(set (cc0)
4716 (compare (match_operand:SI 0 "register_operand" "")
4717 (match_operand:SI 1 "const_int_operand" "")))
4718 (set (pc)
4719 (if_then_else (match_operator 2 "gtle_operator"
4720 [(cc0) (const_int 0)])
4721 (label_ref (match_operand 3 "" ""))
4722 (pc)))]
4723 "(TARGET_H8300H || TARGET_H8300S)
4724 && peep2_reg_dead_p (1, operands[0])
4725 && (INTVAL (operands[1]) == 1
4726 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
4727 [(parallel [(set (match_dup 0)
4728 (ashiftrt:SI (match_dup 0)
4729 (match_dup 5)))
4730 (clobber (scratch:QI))])
4731 (set (cc0)
4732 (match_dup 0))
4733 (set (pc)
4734 (if_then_else (match_dup 4)
4735 (label_ref (match_dup 3))
4736 (pc)))]
4737 "switch (GET_CODE (operands[2]))
4738 {
4739 case GTU:
4740 operands[4] = gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx);
4741 break;
4742 case LEU:
4743 operands[4] = gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx);
4744 break;
4745 default:
4746 operands[4] = operands[2];
4747 break;
4748 }
4749 operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
4750
4751 ;; Transform
4752 ;;
4753 ;; cmp.l #15,er0
4754 ;; bhi .L1
4755 ;;
4756 ;; into
4757 ;;
4758 ;; and #240,r0l
4759 ;; mov.l er0,er0
4760 ;; bne .L1
4761
4762 (define_peephole2
4763 [(set (cc0)
4764 (compare (match_operand:SI 0 "register_operand" "")
4765 (match_operand:SI 1 "const_int_operand" "")))
4766 (set (pc)
4767 (if_then_else (match_operator 2 "gtle_operator"
4768 [(cc0) (const_int 0)])
4769 (label_ref (match_operand 3 "" ""))
4770 (pc)))]
4771 "(TARGET_H8300H || TARGET_H8300S)
4772 && peep2_reg_dead_p (1, operands[0])
4773 && ((TARGET_H8300H && INTVAL (operands[1]) == 3)
4774 || INTVAL (operands[1]) == 7
4775 || INTVAL (operands[1]) == 15
4776 || INTVAL (operands[1]) == 31
4777 || INTVAL (operands[1]) == 63
4778 || INTVAL (operands[1]) == 127
4779 || INTVAL (operands[1]) == 255)"
4780 [(set (match_dup 0)
4781 (and:SI (match_dup 0)
4782 (match_dup 5)))
4783 (set (cc0)
4784 (match_dup 0))
4785 (set (pc)
4786 (if_then_else (match_dup 4)
4787 (label_ref (match_dup 3))
4788 (pc)))]
4789 "switch (GET_CODE (operands[2]))
4790 {
4791 case GTU:
4792 operands[4] = gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx);
4793 break;
4794 case LEU:
4795 operands[4] = gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx);
4796 break;
4797 default:
4798 operands[4] = operands[2];
4799 break;
4800 }
4801 operands[5] = GEN_INT (~INTVAL (operands[1]));")
4802
4803 ;; Transform A <= 65535 to (A & 0xffff0000) == 0.
4804
4805 (define_peephole2
4806 [(set (cc0)
4807 (compare (match_operand:SI 0 "register_operand" "")
4808 (const_int 65535)))
4809 (set (pc)
4810 (if_then_else (match_operator 1 "gtle_operator"
4811 [(cc0) (const_int 0)])
4812 (label_ref (match_operand 2 "" ""))
4813 (pc)))]
4814 "TARGET_H8300H || TARGET_H8300S"
4815 [(set (cc0)
4816 (and:SI (match_dup 0)
4817 (const_int -65536)))
4818 (set (pc)
4819 (if_then_else (match_dup 3)
4820 (label_ref (match_dup 2))
4821 (pc)))]
4822 "switch (GET_CODE (operands[1]))
4823 {
4824 case GTU:
4825 operands[3] = gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx);
4826 break;
4827 case LEU:
4828 operands[3] = gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx);
4829 break;
4830 default:
4831 operands[3] = operands[1];
4832 break;
4833 }")
4834
4835 ;; For constants like -1, -2, 1, 2, it is still cheaper to make a copy
4836 ;; of the register being tested, do the subtraction on the copy, and
4837 ;; then test the copy. We avoid this transformation if we see more
4838 ;; than one copy of the same compare insn.
4839
4840 (define_peephole2
4841 [(match_scratch:SI 4 "r")
4842 (set (cc0)
4843 (compare (match_operand:SI 0 "register_operand" "")
4844 (match_operand:SI 1 "incdec_operand" "")))
4845 (set (pc)
4846 (if_then_else (match_operator 3 "eqne_operator"
4847 [(cc0) (const_int 0)])
4848 (label_ref (match_operand 2 "" ""))
4849 (pc)))]
4850 "(TARGET_H8300H || TARGET_H8300S)
4851 && !peep2_reg_dead_p (1, operands[0])
4852 && !same_cmp_following_p (insn)"
4853 [(set (match_dup 4)
4854 (match_dup 0))
4855 (set (match_dup 4)
4856 (unspec:SI [(match_dup 4)
4857 (match_dup 5)]
4858 UNSPEC_INCDEC))
4859 (set (cc0)
4860 (match_dup 4))
4861 (set (pc)
4862 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4863 (label_ref (match_dup 2))
4864 (pc)))]
4865 "operands[5] = GEN_INT (- INTVAL (operands[1]));")
4866
4867 ;; Narrow the mode of testing if possible.
4868
4869 (define_peephole2
4870 [(set (match_operand:HI 0 "register_operand" "")
4871 (and:HI (match_dup 0)
4872 (match_operand:HI 1 "const_int_qi_operand" "")))
4873 (set (cc0)
4874 (match_dup 0))
4875 (set (pc)
4876 (if_then_else (match_operator 3 "eqne_operator"
4877 [(cc0) (const_int 0)])
4878 (label_ref (match_operand 2 "" ""))
4879 (pc)))]
4880 "peep2_reg_dead_p (2, operands[0])"
4881 [(set (match_dup 4)
4882 (and:QI (match_dup 4)
4883 (match_dup 5)))
4884 (set (cc0)
4885 (match_dup 4))
4886 (set (pc)
4887 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4888 (label_ref (match_dup 2))
4889 (pc)))]
4890 "operands[4] = gen_rtx_REG (QImode, REGNO (operands[0]));
4891 operands[5] = gen_int_mode (INTVAL (operands[1]), QImode);")
4892
4893 (define_peephole2
4894 [(set (match_operand:SI 0 "register_operand" "")
4895 (and:SI (match_dup 0)
4896 (match_operand:SI 1 "const_int_qi_operand" "")))
4897 (set (cc0)
4898 (match_dup 0))
4899 (set (pc)
4900 (if_then_else (match_operator 3 "eqne_operator"
4901 [(cc0) (const_int 0)])
4902 (label_ref (match_operand 2 "" ""))
4903 (pc)))]
4904 "peep2_reg_dead_p (2, operands[0])"
4905 [(set (match_dup 4)
4906 (and:QI (match_dup 4)
4907 (match_dup 5)))
4908 (set (cc0)
4909 (match_dup 4))
4910 (set (pc)
4911 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4912 (label_ref (match_dup 2))
4913 (pc)))]
4914 "operands[4] = gen_rtx_REG (QImode, REGNO (operands[0]));
4915 operands[5] = gen_int_mode (INTVAL (operands[1]), QImode);")
4916
4917 (define_peephole2
4918 [(set (match_operand:SI 0 "register_operand" "")
4919 (and:SI (match_dup 0)
4920 (match_operand:SI 1 "const_int_hi_operand" "")))
4921 (set (cc0)
4922 (match_dup 0))
4923 (set (pc)
4924 (if_then_else (match_operator 3 "eqne_operator"
4925 [(cc0) (const_int 0)])
4926 (label_ref (match_operand 2 "" ""))
4927 (pc)))]
4928 "peep2_reg_dead_p (2, operands[0])"
4929 [(set (match_dup 4)
4930 (and:HI (match_dup 4)
4931 (match_dup 5)))
4932 (set (cc0)
4933 (match_dup 4))
4934 (set (pc)
4935 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4936 (label_ref (match_dup 2))
4937 (pc)))]
4938 "operands[4] = gen_rtx_REG (HImode, REGNO (operands[0]));
4939 operands[5] = gen_int_mode (INTVAL (operands[1]), HImode);")
4940
4941 (define_peephole2
4942 [(set (match_operand:SI 0 "register_operand" "")
4943 (and:SI (match_dup 0)
4944 (match_operand:SI 1 "const_int_qi_operand" "")))
4945 (set (match_dup 0)
4946 (xor:SI (match_dup 0)
4947 (match_operand:SI 2 "const_int_qi_operand" "")))
4948 (set (cc0)
4949 (match_dup 0))
4950 (set (pc)
4951 (if_then_else (match_operator 4 "eqne_operator"
4952 [(cc0) (const_int 0)])
4953 (label_ref (match_operand 3 "" ""))
4954 (pc)))]
4955 "peep2_reg_dead_p (3, operands[0])
4956 && (~INTVAL (operands[1]) & INTVAL (operands[2])) == 0"
4957 [(set (match_dup 5)
4958 (and:QI (match_dup 5)
4959 (match_dup 6)))
4960 (set (match_dup 5)
4961 (xor:QI (match_dup 5)
4962 (match_dup 7)))
4963 (set (cc0)
4964 (match_dup 5))
4965 (set (pc)
4966 (if_then_else (match_op_dup 4 [(cc0) (const_int 0)])
4967 (label_ref (match_dup 3))
4968 (pc)))]
4969 "operands[5] = gen_rtx_REG (QImode, REGNO (operands[0]));
4970 operands[6] = gen_int_mode (INTVAL (operands[1]), QImode);
4971 operands[7] = gen_int_mode (INTVAL (operands[2]), QImode);")
4972
4973 ;; These triggers right at the end of allocation of locals in the
4974 ;; prologue. The only profitable cases are when we have stack
4975 ;; adjustment of -4 or -12. That of -8 won't happen because it is
4976 ;; always split into two consecutive subtractions of -4.
4977
4978 (define_peephole2
4979 [(set (reg:SI SP_REG)
4980 (plus:SI (reg:SI SP_REG)
4981 (const_int -4)))
4982 (set (mem:SI (reg:SI SP_REG))
4983 (match_operand:SI 0 "register_operand" ""))]
4984 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE
4985 && REGNO (operands[0]) != SP_REG"
4986 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4987 (match_dup 0))]
4988 "")
4989
4990 (define_peephole2
4991 [(set (reg:SI SP_REG)
4992 (plus:SI (reg:SI SP_REG)
4993 (const_int -12)))
4994 (set (mem:SI (reg:SI SP_REG))
4995 (match_operand:SI 0 "register_operand" ""))]
4996 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE
4997 && REGNO (operands[0]) != SP_REG"
4998 [(set (reg:SI SP_REG)
4999 (plus:SI (reg:SI SP_REG)
5000 (const_int -4)))
5001 (set (reg:SI SP_REG)
5002 (plus:SI (reg:SI SP_REG)
5003 (const_int -4)))
5004 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
5005 (match_dup 0))]
5006 "")