1 ;;- Machine description for the Hitachi SH.
2 ;; Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
4 ;; Contributed by Steve Chamberlain (sac@cygnus.com).
5 ;; Improved by Jim Wilson (wilson@cygnus.com).
7 ;; This file is part of GNU CC.
9 ;; GNU CC is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU CC is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU CC; see the file COPYING. If not, write to
21 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
25 ;; ??? Should prepend a * to all pattern names which are not used.
26 ;; This will make the compiler smaller, and rebuilds after changes faster.
28 ;; ??? Should be enhanced to include support for many more GNU superoptimizer
29 ;; sequences. Especially the sequences for arithmetic right shifts.
31 ;; ??? Should check all DImode patterns for consistency and usefulness.
33 ;; ??? The MAC.W and MAC.L instructions are not supported. There is no
34 ;; way to generate them.
36 ;; ??? The cmp/str instruction is not supported. Perhaps it can be used
37 ;; for a str* inline function.
39 ;; BSR is not generated by the compiler proper, but when relaxing, it
40 ;; generates .uses pseudo-ops that allow linker relaxation to create
41 ;; BSR. This is actually implemented in bfd/{coff,elf32}-sh.c
43 ;; Special constraints for SH machine description:
50 ;; Special formats used for outputting SH instructions:
52 ;; %. -- print a .s if insn needs delay slot
53 ;; %@ -- print rte/rts if is/isn't an interrupt function
54 ;; %# -- output a nop if there is nothing to put in the delay slot
55 ;; %O -- print a constant without the #
56 ;; %R -- print the lsw reg of a double
57 ;; %S -- print the msw reg of a double
58 ;; %T -- print next word of a double REG or MEM
60 ;; Special predicates:
62 ;; arith_operand -- operand is valid source for arithmetic op
63 ;; arith_reg_operand -- operand is valid register for arithmetic op
64 ;; general_movdst_operand -- operand is valid move destination
65 ;; general_movsrc_operand -- operand is valid move source
66 ;; logical_operand -- operand is valid source for logical op
68 ;; -------------------------------------------------------------------------
70 ;; -------------------------------------------------------------------------
102 ;; These are used with unspec.
114 ;; These are used with unspec_volatile.
120 (UNSPECV_WINDOW_END 10)
121 (UNSPECV_CONST_END 11)
124 ;; -------------------------------------------------------------------------
126 ;; -------------------------------------------------------------------------
131 "sh1,sh2,sh3,sh3e,sh4"
132 (const (symbol_ref "sh_cpu_attr")))
134 (define_attr "endian" "big,little"
135 (const (if_then_else (symbol_ref "TARGET_LITTLE_ENDIAN")
136 (const_string "little") (const_string "big"))))
138 ;; Indicate if the default fpu mode is single precision.
139 (define_attr "fpu_single" "yes,no"
140 (const (if_then_else (symbol_ref "TARGET_FPU_SINGLE")
141 (const_string "yes") (const_string "no"))))
143 (define_attr "fmovd" "yes,no"
144 (const (if_then_else (symbol_ref "TARGET_FMOVD")
145 (const_string "yes") (const_string "no"))))
147 (define_attr "issues" "1,2"
148 (const (if_then_else (symbol_ref "TARGET_SUPERSCALAR") (const_string "2") (const_string "1"))))
150 ;; cbranch conditional branch instructions
151 ;; jump unconditional jumps
152 ;; arith ordinary arithmetic
153 ;; arith3 a compound insn that behaves similarly to a sequence of
154 ;; three insns of type arith
155 ;; arith3b like above, but might end with a redirected branch
157 ;; load_si Likewise, SImode variant for general register.
159 ;; move register to register
160 ;; fmove register to register, floating point
161 ;; smpy word precision integer multiply
162 ;; dmpy longword or doublelongword precision integer multiply
164 ;; pload load of pr reg, which can't be put into delay slot of rts
165 ;; prset copy register to pr reg, ditto
166 ;; pstore store of pr reg, which can't be put into delay slot of jsr
167 ;; prget copy pr to register, ditto
168 ;; pcload pc relative load of constant value
169 ;; pcload_si Likewise, SImode variant for general register.
170 ;; rte return from exception
171 ;; sfunc special function call with known used registers
172 ;; call function call
174 ;; fdiv floating point divide (or square root)
175 ;; gp_fpul move between general purpose register and fpul
176 ;; dfp_arith, dfp_cmp,dfp_conv
177 ;; dfdiv double precision floating point divide (or square root)
178 ;; nil no-op move, will be deleted.
181 "cbranch,jump,jump_ind,arith,arith3,arith3b,dyn_shift,other,load,load_si,store,move,fmove,smpy,dmpy,return,pload,prset,pstore,prget,pcload,pcload_si,rte,sfunc,call,fp,fdiv,dfp_arith,dfp_cmp,dfp_conv,dfdiv,gp_fpul,nil"
182 (const_string "other"))
184 ;; Indicate what precision must be selected in fpscr for this insn, if any.
186 (define_attr "fp_mode" "single,double,none" (const_string "none"))
188 ; If a conditional branch destination is within -252..258 bytes away
189 ; from the instruction it can be 2 bytes long. Something in the
190 ; range -4090..4100 bytes can be 6 bytes long. All other conditional
191 ; branches are initially assumed to be 16 bytes long.
192 ; In machine_dependent_reorg, we split all branches that are longer than
195 ;; The maximum range used for SImode constant pool entries is 1018. A final
196 ;; instruction can add 8 bytes while only being 4 bytes in size, thus we
197 ;; can have a total of 1022 bytes in the pool. Add 4 bytes for a branch
198 ;; instruction around the pool table, 2 bytes of alignment before the table,
199 ;; and 30 bytes of alignment after the table. That gives a maximum total
200 ;; pool size of 1058 bytes.
201 ;; Worst case code/pool content size ratio is 1:2 (using asms).
202 ;; Thus, in the worst case, there is one instruction in front of a maximum
203 ;; sized pool, and then there are 1052 bytes of pool for every 508 bytes of
204 ;; code. For the last n bytes of code, there are 2n + 36 bytes of pool.
205 ;; If we have a forward branch, the initial table will be put after the
206 ;; unconditional branch.
208 ;; ??? We could do much better by keeping track of the actual pcloads within
209 ;; the branch range and in the pcload range in front of the branch range.
211 ;; ??? This looks ugly because genattrtab won't allow if_then_else or cond
213 (define_attr "short_cbranch_p" "no,yes"
214 (cond [(ne (symbol_ref "mdep_reorg_phase <= SH_FIXUP_PCLOAD") (const_int 0))
216 (leu (plus (minus (match_dup 0) (pc)) (const_int 252)) (const_int 506))
218 (ne (symbol_ref "NEXT_INSN (PREV_INSN (insn)) != insn") (const_int 0))
220 (leu (plus (minus (match_dup 0) (pc)) (const_int 252)) (const_int 508))
222 ] (const_string "no")))
224 (define_attr "med_branch_p" "no,yes"
225 (cond [(leu (plus (minus (match_dup 0) (pc)) (const_int 990))
228 (ne (symbol_ref "mdep_reorg_phase <= SH_FIXUP_PCLOAD") (const_int 0))
230 (leu (plus (minus (match_dup 0) (pc)) (const_int 4092))
233 ] (const_string "no")))
235 (define_attr "med_cbranch_p" "no,yes"
236 (cond [(leu (plus (minus (match_dup 0) (pc)) (const_int 988))
239 (ne (symbol_ref "mdep_reorg_phase <= SH_FIXUP_PCLOAD") (const_int 0))
241 (leu (plus (minus (match_dup 0) (pc)) (const_int 4090))
244 ] (const_string "no")))
246 (define_attr "braf_branch_p" "no,yes"
247 (cond [(ne (symbol_ref "! TARGET_SH2") (const_int 0))
249 (leu (plus (minus (match_dup 0) (pc)) (const_int 10330))
252 (ne (symbol_ref "mdep_reorg_phase <= SH_FIXUP_PCLOAD") (const_int 0))
254 (leu (plus (minus (match_dup 0) (pc)) (const_int 32764))
257 ] (const_string "no")))
259 (define_attr "braf_cbranch_p" "no,yes"
260 (cond [(ne (symbol_ref "! TARGET_SH2") (const_int 0))
262 (leu (plus (minus (match_dup 0) (pc)) (const_int 10328))
265 (ne (symbol_ref "mdep_reorg_phase <= SH_FIXUP_PCLOAD") (const_int 0))
267 (leu (plus (minus (match_dup 0) (pc)) (const_int 32762))
270 ] (const_string "no")))
272 ; An unconditional jump in the range -4092..4098 can be 2 bytes long.
273 ; For wider ranges, we need a combination of a code and a data part.
274 ; If we can get a scratch register for a long range jump, the code
275 ; part can be 4 bytes long; otherwise, it must be 8 bytes long.
276 ; If the jump is in the range -32764..32770, the data part can be 2 bytes
277 ; long; otherwise, it must be 6 bytes long.
279 ; All other instructions are two bytes long by default.
281 ;; ??? This should use something like *branch_p (minus (match_dup 0) (pc)),
282 ;; but getattrtab doesn't understand this.
283 (define_attr "length" ""
284 (cond [(eq_attr "type" "cbranch")
285 (cond [(eq_attr "short_cbranch_p" "yes")
287 (eq_attr "med_cbranch_p" "yes")
289 (eq_attr "braf_cbranch_p" "yes")
291 ;; ??? using pc is not computed transitively.
292 (ne (match_dup 0) (match_dup 0))
294 (ne (symbol_ref ("flag_pic")) (const_int 0))
297 (eq_attr "type" "jump")
298 (cond [(eq_attr "med_branch_p" "yes")
300 (and (eq (symbol_ref "GET_CODE (PREV_INSN (insn))")
302 (eq (symbol_ref "INSN_CODE (PREV_INSN (insn))")
303 (symbol_ref "code_for_indirect_jump_scratch")))
304 (if_then_else (eq_attr "braf_branch_p" "yes")
307 (eq_attr "braf_branch_p" "yes")
309 ;; ??? using pc is not computed transitively.
310 (ne (match_dup 0) (match_dup 0))
312 (ne (symbol_ref ("flag_pic")) (const_int 0))
317 ;; (define_function_unit {name} {num-units} {n-users} {test}
318 ;; {ready-delay} {issue-delay} [{conflict-list}])
320 ;; Load and store instructions save a cycle if they are aligned on a
321 ;; four byte boundary. Using a function unit for stores encourages
322 ;; gcc to separate load and store instructions by one instruction,
323 ;; which makes it more likely that the linker will be able to word
324 ;; align them when relaxing.
326 ;; Loads have a latency of two.
327 ;; However, call insns can have a delay slot, so that we want one more
328 ;; insn to be scheduled between the load of the function address and the call.
329 ;; This is equivalent to a latency of three.
330 ;; We cannot use a conflict list for this, because we need to distinguish
331 ;; between the actual call address and the function arguments.
332 ;; ADJUST_COST can only properly handle reductions of the cost, so we
333 ;; use a latency of three here.
334 ;; We only do this for SImode loads of general registers, to make the work
335 ;; for ADJUST_COST easier.
336 (define_function_unit "memory" 1 0
337 (and (eq_attr "issues" "1")
338 (eq_attr "type" "load_si,pcload_si"))
340 (define_function_unit "memory" 1 0
341 (and (eq_attr "issues" "1")
342 (eq_attr "type" "load,pcload,pload,store,pstore"))
345 (define_function_unit "int" 1 0
346 (and (eq_attr "issues" "1") (eq_attr "type" "arith3,arith3b")) 3 3)
348 (define_function_unit "int" 1 0
349 (and (eq_attr "issues" "1") (eq_attr "type" "dyn_shift")) 2 2)
351 (define_function_unit "int" 1 0
352 (and (eq_attr "issues" "1") (eq_attr "type" "!arith3,arith3b,dyn_shift")) 1 1)
354 ;; ??? These are approximations.
355 (define_function_unit "mpy" 1 0
356 (and (eq_attr "issues" "1") (eq_attr "type" "smpy")) 2 2)
357 (define_function_unit "mpy" 1 0
358 (and (eq_attr "issues" "1") (eq_attr "type" "dmpy")) 3 3)
360 (define_function_unit "fp" 1 0
361 (and (eq_attr "issues" "1") (eq_attr "type" "fp,fmove")) 2 1)
362 (define_function_unit "fp" 1 0
363 (and (eq_attr "issues" "1") (eq_attr "type" "fdiv")) 13 12)
367 ;; The SH4 is a dual-issue implementation, thus we have to multiply all
368 ;; costs by at least two.
369 ;; There will be single increments of the modeled that don't correspond
370 ;; to the actual target ;; whenever two insns to be issued depend one a
371 ;; single resource, and the scheduler picks to be the first one.
372 ;; If we multiplied the costs just by two, just two of these single
373 ;; increments would amount to an actual cycle. By picking a larger
374 ;; factor, we can ameliorate the effect; However, we then have to make sure
375 ;; that only two insns are modeled as issued per actual cycle.
376 ;; Moreover, we need a way to specify the latency of insns that don't
377 ;; use an actual function unit.
378 ;; We use an 'issue' function unit to do that, and a cost factor of 10.
380 (define_function_unit "issue" 2 0
381 (and (eq_attr "issues" "2") (eq_attr "type" "!nil,arith3"))
384 (define_function_unit "issue" 2 0
385 (and (eq_attr "issues" "2") (eq_attr "type" "arith3"))
388 ;; There is no point in providing exact scheduling information about branches,
389 ;; because they are at the starts / ends of basic blocks anyways.
391 ;; Some insns cannot be issued before/after another insn in the same cycle,
392 ;; irrespective of the type of the other insn.
394 ;; default is dual-issue, but can't be paired with an insn that
395 ;; uses multiple function units.
396 (define_function_unit "single_issue" 1 0
397 (and (eq_attr "issues" "2")
398 (eq_attr "type" "!smpy,dmpy,pload,pstore,dfp_cmp,gp_fpul,call,sfunc,arith3,arith3b"))
400 [(eq_attr "type" "smpy,dmpy,pload,pstore,dfp_cmp,gp_fpul")])
402 (define_function_unit "single_issue" 1 0
403 (and (eq_attr "issues" "2")
404 (eq_attr "type" "smpy,dmpy,pload,pstore,dfp_cmp,gp_fpul"))
408 ;; arith3 insns are always pairable at the start, but not inecessarily at
409 ;; the end; however, there doesn't seem to be a way to express that.
410 (define_function_unit "single_issue" 1 0
411 (and (eq_attr "issues" "2")
412 (eq_attr "type" "arith3"))
416 ;; arith3b insn are pairable at the end and have latency that prevents pairing
417 ;; with the following branch, but we don't want this latency be respected;
418 ;; When the following branch is immediately adjacent, we can redirect the
419 ;; internal branch, which is likly to be a larger win.
420 (define_function_unit "single_issue" 1 0
421 (and (eq_attr "issues" "2")
422 (eq_attr "type" "arith3b"))
426 ;; calls introduce a longisch delay that is likely to flush the pipelines.
427 (define_function_unit "single_issue" 1 0
428 (and (eq_attr "issues" "2")
429 (eq_attr "type" "call,sfunc"))
431 [(eq_attr "type" "!call") (eq_attr "type" "call")])
433 ;; Load and store instructions have no alignment peculiarities for the SH4,
434 ;; but they use the load-store unit, which they share with the fmove type
435 ;; insns (fldi[01]; fmov frn,frm; flds; fsts; fabs; fneg) .
436 ;; Loads have a latency of two.
437 ;; However, call insns can only paired with a preceding insn, and have
438 ;; a delay slot, so that we want two more insns to be scheduled between the
439 ;; load of the function address and the call. This is equivalent to a
441 ;; We cannot use a conflict list for this, because we need to distinguish
442 ;; between the actual call address and the function arguments.
443 ;; ADJUST_COST can only properly handle reductions of the cost, so we
444 ;; use a latency of three here, which gets multiplied by 10 to yield 30.
445 ;; We only do this for SImode loads of general registers, to make the work
446 ;; for ADJUST_COST easier.
448 ;; When specifying different latencies for different insns using the
449 ;; the same function unit, genattrtab.c assumes a 'FIFO constraint'
450 ;; so that the blockage is at least READY-COST (E) + 1 - READY-COST (C)
451 ;; for an executing insn E and a candidate insn C.
452 ;; Therefore, we define three different function units for load_store:
453 ;; load_store, load and load_si.
455 (define_function_unit "load_si" 1 0
456 (and (eq_attr "issues" "2")
457 (eq_attr "type" "load_si,pcload_si")) 30 10)
458 (define_function_unit "load" 1 0
459 (and (eq_attr "issues" "2")
460 (eq_attr "type" "load,pcload,pload")) 20 10)
461 (define_function_unit "load_store" 1 0
462 (and (eq_attr "issues" "2")
463 (eq_attr "type" "load_si,pcload_si,load,pcload,pload,store,pstore,fmove"))
466 (define_function_unit "int" 1 0
467 (and (eq_attr "issues" "2") (eq_attr "type" "arith,dyn_shift")) 10 10)
469 ;; Again, we have to pretend a lower latency for the "int" unit to avoid a
470 ;; spurious FIFO constraint; the multiply instructions use the "int"
471 ;; unit actually only for two cycles.
472 (define_function_unit "int" 1 0
473 (and (eq_attr "issues" "2") (eq_attr "type" "smpy,dmpy")) 20 20)
475 ;; We use a fictous "mpy" unit to express the actual latency.
476 (define_function_unit "mpy" 1 0
477 (and (eq_attr "issues" "2") (eq_attr "type" "smpy,dmpy")) 40 20)
479 ;; Again, we have to pretend a lower latency for the "int" unit to avoid a
480 ;; spurious FIFO constraint.
481 (define_function_unit "int" 1 0
482 (and (eq_attr "issues" "2") (eq_attr "type" "gp_fpul")) 10 10)
484 ;; We use a fictous "gp_fpul" unit to express the actual latency.
485 (define_function_unit "gp_fpul" 1 0
486 (and (eq_attr "issues" "2") (eq_attr "type" "gp_fpul")) 20 10)
488 ;; ??? multiply uses the floating point unit, but with a two cycle delay.
489 ;; Thus, a simple single-precision fp operation could finish if issued in
490 ;; the very next cycle, but stalls when issued two or three cycles later.
491 ;; Similarily, a divide / sqrt can work without stalls if issued in
492 ;; the very next cycle, while it would have to block if issued two or
493 ;; three cycles later.
494 ;; There is no way to model this with gcc's function units. This problem is
495 ;; actually mentioned in md.texi. Tackling this problem requires first that
496 ;; it is possible to speak about the target in an open discussion.
498 ;; However, simple double-precision operations always conflict.
500 (define_function_unit "fp" 1 0
501 (and (eq_attr "issues" "2") (eq_attr "type" "smpy,dmpy")) 40 40
502 [(eq_attr "type" "dfp_cmp,dfp_conv,dfp_arith")])
504 ;; The "fp" unit is for pipeline stages F1 and F2.
506 (define_function_unit "fp" 1 0
507 (and (eq_attr "issues" "2") (eq_attr "type" "fp")) 30 10)
509 ;; Again, we have to pretend a lower latency for the "fp" unit to avoid a
510 ;; spurious FIFO constraint; the bulk of the fdiv type insns executes in
512 (define_function_unit "fp" 1 0
513 (and (eq_attr "issues" "2") (eq_attr "type" "fdiv")) 30 10)
515 ;; The "fdiv" function unit models the aggregate effect of the F1, F2 and F3
516 ;; pipeline stages on the pipelining of fdiv/fsqrt insns.
517 ;; We also use it to give the actual latency here.
518 ;; fsqrt is actually one cycle faster than fdiv (and the value used here),
519 ;; but that will hardly matter in practice for scheduling.
520 (define_function_unit "fdiv" 1 0
521 (and (eq_attr "issues" "2") (eq_attr "type" "fdiv")) 120 100)
523 ;; There is again a late use of the "fp" unit by [d]fdiv type insns
524 ;; that we can't express.
526 (define_function_unit "fp" 1 0
527 (and (eq_attr "issues" "2") (eq_attr "type" "dfp_cmp,dfp_conv")) 40 20)
529 (define_function_unit "fp" 1 0
530 (and (eq_attr "issues" "2") (eq_attr "type" "dfp_arith")) 80 60)
532 (define_function_unit "fp" 1 0
533 (and (eq_attr "issues" "2") (eq_attr "type" "dfdiv")) 230 10)
535 (define_function_unit "fdiv" 1 0
536 (and (eq_attr "issues" "2") (eq_attr "type" "dfdiv")) 230 210)
538 ; Definitions for filling branch delay slots.
540 (define_attr "needs_delay_slot" "yes,no" (const_string "no"))
542 ;; ??? This should be (nil) instead of (const_int 0)
543 (define_attr "hit_stack" "yes,no"
544 (cond [(eq (symbol_ref "find_regno_note (insn, REG_INC, SP_REG)")
547 (const_string "yes")))
549 (define_attr "interrupt_function" "no,yes"
550 (const (symbol_ref "current_function_interrupt")))
552 (define_attr "in_delay_slot" "yes,no"
553 (cond [(eq_attr "type" "cbranch") (const_string "no")
554 (eq_attr "type" "pcload,pcload_si") (const_string "no")
555 (eq_attr "needs_delay_slot" "yes") (const_string "no")
556 (eq_attr "length" "2") (const_string "yes")
557 ] (const_string "no")))
559 (define_attr "is_sfunc" ""
560 (if_then_else (eq_attr "type" "sfunc") (const_int 1) (const_int 0)))
563 (eq_attr "needs_delay_slot" "yes")
564 [(eq_attr "in_delay_slot" "yes") (nil) (nil)])
566 ;; On the SH and SH2, the rte instruction reads the return pc from the stack,
567 ;; and thus we can't put a pop instruction in its delay slot.
568 ;; ??? On the SH3, the rte instruction does not use the stack, so a pop
569 ;; instruction can go in the delay slot.
571 ;; Since a normal return (rts) implicitly uses the PR register,
572 ;; we can't allow PR register loads in an rts delay slot.
575 (eq_attr "type" "return")
576 [(and (eq_attr "in_delay_slot" "yes")
577 (ior (and (eq_attr "interrupt_function" "no")
578 (eq_attr "type" "!pload,prset"))
579 (and (eq_attr "interrupt_function" "yes")
581 (ne (symbol_ref "TARGET_SH3") (const_int 0))
582 (eq_attr "hit_stack" "no"))))) (nil) (nil)])
584 ;; Since a call implicitly uses the PR register, we can't allow
585 ;; a PR register store in a jsr delay slot.
588 (ior (eq_attr "type" "call") (eq_attr "type" "sfunc"))
589 [(and (eq_attr "in_delay_slot" "yes")
590 (eq_attr "type" "!pstore,prget")) (nil) (nil)])
592 ;; Say that we have annulled true branches, since this gives smaller and
593 ;; faster code when branches are predicted as not taken.
596 (and (eq_attr "type" "cbranch")
597 (ne (symbol_ref "TARGET_SH2") (const_int 0)))
598 [(eq_attr "in_delay_slot" "yes") (eq_attr "in_delay_slot" "yes") (nil)])
600 ;; -------------------------------------------------------------------------
601 ;; SImode signed integer comparisons
602 ;; -------------------------------------------------------------------------
606 (eq:SI (and:SI (match_operand:SI 0 "arith_reg_operand" "z,r")
607 (match_operand:SI 1 "arith_operand" "L,r"))
612 ;; ??? Perhaps should only accept reg/constant if the register is reg 0.
613 ;; That would still allow reload to create cmpi instructions, but would
614 ;; perhaps allow forcing the constant into a register when that is better.
615 ;; Probably should use r0 for mem/imm compares, but force constant into a
616 ;; register for pseudo/imm compares.
618 (define_insn "cmpeqsi_t"
620 (eq:SI (match_operand:SI 0 "arith_reg_operand" "r,z,r")
621 (match_operand:SI 1 "arith_operand" "N,rI,r")))]
628 (define_insn "cmpgtsi_t"
630 (gt:SI (match_operand:SI 0 "arith_reg_operand" "r,r")
631 (match_operand:SI 1 "arith_reg_or_0_operand" "r,N")))]
637 (define_insn "cmpgesi_t"
639 (ge:SI (match_operand:SI 0 "arith_reg_operand" "r,r")
640 (match_operand:SI 1 "arith_reg_or_0_operand" "r,N")))]
646 ;; -------------------------------------------------------------------------
647 ;; SImode unsigned integer comparisons
648 ;; -------------------------------------------------------------------------
650 (define_insn "cmpgeusi_t"
652 (geu:SI (match_operand:SI 0 "arith_reg_operand" "r")
653 (match_operand:SI 1 "arith_reg_operand" "r")))]
657 (define_insn "cmpgtusi_t"
659 (gtu:SI (match_operand:SI 0 "arith_reg_operand" "r")
660 (match_operand:SI 1 "arith_reg_operand" "r")))]
664 ;; We save the compare operands in the cmpxx patterns and use them when
665 ;; we generate the branch.
667 (define_expand "cmpsi"
669 (compare (match_operand:SI 0 "arith_operand" "")
670 (match_operand:SI 1 "arith_operand" "")))]
674 sh_compare_op0 = operands[0];
675 sh_compare_op1 = operands[1];
679 ;; -------------------------------------------------------------------------
680 ;; DImode signed integer comparisons
681 ;; -------------------------------------------------------------------------
683 ;; ??? Could get better scheduling by splitting the initial test from the
684 ;; rest of the insn after reload. However, the gain would hardly justify
685 ;; the sh.md size increase necessary to do that.
689 (eq:SI (and:DI (match_operand:DI 0 "arith_reg_operand" "r")
690 (match_operand:DI 1 "arith_operand" "r"))
693 "* return output_branchy_insn (EQ, \"tst\\t%S1,%S0\;bf\\t%l9\;tst\\t%R1,%R0\",
695 [(set_attr "length" "6")
696 (set_attr "type" "arith3b")])
698 (define_insn "cmpeqdi_t"
700 (eq:SI (match_operand:DI 0 "arith_reg_operand" "r,r")
701 (match_operand:DI 1 "arith_reg_or_0_operand" "N,r")))]
704 tst %S0,%S0\;bf %,Ldi%=\;tst %R0,%R0\\n%,Ldi%=:
705 cmp/eq %S1,%S0\;bf %,Ldi%=\;cmp/eq %R1,%R0\\n%,Ldi%=:"
706 [(set_attr "length" "6")
707 (set_attr "type" "arith3b")])
711 (eq:SI (match_operand:DI 0 "arith_reg_operand" "r,r")
712 (match_operand:DI 1 "arith_reg_or_0_operand" "N,r")))]
713 ;; If we applied this split when not optimizing, it would only be
714 ;; applied during the machine-dependent reorg, when no new basic blocks
716 "reload_completed && optimize"
717 [(set (reg:SI T_REG) (eq:SI (match_dup 2) (match_dup 3)))
718 (set (pc) (if_then_else (eq (reg:SI T_REG) (const_int 0))
719 (label_ref (match_dup 6))
721 (set (reg:SI T_REG) (eq:SI (match_dup 4) (match_dup 5)))
726 = gen_rtx_REG (SImode,
727 true_regnum (operands[0]) + (TARGET_LITTLE_ENDIAN ? 1 : 0));
729 = (operands[1] == const0_rtx
731 : gen_rtx_REG (SImode,
732 true_regnum (operands[1])
733 + (TARGET_LITTLE_ENDIAN ? 1 : 0)));
734 operands[4] = gen_lowpart (SImode, operands[0]);
735 operands[5] = gen_lowpart (SImode, operands[1]);
736 operands[6] = gen_label_rtx ();
739 (define_insn "cmpgtdi_t"
741 (gt:SI (match_operand:DI 0 "arith_reg_operand" "r,r")
742 (match_operand:DI 1 "arith_reg_or_0_operand" "r,N")))]
745 cmp/eq\\t%S1,%S0\;bf{.|/}s\\t%,Ldi%=\;cmp/gt\\t%S1,%S0\;cmp/hi\\t%R1,%R0\\n%,Ldi%=:
746 tst\\t%S0,%S0\;bf{.|/}s\\t%,Ldi%=\;cmp/pl\\t%S0\;cmp/hi\\t%S0,%R0\\n%,Ldi%=:"
747 [(set_attr "length" "8")
748 (set_attr "type" "arith3")])
750 (define_insn "cmpgedi_t"
752 (ge:SI (match_operand:DI 0 "arith_reg_operand" "r,r")
753 (match_operand:DI 1 "arith_reg_or_0_operand" "r,N")))]
756 cmp/eq\\t%S1,%S0\;bf{.|/}s\\t%,Ldi%=\;cmp/ge\\t%S1,%S0\;cmp/hs\\t%R1,%R0\\n%,Ldi%=:
758 [(set_attr "length" "8,2")
759 (set_attr "type" "arith3,arith")])
761 ;; -------------------------------------------------------------------------
762 ;; DImode unsigned integer comparisons
763 ;; -------------------------------------------------------------------------
765 (define_insn "cmpgeudi_t"
767 (geu:SI (match_operand:DI 0 "arith_reg_operand" "r")
768 (match_operand:DI 1 "arith_reg_operand" "r")))]
770 "cmp/eq\\t%S1,%S0\;bf{.|/}s\\t%,Ldi%=\;cmp/hs\\t%S1,%S0\;cmp/hs\\t%R1,%R0\\n%,Ldi%=:"
771 [(set_attr "length" "8")
772 (set_attr "type" "arith3")])
774 (define_insn "cmpgtudi_t"
776 (gtu:SI (match_operand:DI 0 "arith_reg_operand" "r")
777 (match_operand:DI 1 "arith_reg_operand" "r")))]
779 "cmp/eq\\t%S1,%S0\;bf{.|/}s\\t%,Ldi%=\;cmp/hi\\t%S1,%S0\;cmp/hi\\t%R1,%R0\\n%,Ldi%=:"
780 [(set_attr "length" "8")
781 (set_attr "type" "arith3")])
783 ;; We save the compare operands in the cmpxx patterns and use them when
784 ;; we generate the branch.
786 (define_expand "cmpdi"
788 (compare (match_operand:DI 0 "arith_operand" "")
789 (match_operand:DI 1 "arith_operand" "")))]
793 sh_compare_op0 = operands[0];
794 sh_compare_op1 = operands[1];
798 ;; -------------------------------------------------------------------------
799 ;; Addition instructions
800 ;; -------------------------------------------------------------------------
802 ;; ??? This should be a define expand.
804 (define_insn "adddi3"
805 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
806 (plus:DI (match_operand:DI 1 "arith_reg_operand" "%0")
807 (match_operand:DI 2 "arith_reg_operand" "r")))
808 (clobber (reg:SI T_REG))]
811 [(set_attr "length" "6")])
814 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
815 (plus:DI (match_operand:DI 1 "arith_reg_operand" "%0")
816 (match_operand:DI 2 "arith_reg_operand" "r")))
817 (clobber (reg:SI T_REG))]
822 rtx high0, high2, low0 = gen_lowpart (SImode, operands[0]);
823 high0 = gen_rtx_REG (SImode,
824 true_regnum (operands[0])
825 + (TARGET_LITTLE_ENDIAN ? 1 : 0));
826 high2 = gen_rtx_REG (SImode,
827 true_regnum (operands[2])
828 + (TARGET_LITTLE_ENDIAN ? 1 : 0));
829 emit_insn (gen_clrt ());
830 emit_insn (gen_addc (low0, low0, gen_lowpart (SImode, operands[2])));
831 emit_insn (gen_addc1 (high0, high0, high2));
836 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
837 (plus:SI (plus:SI (match_operand:SI 1 "arith_reg_operand" "0")
838 (match_operand:SI 2 "arith_reg_operand" "r"))
841 (ltu:SI (plus:SI (match_dup 1) (match_dup 2)) (match_dup 1)))]
844 [(set_attr "type" "arith")])
847 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
848 (plus:SI (plus:SI (match_operand:SI 1 "arith_reg_operand" "0")
849 (match_operand:SI 2 "arith_reg_operand" "r"))
851 (clobber (reg:SI T_REG))]
854 [(set_attr "type" "arith")])
856 (define_insn "addsi3"
857 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
858 (plus:SI (match_operand:SI 1 "arith_operand" "%0")
859 (match_operand:SI 2 "arith_operand" "rI")))]
862 [(set_attr "type" "arith")])
864 ;; -------------------------------------------------------------------------
865 ;; Subtraction instructions
866 ;; -------------------------------------------------------------------------
868 ;; ??? This should be a define expand.
870 (define_insn "subdi3"
871 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
872 (minus:DI (match_operand:DI 1 "arith_reg_operand" "0")
873 (match_operand:DI 2 "arith_reg_operand" "r")))
874 (clobber (reg:SI T_REG))]
877 [(set_attr "length" "6")])
880 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
881 (minus:DI (match_operand:DI 1 "arith_reg_operand" "0")
882 (match_operand:DI 2 "arith_reg_operand" "r")))
883 (clobber (reg:SI T_REG))]
888 rtx high0, high2, low0 = gen_lowpart (SImode, operands[0]);
889 high0 = gen_rtx_REG (SImode,
890 true_regnum (operands[0])
891 + (TARGET_LITTLE_ENDIAN ? 1 : 0));
892 high2 = gen_rtx_REG (SImode,
893 true_regnum (operands[2])
894 + (TARGET_LITTLE_ENDIAN ? 1 : 0));
895 emit_insn (gen_clrt ());
896 emit_insn (gen_subc (low0, low0, gen_lowpart (SImode, operands[2])));
897 emit_insn (gen_subc1 (high0, high0, high2));
902 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
903 (minus:SI (minus:SI (match_operand:SI 1 "arith_reg_operand" "0")
904 (match_operand:SI 2 "arith_reg_operand" "r"))
907 (gtu:SI (minus:SI (match_dup 1) (match_dup 2)) (match_dup 1)))]
910 [(set_attr "type" "arith")])
913 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
914 (minus:SI (minus:SI (match_operand:SI 1 "arith_reg_operand" "0")
915 (match_operand:SI 2 "arith_reg_operand" "r"))
917 (clobber (reg:SI T_REG))]
920 [(set_attr "type" "arith")])
922 (define_insn "*subsi3_internal"
923 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
924 (minus:SI (match_operand:SI 1 "arith_reg_operand" "0")
925 (match_operand:SI 2 "arith_reg_operand" "r")))]
928 [(set_attr "type" "arith")])
930 ;; Convert `constant - reg' to `neg rX; add rX, #const' since this
931 ;; will sometimes save one instruction. Otherwise we might get
932 ;; `mov #const, rY; sub rY,rX; mov rX, rY' if the source and dest regs
935 (define_expand "subsi3"
936 [(set (match_operand:SI 0 "arith_reg_operand" "")
937 (minus:SI (match_operand:SI 1 "arith_operand" "")
938 (match_operand:SI 2 "arith_reg_operand" "")))]
942 if (GET_CODE (operands[1]) == CONST_INT)
944 emit_insn (gen_negsi2 (operands[0], operands[2]));
945 emit_insn (gen_addsi3 (operands[0], operands[0], operands[1]));
950 ;; -------------------------------------------------------------------------
951 ;; Division instructions
952 ;; -------------------------------------------------------------------------
954 ;; We take advantage of the library routines which don't clobber as many
955 ;; registers as a normal function call would.
957 ;; The INSN_REFERENCES_ARE_DELAYED in sh.h is problematic because it
958 ;; also has an effect on the register that holds the address of the sfunc.
959 ;; To make this work, we have an extra dummy insns that shows the use
960 ;; of this register for reorg.
962 (define_insn "use_sfunc_addr"
963 [(set (reg:SI PR_REG)
964 (unspec [(match_operand:SI 0 "register_operand" "r")] UNSPEC_SFUNC))]
967 [(set_attr "length" "0")])
969 ;; We must use a pseudo-reg forced to reg 0 in the SET_DEST rather than
970 ;; hard register 0. If we used hard register 0, then the next instruction
971 ;; would be a move from hard register 0 to a pseudo-reg. If the pseudo-reg
972 ;; gets allocated to a stack slot that needs its address reloaded, then
973 ;; there is nothing to prevent reload from using r0 to reload the address.
974 ;; This reload would clobber the value in r0 we are trying to store.
975 ;; If we let reload allocate r0, then this problem can never happen.
977 (define_insn "udivsi3_i1"
978 [(set (match_operand:SI 0 "register_operand" "=z")
979 (udiv:SI (reg:SI R4_REG) (reg:SI R5_REG)))
980 (clobber (reg:SI T_REG))
981 (clobber (reg:SI PR_REG))
982 (clobber (reg:SI R4_REG))
983 (use (match_operand:SI 1 "arith_reg_operand" "r"))]
986 [(set_attr "type" "sfunc")
987 (set_attr "needs_delay_slot" "yes")])
989 (define_insn "udivsi3_i4"
990 [(set (match_operand:SI 0 "register_operand" "=y")
991 (udiv:SI (reg:SI R4_REG) (reg:SI R5_REG)))
992 (clobber (reg:SI T_REG))
993 (clobber (reg:SI PR_REG))
994 (clobber (reg:DF DR0_REG))
995 (clobber (reg:DF DR2_REG))
996 (clobber (reg:DF DR4_REG))
997 (clobber (reg:SI R0_REG))
998 (clobber (reg:SI R1_REG))
999 (clobber (reg:SI R4_REG))
1000 (clobber (reg:SI R5_REG))
1001 (use (reg:PSI FPSCR_REG))
1002 (use (match_operand:SI 1 "arith_reg_operand" "r"))]
1003 "TARGET_SH4 && ! TARGET_FPU_SINGLE"
1005 [(set_attr "type" "sfunc")
1006 (set_attr "fp_mode" "double")
1007 (set_attr "needs_delay_slot" "yes")])
1009 (define_insn "udivsi3_i4_single"
1010 [(set (match_operand:SI 0 "register_operand" "=y")
1011 (udiv:SI (reg:SI R4_REG) (reg:SI R5_REG)))
1012 (clobber (reg:SI T_REG))
1013 (clobber (reg:SI PR_REG))
1014 (clobber (reg:DF DR0_REG))
1015 (clobber (reg:DF DR2_REG))
1016 (clobber (reg:DF DR4_REG))
1017 (clobber (reg:SI R0_REG))
1018 (clobber (reg:SI R1_REG))
1019 (clobber (reg:SI R4_REG))
1020 (clobber (reg:SI R5_REG))
1021 (use (match_operand:SI 1 "arith_reg_operand" "r"))]
1022 "TARGET_HARD_SH4 && TARGET_FPU_SINGLE"
1024 [(set_attr "type" "sfunc")
1025 (set_attr "needs_delay_slot" "yes")])
1027 (define_expand "udivsi3"
1028 [(set (match_dup 3) (symbol_ref:SI "__udivsi3"))
1029 (set (reg:SI R4_REG) (match_operand:SI 1 "general_operand" ""))
1030 (set (reg:SI R5_REG) (match_operand:SI 2 "general_operand" ""))
1031 (parallel [(set (match_operand:SI 0 "register_operand" "")
1032 (udiv:SI (reg:SI R4_REG)
1034 (clobber (reg:SI T_REG))
1035 (clobber (reg:SI PR_REG))
1036 (clobber (reg:SI R4_REG))
1037 (use (match_dup 3))])]
1043 operands[3] = gen_reg_rtx(SImode);
1044 /* Emit the move of the address to a pseudo outside of the libcall. */
1045 if (TARGET_HARD_SH4 && TARGET_SH3E)
1047 emit_move_insn (operands[3],
1048 gen_rtx_SYMBOL_REF (SImode, \"__udivsi3_i4\"));
1049 if (TARGET_FPU_SINGLE)
1050 last = gen_udivsi3_i4_single (operands[0], operands[3]);
1052 last = gen_udivsi3_i4 (operands[0], operands[3]);
1056 emit_move_insn (operands[3],
1057 gen_rtx_SYMBOL_REF (SImode, \"__udivsi3\"));
1058 last = gen_udivsi3_i1 (operands[0], operands[3]);
1060 first = emit_move_insn (gen_rtx_REG (SImode, 4), operands[1]);
1061 emit_move_insn (gen_rtx_REG (SImode, 5), operands[2]);
1062 last = emit_insn (last);
1063 /* Wrap the sequence in REG_LIBCALL / REG_RETVAL notes so that loop
1064 invariant code motion can move it. */
1065 REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last, REG_NOTES (first));
1066 REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first, REG_NOTES (last));
1070 (define_insn "divsi3_i1"
1071 [(set (match_operand:SI 0 "register_operand" "=z")
1072 (div:SI (reg:SI R4_REG) (reg:SI R5_REG)))
1073 (clobber (reg:SI T_REG))
1074 (clobber (reg:SI PR_REG))
1075 (clobber (reg:SI R1_REG))
1076 (clobber (reg:SI R2_REG))
1077 (clobber (reg:SI R3_REG))
1078 (use (match_operand:SI 1 "arith_reg_operand" "r"))]
1081 [(set_attr "type" "sfunc")
1082 (set_attr "needs_delay_slot" "yes")])
1084 (define_insn "divsi3_i4"
1085 [(set (match_operand:SI 0 "register_operand" "=y")
1086 (div:SI (reg:SI R4_REG) (reg:SI R5_REG)))
1087 (clobber (reg:SI PR_REG))
1088 (clobber (reg:DF DR0_REG))
1089 (clobber (reg:DF DR2_REG))
1090 (use (reg:PSI FPSCR_REG))
1091 (use (match_operand:SI 1 "arith_reg_operand" "r"))]
1092 "TARGET_SH4 && ! TARGET_FPU_SINGLE"
1094 [(set_attr "type" "sfunc")
1095 (set_attr "fp_mode" "double")
1096 (set_attr "needs_delay_slot" "yes")])
1098 (define_insn "divsi3_i4_single"
1099 [(set (match_operand:SI 0 "register_operand" "=y")
1100 (div:SI (reg:SI R4_REG) (reg:SI R5_REG)))
1101 (clobber (reg:SI PR_REG))
1102 (clobber (reg:DF DR0_REG))
1103 (clobber (reg:DF DR2_REG))
1104 (clobber (reg:SI R2_REG))
1105 (use (match_operand:SI 1 "arith_reg_operand" "r"))]
1106 "TARGET_HARD_SH4 && TARGET_FPU_SINGLE"
1108 [(set_attr "type" "sfunc")
1109 (set_attr "needs_delay_slot" "yes")])
1111 (define_expand "divsi3"
1112 [(set (match_dup 3) (symbol_ref:SI "__sdivsi3"))
1113 (set (reg:SI R4_REG) (match_operand:SI 1 "general_operand" ""))
1114 (set (reg:SI R5_REG) (match_operand:SI 2 "general_operand" ""))
1115 (parallel [(set (match_operand:SI 0 "register_operand" "")
1116 (div:SI (reg:SI R4_REG)
1118 (clobber (reg:SI T_REG))
1119 (clobber (reg:SI PR_REG))
1120 (clobber (reg:SI R1_REG))
1121 (clobber (reg:SI R2_REG))
1122 (clobber (reg:SI R3_REG))
1123 (use (match_dup 3))])]
1129 operands[3] = gen_reg_rtx(SImode);
1130 /* Emit the move of the address to a pseudo outside of the libcall. */
1131 if (TARGET_HARD_SH4 && TARGET_SH3E)
1133 emit_move_insn (operands[3],
1134 gen_rtx_SYMBOL_REF (SImode, \"__sdivsi3_i4\"));
1135 if (TARGET_FPU_SINGLE)
1136 last = gen_divsi3_i4_single (operands[0], operands[3]);
1138 last = gen_divsi3_i4 (operands[0], operands[3]);
1142 emit_move_insn (operands[3], gen_rtx_SYMBOL_REF (SImode, \"__sdivsi3\"));
1143 last = gen_divsi3_i1 (operands[0], operands[3]);
1145 first = emit_move_insn (gen_rtx_REG (SImode, 4), operands[1]);
1146 emit_move_insn (gen_rtx_REG (SImode, 5), operands[2]);
1147 last = emit_insn (last);
1148 /* Wrap the sequence in REG_LIBCALL / REG_RETVAL notes so that loop
1149 invariant code motion can move it. */
1150 REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last, REG_NOTES (first));
1151 REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first, REG_NOTES (last));
1155 ;; -------------------------------------------------------------------------
1156 ;; Multiplication instructions
1157 ;; -------------------------------------------------------------------------
1159 (define_insn "umulhisi3_i"
1160 [(set (reg:SI MACL_REG)
1161 (mult:SI (zero_extend:SI
1162 (match_operand:HI 0 "arith_reg_operand" "r"))
1164 (match_operand:HI 1 "arith_reg_operand" "r"))))]
1167 [(set_attr "type" "smpy")])
1169 (define_insn "mulhisi3_i"
1170 [(set (reg:SI MACL_REG)
1171 (mult:SI (sign_extend:SI
1172 (match_operand:HI 0 "arith_reg_operand" "r"))
1174 (match_operand:HI 1 "arith_reg_operand" "r"))))]
1177 [(set_attr "type" "smpy")])
1179 (define_expand "mulhisi3"
1180 [(set (reg:SI MACL_REG)
1181 (mult:SI (sign_extend:SI
1182 (match_operand:HI 1 "arith_reg_operand" ""))
1184 (match_operand:HI 2 "arith_reg_operand" ""))))
1185 (set (match_operand:SI 0 "arith_reg_operand" "")
1192 first = emit_insn (gen_mulhisi3_i (operands[1], operands[2]));
1193 last = emit_move_insn (operands[0], gen_rtx_REG (SImode, MACL_REG));
1194 /* Wrap the sequence in REG_LIBCALL / REG_RETVAL notes so that loop
1195 invariant code motion can move it. */
1196 REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last, REG_NOTES (first));
1197 REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first, REG_NOTES (last));
1201 (define_expand "umulhisi3"
1202 [(set (reg:SI MACL_REG)
1203 (mult:SI (zero_extend:SI
1204 (match_operand:HI 1 "arith_reg_operand" ""))
1206 (match_operand:HI 2 "arith_reg_operand" ""))))
1207 (set (match_operand:SI 0 "arith_reg_operand" "")
1214 first = emit_insn (gen_umulhisi3_i (operands[1], operands[2]));
1215 last = emit_move_insn (operands[0], gen_rtx_REG (SImode, MACL_REG));
1216 /* Wrap the sequence in REG_LIBCALL / REG_RETVAL notes so that loop
1217 invariant code motion can move it. */
1218 REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last, REG_NOTES (first));
1219 REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first, REG_NOTES (last));
1223 ;; mulsi3 on the SH2 can be done in one instruction, on the SH1 we generate
1224 ;; a call to a routine which clobbers known registers.
1227 [(set (match_operand:SI 1 "register_operand" "=z")
1228 (mult:SI (reg:SI R4_REG) (reg:SI R5_REG)))
1229 (clobber (reg:SI MACL_REG))
1230 (clobber (reg:SI T_REG))
1231 (clobber (reg:SI PR_REG))
1232 (clobber (reg:SI R3_REG))
1233 (clobber (reg:SI R2_REG))
1234 (clobber (reg:SI R1_REG))
1235 (use (match_operand:SI 0 "arith_reg_operand" "r"))]
1238 [(set_attr "type" "sfunc")
1239 (set_attr "needs_delay_slot" "yes")])
1241 (define_expand "mulsi3_call"
1242 [(set (reg:SI R4_REG) (match_operand:SI 1 "general_operand" ""))
1243 (set (reg:SI R5_REG) (match_operand:SI 2 "general_operand" ""))
1244 (parallel[(set (match_operand:SI 0 "register_operand" "")
1245 (mult:SI (reg:SI R4_REG)
1247 (clobber (reg:SI MACL_REG))
1248 (clobber (reg:SI T_REG))
1249 (clobber (reg:SI PR_REG))
1250 (clobber (reg:SI R3_REG))
1251 (clobber (reg:SI R2_REG))
1252 (clobber (reg:SI R1_REG))
1253 (use (match_operand:SI 3 "register_operand" ""))])]
1257 (define_insn "mul_l"
1258 [(set (reg:SI MACL_REG)
1259 (mult:SI (match_operand:SI 0 "arith_reg_operand" "r")
1260 (match_operand:SI 1 "arith_reg_operand" "r")))]
1263 [(set_attr "type" "dmpy")])
1265 (define_expand "mulsi3"
1266 [(set (reg:SI MACL_REG)
1267 (mult:SI (match_operand:SI 1 "arith_reg_operand" "")
1268 (match_operand:SI 2 "arith_reg_operand" "")))
1269 (set (match_operand:SI 0 "arith_reg_operand" "")
1278 /* The address must be set outside the libcall,
1279 since it goes into a pseudo. */
1280 rtx sym = gen_rtx_SYMBOL_REF (SImode, \"__mulsi3\");
1281 rtx addr = force_reg (SImode, sym);
1282 rtx insns = gen_mulsi3_call (operands[0], operands[1],
1284 first = XVECEXP (insns, 0, 0);
1285 last = XVECEXP (insns, 0, XVECLEN (insns, 0) - 1);
1290 rtx macl = gen_rtx_REG (SImode, MACL_REG);
1292 first = emit_insn (gen_mul_l (operands[1], operands[2]));
1293 /* consec_sets_giv can only recognize the first insn that sets a
1294 giv as the giv insn. So we must tag this also with a REG_EQUAL
1296 last = emit_insn (gen_movsi_i ((operands[0]), macl));
1298 /* Wrap the sequence in REG_LIBCALL / REG_RETVAL notes so that loop
1299 invariant code motion can move it. */
1300 REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last, REG_NOTES (first));
1301 REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first, REG_NOTES (last));
1305 (define_insn "mulsidi3_i"
1306 [(set (reg:SI MACH_REG)
1310 (sign_extend:DI (match_operand:SI 0 "arith_reg_operand" "r"))
1311 (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" "r")))
1313 (set (reg:SI MACL_REG)
1314 (mult:SI (match_dup 0)
1318 [(set_attr "type" "dmpy")])
1320 (define_insn "mulsidi3"
1321 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
1323 (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" "r"))
1324 (sign_extend:DI (match_operand:SI 2 "arith_reg_operand" "r"))))
1325 (clobber (reg:SI MACH_REG))
1326 (clobber (reg:SI MACL_REG))]
1331 [(set (match_operand:DI 0 "arith_reg_operand" "")
1333 (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" ""))
1334 (sign_extend:DI (match_operand:SI 2 "arith_reg_operand" ""))))
1335 (clobber (reg:SI MACH_REG))
1336 (clobber (reg:SI MACL_REG))]
1341 rtx low_dst = gen_lowpart (SImode, operands[0]);
1342 rtx high_dst = gen_highpart (SImode, operands[0]);
1344 emit_insn (gen_mulsidi3_i (operands[1], operands[2]));
1346 emit_move_insn (low_dst, gen_rtx_REG (SImode, MACL_REG));
1347 emit_move_insn (high_dst, gen_rtx_REG (SImode, MACH_REG));
1348 /* We need something to tag the possible REG_EQUAL notes on to. */
1349 emit_move_insn (operands[0], operands[0]);
1353 (define_insn "umulsidi3_i"
1354 [(set (reg:SI MACH_REG)
1358 (zero_extend:DI (match_operand:SI 0 "arith_reg_operand" "r"))
1359 (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" "r")))
1361 (set (reg:SI MACL_REG)
1362 (mult:SI (match_dup 0)
1366 [(set_attr "type" "dmpy")])
1368 (define_insn "umulsidi3"
1369 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
1371 (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" "r"))
1372 (zero_extend:DI (match_operand:SI 2 "arith_reg_operand" "r"))))
1373 (clobber (reg:SI MACH_REG))
1374 (clobber (reg:SI MACL_REG))]
1379 [(set (match_operand:DI 0 "arith_reg_operand" "")
1380 (mult:DI (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" ""))
1381 (zero_extend:DI (match_operand:SI 2 "arith_reg_operand" ""))))
1382 (clobber (reg:SI MACH_REG))
1383 (clobber (reg:SI MACL_REG))]
1388 rtx low_dst = gen_lowpart (SImode, operands[0]);
1389 rtx high_dst = gen_highpart (SImode, operands[0]);
1391 emit_insn (gen_umulsidi3_i (operands[1], operands[2]));
1393 emit_move_insn (low_dst, gen_rtx_REG (SImode, MACL_REG));
1394 emit_move_insn (high_dst, gen_rtx_REG (SImode, MACH_REG));
1395 /* We need something to tag the possible REG_EQUAL notes on to. */
1396 emit_move_insn (operands[0], operands[0]);
1400 (define_insn "smulsi3_highpart_i"
1401 [(set (reg:SI MACH_REG)
1405 (sign_extend:DI (match_operand:SI 0 "arith_reg_operand" "r"))
1406 (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" "r")))
1408 (clobber (reg:SI MACL_REG))]
1411 [(set_attr "type" "dmpy")])
1413 (define_expand "smulsi3_highpart"
1415 [(set (reg:SI MACH_REG)
1419 (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" ""))
1420 (sign_extend:DI (match_operand:SI 2 "arith_reg_operand" "")))
1422 (clobber (reg:SI MACL_REG))])
1423 (set (match_operand:SI 0 "arith_reg_operand" "")
1430 first = emit_insn (gen_smulsi3_highpart_i (operands[1], operands[2]));
1431 last = emit_move_insn (operands[0], gen_rtx_REG (SImode, MACH_REG));
1432 /* Wrap the sequence in REG_LIBCALL / REG_RETVAL notes so that loop
1433 invariant code motion can move it. */
1434 REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last, REG_NOTES (first));
1435 REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first, REG_NOTES (last));
1436 /* expand_binop can't find a suitable code in mul_highpart_optab to
1437 make a REG_EQUAL note from, so make one here.
1438 ??? Alternatively, we could put this at the calling site of expand_binop,
1439 i.e. expand_mult_highpart. */
1441 = gen_rtx_EXPR_LIST (REG_EQUAL, copy_rtx (SET_SRC (single_set (first))),
1446 (define_insn "umulsi3_highpart_i"
1447 [(set (reg:SI MACH_REG)
1451 (zero_extend:DI (match_operand:SI 0 "arith_reg_operand" "r"))
1452 (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" "r")))
1454 (clobber (reg:SI MACL_REG))]
1457 [(set_attr "type" "dmpy")])
1459 (define_expand "umulsi3_highpart"
1461 [(set (reg:SI MACH_REG)
1465 (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" ""))
1466 (zero_extend:DI (match_operand:SI 2 "arith_reg_operand" "")))
1468 (clobber (reg:SI MACL_REG))])
1469 (set (match_operand:SI 0 "arith_reg_operand" "")
1476 first = emit_insn (gen_umulsi3_highpart_i (operands[1], operands[2]));
1477 last = emit_move_insn (operands[0], gen_rtx_REG (SImode, MACH_REG));
1478 /* Wrap the sequence in REG_LIBCALL / REG_RETVAL notes so that loop
1479 invariant code motion can move it. */
1480 REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last, REG_NOTES (first));
1481 REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first, REG_NOTES (last));
1485 ;; -------------------------------------------------------------------------
1486 ;; Logical operations
1487 ;; -------------------------------------------------------------------------
1490 [(set (match_operand:SI 0 "arith_reg_operand" "=r,z")
1491 (and:SI (match_operand:SI 1 "arith_reg_operand" "%0,0")
1492 (match_operand:SI 2 "logical_operand" "r,L")))]
1495 [(set_attr "type" "arith")])
1497 ;; If the constant is 255, then emit a extu.b instruction instead of an
1498 ;; and, since that will give better code.
1500 (define_expand "andsi3"
1501 [(set (match_operand:SI 0 "arith_reg_operand" "")
1502 (and:SI (match_operand:SI 1 "arith_reg_operand" "")
1503 (match_operand:SI 2 "logical_operand" "")))]
1507 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 255)
1509 emit_insn (gen_zero_extendqisi2 (operands[0],
1510 gen_lowpart (QImode, operands[1])));
1515 (define_insn "iorsi3"
1516 [(set (match_operand:SI 0 "arith_reg_operand" "=r,z")
1517 (ior:SI (match_operand:SI 1 "arith_reg_operand" "%0,0")
1518 (match_operand:SI 2 "logical_operand" "r,L")))]
1521 [(set_attr "type" "arith")])
1523 (define_insn "xorsi3"
1524 [(set (match_operand:SI 0 "arith_reg_operand" "=z,r")
1525 (xor:SI (match_operand:SI 1 "arith_reg_operand" "%0,0")
1526 (match_operand:SI 2 "logical_operand" "L,r")))]
1529 [(set_attr "type" "arith")])
1531 ;; -------------------------------------------------------------------------
1532 ;; Shifts and rotates
1533 ;; -------------------------------------------------------------------------
1535 (define_insn "rotlsi3_1"
1536 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1537 (rotate:SI (match_operand:SI 1 "arith_reg_operand" "0")
1540 (lshiftrt:SI (match_dup 1) (const_int 31)))]
1543 [(set_attr "type" "arith")])
1545 (define_insn "rotlsi3_31"
1546 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1547 (rotate:SI (match_operand:SI 1 "arith_reg_operand" "0")
1549 (clobber (reg:SI T_REG))]
1552 [(set_attr "type" "arith")])
1554 (define_insn "rotlsi3_16"
1555 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1556 (rotate:SI (match_operand:SI 1 "arith_reg_operand" "r")
1560 [(set_attr "type" "arith")])
1562 (define_expand "rotlsi3"
1563 [(set (match_operand:SI 0 "arith_reg_operand" "")
1564 (rotate:SI (match_operand:SI 1 "arith_reg_operand" "")
1565 (match_operand:SI 2 "immediate_operand" "")))]
1569 static char rot_tab[] = {
1570 000, 000, 000, 000, 000, 000, 010, 001,
1571 001, 001, 011, 013, 003, 003, 003, 003,
1572 003, 003, 003, 003, 003, 013, 012, 002,
1573 002, 002, 010, 000, 000, 000, 000, 000,
1578 if (GET_CODE (operands[2]) != CONST_INT)
1580 count = INTVAL (operands[2]);
1581 choice = rot_tab[count];
1582 if (choice & 010 && SH_DYNAMIC_SHIFT_COST <= 1)
1588 emit_move_insn (operands[0], operands[1]);
1589 count -= (count & 16) * 2;
1592 emit_insn (gen_rotlsi3_16 (operands[0], operands[1]));
1599 parts[0] = gen_reg_rtx (SImode);
1600 parts[1] = gen_reg_rtx (SImode);
1601 emit_insn (gen_rotlsi3_16 (parts[2-choice], operands[1]));
1602 parts[choice-1] = operands[1];
1603 emit_insn (gen_ashlsi3 (parts[0], parts[0], GEN_INT (8)));
1604 emit_insn (gen_lshrsi3 (parts[1], parts[1], GEN_INT (8)));
1605 emit_insn (gen_iorsi3 (operands[0], parts[0], parts[1]));
1606 count = (count & ~16) - 8;
1610 for (; count > 0; count--)
1611 emit_insn (gen_rotlsi3_1 (operands[0], operands[0]));
1612 for (; count < 0; count++)
1613 emit_insn (gen_rotlsi3_31 (operands[0], operands[0]));
1618 (define_insn "*rotlhi3_8"
1619 [(set (match_operand:HI 0 "arith_reg_operand" "=r")
1620 (rotate:HI (match_operand:HI 1 "arith_reg_operand" "r")
1624 [(set_attr "type" "arith")])
1626 (define_expand "rotlhi3"
1627 [(set (match_operand:HI 0 "arith_reg_operand" "")
1628 (rotate:HI (match_operand:HI 1 "arith_reg_operand" "")
1629 (match_operand:HI 2 "immediate_operand" "")))]
1633 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 8)
1640 ;; This pattern is used by init_expmed for computing the costs of shift
1643 (define_insn_and_split "ashlsi3_std"
1644 [(set (match_operand:SI 0 "arith_reg_operand" "=r,r,r,r")
1645 (ashift:SI (match_operand:SI 1 "arith_reg_operand" "0,0,0,0")
1646 (match_operand:SI 2 "nonmemory_operand" "r,M,K,?ri")))
1647 (clobber (match_scratch:SI 3 "=X,X,X,&r"))]
1649 || (GET_CODE (operands[2]) == CONST_INT
1650 && CONST_OK_FOR_K (INTVAL (operands[2])))"
1658 && GET_CODE (operands[2]) == CONST_INT
1659 && ! CONST_OK_FOR_K (INTVAL (operands[2]))"
1660 [(set (match_dup 3) (match_dup 2))
1662 [(set (match_dup 0) (ashift:SI (match_dup 1) (match_dup 3)))
1663 (clobber (match_dup 4))])]
1664 "operands[4] = gen_rtx_SCRATCH (SImode);"
1665 [(set_attr "length" "*,*,*,4")
1666 (set_attr "type" "dyn_shift,arith,arith,arith")])
1668 (define_insn "ashlhi3_k"
1669 [(set (match_operand:HI 0 "arith_reg_operand" "=r,r")
1670 (ashift:HI (match_operand:HI 1 "arith_reg_operand" "0,0")
1671 (match_operand:HI 2 "const_int_operand" "M,K")))]
1672 "CONST_OK_FOR_K (INTVAL (operands[2]))"
1676 [(set_attr "type" "arith")])
1678 (define_insn "ashlsi3_n"
1679 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1680 (ashift:SI (match_operand:SI 1 "arith_reg_operand" "0")
1681 (match_operand:SI 2 "const_int_operand" "n")))
1682 (clobber (reg:SI T_REG))]
1683 "! sh_dynamicalize_shift_p (operands[2])"
1685 [(set (attr "length")
1686 (cond [(eq (symbol_ref "shift_insns_rtx (insn)") (const_int 1))
1688 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 2))
1690 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 3))
1692 (const_string "8")))
1693 (set_attr "type" "arith")])
1696 [(set (match_operand:SI 0 "arith_reg_operand" "")
1697 (ashift:SI (match_operand:SI 1 "arith_reg_operand" "")
1698 (match_operand:SI 2 "const_int_operand" "n")))
1699 (clobber (reg:SI T_REG))]
1701 [(use (reg:SI R0_REG))]
1704 gen_shifty_op (ASHIFT, operands);
1708 (define_expand "ashlsi3"
1709 [(parallel [(set (match_operand:SI 0 "arith_reg_operand" "")
1710 (ashift:SI (match_operand:SI 1 "arith_reg_operand" "")
1711 (match_operand:SI 2 "nonmemory_operand" "")))
1712 (clobber (reg:SI T_REG))])]
1716 if (GET_CODE (operands[2]) == CONST_INT
1717 && sh_dynamicalize_shift_p (operands[2]))
1718 operands[2] = force_reg (SImode, operands[2]);
1721 emit_insn (gen_ashlsi3_std (operands[0], operands[1], operands[2]));
1724 if (! immediate_operand (operands[2], GET_MODE (operands[2])))
1728 (define_insn "ashlhi3"
1729 [(set (match_operand:HI 0 "arith_reg_operand" "=r")
1730 (ashift:HI (match_operand:HI 1 "arith_reg_operand" "0")
1731 (match_operand:HI 2 "const_int_operand" "n")))
1732 (clobber (reg:SI T_REG))]
1735 [(set (attr "length")
1736 (cond [(eq (symbol_ref "shift_insns_rtx (insn)") (const_int 1))
1738 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 2))
1740 (const_string "6")))
1741 (set_attr "type" "arith")])
1744 [(set (match_operand:HI 0 "arith_reg_operand" "")
1745 (ashift:HI (match_operand:HI 1 "arith_reg_operand" "")
1746 (match_operand:HI 2 "const_int_operand" "n")))
1747 (clobber (reg:SI T_REG))]
1749 [(use (reg:SI R0_REG))]
1752 gen_shifty_hi_op (ASHIFT, operands);
1757 ; arithmetic shift right
1760 (define_insn "ashrsi3_k"
1761 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1762 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
1763 (match_operand:SI 2 "const_int_operand" "M")))
1764 (clobber (reg:SI T_REG))]
1765 "INTVAL (operands[2]) == 1"
1767 [(set_attr "type" "arith")])
1769 ;; We can't do HImode right shifts correctly unless we start out with an
1770 ;; explicit zero / sign extension; doing that would result in worse overall
1771 ;; code, so just let the machine independent code widen the mode.
1772 ;; That's why we don't have ashrhi3_k / lshrhi3_k / lshrhi3_m / lshrhi3 .
1775 ;; ??? This should be a define expand.
1777 (define_insn "ashrsi2_16"
1778 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1779 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "r")
1783 [(set_attr "length" "4")])
1786 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1787 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "r")
1790 [(set (match_dup 0) (rotate:SI (match_dup 1) (const_int 16)))
1791 (set (match_dup 0) (sign_extend:SI (match_dup 2)))]
1792 "operands[2] = gen_lowpart (HImode, operands[0]);")
1794 ;; ??? This should be a define expand.
1796 (define_insn "ashrsi2_31"
1797 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1798 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
1800 (clobber (reg:SI T_REG))]
1803 [(set_attr "length" "4")])
1806 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1807 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
1809 (clobber (reg:SI T_REG))]
1814 emit_insn (gen_ashlsi_c (operands[0], operands[1]));
1815 emit_insn (gen_subc1 (operands[0], operands[0], operands[0]));
1819 (define_insn "ashlsi_c"
1820 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1821 (ashift:SI (match_operand:SI 1 "arith_reg_operand" "0") (const_int 1)))
1823 (lt:SI (match_dup 1) (const_int 0)))]
1826 [(set_attr "type" "arith")])
1828 (define_insn "ashrsi3_d"
1829 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1830 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
1831 (neg:SI (match_operand:SI 2 "arith_reg_operand" "r"))))]
1834 [(set_attr "type" "dyn_shift")])
1836 (define_insn "ashrsi3_n"
1837 [(set (reg:SI R4_REG)
1838 (ashiftrt:SI (reg:SI R4_REG)
1839 (match_operand:SI 0 "const_int_operand" "i")))
1840 (clobber (reg:SI T_REG))
1841 (clobber (reg:SI PR_REG))
1842 (use (match_operand:SI 1 "arith_reg_operand" "r"))]
1845 [(set_attr "type" "sfunc")
1846 (set_attr "needs_delay_slot" "yes")])
1848 (define_expand "ashrsi3"
1849 [(parallel [(set (match_operand:SI 0 "arith_reg_operand" "")
1850 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "")
1851 (match_operand:SI 2 "nonmemory_operand" "")))
1852 (clobber (reg:SI T_REG))])]
1854 "if (expand_ashiftrt (operands)) DONE; else FAIL;")
1856 ;; logical shift right
1858 (define_insn "lshrsi3_d"
1859 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1860 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
1861 (neg:SI (match_operand:SI 2 "arith_reg_operand" "r"))))]
1864 [(set_attr "type" "dyn_shift")])
1866 ;; Only the single bit shift clobbers the T bit.
1868 (define_insn "lshrsi3_m"
1869 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1870 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
1871 (match_operand:SI 2 "const_int_operand" "M")))
1872 (clobber (reg:SI T_REG))]
1873 "CONST_OK_FOR_M (INTVAL (operands[2]))"
1875 [(set_attr "type" "arith")])
1877 (define_insn "lshrsi3_k"
1878 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1879 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
1880 (match_operand:SI 2 "const_int_operand" "K")))]
1881 "CONST_OK_FOR_K (INTVAL (operands[2]))
1882 && ! CONST_OK_FOR_M (INTVAL (operands[2]))"
1884 [(set_attr "type" "arith")])
1886 (define_insn "lshrsi3_n"
1887 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1888 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
1889 (match_operand:SI 2 "const_int_operand" "n")))
1890 (clobber (reg:SI T_REG))]
1891 "! sh_dynamicalize_shift_p (operands[2])"
1893 [(set (attr "length")
1894 (cond [(eq (symbol_ref "shift_insns_rtx (insn)") (const_int 1))
1896 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 2))
1898 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 3))
1900 (const_string "8")))
1901 (set_attr "type" "arith")])
1904 [(set (match_operand:SI 0 "arith_reg_operand" "")
1905 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "")
1906 (match_operand:SI 2 "const_int_operand" "n")))
1907 (clobber (reg:SI T_REG))]
1909 [(use (reg:SI R0_REG))]
1912 gen_shifty_op (LSHIFTRT, operands);
1916 (define_expand "lshrsi3"
1917 [(parallel [(set (match_operand:SI 0 "arith_reg_operand" "")
1918 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "")
1919 (match_operand:SI 2 "nonmemory_operand" "")))
1920 (clobber (reg:SI T_REG))])]
1924 if (GET_CODE (operands[2]) == CONST_INT
1925 && sh_dynamicalize_shift_p (operands[2]))
1926 operands[2] = force_reg (SImode, operands[2]);
1927 if (TARGET_SH3 && arith_reg_operand (operands[2], GET_MODE (operands[2])))
1929 rtx count = copy_to_mode_reg (SImode, operands[2]);
1930 emit_insn (gen_negsi2 (count, count));
1931 emit_insn (gen_lshrsi3_d (operands[0], operands[1], count));
1934 if (! immediate_operand (operands[2], GET_MODE (operands[2])))
1938 ;; ??? This should be a define expand.
1940 (define_insn "ashldi3_k"
1941 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
1942 (ashift:DI (match_operand:DI 1 "arith_reg_operand" "0")
1944 (clobber (reg:SI T_REG))]
1946 "shll %R0\;rotcl %S0"
1947 [(set_attr "length" "4")
1948 (set_attr "type" "arith")])
1950 (define_expand "ashldi3"
1951 [(parallel [(set (match_operand:DI 0 "arith_reg_operand" "")
1952 (ashift:DI (match_operand:DI 1 "arith_reg_operand" "")
1953 (match_operand:DI 2 "immediate_operand" "")))
1954 (clobber (reg:SI T_REG))])]
1956 "{ if (GET_CODE (operands[2]) != CONST_INT
1957 || INTVAL (operands[2]) != 1) FAIL;} ")
1959 ;; ??? This should be a define expand.
1961 (define_insn "lshrdi3_k"
1962 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
1963 (lshiftrt:DI (match_operand:DI 1 "arith_reg_operand" "0")
1965 (clobber (reg:SI T_REG))]
1967 "shlr %S0\;rotcr %R0"
1968 [(set_attr "length" "4")
1969 (set_attr "type" "arith")])
1971 (define_expand "lshrdi3"
1972 [(parallel [(set (match_operand:DI 0 "arith_reg_operand" "")
1973 (lshiftrt:DI (match_operand:DI 1 "arith_reg_operand" "")
1974 (match_operand:DI 2 "immediate_operand" "")))
1975 (clobber (reg:SI T_REG))])]
1977 "{ if (GET_CODE (operands[2]) != CONST_INT
1978 || INTVAL (operands[2]) != 1) FAIL;} ")
1980 ;; ??? This should be a define expand.
1982 (define_insn "ashrdi3_k"
1983 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
1984 (ashiftrt:DI (match_operand:DI 1 "arith_reg_operand" "0")
1986 (clobber (reg:SI T_REG))]
1988 "shar %S0\;rotcr %R0"
1989 [(set_attr "length" "4")
1990 (set_attr "type" "arith")])
1992 (define_expand "ashrdi3"
1993 [(parallel [(set (match_operand:DI 0 "arith_reg_operand" "")
1994 (ashiftrt:DI (match_operand:DI 1 "arith_reg_operand" "")
1995 (match_operand:DI 2 "immediate_operand" "")))
1996 (clobber (reg:SI T_REG))])]
1998 "{ if (GET_CODE (operands[2]) != CONST_INT
1999 || INTVAL (operands[2]) != 1) FAIL; } ")
2001 ;; combined left/right shift
2004 [(set (match_operand:SI 0 "register_operand" "")
2005 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
2006 (match_operand:SI 2 "const_int_operand" "n"))
2007 (match_operand:SI 3 "const_int_operand" "n")))]
2008 "(unsigned)INTVAL (operands[2]) < 32"
2009 [(use (reg:SI R0_REG))]
2010 "if (gen_shl_and (operands[0], operands[2], operands[3], operands[1])) FAIL;
2014 [(set (match_operand:SI 0 "register_operand" "")
2015 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
2016 (match_operand:SI 2 "const_int_operand" "n"))
2017 (match_operand:SI 3 "const_int_operand" "n")))
2018 (clobber (reg:SI T_REG))]
2019 "(unsigned)INTVAL (operands[2]) < 32"
2020 [(use (reg:SI R0_REG))]
2021 "if (gen_shl_and (operands[0], operands[2], operands[3], operands[1])) FAIL;
2025 [(set (match_operand:SI 0 "register_operand" "=r")
2026 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
2027 (match_operand:SI 2 "const_int_operand" "n"))
2028 (match_operand:SI 3 "const_int_operand" "n")))
2029 (clobber (reg:SI T_REG))]
2030 "shl_and_kind (operands[2], operands[3], 0) == 1"
2032 [(set (attr "length")
2033 (cond [(eq (symbol_ref "shl_and_length (insn)") (const_int 2))
2035 (eq (symbol_ref "shl_and_length (insn)") (const_int 3))
2037 (eq (symbol_ref "shl_and_length (insn)") (const_int 4))
2039 (eq (symbol_ref "shl_and_length (insn)") (const_int 5))
2041 (eq (symbol_ref "shl_and_length (insn)") (const_int 6))
2043 (eq (symbol_ref "shl_and_length (insn)") (const_int 7))
2045 (eq (symbol_ref "shl_and_length (insn)") (const_int 8))
2046 (const_string "16")]
2047 (const_string "18")))
2048 (set_attr "type" "arith")])
2051 [(set (match_operand:SI 0 "register_operand" "=z")
2052 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
2053 (match_operand:SI 2 "const_int_operand" "n"))
2054 (match_operand:SI 3 "const_int_operand" "n")))
2055 (clobber (reg:SI T_REG))]
2056 "shl_and_kind (operands[2], operands[3], 0) == 2"
2058 [(set (attr "length")
2059 (cond [(eq (symbol_ref "shl_and_length (insn)") (const_int 2))
2061 (eq (symbol_ref "shl_and_length (insn)") (const_int 3))
2063 (eq (symbol_ref "shl_and_length (insn)") (const_int 4))
2065 (const_string "10")))
2066 (set_attr "type" "arith")])
2068 ;; shift left / and combination with a scratch register: The combine pass
2069 ;; does not accept the individual instructions, even though they are
2070 ;; cheap. But it needs a precise description so that it is usable after
2072 (define_insn "and_shl_scratch"
2073 [(set (match_operand:SI 0 "register_operand" "=r,&r")
2077 (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,0")
2078 (match_operand:SI 2 "const_int_operand" "N,n"))
2079 (match_operand:SI 3 "" "0,r"))
2080 (match_operand:SI 4 "const_int_operand" "n,n"))
2081 (match_operand:SI 5 "const_int_operand" "n,n")))
2082 (clobber (reg:SI T_REG))]
2085 [(set (attr "length")
2086 (cond [(eq (symbol_ref "shl_and_scr_length (insn)") (const_int 2))
2088 (eq (symbol_ref "shl_and_scr_length (insn)") (const_int 3))
2090 (eq (symbol_ref "shl_and_scr_length (insn)") (const_int 4))
2092 (eq (symbol_ref "shl_and_scr_length (insn)") (const_int 5))
2093 (const_string "10")]
2094 (const_string "12")))
2095 (set_attr "type" "arith")])
2098 [(set (match_operand:SI 0 "register_operand" "=r,&r")
2102 (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,0")
2103 (match_operand:SI 2 "const_int_operand" "N,n"))
2104 (match_operand:SI 3 "register_operand" "0,r"))
2105 (match_operand:SI 4 "const_int_operand" "n,n"))
2106 (match_operand:SI 5 "const_int_operand" "n,n")))
2107 (clobber (reg:SI T_REG))]
2109 [(use (reg:SI R0_REG))]
2112 rtx and_source = operands[rtx_equal_p (operands[0], operands[1]) ? 3 : 1];
2114 if (INTVAL (operands[2]))
2116 gen_shifty_op (LSHIFTRT, operands);
2118 emit_insn (gen_andsi3 (operands[0], operands[0], and_source));
2119 operands[2] = operands[4];
2120 gen_shifty_op (ASHIFT, operands);
2121 if (INTVAL (operands[5]))
2123 operands[2] = operands[5];
2124 gen_shifty_op (LSHIFTRT, operands);
2129 ;; signed left/right shift combination.
2131 [(set (match_operand:SI 0 "register_operand" "=r")
2133 (ashift:SI (match_operand:SI 1 "register_operand" "r")
2134 (match_operand:SI 2 "const_int_operand" "n"))
2135 (match_operand:SI 3 "const_int_operand" "n")
2137 (clobber (reg:SI T_REG))]
2139 [(use (reg:SI R0_REG))]
2140 "if (gen_shl_sext (operands[0], operands[2], operands[3], operands[1])) FAIL;
2143 (define_insn "shl_sext_ext"
2144 [(set (match_operand:SI 0 "register_operand" "=r")
2146 (ashift:SI (match_operand:SI 1 "register_operand" "0")
2147 (match_operand:SI 2 "const_int_operand" "n"))
2148 (match_operand:SI 3 "const_int_operand" "n")
2150 (clobber (reg:SI T_REG))]
2151 "(unsigned)shl_sext_kind (operands[2], operands[3], 0) - 1 < 5"
2153 [(set (attr "length")
2154 (cond [(eq (symbol_ref "shl_sext_length (insn)") (const_int 1))
2156 (eq (symbol_ref "shl_sext_length (insn)") (const_int 2))
2158 (eq (symbol_ref "shl_sext_length (insn)") (const_int 3))
2160 (eq (symbol_ref "shl_sext_length (insn)") (const_int 4))
2162 (eq (symbol_ref "shl_sext_length (insn)") (const_int 5))
2164 (eq (symbol_ref "shl_sext_length (insn)") (const_int 6))
2166 (eq (symbol_ref "shl_sext_length (insn)") (const_int 7))
2168 (eq (symbol_ref "shl_sext_length (insn)") (const_int 8))
2169 (const_string "16")]
2170 (const_string "18")))
2171 (set_attr "type" "arith")])
2173 (define_insn "shl_sext_sub"
2174 [(set (match_operand:SI 0 "register_operand" "=z")
2176 (ashift:SI (match_operand:SI 1 "register_operand" "0")
2177 (match_operand:SI 2 "const_int_operand" "n"))
2178 (match_operand:SI 3 "const_int_operand" "n")
2180 (clobber (reg:SI T_REG))]
2181 "(shl_sext_kind (operands[2], operands[3], 0) & ~1) == 6"
2183 [(set (attr "length")
2184 (cond [(eq (symbol_ref "shl_sext_length (insn)") (const_int 3))
2186 (eq (symbol_ref "shl_sext_length (insn)") (const_int 4))
2188 (eq (symbol_ref "shl_sext_length (insn)") (const_int 5))
2190 (eq (symbol_ref "shl_sext_length (insn)") (const_int 6))
2191 (const_string "12")]
2192 (const_string "14")))
2193 (set_attr "type" "arith")])
2195 ;; These patterns are found in expansions of DImode shifts by 16, and
2196 ;; allow the xtrct instruction to be generated from C source.
2198 (define_insn "xtrct_left"
2199 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
2200 (ior:SI (ashift:SI (match_operand:SI 1 "arith_reg_operand" "r")
2202 (lshiftrt:SI (match_operand:SI 2 "arith_reg_operand" "0")
2206 [(set_attr "type" "arith")])
2208 (define_insn "xtrct_right"
2209 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
2210 (ior:SI (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
2212 (ashift:SI (match_operand:SI 2 "arith_reg_operand" "r")
2216 [(set_attr "type" "arith")])
2218 ;; -------------------------------------------------------------------------
2220 ;; -------------------------------------------------------------------------
2223 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
2224 (neg:SI (plus:SI (reg:SI T_REG)
2225 (match_operand:SI 1 "arith_reg_operand" "r"))))
2227 (ne:SI (ior:SI (reg:SI T_REG) (match_dup 1))
2231 [(set_attr "type" "arith")])
2233 (define_expand "negdi2"
2234 [(set (match_operand:DI 0 "arith_reg_operand" "")
2235 (neg:DI (match_operand:DI 1 "arith_reg_operand" "")))
2236 (clobber (reg:SI T_REG))]
2240 int low_word = (TARGET_LITTLE_ENDIAN ? 0 : 1);
2241 int high_word = (TARGET_LITTLE_ENDIAN ? 1 : 0);
2243 rtx low_src = operand_subword (operands[1], low_word, 0, DImode);
2244 rtx high_src = operand_subword (operands[1], high_word, 0, DImode);
2246 rtx low_dst = operand_subword (operands[0], low_word, 1, DImode);
2247 rtx high_dst = operand_subword (operands[0], high_word, 1, DImode);
2249 emit_insn (gen_clrt ());
2250 emit_insn (gen_negc (low_dst, low_src));
2251 emit_insn (gen_negc (high_dst, high_src));
2255 (define_insn "negsi2"
2256 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
2257 (neg:SI (match_operand:SI 1 "arith_reg_operand" "r")))]
2260 [(set_attr "type" "arith")])
2262 (define_insn "one_cmplsi2"
2263 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
2264 (not:SI (match_operand:SI 1 "arith_reg_operand" "r")))]
2267 [(set_attr "type" "arith")])
2269 ;; -------------------------------------------------------------------------
2270 ;; Zero extension instructions
2271 ;; -------------------------------------------------------------------------
2273 (define_insn "zero_extendhisi2"
2274 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
2275 (zero_extend:SI (match_operand:HI 1 "arith_reg_operand" "r")))]
2278 [(set_attr "type" "arith")])
2280 (define_insn "zero_extendqisi2"
2281 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
2282 (zero_extend:SI (match_operand:QI 1 "arith_reg_operand" "r")))]
2285 [(set_attr "type" "arith")])
2287 (define_insn "zero_extendqihi2"
2288 [(set (match_operand:HI 0 "arith_reg_operand" "=r")
2289 (zero_extend:HI (match_operand:QI 1 "arith_reg_operand" "r")))]
2292 [(set_attr "type" "arith")])
2294 ;; -------------------------------------------------------------------------
2295 ;; Sign extension instructions
2296 ;; -------------------------------------------------------------------------
2298 ;; ??? This should be a define expand.
2299 ;; ??? Or perhaps it should be dropped?
2301 /* There is no point in defining extendsidi2; convert_move generates good
2304 (define_insn "extendhisi2"
2305 [(set (match_operand:SI 0 "arith_reg_operand" "=r,r")
2306 (sign_extend:SI (match_operand:HI 1 "general_movsrc_operand" "r,m")))]
2311 [(set_attr "type" "arith,load")])
2313 (define_insn "extendqisi2"
2314 [(set (match_operand:SI 0 "arith_reg_operand" "=r,r")
2315 (sign_extend:SI (match_operand:QI 1 "general_movsrc_operand" "r,m")))]
2320 [(set_attr "type" "arith,load")])
2322 (define_insn "extendqihi2"
2323 [(set (match_operand:HI 0 "arith_reg_operand" "=r,r")
2324 (sign_extend:HI (match_operand:QI 1 "general_movsrc_operand" "r,m")))]
2329 [(set_attr "type" "arith,load")])
2331 ;; -------------------------------------------------------------------------
2332 ;; Move instructions
2333 ;; -------------------------------------------------------------------------
2335 ;; define push and pop so it is easy for sh.c
2337 (define_expand "push"
2338 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
2339 (match_operand:SI 0 "register_operand" "r,l,x"))]
2343 (define_expand "pop"
2344 [(set (match_operand:SI 0 "register_operand" "=r,l,x")
2345 (mem:SI (post_inc:SI (reg:SI SP_REG))))]
2349 (define_expand "push_e"
2350 [(parallel [(set (mem:SF (pre_dec:SI (reg:SI SP_REG)))
2351 (match_operand:SF 0 "" ""))
2352 (use (reg:PSI FPSCR_REG))
2353 (clobber (scratch:SI))])]
2357 (define_insn "push_fpul"
2358 [(set (mem:SF (pre_dec:SI (reg:SI SP_REG))) (reg:SF FPUL_REG))]
2361 [(set_attr "type" "store")
2362 (set_attr "hit_stack" "yes")])
2364 ;; DFmode pushes for sh4 require a lot of what is defined for movdf_i4,
2366 (define_expand "push_4"
2367 [(parallel [(set (mem:DF (pre_dec:SI (reg:SI SP_REG)))
2368 (match_operand:DF 0 "" ""))
2369 (use (reg:PSI FPSCR_REG))
2370 (clobber (scratch:SI))])]
2374 (define_expand "pop_e"
2375 [(parallel [(set (match_operand:SF 0 "" "")
2376 (mem:SF (post_inc:SI (reg:SI SP_REG))))
2377 (use (reg:PSI FPSCR_REG))
2378 (clobber (scratch:SI))])]
2382 (define_insn "pop_fpul"
2383 [(set (reg:SF FPUL_REG) (mem:SF (post_inc:SI (reg:SI SP_REG))))]
2386 [(set_attr "type" "load")
2387 (set_attr "hit_stack" "yes")])
2389 (define_expand "pop_4"
2390 [(parallel [(set (match_operand:DF 0 "" "")
2391 (mem:DF (post_inc:SI (reg:SI SP_REG))))
2392 (use (reg:PSI FPSCR_REG))
2393 (clobber (scratch:SI))])]
2397 ;; These two patterns can happen as the result of optimization, when
2398 ;; comparisons get simplified to a move of zero or 1 into the T reg.
2399 ;; They don't disappear completely, because the T reg is a fixed hard reg.
2402 [(set (reg:SI T_REG) (const_int 0))]
2407 [(set (reg:SI T_REG) (const_int 1))]
2411 ;; t/r must come after r/r, lest reload will try to reload stuff like
2412 ;; (set (subreg:SI (mem:QI (plus:SI (reg:SI SP_REG) (const_int 12)) 0) 0)
2413 ;; (made from (set (subreg:SI (reg:QI ###) 0) ) into T.
2414 (define_insn "movsi_i"
2415 [(set (match_operand:SI 0 "general_movdst_operand" "=r,r,t,r,r,r,r,m,<,<,x,l,x,l,r")
2416 (match_operand:SI 1 "general_movsrc_operand" "Q,rI,r,mr,x,l,t,r,x,l,r,r,>,>,i"))]
2419 && (register_operand (operands[0], SImode)
2420 || register_operand (operands[1], SImode))"
2437 [(set_attr "type" "pcload_si,move,*,load_si,move,prget,move,store,store,pstore,move,prset,load,pload,pcload_si")
2438 (set_attr "length" "*,*,*,*,*,*,*,*,*,*,*,*,*,*,*")])
2440 ;; t/r must come after r/r, lest reload will try to reload stuff like
2441 ;; (subreg:SI (reg:SF FR14_REG) 0) into T (compiling stdlib/strtod.c -m3e -O2)
2442 ;; ??? This allows moves from macl to fpul to be recognized, but these moves
2443 ;; will require a reload.
2444 (define_insn "movsi_ie"
2445 [(set (match_operand:SI 0 "general_movdst_operand" "=r,r,t,r,r,r,r,m,<,<,x,l,x,l,y,<,r,y,r,y")
2446 (match_operand:SI 1 "general_movsrc_operand" "Q,rI,r,mr,x,l,t,r,x,l,r,r,>,>,>,y,i,r,y,y"))]
2448 && (register_operand (operands[0], SImode)
2449 || register_operand (operands[1], SImode))"
2470 ! move optimized away"
2471 [(set_attr "type" "pcload_si,move,*,load_si,move,prget,move,store,store,pstore,move,prset,load,pload,load,store,pcload_si,gp_fpul,gp_fpul,nil")
2472 (set_attr "length" "*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,0")])
2474 (define_insn "movsi_i_lowpart"
2475 [(set (strict_low_part (match_operand:SI 0 "general_movdst_operand" "+r,r,r,r,r,r,m,r"))
2476 (match_operand:SI 1 "general_movsrc_operand" "Q,rI,mr,x,l,t,r,i"))]
2477 "register_operand (operands[0], SImode)
2478 || register_operand (operands[1], SImode)"
2488 [(set_attr "type" "pcload,move,load,move,prget,move,store,pcload")])
2490 (define_expand "movsi"
2491 [(set (match_operand:SI 0 "general_movdst_operand" "")
2492 (match_operand:SI 1 "general_movsrc_operand" ""))]
2494 "{ if (prepare_move_operands (operands, SImode)) DONE; }")
2496 (define_expand "ic_invalidate_line"
2497 [(parallel [(unspec_volatile [(match_operand:SI 0 "register_operand" "+r")
2498 (match_dup 1)] UNSPEC_ICACHE)
2499 (clobber (scratch:SI))])]
2503 operands[0] = force_reg (Pmode, operands[0]);
2504 operands[1] = force_reg (Pmode, GEN_INT (trunc_int_for_mode (0xf0000008,
2508 ;; The address %0 is assumed to be 4-aligned at least. Thus, by ORing
2509 ;; 0xf0000008, we get the low-oder bits *1*00 (binary), which fits
2510 ;; the requirement *1*00 for associative address writes. The alignment of
2511 ;; %0 implies that its least significant bit is cleared,
2512 ;; thus we clear the V bit of a matching entry if there is one.
2513 (define_insn "ic_invalidate_line_i"
2514 [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")
2515 (match_operand:SI 1 "register_operand" "r")]
2517 (clobber (match_scratch:SI 2 "=&r"))]
2519 "ocbwb\\t@%0\;extu.w\\t%0,%2\;or\\t%1,%2\;mov.l\\t%0,@%2"
2520 [(set_attr "length" "8")])
2522 (define_insn "movqi_i"
2523 [(set (match_operand:QI 0 "general_movdst_operand" "=r,r,m,r,r,l")
2524 (match_operand:QI 1 "general_movsrc_operand" "ri,m,r,t,l,r"))]
2525 "arith_reg_operand (operands[0], QImode)
2526 || arith_reg_operand (operands[1], QImode)"
2534 [(set_attr "type" "move,load,store,move,move,move")])
2536 (define_expand "movqi"
2537 [(set (match_operand:QI 0 "general_operand" "")
2538 (match_operand:QI 1 "general_operand" ""))]
2540 "{ if (prepare_move_operands (operands, QImode)) DONE; }")
2542 (define_insn "movhi_i"
2543 [(set (match_operand:HI 0 "general_movdst_operand" "=r,r,r,r,m,r,l,r")
2544 (match_operand:HI 1 "general_movsrc_operand" "Q,rI,m,t,r,l,r,i"))]
2545 "arith_reg_operand (operands[0], HImode)
2546 || arith_reg_operand (operands[1], HImode)"
2556 [(set_attr "type" "pcload,move,load,move,store,move,move,pcload")])
2558 (define_expand "movhi"
2559 [(set (match_operand:HI 0 "general_movdst_operand" "")
2560 (match_operand:HI 1 "general_movsrc_operand" ""))]
2562 "{ if (prepare_move_operands (operands, HImode)) DONE; }")
2564 ;; ??? This should be a define expand.
2566 ;; x/r can be created by inlining/cse, e.g. for execute/961213-1.c
2567 ;; compiled with -m2 -ml -O3 -funroll-loops
2569 [(set (match_operand:DI 0 "general_movdst_operand" "=r,r,r,m,r,r,r,*!x")
2570 (match_operand:DI 1 "general_movsrc_operand" "Q,r,m,r,I,i,x,r"))]
2571 "arith_reg_operand (operands[0], DImode)
2572 || arith_reg_operand (operands[1], DImode)"
2573 "* return output_movedouble (insn, operands, DImode);"
2574 [(set_attr "length" "4")
2575 (set_attr "type" "pcload,move,load,store,move,pcload,move,move")])
2577 ;; If the output is a register and the input is memory or a register, we have
2578 ;; to be careful and see which word needs to be loaded first.
2581 [(set (match_operand:DI 0 "general_movdst_operand" "")
2582 (match_operand:DI 1 "general_movsrc_operand" ""))]
2584 [(set (match_dup 2) (match_dup 3))
2585 (set (match_dup 4) (match_dup 5))]
2590 if ((GET_CODE (operands[0]) == MEM
2591 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2592 || (GET_CODE (operands[1]) == MEM
2593 && GET_CODE (XEXP (operands[1], 0)) == POST_INC))
2596 if (GET_CODE (operands[0]) == REG)
2597 regno = REGNO (operands[0]);
2598 else if (GET_CODE (operands[0]) == SUBREG)
2599 regno = subreg_regno (operands[0]);
2600 else if (GET_CODE (operands[0]) == MEM)
2606 || ! refers_to_regno_p (regno, regno + 1, operands[1], 0))
2608 operands[2] = operand_subword (operands[0], 0, 0, DImode);
2609 operands[3] = operand_subword (operands[1], 0, 0, DImode);
2610 operands[4] = operand_subword (operands[0], 1, 0, DImode);
2611 operands[5] = operand_subword (operands[1], 1, 0, DImode);
2615 operands[2] = operand_subword (operands[0], 1, 0, DImode);
2616 operands[3] = operand_subword (operands[1], 1, 0, DImode);
2617 operands[4] = operand_subword (operands[0], 0, 0, DImode);
2618 operands[5] = operand_subword (operands[1], 0, 0, DImode);
2621 if (operands[2] == 0 || operands[3] == 0
2622 || operands[4] == 0 || operands[5] == 0)
2626 (define_expand "movdi"
2627 [(set (match_operand:DI 0 "general_movdst_operand" "")
2628 (match_operand:DI 1 "general_movsrc_operand" ""))]
2630 "{ if (prepare_move_operands (operands, DImode)) DONE; }")
2632 ;; ??? This should be a define expand.
2634 (define_insn "movdf_k"
2635 [(set (match_operand:DF 0 "general_movdst_operand" "=r,r,r,m")
2636 (match_operand:DF 1 "general_movsrc_operand" "r,FQ,m,r"))]
2637 "(! TARGET_SH4 || reload_completed
2638 /* ??? We provide some insn so that direct_{load,store}[DFmode] get set */
2639 || (GET_CODE (operands[0]) == REG && REGNO (operands[0]) == 3)
2640 || (GET_CODE (operands[1]) == REG && REGNO (operands[1]) == 3))
2641 && (arith_reg_operand (operands[0], DFmode)
2642 || arith_reg_operand (operands[1], DFmode))"
2643 "* return output_movedouble (insn, operands, DFmode);"
2644 [(set_attr "length" "4")
2645 (set_attr "type" "move,pcload,load,store")])
2647 ;; All alternatives of movdf_i4 are split for ! TARGET_FMOVD.
2648 ;; However, the d/F/c/z alternative cannot be split directly; it is converted
2649 ;; with special code in machine_dependent_reorg into a load of the R0_REG and
2650 ;; the d/m/c/X alternative, which is split later into single-precision
2651 ;; instructions. And when not optimizing, no splits are done before fixing
2652 ;; up pcloads, so we need usable length information for that.
2653 (define_insn "movdf_i4"
2654 [(set (match_operand:DF 0 "general_movdst_operand" "=d,r,d,d,m,r,r,m,!??r,!???d")
2655 (match_operand:DF 1 "general_movsrc_operand" "d,r,F,m,d,FQ,m,r,d,r"))
2656 (use (match_operand:PSI 2 "fpscr_operand" "c,c,c,c,c,c,c,c,c,c"))
2657 (clobber (match_scratch:SI 3 "=X,X,&z,X,X,X,X,X,X,X"))]
2659 && (arith_reg_operand (operands[0], DFmode)
2660 || arith_reg_operand (operands[1], DFmode))"
2672 [(set_attr_alternative "length"
2673 [(if_then_else (eq_attr "fmovd" "yes") (const_int 2) (const_int 4))
2675 (if_then_else (eq_attr "fmovd" "yes") (const_int 4) (const_int 6))
2676 (if_then_else (eq_attr "fmovd" "yes") (const_int 2) (const_int 6))
2677 (if_then_else (eq_attr "fmovd" "yes") (const_int 2) (const_int 6))
2679 (const_int 8) (const_int 8) ;; these need only 8 bytes for @(r0,rn)
2680 (const_int 8) (const_int 8)])
2681 (set_attr "type" "fmove,move,pcload,load,store,pcload,load,store,load,load")
2682 (set (attr "fp_mode") (if_then_else (eq_attr "fmovd" "yes")
2683 (const_string "double")
2684 (const_string "none")))])
2686 ;; Moving DFmode between fp/general registers through memory
2687 ;; (the top of the stack) is faster than moving through fpul even for
2688 ;; little endian. Because the type of an instruction is important for its
2689 ;; scheduling, it is beneficial to split these operations, rather than
2690 ;; emitting them in one single chunk, even if this will expose a stack
2691 ;; use that will prevent scheduling of other stack accesses beyond this
2694 [(set (match_operand:DF 0 "register_operand" "")
2695 (match_operand:DF 1 "register_operand" ""))
2696 (use (match_operand:PSI 2 "fpscr_operand" "c"))
2697 (clobber (match_scratch:SI 3 "=X"))]
2698 "TARGET_SH4 && reload_completed
2699 && (true_regnum (operands[0]) < 16) != (true_regnum (operands[1]) < 16)"
2705 tos = gen_rtx (MEM, DFmode, gen_rtx (PRE_DEC, Pmode, stack_pointer_rtx));
2706 insn = emit_insn (gen_movdf_i4 (tos, operands[1], operands[2]));
2707 REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_INC, stack_pointer_rtx, NULL_RTX);
2708 tos = gen_rtx (MEM, DFmode, gen_rtx (POST_INC, Pmode, stack_pointer_rtx));
2709 insn = emit_insn (gen_movdf_i4 (operands[0], tos, operands[2]));
2710 REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_INC, stack_pointer_rtx, NULL_RTX);
2714 ;; local-alloc sometimes allocates scratch registers even when not required,
2715 ;; so we must be prepared to handle these.
2717 ;; Remove the use and clobber from a movdf_i4 so that we can use movdf_k.
2719 [(set (match_operand:DF 0 "general_movdst_operand" "")
2720 (match_operand:DF 1 "general_movsrc_operand" ""))
2721 (use (match_operand:PSI 2 "fpscr_operand" "c"))
2722 (clobber (match_scratch:SI 3 "X"))]
2725 && true_regnum (operands[0]) < 16
2726 && true_regnum (operands[1]) < 16"
2727 [(set (match_dup 0) (match_dup 1))]
2730 /* If this was a reg <-> mem operation with base + index reg addressing,
2731 we have to handle this in a special way. */
2732 rtx mem = operands[0];
2734 if (! memory_operand (mem, DFmode))
2739 if (GET_CODE (mem) == SUBREG && SUBREG_BYTE (mem) == 0)
2740 mem = SUBREG_REG (mem);
2741 if (GET_CODE (mem) == MEM)
2743 rtx addr = XEXP (mem, 0);
2744 if (GET_CODE (addr) == PLUS
2745 && GET_CODE (XEXP (addr, 0)) == REG
2746 && GET_CODE (XEXP (addr, 1)) == REG)
2749 rtx reg0 = gen_rtx (REG, Pmode, 0);
2750 rtx regop = operands[store_p], word0 ,word1;
2752 if (GET_CODE (regop) == SUBREG)
2753 alter_subreg (®op);
2754 if (REGNO (XEXP (addr, 0)) == REGNO (XEXP (addr, 1)))
2758 mem = copy_rtx (mem);
2759 PUT_MODE (mem, SImode);
2760 word0 = gen_rtx (SUBREG, SImode, regop, 0);
2761 alter_subreg (&word0);
2762 word1 = gen_rtx (SUBREG, SImode, regop, 4);
2763 alter_subreg (&word1);
2764 if (store_p || ! refers_to_regno_p (REGNO (word0),
2765 REGNO (word0) + 1, addr, 0))
2768 ? gen_movsi_ie (mem, word0)
2769 : gen_movsi_ie (word0, mem));
2770 emit_insn (gen_addsi3 (reg0, reg0, GEN_INT (offset)));
2771 mem = copy_rtx (mem);
2773 ? gen_movsi_ie (mem, word1)
2774 : gen_movsi_ie (word1, mem));
2775 emit_insn (gen_addsi3 (reg0, reg0, GEN_INT (-offset)));
2779 emit_insn (gen_addsi3 (reg0, reg0, GEN_INT (offset)));
2780 emit_insn (gen_movsi_ie (word1, mem));
2781 emit_insn (gen_addsi3 (reg0, reg0, GEN_INT (-offset)));
2782 mem = copy_rtx (mem);
2783 emit_insn (gen_movsi_ie (word0, mem));
2790 ;; Split away the clobber of r0 after machine_dependent_reorg has fixed pcloads.
2792 [(set (match_operand:DF 0 "register_operand" "")
2793 (match_operand:DF 1 "memory_operand" ""))
2794 (use (match_operand:PSI 2 "fpscr_operand" "c"))
2795 (clobber (reg:SI R0_REG))]
2796 "TARGET_SH4 && reload_completed"
2797 [(parallel [(set (match_dup 0) (match_dup 1))
2799 (clobber (scratch:SI))])]
2802 (define_expand "reload_indf"
2803 [(parallel [(set (match_operand:DF 0 "register_operand" "=f")
2804 (match_operand:DF 1 "immediate_operand" "FQ"))
2805 (use (reg:PSI FPSCR_REG))
2806 (clobber (match_operand:SI 2 "register_operand" "=&z"))])]
2810 (define_expand "reload_outdf"
2811 [(parallel [(set (match_operand:DF 0 "register_operand" "=r,f")
2812 (match_operand:DF 1 "register_operand" "af,r"))
2813 (clobber (match_operand:SI 2 "register_operand" "=&y,y"))])]
2817 ;; Simplify no-op moves.
2819 [(set (match_operand:SF 0 "register_operand" "")
2820 (match_operand:SF 1 "register_operand" ""))
2821 (use (match_operand:PSI 2 "fpscr_operand" ""))
2822 (clobber (match_scratch:SI 3 "X"))]
2823 "TARGET_SH3E && reload_completed
2824 && true_regnum (operands[0]) == true_regnum (operands[1])"
2825 [(set (match_dup 0) (match_dup 0))]
2828 ;; fmovd substitute post-reload splits
2830 [(set (match_operand:DF 0 "register_operand" "")
2831 (match_operand:DF 1 "register_operand" ""))
2832 (use (match_operand:PSI 2 "fpscr_operand" "c"))
2833 (clobber (match_scratch:SI 3 "X"))]
2834 "TARGET_SH4 && ! TARGET_FMOVD && reload_completed
2835 && FP_OR_XD_REGISTER_P (true_regnum (operands[0]))
2836 && FP_OR_XD_REGISTER_P (true_regnum (operands[1]))"
2840 int dst = true_regnum (operands[0]), src = true_regnum (operands[1]);
2841 emit_insn (gen_movsf_ie (gen_rtx (REG, SFmode, dst),
2842 gen_rtx (REG, SFmode, src), operands[2]));
2843 emit_insn (gen_movsf_ie (gen_rtx (REG, SFmode, dst + 1),
2844 gen_rtx (REG, SFmode, src + 1), operands[2]));
2849 [(set (match_operand:DF 0 "register_operand" "")
2850 (mem:DF (match_operand:SI 1 "register_operand" "")))
2851 (use (match_operand:PSI 2 "fpscr_operand" "c"))
2852 (clobber (match_scratch:SI 3 "X"))]
2853 "TARGET_SH4 && ! TARGET_FMOVD && reload_completed
2854 && FP_OR_XD_REGISTER_P (true_regnum (operands[0]))
2855 && find_regno_note (insn, REG_DEAD, true_regnum (operands[1]))"
2859 int regno = true_regnum (operands[0]);
2861 rtx mem2 = gen_rtx (MEM, SFmode, gen_rtx (POST_INC, Pmode, operands[1]));
2863 insn = emit_insn (gen_movsf_ie (gen_rtx (REG, SFmode,
2864 regno + !! TARGET_LITTLE_ENDIAN),
2865 mem2, operands[2]));
2866 REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_INC, operands[1], NULL_RTX);
2867 insn = emit_insn (gen_movsf_ie (gen_rtx (REG, SFmode,
2868 regno + ! TARGET_LITTLE_ENDIAN),
2869 gen_rtx (MEM, SFmode, operands[1]),
2875 [(set (match_operand:DF 0 "register_operand" "")
2876 (match_operand:DF 1 "memory_operand" ""))
2877 (use (match_operand:PSI 2 "fpscr_operand" "c"))
2878 (clobber (match_scratch:SI 3 "X"))]
2879 "TARGET_SH4 && ! TARGET_FMOVD && reload_completed
2880 && FP_OR_XD_REGISTER_P (true_regnum (operands[0]))"
2884 int regno = true_regnum (operands[0]);
2885 rtx addr, insn, adjust = NULL_RTX;
2886 rtx mem2 = copy_rtx (operands[1]);
2887 rtx reg0 = gen_rtx_REG (SFmode, regno + !! TARGET_LITTLE_ENDIAN);
2888 rtx reg1 = gen_rtx_REG (SFmode, regno + ! TARGET_LITTLE_ENDIAN);
2890 PUT_MODE (mem2, SFmode);
2891 operands[1] = copy_rtx (mem2);
2892 addr = XEXP (mem2, 0);
2893 if (GET_CODE (addr) != POST_INC)
2895 /* If we have to modify the stack pointer, the value that we have
2896 read with post-increment might be modified by an interrupt,
2897 so write it back. */
2898 if (REGNO (addr) == STACK_POINTER_REGNUM)
2899 adjust = gen_push_e (reg0);
2901 adjust = gen_addsi3 (addr, addr, GEN_INT (-4));
2902 XEXP (mem2, 0) = addr = gen_rtx_POST_INC (SImode, addr);
2904 addr = XEXP (addr, 0);
2905 insn = emit_insn (gen_movsf_ie (reg0, mem2, operands[2]));
2906 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, addr, NULL_RTX);
2907 insn = emit_insn (gen_movsf_ie (reg1, operands[1], operands[2]));
2911 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, addr, NULL_RTX);
2916 [(set (match_operand:DF 0 "memory_operand" "")
2917 (match_operand:DF 1 "register_operand" ""))
2918 (use (match_operand:PSI 2 "fpscr_operand" "c"))
2919 (clobber (match_scratch:SI 3 "X"))]
2920 "TARGET_SH4 && ! TARGET_FMOVD && reload_completed
2921 && FP_OR_XD_REGISTER_P (true_regnum (operands[1]))"
2925 int regno = true_regnum (operands[1]);
2926 rtx insn, addr, adjust = NULL_RTX;
2928 operands[0] = copy_rtx (operands[0]);
2929 PUT_MODE (operands[0], SFmode);
2930 insn = emit_insn (gen_movsf_ie (operands[0],
2931 gen_rtx (REG, SFmode,
2932 regno + ! TARGET_LITTLE_ENDIAN),
2934 operands[0] = copy_rtx (operands[0]);
2935 addr = XEXP (operands[0], 0);
2936 if (GET_CODE (addr) != PRE_DEC)
2938 adjust = gen_addsi3 (addr, addr, GEN_INT (4));
2939 emit_insn_before (adjust, insn);
2940 XEXP (operands[0], 0) = addr = gen_rtx (PRE_DEC, SImode, addr);
2942 addr = XEXP (addr, 0);
2944 REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_INC, addr, NULL_RTX);
2945 insn = emit_insn (gen_movsf_ie (operands[0],
2946 gen_rtx (REG, SFmode,
2947 regno + !! TARGET_LITTLE_ENDIAN),
2949 REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_INC, addr, NULL_RTX);
2953 ;; If the output is a register and the input is memory or a register, we have
2954 ;; to be careful and see which word needs to be loaded first.
2957 [(set (match_operand:DF 0 "general_movdst_operand" "")
2958 (match_operand:DF 1 "general_movsrc_operand" ""))]
2960 [(set (match_dup 2) (match_dup 3))
2961 (set (match_dup 4) (match_dup 5))]
2966 if ((GET_CODE (operands[0]) == MEM
2967 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2968 || (GET_CODE (operands[1]) == MEM
2969 && GET_CODE (XEXP (operands[1], 0)) == POST_INC))
2972 if (GET_CODE (operands[0]) == REG)
2973 regno = REGNO (operands[0]);
2974 else if (GET_CODE (operands[0]) == SUBREG)
2975 regno = subreg_regno (operands[0]);
2976 else if (GET_CODE (operands[0]) == MEM)
2982 || ! refers_to_regno_p (regno, regno + 1, operands[1], 0))
2984 operands[2] = operand_subword (operands[0], 0, 0, DFmode);
2985 operands[3] = operand_subword (operands[1], 0, 0, DFmode);
2986 operands[4] = operand_subword (operands[0], 1, 0, DFmode);
2987 operands[5] = operand_subword (operands[1], 1, 0, DFmode);
2991 operands[2] = operand_subword (operands[0], 1, 0, DFmode);
2992 operands[3] = operand_subword (operands[1], 1, 0, DFmode);
2993 operands[4] = operand_subword (operands[0], 0, 0, DFmode);
2994 operands[5] = operand_subword (operands[1], 0, 0, DFmode);
2997 if (operands[2] == 0 || operands[3] == 0
2998 || operands[4] == 0 || operands[5] == 0)
3002 ;; If a base address generated by LEGITIMIZE_ADDRESS for SImode is
3003 ;; used only once, let combine add in the index again.
3006 [(set (match_operand:SI 0 "register_operand" "")
3007 (match_operand:SI 1 "" ""))
3008 (clobber (match_operand 2 "register_operand" ""))]
3009 "! reload_in_progress && ! reload_completed"
3010 [(use (reg:SI R0_REG))]
3013 rtx addr, reg, const_int;
3015 if (GET_CODE (operands[1]) != MEM)
3017 addr = XEXP (operands[1], 0);
3018 if (GET_CODE (addr) != PLUS)
3020 reg = XEXP (addr, 0);
3021 const_int = XEXP (addr, 1);
3022 if (! (BASE_REGISTER_RTX_P (reg) && INDEX_REGISTER_RTX_P (operands[2])
3023 && GET_CODE (const_int) == CONST_INT))
3025 emit_move_insn (operands[2], const_int);
3026 emit_move_insn (operands[0],
3027 change_address (operands[1], VOIDmode,
3028 gen_rtx_PLUS (SImode, reg, operands[2])));
3033 [(set (match_operand:SI 1 "" "")
3034 (match_operand:SI 0 "register_operand" ""))
3035 (clobber (match_operand 2 "register_operand" ""))]
3036 "! reload_in_progress && ! reload_completed"
3037 [(use (reg:SI R0_REG))]
3040 rtx addr, reg, const_int;
3042 if (GET_CODE (operands[1]) != MEM)
3044 addr = XEXP (operands[1], 0);
3045 if (GET_CODE (addr) != PLUS)
3047 reg = XEXP (addr, 0);
3048 const_int = XEXP (addr, 1);
3049 if (! (BASE_REGISTER_RTX_P (reg) && INDEX_REGISTER_RTX_P (operands[2])
3050 && GET_CODE (const_int) == CONST_INT))
3052 emit_move_insn (operands[2], const_int);
3053 emit_move_insn (change_address (operands[1], VOIDmode,
3054 gen_rtx_PLUS (SImode, reg, operands[2])),
3059 (define_expand "movdf"
3060 [(set (match_operand:DF 0 "general_movdst_operand" "")
3061 (match_operand:DF 1 "general_movsrc_operand" ""))]
3065 if (prepare_move_operands (operands, DFmode)) DONE;
3068 emit_df_insn (gen_movdf_i4 (operands[0], operands[1], get_fpscr_rtx ()));
3074 (define_insn "movsf_i"
3075 [(set (match_operand:SF 0 "general_movdst_operand" "=r,r,r,r,m,l,r")
3076 (match_operand:SF 1 "general_movsrc_operand" "r,I,FQ,mr,r,r,l"))]
3079 /* ??? We provide some insn so that direct_{load,store}[SFmode] get set */
3080 || (GET_CODE (operands[0]) == REG && REGNO (operands[0]) == 3)
3081 || (GET_CODE (operands[1]) == REG && REGNO (operands[1]) == 3))
3082 && (arith_reg_operand (operands[0], SFmode)
3083 || arith_reg_operand (operands[1], SFmode))"
3092 [(set_attr "type" "move,move,pcload,load,store,move,move")])
3094 ;; We may not split the ry/yr/XX alternatives to movsi_ie, since
3095 ;; update_flow_info would not know where to put REG_EQUAL notes
3096 ;; when the destination changes mode.
3097 (define_insn "movsf_ie"
3098 [(set (match_operand:SF 0 "general_movdst_operand"
3099 "=f,r,f,f,fy,f,m,r,r,m,f,y,y,rf,r,y,<,y,y")
3100 (match_operand:SF 1 "general_movsrc_operand"
3101 "f,r,G,H,FQ,mf,f,FQ,mr,r,y,f,>,fr,y,r,y,>,y"))
3102 (use (match_operand:PSI 2 "fpscr_operand" "c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c"))
3103 (clobber (match_scratch:SI 3 "=X,X,X,X,&z,X,X,X,X,X,X,X,X,y,X,X,X,X,X"))]
3106 && (arith_reg_operand (operands[0], SFmode)
3107 || arith_reg_operand (operands[1], SFmode)
3108 || arith_reg_operand (operands[3], SImode)
3109 || (fpul_operand (operands[0], SFmode)
3110 && memory_operand (operands[1], SFmode)
3111 && GET_CODE (XEXP (operands[1], 0)) == POST_INC)
3112 || (fpul_operand (operands[1], SFmode)
3113 && memory_operand (operands[0], SFmode)
3114 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC))"
3134 ! move optimized away"
3135 [(set_attr "type" "fmove,move,fmove,fmove,pcload,load,store,pcload,load,store,fmove,fmove,load,*,gp_fpul,gp_fpul,store,load,nil")
3136 (set_attr "length" "*,*,*,*,4,*,*,*,*,*,2,2,2,4,2,2,2,2,0")
3137 (set (attr "fp_mode") (if_then_else (eq_attr "fmovd" "yes")
3138 (const_string "single")
3139 (const_string "none")))])
3142 [(set (match_operand:SF 0 "register_operand" "")
3143 (match_operand:SF 1 "register_operand" ""))
3144 (use (match_operand:PSI 2 "fpscr_operand" "c"))
3145 (clobber (reg:SI FPUL_REG))]
3147 [(parallel [(set (reg:SF FPUL_REG) (match_dup 1))
3149 (clobber (scratch:SI))])
3150 (parallel [(set (match_dup 0) (reg:SF FPUL_REG))
3152 (clobber (scratch:SI))])]
3155 (define_expand "movsf"
3156 [(set (match_operand:SF 0 "general_movdst_operand" "")
3157 (match_operand:SF 1 "general_movsrc_operand" ""))]
3161 if (prepare_move_operands (operands, SFmode))
3165 emit_sf_insn (gen_movsf_ie (operands[0], operands[1], get_fpscr_rtx ()));
3170 (define_insn "mov_nop"
3171 [(set (match_operand 0 "register_operand" "") (match_dup 0))]
3174 [(set_attr "length" "0")
3175 (set_attr "type" "nil")])
3177 (define_expand "reload_insf"
3178 [(parallel [(set (match_operand:SF 0 "register_operand" "=a")
3179 (match_operand:SF 1 "immediate_operand" "FQ"))
3180 (use (reg:PSI FPSCR_REG))
3181 (clobber (match_operand:SI 2 "register_operand" "=&z"))])]
3185 (define_expand "reload_insi"
3186 [(parallel [(set (match_operand:SF 0 "register_operand" "=y")
3187 (match_operand:SF 1 "immediate_operand" "FQ"))
3188 (clobber (match_operand:SI 2 "register_operand" "=&z"))])]
3192 (define_insn "*movsi_y"
3193 [(set (match_operand:SI 0 "register_operand" "=y,y")
3194 (match_operand:SI 1 "immediate_operand" "Qi,I"))
3195 (clobber (match_scratch:SI 2 "=&z,r"))]
3197 && (reload_in_progress || reload_completed)"
3199 [(set_attr "length" "4")
3200 (set_attr "type" "pcload,move")])
3203 [(set (match_operand:SI 0 "register_operand" "")
3204 (match_operand:SI 1 "immediate_operand" ""))
3205 (clobber (match_operand:SI 2 "register_operand" ""))]
3207 [(set (match_dup 2) (match_dup 1))
3208 (set (match_dup 0) (match_dup 2))]
3212 [(set (match_operand:SI 0 "register_operand" "")
3213 (match_operand:SI 1 "memory_operand" ""))
3214 (clobber (reg:SI R0_REG))]
3216 [(set (match_dup 0) (match_dup 1))]
3219 ;; ------------------------------------------------------------------------
3220 ;; Define the real conditional branch instructions.
3221 ;; ------------------------------------------------------------------------
3223 (define_insn "branch_true"
3224 [(set (pc) (if_then_else (ne (reg:SI T_REG) (const_int 0))
3225 (label_ref (match_operand 0 "" ""))
3228 "* return output_branch (1, insn, operands);"
3229 [(set_attr "type" "cbranch")])
3231 (define_insn "branch_false"
3232 [(set (pc) (if_then_else (eq (reg:SI T_REG) (const_int 0))
3233 (label_ref (match_operand 0 "" ""))
3236 "* return output_branch (0, insn, operands);"
3237 [(set_attr "type" "cbranch")])
3239 ;; Patterns to prevent reorg from re-combining a condbranch with a branch
3240 ;; which destination is too far away.
3241 ;; The const_int_operand is distinct for each branch target; it avoids
3242 ;; unwanted matches with redundant_insn.
3243 (define_insn "block_branch_redirect"
3244 [(set (pc) (unspec [(match_operand 0 "const_int_operand" "")] UNSPEC_BBR))]
3247 [(set_attr "length" "0")])
3249 ;; This one has the additional purpose to record a possible scratch register
3250 ;; for the following branch.
3251 (define_insn "indirect_jump_scratch"
3252 [(set (match_operand 0 "register_operand" "=r")
3253 (unspec [(match_operand 1 "const_int_operand" "")] UNSPEC_BBR))]
3256 [(set_attr "length" "0")])
3258 ;; Conditional branch insns
3260 (define_expand "beq"
3262 (if_then_else (ne (reg:SI T_REG) (const_int 0))
3263 (label_ref (match_operand 0 "" ""))
3266 "from_compare (operands, EQ);")
3268 (define_expand "bne"
3270 (if_then_else (eq (reg:SI T_REG) (const_int 0))
3271 (label_ref (match_operand 0 "" ""))
3274 "from_compare (operands, EQ);")
3276 (define_expand "bgt"
3278 (if_then_else (ne (reg:SI T_REG) (const_int 0))
3279 (label_ref (match_operand 0 "" ""))
3282 "from_compare (operands, GT);")
3284 (define_expand "blt"
3286 (if_then_else (eq (reg:SI T_REG) (const_int 0))
3287 (label_ref (match_operand 0 "" ""))
3292 if (GET_MODE_CLASS (GET_MODE (sh_compare_op0)) == MODE_FLOAT)
3294 rtx tmp = sh_compare_op0;
3295 sh_compare_op0 = sh_compare_op1;
3296 sh_compare_op1 = tmp;
3297 emit_insn (gen_bgt (operands[0]));
3300 from_compare (operands, GE);
3303 (define_expand "ble"
3305 (if_then_else (eq (reg:SI T_REG) (const_int 0))
3306 (label_ref (match_operand 0 "" ""))
3313 && GET_MODE_CLASS (GET_MODE (sh_compare_op0)) == MODE_FLOAT)
3315 rtx tmp = sh_compare_op0;
3316 sh_compare_op0 = sh_compare_op1;
3317 sh_compare_op1 = tmp;
3318 emit_insn (gen_bge (operands[0]));
3321 from_compare (operands, GT);
3324 (define_expand "bge"
3326 (if_then_else (ne (reg:SI T_REG) (const_int 0))
3327 (label_ref (match_operand 0 "" ""))
3334 && GET_MODE_CLASS (GET_MODE (sh_compare_op0)) == MODE_FLOAT)
3336 rtx tmp = sh_compare_op0;
3337 sh_compare_op0 = sh_compare_op1;
3338 sh_compare_op1 = tmp;
3339 emit_insn (gen_ble (operands[0]));
3342 from_compare (operands, GE);
3345 (define_expand "bgtu"
3347 (if_then_else (ne (reg:SI T_REG) (const_int 0))
3348 (label_ref (match_operand 0 "" ""))
3351 "from_compare (operands, GTU); ")
3353 (define_expand "bltu"
3355 (if_then_else (eq (reg:SI T_REG) (const_int 0))
3356 (label_ref (match_operand 0 "" ""))
3359 "from_compare (operands, GEU);")
3361 (define_expand "bgeu"
3363 (if_then_else (ne (reg:SI T_REG) (const_int 0))
3364 (label_ref (match_operand 0 "" ""))
3367 "from_compare (operands, GEU);")
3369 (define_expand "bleu"
3371 (if_then_else (eq (reg:SI T_REG) (const_int 0))
3372 (label_ref (match_operand 0 "" ""))
3375 "from_compare (operands, GTU);")
3377 ;; ------------------------------------------------------------------------
3378 ;; Jump and linkage insns
3379 ;; ------------------------------------------------------------------------
3383 (label_ref (match_operand 0 "" "")))]
3387 /* The length is 16 if the delay slot is unfilled. */
3388 if (get_attr_length(insn) > 4)
3389 return output_far_jump(insn, operands[0]);
3391 return \"bra %l0%#\";
3393 [(set_attr "type" "jump")
3394 (set_attr "needs_delay_slot" "yes")])
3396 (define_insn "calli"
3397 [(call (mem:SI (match_operand:SI 0 "arith_reg_operand" "r"))
3398 (match_operand 1 "" ""))
3399 (use (reg:PSI FPSCR_REG))
3400 (clobber (reg:SI PR_REG))]
3403 [(set_attr "type" "call")
3404 (set (attr "fp_mode")
3405 (if_then_else (eq_attr "fpu_single" "yes")
3406 (const_string "single") (const_string "double")))
3407 (set_attr "needs_delay_slot" "yes")])
3409 ;; This is a pc-rel call, using bsrf, for use with PIC.
3411 (define_insn "calli_pcrel"
3412 [(call (mem:SI (match_operand:SI 0 "arith_reg_operand" "r"))
3413 (match_operand 1 "" ""))
3414 (use (reg:PSI FPSCR_REG))
3415 (use (reg:SI PIC_REG))
3416 (use (match_operand 2 "" ""))
3417 (clobber (reg:SI PR_REG))]
3420 [(set_attr "type" "call")
3421 (set (attr "fp_mode")
3422 (if_then_else (eq_attr "fpu_single" "yes")
3423 (const_string "single") (const_string "double")))
3424 (set_attr "needs_delay_slot" "yes")])
3426 (define_insn_and_split "call_pcrel"
3427 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" ""))
3428 (match_operand 1 "" ""))
3429 (use (reg:PSI FPSCR_REG))
3430 (use (reg:SI PIC_REG))
3431 (clobber (reg:SI PR_REG))
3432 (clobber (match_scratch:SI 2 "=r"))]
3439 rtx lab = gen_call_site ();
3441 if (SYMBOL_REF_FLAG (operands[0]))
3442 emit_insn (gen_sym_label2reg (operands[2], operands[0], lab));
3444 emit_insn (gen_symPLT_label2reg (operands[2], operands[0], lab));
3445 emit_call_insn (gen_calli_pcrel (operands[2], operands[1], lab));
3448 [(set_attr "type" "call")
3449 (set (attr "fp_mode")
3450 (if_then_else (eq_attr "fpu_single" "yes")
3451 (const_string "single") (const_string "double")))
3452 (set_attr "needs_delay_slot" "yes")])
3454 (define_insn "call_valuei"
3455 [(set (match_operand 0 "" "=rf")
3456 (call (mem:SI (match_operand:SI 1 "arith_reg_operand" "r"))
3457 (match_operand 2 "" "")))
3458 (use (reg:PSI FPSCR_REG))
3459 (clobber (reg:SI PR_REG))]
3462 [(set_attr "type" "call")
3463 (set (attr "fp_mode")
3464 (if_then_else (eq_attr "fpu_single" "yes")
3465 (const_string "single") (const_string "double")))
3466 (set_attr "needs_delay_slot" "yes")])
3468 (define_insn "call_valuei_pcrel"
3469 [(set (match_operand 0 "" "=rf")
3470 (call (mem:SI (match_operand:SI 1 "arith_reg_operand" "r"))
3471 (match_operand 2 "" "")))
3472 (use (reg:PSI FPSCR_REG))
3473 (use (reg:SI PIC_REG))
3474 (use (match_operand 3 "" ""))
3475 (clobber (reg:SI PR_REG))]
3478 [(set_attr "type" "call")
3479 (set (attr "fp_mode")
3480 (if_then_else (eq_attr "fpu_single" "yes")
3481 (const_string "single") (const_string "double")))
3482 (set_attr "needs_delay_slot" "yes")])
3484 (define_insn_and_split "call_value_pcrel"
3485 [(set (match_operand 0 "" "=rf")
3486 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" ""))
3487 (match_operand 2 "" "")))
3488 (use (reg:PSI FPSCR_REG))
3489 (use (reg:SI PIC_REG))
3490 (clobber (reg:SI PR_REG))
3491 (clobber (match_scratch:SI 3 "=r"))]
3498 rtx lab = gen_call_site ();
3500 if (SYMBOL_REF_FLAG (operands[1]))
3501 emit_insn (gen_sym_label2reg (operands[3], operands[1], lab));
3503 emit_insn (gen_symPLT_label2reg (operands[3], operands[1], lab));
3504 emit_call_insn (gen_call_valuei_pcrel (operands[0], operands[3],
3508 [(set_attr "type" "call")
3509 (set (attr "fp_mode")
3510 (if_then_else (eq_attr "fpu_single" "yes")
3511 (const_string "single") (const_string "double")))
3512 (set_attr "needs_delay_slot" "yes")])
3514 (define_expand "call"
3515 [(parallel [(call (mem:SI (match_operand 0 "arith_reg_operand" ""))
3516 (match_operand 1 "" ""))
3517 (use (reg:PSI FPSCR_REG))
3518 (clobber (reg:SI PR_REG))])]
3522 if (flag_pic && TARGET_SH2
3523 && GET_CODE (operands[0]) == MEM
3524 && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF)
3526 emit_call_insn (gen_call_pcrel (XEXP (operands[0], 0), operands[1]));
3530 operands[0] = force_reg (SImode, XEXP (operands[0], 0));
3533 (define_expand "call_value"
3534 [(parallel [(set (match_operand 0 "arith_reg_operand" "")
3535 (call (mem:SI (match_operand 1 "arith_reg_operand" ""))
3536 (match_operand 2 "" "")))
3537 (use (reg:PSI FPSCR_REG))
3538 (clobber (reg:SI PR_REG))])]
3542 if (flag_pic && TARGET_SH2
3543 && GET_CODE (operands[1]) == MEM
3544 && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
3546 emit_call_insn (gen_call_value_pcrel (operands[0], XEXP (operands[1], 0),
3551 operands[1] = force_reg (SImode, XEXP (operands[1], 0));
3554 (define_insn "sibcalli"
3555 [(call (mem:SI (match_operand:SI 0 "register_operand" "k"))
3556 (match_operand 1 "" ""))
3557 (use (reg:PSI FPSCR_REG))
3561 [(set_attr "needs_delay_slot" "yes")
3562 (set (attr "fp_mode")
3563 (if_then_else (eq_attr "fpu_single" "yes")
3564 (const_string "single") (const_string "double")))
3565 (set_attr "type" "jump_ind")])
3567 (define_insn "sibcalli_pcrel"
3568 [(call (mem:SI (match_operand:SI 0 "arith_reg_operand" "k"))
3569 (match_operand 1 "" ""))
3570 (use (match_operand 2 "" ""))
3571 (use (reg:PSI FPSCR_REG))
3575 [(set_attr "needs_delay_slot" "yes")
3576 (set (attr "fp_mode")
3577 (if_then_else (eq_attr "fpu_single" "yes")
3578 (const_string "single") (const_string "double")))
3579 (set_attr "type" "jump_ind")])
3581 (define_insn_and_split "sibcall_pcrel"
3582 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" ""))
3583 (match_operand 1 "" ""))
3584 (use (reg:PSI FPSCR_REG))
3585 (clobber (match_scratch:SI 2 "=k"))
3593 rtx lab = gen_call_site ();
3596 emit_insn (gen_sym_label2reg (operands[2], operands[0], lab));
3597 call_insn = emit_call_insn (gen_sibcalli_pcrel (operands[2], operands[1],
3599 SIBLING_CALL_P (call_insn) = 1;
3602 [(set_attr "needs_delay_slot" "yes")
3603 (set (attr "fp_mode")
3604 (if_then_else (eq_attr "fpu_single" "yes")
3605 (const_string "single") (const_string "double")))
3606 (set_attr "type" "jump_ind")])
3608 (define_expand "sibcall"
3610 [(call (mem:SI (match_operand 0 "arith_reg_operand" ""))
3611 (match_operand 1 "" ""))
3612 (use (reg:PSI FPSCR_REG))
3617 if (flag_pic && TARGET_SH2
3618 && GET_CODE (operands[0]) == MEM
3619 && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
3620 /* The PLT needs the PIC register, but the epilogue would have
3621 to restore it, so we can only use PC-relative PIC calls for
3622 static functions. */
3623 && SYMBOL_REF_FLAG (XEXP (operands[0], 0)))
3625 emit_call_insn (gen_sibcall_pcrel (XEXP (operands[0], 0), operands[1]));
3629 operands[0] = force_reg (SImode, XEXP (operands[0], 0));
3632 (define_expand "sibcall_value"
3633 [(set (match_operand 0 "" "")
3634 (call (match_operand 1 "" "")
3635 (match_operand 2 "" "")))]
3639 emit_call_insn (gen_sibcall (operands[1], operands[2]));
3643 (define_expand "sibcall_epilogue"
3648 sh_expand_epilogue ();
3652 (define_insn "indirect_jump"
3654 (match_operand:SI 0 "arith_reg_operand" "r"))]
3657 [(set_attr "needs_delay_slot" "yes")
3658 (set_attr "type" "jump_ind")])
3660 ;; The use of operand 1 / 2 helps us distinguish case table jumps
3661 ;; which can be present in structured code from indirect jumps which can not
3662 ;; be present in structured code. This allows -fprofile-arcs to work.
3664 ;; For SH1 processors.
3665 (define_insn "casesi_jump_1"
3667 (match_operand:SI 0 "register_operand" "r"))
3668 (use (label_ref (match_operand 1 "" "")))]
3671 [(set_attr "needs_delay_slot" "yes")
3672 (set_attr "type" "jump_ind")])
3674 ;; For all later processors.
3675 (define_insn "casesi_jump_2"
3676 [(set (pc) (plus:SI (match_operand:SI 0 "register_operand" "r")
3677 (label_ref (match_operand 1 "" ""))))
3678 (use (label_ref (match_operand 2 "" "")))]
3680 && (! INSN_UID (operands[1]) || prev_real_insn (operands[1]) == insn)"
3682 [(set_attr "needs_delay_slot" "yes")
3683 (set_attr "type" "jump_ind")])
3685 ;; Call subroutine returning any type.
3686 ;; ??? This probably doesn't work.
3688 (define_expand "untyped_call"
3689 [(parallel [(call (match_operand 0 "" "")
3691 (match_operand 1 "" "")
3692 (match_operand 2 "" "")])]
3698 emit_call_insn (gen_call (operands[0], const0_rtx));
3700 for (i = 0; i < XVECLEN (operands[2], 0); i++)
3702 rtx set = XVECEXP (operands[2], 0, i);
3703 emit_move_insn (SET_DEST (set), SET_SRC (set));
3706 /* The optimizer does not know that the call sets the function value
3707 registers we stored in the result block. We avoid problems by
3708 claiming that all hard registers are used and clobbered at this
3710 emit_insn (gen_blockage ());
3715 ;; ------------------------------------------------------------------------
3717 ;; ------------------------------------------------------------------------
3720 [(set (reg:SI T_REG)
3721 (eq:SI (match_operand:SI 0 "arith_reg_operand" "+r") (const_int 1)))
3722 (set (match_dup 0) (plus:SI (match_dup 0) (const_int -1)))]
3725 [(set_attr "type" "arith")])
3732 ;; Load address of a label. This is only generated by the casesi expand,
3733 ;; and by machine_dependent_reorg (fixing up fp moves).
3734 ;; This must use unspec, because this only works for labels that are
3738 [(set (reg:SI R0_REG)
3739 (unspec [(label_ref (match_operand 0 "" ""))] UNSPEC_MOVA))]
3742 [(set_attr "in_delay_slot" "no")
3743 (set_attr "type" "arith")])
3745 ;; machine_dependent_reorg() will make this a `mova'.
3746 (define_insn "mova_const"
3747 [(set (reg:SI R0_REG)
3748 (unspec [(match_operand 0 "immediate_operand" "i")] UNSPEC_MOVA))]
3751 [(set_attr "in_delay_slot" "no")
3752 (set_attr "type" "arith")])
3754 (define_expand "GOTaddr2picreg"
3755 [(set (reg:SI R0_REG)
3756 (unspec [(const:SI (unspec:SI [(match_dup 1)] UNSPEC_PIC))]
3758 (set (match_dup 0) (const:SI (unspec:SI [(match_dup 1)] UNSPEC_PIC)))
3759 (set (match_dup 0) (plus:SI (match_dup 0) (reg:SI R0_REG)))]
3762 operands[0] = pic_offset_table_rtx;
3763 operands[1] = gen_rtx_SYMBOL_REF (VOIDmode, GOT_SYMBOL_NAME);
3767 (define_expand "builtin_setjmp_receiver"
3768 [(match_operand 0 "" "")]
3772 emit_insn (gen_GOTaddr2picreg ());
3776 (define_expand "call_site"
3777 [(unspec [(match_dup 0)] UNSPEC_CALLER)]
3781 static HOST_WIDE_INT i = 0;
3782 operands[0] = GEN_INT (i);
3786 (define_expand "sym_label2reg"
3787 [(set (match_operand:SI 0 "" "")
3790 (unspec:SI [(match_operand:SI 1 "" "")] UNSPEC_PIC))
3793 (match_operand:SI 2 "" "")
3797 (define_expand "symGOT_load"
3798 [(set (match_dup 2) (match_operand 1 "" ""))
3799 (set (match_dup 3) (plus (match_dup 2) (reg PIC_REG)))
3800 (set (match_operand 0 "" "") (mem (match_dup 3)))]
3806 operands[2] = no_new_pseudos ? operands[0] : gen_reg_rtx (Pmode);
3807 operands[3] = no_new_pseudos ? operands[0] : gen_reg_rtx (Pmode);
3809 emit_move_insn (operands[2], operands[1]);
3811 emit_move_insn (operands[3], gen_rtx_PLUS (Pmode,
3813 gen_rtx_REG (Pmode, PIC_REG)));
3815 insn = emit_move_insn (operands[0], gen_rtx_MEM (Pmode, operands[3]));
3817 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_EQUAL, XVECEXP (XEXP (operands[1],
3824 (define_expand "sym2GOT"
3825 [(const (unspec [(match_operand 0 "" "")] UNSPEC_GOT))]
3829 (define_expand "symGOT2reg"
3830 [(match_operand 0 "" "") (match_operand 1 "" "")]
3836 gotsym = gen_sym2GOT (operands[1]);
3837 PUT_MODE (gotsym, Pmode);
3838 insn = emit_insn (gen_symGOT_load (operands[0], gotsym));
3840 RTX_UNCHANGING_P (SET_SRC (PATTERN (insn))) = 1;
3845 (define_expand "sym2GOTOFF"
3846 [(const (unspec [(match_operand 0 "" "")] UNSPEC_GOTOFF))]
3850 (define_expand "symGOTOFF2reg"
3851 [(match_operand 0 "" "") (match_operand 1 "" "")]
3855 rtx gotoffsym, insn;
3856 rtx t = no_new_pseudos ? operands[0] : gen_reg_rtx (GET_MODE (operands[0]));
3858 gotoffsym = gen_sym2GOTOFF (operands[1]);
3859 PUT_MODE (gotoffsym, Pmode);
3860 emit_move_insn (t, gotoffsym);
3861 insn = emit_move_insn (operands[0],
3862 gen_rtx_PLUS (Pmode, t,
3863 gen_rtx_REG (Pmode, PIC_REG)));
3865 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_EQUAL, operands[1],
3871 (define_expand "symPLT_label2reg"
3872 [(set (match_operand:SI 0 "" "")
3875 (unspec:SI [(match_operand:SI 1 "" "")] UNSPEC_PLT))
3879 (match_operand:SI 2 "" "")
3881 (const:SI (unspec:SI [(pc)] UNSPEC_PIC)))))))
3882 ;; Even though the PIC register is not really used by the call
3883 ;; sequence in which this is expanded, the PLT code assumes the PIC
3884 ;; register is set, so we must not skip its initialization. Since
3885 ;; we only use this expand as part of calling sequences, and never
3886 ;; to take the address of a function, this is the best point to
3887 ;; insert the (use). Using the PLT to take the address of a
3888 ;; function would be wrong, not only because the PLT entry could
3889 ;; then be called from a function that doesn't initialize the PIC
3890 ;; register to the proper GOT, but also because pointers to the
3891 ;; same function might not compare equal, should they be set by
3892 ;; different shared libraries.
3893 (use (reg:SI PIC_REG))]
3897 ;; case instruction for switch statements.
3899 ;; Operand 0 is index
3900 ;; operand 1 is the minimum bound
3901 ;; operand 2 is the maximum bound - minimum bound + 1
3902 ;; operand 3 is CODE_LABEL for the table;
3903 ;; operand 4 is the CODE_LABEL to go to if index out of range.
3905 (define_expand "casesi"
3906 [(match_operand:SI 0 "arith_reg_operand" "")
3907 (match_operand:SI 1 "arith_reg_operand" "")
3908 (match_operand:SI 2 "arith_reg_operand" "")
3909 (match_operand 3 "" "") (match_operand 4 "" "")]
3913 rtx reg = gen_reg_rtx (SImode);
3914 rtx reg2 = gen_reg_rtx (SImode);
3915 operands[1] = copy_to_mode_reg (SImode, operands[1]);
3916 operands[2] = copy_to_mode_reg (SImode, operands[2]);
3917 /* If optimizing, casesi_worker depends on the mode of the instruction
3918 before label it 'uses' - operands[3]. */
3919 emit_insn (gen_casesi_0 (operands[0], operands[1], operands[2], operands[4],
3921 emit_insn (gen_casesi_worker_0 (reg2, reg, operands[3]));
3923 emit_jump_insn (gen_casesi_jump_2 (reg2, gen_label_rtx (), operands[3]));
3925 emit_jump_insn (gen_casesi_jump_1 (reg2, operands[3]));
3926 /* For SH2 and newer, the ADDR_DIFF_VEC is not actually relative to
3927 operands[3], but to lab. We will fix this up in
3928 machine_dependent_reorg. */
3933 (define_expand "casesi_0"
3934 [(set (match_operand:SI 4 "" "") (match_operand:SI 0 "arith_reg_operand" ""))
3935 (set (match_dup 4) (minus:SI (match_dup 4)
3936 (match_operand:SI 1 "arith_operand" "")))
3938 (gtu:SI (match_dup 4)
3939 (match_operand:SI 2 "arith_reg_operand" "")))
3941 (if_then_else (ne (reg:SI T_REG)
3943 (label_ref (match_operand 3 "" ""))
3948 ;; ??? reload might clobber r0 if we use it explicitly in the RTL before
3949 ;; reload; using a R0_REGS pseudo reg is likely to give poor code.
3950 ;; So we keep the use of r0 hidden in a R0_REGS clobber until after reload.
3952 (define_insn "casesi_worker_0"
3953 [(set (match_operand:SI 0 "register_operand" "=r,r")
3954 (unspec:SI [(match_operand 1 "register_operand" "0,r")
3955 (label_ref (match_operand 2 "" ""))] UNSPEC_CASESI))
3956 (clobber (match_scratch:SI 3 "=X,1"))
3957 (clobber (match_scratch:SI 4 "=&z,z"))]
3962 [(set (match_operand:SI 0 "register_operand" "")
3963 (unspec [(match_operand 1 "register_operand" "")
3964 (label_ref (match_operand 2 "" ""))] UNSPEC_CASESI))
3965 (clobber (match_scratch:SI 3 ""))
3966 (clobber (match_scratch:SI 4 ""))]
3967 "! TARGET_SH2 && reload_completed"
3968 [(set (reg:SI R0_REG) (unspec [(label_ref (match_dup 2))] UNSPEC_MOVA))
3969 (parallel [(set (match_dup 0)
3970 (unspec [(reg:SI R0_REG) (match_dup 1)
3971 (label_ref (match_dup 2))] UNSPEC_CASESI))
3972 (clobber (match_dup 3))])
3973 (set (match_dup 0) (plus:SI (match_dup 0) (reg:SI R0_REG)))]
3974 "LABEL_NUSES (operands[2])++;")
3977 [(set (match_operand:SI 0 "register_operand" "")
3978 (unspec:SI [(match_operand 1 "register_operand" "")
3979 (label_ref (match_operand 2 "" ""))] UNSPEC_CASESI))
3980 (clobber (match_scratch:SI 3 ""))
3981 (clobber (match_scratch:SI 4 ""))]
3982 "TARGET_SH2 && reload_completed"
3983 [(set (reg:SI R0_REG) (unspec [(label_ref (match_dup 2))] UNSPEC_MOVA))
3984 (parallel [(set (match_dup 0)
3985 (unspec:SI [(reg:SI R0_REG) (match_dup 1)
3986 (label_ref (match_dup 2))] UNSPEC_CASESI))
3987 (clobber (match_dup 3))])]
3988 "LABEL_NUSES (operands[2])++;")
3990 (define_insn "*casesi_worker"
3991 [(set (match_operand:SI 0 "register_operand" "=r,r")
3992 (unspec [(reg:SI R0_REG) (match_operand 1 "register_operand" "0,r")
3993 (label_ref (match_operand 2 "" ""))] UNSPEC_CASESI))
3994 (clobber (match_scratch:SI 3 "=X,1"))]
3998 rtx diff_vec = PATTERN (next_real_insn (operands[2]));
4000 if (GET_CODE (diff_vec) != ADDR_DIFF_VEC)
4003 switch (GET_MODE (diff_vec))
4006 return \"shll2 %1\;mov.l @(r0,%1),%0\";
4008 return \"add %1,%1\;mov.w @(r0,%1),%0\";
4010 if (ADDR_DIFF_VEC_FLAGS (diff_vec).offset_unsigned)
4011 return \"mov.b @(r0,%1),%0\;extu.b %0,%0\";
4012 return \"mov.b @(r0,%1),%0\";
4017 [(set_attr "length" "4")])
4019 (define_expand "return"
4021 "reload_completed && ! sh_need_epilogue ()"
4024 (define_insn "*return_i"
4028 [(set_attr "type" "return")
4029 (set_attr "needs_delay_slot" "yes")])
4031 (define_expand "prologue"
4034 "sh_expand_prologue (); DONE;")
4036 (define_expand "epilogue"
4039 "sh_expand_epilogue ();")
4041 (define_insn "blockage"
4042 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
4045 [(set_attr "length" "0")])
4047 ;; ------------------------------------------------------------------------
4049 ;; ------------------------------------------------------------------------
4052 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
4053 (eq:SI (reg:SI T_REG) (const_int 1)))]
4056 [(set_attr "type" "arith")])
4058 (define_expand "seq"
4059 [(set (match_operand:SI 0 "arith_reg_operand" "")
4062 "operands[1] = prepare_scc_operands (EQ);")
4064 (define_expand "slt"
4065 [(set (match_operand:SI 0 "arith_reg_operand" "")
4068 "operands[1] = prepare_scc_operands (LT);")
4070 (define_expand "sle"
4071 [(match_operand:SI 0 "arith_reg_operand" "")]
4075 rtx tmp = sh_compare_op0;
4076 sh_compare_op0 = sh_compare_op1;
4077 sh_compare_op1 = tmp;
4078 emit_insn (gen_sge (operands[0]));
4082 (define_expand "sgt"
4083 [(set (match_operand:SI 0 "arith_reg_operand" "")
4086 "operands[1] = prepare_scc_operands (GT);")
4088 (define_expand "sge"
4089 [(set (match_operand:SI 0 "arith_reg_operand" "")
4094 if (GET_MODE_CLASS (GET_MODE (sh_compare_op0)) == MODE_FLOAT)
4098 rtx lab = gen_label_rtx ();
4099 prepare_scc_operands (EQ);
4100 emit_jump_insn (gen_branch_true (lab));
4101 prepare_scc_operands (GT);
4103 emit_insn (gen_movt (operands[0]));
4106 emit_insn (gen_movnegt (operands[0], prepare_scc_operands (LT)));
4109 operands[1] = prepare_scc_operands (GE);
4112 (define_expand "sgtu"
4113 [(set (match_operand:SI 0 "arith_reg_operand" "")
4116 "operands[1] = prepare_scc_operands (GTU);")
4118 (define_expand "sltu"
4119 [(set (match_operand:SI 0 "arith_reg_operand" "")
4122 "operands[1] = prepare_scc_operands (LTU);")
4124 (define_expand "sleu"
4125 [(set (match_operand:SI 0 "arith_reg_operand" "")
4128 "operands[1] = prepare_scc_operands (LEU);")
4130 (define_expand "sgeu"
4131 [(set (match_operand:SI 0 "arith_reg_operand" "")
4134 "operands[1] = prepare_scc_operands (GEU);")
4136 ;; sne moves the complement of the T reg to DEST like this:
4140 ;; This is better than xoring compare result with 1 because it does
4141 ;; not require r0 and further, the -1 may be CSE-ed or lifted out of a
4144 (define_expand "sne"
4145 [(set (match_dup 2) (const_int -1))
4146 (parallel [(set (match_operand:SI 0 "arith_reg_operand" "")
4147 (neg:SI (plus:SI (match_dup 1)
4150 (ne:SI (ior:SI (match_dup 1) (match_dup 2))
4155 operands[1] = prepare_scc_operands (EQ);
4156 operands[2] = gen_reg_rtx (SImode);
4159 ;; Use the same trick for FP sle / sge
4160 (define_expand "movnegt"
4161 [(set (match_dup 2) (const_int -1))
4162 (parallel [(set (match_operand 0 "" "")
4163 (neg:SI (plus:SI (match_dup 1)
4166 (ne:SI (ior:SI (match_operand 1 "" "") (match_dup 2))
4169 "operands[2] = gen_reg_rtx (SImode);")
4171 ;; Recognize mov #-1/negc/neg sequence, and change it to movt/add #-1.
4172 ;; This prevents a regression that occurred when we switched from xor to
4176 [(set (match_operand:SI 0 "arith_reg_operand" "")
4177 (plus:SI (reg:SI T_REG)
4180 [(set (match_dup 0) (eq:SI (reg:SI T_REG) (const_int 1)))
4181 (set (match_dup 0) (plus:SI (match_dup 0) (const_int -1)))]
4184 ;; -------------------------------------------------------------------------
4185 ;; Instructions to cope with inline literal tables
4186 ;; -------------------------------------------------------------------------
4188 ; 2 byte integer in line
4190 (define_insn "consttable_2"
4191 [(unspec_volatile [(match_operand:SI 0 "general_operand" "=g")
4192 (match_operand 1 "" "")]
4197 if (operands[1] != const0_rtx)
4198 assemble_integer (operands[0], 2, BITS_PER_UNIT * 2, 1);
4201 [(set_attr "length" "2")
4202 (set_attr "in_delay_slot" "no")])
4204 ; 4 byte integer in line
4206 (define_insn "consttable_4"
4207 [(unspec_volatile [(match_operand:SI 0 "general_operand" "=g")
4208 (match_operand 1 "" "")]
4213 if (operands[1] != const0_rtx)
4214 assemble_integer (operands[0], 4, BITS_PER_UNIT * 4, 1);
4217 [(set_attr "length" "4")
4218 (set_attr "in_delay_slot" "no")])
4220 ; 8 byte integer in line
4222 (define_insn "consttable_8"
4223 [(unspec_volatile [(match_operand:SI 0 "general_operand" "=g")
4224 (match_operand 1 "" "")]
4229 if (operands[1] != const0_rtx)
4230 assemble_integer (operands[0], 8, BITS_PER_UNIT * 8, 1);
4233 [(set_attr "length" "8")
4234 (set_attr "in_delay_slot" "no")])
4236 ; 4 byte floating point
4238 (define_insn "consttable_sf"
4239 [(unspec_volatile [(match_operand:SF 0 "general_operand" "=g")
4240 (match_operand 1 "" "")]
4245 if (operands[1] != const0_rtx)
4247 union real_extract u;
4248 memcpy (&u, &CONST_DOUBLE_LOW (operands[0]), sizeof u);
4249 assemble_real (u.d, SFmode, GET_MODE_ALIGNMENT (SFmode));
4253 [(set_attr "length" "4")
4254 (set_attr "in_delay_slot" "no")])
4256 ; 8 byte floating point
4258 (define_insn "consttable_df"
4259 [(unspec_volatile [(match_operand:DF 0 "general_operand" "=g")
4260 (match_operand 1 "" "")]
4265 if (operands[1] != const0_rtx)
4267 union real_extract u;
4268 memcpy (&u, &CONST_DOUBLE_LOW (operands[0]), sizeof u);
4269 assemble_real (u.d, DFmode, GET_MODE_ALIGNMENT (DFmode));
4273 [(set_attr "length" "8")
4274 (set_attr "in_delay_slot" "no")])
4276 ;; Alignment is needed for some constant tables; it may also be added for
4277 ;; Instructions at the start of loops, or after unconditional branches.
4278 ;; ??? We would get more accurate lengths if we did instruction
4279 ;; alignment based on the value of INSN_CURRENT_ADDRESS; the approach used
4280 ;; here is too conservative.
4282 ; align to a two byte boundary
4284 (define_expand "align_2"
4285 [(unspec_volatile [(const_int 1)] UNSPECV_ALIGN)]
4289 ; align to a four byte boundary
4290 ;; align_4 and align_log are instructions for the starts of loops, or
4291 ;; after unconditional branches, which may take up extra room.
4293 (define_expand "align_4"
4294 [(unspec_volatile [(const_int 2)] UNSPECV_ALIGN)]
4298 ; align to a cache line boundary
4300 (define_insn "align_log"
4301 [(unspec_volatile [(match_operand 0 "const_int_operand" "")] UNSPECV_ALIGN)]
4304 [(set_attr "length" "0")
4305 (set_attr "in_delay_slot" "no")])
4307 ; emitted at the end of the literal table, used to emit the
4308 ; 32bit branch labels if needed.
4310 (define_insn "consttable_end"
4311 [(unspec_volatile [(const_int 0)] UNSPECV_CONST_END)]
4313 "* return output_jump_label_table ();"
4314 [(set_attr "in_delay_slot" "no")])
4316 ; emitted at the end of the window in the literal table.
4318 (define_insn "consttable_window_end"
4319 [(unspec_volatile [(match_operand 0 "" "")] UNSPECV_WINDOW_END)]
4322 [(set_attr "length" "0")
4323 (set_attr "in_delay_slot" "no")])
4325 ;; -------------------------------------------------------------------------
4327 ;; -------------------------------------------------------------------------
4329 ;; String/block move insn.
4331 (define_expand "movstrsi"
4332 [(parallel [(set (mem:BLK (match_operand:BLK 0 "" ""))
4333 (mem:BLK (match_operand:BLK 1 "" "")))
4334 (use (match_operand:SI 2 "nonmemory_operand" ""))
4335 (use (match_operand:SI 3 "immediate_operand" ""))
4336 (clobber (reg:SI PR_REG))
4337 (clobber (reg:SI R4_REG))
4338 (clobber (reg:SI R5_REG))
4339 (clobber (reg:SI R0_REG))])]
4343 if(expand_block_move (operands))
4348 (define_insn "block_move_real"
4349 [(parallel [(set (mem:BLK (reg:SI R4_REG))
4350 (mem:BLK (reg:SI R5_REG)))
4351 (use (match_operand:SI 0 "arith_reg_operand" "r"))
4352 (clobber (reg:SI PR_REG))
4353 (clobber (reg:SI R0_REG))])]
4356 [(set_attr "type" "sfunc")
4357 (set_attr "needs_delay_slot" "yes")])
4359 (define_insn "block_lump_real"
4360 [(parallel [(set (mem:BLK (reg:SI R4_REG))
4361 (mem:BLK (reg:SI R5_REG)))
4362 (use (match_operand:SI 0 "arith_reg_operand" "r"))
4363 (use (reg:SI R6_REG))
4364 (clobber (reg:SI PR_REG))
4365 (clobber (reg:SI T_REG))
4366 (clobber (reg:SI R4_REG))
4367 (clobber (reg:SI R5_REG))
4368 (clobber (reg:SI R6_REG))
4369 (clobber (reg:SI R0_REG))])]
4372 [(set_attr "type" "sfunc")
4373 (set_attr "needs_delay_slot" "yes")])
4375 (define_insn "block_move_real_i4"
4376 [(parallel [(set (mem:BLK (reg:SI R4_REG))
4377 (mem:BLK (reg:SI R5_REG)))
4378 (use (match_operand:SI 0 "arith_reg_operand" "r"))
4379 (clobber (reg:SI PR_REG))
4380 (clobber (reg:SI R0_REG))
4381 (clobber (reg:SI R1_REG))
4382 (clobber (reg:SI R2_REG))])]
4385 [(set_attr "type" "sfunc")
4386 (set_attr "needs_delay_slot" "yes")])
4388 (define_insn "block_lump_real_i4"
4389 [(parallel [(set (mem:BLK (reg:SI R4_REG))
4390 (mem:BLK (reg:SI R5_REG)))
4391 (use (match_operand:SI 0 "arith_reg_operand" "r"))
4392 (use (reg:SI R6_REG))
4393 (clobber (reg:SI PR_REG))
4394 (clobber (reg:SI T_REG))
4395 (clobber (reg:SI R4_REG))
4396 (clobber (reg:SI R5_REG))
4397 (clobber (reg:SI R6_REG))
4398 (clobber (reg:SI R0_REG))
4399 (clobber (reg:SI R1_REG))
4400 (clobber (reg:SI R2_REG))
4401 (clobber (reg:SI R3_REG))])]
4404 [(set_attr "type" "sfunc")
4405 (set_attr "needs_delay_slot" "yes")])
4407 ;; -------------------------------------------------------------------------
4408 ;; Floating point instructions.
4409 ;; -------------------------------------------------------------------------
4411 ;; ??? All patterns should have a type attribute.
4413 (define_expand "fpu_switch0"
4414 [(set (match_operand:SI 0 "" "") (match_dup 2))
4415 (set (match_dup 1) (mem:PSI (match_dup 0)))]
4419 operands[1] = get_fpscr_rtx ();
4420 operands[2] = gen_rtx_SYMBOL_REF (SImode, \"__fpscr_values\");
4422 operands[2] = legitimize_pic_address (operands[2], SImode,
4423 no_new_pseudos ? operands[0] : 0);
4426 (define_expand "fpu_switch1"
4427 [(set (match_operand:SI 0 "" "") (match_dup 2))
4428 (set (match_dup 3) (plus:SI (match_dup 0) (const_int 4)))
4429 (set (match_dup 1) (mem:PSI (match_dup 3)))]
4433 operands[1] = get_fpscr_rtx ();
4434 operands[2] = gen_rtx_SYMBOL_REF (SImode, \"__fpscr_values\");
4436 operands[2] = legitimize_pic_address (operands[2], SImode,
4437 no_new_pseudos ? operands[0] : 0);
4438 operands[3] = no_new_pseudos ? operands[0] : gen_reg_rtx (SImode);
4441 (define_expand "movpsi"
4442 [(set (match_operand:PSI 0 "register_operand" "")
4443 (match_operand:PSI 1 "general_movsrc_operand" ""))]
4447 ;; The c / m alternative is a fake to guide reload to load directly into
4448 ;; fpscr, since reload doesn't know how to use post-increment.
4449 ;; GO_IF_LEGITIMATE_ADDRESS guards about bogus addresses before reload,
4450 ;; SECONDARY_INPUT_RELOAD_CLASS does this during reload, and the insn's
4451 ;; predicate after reload.
4452 ;; The gp_fpul type for r/!c might look a bit odd, but it actually schedules
4453 ;; like a gpr <-> fpul move.
4454 (define_insn "fpu_switch"
4455 [(set (match_operand:PSI 0 "register_operand" "=c,c,r,c,c,r,m,r")
4456 (match_operand:PSI 1 "general_movsrc_operand" "c,>,m,m,r,r,r,!c"))]
4458 && (! reload_completed
4459 || true_regnum (operands[0]) != FPSCR_REG
4460 || GET_CODE (operands[1]) != MEM
4461 || GET_CODE (XEXP (operands[1], 0)) != PLUS)"
4463 ! precision stays the same
4471 [(set_attr "length" "0,2,2,4,2,2,2,2")
4472 (set_attr "type" "dfp_conv,dfp_conv,load,dfp_conv,dfp_conv,move,store,gp_fpul")])
4475 [(set (reg:PSI FPSCR_REG)
4476 (mem:PSI (match_operand:SI 0 "register_operand" "r")))]
4477 "TARGET_SH4 && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
4478 [(set (match_dup 0) (match_dup 0))]
4481 rtx insn = emit_insn (gen_fpu_switch (get_fpscr_rtx (),
4482 gen_rtx (MEM, PSImode,
4483 gen_rtx (POST_INC, Pmode,
4485 REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_INC, operands[0], NULL_RTX);
4489 [(set (reg:PSI FPSCR_REG)
4490 (mem:PSI (match_operand:SI 0 "register_operand" "r")))]
4492 [(set (match_dup 0) (plus:SI (match_dup 0) (const_int -4)))]
4495 rtx insn = emit_insn (gen_fpu_switch (get_fpscr_rtx (),
4496 gen_rtx (MEM, PSImode,
4497 gen_rtx (POST_INC, Pmode,
4499 REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_INC, operands[0], NULL_RTX);
4502 ;; ??? This uses the fp unit, but has no type indicating that.
4503 ;; If we did that, this would either give a bogus latency or introduce
4504 ;; a bogus FIFO constraint.
4505 ;; Since this insn is currently only used for prologues/epilogues,
4506 ;; it is probably best to claim no function unit, which matches the
4508 (define_insn "toggle_sz"
4509 [(set (reg:PSI FPSCR_REG)
4510 (xor:PSI (reg:PSI FPSCR_REG) (const_int 1048576)))]
4514 (define_expand "addsf3"
4515 [(match_operand:SF 0 "arith_reg_operand" "")
4516 (match_operand:SF 1 "arith_reg_operand" "")
4517 (match_operand:SF 2 "arith_reg_operand" "")]
4519 "{ expand_sf_binop (&gen_addsf3_i, operands); DONE; }")
4521 (define_insn "addsf3_i"
4522 [(set (match_operand:SF 0 "arith_reg_operand" "=f")
4523 (plus:SF (match_operand:SF 1 "arith_reg_operand" "%0")
4524 (match_operand:SF 2 "arith_reg_operand" "f")))
4525 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
4528 [(set_attr "type" "fp")
4529 (set_attr "fp_mode" "single")])
4531 (define_expand "subsf3"
4532 [(match_operand:SF 0 "fp_arith_reg_operand" "")
4533 (match_operand:SF 1 "fp_arith_reg_operand" "")
4534 (match_operand:SF 2 "fp_arith_reg_operand" "")]
4536 "{ expand_sf_binop (&gen_subsf3_i, operands); DONE; }")
4538 (define_insn "subsf3_i"
4539 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
4540 (minus:SF (match_operand:SF 1 "fp_arith_reg_operand" "0")
4541 (match_operand:SF 2 "fp_arith_reg_operand" "f")))
4542 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
4545 [(set_attr "type" "fp")
4546 (set_attr "fp_mode" "single")])
4548 ;; Unfortunately, the combiner is unable to cope with the USE of the FPSCR
4549 ;; register in feeding fp instructions. Thus, we cannot generate fmac for
4550 ;; mixed-precision SH4 targets. To allow it to be still generated for the
4551 ;; SH3E, we use a separate insn for SH3E mulsf3.
4553 (define_expand "mulsf3"
4554 [(match_operand:SF 0 "fp_arith_reg_operand" "")
4555 (match_operand:SF 1 "fp_arith_reg_operand" "")
4556 (match_operand:SF 2 "fp_arith_reg_operand" "")]
4561 expand_sf_binop (&gen_mulsf3_i4, operands);
4563 emit_insn (gen_mulsf3_ie (operands[0], operands[1], operands[2]));
4567 (define_insn "mulsf3_i4"
4568 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
4569 (mult:SF (match_operand:SF 1 "fp_arith_reg_operand" "%0")
4570 (match_operand:SF 2 "fp_arith_reg_operand" "f")))
4571 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
4574 [(set_attr "type" "fp")
4575 (set_attr "fp_mode" "single")])
4577 (define_insn "mulsf3_ie"
4578 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
4579 (mult:SF (match_operand:SF 1 "fp_arith_reg_operand" "%0")
4580 (match_operand:SF 2 "fp_arith_reg_operand" "f")))]
4581 "TARGET_SH3E && ! TARGET_SH4"
4583 [(set_attr "type" "fp")])
4585 (define_insn "*macsf3"
4586 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
4587 (plus:SF (mult:SF (match_operand:SF 1 "fp_arith_reg_operand" "%w")
4588 (match_operand:SF 2 "fp_arith_reg_operand" "f"))
4589 (match_operand:SF 3 "arith_reg_operand" "0")))
4590 (use (match_operand:PSI 4 "fpscr_operand" "c"))]
4591 "TARGET_SH3E && ! TARGET_SH4"
4593 [(set_attr "type" "fp")
4594 (set_attr "fp_mode" "single")])
4596 (define_expand "divsf3"
4597 [(match_operand:SF 0 "arith_reg_operand" "")
4598 (match_operand:SF 1 "arith_reg_operand" "")
4599 (match_operand:SF 2 "arith_reg_operand" "")]
4601 "{ expand_sf_binop (&gen_divsf3_i, operands); DONE; }")
4603 (define_insn "divsf3_i"
4604 [(set (match_operand:SF 0 "arith_reg_operand" "=f")
4605 (div:SF (match_operand:SF 1 "arith_reg_operand" "0")
4606 (match_operand:SF 2 "arith_reg_operand" "f")))
4607 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
4610 [(set_attr "type" "fdiv")
4611 (set_attr "fp_mode" "single")])
4613 (define_expand "floatsisf2"
4614 [(set (match_operand:SF 0 "fp_arith_reg_operand" "")
4615 (float:SF (match_operand:SI 1 "fpul_operand" "")))]
4621 emit_sf_insn (gen_floatsisf2_i4 (operands[0], operands[1], get_fpscr_rtx ()));
4626 (define_insn "floatsisf2_i4"
4627 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
4628 (float:SF (match_operand:SI 1 "fpul_operand" "y")))
4629 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4632 [(set_attr "type" "fp")
4633 (set_attr "fp_mode" "single")])
4635 (define_insn "*floatsisf2_ie"
4636 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
4637 (float:SF (match_operand:SI 1 "fpul_operand" "y")))]
4638 "TARGET_SH3E && ! TARGET_SH4"
4640 [(set_attr "type" "fp")])
4642 (define_expand "fix_truncsfsi2"
4643 [(set (match_operand:SI 0 "fpul_operand" "=y")
4644 (fix:SI (match_operand:SF 1 "fp_arith_reg_operand" "f")))]
4650 emit_sf_insn (gen_fix_truncsfsi2_i4 (operands[0], operands[1], get_fpscr_rtx ()));
4655 (define_insn "fix_truncsfsi2_i4"
4656 [(set (match_operand:SI 0 "fpul_operand" "=y")
4657 (fix:SI (match_operand:SF 1 "fp_arith_reg_operand" "f")))
4658 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4661 [(set_attr "type" "fp")
4662 (set_attr "fp_mode" "single")])
4664 ;; ??? This pattern is used nowhere. fix_truncsfsi2 always expands to
4665 ;; fix_truncsfsi2_i4.
4666 ;; (define_insn "fix_truncsfsi2_i4_2"
4667 ;; [(set (match_operand:SI 0 "arith_reg_operand" "=r")
4668 ;; (fix:SI (match_operand:SF 1 "arith_reg_operand" "f")))
4669 ;; (use (reg:PSI FPSCR_REG))
4670 ;; (clobber (reg:SI FPUL_REG))]
4673 ;; [(set_attr "length" "4")
4674 ;; (set_attr "fp_mode" "single")])
4677 ;; [(set (match_operand:SI 0 "arith_reg_operand" "=r")
4678 ;; (fix:SI (match_operand:SF 1 "arith_reg_operand" "f")))
4679 ;; (use (match_operand:PSI 2 "fpscr_operand" "c"))
4680 ;; (clobber (reg:SI FPUL_REG))]
4682 ;; [(parallel [(set (reg:SI FPUL_REG) (fix:SI (match_dup 1)))
4683 ;; (use (match_dup 2))])
4684 ;; (set (match_dup 0) (reg:SI FPUL_REG))])
4686 (define_insn "*fixsfsi"
4687 [(set (match_operand:SI 0 "fpul_operand" "=y")
4688 (fix:SI (match_operand:SF 1 "fp_arith_reg_operand" "f")))]
4689 "TARGET_SH3E && ! TARGET_SH4"
4691 [(set_attr "type" "fp")])
4693 (define_insn "cmpgtsf_t"
4694 [(set (reg:SI T_REG)
4695 (gt:SI (match_operand:SF 0 "fp_arith_reg_operand" "f")
4696 (match_operand:SF 1 "fp_arith_reg_operand" "f")))]
4697 "TARGET_SH3E && ! TARGET_SH4"
4699 [(set_attr "type" "fp")
4700 (set_attr "fp_mode" "single")])
4702 (define_insn "cmpeqsf_t"
4703 [(set (reg:SI T_REG)
4704 (eq:SI (match_operand:SF 0 "fp_arith_reg_operand" "f")
4705 (match_operand:SF 1 "fp_arith_reg_operand" "f")))]
4706 "TARGET_SH3E && ! TARGET_SH4"
4708 [(set_attr "type" "fp")
4709 (set_attr "fp_mode" "single")])
4711 (define_insn "ieee_ccmpeqsf_t"
4712 [(set (reg:SI T_REG)
4713 (ior:SI (reg:SI T_REG)
4714 (eq:SI (match_operand:SF 0 "fp_arith_reg_operand" "f")
4715 (match_operand:SF 1 "fp_arith_reg_operand" "f"))))]
4716 "TARGET_SH3E && TARGET_IEEE && ! TARGET_SH4"
4717 "* return output_ieee_ccmpeq (insn, operands);"
4718 [(set_attr "length" "4")])
4721 (define_insn "cmpgtsf_t_i4"
4722 [(set (reg:SI T_REG)
4723 (gt:SI (match_operand:SF 0 "fp_arith_reg_operand" "f")
4724 (match_operand:SF 1 "fp_arith_reg_operand" "f")))
4725 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4728 [(set_attr "type" "fp")
4729 (set_attr "fp_mode" "single")])
4731 (define_insn "cmpeqsf_t_i4"
4732 [(set (reg:SI T_REG)
4733 (eq:SI (match_operand:SF 0 "fp_arith_reg_operand" "f")
4734 (match_operand:SF 1 "fp_arith_reg_operand" "f")))
4735 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4738 [(set_attr "type" "fp")
4739 (set_attr "fp_mode" "single")])
4741 (define_insn "*ieee_ccmpeqsf_t_4"
4742 [(set (reg:SI T_REG)
4743 (ior:SI (reg:SI T_REG)
4744 (eq:SI (match_operand:SF 0 "fp_arith_reg_operand" "f")
4745 (match_operand:SF 1 "fp_arith_reg_operand" "f"))))
4746 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4747 "TARGET_IEEE && TARGET_SH4"
4748 "* return output_ieee_ccmpeq (insn, operands);"
4749 [(set_attr "length" "4")
4750 (set_attr "fp_mode" "single")])
4752 (define_expand "cmpsf"
4753 [(set (reg:SI T_REG)
4754 (compare (match_operand:SF 0 "arith_operand" "")
4755 (match_operand:SF 1 "arith_operand" "")))]
4759 sh_compare_op0 = operands[0];
4760 sh_compare_op1 = operands[1];
4764 (define_expand "negsf2"
4765 [(match_operand:SF 0 "fp_arith_reg_operand" "")
4766 (match_operand:SF 1 "fp_arith_reg_operand" "")]
4768 "{ expand_sf_unop (&gen_negsf2_i, operands); DONE; }")
4770 (define_insn "negsf2_i"
4771 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
4772 (neg:SF (match_operand:SF 1 "fp_arith_reg_operand" "0")))
4773 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4776 [(set_attr "type" "fmove")
4777 (set_attr "fp_mode" "single")])
4779 (define_expand "sqrtsf2"
4780 [(match_operand:SF 0 "fp_arith_reg_operand" "")
4781 (match_operand:SF 1 "fp_arith_reg_operand" "")]
4783 "{ expand_sf_unop (&gen_sqrtsf2_i, operands); DONE; }")
4785 (define_insn "sqrtsf2_i"
4786 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
4787 (sqrt:SF (match_operand:SF 1 "fp_arith_reg_operand" "0")))
4788 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4791 [(set_attr "type" "fdiv")
4792 (set_attr "fp_mode" "single")])
4794 (define_expand "abssf2"
4795 [(match_operand:SF 0 "fp_arith_reg_operand" "")
4796 (match_operand:SF 1 "fp_arith_reg_operand" "")]
4798 "{ expand_sf_unop (&gen_abssf2_i, operands); DONE; }")
4800 (define_insn "abssf2_i"
4801 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
4802 (abs:SF (match_operand:SF 1 "fp_arith_reg_operand" "0")))
4803 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4806 [(set_attr "type" "fmove")
4807 (set_attr "fp_mode" "single")])
4809 (define_expand "adddf3"
4810 [(match_operand:DF 0 "fp_arith_reg_operand" "")
4811 (match_operand:DF 1 "fp_arith_reg_operand" "")
4812 (match_operand:DF 2 "fp_arith_reg_operand" "")]
4814 "{ expand_df_binop (&gen_adddf3_i, operands); DONE; }")
4816 (define_insn "adddf3_i"
4817 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
4818 (plus:DF (match_operand:DF 1 "fp_arith_reg_operand" "%0")
4819 (match_operand:DF 2 "fp_arith_reg_operand" "f")))
4820 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
4823 [(set_attr "type" "dfp_arith")
4824 (set_attr "fp_mode" "double")])
4826 (define_expand "subdf3"
4827 [(match_operand:DF 0 "fp_arith_reg_operand" "")
4828 (match_operand:DF 1 "fp_arith_reg_operand" "")
4829 (match_operand:DF 2 "fp_arith_reg_operand" "")]
4831 "{ expand_df_binop (&gen_subdf3_i, operands); DONE; }")
4833 (define_insn "subdf3_i"
4834 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
4835 (minus:DF (match_operand:DF 1 "fp_arith_reg_operand" "0")
4836 (match_operand:DF 2 "fp_arith_reg_operand" "f")))
4837 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
4840 [(set_attr "type" "dfp_arith")
4841 (set_attr "fp_mode" "double")])
4843 (define_expand "muldf3"
4844 [(match_operand:DF 0 "fp_arith_reg_operand" "")
4845 (match_operand:DF 1 "fp_arith_reg_operand" "")
4846 (match_operand:DF 2 "fp_arith_reg_operand" "")]
4848 "{ expand_df_binop (&gen_muldf3_i, operands); DONE; }")
4850 (define_insn "muldf3_i"
4851 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
4852 (mult:DF (match_operand:DF 1 "fp_arith_reg_operand" "%0")
4853 (match_operand:DF 2 "fp_arith_reg_operand" "f")))
4854 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
4857 [(set_attr "type" "dfp_arith")
4858 (set_attr "fp_mode" "double")])
4860 (define_expand "divdf3"
4861 [(match_operand:DF 0 "fp_arith_reg_operand" "")
4862 (match_operand:DF 1 "fp_arith_reg_operand" "")
4863 (match_operand:DF 2 "fp_arith_reg_operand" "")]
4865 "{ expand_df_binop (&gen_divdf3_i, operands); DONE; }")
4867 (define_insn "divdf3_i"
4868 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
4869 (div:DF (match_operand:DF 1 "fp_arith_reg_operand" "0")
4870 (match_operand:DF 2 "fp_arith_reg_operand" "f")))
4871 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
4874 [(set_attr "type" "dfdiv")
4875 (set_attr "fp_mode" "double")])
4877 (define_expand "floatsidf2"
4878 [(match_operand:DF 0 "fp_arith_reg_operand" "")
4879 (match_operand:SI 1 "fpul_operand" "")]
4883 emit_df_insn (gen_floatsidf2_i (operands[0], operands[1], get_fpscr_rtx ()));
4887 (define_insn "floatsidf2_i"
4888 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
4889 (float:DF (match_operand:SI 1 "fpul_operand" "y")))
4890 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4893 [(set_attr "type" "dfp_conv")
4894 (set_attr "fp_mode" "double")])
4896 (define_expand "fix_truncdfsi2"
4897 [(match_operand:SI 0 "fpul_operand" "")
4898 (match_operand:DF 1 "fp_arith_reg_operand" "")]
4902 emit_df_insn (gen_fix_truncdfsi2_i (operands[0], operands[1], get_fpscr_rtx ()));
4906 (define_insn "fix_truncdfsi2_i"
4907 [(set (match_operand:SI 0 "fpul_operand" "=y")
4908 (fix:SI (match_operand:DF 1 "fp_arith_reg_operand" "f")))
4909 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4912 [(set_attr "type" "dfp_conv")
4913 (set_attr "fp_mode" "double")])
4915 ;; ??? This pattern is used nowhere. fix_truncdfsi2 always expands to
4916 ;; fix_truncdfsi2_i.
4917 ;; (define_insn "fix_truncdfsi2_i4"
4918 ;; [(set (match_operand:SI 0 "arith_reg_operand" "=r")
4919 ;; (fix:SI (match_operand:DF 1 "arith_reg_operand" "f")))
4920 ;; (use (match_operand:PSI 2 "fpscr_operand" "c"))
4921 ;; (clobber (reg:SI FPUL_REG))]
4924 ;; [(set_attr "length" "4")
4925 ;; (set_attr "fp_mode" "double")])
4928 ;; [(set (match_operand:SI 0 "arith_reg_operand" "=r")
4929 ;; (fix:SI (match_operand:DF 1 "arith_reg_operand" "f")))
4930 ;; (use (match_operand:PSI 2 "fpscr_operand" "c"))
4931 ;; (clobber (reg:SI FPUL_REG))]
4933 ;; [(parallel [(set (reg:SI FPUL_REG) (fix:SI (match_dup 1)))
4934 ;; (use (match_dup 2))])
4935 ;; (set (match_dup 0) (reg:SI FPUL_REG))])
4937 (define_insn "cmpgtdf_t"
4938 [(set (reg:SI T_REG)
4939 (gt:SI (match_operand:DF 0 "arith_reg_operand" "f")
4940 (match_operand:DF 1 "arith_reg_operand" "f")))
4941 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4944 [(set_attr "type" "dfp_cmp")
4945 (set_attr "fp_mode" "double")])
4947 (define_insn "cmpeqdf_t"
4948 [(set (reg:SI T_REG)
4949 (eq:SI (match_operand:DF 0 "arith_reg_operand" "f")
4950 (match_operand:DF 1 "arith_reg_operand" "f")))
4951 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4954 [(set_attr "type" "dfp_cmp")
4955 (set_attr "fp_mode" "double")])
4957 (define_insn "*ieee_ccmpeqdf_t"
4958 [(set (reg:SI T_REG)
4959 (ior:SI (reg:SI T_REG)
4960 (eq:SI (match_operand:DF 0 "arith_reg_operand" "f")
4961 (match_operand:DF 1 "arith_reg_operand" "f"))))
4962 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4963 "TARGET_IEEE && TARGET_SH4"
4964 "* return output_ieee_ccmpeq (insn, operands);"
4965 [(set_attr "length" "4")
4966 (set_attr "fp_mode" "double")])
4968 (define_expand "cmpdf"
4969 [(set (reg:SI T_REG)
4970 (compare (match_operand:DF 0 "arith_operand" "")
4971 (match_operand:DF 1 "arith_operand" "")))]
4975 sh_compare_op0 = operands[0];
4976 sh_compare_op1 = operands[1];
4980 (define_expand "negdf2"
4981 [(match_operand:DF 0 "arith_reg_operand" "")
4982 (match_operand:DF 1 "arith_reg_operand" "")]
4984 "{ expand_df_unop (&gen_negdf2_i, operands); DONE; }")
4986 (define_insn "negdf2_i"
4987 [(set (match_operand:DF 0 "arith_reg_operand" "=f")
4988 (neg:DF (match_operand:DF 1 "arith_reg_operand" "0")))
4989 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4992 [(set_attr "type" "fmove")
4993 (set_attr "fp_mode" "double")])
4995 (define_expand "sqrtdf2"
4996 [(match_operand:DF 0 "arith_reg_operand" "")
4997 (match_operand:DF 1 "arith_reg_operand" "")]
4999 "{ expand_df_unop (&gen_sqrtdf2_i, operands); DONE; }")
5001 (define_insn "sqrtdf2_i"
5002 [(set (match_operand:DF 0 "arith_reg_operand" "=f")
5003 (sqrt:DF (match_operand:DF 1 "arith_reg_operand" "0")))
5004 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
5007 [(set_attr "type" "dfdiv")
5008 (set_attr "fp_mode" "double")])
5010 (define_expand "absdf2"
5011 [(match_operand:DF 0 "arith_reg_operand" "")
5012 (match_operand:DF 1 "arith_reg_operand" "")]
5014 "{ expand_df_unop (&gen_absdf2_i, operands); DONE; }")
5016 (define_insn "absdf2_i"
5017 [(set (match_operand:DF 0 "arith_reg_operand" "=f")
5018 (abs:DF (match_operand:DF 1 "arith_reg_operand" "0")))
5019 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
5022 [(set_attr "type" "fmove")
5023 (set_attr "fp_mode" "double")])
5025 (define_expand "extendsfdf2"
5026 [(match_operand:DF 0 "fp_arith_reg_operand" "")
5027 (match_operand:SF 1 "fpul_operand" "")]
5031 emit_df_insn (gen_extendsfdf2_i4 (operands[0], operands[1], get_fpscr_rtx ()));
5035 (define_insn "extendsfdf2_i4"
5036 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
5037 (float_extend:DF (match_operand:SF 1 "fpul_operand" "y")))
5038 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
5041 [(set_attr "type" "fp")
5042 (set_attr "fp_mode" "double")])
5044 (define_expand "truncdfsf2"
5045 [(match_operand:SF 0 "fpul_operand" "")
5046 (match_operand:DF 1 "fp_arith_reg_operand" "")]
5050 emit_df_insn (gen_truncdfsf2_i4 (operands[0], operands[1], get_fpscr_rtx ()));
5054 (define_insn "truncdfsf2_i4"
5055 [(set (match_operand:SF 0 "fpul_operand" "=y")
5056 (float_truncate:SF (match_operand:DF 1 "fp_arith_reg_operand" "f")))
5057 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
5060 [(set_attr "type" "fp")
5061 (set_attr "fp_mode" "double")])
5063 ;; Bit field extract patterns. These give better code for packed bitfields,
5064 ;; because they allow auto-increment addresses to be generated.
5066 (define_expand "insv"
5067 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "")
5068 (match_operand:SI 1 "immediate_operand" "")
5069 (match_operand:SI 2 "immediate_operand" ""))
5070 (match_operand:SI 3 "general_operand" ""))]
5071 "! TARGET_LITTLE_ENDIAN"
5074 rtx addr_target, orig_address, shift_reg;
5077 /* ??? expmed doesn't care for non-register predicates. */
5078 if (! memory_operand (operands[0], VOIDmode)
5079 || ! immediate_operand (operands[1], VOIDmode)
5080 || ! immediate_operand (operands[2], VOIDmode)
5081 || ! general_operand (operands[3], VOIDmode))
5083 /* If this isn't a 16 / 24 / 32 bit field, or if
5084 it doesn't start on a byte boundary, then fail. */
5085 size = INTVAL (operands[1]);
5086 if (size < 16 || size > 32 || size % 8 != 0
5087 || (INTVAL (operands[2]) % 8) != 0)
5091 orig_address = XEXP (operands[0], 0);
5092 shift_reg = gen_reg_rtx (SImode);
5093 emit_insn (gen_movsi (shift_reg, operands[3]));
5094 addr_target = copy_addr_to_reg (plus_constant (orig_address, size - 1));
5096 operands[0] = replace_equiv_address (operands[0], addr_target);
5097 emit_insn (gen_movqi (operands[0], gen_rtx_SUBREG (QImode, shift_reg, 0)));
5101 emit_insn (gen_lshrsi3_k (shift_reg, shift_reg, GEN_INT (8)));
5102 emit_insn (gen_addsi3 (addr_target, addr_target, GEN_INT (-1)));
5103 emit_insn (gen_movqi (operands[0],
5104 gen_rtx_SUBREG (QImode, shift_reg, 0)));
5110 ;; -------------------------------------------------------------------------
5112 ;; -------------------------------------------------------------------------
5114 ;; This matches cases where a stack pointer increment at the start of the
5115 ;; epilogue combines with a stack slot read loading the return value.
5118 [(set (match_operand:SI 0 "arith_reg_operand" "")
5119 (mem:SI (match_operand:SI 1 "arith_reg_operand" "")))
5120 (set (match_dup 1) (plus:SI (match_dup 1) (const_int 4)))]
5121 "REGNO (operands[1]) != REGNO (operands[0])"
5124 ;; See the comment on the dt combiner pattern above.
5127 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
5128 (plus:SI (match_dup 0)
5131 (eq:SI (match_dup 0)
5136 ;; These convert sequences such as `mov #k,r0; add r15,r0; mov.l @r0,rn'
5137 ;; to `mov #k,r0; mov.l @(r0,r15),rn'. These sequences are generated by
5138 ;; reload when the constant is too large for a reg+offset address.
5140 ;; ??? We would get much better code if this was done in reload. This would
5141 ;; require modifying find_reloads_address to recognize that if the constant
5142 ;; is out-of-range for an immediate add, then we get better code by reloading
5143 ;; the constant into a register than by reloading the sum into a register,
5144 ;; since the former is one instruction shorter if the address does not need
5145 ;; to be offsettable. Unfortunately this does not work, because there is
5146 ;; only one register, r0, that can be used as an index register. This register
5147 ;; is also the function return value register. So, if we try to force reload
5148 ;; to use double-reg addresses, then we end up with some instructions that
5149 ;; need to use r0 twice. The only way to fix this is to change the calling
5150 ;; convention so that r0 is not used to return values.
5153 [(set (match_operand:SI 0 "register_operand" "=r")
5154 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
5155 (set (mem:SI (match_dup 0))
5156 (match_operand:SI 2 "general_movsrc_operand" ""))]
5157 "REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
5158 "mov.l %2,@(%0,%1)")
5161 [(set (match_operand:SI 0 "register_operand" "=r")
5162 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
5163 (set (match_operand:SI 2 "general_movdst_operand" "")
5164 (mem:SI (match_dup 0)))]
5165 "REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
5166 "mov.l @(%0,%1),%2")
5169 [(set (match_operand:SI 0 "register_operand" "=r")
5170 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
5171 (set (mem:HI (match_dup 0))
5172 (match_operand:HI 2 "general_movsrc_operand" ""))]
5173 "REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
5174 "mov.w %2,@(%0,%1)")
5177 [(set (match_operand:SI 0 "register_operand" "=r")
5178 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
5179 (set (match_operand:HI 2 "general_movdst_operand" "")
5180 (mem:HI (match_dup 0)))]
5181 "REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
5182 "mov.w @(%0,%1),%2")
5185 [(set (match_operand:SI 0 "register_operand" "=r")
5186 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
5187 (set (mem:QI (match_dup 0))
5188 (match_operand:QI 2 "general_movsrc_operand" ""))]
5189 "REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
5190 "mov.b %2,@(%0,%1)")
5193 [(set (match_operand:SI 0 "register_operand" "=r")
5194 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
5195 (set (match_operand:QI 2 "general_movdst_operand" "")
5196 (mem:QI (match_dup 0)))]
5197 "REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
5198 "mov.b @(%0,%1),%2")
5201 [(set (match_operand:SI 0 "register_operand" "=r")
5202 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
5203 (set (mem:SF (match_dup 0))
5204 (match_operand:SF 2 "general_movsrc_operand" ""))]
5205 "REGNO (operands[0]) == 0
5206 && ((GET_CODE (operands[2]) == REG && REGNO (operands[2]) < 16)
5207 || (GET_CODE (operands[2]) == SUBREG
5208 && REGNO (SUBREG_REG (operands[2])) < 16))
5209 && reg_unused_after (operands[0], insn)"
5210 "mov.l %2,@(%0,%1)")
5213 [(set (match_operand:SI 0 "register_operand" "=r")
5214 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
5215 (set (match_operand:SF 2 "general_movdst_operand" "")
5217 (mem:SF (match_dup 0)))]
5218 "REGNO (operands[0]) == 0
5219 && ((GET_CODE (operands[2]) == REG && REGNO (operands[2]) < 16)
5220 || (GET_CODE (operands[2]) == SUBREG
5221 && REGNO (SUBREG_REG (operands[2])) < 16))
5222 && reg_unused_after (operands[0], insn)"
5223 "mov.l @(%0,%1),%2")
5226 [(set (match_operand:SI 0 "register_operand" "=r")
5227 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
5228 (set (mem:SF (match_dup 0))
5229 (match_operand:SF 2 "general_movsrc_operand" ""))]
5230 "REGNO (operands[0]) == 0
5231 && ((GET_CODE (operands[2]) == REG
5232 && FP_OR_XD_REGISTER_P (REGNO (operands[2])))
5233 || (GET_CODE (operands[2]) == SUBREG
5234 && FP_OR_XD_REGISTER_P (REGNO (SUBREG_REG (operands[2])))))
5235 && reg_unused_after (operands[0], insn)"
5236 "fmov{.s|} %2,@(%0,%1)")
5239 [(set (match_operand:SI 0 "register_operand" "=r")
5240 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
5241 (set (match_operand:SF 2 "general_movdst_operand" "")
5243 (mem:SF (match_dup 0)))]
5244 "REGNO (operands[0]) == 0
5245 && ((GET_CODE (operands[2]) == REG
5246 && FP_OR_XD_REGISTER_P (REGNO (operands[2])))
5247 || (GET_CODE (operands[2]) == SUBREG
5248 && FP_OR_XD_REGISTER_P (REGNO (SUBREG_REG (operands[2])))))
5249 && reg_unused_after (operands[0], insn)"
5250 "fmov{.s|} @(%0,%1),%2")
5252 ;; Switch to a new stack with its address in sp_switch (a SYMBOL_REF). */
5253 (define_insn "sp_switch_1"
5260 xoperands[0] = sp_switch;
5261 output_asm_insn (\"mov.l r0,@-r15\;mov.l %0,r0\", xoperands);
5262 output_asm_insn (\"mov.l @r0,r0\;mov.l r15,@-r0\", xoperands);
5263 return \"mov r0,r15\";
5265 [(set_attr "length" "10")])
5267 ;; Switch back to the original stack for interrupt functions with the
5268 ;; sp_switch attribute. */
5269 (define_insn "sp_switch_2"
5272 "mov.l @r15+,r15\;mov.l @r15+,r0"
5273 [(set_attr "length" "4")])