1 ;;- Machine description for the Hitachi SH.
2 ;; Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
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])))"
1657 && GET_CODE (operands[2]) == CONST_INT
1658 && ! CONST_OK_FOR_K (INTVAL (operands[2]))"
1659 [(set (match_dup 3) (match_dup 2))
1661 [(set (match_dup 0) (ashift:SI (match_dup 1) (match_dup 3)))
1662 (clobber (match_dup 4))])]
1663 "operands[4] = gen_rtx_SCRATCH (SImode);"
1664 [(set_attr "length" "*,*,*,4")
1665 (set_attr "type" "dyn_shift,arith,arith,arith")])
1667 (define_insn "ashlhi3_k"
1668 [(set (match_operand:HI 0 "arith_reg_operand" "=r,r")
1669 (ashift:HI (match_operand:HI 1 "arith_reg_operand" "0,0")
1670 (match_operand:HI 2 "const_int_operand" "M,K")))]
1671 "CONST_OK_FOR_K (INTVAL (operands[2]))"
1675 [(set_attr "type" "arith")])
1677 (define_insn "ashlsi3_n"
1678 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1679 (ashift:SI (match_operand:SI 1 "arith_reg_operand" "0")
1680 (match_operand:SI 2 "const_int_operand" "n")))
1681 (clobber (reg:SI T_REG))]
1682 "! sh_dynamicalize_shift_p (operands[2])"
1684 [(set (attr "length")
1685 (cond [(eq (symbol_ref "shift_insns_rtx (insn)") (const_int 1))
1687 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 2))
1689 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 3))
1691 (const_string "8")))
1692 (set_attr "type" "arith")])
1695 [(set (match_operand:SI 0 "arith_reg_operand" "")
1696 (ashift:SI (match_operand:SI 1 "arith_reg_operand" "")
1697 (match_operand:SI 2 "const_int_operand" "n")))
1698 (clobber (reg:SI T_REG))]
1700 [(use (reg:SI R0_REG))]
1703 gen_shifty_op (ASHIFT, operands);
1707 (define_expand "ashlsi3"
1708 [(parallel [(set (match_operand:SI 0 "arith_reg_operand" "")
1709 (ashift:SI (match_operand:SI 1 "arith_reg_operand" "")
1710 (match_operand:SI 2 "nonmemory_operand" "")))
1711 (clobber (reg:SI T_REG))])]
1715 if (GET_CODE (operands[2]) == CONST_INT
1716 && sh_dynamicalize_shift_p (operands[2]))
1717 operands[2] = force_reg (SImode, operands[2]);
1720 emit_insn (gen_ashlsi3_std (operands[0], operands[1], operands[2]));
1723 if (! immediate_operand (operands[2], GET_MODE (operands[2])))
1727 (define_insn "ashlhi3"
1728 [(set (match_operand:HI 0 "arith_reg_operand" "=r")
1729 (ashift:HI (match_operand:HI 1 "arith_reg_operand" "0")
1730 (match_operand:HI 2 "const_int_operand" "n")))
1731 (clobber (reg:SI T_REG))]
1734 [(set (attr "length")
1735 (cond [(eq (symbol_ref "shift_insns_rtx (insn)") (const_int 1))
1737 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 2))
1739 (const_string "6")))
1740 (set_attr "type" "arith")])
1743 [(set (match_operand:HI 0 "arith_reg_operand" "")
1744 (ashift:HI (match_operand:HI 1 "arith_reg_operand" "")
1745 (match_operand:HI 2 "const_int_operand" "n")))
1746 (clobber (reg:SI T_REG))]
1748 [(use (reg:SI R0_REG))]
1751 gen_shifty_hi_op (ASHIFT, operands);
1756 ; arithmetic shift right
1759 (define_insn "ashrsi3_k"
1760 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1761 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
1762 (match_operand:SI 2 "const_int_operand" "M")))
1763 (clobber (reg:SI T_REG))]
1764 "INTVAL (operands[2]) == 1"
1766 [(set_attr "type" "arith")])
1768 ;; We can't do HImode right shifts correctly unless we start out with an
1769 ;; explicit zero / sign extension; doing that would result in worse overall
1770 ;; code, so just let the machine independent code widen the mode.
1771 ;; That's why we don't have ashrhi3_k / lshrhi3_k / lshrhi3_m / lshrhi3 .
1774 ;; ??? This should be a define expand.
1776 (define_insn "ashrsi2_16"
1777 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1778 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "r")
1782 [(set_attr "length" "4")])
1785 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1786 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "r")
1789 [(set (match_dup 0) (rotate:SI (match_dup 1) (const_int 16)))
1790 (set (match_dup 0) (sign_extend:SI (match_dup 2)))]
1791 "operands[2] = gen_lowpart (HImode, operands[0]);")
1793 ;; ??? This should be a define expand.
1795 (define_insn "ashrsi2_31"
1796 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1797 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
1799 (clobber (reg:SI T_REG))]
1802 [(set_attr "length" "4")])
1805 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1806 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
1808 (clobber (reg:SI T_REG))]
1813 emit_insn (gen_ashlsi_c (operands[0], operands[1]));
1814 emit_insn (gen_subc1 (operands[0], operands[0], operands[0]));
1818 (define_insn "ashlsi_c"
1819 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1820 (ashift:SI (match_operand:SI 1 "arith_reg_operand" "0") (const_int 1)))
1822 (lt:SI (match_dup 1) (const_int 0)))]
1825 [(set_attr "type" "arith")])
1827 (define_insn "ashrsi3_d"
1828 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1829 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
1830 (neg:SI (match_operand:SI 2 "arith_reg_operand" "r"))))]
1833 [(set_attr "type" "dyn_shift")])
1835 (define_insn "ashrsi3_n"
1836 [(set (reg:SI R4_REG)
1837 (ashiftrt:SI (reg:SI R4_REG)
1838 (match_operand:SI 0 "const_int_operand" "i")))
1839 (clobber (reg:SI T_REG))
1840 (clobber (reg:SI PR_REG))
1841 (use (match_operand:SI 1 "arith_reg_operand" "r"))]
1844 [(set_attr "type" "sfunc")
1845 (set_attr "needs_delay_slot" "yes")])
1847 (define_expand "ashrsi3"
1848 [(parallel [(set (match_operand:SI 0 "arith_reg_operand" "")
1849 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "")
1850 (match_operand:SI 2 "nonmemory_operand" "")))
1851 (clobber (reg:SI T_REG))])]
1853 "if (expand_ashiftrt (operands)) DONE; else FAIL;")
1855 ;; logical shift right
1857 (define_insn "lshrsi3_d"
1858 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1859 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
1860 (neg:SI (match_operand:SI 2 "arith_reg_operand" "r"))))]
1863 [(set_attr "type" "dyn_shift")])
1865 ;; Only the single bit shift clobbers the T bit.
1867 (define_insn "lshrsi3_m"
1868 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1869 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
1870 (match_operand:SI 2 "const_int_operand" "M")))
1871 (clobber (reg:SI T_REG))]
1872 "CONST_OK_FOR_M (INTVAL (operands[2]))"
1874 [(set_attr "type" "arith")])
1876 (define_insn "lshrsi3_k"
1877 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1878 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
1879 (match_operand:SI 2 "const_int_operand" "K")))]
1880 "CONST_OK_FOR_K (INTVAL (operands[2]))
1881 && ! CONST_OK_FOR_M (INTVAL (operands[2]))"
1883 [(set_attr "type" "arith")])
1885 (define_insn "lshrsi3_n"
1886 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
1887 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
1888 (match_operand:SI 2 "const_int_operand" "n")))
1889 (clobber (reg:SI T_REG))]
1890 "! sh_dynamicalize_shift_p (operands[2])"
1892 [(set (attr "length")
1893 (cond [(eq (symbol_ref "shift_insns_rtx (insn)") (const_int 1))
1895 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 2))
1897 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 3))
1899 (const_string "8")))
1900 (set_attr "type" "arith")])
1903 [(set (match_operand:SI 0 "arith_reg_operand" "")
1904 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "")
1905 (match_operand:SI 2 "const_int_operand" "n")))
1906 (clobber (reg:SI T_REG))]
1908 [(use (reg:SI R0_REG))]
1911 gen_shifty_op (LSHIFTRT, operands);
1915 (define_expand "lshrsi3"
1916 [(parallel [(set (match_operand:SI 0 "arith_reg_operand" "")
1917 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "")
1918 (match_operand:SI 2 "nonmemory_operand" "")))
1919 (clobber (reg:SI T_REG))])]
1923 if (GET_CODE (operands[2]) == CONST_INT
1924 && sh_dynamicalize_shift_p (operands[2]))
1925 operands[2] = force_reg (SImode, operands[2]);
1926 if (TARGET_SH3 && arith_reg_operand (operands[2], GET_MODE (operands[2])))
1928 rtx count = copy_to_mode_reg (SImode, operands[2]);
1929 emit_insn (gen_negsi2 (count, count));
1930 emit_insn (gen_lshrsi3_d (operands[0], operands[1], count));
1933 if (! immediate_operand (operands[2], GET_MODE (operands[2])))
1937 ;; ??? This should be a define expand.
1939 (define_insn "ashldi3_k"
1940 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
1941 (ashift:DI (match_operand:DI 1 "arith_reg_operand" "0")
1943 (clobber (reg:SI T_REG))]
1945 "shll %R0\;rotcl %S0"
1946 [(set_attr "length" "4")
1947 (set_attr "type" "arith")])
1949 (define_expand "ashldi3"
1950 [(parallel [(set (match_operand:DI 0 "arith_reg_operand" "")
1951 (ashift:DI (match_operand:DI 1 "arith_reg_operand" "")
1952 (match_operand:DI 2 "immediate_operand" "")))
1953 (clobber (reg:SI T_REG))])]
1955 "{ if (GET_CODE (operands[2]) != CONST_INT
1956 || INTVAL (operands[2]) != 1) FAIL;} ")
1958 ;; ??? This should be a define expand.
1960 (define_insn "lshrdi3_k"
1961 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
1962 (lshiftrt:DI (match_operand:DI 1 "arith_reg_operand" "0")
1964 (clobber (reg:SI T_REG))]
1966 "shlr %S0\;rotcr %R0"
1967 [(set_attr "length" "4")
1968 (set_attr "type" "arith")])
1970 (define_expand "lshrdi3"
1971 [(parallel [(set (match_operand:DI 0 "arith_reg_operand" "")
1972 (lshiftrt:DI (match_operand:DI 1 "arith_reg_operand" "")
1973 (match_operand:DI 2 "immediate_operand" "")))
1974 (clobber (reg:SI T_REG))])]
1976 "{ if (GET_CODE (operands[2]) != CONST_INT
1977 || INTVAL (operands[2]) != 1) FAIL;} ")
1979 ;; ??? This should be a define expand.
1981 (define_insn "ashrdi3_k"
1982 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
1983 (ashiftrt:DI (match_operand:DI 1 "arith_reg_operand" "0")
1985 (clobber (reg:SI T_REG))]
1987 "shar %S0\;rotcr %R0"
1988 [(set_attr "length" "4")
1989 (set_attr "type" "arith")])
1991 (define_expand "ashrdi3"
1992 [(parallel [(set (match_operand:DI 0 "arith_reg_operand" "")
1993 (ashiftrt:DI (match_operand:DI 1 "arith_reg_operand" "")
1994 (match_operand:DI 2 "immediate_operand" "")))
1995 (clobber (reg:SI T_REG))])]
1997 "{ if (GET_CODE (operands[2]) != CONST_INT
1998 || INTVAL (operands[2]) != 1) FAIL; } ")
2000 ;; combined left/right shift
2003 [(set (match_operand:SI 0 "register_operand" "")
2004 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
2005 (match_operand:SI 2 "const_int_operand" "n"))
2006 (match_operand:SI 3 "const_int_operand" "n")))]
2007 "(unsigned)INTVAL (operands[2]) < 32"
2008 [(use (reg:SI R0_REG))]
2009 "if (gen_shl_and (operands[0], operands[2], operands[3], operands[1])) FAIL;
2013 [(set (match_operand:SI 0 "register_operand" "")
2014 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
2015 (match_operand:SI 2 "const_int_operand" "n"))
2016 (match_operand:SI 3 "const_int_operand" "n")))
2017 (clobber (reg:SI T_REG))]
2018 "(unsigned)INTVAL (operands[2]) < 32"
2019 [(use (reg:SI R0_REG))]
2020 "if (gen_shl_and (operands[0], operands[2], operands[3], operands[1])) FAIL;
2024 [(set (match_operand:SI 0 "register_operand" "=r")
2025 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
2026 (match_operand:SI 2 "const_int_operand" "n"))
2027 (match_operand:SI 3 "const_int_operand" "n")))
2028 (clobber (reg:SI T_REG))]
2029 "shl_and_kind (operands[2], operands[3], 0) == 1"
2031 [(set (attr "length")
2032 (cond [(eq (symbol_ref "shl_and_length (insn)") (const_int 2))
2034 (eq (symbol_ref "shl_and_length (insn)") (const_int 3))
2036 (eq (symbol_ref "shl_and_length (insn)") (const_int 4))
2038 (eq (symbol_ref "shl_and_length (insn)") (const_int 5))
2040 (eq (symbol_ref "shl_and_length (insn)") (const_int 6))
2042 (eq (symbol_ref "shl_and_length (insn)") (const_int 7))
2044 (eq (symbol_ref "shl_and_length (insn)") (const_int 8))
2045 (const_string "16")]
2046 (const_string "18")))
2047 (set_attr "type" "arith")])
2050 [(set (match_operand:SI 0 "register_operand" "=z")
2051 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
2052 (match_operand:SI 2 "const_int_operand" "n"))
2053 (match_operand:SI 3 "const_int_operand" "n")))
2054 (clobber (reg:SI T_REG))]
2055 "shl_and_kind (operands[2], operands[3], 0) == 2"
2057 [(set (attr "length")
2058 (cond [(eq (symbol_ref "shl_and_length (insn)") (const_int 2))
2060 (eq (symbol_ref "shl_and_length (insn)") (const_int 3))
2062 (eq (symbol_ref "shl_and_length (insn)") (const_int 4))
2064 (const_string "10")))
2065 (set_attr "type" "arith")])
2067 ;; shift left / and combination with a scratch register: The combine pass
2068 ;; does not accept the individual instructions, even though they are
2069 ;; cheap. But it needs a precise description so that it is usable after
2071 (define_insn "and_shl_scratch"
2072 [(set (match_operand:SI 0 "register_operand" "=r,&r")
2076 (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,0")
2077 (match_operand:SI 2 "const_int_operand" "N,n"))
2078 (match_operand:SI 3 "" "0,r"))
2079 (match_operand:SI 4 "const_int_operand" "n,n"))
2080 (match_operand:SI 5 "const_int_operand" "n,n")))
2081 (clobber (reg:SI T_REG))]
2084 [(set (attr "length")
2085 (cond [(eq (symbol_ref "shl_and_scr_length (insn)") (const_int 2))
2087 (eq (symbol_ref "shl_and_scr_length (insn)") (const_int 3))
2089 (eq (symbol_ref "shl_and_scr_length (insn)") (const_int 4))
2091 (eq (symbol_ref "shl_and_scr_length (insn)") (const_int 5))
2092 (const_string "10")]
2093 (const_string "12")))
2094 (set_attr "type" "arith")])
2097 [(set (match_operand:SI 0 "register_operand" "=r,&r")
2101 (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,0")
2102 (match_operand:SI 2 "const_int_operand" "N,n"))
2103 (match_operand:SI 3 "register_operand" "0,r"))
2104 (match_operand:SI 4 "const_int_operand" "n,n"))
2105 (match_operand:SI 5 "const_int_operand" "n,n")))
2106 (clobber (reg:SI T_REG))]
2108 [(use (reg:SI R0_REG))]
2111 rtx and_source = operands[rtx_equal_p (operands[0], operands[1]) ? 3 : 1];
2113 if (INTVAL (operands[2]))
2115 gen_shifty_op (LSHIFTRT, operands);
2117 emit_insn (gen_andsi3 (operands[0], operands[0], and_source));
2118 operands[2] = operands[4];
2119 gen_shifty_op (ASHIFT, operands);
2120 if (INTVAL (operands[5]))
2122 operands[2] = operands[5];
2123 gen_shifty_op (LSHIFTRT, operands);
2128 ;; signed left/right shift combination.
2130 [(set (match_operand:SI 0 "register_operand" "=r")
2132 (ashift:SI (match_operand:SI 1 "register_operand" "r")
2133 (match_operand:SI 2 "const_int_operand" "n"))
2134 (match_operand:SI 3 "const_int_operand" "n")
2136 (clobber (reg:SI T_REG))]
2138 [(use (reg:SI R0_REG))]
2139 "if (gen_shl_sext (operands[0], operands[2], operands[3], operands[1])) FAIL;
2142 (define_insn "shl_sext_ext"
2143 [(set (match_operand:SI 0 "register_operand" "=r")
2145 (ashift:SI (match_operand:SI 1 "register_operand" "0")
2146 (match_operand:SI 2 "const_int_operand" "n"))
2147 (match_operand:SI 3 "const_int_operand" "n")
2149 (clobber (reg:SI T_REG))]
2150 "(unsigned)shl_sext_kind (operands[2], operands[3], 0) - 1 < 5"
2152 [(set (attr "length")
2153 (cond [(eq (symbol_ref "shl_sext_length (insn)") (const_int 1))
2155 (eq (symbol_ref "shl_sext_length (insn)") (const_int 2))
2157 (eq (symbol_ref "shl_sext_length (insn)") (const_int 3))
2159 (eq (symbol_ref "shl_sext_length (insn)") (const_int 4))
2161 (eq (symbol_ref "shl_sext_length (insn)") (const_int 5))
2163 (eq (symbol_ref "shl_sext_length (insn)") (const_int 6))
2165 (eq (symbol_ref "shl_sext_length (insn)") (const_int 7))
2167 (eq (symbol_ref "shl_sext_length (insn)") (const_int 8))
2168 (const_string "16")]
2169 (const_string "18")))
2170 (set_attr "type" "arith")])
2172 (define_insn "shl_sext_sub"
2173 [(set (match_operand:SI 0 "register_operand" "=z")
2175 (ashift:SI (match_operand:SI 1 "register_operand" "0")
2176 (match_operand:SI 2 "const_int_operand" "n"))
2177 (match_operand:SI 3 "const_int_operand" "n")
2179 (clobber (reg:SI T_REG))]
2180 "(shl_sext_kind (operands[2], operands[3], 0) & ~1) == 6"
2182 [(set (attr "length")
2183 (cond [(eq (symbol_ref "shl_sext_length (insn)") (const_int 3))
2185 (eq (symbol_ref "shl_sext_length (insn)") (const_int 4))
2187 (eq (symbol_ref "shl_sext_length (insn)") (const_int 5))
2189 (eq (symbol_ref "shl_sext_length (insn)") (const_int 6))
2190 (const_string "12")]
2191 (const_string "14")))
2192 (set_attr "type" "arith")])
2194 ;; These patterns are found in expansions of DImode shifts by 16, and
2195 ;; allow the xtrct instruction to be generated from C source.
2197 (define_insn "xtrct_left"
2198 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
2199 (ior:SI (ashift:SI (match_operand:SI 1 "arith_reg_operand" "r")
2201 (lshiftrt:SI (match_operand:SI 2 "arith_reg_operand" "0")
2205 [(set_attr "type" "arith")])
2207 (define_insn "xtrct_right"
2208 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
2209 (ior:SI (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
2211 (ashift:SI (match_operand:SI 2 "arith_reg_operand" "r")
2215 [(set_attr "type" "arith")])
2217 ;; -------------------------------------------------------------------------
2219 ;; -------------------------------------------------------------------------
2222 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
2223 (neg:SI (plus:SI (reg:SI T_REG)
2224 (match_operand:SI 1 "arith_reg_operand" "r"))))
2226 (ne:SI (ior:SI (reg:SI T_REG) (match_dup 1))
2230 [(set_attr "type" "arith")])
2232 (define_expand "negdi2"
2233 [(set (match_operand:DI 0 "arith_reg_operand" "")
2234 (neg:DI (match_operand:DI 1 "arith_reg_operand" "")))
2235 (clobber (reg:SI T_REG))]
2239 int low_word = (TARGET_LITTLE_ENDIAN ? 0 : 1);
2240 int high_word = (TARGET_LITTLE_ENDIAN ? 1 : 0);
2242 rtx low_src = operand_subword (operands[1], low_word, 0, DImode);
2243 rtx high_src = operand_subword (operands[1], high_word, 0, DImode);
2245 rtx low_dst = operand_subword (operands[0], low_word, 1, DImode);
2246 rtx high_dst = operand_subword (operands[0], high_word, 1, DImode);
2248 emit_insn (gen_clrt ());
2249 emit_insn (gen_negc (low_dst, low_src));
2250 emit_insn (gen_negc (high_dst, high_src));
2254 (define_insn "negsi2"
2255 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
2256 (neg:SI (match_operand:SI 1 "arith_reg_operand" "r")))]
2259 [(set_attr "type" "arith")])
2261 (define_insn "one_cmplsi2"
2262 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
2263 (not:SI (match_operand:SI 1 "arith_reg_operand" "r")))]
2266 [(set_attr "type" "arith")])
2268 ;; -------------------------------------------------------------------------
2269 ;; Zero extension instructions
2270 ;; -------------------------------------------------------------------------
2272 (define_insn "zero_extendhisi2"
2273 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
2274 (zero_extend:SI (match_operand:HI 1 "arith_reg_operand" "r")))]
2277 [(set_attr "type" "arith")])
2279 (define_insn "zero_extendqisi2"
2280 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
2281 (zero_extend:SI (match_operand:QI 1 "arith_reg_operand" "r")))]
2284 [(set_attr "type" "arith")])
2286 (define_insn "zero_extendqihi2"
2287 [(set (match_operand:HI 0 "arith_reg_operand" "=r")
2288 (zero_extend:HI (match_operand:QI 1 "arith_reg_operand" "r")))]
2291 [(set_attr "type" "arith")])
2293 ;; -------------------------------------------------------------------------
2294 ;; Sign extension instructions
2295 ;; -------------------------------------------------------------------------
2297 ;; ??? This should be a define expand.
2298 ;; ??? Or perhaps it should be dropped?
2300 /* There is no point in defining extendsidi2; convert_move generates good
2303 (define_insn "extendhisi2"
2304 [(set (match_operand:SI 0 "arith_reg_operand" "=r,r")
2305 (sign_extend:SI (match_operand:HI 1 "general_movsrc_operand" "r,m")))]
2310 [(set_attr "type" "arith,load")])
2312 (define_insn "extendqisi2"
2313 [(set (match_operand:SI 0 "arith_reg_operand" "=r,r")
2314 (sign_extend:SI (match_operand:QI 1 "general_movsrc_operand" "r,m")))]
2319 [(set_attr "type" "arith,load")])
2321 (define_insn "extendqihi2"
2322 [(set (match_operand:HI 0 "arith_reg_operand" "=r,r")
2323 (sign_extend:HI (match_operand:QI 1 "general_movsrc_operand" "r,m")))]
2328 [(set_attr "type" "arith,load")])
2330 ;; -------------------------------------------------------------------------
2331 ;; Move instructions
2332 ;; -------------------------------------------------------------------------
2334 ;; define push and pop so it is easy for sh.c
2336 (define_expand "push"
2337 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
2338 (match_operand:SI 0 "register_operand" "r,l,x"))]
2342 (define_expand "pop"
2343 [(set (match_operand:SI 0 "register_operand" "=r,l,x")
2344 (mem:SI (post_inc:SI (reg:SI SP_REG))))]
2348 (define_expand "push_e"
2349 [(parallel [(set (mem:SF (pre_dec:SI (reg:SI SP_REG)))
2350 (match_operand:SF 0 "" ""))
2351 (use (reg:PSI FPSCR_REG))
2352 (clobber (scratch:SI))])]
2356 (define_insn "push_fpul"
2357 [(set (mem:SF (pre_dec:SI (reg:SI SP_REG))) (reg:SF FPUL_REG))]
2360 [(set_attr "type" "store")
2361 (set_attr "hit_stack" "yes")])
2363 ;; DFmode pushes for sh4 require a lot of what is defined for movdf_i4,
2365 (define_expand "push_4"
2366 [(parallel [(set (mem:DF (pre_dec:SI (reg:SI SP_REG)))
2367 (match_operand:DF 0 "" ""))
2368 (use (reg:PSI FPSCR_REG))
2369 (clobber (scratch:SI))])]
2373 (define_expand "pop_e"
2374 [(parallel [(set (match_operand:SF 0 "" "")
2375 (mem:SF (post_inc:SI (reg:SI SP_REG))))
2376 (use (reg:PSI FPSCR_REG))
2377 (clobber (scratch:SI))])]
2381 (define_insn "pop_fpul"
2382 [(set (reg:SF FPUL_REG) (mem:SF (post_inc:SI (reg:SI SP_REG))))]
2385 [(set_attr "type" "load")
2386 (set_attr "hit_stack" "yes")])
2388 (define_expand "pop_4"
2389 [(parallel [(set (match_operand:DF 0 "" "")
2390 (mem:DF (post_inc:SI (reg:SI SP_REG))))
2391 (use (reg:PSI FPSCR_REG))
2392 (clobber (scratch:SI))])]
2396 ;; These two patterns can happen as the result of optimization, when
2397 ;; comparisons get simplified to a move of zero or 1 into the T reg.
2398 ;; They don't disappear completely, because the T reg is a fixed hard reg.
2401 [(set (reg:SI T_REG) (const_int 0))]
2406 [(set (reg:SI T_REG) (const_int 1))]
2410 ;; t/r must come after r/r, lest reload will try to reload stuff like
2411 ;; (set (subreg:SI (mem:QI (plus:SI (reg:SI SP_REG) (const_int 12)) 0) 0)
2412 ;; (made from (set (subreg:SI (reg:QI ###) 0) ) into T.
2413 (define_insn "movsi_i"
2414 [(set (match_operand:SI 0 "general_movdst_operand" "=r,r,t,r,r,r,r,m,<,<,x,l,x,l,r")
2415 (match_operand:SI 1 "general_movsrc_operand" "Q,rI,r,mr,x,l,t,r,x,l,r,r,>,>,i"))]
2418 && (register_operand (operands[0], SImode)
2419 || register_operand (operands[1], SImode))"
2436 [(set_attr "type" "pcload_si,move,*,load_si,move,prget,move,store,store,pstore,move,prset,load,pload,pcload_si")
2437 (set_attr "length" "*,*,*,*,*,*,*,*,*,*,*,*,*,*,*")])
2439 ;; t/r must come after r/r, lest reload will try to reload stuff like
2440 ;; (subreg:SI (reg:SF FR14_REG) 0) into T (compiling stdlib/strtod.c -m3e -O2)
2441 ;; ??? This allows moves from macl to fpul to be recognized, but these moves
2442 ;; will require a reload.
2443 (define_insn "movsi_ie"
2444 [(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")
2445 (match_operand:SI 1 "general_movsrc_operand" "Q,rI,r,mr,x,l,t,r,x,l,r,r,>,>,>,y,i,r,y,y"))]
2447 && (register_operand (operands[0], SImode)
2448 || register_operand (operands[1], SImode))"
2469 ! move optimized away"
2470 [(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")
2471 (set_attr "length" "*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,0")])
2473 (define_insn "movsi_i_lowpart"
2474 [(set (strict_low_part (match_operand:SI 0 "general_movdst_operand" "+r,r,r,r,r,r,m,r"))
2475 (match_operand:SI 1 "general_movsrc_operand" "Q,rI,mr,x,l,t,r,i"))]
2476 "register_operand (operands[0], SImode)
2477 || register_operand (operands[1], SImode)"
2487 [(set_attr "type" "pcload,move,load,move,prget,move,store,pcload")])
2489 (define_expand "movsi"
2490 [(set (match_operand:SI 0 "general_movdst_operand" "")
2491 (match_operand:SI 1 "general_movsrc_operand" ""))]
2493 "{ if (prepare_move_operands (operands, SImode)) DONE; }")
2495 (define_expand "ic_invalidate_line"
2496 [(parallel [(unspec_volatile [(match_operand:SI 0 "register_operand" "+r")
2497 (match_dup 1)] UNSPEC_ICACHE)
2498 (clobber (scratch:SI))])]
2502 operands[0] = force_reg (Pmode, operands[0]);
2503 operands[1] = force_reg (Pmode, GEN_INT (0xf0000008));
2506 ;; The address %0 is assumed to be 4-aligned at least. Thus, by ORing
2507 ;; 0xf0000008, we get the low-oder bits *1*00 (binary), which fits
2508 ;; the requirement *1*00 for associative address writes. The alignment of
2509 ;; %0 implies that its least significant bit is cleared,
2510 ;; thus we clear the V bit of a matching entry if there is one.
2511 (define_insn "ic_invalidate_line_i"
2512 [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")
2513 (match_operand:SI 1 "register_operand" "r")]
2515 (clobber (match_scratch:SI 2 "=&r"))]
2517 "ocbwb\\t@%0\;extu.w\\t%0,%2\;or\\t%1,%2\;mov.l\\t%0,@%2"
2518 [(set_attr "length" "8")])
2520 (define_insn "movqi_i"
2521 [(set (match_operand:QI 0 "general_movdst_operand" "=r,r,m,r,r,l")
2522 (match_operand:QI 1 "general_movsrc_operand" "ri,m,r,t,l,r"))]
2523 "arith_reg_operand (operands[0], QImode)
2524 || arith_reg_operand (operands[1], QImode)"
2532 [(set_attr "type" "move,load,store,move,move,move")])
2534 (define_expand "movqi"
2535 [(set (match_operand:QI 0 "general_operand" "")
2536 (match_operand:QI 1 "general_operand" ""))]
2538 "{ if (prepare_move_operands (operands, QImode)) DONE; }")
2540 (define_insn "movhi_i"
2541 [(set (match_operand:HI 0 "general_movdst_operand" "=r,r,r,r,m,r,l,r")
2542 (match_operand:HI 1 "general_movsrc_operand" "Q,rI,m,t,r,l,r,i"))]
2543 "arith_reg_operand (operands[0], HImode)
2544 || arith_reg_operand (operands[1], HImode)"
2554 [(set_attr "type" "pcload,move,load,move,store,move,move,pcload")])
2556 (define_expand "movhi"
2557 [(set (match_operand:HI 0 "general_movdst_operand" "")
2558 (match_operand:HI 1 "general_movsrc_operand" ""))]
2560 "{ if (prepare_move_operands (operands, HImode)) DONE; }")
2562 ;; ??? This should be a define expand.
2564 ;; x/r can be created by inlining/cse, e.g. for execute/961213-1.c
2565 ;; compiled with -m2 -ml -O3 -funroll-loops
2567 [(set (match_operand:DI 0 "general_movdst_operand" "=r,r,r,m,r,r,r,*!x")
2568 (match_operand:DI 1 "general_movsrc_operand" "Q,r,m,r,I,i,x,r"))]
2569 "arith_reg_operand (operands[0], DImode)
2570 || arith_reg_operand (operands[1], DImode)"
2571 "* return output_movedouble (insn, operands, DImode);"
2572 [(set_attr "length" "4")
2573 (set_attr "type" "pcload,move,load,store,move,pcload,move,move")])
2575 ;; If the output is a register and the input is memory or a register, we have
2576 ;; to be careful and see which word needs to be loaded first.
2579 [(set (match_operand:DI 0 "general_movdst_operand" "")
2580 (match_operand:DI 1 "general_movsrc_operand" ""))]
2582 [(set (match_dup 2) (match_dup 3))
2583 (set (match_dup 4) (match_dup 5))]
2588 if ((GET_CODE (operands[0]) == MEM
2589 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2590 || (GET_CODE (operands[1]) == MEM
2591 && GET_CODE (XEXP (operands[1], 0)) == POST_INC))
2594 if (GET_CODE (operands[0]) == REG)
2595 regno = REGNO (operands[0]);
2596 else if (GET_CODE (operands[0]) == SUBREG)
2597 regno = subreg_regno (operands[0]);
2598 else if (GET_CODE (operands[0]) == MEM)
2602 || ! refers_to_regno_p (regno, regno + 1, operands[1], 0))
2604 operands[2] = operand_subword (operands[0], 0, 0, DImode);
2605 operands[3] = operand_subword (operands[1], 0, 0, DImode);
2606 operands[4] = operand_subword (operands[0], 1, 0, DImode);
2607 operands[5] = operand_subword (operands[1], 1, 0, DImode);
2611 operands[2] = operand_subword (operands[0], 1, 0, DImode);
2612 operands[3] = operand_subword (operands[1], 1, 0, DImode);
2613 operands[4] = operand_subword (operands[0], 0, 0, DImode);
2614 operands[5] = operand_subword (operands[1], 0, 0, DImode);
2617 if (operands[2] == 0 || operands[3] == 0
2618 || operands[4] == 0 || operands[5] == 0)
2622 (define_expand "movdi"
2623 [(set (match_operand:DI 0 "general_movdst_operand" "")
2624 (match_operand:DI 1 "general_movsrc_operand" ""))]
2626 "{ if (prepare_move_operands (operands, DImode)) DONE; }")
2628 ;; ??? This should be a define expand.
2630 (define_insn "movdf_k"
2631 [(set (match_operand:DF 0 "general_movdst_operand" "=r,r,r,m")
2632 (match_operand:DF 1 "general_movsrc_operand" "r,FQ,m,r"))]
2633 "(! TARGET_SH4 || reload_completed
2634 /* ??? We provide some insn so that direct_{load,store}[DFmode] get set */
2635 || (GET_CODE (operands[0]) == REG && REGNO (operands[0]) == 3)
2636 || (GET_CODE (operands[1]) == REG && REGNO (operands[1]) == 3))
2637 && (arith_reg_operand (operands[0], DFmode)
2638 || arith_reg_operand (operands[1], DFmode))"
2639 "* return output_movedouble (insn, operands, DFmode);"
2640 [(set_attr "length" "4")
2641 (set_attr "type" "move,pcload,load,store")])
2643 ;; All alternatives of movdf_i4 are split for ! TARGET_FMOVD.
2644 ;; However, the d/F/c/z alternative cannot be split directly; it is converted
2645 ;; with special code in machine_dependent_reorg into a load of the R0_REG and
2646 ;; the d/m/c/X alternative, which is split later into single-precision
2647 ;; instructions. And when not optimizing, no splits are done before fixing
2648 ;; up pcloads, so we need usable length information for that.
2649 (define_insn "movdf_i4"
2650 [(set (match_operand:DF 0 "general_movdst_operand" "=d,r,d,d,m,r,r,m,!??r,!???d")
2651 (match_operand:DF 1 "general_movsrc_operand" "d,r,F,m,d,FQ,m,r,d,r"))
2652 (use (match_operand:PSI 2 "fpscr_operand" "c,c,c,c,c,c,c,c,c,c"))
2653 (clobber (match_scratch:SI 3 "=X,X,&z,X,X,X,X,X,X,X"))]
2655 && (arith_reg_operand (operands[0], DFmode)
2656 || arith_reg_operand (operands[1], DFmode))"
2668 [(set_attr_alternative "length"
2669 [(if_then_else (eq_attr "fmovd" "yes") (const_int 2) (const_int 4))
2671 (if_then_else (eq_attr "fmovd" "yes") (const_int 4) (const_int 6))
2672 (if_then_else (eq_attr "fmovd" "yes") (const_int 2) (const_int 6))
2673 (if_then_else (eq_attr "fmovd" "yes") (const_int 2) (const_int 6))
2675 (const_int 8) (const_int 8) ;; these need only 8 bytes for @(r0,rn)
2676 (const_int 8) (const_int 8)])
2677 (set_attr "type" "fmove,move,pcload,load,store,pcload,load,store,load,load")
2678 (set (attr "fp_mode") (if_then_else (eq_attr "fmovd" "yes")
2679 (const_string "double")
2680 (const_string "none")))])
2682 ;; Moving DFmode between fp/general registers through memory
2683 ;; (the top of the stack) is faster than moving through fpul even for
2684 ;; little endian. Because the type of an instruction is important for its
2685 ;; scheduling, it is beneficial to split these operations, rather than
2686 ;; emitting them in one single chunk, even if this will expose a stack
2687 ;; use that will prevent scheduling of other stack accesses beyond this
2690 [(set (match_operand:DF 0 "register_operand" "")
2691 (match_operand:DF 1 "register_operand" ""))
2692 (use (match_operand:PSI 2 "fpscr_operand" "c"))
2693 (clobber (match_scratch:SI 3 "=X"))]
2694 "TARGET_SH4 && reload_completed
2695 && (true_regnum (operands[0]) < 16) != (true_regnum (operands[1]) < 16)"
2701 tos = gen_rtx (MEM, DFmode, gen_rtx (PRE_DEC, Pmode, stack_pointer_rtx));
2702 insn = emit_insn (gen_movdf_i4 (tos, operands[1], operands[2]));
2703 REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_INC, stack_pointer_rtx, NULL_RTX);
2704 tos = gen_rtx (MEM, DFmode, gen_rtx (POST_INC, Pmode, stack_pointer_rtx));
2705 insn = emit_insn (gen_movdf_i4 (operands[0], tos, operands[2]));
2706 REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_INC, stack_pointer_rtx, NULL_RTX);
2710 ;; local-alloc sometimes allocates scratch registers even when not required,
2711 ;; so we must be prepared to handle these.
2713 ;; Remove the use and clobber from a movdf_i4 so that we can use movdf_k.
2715 [(set (match_operand:DF 0 "general_movdst_operand" "")
2716 (match_operand:DF 1 "general_movsrc_operand" ""))
2717 (use (match_operand:PSI 2 "fpscr_operand" "c"))
2718 (clobber (match_scratch:SI 3 "X"))]
2721 && true_regnum (operands[0]) < 16
2722 && true_regnum (operands[1]) < 16"
2723 [(set (match_dup 0) (match_dup 1))]
2726 /* If this was a reg <-> mem operation with base + index reg addressing,
2727 we have to handle this in a special way. */
2728 rtx mem = operands[0];
2730 if (! memory_operand (mem, DFmode))
2735 if (GET_CODE (mem) == SUBREG && SUBREG_BYTE (mem) == 0)
2736 mem = SUBREG_REG (mem);
2737 if (GET_CODE (mem) == MEM)
2739 rtx addr = XEXP (mem, 0);
2740 if (GET_CODE (addr) == PLUS
2741 && GET_CODE (XEXP (addr, 0)) == REG
2742 && GET_CODE (XEXP (addr, 1)) == REG)
2745 rtx reg0 = gen_rtx (REG, Pmode, 0);
2746 rtx regop = operands[store_p], word0 ,word1;
2748 if (GET_CODE (regop) == SUBREG)
2749 regop = alter_subreg (regop);
2750 if (REGNO (XEXP (addr, 0)) == REGNO (XEXP (addr, 1)))
2754 mem = copy_rtx (mem);
2755 PUT_MODE (mem, SImode);
2756 word0 = alter_subreg (gen_rtx (SUBREG, SImode, regop, 0));
2757 word1 = alter_subreg (gen_rtx (SUBREG, SImode, regop, 4));
2758 if (store_p || ! refers_to_regno_p (REGNO (word0),
2759 REGNO (word0) + 1, addr, 0))
2762 ? gen_movsi_ie (mem, word0)
2763 : gen_movsi_ie (word0, mem));
2764 emit_insn (gen_addsi3 (reg0, reg0, GEN_INT (offset)));
2765 mem = copy_rtx (mem);
2767 ? gen_movsi_ie (mem, word1)
2768 : gen_movsi_ie (word1, mem));
2769 emit_insn (gen_addsi3 (reg0, reg0, GEN_INT (-offset)));
2773 emit_insn (gen_addsi3 (reg0, reg0, GEN_INT (offset)));
2774 emit_insn (gen_movsi_ie (word1, mem));
2775 emit_insn (gen_addsi3 (reg0, reg0, GEN_INT (-offset)));
2776 mem = copy_rtx (mem);
2777 emit_insn (gen_movsi_ie (word0, mem));
2784 ;; Split away the clobber of r0 after machine_dependent_reorg has fixed pcloads.
2786 [(set (match_operand:DF 0 "register_operand" "")
2787 (match_operand:DF 1 "memory_operand" ""))
2788 (use (match_operand:PSI 2 "fpscr_operand" "c"))
2789 (clobber (reg:SI R0_REG))]
2790 "TARGET_SH4 && reload_completed"
2791 [(parallel [(set (match_dup 0) (match_dup 1))
2793 (clobber (scratch:SI))])]
2796 (define_expand "reload_indf"
2797 [(parallel [(set (match_operand:DF 0 "register_operand" "=f")
2798 (match_operand:DF 1 "immediate_operand" "FQ"))
2799 (use (reg:PSI FPSCR_REG))
2800 (clobber (match_operand:SI 2 "register_operand" "=&z"))])]
2804 (define_expand "reload_outdf"
2805 [(parallel [(set (match_operand:DF 0 "register_operand" "=r,f")
2806 (match_operand:DF 1 "register_operand" "af,r"))
2807 (clobber (match_operand:SI 2 "register_operand" "=&y,y"))])]
2811 ;; Simplify no-op moves.
2813 [(set (match_operand:SF 0 "register_operand" "")
2814 (match_operand:SF 1 "register_operand" ""))
2815 (use (match_operand:PSI 2 "fpscr_operand" ""))
2816 (clobber (match_scratch:SI 3 "X"))]
2817 "TARGET_SH3E && reload_completed
2818 && true_regnum (operands[0]) == true_regnum (operands[1])"
2819 [(set (match_dup 0) (match_dup 0))]
2822 ;; fmovd substitute post-reload splits
2824 [(set (match_operand:DF 0 "register_operand" "")
2825 (match_operand:DF 1 "register_operand" ""))
2826 (use (match_operand:PSI 2 "fpscr_operand" "c"))
2827 (clobber (match_scratch:SI 3 "X"))]
2828 "TARGET_SH4 && ! TARGET_FMOVD && reload_completed
2829 && FP_OR_XD_REGISTER_P (true_regnum (operands[0]))
2830 && FP_OR_XD_REGISTER_P (true_regnum (operands[1]))"
2834 int dst = true_regnum (operands[0]), src = true_regnum (operands[1]);
2835 emit_insn (gen_movsf_ie (gen_rtx (REG, SFmode, dst),
2836 gen_rtx (REG, SFmode, src), operands[2]));
2837 emit_insn (gen_movsf_ie (gen_rtx (REG, SFmode, dst + 1),
2838 gen_rtx (REG, SFmode, src + 1), operands[2]));
2843 [(set (match_operand:DF 0 "register_operand" "")
2844 (mem:DF (match_operand:SI 1 "register_operand" "")))
2845 (use (match_operand:PSI 2 "fpscr_operand" "c"))
2846 (clobber (match_scratch:SI 3 "X"))]
2847 "TARGET_SH4 && ! TARGET_FMOVD && reload_completed
2848 && FP_OR_XD_REGISTER_P (true_regnum (operands[0]))
2849 && find_regno_note (insn, REG_DEAD, true_regnum (operands[1]))"
2853 int regno = true_regnum (operands[0]);
2855 rtx mem2 = gen_rtx (MEM, SFmode, gen_rtx (POST_INC, Pmode, operands[1]));
2857 insn = emit_insn (gen_movsf_ie (gen_rtx (REG, SFmode,
2858 regno + !! TARGET_LITTLE_ENDIAN),
2859 mem2, operands[2]));
2860 REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_INC, operands[1], NULL_RTX);
2861 insn = emit_insn (gen_movsf_ie (gen_rtx (REG, SFmode,
2862 regno + ! TARGET_LITTLE_ENDIAN),
2863 gen_rtx (MEM, SFmode, operands[1]),
2869 [(set (match_operand:DF 0 "register_operand" "")
2870 (match_operand:DF 1 "memory_operand" ""))
2871 (use (match_operand:PSI 2 "fpscr_operand" "c"))
2872 (clobber (match_scratch:SI 3 "X"))]
2873 "TARGET_SH4 && ! TARGET_FMOVD && reload_completed
2874 && FP_OR_XD_REGISTER_P (true_regnum (operands[0]))"
2878 int regno = true_regnum (operands[0]);
2879 rtx addr, insn, adjust = NULL_RTX;
2880 rtx mem2 = copy_rtx (operands[1]);
2881 rtx reg0 = gen_rtx_REG (SFmode, regno + !! TARGET_LITTLE_ENDIAN);
2882 rtx reg1 = gen_rtx_REG (SFmode, regno + ! TARGET_LITTLE_ENDIAN);
2884 PUT_MODE (mem2, SFmode);
2885 operands[1] = copy_rtx (mem2);
2886 addr = XEXP (mem2, 0);
2887 if (GET_CODE (addr) != POST_INC)
2889 /* If we have to modify the stack pointer, the value that we have
2890 read with post-increment might be modified by an interrupt,
2891 so write it back. */
2892 if (REGNO (addr) == STACK_POINTER_REGNUM)
2893 adjust = gen_push_e (reg0);
2895 adjust = gen_addsi3 (addr, addr, GEN_INT (-4));
2896 XEXP (mem2, 0) = addr = gen_rtx_POST_INC (SImode, addr);
2898 addr = XEXP (addr, 0);
2899 insn = emit_insn (gen_movsf_ie (reg0, mem2, operands[2]));
2900 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, addr, NULL_RTX);
2901 insn = emit_insn (gen_movsf_ie (reg1, operands[1], operands[2]));
2905 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, addr, NULL_RTX);
2910 [(set (match_operand:DF 0 "memory_operand" "")
2911 (match_operand:DF 1 "register_operand" ""))
2912 (use (match_operand:PSI 2 "fpscr_operand" "c"))
2913 (clobber (match_scratch:SI 3 "X"))]
2914 "TARGET_SH4 && ! TARGET_FMOVD && reload_completed
2915 && FP_OR_XD_REGISTER_P (true_regnum (operands[1]))"
2919 int regno = true_regnum (operands[1]);
2920 rtx insn, addr, adjust = NULL_RTX;
2922 operands[0] = copy_rtx (operands[0]);
2923 PUT_MODE (operands[0], SFmode);
2924 insn = emit_insn (gen_movsf_ie (operands[0],
2925 gen_rtx (REG, SFmode,
2926 regno + ! TARGET_LITTLE_ENDIAN),
2928 operands[0] = copy_rtx (operands[0]);
2929 addr = XEXP (operands[0], 0);
2930 if (GET_CODE (addr) != PRE_DEC)
2932 adjust = gen_addsi3 (addr, addr, GEN_INT (4));
2933 emit_insn_before (adjust, insn);
2934 XEXP (operands[0], 0) = addr = gen_rtx (PRE_DEC, SImode, addr);
2936 addr = XEXP (addr, 0);
2938 REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_INC, addr, NULL_RTX);
2939 insn = emit_insn (gen_movsf_ie (operands[0],
2940 gen_rtx (REG, SFmode,
2941 regno + !! TARGET_LITTLE_ENDIAN),
2943 REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_INC, addr, NULL_RTX);
2947 ;; If the output is a register and the input is memory or a register, we have
2948 ;; to be careful and see which word needs to be loaded first.
2951 [(set (match_operand:DF 0 "general_movdst_operand" "")
2952 (match_operand:DF 1 "general_movsrc_operand" ""))]
2954 [(set (match_dup 2) (match_dup 3))
2955 (set (match_dup 4) (match_dup 5))]
2960 if ((GET_CODE (operands[0]) == MEM
2961 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2962 || (GET_CODE (operands[1]) == MEM
2963 && GET_CODE (XEXP (operands[1], 0)) == POST_INC))
2966 if (GET_CODE (operands[0]) == REG)
2967 regno = REGNO (operands[0]);
2968 else if (GET_CODE (operands[0]) == SUBREG)
2969 regno = subreg_regno (operands[0]);
2970 else if (GET_CODE (operands[0]) == MEM)
2974 || ! refers_to_regno_p (regno, regno + 1, operands[1], 0))
2976 operands[2] = operand_subword (operands[0], 0, 0, DFmode);
2977 operands[3] = operand_subword (operands[1], 0, 0, DFmode);
2978 operands[4] = operand_subword (operands[0], 1, 0, DFmode);
2979 operands[5] = operand_subword (operands[1], 1, 0, DFmode);
2983 operands[2] = operand_subword (operands[0], 1, 0, DFmode);
2984 operands[3] = operand_subword (operands[1], 1, 0, DFmode);
2985 operands[4] = operand_subword (operands[0], 0, 0, DFmode);
2986 operands[5] = operand_subword (operands[1], 0, 0, DFmode);
2989 if (operands[2] == 0 || operands[3] == 0
2990 || operands[4] == 0 || operands[5] == 0)
2994 ;; If a base address generated by LEGITIMIZE_ADDRESS for SImode is
2995 ;; used only once, let combine add in the index again.
2998 [(set (match_operand:SI 0 "register_operand" "")
2999 (match_operand:SI 1 "" ""))
3000 (clobber (match_operand 2 "register_operand" ""))]
3001 "! reload_in_progress && ! reload_completed"
3002 [(use (reg:SI R0_REG))]
3005 rtx addr, reg, const_int;
3007 if (GET_CODE (operands[1]) != MEM)
3009 addr = XEXP (operands[1], 0);
3010 if (GET_CODE (addr) != PLUS)
3012 reg = XEXP (addr, 0);
3013 const_int = XEXP (addr, 1);
3014 if (! (BASE_REGISTER_RTX_P (reg) && INDEX_REGISTER_RTX_P (operands[2])
3015 && GET_CODE (const_int) == CONST_INT))
3017 emit_move_insn (operands[2], const_int);
3018 emit_move_insn (operands[0],
3019 change_address (operands[1], VOIDmode,
3020 gen_rtx_PLUS (SImode, reg, operands[2])));
3025 [(set (match_operand:SI 1 "" "")
3026 (match_operand:SI 0 "register_operand" ""))
3027 (clobber (match_operand 2 "register_operand" ""))]
3028 "! reload_in_progress && ! reload_completed"
3029 [(use (reg:SI R0_REG))]
3032 rtx addr, reg, const_int;
3034 if (GET_CODE (operands[1]) != MEM)
3036 addr = XEXP (operands[1], 0);
3037 if (GET_CODE (addr) != PLUS)
3039 reg = XEXP (addr, 0);
3040 const_int = XEXP (addr, 1);
3041 if (! (BASE_REGISTER_RTX_P (reg) && INDEX_REGISTER_RTX_P (operands[2])
3042 && GET_CODE (const_int) == CONST_INT))
3044 emit_move_insn (operands[2], const_int);
3045 emit_move_insn (change_address (operands[1], VOIDmode,
3046 gen_rtx_PLUS (SImode, reg, operands[2])),
3051 (define_expand "movdf"
3052 [(set (match_operand:DF 0 "general_movdst_operand" "")
3053 (match_operand:DF 1 "general_movsrc_operand" ""))]
3057 if (prepare_move_operands (operands, DFmode)) DONE;
3060 emit_df_insn (gen_movdf_i4 (operands[0], operands[1], get_fpscr_rtx ()));
3066 (define_insn "movsf_i"
3067 [(set (match_operand:SF 0 "general_movdst_operand" "=r,r,r,r,m,l,r")
3068 (match_operand:SF 1 "general_movsrc_operand" "r,I,FQ,mr,r,r,l"))]
3071 /* ??? We provide some insn so that direct_{load,store}[SFmode] get set */
3072 || (GET_CODE (operands[0]) == REG && REGNO (operands[0]) == 3)
3073 || (GET_CODE (operands[1]) == REG && REGNO (operands[1]) == 3))
3074 && (arith_reg_operand (operands[0], SFmode)
3075 || arith_reg_operand (operands[1], SFmode))"
3084 [(set_attr "type" "move,move,pcload,load,store,move,move")])
3086 ;; We may not split the ry/yr/XX alternatives to movsi_ie, since
3087 ;; update_flow_info would not know where to put REG_EQUAL notes
3088 ;; when the destination changes mode.
3089 (define_insn "movsf_ie"
3090 [(set (match_operand:SF 0 "general_movdst_operand"
3091 "=f,r,f,f,fy,f,m,r,r,m,f,y,y,rf,r,y,<,y,y")
3092 (match_operand:SF 1 "general_movsrc_operand"
3093 "f,r,G,H,FQ,mf,f,FQ,mr,r,y,f,>,fr,y,r,y,>,y"))
3094 (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"))
3095 (clobber (match_scratch:SI 3 "=X,X,X,X,&z,X,X,X,X,X,X,X,X,y,X,X,X,X,X"))]
3098 && (arith_reg_operand (operands[0], SFmode)
3099 || arith_reg_operand (operands[1], SFmode)
3100 || arith_reg_operand (operands[3], SImode)
3101 || (fpul_operand (operands[0], SFmode)
3102 && memory_operand (operands[1], SFmode)
3103 && GET_CODE (XEXP (operands[1], 0)) == POST_INC)
3104 || (fpul_operand (operands[1], SFmode)
3105 && memory_operand (operands[0], SFmode)
3106 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC))"
3126 ! move optimized away"
3127 [(set_attr "type" "fmove,move,fmove,fmove,pcload,load,store,pcload,load,store,fmove,fmove,load,*,gp_fpul,gp_fpul,store,load,nil")
3128 (set_attr "length" "*,*,*,*,4,*,*,*,*,*,2,2,2,4,2,2,2,2,0")
3129 (set (attr "fp_mode") (if_then_else (eq_attr "fmovd" "yes")
3130 (const_string "single")
3131 (const_string "none")))])
3134 [(set (match_operand:SF 0 "register_operand" "")
3135 (match_operand:SF 1 "register_operand" ""))
3136 (use (match_operand:PSI 2 "fpscr_operand" "c"))
3137 (clobber (reg:SI FPUL_REG))]
3139 [(parallel [(set (reg:SF FPUL_REG) (match_dup 1))
3141 (clobber (scratch:SI))])
3142 (parallel [(set (match_dup 0) (reg:SF FPUL_REG))
3144 (clobber (scratch:SI))])]
3147 (define_expand "movsf"
3148 [(set (match_operand:SF 0 "general_movdst_operand" "")
3149 (match_operand:SF 1 "general_movsrc_operand" ""))]
3153 if (prepare_move_operands (operands, SFmode))
3157 emit_sf_insn (gen_movsf_ie (operands[0], operands[1], get_fpscr_rtx ()));
3162 (define_insn "mov_nop"
3163 [(set (match_operand 0 "register_operand" "") (match_dup 0))]
3166 [(set_attr "length" "0")
3167 (set_attr "type" "nil")])
3169 (define_expand "reload_insf"
3170 [(parallel [(set (match_operand:SF 0 "register_operand" "=a")
3171 (match_operand:SF 1 "immediate_operand" "FQ"))
3172 (use (reg:PSI FPSCR_REG))
3173 (clobber (match_operand:SI 2 "register_operand" "=&z"))])]
3177 (define_expand "reload_insi"
3178 [(parallel [(set (match_operand:SF 0 "register_operand" "=y")
3179 (match_operand:SF 1 "immediate_operand" "FQ"))
3180 (clobber (match_operand:SI 2 "register_operand" "=&z"))])]
3184 (define_insn "*movsi_y"
3185 [(set (match_operand:SI 0 "register_operand" "=y,y")
3186 (match_operand:SI 1 "immediate_operand" "Qi,I"))
3187 (clobber (match_scratch:SI 2 "=&z,r"))]
3189 && (reload_in_progress || reload_completed)"
3191 [(set_attr "length" "4")
3192 (set_attr "type" "pcload,move")])
3195 [(set (match_operand:SI 0 "register_operand" "")
3196 (match_operand:SI 1 "immediate_operand" ""))
3197 (clobber (match_operand:SI 2 "register_operand" ""))]
3199 [(set (match_dup 2) (match_dup 1))
3200 (set (match_dup 0) (match_dup 2))]
3204 [(set (match_operand:SI 0 "register_operand" "")
3205 (match_operand:SI 1 "memory_operand" ""))
3206 (clobber (reg:SI R0_REG))]
3208 [(set (match_dup 0) (match_dup 1))]
3211 ;; ------------------------------------------------------------------------
3212 ;; Define the real conditional branch instructions.
3213 ;; ------------------------------------------------------------------------
3215 (define_insn "branch_true"
3216 [(set (pc) (if_then_else (ne (reg:SI T_REG) (const_int 0))
3217 (label_ref (match_operand 0 "" ""))
3220 "* return output_branch (1, insn, operands);"
3221 [(set_attr "type" "cbranch")])
3223 (define_insn "branch_false"
3224 [(set (pc) (if_then_else (eq (reg:SI T_REG) (const_int 0))
3225 (label_ref (match_operand 0 "" ""))
3228 "* return output_branch (0, insn, operands);"
3229 [(set_attr "type" "cbranch")])
3231 ;; Patterns to prevent reorg from re-combining a condbranch with a branch
3232 ;; which destination is too far away.
3233 ;; The const_int_operand is distinct for each branch target; it avoids
3234 ;; unwanted matches with redundant_insn.
3235 (define_insn "block_branch_redirect"
3236 [(set (pc) (unspec [(match_operand 0 "const_int_operand" "")] UNSPEC_BBR))]
3239 [(set_attr "length" "0")])
3241 ;; This one has the additional purpose to record a possible scratch register
3242 ;; for the following branch.
3243 (define_insn "indirect_jump_scratch"
3244 [(set (match_operand 0 "register_operand" "=r")
3245 (unspec [(match_operand 1 "const_int_operand" "")] UNSPEC_BBR))]
3248 [(set_attr "length" "0")])
3250 ;; Conditional branch insns
3252 (define_expand "beq"
3254 (if_then_else (ne (reg:SI T_REG) (const_int 0))
3255 (label_ref (match_operand 0 "" ""))
3258 "from_compare (operands, EQ);")
3260 (define_expand "bne"
3262 (if_then_else (eq (reg:SI T_REG) (const_int 0))
3263 (label_ref (match_operand 0 "" ""))
3266 "from_compare (operands, EQ);")
3268 (define_expand "bgt"
3270 (if_then_else (ne (reg:SI T_REG) (const_int 0))
3271 (label_ref (match_operand 0 "" ""))
3274 "from_compare (operands, GT);")
3276 (define_expand "blt"
3278 (if_then_else (eq (reg:SI T_REG) (const_int 0))
3279 (label_ref (match_operand 0 "" ""))
3284 if (GET_MODE_CLASS (GET_MODE (sh_compare_op0)) == MODE_FLOAT)
3286 rtx tmp = sh_compare_op0;
3287 sh_compare_op0 = sh_compare_op1;
3288 sh_compare_op1 = tmp;
3289 emit_insn (gen_bgt (operands[0]));
3292 from_compare (operands, GE);
3295 (define_expand "ble"
3297 (if_then_else (eq (reg:SI T_REG) (const_int 0))
3298 (label_ref (match_operand 0 "" ""))
3305 && GET_MODE_CLASS (GET_MODE (sh_compare_op0)) == MODE_FLOAT)
3307 rtx tmp = sh_compare_op0;
3308 sh_compare_op0 = sh_compare_op1;
3309 sh_compare_op1 = tmp;
3310 emit_insn (gen_bge (operands[0]));
3313 from_compare (operands, GT);
3316 (define_expand "bge"
3318 (if_then_else (ne (reg:SI T_REG) (const_int 0))
3319 (label_ref (match_operand 0 "" ""))
3326 && GET_MODE_CLASS (GET_MODE (sh_compare_op0)) == MODE_FLOAT)
3328 rtx tmp = sh_compare_op0;
3329 sh_compare_op0 = sh_compare_op1;
3330 sh_compare_op1 = tmp;
3331 emit_insn (gen_ble (operands[0]));
3334 from_compare (operands, GE);
3337 (define_expand "bgtu"
3339 (if_then_else (ne (reg:SI T_REG) (const_int 0))
3340 (label_ref (match_operand 0 "" ""))
3343 "from_compare (operands, GTU); ")
3345 (define_expand "bltu"
3347 (if_then_else (eq (reg:SI T_REG) (const_int 0))
3348 (label_ref (match_operand 0 "" ""))
3351 "from_compare (operands, GEU);")
3353 (define_expand "bgeu"
3355 (if_then_else (ne (reg:SI T_REG) (const_int 0))
3356 (label_ref (match_operand 0 "" ""))
3359 "from_compare (operands, GEU);")
3361 (define_expand "bleu"
3363 (if_then_else (eq (reg:SI T_REG) (const_int 0))
3364 (label_ref (match_operand 0 "" ""))
3367 "from_compare (operands, GTU);")
3369 ;; ------------------------------------------------------------------------
3370 ;; Jump and linkage insns
3371 ;; ------------------------------------------------------------------------
3375 (label_ref (match_operand 0 "" "")))]
3379 /* The length is 16 if the delay slot is unfilled. */
3380 if (get_attr_length(insn) > 4)
3381 return output_far_jump(insn, operands[0]);
3383 return \"bra %l0%#\";
3385 [(set_attr "type" "jump")
3386 (set_attr "needs_delay_slot" "yes")])
3388 (define_insn "calli"
3389 [(call (mem:SI (match_operand:SI 0 "arith_reg_operand" "r"))
3390 (match_operand 1 "" ""))
3391 (use (reg:PSI FPSCR_REG))
3392 (clobber (reg:SI PR_REG))]
3395 [(set_attr "type" "call")
3396 (set (attr "fp_mode")
3397 (if_then_else (eq_attr "fpu_single" "yes")
3398 (const_string "single") (const_string "double")))
3399 (set_attr "needs_delay_slot" "yes")])
3401 ;; This is a pc-rel call, using bsrf, for use with PIC.
3403 (define_insn "calli_pcrel"
3404 [(call (mem:SI (match_operand:SI 0 "arith_reg_operand" "r"))
3405 (match_operand 1 "" ""))
3406 (use (reg:PSI FPSCR_REG))
3407 (use (reg:SI PIC_REG))
3408 (use (match_operand 2 "" ""))
3409 (clobber (reg:SI PR_REG))]
3412 [(set_attr "type" "call")
3413 (set (attr "fp_mode")
3414 (if_then_else (eq_attr "fpu_single" "yes")
3415 (const_string "single") (const_string "double")))
3416 (set_attr "needs_delay_slot" "yes")])
3418 (define_insn_and_split "call_pcrel"
3419 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" ""))
3420 (match_operand 1 "" ""))
3421 (use (reg:PSI FPSCR_REG))
3422 (use (reg:SI PIC_REG))
3423 (clobber (reg:SI PR_REG))
3424 (clobber (match_scratch:SI 2 "=r"))]
3431 rtx lab = gen_call_site ();
3433 if (SYMBOL_REF_FLAG (operands[0]))
3434 emit_insn (gen_sym_label2reg (operands[2], operands[0], lab));
3436 emit_insn (gen_symPLT_label2reg (operands[2], operands[0], lab));
3437 emit_call_insn (gen_calli_pcrel (operands[2], operands[1], lab));
3440 [(set_attr "type" "call")
3441 (set (attr "fp_mode")
3442 (if_then_else (eq_attr "fpu_single" "yes")
3443 (const_string "single") (const_string "double")))
3444 (set_attr "needs_delay_slot" "yes")])
3446 (define_insn "call_valuei"
3447 [(set (match_operand 0 "" "=rf")
3448 (call (mem:SI (match_operand:SI 1 "arith_reg_operand" "r"))
3449 (match_operand 2 "" "")))
3450 (use (reg:PSI FPSCR_REG))
3451 (clobber (reg:SI PR_REG))]
3454 [(set_attr "type" "call")
3455 (set (attr "fp_mode")
3456 (if_then_else (eq_attr "fpu_single" "yes")
3457 (const_string "single") (const_string "double")))
3458 (set_attr "needs_delay_slot" "yes")])
3460 (define_insn "call_valuei_pcrel"
3461 [(set (match_operand 0 "" "=rf")
3462 (call (mem:SI (match_operand:SI 1 "arith_reg_operand" "r"))
3463 (match_operand 2 "" "")))
3464 (use (reg:PSI FPSCR_REG))
3465 (use (reg:SI PIC_REG))
3466 (use (match_operand 3 "" ""))
3467 (clobber (reg:SI PR_REG))]
3470 [(set_attr "type" "call")
3471 (set (attr "fp_mode")
3472 (if_then_else (eq_attr "fpu_single" "yes")
3473 (const_string "single") (const_string "double")))
3474 (set_attr "needs_delay_slot" "yes")])
3476 (define_insn_and_split "call_value_pcrel"
3477 [(set (match_operand 0 "" "=rf")
3478 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" ""))
3479 (match_operand 2 "" "")))
3480 (use (reg:PSI FPSCR_REG))
3481 (use (reg:SI PIC_REG))
3482 (clobber (reg:SI PR_REG))
3483 (clobber (match_scratch:SI 3 "=r"))]
3490 rtx lab = gen_call_site ();
3492 if (SYMBOL_REF_FLAG (operands[1]))
3493 emit_insn (gen_sym_label2reg (operands[3], operands[1], lab));
3495 emit_insn (gen_symPLT_label2reg (operands[3], operands[1], lab));
3496 emit_call_insn (gen_call_valuei_pcrel (operands[0], operands[3],
3500 [(set_attr "type" "call")
3501 (set (attr "fp_mode")
3502 (if_then_else (eq_attr "fpu_single" "yes")
3503 (const_string "single") (const_string "double")))
3504 (set_attr "needs_delay_slot" "yes")])
3506 (define_expand "call"
3507 [(parallel [(call (mem:SI (match_operand 0 "arith_reg_operand" ""))
3508 (match_operand 1 "" ""))
3509 (use (reg:PSI FPSCR_REG))
3510 (clobber (reg:SI PR_REG))])]
3514 if (flag_pic && TARGET_SH2
3515 && GET_CODE (operands[0]) == MEM
3516 && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF)
3518 emit_call_insn (gen_call_pcrel (XEXP (operands[0], 0), operands[1]));
3522 operands[0] = force_reg (SImode, XEXP (operands[0], 0));
3525 (define_expand "call_value"
3526 [(parallel [(set (match_operand 0 "arith_reg_operand" "")
3527 (call (mem:SI (match_operand 1 "arith_reg_operand" ""))
3528 (match_operand 2 "" "")))
3529 (use (reg:PSI FPSCR_REG))
3530 (clobber (reg:SI PR_REG))])]
3534 if (flag_pic && TARGET_SH2
3535 && GET_CODE (operands[1]) == MEM
3536 && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
3538 emit_call_insn (gen_call_value_pcrel (operands[0], XEXP (operands[1], 0),
3543 operands[1] = force_reg (SImode, XEXP (operands[1], 0));
3546 (define_insn "sibcalli"
3547 [(call (mem:SI (match_operand:SI 0 "register_operand" "k"))
3548 (match_operand 1 "" ""))
3549 (use (reg:PSI FPSCR_REG))
3553 [(set_attr "needs_delay_slot" "yes")
3554 (set (attr "fp_mode")
3555 (if_then_else (eq_attr "fpu_single" "yes")
3556 (const_string "single") (const_string "double")))
3557 (set_attr "type" "jump_ind")])
3559 (define_insn "sibcalli_pcrel"
3560 [(call (mem:SI (match_operand:SI 0 "arith_reg_operand" "k"))
3561 (match_operand 1 "" ""))
3562 (use (match_operand 2 "" ""))
3563 (use (reg:PSI FPSCR_REG))
3567 [(set_attr "needs_delay_slot" "yes")
3568 (set (attr "fp_mode")
3569 (if_then_else (eq_attr "fpu_single" "yes")
3570 (const_string "single") (const_string "double")))
3571 (set_attr "type" "jump_ind")])
3573 (define_insn_and_split "sibcall_pcrel"
3574 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" ""))
3575 (match_operand 1 "" ""))
3576 (use (reg:PSI FPSCR_REG))
3577 (clobber (match_scratch:SI 2 "=k"))
3585 rtx lab = gen_call_site ();
3588 emit_insn (gen_sym_label2reg (operands[2], operands[0], lab));
3589 call_insn = emit_call_insn (gen_sibcalli_pcrel (operands[2], operands[1],
3591 SIBLING_CALL_P (call_insn) = 1;
3594 [(set_attr "needs_delay_slot" "yes")
3595 (set (attr "fp_mode")
3596 (if_then_else (eq_attr "fpu_single" "yes")
3597 (const_string "single") (const_string "double")))
3598 (set_attr "type" "jump_ind")])
3600 (define_expand "sibcall"
3602 [(call (mem:SI (match_operand 0 "arith_reg_operand" ""))
3603 (match_operand 1 "" ""))
3604 (use (reg:PSI FPSCR_REG))
3609 if (flag_pic && TARGET_SH2
3610 && GET_CODE (operands[0]) == MEM
3611 && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
3612 /* The PLT needs the PIC register, but the epilogue would have
3613 to restore it, so we can only use PC-relative PIC calls for
3614 static functions. */
3615 && SYMBOL_REF_FLAG (XEXP (operands[0], 0)))
3617 emit_call_insn (gen_sibcall_pcrel (XEXP (operands[0], 0), operands[1]));
3621 operands[0] = force_reg (SImode, XEXP (operands[0], 0));
3624 (define_expand "sibcall_value"
3625 [(set (match_operand 0 "" "")
3626 (call (match_operand 1 "" "")
3627 (match_operand 2 "" "")))]
3631 emit_call_insn (gen_sibcall (operands[1], operands[2]));
3635 (define_expand "sibcall_epilogue"
3640 sh_expand_epilogue ();
3644 (define_insn "indirect_jump"
3646 (match_operand:SI 0 "arith_reg_operand" "r"))]
3649 [(set_attr "needs_delay_slot" "yes")
3650 (set_attr "type" "jump_ind")])
3652 ;; The use of operand 1 / 2 helps us distinguish case table jumps
3653 ;; which can be present in structured code from indirect jumps which can not
3654 ;; be present in structured code. This allows -fprofile-arcs to work.
3656 ;; For SH1 processors.
3657 (define_insn "casesi_jump_1"
3659 (match_operand:SI 0 "register_operand" "r"))
3660 (use (label_ref (match_operand 1 "" "")))]
3663 [(set_attr "needs_delay_slot" "yes")
3664 (set_attr "type" "jump_ind")])
3666 ;; For all later processors.
3667 (define_insn "casesi_jump_2"
3668 [(set (pc) (plus:SI (match_operand:SI 0 "register_operand" "r")
3669 (label_ref (match_operand 1 "" ""))))
3670 (use (label_ref (match_operand 2 "" "")))]
3672 && (! INSN_UID (operands[1]) || prev_real_insn (operands[1]) == insn)"
3674 [(set_attr "needs_delay_slot" "yes")
3675 (set_attr "type" "jump_ind")])
3677 ;; Call subroutine returning any type.
3678 ;; ??? This probably doesn't work.
3680 (define_expand "untyped_call"
3681 [(parallel [(call (match_operand 0 "" "")
3683 (match_operand 1 "" "")
3684 (match_operand 2 "" "")])]
3690 emit_call_insn (gen_call (operands[0], const0_rtx));
3692 for (i = 0; i < XVECLEN (operands[2], 0); i++)
3694 rtx set = XVECEXP (operands[2], 0, i);
3695 emit_move_insn (SET_DEST (set), SET_SRC (set));
3698 /* The optimizer does not know that the call sets the function value
3699 registers we stored in the result block. We avoid problems by
3700 claiming that all hard registers are used and clobbered at this
3702 emit_insn (gen_blockage ());
3707 ;; ------------------------------------------------------------------------
3709 ;; ------------------------------------------------------------------------
3712 [(set (reg:SI T_REG)
3713 (eq:SI (match_operand:SI 0 "arith_reg_operand" "+r") (const_int 1)))
3714 (set (match_dup 0) (plus:SI (match_dup 0) (const_int -1)))]
3717 [(set_attr "type" "arith")])
3724 ;; Load address of a label. This is only generated by the casesi expand,
3725 ;; and by machine_dependent_reorg (fixing up fp moves).
3726 ;; This must use unspec, because this only works for labels that are
3730 [(set (reg:SI R0_REG)
3731 (unspec [(label_ref (match_operand 0 "" ""))] UNSPEC_MOVA))]
3734 [(set_attr "in_delay_slot" "no")
3735 (set_attr "type" "arith")])
3737 ;; machine_dependent_reorg() will make this a `mova'.
3738 (define_insn "mova_const"
3739 [(set (reg:SI R0_REG)
3740 (unspec [(match_operand 0 "immediate_operand" "i")] UNSPEC_MOVA))]
3743 [(set_attr "in_delay_slot" "no")
3744 (set_attr "type" "arith")])
3746 (define_expand "GOTaddr2picreg"
3747 [(set (reg:SI R0_REG)
3748 (unspec [(const (unspec [(match_dup 1)] UNSPEC_PIC))]
3750 (set (match_dup 0) (const (unspec [(match_dup 1)] UNSPEC_PIC)))
3751 (set (match_dup 0) (plus:SI (match_dup 0) (reg:SI R0_REG)))]
3754 operands[0] = pic_offset_table_rtx;
3755 operands[1] = gen_rtx_SYMBOL_REF (VOIDmode, GOT_SYMBOL_NAME);
3759 (define_expand "builtin_setjmp_receiver"
3760 [(match_operand 0 "" "")]
3764 emit_insn (gen_GOTaddr2picreg ());
3768 (define_expand "call_site"
3769 [(unspec [(match_dup 0)] UNSPEC_CALLER)]
3773 static HOST_WIDE_INT i = 0;
3774 operands[0] = GEN_INT (i);
3778 (define_expand "sym_label2reg"
3779 [(set (match_operand:SI 0 "" "")
3781 (const (unspec [(match_operand:SI 1 "" "")] UNSPEC_PIC))
3783 (match_operand:SI 2 "" "")
3787 (define_expand "symGOT2reg"
3788 [(set (match_operand:SI 0 "" "")
3789 (const (unspec [(match_operand:SI 1 "" "")] UNSPEC_GOT)))
3790 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
3791 (set (match_dup 0) (mem:SI (match_dup 0)))]
3795 operands[2] = pic_offset_table_rtx;
3798 (define_expand "symGOTOFF2reg"
3799 [(set (match_operand:SI 0 "" "")
3800 (const (unspec [(match_operand:SI 1 "" "")] UNSPEC_GOTOFF)))
3801 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]
3805 operands[2] = pic_offset_table_rtx;
3808 (define_expand "symPLT_label2reg"
3809 [(set (match_operand:SI 0 "" "")
3812 (unspec [(match_operand:SI 1 "" "")] UNSPEC_PLT)
3815 (match_operand:SI 2 "" "")
3817 ;; Even though the PIC register is not really used by the call
3818 ;; sequence in which this is expanded, the PLT code assumes the PIC
3819 ;; register is set, so we must not skip its initialization. Since
3820 ;; we only use this expand as part of calling sequences, and never
3821 ;; to take the address of a function, this is the best point to
3822 ;; insert the (use). Using the PLT to take the address of a
3823 ;; function would be wrong, not only because the PLT entry could
3824 ;; then be called from a function that doesn't initialize the PIC
3825 ;; register to the proper GOT, but also because pointers to the
3826 ;; same function might not compare equal, should they be set by
3827 ;; different shared libraries.
3828 (use (reg:SI PIC_REG))]
3832 ;; case instruction for switch statements.
3834 ;; Operand 0 is index
3835 ;; operand 1 is the minimum bound
3836 ;; operand 2 is the maximum bound - minimum bound + 1
3837 ;; operand 3 is CODE_LABEL for the table;
3838 ;; operand 4 is the CODE_LABEL to go to if index out of range.
3840 (define_expand "casesi"
3841 [(match_operand:SI 0 "arith_reg_operand" "")
3842 (match_operand:SI 1 "arith_reg_operand" "")
3843 (match_operand:SI 2 "arith_reg_operand" "")
3844 (match_operand 3 "" "") (match_operand 4 "" "")]
3848 rtx reg = gen_reg_rtx (SImode);
3849 rtx reg2 = gen_reg_rtx (SImode);
3850 operands[1] = copy_to_mode_reg (SImode, operands[1]);
3851 operands[2] = copy_to_mode_reg (SImode, operands[2]);
3852 /* If optimizing, casesi_worker depends on the mode of the instruction
3853 before label it 'uses' - operands[3]. */
3854 emit_insn (gen_casesi_0 (operands[0], operands[1], operands[2], operands[4],
3856 emit_insn (gen_casesi_worker_0 (reg2, reg, operands[3]));
3858 emit_jump_insn (gen_casesi_jump_2 (reg2, gen_label_rtx (), operands[3]));
3860 emit_jump_insn (gen_casesi_jump_1 (reg2, operands[3]));
3861 /* For SH2 and newer, the ADDR_DIFF_VEC is not actually relative to
3862 operands[3], but to lab. We will fix this up in
3863 machine_dependent_reorg. */
3868 (define_expand "casesi_0"
3869 [(set (match_operand:SI 4 "" "") (match_operand:SI 0 "arith_reg_operand" ""))
3870 (set (match_dup 4) (minus:SI (match_dup 4)
3871 (match_operand:SI 1 "arith_operand" "")))
3873 (gtu:SI (match_dup 4)
3874 (match_operand:SI 2 "arith_reg_operand" "")))
3876 (if_then_else (ne (reg:SI T_REG)
3878 (label_ref (match_operand 3 "" ""))
3883 ;; ??? reload might clobber r0 if we use it explicitly in the RTL before
3884 ;; reload; using a R0_REGS pseudo reg is likely to give poor code.
3885 ;; So we keep the use of r0 hidden in a R0_REGS clobber until after reload.
3887 (define_insn "casesi_worker_0"
3888 [(set (match_operand:SI 0 "register_operand" "=r,r")
3889 (unspec [(match_operand 1 "register_operand" "0,r")
3890 (label_ref (match_operand 2 "" ""))] UNSPEC_CASESI))
3891 (clobber (match_scratch:SI 3 "=X,1"))
3892 (clobber (match_scratch:SI 4 "=&z,z"))]
3897 [(set (match_operand:SI 0 "register_operand" "")
3898 (unspec [(match_operand 1 "register_operand" "")
3899 (label_ref (match_operand 2 "" ""))] UNSPEC_CASESI))
3900 (clobber (match_scratch:SI 3 ""))
3901 (clobber (match_scratch:SI 4 ""))]
3902 "! TARGET_SH2 && reload_completed"
3903 [(set (reg:SI R0_REG) (unspec [(label_ref (match_dup 2))] UNSPEC_MOVA))
3904 (parallel [(set (match_dup 0)
3905 (unspec [(reg:SI R0_REG) (match_dup 1)
3906 (label_ref (match_dup 2))] UNSPEC_CASESI))
3907 (clobber (match_dup 3))])
3908 (set (match_dup 0) (plus:SI (match_dup 0) (reg:SI R0_REG)))]
3909 "LABEL_NUSES (operands[2])++;")
3912 [(set (match_operand:SI 0 "register_operand" "")
3913 (unspec [(match_operand 1 "register_operand" "")
3914 (label_ref (match_operand 2 "" ""))] UNSPEC_CASESI))
3915 (clobber (match_scratch:SI 3 ""))
3916 (clobber (match_scratch:SI 4 ""))]
3917 "TARGET_SH2 && reload_completed"
3918 [(set (reg:SI R0_REG) (unspec [(label_ref (match_dup 2))] UNSPEC_MOVA))
3919 (parallel [(set (match_dup 0)
3920 (unspec [(reg:SI R0_REG) (match_dup 1)
3921 (label_ref (match_dup 2))] UNSPEC_CASESI))
3922 (clobber (match_dup 3))])]
3923 "LABEL_NUSES (operands[2])++;")
3925 (define_insn "*casesi_worker"
3926 [(set (match_operand:SI 0 "register_operand" "=r,r")
3927 (unspec [(reg:SI R0_REG) (match_operand 1 "register_operand" "0,r")
3928 (label_ref (match_operand 2 "" ""))] UNSPEC_CASESI))
3929 (clobber (match_scratch:SI 3 "=X,1"))]
3933 rtx diff_vec = PATTERN (next_real_insn (operands[2]));
3935 if (GET_CODE (diff_vec) != ADDR_DIFF_VEC)
3938 switch (GET_MODE (diff_vec))
3941 return \"shll2 %1\;mov.l @(r0,%1),%0\";
3943 return \"add %1,%1\;mov.w @(r0,%1),%0\";
3945 if (ADDR_DIFF_VEC_FLAGS (diff_vec).offset_unsigned)
3946 return \"mov.b @(r0,%1),%0\;extu.b %0,%0\";
3947 return \"mov.b @(r0,%1),%0\";
3952 [(set_attr "length" "4")])
3954 (define_expand "return"
3956 "reload_completed && ! sh_need_epilogue ()"
3959 (define_insn "*return_i"
3963 [(set_attr "type" "return")
3964 (set_attr "needs_delay_slot" "yes")])
3966 (define_expand "prologue"
3969 "sh_expand_prologue (); DONE;")
3971 (define_expand "epilogue"
3974 "sh_expand_epilogue ();")
3976 (define_insn "blockage"
3977 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
3980 [(set_attr "length" "0")])
3982 ;; ------------------------------------------------------------------------
3984 ;; ------------------------------------------------------------------------
3987 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
3988 (eq:SI (reg:SI T_REG) (const_int 1)))]
3991 [(set_attr "type" "arith")])
3993 (define_expand "seq"
3994 [(set (match_operand:SI 0 "arith_reg_operand" "")
3997 "operands[1] = prepare_scc_operands (EQ);")
3999 (define_expand "slt"
4000 [(set (match_operand:SI 0 "arith_reg_operand" "")
4003 "operands[1] = prepare_scc_operands (LT);")
4005 (define_expand "sle"
4006 [(match_operand:SI 0 "arith_reg_operand" "")]
4010 rtx tmp = sh_compare_op0;
4011 sh_compare_op0 = sh_compare_op1;
4012 sh_compare_op1 = tmp;
4013 emit_insn (gen_sge (operands[0]));
4017 (define_expand "sgt"
4018 [(set (match_operand:SI 0 "arith_reg_operand" "")
4021 "operands[1] = prepare_scc_operands (GT);")
4023 (define_expand "sge"
4024 [(set (match_operand:SI 0 "arith_reg_operand" "")
4029 if (GET_MODE_CLASS (GET_MODE (sh_compare_op0)) == MODE_FLOAT)
4033 rtx lab = gen_label_rtx ();
4034 prepare_scc_operands (EQ);
4035 emit_jump_insn (gen_branch_true (lab));
4036 prepare_scc_operands (GT);
4038 emit_insn (gen_movt (operands[0]));
4041 emit_insn (gen_movnegt (operands[0], prepare_scc_operands (LT)));
4044 operands[1] = prepare_scc_operands (GE);
4047 (define_expand "sgtu"
4048 [(set (match_operand:SI 0 "arith_reg_operand" "")
4051 "operands[1] = prepare_scc_operands (GTU);")
4053 (define_expand "sltu"
4054 [(set (match_operand:SI 0 "arith_reg_operand" "")
4057 "operands[1] = prepare_scc_operands (LTU);")
4059 (define_expand "sleu"
4060 [(set (match_operand:SI 0 "arith_reg_operand" "")
4063 "operands[1] = prepare_scc_operands (LEU);")
4065 (define_expand "sgeu"
4066 [(set (match_operand:SI 0 "arith_reg_operand" "")
4069 "operands[1] = prepare_scc_operands (GEU);")
4071 ;; sne moves the complement of the T reg to DEST like this:
4075 ;; This is better than xoring compare result with 1 because it does
4076 ;; not require r0 and further, the -1 may be CSE-ed or lifted out of a
4079 (define_expand "sne"
4080 [(set (match_dup 2) (const_int -1))
4081 (parallel [(set (match_operand:SI 0 "arith_reg_operand" "")
4082 (neg:SI (plus:SI (match_dup 1)
4085 (ne:SI (ior:SI (match_dup 1) (match_dup 2))
4090 operands[1] = prepare_scc_operands (EQ);
4091 operands[2] = gen_reg_rtx (SImode);
4094 ;; Use the same trick for FP sle / sge
4095 (define_expand "movnegt"
4096 [(set (match_dup 2) (const_int -1))
4097 (parallel [(set (match_operand 0 "" "")
4098 (neg:SI (plus:SI (match_dup 1)
4101 (ne:SI (ior:SI (match_operand 1 "" "") (match_dup 2))
4104 "operands[2] = gen_reg_rtx (SImode);")
4106 ;; Recognize mov #-1/negc/neg sequence, and change it to movt/add #-1.
4107 ;; This prevents a regression that occurred when we switched from xor to
4111 [(set (match_operand:SI 0 "arith_reg_operand" "")
4112 (plus:SI (reg:SI T_REG)
4115 [(set (match_dup 0) (eq:SI (reg:SI T_REG) (const_int 1)))
4116 (set (match_dup 0) (plus:SI (match_dup 0) (const_int -1)))]
4119 ;; -------------------------------------------------------------------------
4120 ;; Instructions to cope with inline literal tables
4121 ;; -------------------------------------------------------------------------
4123 ; 2 byte integer in line
4125 (define_insn "consttable_2"
4126 [(unspec_volatile [(match_operand:SI 0 "general_operand" "=g")
4127 (match_operand 1 "" "")]
4132 if (operands[1] != const0_rtx)
4133 assemble_integer (operands[0], 2, 1);
4136 [(set_attr "length" "2")
4137 (set_attr "in_delay_slot" "no")])
4139 ; 4 byte integer in line
4141 (define_insn "consttable_4"
4142 [(unspec_volatile [(match_operand:SI 0 "general_operand" "=g")
4143 (match_operand 1 "" "")]
4148 if (operands[1] != const0_rtx)
4149 assemble_integer (operands[0], 4, 1);
4152 [(set_attr "length" "4")
4153 (set_attr "in_delay_slot" "no")])
4155 ; 8 byte integer in line
4157 (define_insn "consttable_8"
4158 [(unspec_volatile [(match_operand:SI 0 "general_operand" "=g")
4159 (match_operand 1 "" "")]
4164 if (operands[1] != const0_rtx)
4165 assemble_integer (operands[0], 8, 1);
4168 [(set_attr "length" "8")
4169 (set_attr "in_delay_slot" "no")])
4171 ; 4 byte floating point
4173 (define_insn "consttable_sf"
4174 [(unspec_volatile [(match_operand:SF 0 "general_operand" "=g")
4175 (match_operand 1 "" "")]
4180 if (operands[1] != const0_rtx)
4182 union real_extract u;
4183 memcpy (&u, &CONST_DOUBLE_LOW (operands[0]), sizeof u);
4184 assemble_real (u.d, SFmode);
4188 [(set_attr "length" "4")
4189 (set_attr "in_delay_slot" "no")])
4191 ; 8 byte floating point
4193 (define_insn "consttable_df"
4194 [(unspec_volatile [(match_operand:DF 0 "general_operand" "=g")
4195 (match_operand 1 "" "")]
4200 if (operands[1] != const0_rtx)
4202 union real_extract u;
4203 memcpy (&u, &CONST_DOUBLE_LOW (operands[0]), sizeof u);
4204 assemble_real (u.d, DFmode);
4208 [(set_attr "length" "8")
4209 (set_attr "in_delay_slot" "no")])
4211 ;; Alignment is needed for some constant tables; it may also be added for
4212 ;; Instructions at the start of loops, or after unconditional branches.
4213 ;; ??? We would get more accurate lengths if we did instruction
4214 ;; alignment based on the value of INSN_CURRENT_ADDRESS; the approach used
4215 ;; here is too conservative.
4217 ; align to a two byte boundary
4219 (define_expand "align_2"
4220 [(unspec_volatile [(const_int 1)] UNSPECV_ALIGN)]
4224 ; align to a four byte boundary
4225 ;; align_4 and align_log are instructions for the starts of loops, or
4226 ;; after unconditional branches, which may take up extra room.
4228 (define_expand "align_4"
4229 [(unspec_volatile [(const_int 2)] UNSPECV_ALIGN)]
4233 ; align to a cache line boundary
4235 (define_insn "align_log"
4236 [(unspec_volatile [(match_operand 0 "const_int_operand" "")] UNSPECV_ALIGN)]
4239 [(set_attr "length" "0")
4240 (set_attr "in_delay_slot" "no")])
4242 ; emitted at the end of the literal table, used to emit the
4243 ; 32bit branch labels if needed.
4245 (define_insn "consttable_end"
4246 [(unspec_volatile [(const_int 0)] UNSPECV_CONST_END)]
4248 "* return output_jump_label_table ();"
4249 [(set_attr "in_delay_slot" "no")])
4251 ; emitted at the end of the window in the literal table.
4253 (define_insn "consttable_window_end"
4254 [(unspec_volatile [(match_operand 0 "" "")] UNSPECV_WINDOW_END)]
4257 [(set_attr "length" "0")
4258 (set_attr "in_delay_slot" "no")])
4260 ;; -------------------------------------------------------------------------
4262 ;; -------------------------------------------------------------------------
4264 ;; String/block move insn.
4266 (define_expand "movstrsi"
4267 [(parallel [(set (mem:BLK (match_operand:BLK 0 "" ""))
4268 (mem:BLK (match_operand:BLK 1 "" "")))
4269 (use (match_operand:SI 2 "nonmemory_operand" ""))
4270 (use (match_operand:SI 3 "immediate_operand" ""))
4271 (clobber (reg:SI PR_REG))
4272 (clobber (reg:SI R4_REG))
4273 (clobber (reg:SI R5_REG))
4274 (clobber (reg:SI R0_REG))])]
4278 if(expand_block_move (operands))
4283 (define_insn "block_move_real"
4284 [(parallel [(set (mem:BLK (reg:SI R4_REG))
4285 (mem:BLK (reg:SI R5_REG)))
4286 (use (match_operand:SI 0 "arith_reg_operand" "r"))
4287 (clobber (reg:SI PR_REG))
4288 (clobber (reg:SI R0_REG))])]
4291 [(set_attr "type" "sfunc")
4292 (set_attr "needs_delay_slot" "yes")])
4294 (define_insn "block_lump_real"
4295 [(parallel [(set (mem:BLK (reg:SI R4_REG))
4296 (mem:BLK (reg:SI R5_REG)))
4297 (use (match_operand:SI 0 "arith_reg_operand" "r"))
4298 (use (reg:SI R6_REG))
4299 (clobber (reg:SI PR_REG))
4300 (clobber (reg:SI T_REG))
4301 (clobber (reg:SI R4_REG))
4302 (clobber (reg:SI R5_REG))
4303 (clobber (reg:SI R6_REG))
4304 (clobber (reg:SI R0_REG))])]
4307 [(set_attr "type" "sfunc")
4308 (set_attr "needs_delay_slot" "yes")])
4310 (define_insn "block_move_real_i4"
4311 [(parallel [(set (mem:BLK (reg:SI R4_REG))
4312 (mem:BLK (reg:SI R5_REG)))
4313 (use (match_operand:SI 0 "arith_reg_operand" "r"))
4314 (clobber (reg:SI PR_REG))
4315 (clobber (reg:SI R0_REG))
4316 (clobber (reg:SI R1_REG))
4317 (clobber (reg:SI R2_REG))])]
4320 [(set_attr "type" "sfunc")
4321 (set_attr "needs_delay_slot" "yes")])
4323 (define_insn "block_lump_real_i4"
4324 [(parallel [(set (mem:BLK (reg:SI R4_REG))
4325 (mem:BLK (reg:SI R5_REG)))
4326 (use (match_operand:SI 0 "arith_reg_operand" "r"))
4327 (use (reg:SI R6_REG))
4328 (clobber (reg:SI PR_REG))
4329 (clobber (reg:SI T_REG))
4330 (clobber (reg:SI R4_REG))
4331 (clobber (reg:SI R5_REG))
4332 (clobber (reg:SI R6_REG))
4333 (clobber (reg:SI R0_REG))
4334 (clobber (reg:SI R1_REG))
4335 (clobber (reg:SI R2_REG))
4336 (clobber (reg:SI R3_REG))])]
4339 [(set_attr "type" "sfunc")
4340 (set_attr "needs_delay_slot" "yes")])
4342 ;; -------------------------------------------------------------------------
4343 ;; Floating point instructions.
4344 ;; -------------------------------------------------------------------------
4346 ;; ??? All patterns should have a type attribute.
4348 (define_expand "fpu_switch0"
4349 [(set (match_operand:SI 0 "" "") (match_dup 2))
4350 (set (match_dup 1) (mem:PSI (match_dup 0)))]
4354 operands[1] = get_fpscr_rtx ();
4355 operands[2] = gen_rtx_SYMBOL_REF (SImode, \"__fpscr_values\");
4357 operands[2] = legitimize_pic_address (operands[2], SImode,
4358 no_new_pseudos ? operands[0] : 0);
4361 (define_expand "fpu_switch1"
4362 [(set (match_operand:SI 0 "" "") (match_dup 2))
4363 (set (match_dup 3) (plus:SI (match_dup 0) (const_int 4)))
4364 (set (match_dup 1) (mem:PSI (match_dup 3)))]
4368 operands[1] = get_fpscr_rtx ();
4369 operands[2] = gen_rtx_SYMBOL_REF (SImode, \"__fpscr_values\");
4371 operands[2] = legitimize_pic_address (operands[2], SImode,
4372 no_new_pseudos ? operands[0] : 0);
4373 operands[3] = no_new_pseudos ? operands[0] : gen_reg_rtx (SImode);
4376 (define_expand "movpsi"
4377 [(set (match_operand:PSI 0 "register_operand" "")
4378 (match_operand:PSI 1 "general_movsrc_operand" ""))]
4382 ;; The c / m alternative is a fake to guide reload to load directly into
4383 ;; fpscr, since reload doesn't know how to use post-increment.
4384 ;; GO_IF_LEGITIMATE_ADDRESS guards about bogus addresses before reload,
4385 ;; SECONDARY_INPUT_RELOAD_CLASS does this during reload, and the insn's
4386 ;; predicate after reload.
4387 ;; The gp_fpul type for r/!c might look a bit odd, but it actually schedules
4388 ;; like a gpr <-> fpul move.
4389 (define_insn "fpu_switch"
4390 [(set (match_operand:PSI 0 "register_operand" "=c,c,r,c,c,r,m,r")
4391 (match_operand:PSI 1 "general_movsrc_operand" "c,>,m,m,r,r,r,!c"))]
4393 && (! reload_completed
4394 || true_regnum (operands[0]) != FPSCR_REG
4395 || GET_CODE (operands[1]) != MEM
4396 || GET_CODE (XEXP (operands[1], 0)) != PLUS)"
4398 ! precision stays the same
4406 [(set_attr "length" "0,2,2,4,2,2,2,2")
4407 (set_attr "type" "dfp_conv,dfp_conv,load,dfp_conv,dfp_conv,move,store,gp_fpul")])
4410 [(set (reg:PSI FPSCR_REG)
4411 (mem:PSI (match_operand:SI 0 "register_operand" "r")))]
4412 "TARGET_SH4 && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
4413 [(set (match_dup 0) (match_dup 0))]
4416 rtx insn = emit_insn (gen_fpu_switch (get_fpscr_rtx (),
4417 gen_rtx (MEM, PSImode,
4418 gen_rtx (POST_INC, Pmode,
4420 REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_INC, operands[0], NULL_RTX);
4424 [(set (reg:PSI FPSCR_REG)
4425 (mem:PSI (match_operand:SI 0 "register_operand" "r")))]
4427 [(set (match_dup 0) (plus:SI (match_dup 0) (const_int -4)))]
4430 rtx insn = emit_insn (gen_fpu_switch (get_fpscr_rtx (),
4431 gen_rtx (MEM, PSImode,
4432 gen_rtx (POST_INC, Pmode,
4434 REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_INC, operands[0], NULL_RTX);
4437 ;; ??? This uses the fp unit, but has no type indicating that.
4438 ;; If we did that, this would either give a bogus latency or introduce
4439 ;; a bogus FIFO constraint.
4440 ;; Since this insn is currently only used for prologues/epilogues,
4441 ;; it is probably best to claim no function unit, which matches the
4443 (define_insn "toggle_sz"
4444 [(set (reg:PSI FPSCR_REG)
4445 (xor:PSI (reg:PSI FPSCR_REG) (const_int 1048576)))]
4449 (define_expand "addsf3"
4450 [(match_operand:SF 0 "arith_reg_operand" "")
4451 (match_operand:SF 1 "arith_reg_operand" "")
4452 (match_operand:SF 2 "arith_reg_operand" "")]
4454 "{ expand_sf_binop (&gen_addsf3_i, operands); DONE; }")
4456 (define_insn "addsf3_i"
4457 [(set (match_operand:SF 0 "arith_reg_operand" "=f")
4458 (plus:SF (match_operand:SF 1 "arith_reg_operand" "%0")
4459 (match_operand:SF 2 "arith_reg_operand" "f")))
4460 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
4463 [(set_attr "type" "fp")
4464 (set_attr "fp_mode" "single")])
4466 (define_expand "subsf3"
4467 [(match_operand:SF 0 "fp_arith_reg_operand" "")
4468 (match_operand:SF 1 "fp_arith_reg_operand" "")
4469 (match_operand:SF 2 "fp_arith_reg_operand" "")]
4471 "{ expand_sf_binop (&gen_subsf3_i, operands); DONE; }")
4473 (define_insn "subsf3_i"
4474 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
4475 (minus:SF (match_operand:SF 1 "fp_arith_reg_operand" "0")
4476 (match_operand:SF 2 "fp_arith_reg_operand" "f")))
4477 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
4480 [(set_attr "type" "fp")
4481 (set_attr "fp_mode" "single")])
4483 ;; Unfortunately, the combiner is unable to cope with the USE of the FPSCR
4484 ;; register in feeding fp instructions. Thus, we cannot generate fmac for
4485 ;; mixed-precision SH4 targets. To allow it to be still generated for the
4486 ;; SH3E, we use a separate insn for SH3E mulsf3.
4488 (define_expand "mulsf3"
4489 [(match_operand:SF 0 "fp_arith_reg_operand" "")
4490 (match_operand:SF 1 "fp_arith_reg_operand" "")
4491 (match_operand:SF 2 "fp_arith_reg_operand" "")]
4496 expand_sf_binop (&gen_mulsf3_i4, operands);
4498 emit_insn (gen_mulsf3_ie (operands[0], operands[1], operands[2]));
4502 (define_insn "mulsf3_i4"
4503 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
4504 (mult:SF (match_operand:SF 1 "fp_arith_reg_operand" "%0")
4505 (match_operand:SF 2 "fp_arith_reg_operand" "f")))
4506 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
4509 [(set_attr "type" "fp")
4510 (set_attr "fp_mode" "single")])
4512 (define_insn "mulsf3_ie"
4513 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
4514 (mult:SF (match_operand:SF 1 "fp_arith_reg_operand" "%0")
4515 (match_operand:SF 2 "fp_arith_reg_operand" "f")))]
4516 "TARGET_SH3E && ! TARGET_SH4"
4518 [(set_attr "type" "fp")])
4520 (define_insn "*macsf3"
4521 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
4522 (plus:SF (mult:SF (match_operand:SF 1 "fp_arith_reg_operand" "%w")
4523 (match_operand:SF 2 "fp_arith_reg_operand" "f"))
4524 (match_operand:SF 3 "arith_reg_operand" "0")))
4525 (use (match_operand:PSI 4 "fpscr_operand" "c"))]
4526 "TARGET_SH3E && ! TARGET_SH4"
4528 [(set_attr "type" "fp")
4529 (set_attr "fp_mode" "single")])
4531 (define_expand "divsf3"
4532 [(match_operand:SF 0 "arith_reg_operand" "")
4533 (match_operand:SF 1 "arith_reg_operand" "")
4534 (match_operand:SF 2 "arith_reg_operand" "")]
4536 "{ expand_sf_binop (&gen_divsf3_i, operands); DONE; }")
4538 (define_insn "divsf3_i"
4539 [(set (match_operand:SF 0 "arith_reg_operand" "=f")
4540 (div:SF (match_operand:SF 1 "arith_reg_operand" "0")
4541 (match_operand:SF 2 "arith_reg_operand" "f")))
4542 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
4545 [(set_attr "type" "fdiv")
4546 (set_attr "fp_mode" "single")])
4548 (define_expand "floatsisf2"
4549 [(set (match_operand:SF 0 "fp_arith_reg_operand" "")
4550 (float:SF (match_operand:SI 1 "fpul_operand" "")))]
4556 emit_sf_insn (gen_floatsisf2_i4 (operands[0], operands[1], get_fpscr_rtx ()));
4561 (define_insn "floatsisf2_i4"
4562 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
4563 (float:SF (match_operand:SI 1 "fpul_operand" "y")))
4564 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4567 [(set_attr "type" "fp")
4568 (set_attr "fp_mode" "single")])
4570 (define_insn "*floatsisf2_ie"
4571 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
4572 (float:SF (match_operand:SI 1 "fpul_operand" "y")))]
4573 "TARGET_SH3E && ! TARGET_SH4"
4575 [(set_attr "type" "fp")])
4577 (define_expand "fix_truncsfsi2"
4578 [(set (match_operand:SI 0 "fpul_operand" "=y")
4579 (fix:SI (match_operand:SF 1 "fp_arith_reg_operand" "f")))]
4585 emit_sf_insn (gen_fix_truncsfsi2_i4 (operands[0], operands[1], get_fpscr_rtx ()));
4590 (define_insn "fix_truncsfsi2_i4"
4591 [(set (match_operand:SI 0 "fpul_operand" "=y")
4592 (fix:SI (match_operand:SF 1 "fp_arith_reg_operand" "f")))
4593 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4596 [(set_attr "type" "fp")
4597 (set_attr "fp_mode" "single")])
4599 ;; ??? This pattern is used nowhere. fix_truncsfsi2 always expands to
4600 ;; fix_truncsfsi2_i4.
4601 ;; (define_insn "fix_truncsfsi2_i4_2"
4602 ;; [(set (match_operand:SI 0 "arith_reg_operand" "=r")
4603 ;; (fix:SI (match_operand:SF 1 "arith_reg_operand" "f")))
4604 ;; (use (reg:PSI FPSCR_REG))
4605 ;; (clobber (reg:SI FPUL_REG))]
4608 ;; [(set_attr "length" "4")
4609 ;; (set_attr "fp_mode" "single")])
4612 ;; [(set (match_operand:SI 0 "arith_reg_operand" "=r")
4613 ;; (fix:SI (match_operand:SF 1 "arith_reg_operand" "f")))
4614 ;; (use (match_operand:PSI 2 "fpscr_operand" "c"))
4615 ;; (clobber (reg:SI FPUL_REG))]
4617 ;; [(parallel [(set (reg:SI FPUL_REG) (fix:SI (match_dup 1)))
4618 ;; (use (match_dup 2))])
4619 ;; (set (match_dup 0) (reg:SI FPUL_REG))])
4621 (define_insn "*fixsfsi"
4622 [(set (match_operand:SI 0 "fpul_operand" "=y")
4623 (fix:SI (match_operand:SF 1 "fp_arith_reg_operand" "f")))]
4624 "TARGET_SH3E && ! TARGET_SH4"
4626 [(set_attr "type" "fp")])
4628 (define_insn "cmpgtsf_t"
4629 [(set (reg:SI T_REG)
4630 (gt:SI (match_operand:SF 0 "fp_arith_reg_operand" "f")
4631 (match_operand:SF 1 "fp_arith_reg_operand" "f")))]
4632 "TARGET_SH3E && ! TARGET_SH4"
4634 [(set_attr "type" "fp")
4635 (set_attr "fp_mode" "single")])
4637 (define_insn "cmpeqsf_t"
4638 [(set (reg:SI T_REG)
4639 (eq:SI (match_operand:SF 0 "fp_arith_reg_operand" "f")
4640 (match_operand:SF 1 "fp_arith_reg_operand" "f")))]
4641 "TARGET_SH3E && ! TARGET_SH4"
4643 [(set_attr "type" "fp")
4644 (set_attr "fp_mode" "single")])
4646 (define_insn "ieee_ccmpeqsf_t"
4647 [(set (reg:SI T_REG)
4648 (ior:SI (reg:SI T_REG)
4649 (eq:SI (match_operand:SF 0 "fp_arith_reg_operand" "f")
4650 (match_operand:SF 1 "fp_arith_reg_operand" "f"))))]
4651 "TARGET_SH3E && TARGET_IEEE && ! TARGET_SH4"
4652 "* return output_ieee_ccmpeq (insn, operands);"
4653 [(set_attr "length" "4")])
4656 (define_insn "cmpgtsf_t_i4"
4657 [(set (reg:SI T_REG)
4658 (gt:SI (match_operand:SF 0 "fp_arith_reg_operand" "f")
4659 (match_operand:SF 1 "fp_arith_reg_operand" "f")))
4660 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4663 [(set_attr "type" "fp")
4664 (set_attr "fp_mode" "single")])
4666 (define_insn "cmpeqsf_t_i4"
4667 [(set (reg:SI T_REG)
4668 (eq:SI (match_operand:SF 0 "fp_arith_reg_operand" "f")
4669 (match_operand:SF 1 "fp_arith_reg_operand" "f")))
4670 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4673 [(set_attr "type" "fp")
4674 (set_attr "fp_mode" "single")])
4676 (define_insn "*ieee_ccmpeqsf_t_4"
4677 [(set (reg:SI T_REG)
4678 (ior:SI (reg:SI T_REG)
4679 (eq:SI (match_operand:SF 0 "fp_arith_reg_operand" "f")
4680 (match_operand:SF 1 "fp_arith_reg_operand" "f"))))
4681 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4682 "TARGET_IEEE && TARGET_SH4"
4683 "* return output_ieee_ccmpeq (insn, operands);"
4684 [(set_attr "length" "4")
4685 (set_attr "fp_mode" "single")])
4687 (define_expand "cmpsf"
4688 [(set (reg:SI T_REG)
4689 (compare (match_operand:SF 0 "arith_operand" "")
4690 (match_operand:SF 1 "arith_operand" "")))]
4694 sh_compare_op0 = operands[0];
4695 sh_compare_op1 = operands[1];
4699 (define_expand "negsf2"
4700 [(match_operand:SF 0 "fp_arith_reg_operand" "")
4701 (match_operand:SF 1 "fp_arith_reg_operand" "")]
4703 "{ expand_sf_unop (&gen_negsf2_i, operands); DONE; }")
4705 (define_insn "negsf2_i"
4706 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
4707 (neg:SF (match_operand:SF 1 "fp_arith_reg_operand" "0")))
4708 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4711 [(set_attr "type" "fmove")
4712 (set_attr "fp_mode" "single")])
4714 (define_expand "sqrtsf2"
4715 [(match_operand:SF 0 "fp_arith_reg_operand" "")
4716 (match_operand:SF 1 "fp_arith_reg_operand" "")]
4718 "{ expand_sf_unop (&gen_sqrtsf2_i, operands); DONE; }")
4720 (define_insn "sqrtsf2_i"
4721 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
4722 (sqrt:SF (match_operand:SF 1 "fp_arith_reg_operand" "0")))
4723 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4726 [(set_attr "type" "fdiv")
4727 (set_attr "fp_mode" "single")])
4729 (define_expand "abssf2"
4730 [(match_operand:SF 0 "fp_arith_reg_operand" "")
4731 (match_operand:SF 1 "fp_arith_reg_operand" "")]
4733 "{ expand_sf_unop (&gen_abssf2_i, operands); DONE; }")
4735 (define_insn "abssf2_i"
4736 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
4737 (abs:SF (match_operand:SF 1 "fp_arith_reg_operand" "0")))
4738 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4741 [(set_attr "type" "fmove")
4742 (set_attr "fp_mode" "single")])
4744 (define_expand "adddf3"
4745 [(match_operand:DF 0 "fp_arith_reg_operand" "")
4746 (match_operand:DF 1 "fp_arith_reg_operand" "")
4747 (match_operand:DF 2 "fp_arith_reg_operand" "")]
4749 "{ expand_df_binop (&gen_adddf3_i, operands); DONE; }")
4751 (define_insn "adddf3_i"
4752 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
4753 (plus:DF (match_operand:DF 1 "fp_arith_reg_operand" "%0")
4754 (match_operand:DF 2 "fp_arith_reg_operand" "f")))
4755 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
4758 [(set_attr "type" "dfp_arith")
4759 (set_attr "fp_mode" "double")])
4761 (define_expand "subdf3"
4762 [(match_operand:DF 0 "fp_arith_reg_operand" "")
4763 (match_operand:DF 1 "fp_arith_reg_operand" "")
4764 (match_operand:DF 2 "fp_arith_reg_operand" "")]
4766 "{ expand_df_binop (&gen_subdf3_i, operands); DONE; }")
4768 (define_insn "subdf3_i"
4769 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
4770 (minus:DF (match_operand:DF 1 "fp_arith_reg_operand" "0")
4771 (match_operand:DF 2 "fp_arith_reg_operand" "f")))
4772 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
4775 [(set_attr "type" "dfp_arith")
4776 (set_attr "fp_mode" "double")])
4778 (define_expand "muldf3"
4779 [(match_operand:DF 0 "fp_arith_reg_operand" "")
4780 (match_operand:DF 1 "fp_arith_reg_operand" "")
4781 (match_operand:DF 2 "fp_arith_reg_operand" "")]
4783 "{ expand_df_binop (&gen_muldf3_i, operands); DONE; }")
4785 (define_insn "muldf3_i"
4786 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
4787 (mult:DF (match_operand:DF 1 "fp_arith_reg_operand" "%0")
4788 (match_operand:DF 2 "fp_arith_reg_operand" "f")))
4789 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
4792 [(set_attr "type" "dfp_arith")
4793 (set_attr "fp_mode" "double")])
4795 (define_expand "divdf3"
4796 [(match_operand:DF 0 "fp_arith_reg_operand" "")
4797 (match_operand:DF 1 "fp_arith_reg_operand" "")
4798 (match_operand:DF 2 "fp_arith_reg_operand" "")]
4800 "{ expand_df_binop (&gen_divdf3_i, operands); DONE; }")
4802 (define_insn "divdf3_i"
4803 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
4804 (div:DF (match_operand:DF 1 "fp_arith_reg_operand" "0")
4805 (match_operand:DF 2 "fp_arith_reg_operand" "f")))
4806 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
4809 [(set_attr "type" "dfdiv")
4810 (set_attr "fp_mode" "double")])
4812 (define_expand "floatsidf2"
4813 [(match_operand:DF 0 "fp_arith_reg_operand" "")
4814 (match_operand:SI 1 "fpul_operand" "")]
4818 emit_df_insn (gen_floatsidf2_i (operands[0], operands[1], get_fpscr_rtx ()));
4822 (define_insn "floatsidf2_i"
4823 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
4824 (float:DF (match_operand:SI 1 "fpul_operand" "y")))
4825 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4828 [(set_attr "type" "dfp_conv")
4829 (set_attr "fp_mode" "double")])
4831 (define_expand "fix_truncdfsi2"
4832 [(match_operand:SI 0 "fpul_operand" "")
4833 (match_operand:DF 1 "fp_arith_reg_operand" "")]
4837 emit_df_insn (gen_fix_truncdfsi2_i (operands[0], operands[1], get_fpscr_rtx ()));
4841 (define_insn "fix_truncdfsi2_i"
4842 [(set (match_operand:SI 0 "fpul_operand" "=y")
4843 (fix:SI (match_operand:DF 1 "fp_arith_reg_operand" "f")))
4844 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4847 [(set_attr "type" "dfp_conv")
4848 (set_attr "fp_mode" "double")])
4850 ;; ??? This pattern is used nowhere. fix_truncdfsi2 always expands to
4851 ;; fix_truncdfsi2_i.
4852 ;; (define_insn "fix_truncdfsi2_i4"
4853 ;; [(set (match_operand:SI 0 "arith_reg_operand" "=r")
4854 ;; (fix:SI (match_operand:DF 1 "arith_reg_operand" "f")))
4855 ;; (use (match_operand:PSI 2 "fpscr_operand" "c"))
4856 ;; (clobber (reg:SI FPUL_REG))]
4859 ;; [(set_attr "length" "4")
4860 ;; (set_attr "fp_mode" "double")])
4863 ;; [(set (match_operand:SI 0 "arith_reg_operand" "=r")
4864 ;; (fix:SI (match_operand:DF 1 "arith_reg_operand" "f")))
4865 ;; (use (match_operand:PSI 2 "fpscr_operand" "c"))
4866 ;; (clobber (reg:SI FPUL_REG))]
4868 ;; [(parallel [(set (reg:SI FPUL_REG) (fix:SI (match_dup 1)))
4869 ;; (use (match_dup 2))])
4870 ;; (set (match_dup 0) (reg:SI FPUL_REG))])
4872 (define_insn "cmpgtdf_t"
4873 [(set (reg:SI T_REG)
4874 (gt:SI (match_operand:DF 0 "arith_reg_operand" "f")
4875 (match_operand:DF 1 "arith_reg_operand" "f")))
4876 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4879 [(set_attr "type" "dfp_cmp")
4880 (set_attr "fp_mode" "double")])
4882 (define_insn "cmpeqdf_t"
4883 [(set (reg:SI T_REG)
4884 (eq:SI (match_operand:DF 0 "arith_reg_operand" "f")
4885 (match_operand:DF 1 "arith_reg_operand" "f")))
4886 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4889 [(set_attr "type" "dfp_cmp")
4890 (set_attr "fp_mode" "double")])
4892 (define_insn "*ieee_ccmpeqdf_t"
4893 [(set (reg:SI T_REG)
4894 (ior:SI (reg:SI T_REG)
4895 (eq:SI (match_operand:DF 0 "arith_reg_operand" "f")
4896 (match_operand:DF 1 "arith_reg_operand" "f"))))
4897 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4898 "TARGET_IEEE && TARGET_SH4"
4899 "* return output_ieee_ccmpeq (insn, operands);"
4900 [(set_attr "length" "4")
4901 (set_attr "fp_mode" "double")])
4903 (define_expand "cmpdf"
4904 [(set (reg:SI T_REG)
4905 (compare (match_operand:DF 0 "arith_operand" "")
4906 (match_operand:DF 1 "arith_operand" "")))]
4910 sh_compare_op0 = operands[0];
4911 sh_compare_op1 = operands[1];
4915 (define_expand "negdf2"
4916 [(match_operand:DF 0 "arith_reg_operand" "")
4917 (match_operand:DF 1 "arith_reg_operand" "")]
4919 "{ expand_df_unop (&gen_negdf2_i, operands); DONE; }")
4921 (define_insn "negdf2_i"
4922 [(set (match_operand:DF 0 "arith_reg_operand" "=f")
4923 (neg:DF (match_operand:DF 1 "arith_reg_operand" "0")))
4924 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4927 [(set_attr "type" "fmove")
4928 (set_attr "fp_mode" "double")])
4930 (define_expand "sqrtdf2"
4931 [(match_operand:DF 0 "arith_reg_operand" "")
4932 (match_operand:DF 1 "arith_reg_operand" "")]
4934 "{ expand_df_unop (&gen_sqrtdf2_i, operands); DONE; }")
4936 (define_insn "sqrtdf2_i"
4937 [(set (match_operand:DF 0 "arith_reg_operand" "=f")
4938 (sqrt:DF (match_operand:DF 1 "arith_reg_operand" "0")))
4939 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4942 [(set_attr "type" "dfdiv")
4943 (set_attr "fp_mode" "double")])
4945 (define_expand "absdf2"
4946 [(match_operand:DF 0 "arith_reg_operand" "")
4947 (match_operand:DF 1 "arith_reg_operand" "")]
4949 "{ expand_df_unop (&gen_absdf2_i, operands); DONE; }")
4951 (define_insn "absdf2_i"
4952 [(set (match_operand:DF 0 "arith_reg_operand" "=f")
4953 (abs:DF (match_operand:DF 1 "arith_reg_operand" "0")))
4954 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4957 [(set_attr "type" "fmove")
4958 (set_attr "fp_mode" "double")])
4960 (define_expand "extendsfdf2"
4961 [(match_operand:DF 0 "fp_arith_reg_operand" "")
4962 (match_operand:SF 1 "fpul_operand" "")]
4966 emit_df_insn (gen_extendsfdf2_i4 (operands[0], operands[1], get_fpscr_rtx ()));
4970 (define_insn "extendsfdf2_i4"
4971 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
4972 (float_extend:DF (match_operand:SF 1 "fpul_operand" "y")))
4973 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4976 [(set_attr "type" "fp")
4977 (set_attr "fp_mode" "double")])
4979 (define_expand "truncdfsf2"
4980 [(match_operand:SF 0 "fpul_operand" "")
4981 (match_operand:DF 1 "fp_arith_reg_operand" "")]
4985 emit_df_insn (gen_truncdfsf2_i4 (operands[0], operands[1], get_fpscr_rtx ()));
4989 (define_insn "truncdfsf2_i4"
4990 [(set (match_operand:SF 0 "fpul_operand" "=y")
4991 (float_truncate:SF (match_operand:DF 1 "fp_arith_reg_operand" "f")))
4992 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
4995 [(set_attr "type" "fp")
4996 (set_attr "fp_mode" "double")])
4998 ;; Bit field extract patterns. These give better code for packed bitfields,
4999 ;; because they allow auto-increment addresses to be generated.
5001 (define_expand "insv"
5002 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "")
5003 (match_operand:SI 1 "immediate_operand" "")
5004 (match_operand:SI 2 "immediate_operand" ""))
5005 (match_operand:SI 3 "general_operand" ""))]
5006 "! TARGET_LITTLE_ENDIAN"
5009 rtx addr_target, orig_address, shift_reg;
5012 /* ??? expmed doesn't care for non-register predicates. */
5013 if (! memory_operand (operands[0], VOIDmode)
5014 || ! immediate_operand (operands[1], VOIDmode)
5015 || ! immediate_operand (operands[2], VOIDmode)
5016 || ! general_operand (operands[3], VOIDmode))
5018 /* If this isn't a 16 / 24 / 32 bit field, or if
5019 it doesn't start on a byte boundary, then fail. */
5020 size = INTVAL (operands[1]);
5021 if (size < 16 || size > 32 || size % 8 != 0
5022 || (INTVAL (operands[2]) % 8) != 0)
5026 orig_address = XEXP (operands[0], 0);
5027 shift_reg = gen_reg_rtx (SImode);
5028 emit_insn (gen_movsi (shift_reg, operands[3]));
5029 addr_target = copy_addr_to_reg (plus_constant (orig_address, size - 1));
5031 operands[0] = change_address (operands[0], QImode, addr_target);
5032 emit_insn (gen_movqi (operands[0], gen_rtx_SUBREG (QImode, shift_reg, 0)));
5036 emit_insn (gen_lshrsi3_k (shift_reg, shift_reg, GEN_INT (8)));
5037 emit_insn (gen_addsi3 (addr_target, addr_target, GEN_INT (-1)));
5038 emit_insn (gen_movqi (operands[0],
5039 gen_rtx_SUBREG (QImode, shift_reg, 0)));
5045 ;; -------------------------------------------------------------------------
5047 ;; -------------------------------------------------------------------------
5049 ;; This matches cases where a stack pointer increment at the start of the
5050 ;; epilogue combines with a stack slot read loading the return value.
5053 [(set (match_operand:SI 0 "arith_reg_operand" "")
5054 (mem:SI (match_operand:SI 1 "arith_reg_operand" "")))
5055 (set (match_dup 1) (plus:SI (match_dup 1) (const_int 4)))]
5056 "REGNO (operands[1]) != REGNO (operands[0])"
5059 ;; See the comment on the dt combiner pattern above.
5062 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
5063 (plus:SI (match_dup 0)
5066 (eq:SI (match_dup 0)
5071 ;; These convert sequences such as `mov #k,r0; add r15,r0; mov.l @r0,rn'
5072 ;; to `mov #k,r0; mov.l @(r0,r15),rn'. These sequences are generated by
5073 ;; reload when the constant is too large for a reg+offset address.
5075 ;; ??? We would get much better code if this was done in reload. This would
5076 ;; require modifying find_reloads_address to recognize that if the constant
5077 ;; is out-of-range for an immediate add, then we get better code by reloading
5078 ;; the constant into a register than by reloading the sum into a register,
5079 ;; since the former is one instruction shorter if the address does not need
5080 ;; to be offsettable. Unfortunately this does not work, because there is
5081 ;; only one register, r0, that can be used as an index register. This register
5082 ;; is also the function return value register. So, if we try to force reload
5083 ;; to use double-reg addresses, then we end up with some instructions that
5084 ;; need to use r0 twice. The only way to fix this is to change the calling
5085 ;; convention so that r0 is not used to return values.
5088 [(set (match_operand:SI 0 "register_operand" "=r")
5089 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
5090 (set (mem:SI (match_dup 0))
5091 (match_operand:SI 2 "general_movsrc_operand" ""))]
5092 "REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
5093 "mov.l %2,@(%0,%1)")
5096 [(set (match_operand:SI 0 "register_operand" "=r")
5097 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
5098 (set (match_operand:SI 2 "general_movdst_operand" "")
5099 (mem:SI (match_dup 0)))]
5100 "REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
5101 "mov.l @(%0,%1),%2")
5104 [(set (match_operand:SI 0 "register_operand" "=r")
5105 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
5106 (set (mem:HI (match_dup 0))
5107 (match_operand:HI 2 "general_movsrc_operand" ""))]
5108 "REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
5109 "mov.w %2,@(%0,%1)")
5112 [(set (match_operand:SI 0 "register_operand" "=r")
5113 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
5114 (set (match_operand:HI 2 "general_movdst_operand" "")
5115 (mem:HI (match_dup 0)))]
5116 "REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
5117 "mov.w @(%0,%1),%2")
5120 [(set (match_operand:SI 0 "register_operand" "=r")
5121 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
5122 (set (mem:QI (match_dup 0))
5123 (match_operand:QI 2 "general_movsrc_operand" ""))]
5124 "REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
5125 "mov.b %2,@(%0,%1)")
5128 [(set (match_operand:SI 0 "register_operand" "=r")
5129 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
5130 (set (match_operand:QI 2 "general_movdst_operand" "")
5131 (mem:QI (match_dup 0)))]
5132 "REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
5133 "mov.b @(%0,%1),%2")
5136 [(set (match_operand:SI 0 "register_operand" "=r")
5137 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
5138 (set (mem:SF (match_dup 0))
5139 (match_operand:SF 2 "general_movsrc_operand" ""))]
5140 "REGNO (operands[0]) == 0
5141 && ((GET_CODE (operands[2]) == REG && REGNO (operands[2]) < 16)
5142 || (GET_CODE (operands[2]) == SUBREG
5143 && REGNO (SUBREG_REG (operands[2])) < 16))
5144 && reg_unused_after (operands[0], insn)"
5145 "mov.l %2,@(%0,%1)")
5148 [(set (match_operand:SI 0 "register_operand" "=r")
5149 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
5150 (set (match_operand:SF 2 "general_movdst_operand" "")
5152 (mem:SF (match_dup 0)))]
5153 "REGNO (operands[0]) == 0
5154 && ((GET_CODE (operands[2]) == REG && REGNO (operands[2]) < 16)
5155 || (GET_CODE (operands[2]) == SUBREG
5156 && REGNO (SUBREG_REG (operands[2])) < 16))
5157 && reg_unused_after (operands[0], insn)"
5158 "mov.l @(%0,%1),%2")
5161 [(set (match_operand:SI 0 "register_operand" "=r")
5162 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
5163 (set (mem:SF (match_dup 0))
5164 (match_operand:SF 2 "general_movsrc_operand" ""))]
5165 "REGNO (operands[0]) == 0
5166 && ((GET_CODE (operands[2]) == REG
5167 && FP_OR_XD_REGISTER_P (REGNO (operands[2])))
5168 || (GET_CODE (operands[2]) == SUBREG
5169 && FP_OR_XD_REGISTER_P (REGNO (SUBREG_REG (operands[2])))))
5170 && reg_unused_after (operands[0], insn)"
5171 "fmov{.s|} %2,@(%0,%1)")
5174 [(set (match_operand:SI 0 "register_operand" "=r")
5175 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
5176 (set (match_operand:SF 2 "general_movdst_operand" "")
5178 (mem:SF (match_dup 0)))]
5179 "REGNO (operands[0]) == 0
5180 && ((GET_CODE (operands[2]) == REG
5181 && FP_OR_XD_REGISTER_P (REGNO (operands[2])))
5182 || (GET_CODE (operands[2]) == SUBREG
5183 && FP_OR_XD_REGISTER_P (REGNO (SUBREG_REG (operands[2])))))
5184 && reg_unused_after (operands[0], insn)"
5185 "fmov{.s|} @(%0,%1),%2")
5187 ;; Switch to a new stack with its address in sp_switch (a SYMBOL_REF). */
5188 (define_insn "sp_switch_1"
5195 xoperands[0] = sp_switch;
5196 output_asm_insn (\"mov.l r0,@-r15\;mov.l %0,r0\", xoperands);
5197 output_asm_insn (\"mov.l @r0,r0\;mov.l r15,@-r0\", xoperands);
5198 return \"mov r0,r15\";
5200 [(set_attr "length" "10")])
5202 ;; Switch back to the original stack for interrupt functions with the
5203 ;; sp_switch attribute. */
5204 (define_insn "sp_switch_2"
5207 "mov.l @r15+,r15\;mov.l @r15+,r0"
5208 [(set_attr "length" "4")])