1 ;;- Machine description for the Hitachi SH.
2 ;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
3 ;; Contributed by Steve Chamberlain (sac@cygnus.com).
4 ;; Improved by Jim Wilson (wilson@cygnus.com).
6 ;; This file is part of GNU CC.
8 ;; GNU CC is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; GNU CC is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU CC; see the file COPYING. If not, write to
20 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
21 ;; Boston, MA 02111-1307, USA.
24 ;; ??? Should prepend a * to all pattern names which are not used.
25 ;; This will make the compiler smaller, and rebuilds after changes faster.
27 ;; ??? Should be enhanced to include support for many more GNU superoptimizer
28 ;; sequences. Especially the sequences for arithmetic right shifts.
30 ;; ??? Should check all DImode patterns for consistency and usefulness.
32 ;; ??? Should add support for using BSR for short function calls.
34 ;; ??? The MAC.W and MAC.L instructions are not supported. There is no
35 ;; way to generate them.
37 ;; ??? The BSR instruction is not supported. It might be possible to
38 ;; generate it by keeping track of function sizes (and hence relative
39 ;; addresses), and then using it only if the target is earlier in the same
40 ;; file, and is within range. Better would be assembler/linker relaxing,
41 ;; but that is much harder.
43 ;; ??? The cmp/str instruction is not supported. Perhaps it can be used
44 ;; for a str* inline function.
46 ;; Special constraints for SH machine description:
53 ;; Special formats used for outputting SH instructions:
55 ;; %. -- print a .s if insn needs delay slot
56 ;; %@ -- print rte/rts if is/isn't an interrupt function
57 ;; %# -- output a nop if there is nothing to put in the delay slot
58 ;; %O -- print a constant without the #
59 ;; %R -- print the lsw reg of a double
60 ;; %S -- print the msw reg of a double
61 ;; %T -- print next word of a double REG or MEM
63 ;; Special predicates:
65 ;; arith_operand -- operand is valid source for arithmetic op
66 ;; arith_reg_operand -- operand is valid register for arithmetic op
67 ;; general_movdst_operand -- operand is valid move destination
68 ;; general_movsrc_operand -- operand is valid move source
69 ;; logical_operand -- operand is valid source for logical op
70 ;; -------------------------------------------------------------------------
72 ;; -------------------------------------------------------------------------
76 (define_attr "cpu" "sh0,sh1,sh2,sh3,sh3e"
77 (const (symbol_ref "sh_cpu_attr")))
79 ;; cbranch conditional branch instructions
80 ;; jump unconditional jumps
81 ;; arith ordinary arithmetic
84 ;; move register to register
85 ;; smpy word precision integer multiply
86 ;; dmpy longword or doublelongword precision integer multiply
88 ;; pload load of pr reg, which can't be put into delay slot of rts
89 ;; pstore store of pr reg, which can't be put into delay slot of jsr
90 ;; pcload pc relative load of constant value
91 ;; rte return from exception
92 ;; sfunc special function call with known used registers
95 ;; fdiv floating point divide (or square root)
98 "cbranch,jump,arith,other,load,store,move,smpy,dmpy,return,pload,pstore,pcload,rte,sfunc,call,fp,fdiv"
99 (const_string "other"))
101 ; If a conditional branch destination is within -252..258 bytes away
102 ; from the instruction it can be 2 bytes long. Something in the
103 ; range -4090..4100 bytes can be 6 bytes long. All other conditional
104 ; branches are 16 bytes long.
106 ; An unconditional jump in the range -4092..4098 can be 2 bytes long.
107 ; Otherwise, it must be 14 bytes long.
109 ; All other instructions are two bytes long by default.
111 ; All positive offsets have an adjustment added, which is the number of bytes
112 ; difference between this instruction length and the next larger instruction
113 ; length. This is because shorten_branches starts with the largest
114 ; instruction size and then tries to reduce them.
116 (define_attr "length" ""
117 (cond [(eq_attr "type" "cbranch")
118 (if_then_else (and (ge (minus (match_dup 0) (pc))
120 (le (minus (match_dup 0) (pc))
123 (if_then_else (and (ge (minus (match_dup 0) (pc))
125 (le (minus (match_dup 0) (pc))
130 (eq_attr "type" "jump")
131 (if_then_else (and (ge (minus (match_dup 0) (pc))
133 (le (minus (match_dup 0) (pc))
139 ;; (define_function_unit {name} {num-units} {n-users} {test}
140 ;; {ready-delay} {issue-delay} [{conflict-list}])
142 ;; Load and store instructions save a cycle if they are aligned on a
143 ;; four byte boundary. Using a function unit for stores encourages
144 ;; gcc to separate load and store instructions by one instruction,
145 ;; which makes it more likely that the linker will be able to word
146 ;; align them when relaxing.
147 (define_function_unit "memory" 1 0
148 (eq_attr "type" "load,pcload,pload,store,pstore") 2 2)
150 ;; ??? These are approximations.
151 (define_function_unit "mpy" 1 0 (eq_attr "type" "smpy") 2 2)
152 (define_function_unit "mpy" 1 0 (eq_attr "type" "dmpy") 3 3)
154 (define_function_unit "fp" 1 0 (eq_attr "type" "fp") 2 1)
155 (define_function_unit "fp" 1 0 (eq_attr "type" "fdiv") 13 12)
157 ; Definitions for filling branch delay slots.
159 (define_attr "needs_delay_slot" "yes,no" (const_string "no"))
161 (define_attr "hit_stack" "yes,no" (const_string "no"))
163 (define_attr "interrupt_function" "no,yes"
164 (const (symbol_ref "pragma_interrupt")))
166 (define_attr "in_delay_slot" "yes,no"
167 (cond [(eq_attr "type" "cbranch") (const_string "no")
168 (eq_attr "type" "pcload") (const_string "no")
169 (eq_attr "needs_delay_slot" "yes") (const_string "no")
170 (eq_attr "length" "2") (const_string "yes")
171 ] (const_string "no")))
174 (eq_attr "needs_delay_slot" "yes")
175 [(eq_attr "in_delay_slot" "yes") (nil) (nil)])
177 ;; On the SH and SH2, the rte instruction reads the return pc from the stack,
178 ;; and thus we can't put a pop instruction in its delay slot.
179 ;; ??? On the SH3, the rte instruction does not use the stack, so a pop
180 ;; instruction can go in the delay slot.
182 ;; Since a normal return (rts) implicitly uses the PR register,
183 ;; we can't allow PR register loads in an rts delay slot.
186 (eq_attr "type" "return")
187 [(and (eq_attr "in_delay_slot" "yes")
188 (ior (and (eq_attr "interrupt_function" "no")
189 (eq_attr "type" "!pload"))
190 (and (eq_attr "interrupt_function" "yes")
191 (eq_attr "hit_stack" "no")))) (nil) (nil)])
193 ;; Since a call implicitly uses the PR register, we can't allow
194 ;; a PR register store in a jsr delay slot.
197 (ior (eq_attr "type" "call") (eq_attr "type" "sfunc"))
198 [(and (eq_attr "in_delay_slot" "yes")
199 (eq_attr "type" "!pstore")) (nil) (nil)])
201 ;; Say that we have annulled true branches, since this gives smaller and
202 ;; faster code when branches are predicted as not taken.
204 ;; ??? Branches which are out-of-range actually have two delay slots,
205 ;; the first is either always executed or else annulled false, and the
206 ;; second is always annulled false. Handling these differently from
207 ;; in range branches would give better code.
210 (and (eq_attr "type" "cbranch")
211 (eq_attr "cpu" "sh2,sh3"))
212 [(eq_attr "in_delay_slot" "yes") (eq_attr "in_delay_slot" "yes") (nil)])
214 ;; -------------------------------------------------------------------------
215 ;; SImode signed integer comparisons
216 ;; -------------------------------------------------------------------------
219 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
225 ;; ??? This combiner pattern does not work, because combine does not combine
226 ;; instructions that set a hard register when SMALL_REGISTER_CLASSES is
227 ;; defined. Perhaps use a pseudo-reg for the T bit?
231 (eq:SI (and:SI (match_operand:SI 0 "arith_reg_operand" "z,r")
232 (match_operand:SI 1 "arith_operand" "L,r"))
237 ;; ??? Perhaps should only accept reg/constant if the register is reg 0.
238 ;; That would still allow reload to create cmpi instructions, but would
239 ;; perhaps allow forcing the constant into a register when that is better.
240 ;; Probably should use r0 for mem/imm compares, but force constant into a
241 ;; register for pseudo/imm compares.
243 (define_insn "cmpeqsi_t"
244 [(set (reg:SI 18) (eq:SI (match_operand:SI 0 "arith_reg_operand" "r,z,r")
245 (match_operand:SI 1 "arith_operand" "N,rI,r")))]
252 (define_insn "cmpgtsi_t"
253 [(set (reg:SI 18) (gt:SI (match_operand:SI 0 "arith_reg_operand" "r,r")
254 (match_operand:SI 1 "arith_reg_or_0_operand" "r,N")))]
260 (define_insn "cmpgesi_t"
261 [(set (reg:SI 18) (ge:SI (match_operand:SI 0 "arith_reg_operand" "r,r")
262 (match_operand:SI 1 "arith_reg_or_0_operand" "r,N")))]
268 ;; -------------------------------------------------------------------------
269 ;; SImode unsigned integer comparisons
270 ;; -------------------------------------------------------------------------
272 (define_insn "cmpgeusi_t"
273 [(set (reg:SI 18) (geu:SI (match_operand:SI 0 "arith_reg_operand" "r")
274 (match_operand:SI 1 "arith_reg_operand" "r")))]
278 (define_insn "cmpgtusi_t"
279 [(set (reg:SI 18) (gtu:SI (match_operand:SI 0 "arith_reg_operand" "r")
280 (match_operand:SI 1 "arith_reg_operand" "r")))]
284 ;; We save the compare operands in the cmpxx patterns and use them when
285 ;; we generate the branch.
287 (define_expand "cmpsi"
288 [(set (reg:SI 18) (compare (match_operand:SI 0 "arith_operand" "")
289 (match_operand:SI 1 "arith_operand" "")))]
293 sh_compare_op0 = operands[0];
294 sh_compare_op1 = operands[1];
298 ;; -------------------------------------------------------------------------
299 ;; Addition instructions
300 ;; -------------------------------------------------------------------------
302 ;; ??? This should be a define expand.
304 (define_insn "adddi3"
305 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
306 (plus:DI (match_operand:DI 1 "arith_reg_operand" "%0")
307 (match_operand:DI 2 "arith_reg_operand" "r")))
308 (clobber (reg:SI 18))]
310 "clrt\;addc %R2,%R0\;addc %S2,%S0"
311 [(set_attr "length" "6")])
313 (define_insn "addsi3"
314 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
315 (plus:SI (match_operand:SI 1 "arith_operand" "%0")
316 (match_operand:SI 2 "arith_operand" "rI")))]
319 [(set_attr "type" "arith")])
321 ;; -------------------------------------------------------------------------
322 ;; Subtraction instructions
323 ;; -------------------------------------------------------------------------
325 ;; ??? This should be a define expand.
327 (define_insn "subdi3"
328 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
329 (minus:DI (match_operand:DI 1 "arith_reg_operand" "0")
330 (match_operand:DI 2 "arith_reg_operand" "r")))
331 (clobber (reg:SI 18))]
333 "clrt\;subc %R2,%R0\;subc %S2,%S0"
334 [(set_attr "length" "6")])
336 (define_insn "*subsi3_internal"
337 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
338 (minus:SI (match_operand:SI 1 "arith_reg_operand" "0")
339 (match_operand:SI 2 "arith_reg_operand" "r")))]
342 [(set_attr "type" "arith")])
344 ;; Convert `constant - reg' to `neg rX; add rX, #const' since this
345 ;; will sometimes save one instruction. Otherwise we might get
346 ;; `mov #const, rY; sub rY,rX; mov rX, rY' if the source and dest regs
349 (define_expand "subsi3"
350 [(set (match_operand:SI 0 "arith_reg_operand" "")
351 (minus:SI (match_operand:SI 1 "arith_operand" "")
352 (match_operand:SI 2 "arith_reg_operand" "")))]
356 if (GET_CODE (operands[1]) == CONST_INT)
358 emit_insn (gen_negsi2 (operands[0], operands[2]));
359 emit_insn (gen_addsi3 (operands[0], operands[0], operands[1]));
364 ;; -------------------------------------------------------------------------
365 ;; Division instructions
366 ;; -------------------------------------------------------------------------
368 ;; We take advantage of the library routines which don't clobber as many
369 ;; registers as a normal function call would.
371 ;; We must use a pseudo-reg forced to reg 0 in the SET_DEST rather than
372 ;; hard register 0. If we used hard register 0, then the next instruction
373 ;; would be a move from hard register 0 to a pseudo-reg. If the pseudo-reg
374 ;; gets allocated to a stack slot that needs its address reloaded, then
375 ;; there is nothing to prevent reload from using r0 to reload the address.
376 ;; This reload would clobber the value in r0 we are trying to store.
377 ;; If we let reload allocate r0, then this problem can never happen.
380 [(set (match_operand:SI 1 "register_operand" "=z")
381 (udiv:SI (reg:SI 4) (reg:SI 5)))
382 (clobber (reg:SI 18))
383 (clobber (reg:SI 17))
385 (use (match_operand:SI 0 "arith_reg_operand" "r"))]
388 [(set_attr "type" "sfunc")
389 (set_attr "needs_delay_slot" "yes")])
391 (define_expand "udivsi3"
392 [(set (reg:SI 4) (match_operand:SI 1 "general_operand" ""))
393 (set (reg:SI 5) (match_operand:SI 2 "general_operand" ""))
394 (set (match_dup 3) (symbol_ref:SI "__udivsi3"))
395 (parallel [(set (match_operand:SI 0 "register_operand" "")
398 (clobber (reg:SI 18))
399 (clobber (reg:SI 17))
401 (use (match_dup 3))])]
403 "operands[3] = gen_reg_rtx(SImode);")
406 [(set (match_operand:SI 1 "register_operand" "=z")
407 (div:SI (reg:SI 4) (reg:SI 5)))
408 (clobber (reg:SI 18))
409 (clobber (reg:SI 17))
413 (use (match_operand:SI 0 "arith_reg_operand" "r"))]
416 [(set_attr "type" "sfunc")
417 (set_attr "needs_delay_slot" "yes")])
419 (define_expand "divsi3"
420 [(set (reg:SI 4) (match_operand:SI 1 "general_operand" ""))
421 (set (reg:SI 5) (match_operand:SI 2 "general_operand" ""))
422 (set (match_dup 3) (symbol_ref:SI "__sdivsi3"))
423 (parallel [(set (match_operand:SI 0 "register_operand" "")
426 (clobber (reg:SI 18))
427 (clobber (reg:SI 17))
431 (use (match_dup 3))])]
433 "operands[3] = gen_reg_rtx(SImode);")
435 ;; -------------------------------------------------------------------------
436 ;; Multiplication instructions
437 ;; -------------------------------------------------------------------------
441 (mult:SI (zero_extend:SI (match_operand:HI 0 "arith_reg_operand" "r"))
442 (zero_extend:SI (match_operand:HI 1 "arith_reg_operand" "r"))))]
445 [(set_attr "type" "smpy")])
449 (mult:SI (sign_extend:SI
450 (match_operand:HI 0 "arith_reg_operand" "r"))
452 (match_operand:HI 1 "arith_reg_operand" "r"))))]
455 [(set_attr "type" "smpy")])
457 (define_expand "mulhisi3"
459 (mult:SI (sign_extend:SI
460 (match_operand:HI 1 "arith_reg_operand" ""))
462 (match_operand:HI 2 "arith_reg_operand" ""))))
463 (set (match_operand:SI 0 "arith_reg_operand" "")
468 (define_expand "umulhisi3"
470 (mult:SI (zero_extend:SI
471 (match_operand:HI 1 "arith_reg_operand" ""))
473 (match_operand:HI 2 "arith_reg_operand" ""))))
474 (set (match_operand:SI 0 "arith_reg_operand" "")
479 ;; mulsi3 on the SH2 can be done in one instruction, on the SH1 we generate
480 ;; a call to a routine which clobbers known registers.
483 [(set (match_operand:SI 1 "register_operand" "=z")
484 (mult:SI (reg:SI 4) (reg:SI 5)))
485 (clobber (reg:SI 21))
486 (clobber (reg:SI 18))
487 (clobber (reg:SI 17))
491 (use (match_operand:SI 0 "arith_reg_operand" "r"))]
494 [(set_attr "type" "sfunc")
495 (set_attr "needs_delay_slot" "yes")])
497 (define_expand "mulsi3_call"
498 [(set (reg:SI 4) (match_operand:SI 1 "general_operand" ""))
499 (set (reg:SI 5) (match_operand:SI 2 "general_operand" ""))
500 (set (match_dup 3) (symbol_ref:SI "__mulsi3"))
501 (parallel[(set (match_operand:SI 0 "register_operand" "")
504 (clobber (reg:SI 21))
505 (clobber (reg:SI 18))
506 (clobber (reg:SI 17))
510 (use (match_dup 3))])]
512 "operands[3] = gen_reg_rtx(SImode);")
516 (mult:SI (match_operand:SI 0 "arith_reg_operand" "r")
517 (match_operand:SI 1 "arith_reg_operand" "r")))]
520 [(set_attr "type" "dmpy")])
522 (define_expand "mulsi3"
524 (mult:SI (match_operand:SI 1 "arith_reg_operand" "")
525 (match_operand:SI 2 "arith_reg_operand" "")))
526 (set (match_operand:SI 0 "arith_reg_operand" "")
534 /* ??? Does this give worse or better code? */
535 emit_insn (gen_mulsi3_call (operands[0], operands[1], operands[2]));
540 (define_insn "mulsidi3_i"
542 (mult:DI (sign_extend:DI (match_operand:SI 0 "arith_reg_operand" "r"))
543 (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" "r"))))]
546 [(set_attr "type" "dmpy")])
548 (define_expand "mulsidi3"
550 (mult:DI (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" ""))
551 (sign_extend:DI (match_operand:SI 2 "arith_reg_operand" ""))))
552 (set (match_operand:DI 0 "arith_reg_operand" "")
557 /* We must swap the two words when copying them from MACH/MACL to the
559 if (TARGET_LITTLE_ENDIAN)
561 rtx low_dst = operand_subword (operands[0], 0, 1, DImode);
562 rtx high_dst = operand_subword (operands[0], 1, 1, DImode);
564 emit_insn (gen_mulsidi3_i (operands[1], operands[2]));
566 emit_insn (gen_rtx (CLOBBER, VOIDmode, operands[0]));
567 emit_move_insn (low_dst, gen_rtx (REG, SImode, 21));
568 emit_move_insn (high_dst, gen_rtx (REG, SImode, 20));
573 (define_insn "umulsidi3_i"
575 (mult:DI (zero_extend:DI (match_operand:SI 0 "arith_reg_operand" "r"))
576 (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" "r"))))]
579 [(set_attr "type" "dmpy")])
581 (define_expand "umulsidi3"
583 (mult:DI (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" ""))
584 (zero_extend:DI (match_operand:SI 2 "arith_reg_operand" ""))))
585 (set (match_operand:DI 0 "arith_reg_operand" "")
590 /* We must swap the two words when copying them from MACH/MACL to the
592 if (TARGET_LITTLE_ENDIAN)
594 rtx low_dst = operand_subword (operands[0], 0, 1, DImode);
595 rtx high_dst = operand_subword (operands[0], 1, 1, DImode);
597 emit_insn (gen_umulsidi3_i (operands[1], operands[2]));
599 emit_insn (gen_rtx (CLOBBER, VOIDmode, operands[0]));
600 emit_move_insn (low_dst, gen_rtx (REG, SImode, 21));
601 emit_move_insn (high_dst, gen_rtx (REG, SImode, 20));
609 (lshiftrt:DI (mult:DI (sign_extend:DI (match_operand:SI 0 "arith_reg_operand" "r"))
610 (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" "r")))
612 (clobber (reg:SI 21))]
615 [(set_attr "type" "dmpy")])
617 (define_expand "smulsi3_highpart"
618 [(parallel [(set (reg:SI 20)
620 (lshiftrt:DI (mult:DI (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" ""))
621 (sign_extend:DI (match_operand:SI 2 "arith_reg_operand" "")))
623 (clobber (reg:SI 21))])
624 (set (match_operand:SI 0 "arith_reg_operand" "")
632 (lshiftrt:DI (mult:DI (zero_extend:DI (match_operand:SI 0 "arith_reg_operand" "r"))
633 (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" "r")))
635 (clobber (reg:SI 21))]
638 [(set_attr "type" "dmpy")])
640 (define_expand "umulsi3_highpart"
641 [(parallel [(set (reg:SI 20)
643 (lshiftrt:DI (mult:DI (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" ""))
644 (zero_extend:DI (match_operand:SI 2 "arith_reg_operand" "")))
646 (clobber (reg:SI 21))])
647 (set (match_operand:SI 0 "arith_reg_operand" "")
652 ;; -------------------------------------------------------------------------
653 ;; Logical operations
654 ;; -------------------------------------------------------------------------
657 [(set (match_operand:SI 0 "arith_reg_operand" "=r,z")
658 (and:SI (match_operand:SI 1 "arith_reg_operand" "%0,0")
659 (match_operand:SI 2 "logical_operand" "r,L")))]
662 [(set_attr "type" "arith")])
664 ;; If the constant is 255, then emit a extu.b instruction instead of an
665 ;; and, since that will give better code.
667 (define_expand "andsi3"
668 [(set (match_operand:SI 0 "arith_reg_operand" "")
669 (and:SI (match_operand:SI 1 "arith_reg_operand" "")
670 (match_operand:SI 2 "logical_operand" "")))]
674 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 255)
676 emit_insn (gen_zero_extendqisi2 (operands[0],
677 gen_lowpart (QImode, operands[1])));
682 (define_insn "iorsi3"
683 [(set (match_operand:SI 0 "arith_reg_operand" "=r,z")
684 (ior:SI (match_operand:SI 1 "arith_reg_operand" "%0,0")
685 (match_operand:SI 2 "logical_operand" "r,L")))]
689 (define_insn "xorsi3"
690 [(set (match_operand:SI 0 "arith_reg_operand" "=z,r")
691 (xor:SI (match_operand:SI 1 "arith_reg_operand" "%0,0")
692 (match_operand:SI 2 "logical_operand" "L,r")))]
695 [(set_attr "type" "arith")])
697 ;; -------------------------------------------------------------------------
698 ;; Shifts and rotates
699 ;; -------------------------------------------------------------------------
701 (define_insn "rotlsi3_1"
702 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
703 (rotate:SI (match_operand:SI 1 "arith_reg_operand" "0")
706 (lshiftrt:SI (match_dup 1) (const_int 31)))]
710 (define_insn "rotlsi3_31"
711 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
712 (rotate:SI (match_operand:SI 1 "arith_reg_operand" "0")
714 (clobber (reg:SI 18))]
719 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
720 (rotate:SI (match_operand:SI 1 "arith_reg_operand" "r")
725 (define_expand "rotlsi3"
726 [(set (match_operand:SI 0 "arith_reg_operand" "")
727 (rotate:SI (match_operand:SI 1 "arith_reg_operand" "")
728 (match_operand:SI 2 "immediate_operand" "")))]
732 if (GET_CODE (operands[2]) != CONST_INT)
735 if (INTVAL (operands[2]) == 1)
737 emit_insn (gen_rotlsi3_1 (operands[0], operands[1]));
740 else if (INTVAL (operands[2]) == 31)
742 emit_insn (gen_rotlsi3_31 (operands[0], operands[1]));
745 else if (INTVAL (operands[2]) != 16)
750 [(set (match_operand:HI 0 "arith_reg_operand" "=r")
751 (rotate:HI (match_operand:HI 1 "arith_reg_operand" "r")
756 (define_expand "rotlhi3"
757 [(set (match_operand:HI 0 "arith_reg_operand" "")
758 (rotate:HI (match_operand:HI 1 "arith_reg_operand" "")
759 (match_operand:HI 2 "immediate_operand" "")))]
763 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 8)
770 (define_insn "ashlsi3_d"
771 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
772 (ashift:SI (match_operand:SI 1 "arith_reg_operand" "0")
773 (match_operand:SI 2 "arith_reg_operand" "r")))]
777 (define_insn "ashlsi3_k"
778 [(set (match_operand:SI 0 "arith_reg_operand" "=r,r")
779 (ashift:SI (match_operand:SI 1 "arith_reg_operand" "0,0")
780 (match_operand:SI 2 "const_int_operand" "M,K")))]
781 "CONST_OK_FOR_K (INTVAL (operands[2]))"
786 (define_insn "ashlhi3_k"
787 [(set (match_operand:HI 0 "arith_reg_operand" "=r,r")
788 (ashift:HI (match_operand:HI 1 "arith_reg_operand" "0,0")
789 (match_operand:HI 2 "const_int_operand" "M,K")))]
790 "CONST_OK_FOR_K (INTVAL (operands[2]))"
795 (define_insn "ashlsi3_n"
796 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
797 (ashift:SI (match_operand:SI 1 "arith_reg_operand" "0")
798 (match_operand:SI 2 "const_int_operand" "n")))
799 (clobber (reg:SI 18))]
802 [(set (attr "length")
803 (cond [(eq (symbol_ref "shift_insns_rtx (insn)") (const_int 1))
805 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 2))
807 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 3))
810 (set_attr "type" "arith")])
813 [(set (match_operand:SI 0 "arith_reg_operand" "")
814 (ashift:SI (match_operand:SI 1 "arith_reg_operand" "")
815 (match_operand:SI 2 "const_int_operand" "n")))
816 (clobber (reg:SI 18))]
821 gen_shifty_op (ASHIFT, operands);
825 (define_expand "ashlsi3"
826 [(parallel [(set (match_operand:SI 0 "arith_reg_operand" "")
827 (ashift:SI (match_operand:SI 1 "arith_reg_operand" "")
828 (match_operand:SI 2 "nonmemory_operand" "")))
829 (clobber (reg:SI 18))])]
833 if (TARGET_SH3 && arith_reg_operand (operands[2], GET_MODE (operands[2])))
835 emit_insn (gen_ashlsi3_d (operands[0], operands[1], operands[2]));
838 if (! immediate_operand (operands[2], GET_MODE (operands[2])))
842 (define_insn "ashlhi3"
843 [(set (match_operand:HI 0 "arith_reg_operand" "=r")
844 (ashift:HI (match_operand:HI 1 "arith_reg_operand" "0")
845 (match_operand:HI 2 "const_int_operand" "n")))
846 (clobber (reg:SI 18))]
849 [(set (attr "length")
850 (cond [(eq (symbol_ref "shift_insns_rtx (insn)") (const_int 1))
852 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 2))
855 (set_attr "type" "arith")])
858 [(set (match_operand:HI 0 "arith_reg_operand" "")
859 (ashift:HI (match_operand:HI 1 "arith_reg_operand" "")
860 (match_operand:HI 2 "const_int_operand" "n")))
861 (clobber (reg:SI 18))]
866 gen_shifty_hi_op (ASHIFT, operands);
871 ; arithmetic shift right
874 (define_insn "ashrsi3_k"
875 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
876 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
877 (match_operand:SI 2 "const_int_operand" "M")))
878 (clobber (reg:SI 18))]
879 "INTVAL (operands[2]) == 1"
881 [(set_attr "type" "arith")])
883 (define_insn "ashrhi3_k"
884 [(set (match_operand:HI 0 "arith_reg_operand" "=r")
885 (ashiftrt:HI (match_operand:HI 1 "arith_reg_operand" "0")
886 (match_operand:HI 2 "const_int_operand" "M")))
887 (clobber (reg:SI 18))]
888 "INTVAL (operands[2]) == 1"
890 [(set_attr "type" "arith")])
892 ;; ??? This should be a define expand.
894 (define_insn "ashrsi2_16"
895 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
896 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "r")
899 "swap.w %1,%0\;exts.w %0,%0"
900 [(set_attr "length" "4")])
902 ;; ??? This should be a define expand.
904 (define_insn "ashrsi2_31"
905 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
906 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
908 (clobber (reg:SI 18))]
912 [(set_attr "length" "4")])
914 (define_insn "ashrsi3_d"
915 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
916 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
917 (neg:SI (match_operand:SI 2 "arith_reg_operand" "r"))))]
921 (define_insn "ashrsi3_n"
923 (ashiftrt:SI (reg:SI 4)
924 (match_operand:SI 0 "const_int_operand" "i")))
925 (clobber (reg:SI 18))
926 (clobber (reg:SI 17))
927 (use (match_operand:SI 1 "arith_reg_operand" "r"))]
930 [(set_attr "type" "sfunc")
931 (set_attr "needs_delay_slot" "yes")])
933 (define_expand "ashrsi3"
934 [(parallel [(set (match_operand:SI 0 "arith_reg_operand" "")
935 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "")
936 (match_operand:SI 2 "nonmemory_operand" "")))
937 (clobber (reg:SI 18))])]
939 "if (expand_ashiftrt (operands)) DONE; else FAIL;")
941 ;; logical shift right
943 (define_insn "lshrsi3_d"
944 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
945 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
946 (neg:SI (match_operand:SI 2 "arith_reg_operand" "r"))))]
950 ;; Only the single bit shift clobbers the T bit.
952 (define_insn "lshrsi3_m"
953 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
954 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
955 (match_operand:SI 2 "const_int_operand" "M")))
956 (clobber (reg:SI 18))]
957 "CONST_OK_FOR_M (INTVAL (operands[2]))"
960 (define_insn "lshrsi3_k"
961 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
962 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
963 (match_operand:SI 2 "const_int_operand" "K")))]
964 "CONST_OK_FOR_K (INTVAL (operands[2]))
965 && ! CONST_OK_FOR_M (INTVAL (operands[2]))"
968 (define_insn "lshrhi3_m"
969 [(set (match_operand:HI 0 "arith_reg_operand" "=r")
970 (lshiftrt:HI (match_operand:HI 1 "arith_reg_operand" "0")
971 (match_operand:HI 2 "const_int_operand" "M")))
972 (clobber (reg:SI 18))]
973 "CONST_OK_FOR_M (INTVAL (operands[2]))"
976 (define_insn "lshrhi3_k"
977 [(set (match_operand:HI 0 "arith_reg_operand" "=r")
978 (lshiftrt:HI (match_operand:HI 1 "arith_reg_operand" "0")
979 (match_operand:HI 2 "const_int_operand" "K")))]
980 "CONST_OK_FOR_K (INTVAL (operands[2]))
981 && ! CONST_OK_FOR_M (INTVAL (operands[2]))"
984 (define_insn "lshrsi3_n"
985 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
986 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
987 (match_operand:SI 2 "const_int_operand" "n")))
988 (clobber (reg:SI 18))]
991 [(set (attr "length")
992 (cond [(eq (symbol_ref "shift_insns_rtx (insn)") (const_int 1))
994 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 2))
996 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 3))
999 (set_attr "type" "arith")])
1002 [(set (match_operand:SI 0 "arith_reg_operand" "")
1003 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "")
1004 (match_operand:SI 2 "const_int_operand" "n")))
1005 (clobber (reg:SI 18))]
1010 gen_shifty_op (LSHIFTRT, operands);
1014 (define_expand "lshrsi3"
1015 [(parallel [(set (match_operand:SI 0 "arith_reg_operand" "")
1016 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "")
1017 (match_operand:SI 2 "nonmemory_operand" "")))
1018 (clobber (reg:SI 18))])]
1022 if (TARGET_SH3 && arith_reg_operand (operands[2], GET_MODE (operands[2])))
1024 rtx count = copy_to_mode_reg (SImode, operands[2]);
1025 emit_insn (gen_negsi2 (count, count));
1026 emit_insn (gen_lshrsi3_d (operands[0], operands[1], count));
1029 if (! immediate_operand (operands[2], GET_MODE (operands[2])))
1033 (define_insn "lshrhi3"
1034 [(set (match_operand:HI 0 "arith_reg_operand" "=r")
1035 (lshiftrt:HI (match_operand:HI 1 "arith_reg_operand" "0")
1036 (match_operand:HI 2 "const_int_operand" "n")))
1037 (clobber (reg:SI 18))]
1040 ;; ??? length attribute is sometimes six instead of four.
1041 [(set (attr "length")
1042 (cond [(eq (symbol_ref "shift_insns_rtx (insn)") (const_int 1))
1044 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 2))
1046 (const_string "6")))
1047 (set_attr "type" "arith")])
1050 [(set (match_operand:HI 0 "arith_reg_operand" "")
1051 (lshiftrt:HI (match_operand:HI 1 "arith_reg_operand" "")
1052 (match_operand:HI 2 "const_int_operand" "n")))
1053 (clobber (reg:SI 18))]
1058 gen_shifty_hi_op (LSHIFTRT, operands);
1062 ;; ??? This should be a define expand.
1064 (define_insn "ashldi3_k"
1065 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
1066 (ashift:DI (match_operand:DI 1 "arith_reg_operand" "0")
1068 (clobber (reg:SI 18))]
1070 "shll %R0\;rotcl %S0"
1071 [(set_attr "length" "4")])
1073 (define_expand "ashldi3"
1074 [(parallel [(set (match_operand:DI 0 "arith_reg_operand" "")
1075 (ashift:DI (match_operand:DI 1 "arith_reg_operand" "")
1076 (match_operand:DI 2 "immediate_operand" "")))
1077 (clobber (reg:SI 18))])]
1079 "{ if (GET_CODE (operands[2]) != CONST_INT
1080 || INTVAL (operands[2]) != 1) FAIL;} ")
1082 ;; ??? This should be a define expand.
1084 (define_insn "lshrdi3_k"
1085 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
1086 (lshiftrt:DI (match_operand:DI 1 "arith_reg_operand" "0")
1088 (clobber (reg:SI 18))]
1090 "shlr %S0\;rotcr %R0"
1091 [(set_attr "length" "4")])
1093 (define_expand "lshrdi3"
1094 [(parallel [(set (match_operand:DI 0 "arith_reg_operand" "")
1095 (lshiftrt:DI (match_operand:DI 1 "arith_reg_operand" "")
1096 (match_operand:DI 2 "immediate_operand" "")))
1097 (clobber (reg:SI 18))])]
1099 "{ if (GET_CODE (operands[2]) != CONST_INT
1100 || INTVAL (operands[2]) != 1) FAIL;} ")
1102 ;; ??? This should be a define expand.
1104 (define_insn "ashrdi3_k"
1105 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
1106 (ashiftrt:DI (match_operand:DI 1 "arith_reg_operand" "0")
1108 (clobber (reg:SI 18))]
1110 "shar %S0\;rotcr %R0"
1111 [(set_attr "length" "4")])
1113 (define_expand "ashrdi3"
1114 [(parallel [(set (match_operand:DI 0 "arith_reg_operand" "")
1115 (ashiftrt:DI (match_operand:DI 1 "arith_reg_operand" "")
1116 (match_operand:DI 2 "immediate_operand" "")))
1117 (clobber (reg:SI 18))])]
1119 "{ if (GET_CODE (operands[2]) != CONST_INT
1120 || INTVAL (operands[2]) != 1) FAIL; } ")
1122 ;; combined left/right shift
1125 [(set (match_operand:SI 0 "register_operand" "")
1126 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
1127 (match_operand:SI 2 "const_int_operand" "n"))
1128 (match_operand:SI 3 "const_int_operand" "n")))]
1129 "(unsigned)INTVAL (operands[2]) < 32"
1131 "if (gen_shl_and (operands[0], operands[2], operands[3], operands[1])) FAIL;
1135 [(set (match_operand:SI 0 "register_operand" "")
1136 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
1137 (match_operand:SI 2 "const_int_operand" "n"))
1138 (match_operand:SI 3 "const_int_operand" "n")))
1139 (clobber (reg:SI 18))]
1140 "(unsigned)INTVAL (operands[2]) < 32"
1142 "if (gen_shl_and (operands[0], operands[2], operands[3], operands[1])) FAIL;
1146 [(set (match_operand:SI 0 "register_operand" "=r")
1147 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
1148 (match_operand:SI 2 "const_int_operand" "n"))
1149 (match_operand:SI 3 "const_int_operand" "n")))
1150 (clobber (reg:SI 18))]
1151 "shl_and_kind (operands[2], operands[3], 0) == 1"
1153 [(set (attr "length")
1154 (cond [(eq (symbol_ref "shl_and_length (insn)") (const_int 2))
1156 (eq (symbol_ref "shl_and_length (insn)") (const_int 3))
1158 (eq (symbol_ref "shl_and_length (insn)") (const_int 4))
1160 (eq (symbol_ref "shl_and_length (insn)") (const_int 5))
1162 (eq (symbol_ref "shl_and_length (insn)") (const_int 6))
1164 (eq (symbol_ref "shl_and_length (insn)") (const_int 7))
1166 (eq (symbol_ref "shl_and_length (insn)") (const_int 8))
1167 (const_string "16")]
1168 (const_string "18")))
1169 (set_attr "type" "arith")])
1172 [(set (match_operand:SI 0 "register_operand" "=z")
1173 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
1174 (match_operand:SI 2 "const_int_operand" "n"))
1175 (match_operand:SI 3 "const_int_operand" "n")))
1176 (clobber (reg:SI 18))]
1177 "shl_and_kind (operands[2], operands[3], 0) == 2"
1179 [(set (attr "length")
1180 (cond [(eq (symbol_ref "shl_and_length (insn)") (const_int 2))
1182 (eq (symbol_ref "shl_and_length (insn)") (const_int 3))
1184 (eq (symbol_ref "shl_and_length (insn)") (const_int 4))
1186 (const_string "10")))
1187 (set_attr "type" "arith")])
1189 ;; shift left / and combination with a scratch register: The combine pass
1190 ;; does not accept the individual instructions, even though they are
1191 ;; cheap. But it needs a precise description so that it is usable after
1193 (define_insn "and_shl_scratch"
1194 [(set (match_operand:SI 0 "register_operand" "=r,&r")
1195 (lshiftrt:SI (ashift:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,0")
1196 (match_operand:SI 2 "const_int_operand" "N,n"))
1197 (match_operand:SI 3 "" "0,r"))
1198 (match_operand:SI 4 "const_int_operand" "n,n"))
1199 (match_operand:SI 5 "const_int_operand" "n,n")))
1200 (clobber (reg:SI 18))]
1203 [(set (attr "length")
1204 (cond [(eq (symbol_ref "shl_and_scr_length (insn)") (const_int 2))
1206 (eq (symbol_ref "shl_and_scr_length (insn)") (const_int 3))
1208 (eq (symbol_ref "shl_and_scr_length (insn)") (const_int 4))
1210 (eq (symbol_ref "shl_and_scr_length (insn)") (const_int 5))
1211 (const_string "10")]
1212 (const_string "12")))
1213 (set_attr "type" "arith")])
1216 [(set (match_operand:SI 0 "register_operand" "=r,&r")
1217 (lshiftrt:SI (ashift:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,0")
1218 (match_operand:SI 2 "const_int_operand" "N,n"))
1219 (match_operand:SI 3 "register_operand" "0,r"))
1220 (match_operand:SI 4 "const_int_operand" "n,n"))
1221 (match_operand:SI 5 "const_int_operand" "n,n")))
1222 (clobber (reg:SI 18))]
1227 rtx and_source = operands[1];
1229 if (INTVAL (operands[2]))
1231 gen_shifty_op (LSHIFTRT, operands);
1232 and_source = operands[3];
1234 emit_insn (gen_andsi3 (operands[0], operands[0], and_source));
1235 operands[2] = operands[4];
1236 gen_shifty_op (ASHIFT, operands);
1237 if (INTVAL (operands[5]))
1239 operands[2] = operands[5];
1240 gen_shifty_op (LSHIFTRT, operands);
1245 ;; signed left/right shift combination.
1247 [(set (match_operand:SI 0 "register_operand" "=r")
1248 (sign_extract:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
1249 (match_operand:SI 2 "const_int_operand" "n"))
1250 (match_operand:SI 3 "const_int_operand" "n")
1252 (clobber (reg:SI 18))]
1255 "if (gen_shl_sext (operands[0], operands[2], operands[3], operands[1])) FAIL;
1258 (define_insn "shl_sext_ext"
1259 [(set (match_operand:SI 0 "register_operand" "=r")
1260 (sign_extract:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
1261 (match_operand:SI 2 "const_int_operand" "n"))
1262 (match_operand:SI 3 "const_int_operand" "n")
1264 (clobber (reg:SI 18))]
1265 "shl_sext_kind (operands[2], operands[3], 0) <= 5"
1267 [(set (attr "length")
1268 (cond [(eq (symbol_ref "shl_sext_length (insn)") (const_int 1))
1270 (eq (symbol_ref "shl_sext_length (insn)") (const_int 2))
1272 (eq (symbol_ref "shl_sext_length (insn)") (const_int 3))
1274 (eq (symbol_ref "shl_sext_length (insn)") (const_int 4))
1276 (eq (symbol_ref "shl_sext_length (insn)") (const_int 5))
1278 (eq (symbol_ref "shl_sext_length (insn)") (const_int 6))
1280 (eq (symbol_ref "shl_sext_length (insn)") (const_int 7))
1282 (eq (symbol_ref "shl_sext_length (insn)") (const_int 8))
1283 (const_string "16")]
1284 (const_string "18")))
1285 (set_attr "type" "arith")])
1287 (define_insn "shl_sext_sub"
1288 [(set (match_operand:SI 0 "register_operand" "=z")
1289 (sign_extract:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
1290 (match_operand:SI 2 "const_int_operand" "n"))
1291 (match_operand:SI 3 "const_int_operand" "n")
1293 (clobber (reg:SI 18))]
1294 "(shl_sext_kind (operands[2], operands[3], 0) & ~1) == 6"
1296 [(set (attr "length")
1297 (cond [(eq (symbol_ref "shl_sext_length (insn)") (const_int 3))
1299 (eq (symbol_ref "shl_sext_length (insn)") (const_int 4))
1301 (eq (symbol_ref "shl_sext_length (insn)") (const_int 5))
1303 (eq (symbol_ref "shl_sext_length (insn)") (const_int 6))
1304 (const_string "12")]
1305 (const_string "14")))
1306 (set_attr "type" "arith")])
1309 ;; -------------------------------------------------------------------------
1311 ;; -------------------------------------------------------------------------
1314 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1315 (neg:SI (plus:SI (reg:SI 18)
1316 (match_operand:SI 1 "arith_reg_operand" "r"))))
1318 (ne:SI (ior:SI (reg:SI 18) (match_dup 1))
1322 [(set_attr "type" "arith")])
1324 (define_expand "negdi2"
1325 [(set (match_operand:DI 0 "arith_reg_operand" "")
1326 (neg:DI (match_operand:DI 1 "arith_reg_operand" "")))
1327 (clobber (reg:SI 18))]
1331 int low_word = (TARGET_LITTLE_ENDIAN ? 0 : 1);
1332 int high_word = (TARGET_LITTLE_ENDIAN ? 1 : 0);
1334 rtx low_src = operand_subword (operands[1], low_word, 0, DImode);
1335 rtx high_src = operand_subword (operands[1], high_word, 0, DImode);
1337 rtx low_dst = operand_subword (operands[0], low_word, 1, DImode);
1338 rtx high_dst = operand_subword (operands[0], high_word, 1, DImode);
1340 emit_insn (gen_clrt ());
1341 emit_insn (gen_negc (low_dst, low_src));
1342 emit_insn (gen_negc (high_dst, high_src));
1346 (define_insn "negsi2"
1347 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1348 (neg:SI (match_operand:SI 1 "arith_reg_operand" "r")))]
1351 [(set_attr "type" "arith")])
1353 (define_insn "one_cmplsi2"
1354 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1355 (not:SI (match_operand:SI 1 "arith_reg_operand" "r")))]
1358 [(set_attr "type" "arith")])
1360 ;; -------------------------------------------------------------------------
1361 ;; Zero extension instructions
1362 ;; -------------------------------------------------------------------------
1364 (define_insn "zero_extendhisi2"
1365 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1366 (zero_extend:SI (match_operand:HI 1 "arith_reg_operand" "r")))]
1369 [(set_attr "type" "arith")])
1371 (define_insn "zero_extendqisi2"
1372 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1373 (zero_extend:SI (match_operand:QI 1 "arith_reg_operand" "r")))]
1376 [(set_attr "type" "arith")])
1378 (define_insn "zero_extendqihi2"
1379 [(set (match_operand:HI 0 "arith_reg_operand" "=r")
1380 (zero_extend:HI (match_operand:QI 1 "arith_reg_operand" "r")))]
1383 [(set_attr "type" "arith")])
1385 ;; -------------------------------------------------------------------------
1386 ;; Sign extension instructions
1387 ;; -------------------------------------------------------------------------
1389 ;; ??? This should be a define expand.
1390 ;; ??? Or perhaps it should be dropped?
1392 (define_insn "extendsidi2"
1393 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
1394 (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" "r")))
1395 (clobber (reg:SI 18))]
1397 "mov %1,%S0\;mov %1,%R0\;shll %S0\;subc %S0,%S0"
1398 [(set_attr "length" "8")])
1400 (define_insn "extendhisi2"
1401 [(set (match_operand:SI 0 "arith_reg_operand" "=r,r")
1402 (sign_extend:SI (match_operand:HI 1 "general_movsrc_operand" "r,m")))]
1407 [(set_attr "type" "arith,load")])
1409 (define_insn "extendqisi2"
1410 [(set (match_operand:SI 0 "arith_reg_operand" "=r,r")
1411 (sign_extend:SI (match_operand:QI 1 "general_movsrc_operand" "r,m")))]
1416 [(set_attr "type" "arith,load")])
1418 (define_insn "extendqihi2"
1419 [(set (match_operand:HI 0 "arith_reg_operand" "=r,r")
1420 (sign_extend:HI (match_operand:QI 1 "general_movsrc_operand" "r,m")))]
1425 [(set_attr "type" "arith,load")])
1427 ;; -------------------------------------------------------------------------
1428 ;; Move instructions
1429 ;; -------------------------------------------------------------------------
1431 ;; define push and pop so it is easy for sh.c
1434 [(set (mem:SI (pre_dec:SI (reg:SI 15)))
1435 (match_operand:SI 0 "register_operand" "r,l,x"))]
1441 [(set_attr "type" "store,pstore,store")
1442 (set_attr "hit_stack" "yes")])
1445 [(set (match_operand:SI 0 "register_operand" "=r,l,x")
1446 (mem:SI (post_inc:SI (reg:SI 15))))]
1452 [(set_attr "type" "load,pload,load")
1453 (set_attr "hit_stack" "yes")])
1455 (define_insn "push_e"
1456 [(set (mem:SF (pre_dec:SI (reg:SI 15)))
1457 (match_operand:SF 0 "register_operand" "r,f,y"))]
1463 [(set_attr "type" "store")
1464 (set_attr "hit_stack" "yes")])
1466 (define_insn "pop_e"
1467 [(set (match_operand:SF 0 "register_operand" "=r,f,y")
1468 (mem:SF (post_inc:SI (reg:SI 15))))]
1474 [(set_attr "type" "load")
1475 (set_attr "hit_stack" "yes")])
1477 ;; These two patterns can happen as the result of optimization, when
1478 ;; comparisons get simplified to a move of zero or 1 into the T reg.
1479 ;; They don't disappear completely, because the T reg is a fixed hard reg.
1482 [(set (reg:SI 18) (const_int 0))]
1487 [(set (reg:SI 18) (const_int 1))]
1491 ;; t/z is first, so that it will be preferred over r/r when reloading a move
1492 ;; of a pseudo-reg into the T reg
1493 (define_insn "movsi_i"
1494 [(set (match_operand:SI 0 "general_movdst_operand" "=t,r,r,r,r,r,m,<,xl,xl,r")
1495 (match_operand:SI 1 "general_movsrc_operand" "z,Q,rI,m,xl,t,r,xl,r,>,i"))]
1498 (register_operand (operands[0], SImode)
1499 || register_operand (operands[1], SImode))"
1501 tst %1,%1\;rotcl %1\;xor #1,%1\;rotcr %1
1512 [(set_attr "type" "move,pcload,move,load,move,store,store,move,load,move,move")
1513 (set_attr "length" "8,*,*,*,*,*,*,*,*,*,*")])
1515 ;; t/z is first, so that it will be preferred over r/r when reloading a move
1516 ;; of a pseudo-reg into the T reg
1517 ;; ??? This allows moves from macl to fpul to be recognized, but these moves
1518 ;; will require a reload.
1519 (define_insn "movsi_ie"
1520 [(set (match_operand:SI 0 "general_movdst_operand" "=t,r,r,r,r,r,m,<,xl,xl,r,y,r")
1521 (match_operand:SI 1 "general_movsrc_operand" "z,Q,rI,m,xl,t,r,xl,r,>,i,r,y"))]
1523 && (register_operand (operands[0], SImode)
1524 || register_operand (operands[1], SImode))"
1526 tst %1,%1\;rotcl %1\;xor #1,%1\;rotcr %1
1539 [(set_attr "type" "move,pcload,move,load,move,store,store,move,load,move,move,move,move")
1540 (set_attr "length" "8,*,*,*,*,*,*,*,*,*,*,*,*")])
1542 (define_expand "movsi"
1543 [(set (match_operand:SI 0 "general_movdst_operand" "")
1544 (match_operand:SI 1 "general_movsrc_operand" ""))]
1546 "{ if (prepare_move_operands (operands, SImode)) DONE; }")
1548 (define_insn "movqi_i"
1549 [(set (match_operand:QI 0 "general_movdst_operand" "=r,r,m,r,r,l")
1550 (match_operand:QI 1 "general_movsrc_operand" "ri,m,r,t,l,r"))]
1551 "arith_reg_operand (operands[0], QImode)
1552 || arith_reg_operand (operands[1], QImode)"
1560 [(set_attr "type" "move,load,store,move,move,move")])
1562 (define_expand "movqi"
1563 [(set (match_operand:QI 0 "general_operand" "")
1564 (match_operand:QI 1 "general_operand" ""))]
1566 "{ if (prepare_move_operands (operands, QImode)) DONE; }")
1568 (define_insn "movhi_i"
1569 [(set (match_operand:HI 0 "general_movdst_operand" "=r,r,r,r,m,r,l,r")
1570 (match_operand:HI 1 "general_movsrc_operand" "Q,rI,m,t,r,l,r,i"))]
1571 "arith_reg_operand (operands[0], HImode)
1572 || arith_reg_operand (operands[1], HImode)"
1582 [(set_attr "type" "pcload,move,load,move,store,move,move,move")])
1584 (define_expand "movhi"
1585 [(set (match_operand:HI 0 "general_movdst_operand" "")
1586 (match_operand:HI 1 "general_movsrc_operand" ""))]
1588 "{ if (prepare_move_operands (operands, HImode)) DONE; }")
1590 ;; ??? This should be a define expand.
1593 [(set (match_operand:DI 0 "general_movdst_operand" "=r,r,r,m,r,r")
1594 (match_operand:DI 1 "general_movsrc_operand" "Q,r,m,r,i,x"))]
1595 "arith_reg_operand (operands[0], DImode)
1596 || arith_reg_operand (operands[1], DImode)"
1597 "* return output_movedouble (insn, operands, DImode);"
1598 [(set_attr "length" "4")
1599 (set_attr "type" "pcload,move,load,store,move,move")])
1601 ;; If the output is a register and the input is memory or a register, we have
1602 ;; to be careful and see which word needs to be loaded first.
1605 [(set (match_operand:DI 0 "general_movdst_operand" "")
1606 (match_operand:DI 1 "general_movsrc_operand" ""))]
1608 [(set (match_dup 2) (match_dup 3))
1609 (set (match_dup 4) (match_dup 5))]
1614 if ((GET_CODE (operands[0]) == MEM
1615 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1616 || (GET_CODE (operands[1]) == MEM
1617 && GET_CODE (XEXP (operands[1], 0)) == POST_INC))
1620 if (GET_CODE (operands[0]) == REG)
1621 regno = REGNO (operands[0]);
1622 else if (GET_CODE (operands[0]) == SUBREG)
1623 regno = REGNO (SUBREG_REG (operands[0])) + SUBREG_WORD (operands[0]);
1624 else if (GET_CODE (operands[0]) == MEM)
1628 || ! refers_to_regno_p (regno, regno + 1, operands[1], 0))
1630 operands[2] = operand_subword (operands[0], 0, 0, DImode);
1631 operands[3] = operand_subword (operands[1], 0, 0, DImode);
1632 operands[4] = operand_subword (operands[0], 1, 0, DImode);
1633 operands[5] = operand_subword (operands[1], 1, 0, DImode);
1637 operands[2] = operand_subword (operands[0], 1, 0, DImode);
1638 operands[3] = operand_subword (operands[1], 1, 0, DImode);
1639 operands[4] = operand_subword (operands[0], 0, 0, DImode);
1640 operands[5] = operand_subword (operands[1], 0, 0, DImode);
1643 if (operands[2] == 0 || operands[3] == 0
1644 || operands[4] == 0 || operands[5] == 0)
1648 (define_expand "movdi"
1649 [(set (match_operand:DI 0 "general_movdst_operand" "")
1650 (match_operand:DI 1 "general_movsrc_operand" ""))]
1652 "{ if ( prepare_move_operands (operands, DImode)) DONE; }")
1654 ;; ??? This should be a define expand.
1656 (define_insn "movdf_k"
1657 [(set (match_operand:DF 0 "general_movdst_operand" "=r,r,m")
1658 (match_operand:DF 1 "general_movsrc_operand" "r,m,r"))]
1659 "arith_reg_operand (operands[0], DFmode)
1660 || arith_reg_operand (operands[1], DFmode)"
1661 "* return output_movedouble (insn, operands, DFmode);"
1662 [(set_attr "length" "4")
1663 (set_attr "type" "move,load,store")])
1665 ;; If the output is a register and the input is memory or a register, we have
1666 ;; to be careful and see which word needs to be loaded first.
1669 [(set (match_operand:DF 0 "general_movdst_operand" "")
1670 (match_operand:DF 1 "general_movsrc_operand" ""))]
1672 [(set (match_dup 2) (match_dup 3))
1673 (set (match_dup 4) (match_dup 5))]
1678 if ((GET_CODE (operands[0]) == MEM
1679 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1680 || (GET_CODE (operands[1]) == MEM
1681 && GET_CODE (XEXP (operands[1], 0)) == POST_INC))
1684 if (GET_CODE (operands[0]) == REG)
1685 regno = REGNO (operands[0]);
1686 else if (GET_CODE (operands[0]) == SUBREG)
1687 regno = REGNO (SUBREG_REG (operands[0])) + SUBREG_WORD (operands[0]);
1688 else if (GET_CODE (operands[0]) == MEM)
1692 || ! refers_to_regno_p (regno, regno + 1, operands[1], 0))
1694 operands[2] = operand_subword (operands[0], 0, 0, DFmode);
1695 operands[3] = operand_subword (operands[1], 0, 0, DFmode);
1696 operands[4] = operand_subword (operands[0], 1, 0, DFmode);
1697 operands[5] = operand_subword (operands[1], 1, 0, DFmode);
1701 operands[2] = operand_subword (operands[0], 1, 0, DFmode);
1702 operands[3] = operand_subword (operands[1], 1, 0, DFmode);
1703 operands[4] = operand_subword (operands[0], 0, 0, DFmode);
1704 operands[5] = operand_subword (operands[1], 0, 0, DFmode);
1707 if (operands[2] == 0 || operands[3] == 0
1708 || operands[4] == 0 || operands[5] == 0)
1712 ;; If a base address generated by LEGITIMIZE_ADDRESS for SImode is
1713 ;; used only once, let combine add in the index again.
1716 [(set (match_operand:SI 0 "register_operand" "")
1717 (match_operand:SI 1 "" ""))
1718 (clobber (match_operand 2 "register_operand" ""))]
1719 "! reload_in_progress && ! reload_completed"
1723 rtx addr, reg, const_int;
1725 if (GET_CODE (operands[1]) != MEM)
1727 addr = XEXP (operands[1], 0);
1728 if (GET_CODE (addr) != PLUS)
1730 reg = XEXP (addr, 0);
1731 const_int = XEXP (addr, 1);
1732 if (GET_CODE (reg) != REG || GET_CODE (const_int) != CONST_INT)
1734 emit_move_insn (operands[2], const_int);
1735 emit_move_insn (operands[0],
1736 change_address (operands[1], VOIDmode,
1737 gen_rtx (PLUS, SImode, reg, operands[2])));
1742 [(set (match_operand:SI 1 "" "")
1743 (match_operand:SI 0 "register_operand" ""))
1744 (clobber (match_operand 2 "register_operand" ""))]
1745 "! reload_in_progress && ! reload_completed"
1749 rtx addr, reg, const_int;
1751 if (GET_CODE (operands[1]) != MEM)
1753 addr = XEXP (operands[1], 0);
1754 if (GET_CODE (addr) != PLUS)
1756 reg = XEXP (addr, 0);
1757 const_int = XEXP (addr, 1);
1758 if (GET_CODE (reg) != REG || GET_CODE (const_int) != CONST_INT)
1760 emit_move_insn (operands[2], const_int);
1761 emit_move_insn (change_address (operands[1], VOIDmode,
1762 gen_rtx (PLUS, SImode, reg, operands[2])),
1767 (define_expand "movdf"
1768 [(set (match_operand:DF 0 "general_movdst_operand" "")
1769 (match_operand:DF 1 "general_movsrc_operand" ""))]
1771 "{ if (prepare_move_operands (operands, DFmode)) DONE; }")
1773 (define_insn "movsf_i"
1774 [(set (match_operand:SF 0 "general_movdst_operand" "=r,r,r,m,l,r")
1775 (match_operand:SF 1 "general_movsrc_operand" "r,I,m,r,r,l"))]
1778 (arith_reg_operand (operands[0], SFmode)
1779 || arith_reg_operand (operands[1], SFmode))"
1787 [(set_attr "type" "move,move,load,store,move,move")])
1789 (define_insn "movsf_ie"
1790 [(set (match_operand:SF 0 "general_movdst_operand" "=f,r,f,f,f,m,r,m,!r,!f")
1791 (match_operand:SF 1 "general_movsrc_operand" "f,r,G,H,m,f,m,r,f,r"))]
1793 && (arith_reg_operand (operands[0], SFmode)
1794 || arith_reg_operand (operands[1], SFmode))"
1804 flds %1,fpul\;sts fpul,%0
1805 lds %1,fpul\;fsts fpul,%0"
1806 [(set_attr "type" "move,move,fp,fp,load,store,load,store,move,fp")
1807 (set_attr "length" "*,*,*,*,*,*,*,*,4,4")])
1809 (define_expand "movsf"
1810 [(set (match_operand:SF 0 "general_movdst_operand" "")
1811 (match_operand:SF 1 "general_movsrc_operand" ""))]
1813 "{ if (prepare_move_operands (operands, SFmode)) DONE; }")
1815 ;; ------------------------------------------------------------------------
1816 ;; Define the real conditional branch instructions.
1817 ;; ------------------------------------------------------------------------
1819 (define_insn "branch_true"
1820 [(set (pc) (if_then_else (ne (reg:SI 18) (const_int 0))
1821 (label_ref (match_operand 0 "" ""))
1824 "* return output_branch (1, insn, operands);"
1825 [(set_attr "type" "cbranch")])
1827 (define_insn "branch_false"
1828 [(set (pc) (if_then_else (eq (reg:SI 18) (const_int 0))
1829 (label_ref (match_operand 0 "" ""))
1832 "* return output_branch (0, insn, operands);"
1833 [(set_attr "type" "cbranch")])
1835 (define_insn "inverse_branch_true"
1836 [(set (pc) (if_then_else (ne (reg:SI 18) (const_int 0))
1838 (label_ref (match_operand 0 "" ""))))]
1840 "* return output_branch (0, insn, operands);"
1841 [(set_attr "type" "cbranch")])
1843 (define_insn "inverse_branch_false"
1844 [(set (pc) (if_then_else (eq (reg:SI 18) (const_int 0))
1846 (label_ref (match_operand 0 "" ""))))]
1848 "* return output_branch (1, insn, operands);"
1849 [(set_attr "type" "cbranch")])
1851 ;; Conditional branch insns
1853 (define_expand "beq"
1854 [(set (reg:SI 18) (eq:SI (match_dup 1) (match_dup 2)))
1856 (if_then_else (ne (reg:SI 18) (const_int 0))
1857 (label_ref (match_operand 0 "" ""))
1860 "from_compare (operands, EQ);")
1862 ; There is no bne compare, so we reverse the branch arms.
1864 (define_expand "bne"
1865 [(set (reg:SI 18) (eq:SI (match_dup 1) (match_dup 2)))
1867 (if_then_else (ne (reg:SI 18) (const_int 0))
1869 (label_ref (match_operand 0 "" ""))))]
1871 "from_compare (operands, NE);")
1873 (define_expand "bgt"
1874 [(set (reg:SI 18) (gt:SI (match_dup 1) (match_dup 2)))
1876 (if_then_else (ne (reg:SI 18) (const_int 0))
1877 (label_ref (match_operand 0 "" ""))
1880 "from_compare (operands, GT);")
1882 (define_expand "blt"
1883 [(set (reg:SI 18) (ge:SI (match_dup 1) (match_dup 2)))
1885 (if_then_else (ne (reg:SI 18) (const_int 0))
1887 (label_ref (match_operand 0 "" ""))))]
1891 if (GET_MODE (sh_compare_op0) == SFmode)
1893 rtx tmp = sh_compare_op0;
1894 sh_compare_op0 = sh_compare_op1;
1895 sh_compare_op1 = tmp;
1896 emit_insn (gen_bgt (operands[0]));
1899 from_compare (operands, LT);
1902 (define_expand "ble"
1903 [(set (reg:SI 18) (gt:SI (match_dup 1) (match_dup 2)))
1905 (if_then_else (ne (reg:SI 18) (const_int 0))
1907 (label_ref (match_operand 0 "" ""))))]
1909 "from_compare (operands, LE);")
1911 (define_expand "bge"
1912 [(set (reg:SI 18) (ge:SI (match_dup 1) (match_dup 2)))
1914 (if_then_else (ne (reg:SI 18) (const_int 0))
1915 (label_ref (match_operand 0 "" ""))
1920 if (GET_MODE (sh_compare_op0) == SFmode)
1922 rtx tmp = sh_compare_op0;
1923 sh_compare_op0 = sh_compare_op1;
1924 sh_compare_op1 = tmp;
1925 emit_insn (gen_ble (operands[0]));
1928 from_compare (operands, GE);
1931 (define_expand "bgtu"
1932 [(set (reg:SI 18) (gtu:SI (match_dup 1) (match_dup 2)))
1934 (if_then_else (ne (reg:SI 18) (const_int 0))
1935 (label_ref (match_operand 0 "" ""))
1938 "from_compare (operands, GTU); ")
1940 (define_expand "bltu"
1941 [(set (reg:SI 18) (geu:SI (match_dup 1) (match_dup 2)))
1943 (if_then_else (ne (reg:SI 18) (const_int 0))
1945 (label_ref (match_operand 0 "" ""))))]
1947 "from_compare (operands, LTU);")
1949 (define_expand "bgeu"
1950 [(set (reg:SI 18) (geu:SI (match_dup 1) (match_dup 2)))
1952 (if_then_else (ne (reg:SI 18) (const_int 0))
1953 (label_ref (match_operand 0 "" ""))
1956 "from_compare (operands, GEU);")
1958 (define_expand "bleu"
1959 [(set (reg:SI 18) (gtu:SI (match_dup 1) (match_dup 2)))
1961 (if_then_else (ne (reg:SI 18) (const_int 0))
1963 (label_ref (match_operand 0 "" ""))))]
1965 "from_compare (operands, LEU);")
1967 ;; ------------------------------------------------------------------------
1968 ;; Jump and linkage insns
1969 ;; ------------------------------------------------------------------------
1973 (label_ref (match_operand 0 "" "")))]
1977 /* The length is 16 if the delay slot is unfilled. */
1978 if (get_attr_length(insn) >= 14)
1979 return output_far_jump(insn, operands[0]);
1981 return \"bra %l0%#\";
1983 [(set_attr "type" "jump")
1984 (set_attr "needs_delay_slot" "yes")])
1986 (define_insn "calli"
1987 [(call (mem:SI (match_operand:SI 0 "arith_reg_operand" "r"))
1988 (match_operand 1 "" ""))
1989 (clobber (reg:SI 17))]
1992 [(set_attr "type" "call")
1993 (set_attr "needs_delay_slot" "yes")])
1995 (define_insn "call_valuei"
1996 [(set (match_operand 0 "" "=rf")
1997 (call (mem:SI (match_operand:SI 1 "arith_reg_operand" "r"))
1998 (match_operand 2 "" "")))
1999 (clobber (reg:SI 17))]
2002 [(set_attr "type" "call")
2003 (set_attr "needs_delay_slot" "yes")])
2005 (define_expand "call"
2006 [(parallel [(call (mem:SI (match_operand 0 "arith_reg_operand" ""))
2007 (match_operand 1 "" ""))
2008 (clobber (reg:SI 17))])]
2010 "operands[0] = force_reg (SImode, XEXP (operands[0], 0));")
2012 (define_expand "call_value"
2013 [(parallel [(set (match_operand 0 "arith_reg_operand" "")
2014 (call (mem:SI (match_operand 1 "arith_reg_operand" ""))
2015 (match_operand 2 "" "")))
2016 (clobber (reg:SI 17))])]
2018 "operands[1] = force_reg (SImode, XEXP (operands[1], 0));")
2020 (define_insn "indirect_jump"
2022 (match_operand:SI 0 "arith_reg_operand" "r"))]
2025 [(set_attr "needs_delay_slot" "yes")])
2027 ;; This might seem redundant, but it helps us distinguish case table jumps
2028 ;; which can be present in structured code from indirect jumps which can not
2029 ;; be present in structured code. This allows -fprofile-arcs to work.
2031 (define_insn "*casesi_jump"
2033 (match_operand:SI 0 "arith_reg_operand" "r"))
2034 (use (label_ref (match_operand 1 "" "")))]
2037 [(set_attr "needs_delay_slot" "yes")])
2039 ;; Call subroutine returning any type.
2040 ;; ??? This probably doesn't work.
2042 (define_expand "untyped_call"
2043 [(parallel [(call (match_operand 0 "" "")
2045 (match_operand 1 "" "")
2046 (match_operand 2 "" "")])]
2052 emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx, const0_rtx));
2054 for (i = 0; i < XVECLEN (operands[2], 0); i++)
2056 rtx set = XVECEXP (operands[2], 0, i);
2057 emit_move_insn (SET_DEST (set), SET_SRC (set));
2060 /* The optimizer does not know that the call sets the function value
2061 registers we stored in the result block. We avoid problems by
2062 claiming that all hard registers are used and clobbered at this
2064 emit_insn (gen_blockage ());
2069 ;; ------------------------------------------------------------------------
2071 ;; ------------------------------------------------------------------------
2073 ;; ??? This combiner pattern does not work, because combine does not combine
2074 ;; instructions that set a hard register when SMALL_REGISTER_CLASSES is
2075 ;; defined. Perhaps use a pseudo-reg for the T bit?
2078 [(parallel [(set (match_operand:SI 0 "arith_reg_operand" "=r")
2079 (plus:SI (match_dup 0)
2082 (eq:SI (plus:SI (match_dup 0) (const_int -1))
2092 ;; Load address of a label. This is only generated by the casesi expand.
2093 ;; This must use unspec, because this only works immediately before a casesi.
2097 (unspec [(label_ref (match_operand 0 "" ""))] 1))]
2100 [(set_attr "in_delay_slot" "no")])
2102 ;; case instruction for switch statements.
2104 ;; Operand 0 is index
2105 ;; operand 1 is the minimum bound
2106 ;; operand 2 is the maximum bound - minimum bound + 1
2107 ;; operand 3 is CODE_LABEL for the table;
2108 ;; operand 4 is the CODE_LABEL to go to if index out of range.
2110 ;; ??? There should be a barrier after the jump at the end.
2112 (define_expand "casesi"
2113 [(set (match_dup 5) (match_operand:SI 0 "arith_reg_operand" ""))
2114 (set (match_dup 5) (minus:SI (match_dup 5)
2115 (match_operand:SI 1 "arith_operand" "")))
2117 (gtu:SI (match_dup 5)
2118 (match_operand:SI 2 "arith_reg_operand" "")))
2120 (if_then_else (ne (reg:SI 18)
2122 (label_ref (match_operand 4 "" ""))
2124 (set (match_dup 6) (match_dup 5))
2125 (set (match_dup 6) (ashift:SI (match_dup 6) (match_dup 7)))
2126 (set (reg:SI 0) (unspec [(label_ref (match_operand 3 "" ""))] 1))
2127 (parallel [(set (reg:SI 0) (plus:SI (reg:SI 0)
2128 (mem:HI (plus:SI (reg:SI 0)
2130 (set (match_dup 6) (mem:HI (plus:SI (reg:SI 0) (match_dup 6))))])
2131 (parallel [(set (pc) (reg:SI 0))
2132 (use (label_ref (match_dup 3)))])]
2136 operands[1] = copy_to_mode_reg (SImode, operands[1]);
2137 operands[2] = copy_to_mode_reg (SImode, operands[2]);
2138 operands[5] = gen_reg_rtx (SImode);
2139 operands[6] = gen_reg_rtx (SImode);
2140 operands[7] = GEN_INT (TARGET_BIGTABLE ? 2 : 1);
2143 (define_insn "casesi_worker"
2146 (mem:HI (plus:SI (reg:SI 0)
2147 (match_operand:SI 0 "arith_reg_operand" "+r")))))
2148 (set (match_dup 0) (mem:HI (plus:SI (reg:SI 0)
2153 if (TARGET_BIGTABLE)
2154 return \"mov.l @(r0,%0),%0\;add %0,r0\";
2156 return \"mov.w @(r0,%0),%0\;add %0,r0\";
2158 [(set_attr "length" "4")])
2160 (define_insn "return"
2164 [(set_attr "type" "return")
2165 (set_attr "needs_delay_slot" "yes")])
2167 (define_expand "prologue"
2170 "sh_expand_prologue (); DONE;")
2172 (define_expand "epilogue"
2175 "sh_expand_epilogue ();")
2177 (define_insn "blockage"
2178 [(unspec_volatile [(const_int 0)] 0)]
2181 [(set_attr "length" "0")])
2183 ;; ------------------------------------------------------------------------
2185 ;; ------------------------------------------------------------------------
2188 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
2189 (eq:SI (reg:SI 18) (const_int 1)))]
2193 (define_expand "seq"
2194 [(set (match_operand:SI 0 "arith_reg_operand" "")
2197 "operands[1] = prepare_scc_operands (EQ);")
2199 (define_expand "slt"
2200 [(set (match_operand:SI 0 "arith_reg_operand" "")
2203 "operands[1] = prepare_scc_operands (LT);")
2205 (define_expand "sle"
2206 [(set (match_operand:SI 0 "arith_reg_operand" "")
2211 if (GET_MODE (sh_compare_op0) == SFmode)
2213 emit_insn (gen_sgt (operands[0]));
2214 emit_insn (gen_xorsi3 (operands[0], operands[0], const1_rtx));
2217 operands[1] = prepare_scc_operands (LE);
2220 (define_expand "sgt"
2221 [(set (match_operand:SI 0 "arith_reg_operand" "")
2224 "operands[1] = prepare_scc_operands (GT);")
2226 (define_expand "sge"
2227 [(set (match_operand:SI 0 "arith_reg_operand" "")
2232 if (GET_MODE (sh_compare_op0) == SFmode)
2234 emit_insn (gen_slt (operands[0]));
2235 emit_insn (gen_xorsi3 (operands[0], operands[0], const1_rtx));
2238 operands[1] = prepare_scc_operands (GE);
2241 (define_expand "sgtu"
2242 [(set (match_operand:SI 0 "arith_reg_operand" "")
2245 "operands[1] = prepare_scc_operands (GTU);")
2247 (define_expand "sltu"
2248 [(set (match_operand:SI 0 "arith_reg_operand" "")
2251 "operands[1] = prepare_scc_operands (LTU);")
2253 (define_expand "sleu"
2254 [(set (match_operand:SI 0 "arith_reg_operand" "")
2257 "operands[1] = prepare_scc_operands (LEU);")
2259 (define_expand "sgeu"
2260 [(set (match_operand:SI 0 "arith_reg_operand" "")
2263 "operands[1] = prepare_scc_operands (GEU);")
2265 (define_expand "sne"
2266 [(set (match_operand:SI 0 "arith_reg_operand" "")
2268 (set (match_dup 0) (xor:SI (match_dup 0) (const_int 1)))]
2270 "operands[1] = prepare_scc_operands (EQ);")
2272 ;; -------------------------------------------------------------------------
2273 ;; Instructions to cope with inline literal tables
2274 ;; -------------------------------------------------------------------------
2276 ; 2 byte integer in line
2278 (define_insn "consttable_2"
2279 [(unspec_volatile [(match_operand:SI 0 "general_operand" "=g")] 2)]
2283 assemble_integer (operands[0], 2, 1);
2286 [(set_attr "length" "2")
2287 (set_attr "in_delay_slot" "no")])
2289 ; 4 byte integer in line
2291 (define_insn "consttable_4"
2292 [(unspec_volatile [(match_operand:SI 0 "general_operand" "=g")] 4)]
2296 assemble_integer (operands[0], 4, 1);
2299 [(set_attr "length" "4")
2300 (set_attr "in_delay_slot" "no")])
2302 ; 8 byte integer in line
2304 (define_insn "consttable_8"
2305 [(unspec_volatile [(match_operand:SI 0 "general_operand" "=g")] 6)]
2309 assemble_integer (operands[0], 8, 1);
2312 [(set_attr "length" "8")
2313 (set_attr "in_delay_slot" "no")])
2315 ; align to a two byte boundary
2317 (define_insn "align_2"
2318 [(unspec_volatile [(const_int 0)] 10)]
2321 [(set_attr "length" "0")
2322 (set_attr "in_delay_slot" "no")])
2324 ; align to a four byte boundary
2326 (define_insn "align_4"
2327 [(unspec_volatile [(const_int 0)] 5)]
2330 [(set_attr "in_delay_slot" "no")])
2332 ; emitted at the end of the literal table, used to emit the
2333 ; 32bit branch labels if needed.
2335 (define_insn "consttable_end"
2336 [(unspec_volatile [(const_int 0)] 11)]
2338 "* return output_jump_label_table ();"
2339 [(set_attr "in_delay_slot" "no")])
2341 ;; -------------------------------------------------------------------------
2343 ;; -------------------------------------------------------------------------
2345 ;; String/block move insn.
2347 (define_expand "movstrsi"
2348 [(parallel [(set (mem:BLK (match_operand:BLK 0 "" ""))
2349 (mem:BLK (match_operand:BLK 1 "" "")))
2350 (use (match_operand:SI 2 "nonmemory_operand" ""))
2351 (use (match_operand:SI 3 "immediate_operand" ""))
2352 (clobber (reg:SI 17))
2353 (clobber (reg:SI 4))
2354 (clobber (reg:SI 5))
2355 (clobber (reg:SI 0))])]
2359 if(expand_block_move (operands))
2364 (define_insn "block_move_real"
2365 [(parallel [(set (mem:BLK (reg:SI 4))
2366 (mem:BLK (reg:SI 5)))
2367 (use (match_operand:SI 0 "arith_reg_operand" "r"))
2368 (clobber (reg:SI 17))
2369 (clobber (reg:SI 0))])]
2372 [(set_attr "type" "sfunc")
2373 (set_attr "needs_delay_slot" "yes")])
2375 (define_insn "block_lump_real"
2376 [(parallel [(set (mem:BLK (reg:SI 4))
2377 (mem:BLK (reg:SI 5)))
2378 (use (match_operand:SI 0 "arith_reg_operand" "r"))
2380 (clobber (reg:SI 17))
2381 (clobber (reg:SI 4))
2382 (clobber (reg:SI 5))
2383 (clobber (reg:SI 6))
2384 (clobber (reg:SI 0))])]
2387 [(set_attr "type" "sfunc")
2388 (set_attr "needs_delay_slot" "yes")])
2390 ;; -------------------------------------------------------------------------
2391 ;; Floating point instructions.
2392 ;; -------------------------------------------------------------------------
2394 ;; ??? All patterns should have a type attribute.
2396 (define_insn "addsf3"
2397 [(set (match_operand:SF 0 "arith_reg_operand" "=f")
2398 (plus:SF (match_operand:SF 1 "arith_reg_operand" "%0")
2399 (match_operand:SF 2 "arith_reg_operand" "f")))]
2402 [(set_attr "type" "fp")])
2404 (define_insn "subsf3"
2405 [(set (match_operand:SF 0 "arith_reg_operand" "=f")
2406 (minus:SF (match_operand:SF 1 "arith_reg_operand" "0")
2407 (match_operand:SF 2 "arith_reg_operand" "f")))]
2410 [(set_attr "type" "fp")])
2412 (define_insn "mulsf3"
2413 [(set (match_operand:SF 0 "arith_reg_operand" "=f")
2414 (mult:SF (match_operand:SF 1 "arith_reg_operand" "%0")
2415 (match_operand:SF 2 "arith_reg_operand" "f")))]
2418 [(set_attr "type" "fp")])
2420 (define_insn "*macsf3"
2421 [(set (match_operand:SF 0 "arith_reg_operand" "=f")
2422 (plus:SF (mult:SF (match_operand:SF 1 "arith_reg_operand" "%w")
2423 (match_operand:SF 2 "arith_reg_operand" "f"))
2424 (match_operand:SF 3 "arith_reg_operand" "0")))]
2427 [(set_attr "type" "fp")])
2429 (define_insn "divsf3"
2430 [(set (match_operand:SF 0 "arith_reg_operand" "=f")
2431 (div:SF (match_operand:SF 1 "arith_reg_operand" "0")
2432 (match_operand:SF 2 "arith_reg_operand" "f")))]
2435 [(set_attr "type" "fdiv")])
2437 ;; ??? This is the right solution, but it fails because the movs[if] patterns
2438 ;; silently clobber FPUL (r22) for int<->fp moves. Thus we can not explicitly
2441 ;;(define_expand "floatsisf2"
2442 ;; [(set (reg:SI 22)
2443 ;; (match_operand:SI 1 "arith_reg_operand" ""))
2444 ;; (set (match_operand:SF 0 "arith_reg_operand" "")
2445 ;; (float:SF (reg:SI 22)))]
2449 ;;(define_insn "*floatsisf"
2450 ;; [(set (match_operand:SF 0 "arith_reg_operand" "=f")
2451 ;; (float:SF (reg:SI 22)))]
2455 (define_insn "floatsisf2"
2456 [(set (match_operand:SF 0 "arith_reg_operand" "=f")
2457 (float:SF (match_operand:SI 1 "arith_reg_operand" "r")))]
2459 "lds %1,fpul\;float fpul,%0"
2460 [(set_attr "length" "4")
2461 (set_attr "type" "fp")])
2463 ;; ??? This is the right solution, but it fails because the movs[if] patterns
2464 ;; silently clobber FPUL (r22) for int<->fp moves. Thus we can not explicitly
2467 ;;(define_expand "fix_truncsfsi2"
2468 ;; [(set (reg:SI 22)
2469 ;; (fix:SI (match_operand:SF 1 "arith_reg_operand" "f")))
2470 ;; (set (match_operand:SI 0 "arith_reg_operand" "=r")
2475 ;;(define_insn "*fixsfsi"
2476 ;; [(set (reg:SI 22)
2477 ;; (fix:SI (match_operand:SF 0 "arith_reg_operand" "f")))]
2481 (define_insn "fix_truncsfsi2"
2482 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
2483 (fix:SI (match_operand:SF 1 "arith_reg_operand" "f")))]
2485 "ftrc %1,fpul\;sts fpul,%0"
2486 [(set_attr "length" "4")
2487 (set_attr "type" "move")])
2489 ;; ??? This should be SFmode not SImode in the compare, but that would
2490 ;; require fixing the branch patterns too.
2491 (define_insn "*cmpgtsf_t"
2492 [(set (reg:SI 18) (gt:SI (match_operand:SF 0 "arith_reg_operand" "f")
2493 (match_operand:SF 1 "arith_reg_operand" "f")))]
2496 [(set_attr "type" "fp")])
2498 ;; ??? This should be SFmode not SImode in the compare, but that would
2499 ;; require fixing the branch patterns too.
2500 (define_insn "*cmpeqsf_t"
2501 [(set (reg:SI 18) (eq:SI (match_operand:SF 0 "arith_reg_operand" "f")
2502 (match_operand:SF 1 "arith_reg_operand" "f")))]
2505 [(set_attr "type" "fp")])
2507 (define_expand "cmpsf"
2508 [(set (reg:SI 18) (compare (match_operand:SF 0 "arith_operand" "")
2509 (match_operand:SF 1 "arith_operand" "")))]
2513 sh_compare_op0 = operands[0];
2514 sh_compare_op1 = operands[1];
2518 (define_insn "negsf2"
2519 [(set (match_operand:SF 0 "arith_reg_operand" "=f")
2520 (neg:SF (match_operand:SF 1 "arith_reg_operand" "0")))]
2523 [(set_attr "type" "fp")])
2525 (define_insn "sqrtsf2"
2526 [(set (match_operand:SF 0 "arith_reg_operand" "=f")
2527 (sqrt:DF (match_operand:SF 1 "arith_reg_operand" "0")))]
2530 [(set_attr "type" "fdiv")])
2532 (define_insn "abssf2"
2533 [(set (match_operand:SF 0 "arith_reg_operand" "=f")
2534 (abs:SF (match_operand:SF 1 "arith_reg_operand" "0")))]
2537 [(set_attr "type" "fp")])
2539 ;; -------------------------------------------------------------------------
2541 ;; -------------------------------------------------------------------------
2543 ;; This matches cases where a stack pointer increment at the start of the
2544 ;; epilogue combines with a stack slot read loading the return value.
2547 [(set (match_operand:SI 0 "arith_reg_operand" "")
2548 (mem:SI (match_operand:SI 1 "arith_reg_operand" "")))
2549 (set (match_dup 1) (plus:SI (match_dup 1) (const_int 4)))]
2550 "REGNO (operands[1]) != REGNO (operands[0])"
2553 ;; See the comment on the dt combiner pattern above.
2556 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
2557 (plus:SI (match_dup 0)
2560 (eq:SI (match_dup 0)
2565 ;; These convert sequences such as `mov #k,r0; add r15,r0; mov.l @r0,rn'
2566 ;; to `mov #k,r0; mov.l @(r0,r15),rn'. These sequences are generated by
2567 ;; reload when the constant is too large for a reg+offset address.
2569 ;; ??? We would get much better code if this was done in reload. This would
2570 ;; require modifying find_reloads_address to recognize that if the constant
2571 ;; is out-of-range for an immediate add, then we get better code by reloading
2572 ;; the constant into a register than by reloading the sum into a register,
2573 ;; since the former is one instruction shorter if the address does not need
2574 ;; to be offsettable. Unfortunately this does not work, because there is
2575 ;; only one register, r0, that can be used as an index register. This register
2576 ;; is also the function return value register. So, if we try to force reload
2577 ;; to use double-reg addresses, then we end up with some instructions that
2578 ;; need to use r0 twice. The only way to fix this is to change the calling
2579 ;; convention so that r0 is not used to return values.
2582 [(set (match_operand:SI 0 "register_operand" "=r")
2583 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
2584 (set (mem:SI (match_dup 0))
2585 (match_operand:SI 2 "general_movsrc_operand" ""))]
2586 "REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
2587 "mov.l %2,@(%0,%1)")
2590 [(set (match_operand:SI 0 "register_operand" "=r")
2591 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
2592 (set (match_operand:SI 2 "general_movdst_operand" "")
2593 (mem:SI (match_dup 0)))]
2594 "REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
2595 "mov.l @(%0,%1),%2")
2598 [(set (match_operand:SI 0 "register_operand" "=r")
2599 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
2600 (set (mem:HI (match_dup 0))
2601 (match_operand:HI 2 "general_movsrc_operand" ""))]
2602 "REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
2603 "mov.w %2,@(%0,%1)")
2606 [(set (match_operand:SI 0 "register_operand" "=r")
2607 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
2608 (set (match_operand:HI 2 "general_movdst_operand" "")
2609 (mem:HI (match_dup 0)))]
2610 "REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
2611 "mov.w @(%0,%1),%2")
2614 [(set (match_operand:SI 0 "register_operand" "=r")
2615 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
2616 (set (mem:QI (match_dup 0))
2617 (match_operand:QI 2 "general_movsrc_operand" ""))]
2618 "REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
2619 "mov.b %2,@(%0,%1)")
2622 [(set (match_operand:SI 0 "register_operand" "=r")
2623 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
2624 (set (match_operand:QI 2 "general_movdst_operand" "")
2625 (mem:QI (match_dup 0)))]
2626 "REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
2627 "mov.b @(%0,%1),%2")
2630 [(set (match_operand:SI 0 "register_operand" "=r")
2631 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
2632 (set (mem:SF (match_dup 0))
2633 (match_operand:SF 2 "general_movsrc_operand" ""))]
2634 "REGNO (operands[0]) == 0
2635 && ((GET_CODE (operands[2]) == REG && REGNO (operands[2]) < 16)
2636 || (GET_CODE (operands[2]) == SUBREG
2637 && REGNO (SUBREG_REG (operands[2])) < 16))
2638 && reg_unused_after (operands[0], insn)"
2639 "mov.l %2,@(%0,%1)")
2642 [(set (match_operand:SI 0 "register_operand" "=r")
2643 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
2644 (set (match_operand:SF 2 "general_movdst_operand" "")
2646 (mem:SF (match_dup 0)))]
2647 "REGNO (operands[0]) == 0
2648 && ((GET_CODE (operands[2]) == REG && REGNO (operands[2]) < 16)
2649 || (GET_CODE (operands[2]) == SUBREG
2650 && REGNO (SUBREG_REG (operands[2])) < 16))
2651 && reg_unused_after (operands[0], insn)"
2652 "mov.l @(%0,%1),%2")
2655 [(set (match_operand:SI 0 "register_operand" "=r")
2656 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
2657 (set (mem:SF (match_dup 0))
2658 (match_operand:SF 2 "general_movsrc_operand" ""))]
2659 "REGNO (operands[0]) == 0
2660 && ((GET_CODE (operands[2]) == REG && REGNO (operands[2]) >= FIRST_FP_REG)
2661 || (GET_CODE (operands[2]) == SUBREG
2662 && REGNO (SUBREG_REG (operands[2])) >= FIRST_FP_REG))
2663 && reg_unused_after (operands[0], insn)"
2664 "fmov.s %2,@(%0,%1)")
2667 [(set (match_operand:SI 0 "register_operand" "=r")
2668 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
2669 (set (match_operand:SF 2 "general_movdst_operand" "")
2671 (mem:SF (match_dup 0)))]
2672 "REGNO (operands[0]) == 0
2673 && ((GET_CODE (operands[2]) == REG && REGNO (operands[2]) >= FIRST_FP_REG)
2674 || (GET_CODE (operands[2]) == SUBREG
2675 && REGNO (SUBREG_REG (operands[2])) >= FIRST_FP_REG))
2676 && reg_unused_after (operands[0], insn)"
2677 "fmov.s @(%0,%1),%2")