1 ;;- Machine description for Renesas / SuperH SH.
2 ;; Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3 ;; 2003, 2004, 2005 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 GCC.
9 ;; GCC 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 ;; GCC 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 GCC; see the file COPYING. If not, write to
21 ;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, 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 ;; -------------------------------------------------------------------------
118 ;; These are used with unspec.
119 (UNSPEC_COMPACT_ARGS 0)
132 (UNSPEC_INIT_TRAMP 13)
138 (UNSPEC_EH_RETURN 19)
146 (UNSPEC_DIV_INV_M0 30)
147 (UNSPEC_DIV_INV_M1 31)
148 (UNSPEC_DIV_INV_M2 32)
149 (UNSPEC_DIV_INV_M3 33)
150 (UNSPEC_DIV_INV20 34)
156 ;; These are used with unspec_volatile.
162 (UNSPECV_WINDOW_END 10)
163 (UNSPECV_CONST_END 11)
166 ;; -------------------------------------------------------------------------
168 ;; -------------------------------------------------------------------------
173 "sh1,sh2,sh2e,sh2a,sh3,sh3e,sh4,sh4a,sh5"
174 (const (symbol_ref "sh_cpu_attr")))
176 (define_attr "endian" "big,little"
177 (const (if_then_else (symbol_ref "TARGET_LITTLE_ENDIAN")
178 (const_string "little") (const_string "big"))))
180 ;; Indicate if the default fpu mode is single precision.
181 (define_attr "fpu_single" "yes,no"
182 (const (if_then_else (symbol_ref "TARGET_FPU_SINGLE")
183 (const_string "yes") (const_string "no"))))
185 (define_attr "fmovd" "yes,no"
186 (const (if_then_else (symbol_ref "TARGET_FMOVD")
187 (const_string "yes") (const_string "no"))))
189 (define_attr "pipe_model" "sh1,sh4,sh5media"
191 (cond [(symbol_ref "TARGET_SHMEDIA") (const_string "sh5media")
192 (symbol_ref "TARGET_SUPERSCALAR") (const_string "sh4")]
193 (const_string "sh1"))))
195 ;; cbranch conditional branch instructions
196 ;; jump unconditional jumps
197 ;; arith ordinary arithmetic
198 ;; arith3 a compound insn that behaves similarly to a sequence of
199 ;; three insns of type arith
200 ;; arith3b like above, but might end with a redirected branch
202 ;; load_si Likewise, SImode variant for general register.
203 ;; fload Likewise, but load to fp register.
205 ;; move general purpose register to register
206 ;; mt_group other sh4 mt instructions
207 ;; fmove register to register, floating point
208 ;; smpy word precision integer multiply
209 ;; dmpy longword or doublelongword precision integer multiply
211 ;; pload load of pr reg, which can't be put into delay slot of rts
212 ;; prset copy register to pr reg, ditto
213 ;; pstore store of pr reg, which can't be put into delay slot of jsr
214 ;; prget copy pr to register, ditto
215 ;; pcload pc relative load of constant value
216 ;; pcfload Likewise, but load to fp register.
217 ;; pcload_si Likewise, SImode variant for general register.
218 ;; rte return from exception
219 ;; sfunc special function call with known used registers
220 ;; call function call
222 ;; fdiv floating point divide (or square root)
223 ;; gp_fpul move from general purpose register to fpul
224 ;; fpul_gp move from fpul to general purpose register
225 ;; mac_gp move from mac[lh] to general purpose register
226 ;; dfp_arith, dfp_cmp,dfp_conv
227 ;; ftrc_s fix_truncsfsi2_i4
228 ;; dfdiv double precision floating point divide (or square root)
229 ;; cwb ic_invalidate_line_i
230 ;; movua SH4a unaligned load
231 ;; fsrra square root reciprocal approximate
232 ;; fsca sine and cosine approximate
233 ;; tls_load load TLS related address
234 ;; arith_media SHmedia arithmetic, logical, and shift instructions
235 ;; cbranch_media SHmedia conditional branch instructions
236 ;; cmp_media SHmedia compare instructions
237 ;; dfdiv_media SHmedia double precision divide and square root
238 ;; dfmul_media SHmedia double precision multiply instruction
239 ;; dfparith_media SHmedia double precision floating point arithmetic
240 ;; dfpconv_media SHmedia double precision floating point conversions
241 ;; dmpy_media SHmedia longword multiply
242 ;; fcmp_media SHmedia floating point compare instructions
243 ;; fdiv_media SHmedia single precision divide and square root
244 ;; fload_media SHmedia floating point register load instructions
245 ;; fmove_media SHmedia floating point register moves (inc. fabs and fneg)
246 ;; fparith_media SHmedia single precision floating point arithmetic
247 ;; fpconv_media SHmedia single precision floating point conversions
248 ;; fstore_media SHmedia floating point register store instructions
249 ;; gettr_media SHmedia gettr instruction
250 ;; invalidate_line_media SHmedia invalidate_line sequence
251 ;; jump_media SHmedia unconditional branch instructions
252 ;; load_media SHmedia general register load instructions
253 ;; pt_media SHmedia pt instruction (expanded by assembler)
254 ;; ptabs_media SHmedia ptabs instruction
255 ;; store_media SHmedia general register store instructions
256 ;; mcmp_media SHmedia multimedia compare, absolute, saturating ops
257 ;; mac_media SHmedia mac-style fixed point operations
258 ;; d2mpy_media SHmedia: two 32 bit integer multiplies
259 ;; atrans_media SHmedia approximate transcendental functions
260 ;; ustore_media SHmedia unaligned stores
261 ;; nil no-op move, will be deleted.
264 "mt_group,cbranch,jump,jump_ind,arith,arith3,arith3b,dyn_shift,load,load_si,fload,store,move,fmove,smpy,dmpy,return,pload,prset,pstore,prget,pcload,pcload_si,pcfload,rte,sfunc,call,fp,fdiv,ftrc_s,dfp_arith,dfp_cmp,dfp_conv,dfdiv,gp_fpul,fpul_gp,mac_gp,mem_fpscr,gp_fpscr,cwb,movua,fsrra,fsca,tls_load,arith_media,cbranch_media,cmp_media,dfdiv_media,dfmul_media,dfparith_media,dfpconv_media,dmpy_media,fcmp_media,fdiv_media,fload_media,fmove_media,fparith_media,fpconv_media,fstore_media,gettr_media,invalidate_line_media,jump_media,load_media,pt_media,ptabs_media,store_media,mcmp_media,mac_media,d2mpy_media,atrans_media,ustore_media,nil,other"
265 (const_string "other"))
267 ;; We define a new attribute namely "insn_class".We use
268 ;; this for the DFA based pipeline description.
270 ;; mt_group SH4 "mt" group instructions.
272 ;; ex_group SH4 "ex" group instructions.
274 ;; ls_group SH4 "ls" group instructions.
277 (define_attr "insn_class"
278 "mt_group,ex_group,ls_group,br_group,fe_group,co_group,none"
279 (cond [(eq_attr "type" "move,mt_group") (const_string "mt_group")
280 (eq_attr "type" "arith,dyn_shift") (const_string "ex_group")
281 (eq_attr "type" "fmove,load,pcload,load_si,pcload_si,fload,pcfload,store,gp_fpul,fpul_gp") (const_string "ls_group")
282 (eq_attr "type" "cbranch,jump") (const_string "br_group")
283 (eq_attr "type" "fp,fdiv,ftrc_s,dfp_arith,dfp_conv,dfdiv")
284 (const_string "fe_group")
285 (eq_attr "type" "jump_ind,smpy,dmpy,mac_gp,return,pload,prset,pstore,prget,rte,sfunc,call,dfp_cmp,mem_fpscr,gp_fpscr,cwb") (const_string "co_group")]
286 (const_string "none")))
287 ;; nil are zero instructions, and arith3 / arith3b are multiple instructions,
288 ;; so these do not belong in an insn group, although they are modeled
289 ;; with their own define_insn_reservations.
291 ;; Indicate what precision must be selected in fpscr for this insn, if any.
293 (define_attr "fp_mode" "single,double,none" (const_string "none"))
295 ;; Indicate if the fpu mode is set by this instruction
296 ;; "unknown" must have the value as "none" in fp_mode, and means
297 ;; that the instruction/abi has left the processor in an unknown
299 ;; "none" means that nothing has changed and no mode is set.
300 ;; This attribute is only used for the Renesas ABI.
301 (define_attr "fp_set" "single,double,unknown,none" (const_string "none"))
303 ; If a conditional branch destination is within -252..258 bytes away
304 ; from the instruction it can be 2 bytes long. Something in the
305 ; range -4090..4100 bytes can be 6 bytes long. All other conditional
306 ; branches are initially assumed to be 16 bytes long.
307 ; In machine_dependent_reorg, we split all branches that are longer than
310 ;; The maximum range used for SImode constant pool entries is 1018. A final
311 ;; instruction can add 8 bytes while only being 4 bytes in size, thus we
312 ;; can have a total of 1022 bytes in the pool. Add 4 bytes for a branch
313 ;; instruction around the pool table, 2 bytes of alignment before the table,
314 ;; and 30 bytes of alignment after the table. That gives a maximum total
315 ;; pool size of 1058 bytes.
316 ;; Worst case code/pool content size ratio is 1:2 (using asms).
317 ;; Thus, in the worst case, there is one instruction in front of a maximum
318 ;; sized pool, and then there are 1052 bytes of pool for every 508 bytes of
319 ;; code. For the last n bytes of code, there are 2n + 36 bytes of pool.
320 ;; If we have a forward branch, the initial table will be put after the
321 ;; unconditional branch.
323 ;; ??? We could do much better by keeping track of the actual pcloads within
324 ;; the branch range and in the pcload range in front of the branch range.
326 ;; ??? This looks ugly because genattrtab won't allow if_then_else or cond
328 (define_attr "short_cbranch_p" "no,yes"
329 (cond [(ne (symbol_ref "mdep_reorg_phase <= SH_FIXUP_PCLOAD") (const_int 0))
331 (leu (plus (minus (match_dup 0) (pc)) (const_int 252)) (const_int 506))
333 (ne (symbol_ref "NEXT_INSN (PREV_INSN (insn)) != insn") (const_int 0))
335 (leu (plus (minus (match_dup 0) (pc)) (const_int 252)) (const_int 508))
337 ] (const_string "no")))
339 (define_attr "med_branch_p" "no,yes"
340 (cond [(leu (plus (minus (match_dup 0) (pc)) (const_int 990))
343 (ne (symbol_ref "mdep_reorg_phase <= SH_FIXUP_PCLOAD") (const_int 0))
345 (leu (plus (minus (match_dup 0) (pc)) (const_int 4092))
348 ] (const_string "no")))
350 (define_attr "med_cbranch_p" "no,yes"
351 (cond [(leu (plus (minus (match_dup 0) (pc)) (const_int 988))
354 (ne (symbol_ref "mdep_reorg_phase <= SH_FIXUP_PCLOAD") (const_int 0))
356 (leu (plus (minus (match_dup 0) (pc)) (const_int 4090))
359 ] (const_string "no")))
361 (define_attr "braf_branch_p" "no,yes"
362 (cond [(ne (symbol_ref "! TARGET_SH2") (const_int 0))
364 (leu (plus (minus (match_dup 0) (pc)) (const_int 10330))
367 (ne (symbol_ref "mdep_reorg_phase <= SH_FIXUP_PCLOAD") (const_int 0))
369 (leu (plus (minus (match_dup 0) (pc)) (const_int 32764))
372 ] (const_string "no")))
374 (define_attr "braf_cbranch_p" "no,yes"
375 (cond [(ne (symbol_ref "! TARGET_SH2") (const_int 0))
377 (leu (plus (minus (match_dup 0) (pc)) (const_int 10328))
380 (ne (symbol_ref "mdep_reorg_phase <= SH_FIXUP_PCLOAD") (const_int 0))
382 (leu (plus (minus (match_dup 0) (pc)) (const_int 32762))
385 ] (const_string "no")))
387 ; An unconditional jump in the range -4092..4098 can be 2 bytes long.
388 ; For wider ranges, we need a combination of a code and a data part.
389 ; If we can get a scratch register for a long range jump, the code
390 ; part can be 4 bytes long; otherwise, it must be 8 bytes long.
391 ; If the jump is in the range -32764..32770, the data part can be 2 bytes
392 ; long; otherwise, it must be 6 bytes long.
394 ; All other instructions are two bytes long by default.
396 ;; ??? This should use something like *branch_p (minus (match_dup 0) (pc)),
397 ;; but getattrtab doesn't understand this.
398 (define_attr "length" ""
399 (cond [(eq_attr "type" "cbranch")
400 (cond [(eq_attr "short_cbranch_p" "yes")
402 (eq_attr "med_cbranch_p" "yes")
404 (eq_attr "braf_cbranch_p" "yes")
406 ;; ??? using pc is not computed transitively.
407 (ne (match_dup 0) (match_dup 0))
409 (ne (symbol_ref ("flag_pic")) (const_int 0))
412 (eq_attr "type" "jump")
413 (cond [(eq_attr "med_branch_p" "yes")
415 (and (eq (symbol_ref "GET_CODE (prev_nonnote_insn (insn))")
417 (eq (symbol_ref "INSN_CODE (prev_nonnote_insn (insn))")
418 (symbol_ref "code_for_indirect_jump_scratch")))
419 (cond [(eq_attr "braf_branch_p" "yes")
421 (eq (symbol_ref "flag_pic") (const_int 0))
423 (ne (symbol_ref "TARGET_SH2") (const_int 0))
424 (const_int 10)] (const_int 18))
425 (eq_attr "braf_branch_p" "yes")
427 ;; ??? using pc is not computed transitively.
428 (ne (match_dup 0) (match_dup 0))
430 (ne (symbol_ref ("flag_pic")) (const_int 0))
433 (eq_attr "type" "pt_media")
434 (if_then_else (ne (symbol_ref "TARGET_SHMEDIA64") (const_int 0))
435 (const_int 20) (const_int 12))
436 (and (eq_attr "type" "jump_media")
437 (ne (symbol_ref "TARGET_SH5_CUT2_WORKAROUND") (const_int 0)))
439 ] (if_then_else (ne (symbol_ref "TARGET_SHMEDIA") (const_int 0))
443 ;; DFA descriptions for the pipelines
446 (include "shmedia.md")
449 (include "predicates.md")
451 ;; Definitions for filling delay slots
453 (define_attr "needs_delay_slot" "yes,no" (const_string "no"))
455 ;; ??? This should be (nil) instead of (const_int 0)
456 (define_attr "hit_stack" "yes,no"
457 (cond [(eq (symbol_ref "find_regno_note (insn, REG_INC, SP_REG)")
460 (const_string "yes")))
462 (define_attr "interrupt_function" "no,yes"
463 (const (symbol_ref "current_function_interrupt")))
465 (define_attr "in_delay_slot" "yes,no"
466 (cond [(eq_attr "type" "cbranch") (const_string "no")
467 (eq_attr "type" "pcload,pcload_si") (const_string "no")
468 (eq_attr "needs_delay_slot" "yes") (const_string "no")
469 (eq_attr "length" "2") (const_string "yes")
470 ] (const_string "no")))
472 (define_attr "cond_delay_slot" "yes,no"
473 (cond [(eq_attr "in_delay_slot" "yes") (const_string "yes")
474 ] (const_string "no")))
476 (define_attr "is_sfunc" ""
477 (if_then_else (eq_attr "type" "sfunc") (const_int 1) (const_int 0)))
479 (define_attr "is_mac_media" ""
480 (if_then_else (eq_attr "type" "mac_media") (const_int 1) (const_int 0)))
482 (define_attr "branch_zero" "yes,no"
483 (cond [(eq_attr "type" "!cbranch") (const_string "no")
484 (ne (symbol_ref "(next_active_insn (insn)\
485 == (prev_active_insn\
486 (XEXP (SET_SRC (PATTERN (insn)), 1))))\
487 && get_attr_length (next_active_insn (insn)) == 2")
489 (const_string "yes")]
490 (const_string "no")))
492 ;; SH4 Double-precision computation with double-precision result -
493 ;; the two halves are ready at different times.
494 (define_attr "dfp_comp" "yes,no"
495 (cond [(eq_attr "type" "dfp_arith,dfp_conv,dfdiv") (const_string "yes")]
496 (const_string "no")))
498 ;; Insns for which the latency of a preceding fp insn is decreased by one.
499 (define_attr "late_fp_use" "yes,no" (const_string "no"))
500 ;; And feeding insns for which this relevant.
501 (define_attr "any_fp_comp" "yes,no"
502 (cond [(eq_attr "type" "fp,fdiv,ftrc_s,dfp_arith,dfp_conv,dfdiv")
503 (const_string "yes")]
504 (const_string "no")))
506 (define_attr "any_int_load" "yes,no"
507 (cond [(eq_attr "type" "load,load_si,pcload,pcload_si")
508 (const_string "yes")]
509 (const_string "no")))
511 (define_attr "highpart" "user, ignore, extend, depend, must_split"
512 (const_string "user"))
515 (eq_attr "needs_delay_slot" "yes")
516 [(eq_attr "in_delay_slot" "yes") (nil) (nil)])
518 ;; On the SH and SH2, the rte instruction reads the return pc from the stack,
519 ;; and thus we can't put a pop instruction in its delay slot.
520 ;; ??? On the SH3, the rte instruction does not use the stack, so a pop
521 ;; instruction can go in the delay slot.
523 ;; Since a normal return (rts) implicitly uses the PR register,
524 ;; we can't allow PR register loads in an rts delay slot.
527 (eq_attr "type" "return")
528 [(and (eq_attr "in_delay_slot" "yes")
529 (ior (and (eq_attr "interrupt_function" "no")
530 (eq_attr "type" "!pload,prset"))
531 (and (eq_attr "interrupt_function" "yes")
533 (ne (symbol_ref "TARGET_SH3") (const_int 0))
534 (eq_attr "hit_stack" "no"))))) (nil) (nil)])
536 ;; Since a call implicitly uses the PR register, we can't allow
537 ;; a PR register store in a jsr delay slot.
540 (ior (eq_attr "type" "call") (eq_attr "type" "sfunc"))
541 [(and (eq_attr "in_delay_slot" "yes")
542 (eq_attr "type" "!pstore,prget")) (nil) (nil)])
544 ;; Say that we have annulled true branches, since this gives smaller and
545 ;; faster code when branches are predicted as not taken.
547 ;; ??? The non-annulled condition should really be "in_delay_slot",
548 ;; but insns that can be filled in non-annulled get priority over insns
549 ;; that can only be filled in anulled.
552 (and (eq_attr "type" "cbranch")
553 (ne (symbol_ref "TARGET_SH2") (const_int 0)))
554 ;; SH2e has a hardware bug that pretty much prohibits the use of
555 ;; annuled delay slots.
556 [(eq_attr "cond_delay_slot" "yes") (and (eq_attr "cond_delay_slot" "yes")
557 (not (eq_attr "cpu" "sh2e"))) (nil)])
559 ;; -------------------------------------------------------------------------
560 ;; SImode signed integer comparisons
561 ;; -------------------------------------------------------------------------
565 (eq:SI (and:SI (match_operand:SI 0 "arith_reg_operand" "z,r")
566 (match_operand:SI 1 "arith_operand" "K08,r"))
570 [(set_attr "type" "mt_group")])
572 ;; ??? Perhaps should only accept reg/constant if the register is reg 0.
573 ;; That would still allow reload to create cmpi instructions, but would
574 ;; perhaps allow forcing the constant into a register when that is better.
575 ;; Probably should use r0 for mem/imm compares, but force constant into a
576 ;; register for pseudo/imm compares.
578 (define_insn "cmpeqsi_t"
580 (eq:SI (match_operand:SI 0 "arith_reg_operand" "r,z,r")
581 (match_operand:SI 1 "arith_operand" "N,rI08,r")))]
587 [(set_attr "type" "mt_group")])
589 (define_insn "cmpgtsi_t"
591 (gt:SI (match_operand:SI 0 "arith_reg_operand" "r,r")
592 (match_operand:SI 1 "arith_reg_or_0_operand" "r,N")))]
597 [(set_attr "type" "mt_group")])
599 (define_insn "cmpgesi_t"
601 (ge:SI (match_operand:SI 0 "arith_reg_operand" "r,r")
602 (match_operand:SI 1 "arith_reg_or_0_operand" "r,N")))]
607 [(set_attr "type" "mt_group")])
609 ;; -------------------------------------------------------------------------
610 ;; SImode unsigned integer comparisons
611 ;; -------------------------------------------------------------------------
613 (define_insn "cmpgeusi_t"
615 (geu:SI (match_operand:SI 0 "arith_reg_operand" "r")
616 (match_operand:SI 1 "arith_reg_operand" "r")))]
619 [(set_attr "type" "mt_group")])
621 (define_insn "cmpgtusi_t"
623 (gtu:SI (match_operand:SI 0 "arith_reg_operand" "r")
624 (match_operand:SI 1 "arith_reg_operand" "r")))]
627 [(set_attr "type" "mt_group")])
629 ;; We save the compare operands in the cmpxx patterns and use them when
630 ;; we generate the branch.
632 (define_expand "cmpsi"
634 (compare (match_operand:SI 0 "cmpsi_operand" "")
635 (match_operand:SI 1 "arith_operand" "")))]
636 "TARGET_SH1 || TARGET_SHMEDIA"
639 if (GET_CODE (operands[0]) == REG && REGNO (operands[0]) == T_REG
640 && GET_CODE (operands[1]) != CONST_INT)
641 operands[0] = copy_to_mode_reg (SImode, operands[0]);
642 sh_compare_op0 = operands[0];
643 sh_compare_op1 = operands[1];
647 ;; -------------------------------------------------------------------------
648 ;; DImode signed integer comparisons
649 ;; -------------------------------------------------------------------------
651 ;; ??? Could get better scheduling by splitting the initial test from the
652 ;; rest of the insn after reload. However, the gain would hardly justify
653 ;; the sh.md size increase necessary to do that.
657 (eq:SI (and:DI (match_operand:DI 0 "arith_reg_operand" "r")
658 (match_operand:DI 1 "arith_operand" "r"))
661 "* return output_branchy_insn (EQ, \"tst\\t%S1,%S0\;bf\\t%l9\;tst\\t%R1,%R0\",
663 [(set_attr "length" "6")
664 (set_attr "type" "arith3b")])
666 (define_insn "cmpeqdi_t"
668 (eq:SI (match_operand:DI 0 "arith_reg_operand" "r,r")
669 (match_operand:DI 1 "arith_reg_or_0_operand" "N,r")))]
672 tst %S0,%S0\;bf %,Ldi%=\;tst %R0,%R0\\n%,Ldi%=:
673 cmp/eq %S1,%S0\;bf %,Ldi%=\;cmp/eq %R1,%R0\\n%,Ldi%=:"
674 [(set_attr "length" "6")
675 (set_attr "type" "arith3b")])
679 (eq:SI (match_operand:DI 0 "arith_reg_operand" "")
680 (match_operand:DI 1 "arith_reg_or_0_operand" "")))]
681 ;; If we applied this split when not optimizing, it would only be
682 ;; applied during the machine-dependent reorg, when no new basic blocks
684 "TARGET_SH1 && reload_completed && optimize"
685 [(set (reg:SI T_REG) (eq:SI (match_dup 2) (match_dup 3)))
686 (set (pc) (if_then_else (eq (reg:SI T_REG) (const_int 0))
687 (label_ref (match_dup 6))
689 (set (reg:SI T_REG) (eq:SI (match_dup 4) (match_dup 5)))
694 = gen_rtx_REG (SImode,
695 true_regnum (operands[0]) + (TARGET_LITTLE_ENDIAN ? 1 : 0));
697 = (operands[1] == const0_rtx
699 : gen_rtx_REG (SImode,
700 true_regnum (operands[1])
701 + (TARGET_LITTLE_ENDIAN ? 1 : 0)));
702 operands[4] = gen_lowpart (SImode, operands[0]);
703 operands[5] = gen_lowpart (SImode, operands[1]);
704 operands[6] = gen_label_rtx ();
707 (define_insn "cmpgtdi_t"
709 (gt:SI (match_operand:DI 0 "arith_reg_operand" "r,r")
710 (match_operand:DI 1 "arith_reg_or_0_operand" "r,N")))]
713 cmp/eq\\t%S1,%S0\;bf{.|/}s\\t%,Ldi%=\;cmp/gt\\t%S1,%S0\;cmp/hi\\t%R1,%R0\\n%,Ldi%=:
714 tst\\t%S0,%S0\;bf{.|/}s\\t%,Ldi%=\;cmp/pl\\t%S0\;cmp/hi\\t%S0,%R0\\n%,Ldi%=:"
715 [(set_attr "length" "8")
716 (set_attr "type" "arith3")])
718 (define_insn "cmpgedi_t"
720 (ge:SI (match_operand:DI 0 "arith_reg_operand" "r,r")
721 (match_operand:DI 1 "arith_reg_or_0_operand" "r,N")))]
724 cmp/eq\\t%S1,%S0\;bf{.|/}s\\t%,Ldi%=\;cmp/ge\\t%S1,%S0\;cmp/hs\\t%R1,%R0\\n%,Ldi%=:
726 [(set_attr "length" "8,2")
727 (set_attr "type" "arith3,mt_group")])
729 ;; -------------------------------------------------------------------------
730 ;; DImode unsigned integer comparisons
731 ;; -------------------------------------------------------------------------
733 (define_insn "cmpgeudi_t"
735 (geu:SI (match_operand:DI 0 "arith_reg_operand" "r")
736 (match_operand:DI 1 "arith_reg_operand" "r")))]
738 "cmp/eq\\t%S1,%S0\;bf{.|/}s\\t%,Ldi%=\;cmp/hs\\t%S1,%S0\;cmp/hs\\t%R1,%R0\\n%,Ldi%=:"
739 [(set_attr "length" "8")
740 (set_attr "type" "arith3")])
742 (define_insn "cmpgtudi_t"
744 (gtu:SI (match_operand:DI 0 "arith_reg_operand" "r")
745 (match_operand:DI 1 "arith_reg_operand" "r")))]
747 "cmp/eq\\t%S1,%S0\;bf{.|/}s\\t%,Ldi%=\;cmp/hi\\t%S1,%S0\;cmp/hi\\t%R1,%R0\\n%,Ldi%=:"
748 [(set_attr "length" "8")
749 (set_attr "type" "arith3")])
751 (define_insn "cmpeqsi_media"
752 [(set (match_operand:DI 0 "register_operand" "=r")
753 (eq:DI (match_operand:SI 1 "logical_operand" "%r")
754 (match_operand:SI 2 "cmp_operand" "Nr")))]
757 [(set_attr "type" "cmp_media")])
759 (define_insn "cmpeqdi_media"
760 [(set (match_operand:DI 0 "register_operand" "=r")
761 (eq:DI (match_operand:DI 1 "register_operand" "%r")
762 (match_operand:DI 2 "cmp_operand" "Nr")))]
765 [(set_attr "type" "cmp_media")])
767 (define_insn "cmpgtsi_media"
768 [(set (match_operand:DI 0 "register_operand" "=r")
769 (gt:DI (match_operand:SI 1 "cmp_operand" "Nr")
770 (match_operand:SI 2 "cmp_operand" "rN")))]
773 [(set_attr "type" "cmp_media")])
775 (define_insn "cmpgtdi_media"
776 [(set (match_operand:DI 0 "register_operand" "=r")
777 (gt:DI (match_operand:DI 1 "arith_reg_or_0_operand" "Nr")
778 (match_operand:DI 2 "arith_reg_or_0_operand" "rN")))]
781 [(set_attr "type" "cmp_media")])
783 (define_insn "cmpgtusi_media"
784 [(set (match_operand:DI 0 "register_operand" "=r")
785 (gtu:DI (match_operand:SI 1 "cmp_operand" "Nr")
786 (match_operand:SI 2 "cmp_operand" "rN")))]
788 "cmpgtu %N1, %N2, %0"
789 [(set_attr "type" "cmp_media")])
791 (define_insn "cmpgtudi_media"
792 [(set (match_operand:DI 0 "register_operand" "=r")
793 (gtu:DI (match_operand:DI 1 "arith_reg_or_0_operand" "Nr")
794 (match_operand:DI 2 "arith_reg_or_0_operand" "rN")))]
796 "cmpgtu %N1, %N2, %0"
797 [(set_attr "type" "cmp_media")])
799 (define_insn "cmpsieqsi_media"
800 [(set (match_operand:SI 0 "register_operand" "=r")
801 (eq:SI (match_operand:SI 1 "logical_operand" "%r")
802 (match_operand:SI 2 "cmp_operand" "Nr")))]
805 [(set_attr "type" "cmp_media")])
807 (define_insn "cmpsieqdi_media"
808 [(set (match_operand:SI 0 "register_operand" "=r")
809 (eq:SI (match_operand:DI 1 "register_operand" "%r")
810 (match_operand:DI 2 "cmp_operand" "Nr")))]
813 [(set_attr "type" "cmp_media")])
815 (define_insn "cmpsigtsi_media"
816 [(set (match_operand:SI 0 "register_operand" "=r")
817 (gt:SI (match_operand:SI 1 "cmp_operand" "Nr")
818 (match_operand:SI 2 "cmp_operand" "rN")))]
821 [(set_attr "type" "cmp_media")])
823 (define_insn "cmpsigtdi_media"
824 [(set (match_operand:SI 0 "register_operand" "=r")
825 (gt:SI (match_operand:DI 1 "arith_reg_or_0_operand" "Nr")
826 (match_operand:DI 2 "arith_reg_or_0_operand" "rN")))]
829 [(set_attr "type" "cmp_media")])
831 (define_insn "cmpsigtusi_media"
832 [(set (match_operand:SI 0 "register_operand" "=r")
833 (gtu:SI (match_operand:SI 1 "cmp_operand" "Nr")
834 (match_operand:SI 2 "cmp_operand" "rN")))]
836 "cmpgtu %N1, %N2, %0"
837 [(set_attr "type" "cmp_media")])
839 (define_insn "cmpsigtudi_media"
840 [(set (match_operand:SI 0 "register_operand" "=r")
841 (gtu:SI (match_operand:DI 1 "arith_reg_or_0_operand" "Nr")
842 (match_operand:DI 2 "arith_reg_or_0_operand" "rN")))]
844 "cmpgtu %N1, %N2, %0"
845 [(set_attr "type" "cmp_media")])
847 ; These two patterns are for combine.
848 (define_insn "*cmpne0si_media"
849 [(set (match_operand:DI 0 "register_operand" "=r")
850 (ne:DI (match_operand:SI 1 "arith_reg_operand" "r") (const_int 0)))]
853 [(set_attr "type" "cmp_media")])
855 (define_insn "*cmpne0sisi_media"
856 [(set (match_operand:SI 0 "register_operand" "=r")
857 (ne:SI (match_operand:SI 1 "arith_reg_operand" "r") (const_int 0)))]
860 [(set_attr "type" "cmp_media")])
862 ;; We save the compare operands in the cmpxx patterns and use them when
863 ;; we generate the branch.
865 (define_expand "cmpdi"
867 (compare (match_operand:DI 0 "arith_operand" "")
868 (match_operand:DI 1 "arith_operand" "")))]
869 "TARGET_SH2 || TARGET_SHMEDIA"
872 sh_compare_op0 = operands[0];
873 sh_compare_op1 = operands[1];
876 ;; -------------------------------------------------------------------------
877 ;; Conditional move instructions
878 ;; -------------------------------------------------------------------------
880 ;; The insn names may seem reversed, but note that cmveq performs the move
881 ;; if op1 == 0, and cmvne does it if op1 != 0.
883 (define_insn "movdicc_false"
884 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
885 (if_then_else:DI (eq (match_operand:DI 1 "arith_reg_operand" "r")
887 (match_operand:DI 2 "arith_reg_or_0_operand" "rN")
888 (match_operand:DI 3 "arith_reg_operand" "0")))]
891 [(set_attr "type" "arith_media")])
893 (define_insn "movdicc_true"
894 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
895 (if_then_else:DI (ne (match_operand:DI 1 "arith_reg_operand" "r")
897 (match_operand:DI 2 "arith_reg_or_0_operand" "rN")
898 (match_operand:DI 3 "arith_reg_operand" "0")))]
901 [(set_attr "type" "arith_media")])
904 [(set (match_operand:DI 0 "arith_reg_dest" "")
905 (if_then_else:DI (match_operator 3 "equality_comparison_operator"
906 [(match_operand:DI 1 "arith_reg_operand" "")
908 (match_operand:DI 2 "arith_reg_dest" "")
910 (set (match_dup 2) (match_dup 0))]
911 "TARGET_SHMEDIA && peep2_reg_dead_p (2, operands[0])"
913 (if_then_else:DI (match_dup 3) (match_dup 0) (match_dup 2)))]
916 operands[3] = gen_rtx_fmt_ee (reverse_condition (GET_CODE (operands[3])),
917 VOIDmode, operands[1], CONST0_RTX (DImode));
921 [(set (match_operand:DI 0 "general_movdst_operand" "")
922 (match_operand:DI 1 "arith_reg_or_0_operand" ""))
923 (set (match_operand:DI 2 "arith_reg_dest" "")
924 (if_then_else:DI (match_operator 4 "equality_comparison_operator"
925 [(match_operand:DI 3 "arith_reg_operand" "")
929 "TARGET_SHMEDIA && peep2_reg_dead_p (2, operands[0])"
931 (if_then_else:DI (match_dup 4) (match_dup 1) (match_dup 2)))]
934 (define_expand "movdicc"
935 [(set (match_operand:DI 0 "register_operand" "")
936 (if_then_else:DI (match_operand 1 "comparison_operator" "")
937 (match_operand:DI 2 "register_operand" "")
938 (match_operand:DI 3 "register_operand" "")))]
942 if ((GET_CODE (operands[1]) == EQ || GET_CODE (operands[1]) == NE)
943 && GET_MODE (sh_compare_op0) == DImode
944 && sh_compare_op1 == const0_rtx)
945 operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]), VOIDmode,
946 sh_compare_op0, sh_compare_op1);
954 tmp = gen_reg_rtx (DImode);
956 switch (GET_CODE (operands[1]))
959 emit_insn (gen_seq (tmp));
960 operands[1] = gen_rtx_NE (VOIDmode, tmp, const0_rtx);
964 emit_insn (gen_seq (tmp));
965 operands[1] = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
969 emit_insn (gen_sgt (tmp));
970 operands[1] = gen_rtx_NE (VOIDmode, tmp, const0_rtx);
974 emit_insn (gen_slt (tmp));
975 operands[1] = gen_rtx_NE (VOIDmode, tmp, const0_rtx);
979 emit_insn (gen_slt (tmp));
980 operands[1] = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
984 emit_insn (gen_sgt (tmp));
985 operands[1] = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
989 emit_insn (gen_sgtu (tmp));
990 operands[1] = gen_rtx_NE (VOIDmode, tmp, const0_rtx);
994 emit_insn (gen_sltu (tmp));
995 operands[1] = gen_rtx_NE (VOIDmode, tmp, const0_rtx);
999 emit_insn (gen_sltu (tmp));
1000 operands[1] = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
1004 emit_insn (gen_sgtu (tmp));
1005 operands[1] = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
1009 emit_insn (gen_sunordered (tmp));
1010 operands[1] = gen_rtx_NE (VOIDmode, tmp, const0_rtx);
1014 emit_insn (gen_sunordered (tmp));
1015 operands[1] = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
1032 ;; Add SImode variants for cmveq / cmvne to compensate for not promoting
1033 ;; SImode to DImode.
1034 (define_insn "movsicc_false"
1035 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
1036 (if_then_else:SI (eq (match_operand:SI 1 "arith_reg_operand" "r")
1038 (match_operand:SI 2 "arith_reg_or_0_operand" "rN")
1039 (match_operand:SI 3 "arith_reg_operand" "0")))]
1042 [(set_attr "type" "arith_media")])
1044 (define_insn "movsicc_true"
1045 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
1046 (if_then_else:SI (ne (match_operand:SI 1 "arith_reg_operand" "r")
1048 (match_operand:SI 2 "arith_reg_or_0_operand" "rN")
1049 (match_operand:SI 3 "arith_reg_operand" "0")))]
1052 [(set_attr "type" "arith_media")])
1055 [(set (match_operand:SI 0 "arith_reg_dest" "")
1056 (if_then_else:SI (match_operator 3 "equality_comparison_operator"
1057 [(match_operand:SI 1 "arith_reg_operand" "")
1059 (match_operand:SI 2 "arith_reg_dest" "")
1061 (set (match_dup 2) (match_dup 0))]
1062 "TARGET_SHMEDIA && peep2_reg_dead_p (2, operands[0])"
1064 (if_then_else:SI (match_dup 3) (match_dup 0) (match_dup 2)))]
1067 operands[3] = gen_rtx_fmt_ee (reverse_condition (GET_CODE (operands[3])),
1068 VOIDmode, operands[1], CONST0_RTX (SImode));
1072 [(set (match_operand:SI 0 "general_movdst_operand" "")
1073 (match_operand:SI 1 "arith_reg_or_0_operand" ""))
1074 (set (match_operand:SI 2 "arith_reg_dest" "")
1075 (if_then_else:SI (match_operator 4 "equality_comparison_operator"
1076 [(match_operand:SI 3 "arith_reg_operand" "")
1080 "TARGET_SHMEDIA && peep2_reg_dead_p (2, operands[0])
1081 && (GET_CODE (operands[1]) != REG || GENERAL_REGISTER_P (REGNO (operands[1])))"
1083 (if_then_else:SI (match_dup 4) (match_dup 1) (match_dup 2)))]
1086 replace_rtx (operands[4], operands[0], operands[1]);
1090 [(set (match_operand 0 "any_register_operand" "")
1091 (match_operand 1 "any_register_operand" ""))
1092 (set (match_operand 2 "any_register_operand" "") (match_operand 3 "" ""))
1093 (set (match_operand 4 "" "") (match_operand 5 "" ""))]
1094 "(HARD_REGNO_NREGS (REGNO (operands[0]), GET_MODE (operands[2]))
1095 <= HARD_REGNO_NREGS (REGNO (operands[0]), GET_MODE (operands[0])))
1096 && peep2_reg_dead_p (3, operands[0]) && peep2_reg_dead_p (3, operands[2])
1097 && ! reg_overlap_mentioned_p (operands[0], operands[3])
1098 && ! reg_overlap_mentioned_p (operands[2], operands[0])
1099 && ! reg_overlap_mentioned_p (operands[0], operands[1])
1100 && (REGNO_REG_CLASS (REGNO (operands[0]))
1101 == REGNO_REG_CLASS (REGNO (operands[2])))
1102 && (REGNO_REG_CLASS (REGNO (operands[1]))
1103 == REGNO_REG_CLASS (REGNO (operands[0])))"
1104 [(set (match_dup 0) (match_dup 3))
1105 (set (match_dup 4) (match_dup 5))]
1109 rtx replacements[4];
1111 /* We want to replace occurrences of operands[0] with operands[1] and
1112 operands[2] with operands[0] in operands[4]/operands[5].
1113 Doing just two replace_rtx calls naively would result in the second
1114 replacement undoing all that the first did if operands[1] and operands[2]
1115 are identical, so we must do this simultaneously. */
1116 replacements[0] = operands[0];
1117 replacements[1] = operands[1];
1118 replacements[2] = operands[2];
1119 replacements[3] = operands[0];
1120 if (!replace_n_hard_rtx (operands[5], replacements, 2, 0)
1121 || !replace_n_hard_rtx (operands[4], replacements, 2, 0)
1122 || !replace_n_hard_rtx (operands[2], replacements, 2, 0))
1125 operands[5] = replace_n_hard_rtx (operands[5], replacements, 2, 1);
1126 replace_n_hard_rtx (operands[4], replacements, 2, 1);
1127 operands[2] = replace_n_hard_rtx (operands[2], replacements, 2, 1);
1128 /* The operands array is aliased to recog_data.operand, which gets
1129 clobbered by extract_insn, so finish with it now. */
1130 set1 = gen_rtx_SET (VOIDmode, operands[2], operands[3]);
1131 set2 = gen_rtx_SET (VOIDmode, operands[4], operands[5]);
1132 /* ??? The last insn might be a jump insn, but the generic peephole2 code
1133 always uses emit_insn. */
1134 /* Check that we don't violate matching constraints or earlyclobbers. */
1135 extract_insn (emit_insn (set1));
1136 if (! constrain_operands (1))
1138 extract_insn (emit (set2));
1139 if (! constrain_operands (1))
1143 tmp = replacements[0];
1144 replacements[0] = replacements[1];
1145 replacements[1] = tmp;
1146 tmp = replacements[2];
1147 replacements[2] = replacements[3];
1148 replacements[3] = tmp;
1149 replace_n_hard_rtx (SET_DEST (set1), replacements, 2, 1);
1150 replace_n_hard_rtx (SET_DEST (set2), replacements, 2, 1);
1151 replace_n_hard_rtx (SET_SRC (set2), replacements, 2, 1);
1157 ;; The register allocator is rather clumsy in handling multi-way conditional
1158 ;; moves, so allow the combiner to make them, and we split them up after
1160 (define_insn_and_split "*movsicc_umin"
1161 [(set (match_operand:SI 0 "arith_reg_dest" "=&r")
1162 (umin:SI (if_then_else:SI
1163 (eq (match_operand:SI 1 "arith_reg_operand" "r")
1165 (match_operand:SI 2 "arith_reg_or_0_operand" "rN")
1166 (match_operand:SI 3 "register_operand" "0"))
1167 (match_operand:SI 4 "arith_reg_or_0_operand" "r")))
1168 (clobber (match_scratch:SI 5 "=&r"))]
1169 "TARGET_SHMEDIA && no_new_pseudos"
1171 "TARGET_SHMEDIA && reload_completed"
1175 emit_insn (gen_movsicc_false (operands[0], operands[1], operands[2],
1177 emit_insn (gen_cmpsigtusi_media (operands[5], operands[4], operands[0]));
1178 emit_insn (gen_movsicc_false (operands[0], operands[5], operands[4],
1183 (define_expand "movsicc"
1184 [(set (match_operand:SI 0 "register_operand" "")
1185 (if_then_else:SI (match_operand 1 "comparison_operator" "")
1186 (match_operand:SI 2 "register_operand" "")
1187 (match_operand:SI 3 "register_operand" "")))]
1191 if ((GET_CODE (operands[1]) == EQ || GET_CODE (operands[1]) == NE)
1192 && GET_MODE (sh_compare_op0) == SImode
1193 && sh_compare_op1 == const0_rtx)
1194 operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]), VOIDmode,
1195 sh_compare_op0, sh_compare_op1);
1203 tmp = gen_reg_rtx (SImode);
1205 switch (GET_CODE (operands[1]))
1208 emit_insn (gen_seq (tmp));
1209 operands[1] = gen_rtx_NE (VOIDmode, tmp, const0_rtx);
1213 emit_insn (gen_seq (tmp));
1214 operands[1] = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
1218 emit_insn (gen_sgt (tmp));
1219 operands[1] = gen_rtx_NE (VOIDmode, tmp, const0_rtx);
1223 emit_insn (gen_slt (tmp));
1224 operands[1] = gen_rtx_NE (VOIDmode, tmp, const0_rtx);
1228 emit_insn (gen_slt (tmp));
1229 operands[1] = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
1233 emit_insn (gen_sgt (tmp));
1234 operands[1] = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
1238 emit_insn (gen_sgtu (tmp));
1239 operands[1] = gen_rtx_NE (VOIDmode, tmp, const0_rtx);
1243 emit_insn (gen_sltu (tmp));
1244 operands[1] = gen_rtx_NE (VOIDmode, tmp, const0_rtx);
1248 emit_insn (gen_sltu (tmp));
1249 operands[1] = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
1253 emit_insn (gen_sgtu (tmp));
1254 operands[1] = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
1258 emit_insn (gen_sunordered (tmp));
1259 operands[1] = gen_rtx_NE (VOIDmode, tmp, const0_rtx);
1263 emit_insn (gen_sunordered (tmp));
1264 operands[1] = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
1281 (define_expand "movqicc"
1282 [(set (match_operand:QI 0 "register_operand" "")
1283 (if_then_else:QI (match_operand 1 "comparison_operator" "")
1284 (match_operand:QI 2 "register_operand" "")
1285 (match_operand:QI 3 "register_operand" "")))]
1289 operands[0] = simplify_gen_subreg (SImode, operands[0], QImode, 0);
1290 operands[2] = simplify_gen_subreg (SImode, operands[2], QImode, 0);
1291 operands[3] = simplify_gen_subreg (SImode, operands[3], QImode, 0);
1292 emit (gen_movsicc (operands[0], operands[1], operands[2], operands[3]));
1296 ;; -------------------------------------------------------------------------
1297 ;; Addition instructions
1298 ;; -------------------------------------------------------------------------
1300 (define_expand "adddi3"
1301 [(set (match_operand:DI 0 "arith_reg_operand" "")
1302 (plus:DI (match_operand:DI 1 "arith_reg_operand" "")
1303 (match_operand:DI 2 "arith_operand" "")))]
1309 if (no_new_pseudos && ! arith_reg_operand (operands[2], DImode))
1311 operands[2] = force_reg (DImode, operands[2]);
1312 emit_insn (gen_adddi3_compact (operands[0], operands[1], operands[2]));
1317 (define_insn "*adddi3_media"
1318 [(set (match_operand:DI 0 "arith_reg_dest" "=r,r")
1319 (plus:DI (match_operand:DI 1 "arith_reg_operand" "%r,r")
1320 (match_operand:DI 2 "arith_operand" "r,I10")))]
1325 [(set_attr "type" "arith_media")])
1327 (define_insn "*adddisi3_media"
1328 [(set (subreg:DI (match_operand:SI 0 "arith_reg_operand" "=r,r") 0)
1329 (plus:DI (match_operand:DI 1 "arith_reg_operand" "%r,r")
1330 (match_operand:DI 2 "arith_operand" "r,I10")))]
1335 [(set_attr "type" "arith_media")
1336 (set_attr "highpart" "ignore")])
1338 (define_insn "adddi3z_media"
1339 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
1341 (plus:SI (match_operand:SI 1 "extend_reg_operand" "r")
1342 (match_operand:SI 2 "extend_reg_or_0_operand" "rN"))))]
1344 "addz.l %1, %N2, %0"
1345 [(set_attr "type" "arith_media")
1346 (set_attr "highpart" "ignore")])
1348 (define_insn "adddi3_compact"
1349 [(set (match_operand:DI 0 "arith_reg_dest" "=&r")
1350 (plus:DI (match_operand:DI 1 "arith_reg_operand" "%0")
1351 (match_operand:DI 2 "arith_reg_operand" "r")))
1352 (clobber (reg:SI T_REG))]
1355 [(set_attr "length" "6")])
1358 [(set (match_operand:DI 0 "arith_reg_dest" "")
1359 (plus:DI (match_operand:DI 1 "arith_reg_operand" "")
1360 (match_operand:DI 2 "arith_reg_operand" "")))
1361 (clobber (reg:SI T_REG))]
1362 "TARGET_SH1 && reload_completed"
1366 rtx high0, high2, low0 = gen_lowpart (SImode, operands[0]);
1367 high0 = gen_rtx_REG (SImode,
1368 true_regnum (operands[0])
1369 + (TARGET_LITTLE_ENDIAN ? 1 : 0));
1370 high2 = gen_rtx_REG (SImode,
1371 true_regnum (operands[2])
1372 + (TARGET_LITTLE_ENDIAN ? 1 : 0));
1373 emit_insn (gen_clrt ());
1374 emit_insn (gen_addc (low0, low0, gen_lowpart (SImode, operands[2])));
1375 emit_insn (gen_addc1 (high0, high0, high2));
1380 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
1381 (plus:SI (plus:SI (match_operand:SI 1 "arith_reg_operand" "0")
1382 (match_operand:SI 2 "arith_reg_operand" "r"))
1385 (ltu:SI (plus:SI (match_dup 1) (match_dup 2)) (match_dup 1)))]
1388 [(set_attr "type" "arith")])
1390 (define_insn "addc1"
1391 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
1392 (plus:SI (plus:SI (match_operand:SI 1 "arith_reg_operand" "0")
1393 (match_operand:SI 2 "arith_reg_operand" "r"))
1395 (clobber (reg:SI T_REG))]
1398 [(set_attr "type" "arith")])
1400 (define_expand "addsi3"
1401 [(set (match_operand:SI 0 "arith_reg_operand" "")
1402 (plus:SI (match_operand:SI 1 "arith_operand" "")
1403 (match_operand:SI 2 "arith_operand" "")))]
1408 operands[1] = force_reg (SImode, operands[1]);
1411 (define_insn "addsi3_media"
1412 [(set (match_operand:SI 0 "arith_reg_dest" "=r,r")
1413 (plus:SI (match_operand:SI 1 "extend_reg_operand" "%r,r")
1414 (match_operand:SI 2 "arith_operand" "r,I10")))]
1419 [(set_attr "type" "arith_media")
1420 (set_attr "highpart" "ignore")])
1422 (define_insn "addsidi3_media"
1423 [(set (match_operand:DI 0 "arith_reg_dest" "=r,r")
1424 (sign_extend:DI (plus:SI (match_operand:SI 1 "extend_reg_operand"
1426 (match_operand:SI 2 "arith_operand"
1432 [(set_attr "type" "arith_media")
1433 (set_attr "highpart" "ignore")])
1435 (define_insn "*addsi3_compact"
1436 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
1437 (plus:SI (match_operand:SI 1 "arith_operand" "%0")
1438 (match_operand:SI 2 "arith_operand" "rI08")))]
1441 [(set_attr "type" "arith")])
1443 ;; -------------------------------------------------------------------------
1444 ;; Subtraction instructions
1445 ;; -------------------------------------------------------------------------
1447 (define_expand "subdi3"
1448 [(set (match_operand:DI 0 "arith_reg_operand" "")
1449 (minus:DI (match_operand:DI 1 "arith_reg_or_0_operand" "")
1450 (match_operand:DI 2 "arith_reg_operand" "")))]
1456 operands[1] = force_reg (DImode, operands[1]);
1457 emit_insn (gen_subdi3_compact (operands[0], operands[1], operands[2]));
1462 (define_insn "*subdi3_media"
1463 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
1464 (minus:DI (match_operand:DI 1 "arith_reg_or_0_operand" "rN")
1465 (match_operand:DI 2 "arith_reg_operand" "r")))]
1468 [(set_attr "type" "arith_media")])
1470 (define_insn "subdisi3_media"
1471 [(set (subreg:DI (match_operand:SI 0 "arith_reg_operand" "=r") 0)
1472 (minus:DI (match_operand:DI 1 "arith_reg_or_0_operand" "rN")
1473 (match_operand:DI 2 "arith_reg_operand" "r")))]
1476 [(set_attr "type" "arith_media")
1477 (set_attr "highpart" "ignore")])
1479 (define_insn "subdi3_compact"
1480 [(set (match_operand:DI 0 "arith_reg_dest" "=&r")
1481 (minus:DI (match_operand:DI 1 "arith_reg_operand" "0")
1482 (match_operand:DI 2 "arith_reg_operand" "r")))
1483 (clobber (reg:SI T_REG))]
1486 [(set_attr "length" "6")])
1489 [(set (match_operand:DI 0 "arith_reg_dest" "")
1490 (minus:DI (match_operand:DI 1 "arith_reg_operand" "")
1491 (match_operand:DI 2 "arith_reg_operand" "")))
1492 (clobber (reg:SI T_REG))]
1493 "TARGET_SH1 && reload_completed"
1497 rtx high0, high2, low0 = gen_lowpart (SImode, operands[0]);
1498 high0 = gen_rtx_REG (SImode,
1499 true_regnum (operands[0])
1500 + (TARGET_LITTLE_ENDIAN ? 1 : 0));
1501 high2 = gen_rtx_REG (SImode,
1502 true_regnum (operands[2])
1503 + (TARGET_LITTLE_ENDIAN ? 1 : 0));
1504 emit_insn (gen_clrt ());
1505 emit_insn (gen_subc (low0, low0, gen_lowpart (SImode, operands[2])));
1506 emit_insn (gen_subc1 (high0, high0, high2));
1511 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
1512 (minus:SI (minus:SI (match_operand:SI 1 "arith_reg_operand" "0")
1513 (match_operand:SI 2 "arith_reg_operand" "r"))
1516 (gtu:SI (minus:SI (minus:SI (match_dup 1) (match_dup 2))
1521 [(set_attr "type" "arith")])
1523 (define_insn "subc1"
1524 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
1525 (minus:SI (minus:SI (match_operand:SI 1 "arith_reg_operand" "0")
1526 (match_operand:SI 2 "arith_reg_operand" "r"))
1528 (clobber (reg:SI T_REG))]
1531 [(set_attr "type" "arith")])
1533 ;; life_analysis thinks rn is live before subc rn,rn, so make a special
1534 ;; pattern for this case. This helps multimedia applications that compute
1535 ;; the sum of absolute differences.
1536 (define_insn "mov_neg_si_t"
1537 [(set (match_operand:SI 0 "arith_reg_dest" "=r") (neg:SI (reg:SI T_REG)))]
1540 [(set_attr "type" "arith")])
1542 (define_insn "*subsi3_internal"
1543 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
1544 (minus:SI (match_operand:SI 1 "arith_reg_operand" "0")
1545 (match_operand:SI 2 "arith_reg_operand" "r")))]
1548 [(set_attr "type" "arith")])
1550 (define_insn_and_split "*subsi3_media"
1551 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
1552 (minus:SI (match_operand:SI 1 "minuend_operand" "rN")
1553 (match_operand:SI 2 "extend_reg_operand" "r")))]
1555 && (operands[1] != constm1_rtx
1556 || (GET_CODE (operands[2]) != TRUNCATE
1557 && GET_CODE (operands[2]) != SUBREG))"
1559 "operands[1] == constm1_rtx"
1560 [(set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))]
1562 [(set_attr "type" "arith_media")
1563 (set_attr "highpart" "ignore")])
1566 [(set (match_operand:SI 0 "arith_reg_dest" "")
1567 (zero_extend:SI (subreg:QI (not:SI (subreg:SI (match_operand:QI 1
1568 "general_extend_operand"
1570 "TARGET_SHMEDIA && TARGET_LITTLE_ENDIAN"
1571 [(set (match_dup 0) (zero_extend:SI (match_dup 1)))
1572 (set (match_dup 0) (xor:SI (match_dup 0) (const_int 255)))]
1576 [(set (match_operand:SI 0 "arith_reg_dest" "")
1577 (zero_extend:SI (subreg:QI (not:SI (subreg:SI (match_operand:QI 1
1578 "general_extend_operand"
1580 "TARGET_SHMEDIA && ! TARGET_LITTLE_ENDIAN"
1581 [(set (match_dup 0) (zero_extend:SI (match_dup 1)))
1582 (set (match_dup 0) (xor:SI (match_dup 0) (const_int 255)))]
1584 ;; Convert `constant - reg' to `neg rX; add rX, #const' since this
1585 ;; will sometimes save one instruction. Otherwise we might get
1586 ;; `mov #const, rY; sub rY,rX; mov rX, rY' if the source and dest regs
1589 (define_expand "subsi3"
1590 [(set (match_operand:SI 0 "arith_reg_operand" "")
1591 (minus:SI (match_operand:SI 1 "arith_operand" "")
1592 (match_operand:SI 2 "arith_reg_operand" "")))]
1596 if (TARGET_SH1 && GET_CODE (operands[1]) == CONST_INT)
1598 emit_insn (gen_negsi2 (operands[0], operands[2]));
1599 emit_insn (gen_addsi3 (operands[0], operands[0], operands[1]));
1604 if (no_new_pseudos && ! arith_reg_or_0_operand (operands[1], SImode))
1606 if (operands[1] != const0_rtx && GET_CODE (operands[1]) != SUBREG)
1607 operands[1] = force_reg (SImode, operands[1]);
1611 ;; -------------------------------------------------------------------------
1612 ;; Division instructions
1613 ;; -------------------------------------------------------------------------
1615 ;; We take advantage of the library routines which don't clobber as many
1616 ;; registers as a normal function call would.
1618 ;; The INSN_REFERENCES_ARE_DELAYED in sh.h is problematic because it
1619 ;; also has an effect on the register that holds the address of the sfunc.
1620 ;; To make this work, we have an extra dummy insn that shows the use
1621 ;; of this register for reorg.
1623 (define_insn "use_sfunc_addr"
1624 [(set (reg:SI PR_REG)
1625 (unspec:SI [(match_operand:SI 0 "register_operand" "r")] UNSPEC_SFUNC))]
1626 "TARGET_SH1 && check_use_sfunc_addr (insn, operands[0])"
1628 [(set_attr "length" "0")])
1630 (define_insn "udivsi3_sh2a"
1631 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
1632 (udiv:SI (match_operand:SI 1 "arith_reg_operand" "0")
1633 (match_operand:SI 2 "arith_reg_operand" "z")))]
1636 [(set_attr "type" "arith")
1637 (set_attr "in_delay_slot" "no")])
1639 ;; We must use a pseudo-reg forced to reg 0 in the SET_DEST rather than
1640 ;; hard register 0. If we used hard register 0, then the next instruction
1641 ;; would be a move from hard register 0 to a pseudo-reg. If the pseudo-reg
1642 ;; gets allocated to a stack slot that needs its address reloaded, then
1643 ;; there is nothing to prevent reload from using r0 to reload the address.
1644 ;; This reload would clobber the value in r0 we are trying to store.
1645 ;; If we let reload allocate r0, then this problem can never happen.
1647 (define_insn "udivsi3_i1"
1648 [(set (match_operand:SI 0 "register_operand" "=z")
1649 (udiv:SI (reg:SI R4_REG) (reg:SI R5_REG)))
1650 (clobber (reg:SI T_REG))
1651 (clobber (reg:SI PR_REG))
1652 (clobber (reg:SI R4_REG))
1653 (use (match_operand:SI 1 "arith_reg_operand" "r"))]
1654 "TARGET_SH1 && ! TARGET_SH4"
1656 [(set_attr "type" "sfunc")
1657 (set_attr "needs_delay_slot" "yes")])
1659 ; Since shmedia-nofpu code could be linked against shcompact code, and
1660 ; the udivsi3 libcall has the same name, we must consider all registers
1661 ; clobbered that are in the union of the registers clobbered by the
1662 ; shmedia and the shcompact implementation. Note, if the shcompact
1663 ; implementation actually used shcompact code, we'd need to clobber
1664 ; also r23 and fr23.
1665 (define_insn "udivsi3_i1_media"
1666 [(set (match_operand:SI 0 "register_operand" "=z")
1667 (udiv:SI (reg:SI R4_REG) (reg:SI R5_REG)))
1668 (clobber (reg:SI T_MEDIA_REG))
1669 (clobber (reg:SI PR_MEDIA_REG))
1670 (clobber (reg:SI R20_REG))
1671 (clobber (reg:SI R21_REG))
1672 (clobber (reg:SI R22_REG))
1673 (clobber (reg:DI TR0_REG))
1674 (clobber (reg:DI TR1_REG))
1675 (clobber (reg:DI TR2_REG))
1676 (use (match_operand 1 "target_operand" "b"))]
1677 "TARGET_SHMEDIA && (! TARGET_SHMEDIA_FPU || ! TARGET_DIVIDE_FP)"
1679 [(set_attr "type" "sfunc")
1680 (set_attr "needs_delay_slot" "yes")])
1682 (define_expand "udivsi3_i4_media"
1684 (zero_extend:DI (match_operand:SI 1 "register_operand" "")))
1686 (zero_extend:DI (match_operand:SI 2 "register_operand" "")))
1687 (set (match_dup 5) (float:DF (match_dup 3)))
1688 (set (match_dup 6) (float:DF (match_dup 4)))
1689 (set (match_dup 7) (div:DF (match_dup 5) (match_dup 6)))
1690 (set (match_dup 8) (fix:DI (match_dup 7)))
1691 (set (match_operand:SI 0 "register_operand" "")
1692 (truncate:SI (match_dup 8)))]
1693 "TARGET_SHMEDIA_FPU"
1696 operands[3] = gen_reg_rtx (DImode);
1697 operands[4] = gen_reg_rtx (DImode);
1698 operands[5] = gen_reg_rtx (DFmode);
1699 operands[6] = gen_reg_rtx (DFmode);
1700 operands[7] = gen_reg_rtx (DFmode);
1701 operands[8] = gen_reg_rtx (DImode);
1704 (define_insn "udivsi3_i4"
1705 [(set (match_operand:SI 0 "register_operand" "=y")
1706 (udiv:SI (reg:SI R4_REG) (reg:SI R5_REG)))
1707 (clobber (reg:SI T_REG))
1708 (clobber (reg:SI PR_REG))
1709 (clobber (reg:DF DR0_REG))
1710 (clobber (reg:DF DR2_REG))
1711 (clobber (reg:DF DR4_REG))
1712 (clobber (reg:SI R0_REG))
1713 (clobber (reg:SI R1_REG))
1714 (clobber (reg:SI R4_REG))
1715 (clobber (reg:SI R5_REG))
1716 (use (reg:PSI FPSCR_REG))
1717 (use (match_operand:SI 1 "arith_reg_operand" "r"))]
1718 "TARGET_SH4 && ! TARGET_FPU_SINGLE"
1720 [(set_attr "type" "sfunc")
1721 (set_attr "fp_mode" "double")
1722 (set_attr "needs_delay_slot" "yes")])
1724 (define_insn "udivsi3_i4_single"
1725 [(set (match_operand:SI 0 "register_operand" "=y")
1726 (udiv:SI (reg:SI R4_REG) (reg:SI R5_REG)))
1727 (clobber (reg:SI T_REG))
1728 (clobber (reg:SI PR_REG))
1729 (clobber (reg:DF DR0_REG))
1730 (clobber (reg:DF DR2_REG))
1731 (clobber (reg:DF DR4_REG))
1732 (clobber (reg:SI R0_REG))
1733 (clobber (reg:SI R1_REG))
1734 (clobber (reg:SI R4_REG))
1735 (clobber (reg:SI R5_REG))
1736 (use (match_operand:SI 1 "arith_reg_operand" "r"))]
1737 "(TARGET_HARD_SH4 || TARGET_SHCOMPACT) && TARGET_FPU_SINGLE"
1739 [(set_attr "type" "sfunc")
1740 (set_attr "needs_delay_slot" "yes")])
1742 (define_expand "udivsi3"
1743 [(set (match_dup 3) (symbol_ref:SI "__udivsi3"))
1744 (set (reg:SI R4_REG) (match_operand:SI 1 "general_operand" ""))
1745 (set (reg:SI R5_REG) (match_operand:SI 2 "general_operand" ""))
1746 (parallel [(set (match_operand:SI 0 "register_operand" "")
1747 (udiv:SI (reg:SI R4_REG)
1749 (clobber (reg:SI T_REG))
1750 (clobber (reg:SI PR_REG))
1751 (clobber (reg:SI R4_REG))
1752 (use (match_dup 3))])]
1758 operands[3] = gen_reg_rtx (Pmode);
1759 /* Emit the move of the address to a pseudo outside of the libcall. */
1760 if (TARGET_HARD_SH4 && TARGET_SH2E)
1762 function_symbol (operands[3], \"__udivsi3_i4\", SFUNC_STATIC);
1763 if (TARGET_FPU_SINGLE)
1764 last = gen_udivsi3_i4_single (operands[0], operands[3]);
1766 last = gen_udivsi3_i4 (operands[0], operands[3]);
1768 else if (TARGET_SHMEDIA_FPU)
1770 operands[1] = force_reg (SImode, operands[1]);
1771 operands[2] = force_reg (SImode, operands[2]);
1772 emit_insn (gen_udivsi3_i4_media (operands[0], operands[1], operands[2]));
1775 else if (TARGET_SH2A)
1777 operands[1] = force_reg (SImode, operands[1]);
1778 operands[2] = force_reg (SImode, operands[2]);
1779 emit_insn (gen_udivsi3_sh2a (operands[0], operands[1], operands[2]));
1782 else if (TARGET_SH5)
1784 function_symbol (operands[3],
1785 TARGET_FPU_ANY ? \"__udivsi3_i4\" : \"__udivsi3\",
1789 last = gen_udivsi3_i1_media (operands[0], operands[3]);
1790 else if (TARGET_FPU_ANY)
1791 last = gen_udivsi3_i4_single (operands[0], operands[3]);
1793 last = gen_udivsi3_i1 (operands[0], operands[3]);
1797 function_symbol (operands[3], \"__udivsi3\", SFUNC_STATIC);
1798 last = gen_udivsi3_i1 (operands[0], operands[3]);
1800 first = emit_move_insn (gen_rtx_REG (SImode, 4), operands[1]);
1801 emit_move_insn (gen_rtx_REG (SImode, 5), operands[2]);
1802 last = emit_insn (last);
1803 /* Wrap the sequence in REG_LIBCALL / REG_RETVAL notes so that loop
1804 invariant code motion can move it. */
1805 REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last, REG_NOTES (first));
1806 REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first, REG_NOTES (last));
1810 (define_insn "divsi3_sh2a"
1811 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
1812 (div:SI (match_operand:SI 1 "arith_reg_operand" "0")
1813 (match_operand:SI 2 "arith_reg_operand" "z")))]
1816 [(set_attr "type" "arith")
1817 (set_attr "in_delay_slot" "no")])
1819 (define_insn "divsi3_i1"
1820 [(set (match_operand:SI 0 "register_operand" "=z")
1821 (div:SI (reg:SI R4_REG) (reg:SI R5_REG)))
1822 (clobber (reg:SI T_REG))
1823 (clobber (reg:SI PR_REG))
1824 (clobber (reg:SI R1_REG))
1825 (clobber (reg:SI R2_REG))
1826 (clobber (reg:SI R3_REG))
1827 (use (match_operand:SI 1 "arith_reg_operand" "r"))]
1828 "TARGET_SH1 && ! TARGET_SH4"
1830 [(set_attr "type" "sfunc")
1831 (set_attr "needs_delay_slot" "yes")])
1833 (define_insn "divsi3_i1_media"
1834 [(set (match_operand:SI 0 "register_operand" "=z")
1835 (div:SI (reg:SI R4_REG) (reg:SI R5_REG)))
1836 (clobber (reg:SI T_MEDIA_REG))
1837 (clobber (reg:SI PR_MEDIA_REG))
1838 (clobber (reg:SI R1_REG))
1839 (clobber (reg:SI R20_REG))
1840 (clobber (reg:SI R21_REG))
1841 (clobber (reg:SI TR0_REG))
1842 (use (match_operand 1 "target_operand" "b"))]
1843 "TARGET_SHMEDIA && (! TARGET_SHMEDIA_FPU || ! TARGET_DIVIDE_FP)"
1845 [(set_attr "type" "sfunc")])
1847 (define_insn "divsi3_media_2"
1848 [(set (match_operand:SI 0 "register_operand" "=z")
1849 (div:SI (reg:SI R4_REG) (reg:SI R5_REG)))
1850 (clobber (reg:SI T_MEDIA_REG))
1851 (clobber (reg:SI PR_MEDIA_REG))
1852 (clobber (reg:SI R1_REG))
1853 (clobber (reg:SI R21_REG))
1854 (clobber (reg:SI TR0_REG))
1855 (use (reg:SI R20_REG))
1856 (use (match_operand 1 "target_operand" "b"))]
1857 "TARGET_SHMEDIA && (! TARGET_SHMEDIA_FPU || ! TARGET_DIVIDE_FP)"
1859 [(set_attr "type" "sfunc")])
1861 ;; This pattern acts as a placeholder for -mdiv=inv:call to carry
1862 ;; hard reg clobbers and data dependencies that we need when we want
1863 ;; to rematerialize the division into a call.
1864 (define_insn_and_split "divsi_inv_call"
1865 [(set (match_operand:SI 0 "register_operand" "=r")
1866 (div:SI (match_operand:SI 1 "register_operand" "r")
1867 (match_operand:SI 2 "register_operand" "r")))
1868 (clobber (reg:SI R4_REG))
1869 (clobber (reg:SI R5_REG))
1870 (clobber (reg:SI T_MEDIA_REG))
1871 (clobber (reg:SI PR_MEDIA_REG))
1872 (clobber (reg:SI R1_REG))
1873 (clobber (reg:SI R21_REG))
1874 (clobber (reg:SI TR0_REG))
1875 (clobber (reg:SI R20_REG))
1876 (use (match_operand:SI 3 "register_operand" "r"))]
1879 "&& (high_life_started || reload_completed)"
1880 [(set (match_dup 0) (match_dup 3))]
1882 [(set_attr "highpart" "must_split")])
1884 ;; This is the combiner pattern for -mdiv=inv:call .
1885 (define_insn_and_split "*divsi_inv_call_combine"
1886 [(set (match_operand:SI 0 "register_operand" "=z")
1887 (div:SI (match_operand:SI 1 "register_operand" "r")
1888 (match_operand:SI 2 "register_operand" "r")))
1889 (clobber (reg:SI R4_REG))
1890 (clobber (reg:SI R5_REG))
1891 (clobber (reg:SI T_MEDIA_REG))
1892 (clobber (reg:SI PR_MEDIA_REG))
1893 (clobber (reg:SI R1_REG))
1894 (clobber (reg:SI R21_REG))
1895 (clobber (reg:SI TR0_REG))
1896 (clobber (reg:SI R20_REG))
1897 (use (unspec:SI [(match_dup 1)
1898 (match_operand:SI 3 "" "")
1899 (unspec:SI [(match_operand:SI 4 "" "")
1901 (match_operand:DI 5 "" "")]
1903 (match_operand:DI 6 "" "")
1906 UNSPEC_DIV_INV_M3))]
1909 "&& (high_life_started || reload_completed)"
1913 const char *name = sh_divsi3_libfunc;
1914 enum sh_function_kind kind = SFUNC_GOT;
1917 emit_move_insn (gen_rtx_REG (SImode, R4_REG), operands[1]);
1918 emit_move_insn (gen_rtx_REG (SImode, R5_REG), operands[2]);
1919 while (TARGET_DIVIDE_INV_CALL2)
1921 rtx x = operands[3];
1923 if (GET_CODE (x) != UNSPEC || XINT (x, 1) != UNSPEC_DIV_INV_M1)
1925 x = XVECEXP (x, 0, 0);
1926 name = \"__sdivsi3_2\";
1927 kind = SFUNC_STATIC;
1928 emit_move_insn (gen_rtx_REG (DImode, R20_REG), x);
1931 sym = function_symbol (NULL, name, kind);
1932 emit_insn (gen_divsi3_media_2 (operands[0], sym));
1935 [(set_attr "highpart" "must_split")])
1937 (define_expand "divsi3_i4_media"
1938 [(set (match_dup 3) (float:DF (match_operand:SI 1 "register_operand" "r")))
1939 (set (match_dup 4) (float:DF (match_operand:SI 2 "register_operand" "r")))
1940 (set (match_dup 5) (div:DF (match_dup 3) (match_dup 4)))
1941 (set (match_operand:SI 0 "register_operand" "=r")
1942 (fix:SI (match_dup 5)))]
1943 "TARGET_SHMEDIA_FPU"
1946 operands[3] = gen_reg_rtx (DFmode);
1947 operands[4] = gen_reg_rtx (DFmode);
1948 operands[5] = gen_reg_rtx (DFmode);
1951 (define_insn "divsi3_i4"
1952 [(set (match_operand:SI 0 "register_operand" "=y")
1953 (div:SI (reg:SI R4_REG) (reg:SI R5_REG)))
1954 (clobber (reg:SI PR_REG))
1955 (clobber (reg:DF DR0_REG))
1956 (clobber (reg:DF DR2_REG))
1957 (use (reg:PSI FPSCR_REG))
1958 (use (match_operand:SI 1 "arith_reg_operand" "r"))]
1959 "TARGET_SH4 && ! TARGET_FPU_SINGLE"
1961 [(set_attr "type" "sfunc")
1962 (set_attr "fp_mode" "double")
1963 (set_attr "needs_delay_slot" "yes")])
1965 (define_insn "divsi3_i4_single"
1966 [(set (match_operand:SI 0 "register_operand" "=y")
1967 (div:SI (reg:SI R4_REG) (reg:SI R5_REG)))
1968 (clobber (reg:SI PR_REG))
1969 (clobber (reg:DF DR0_REG))
1970 (clobber (reg:DF DR2_REG))
1971 (clobber (reg:SI R2_REG))
1972 (use (match_operand:SI 1 "arith_reg_operand" "r"))]
1973 "(TARGET_HARD_SH4 || TARGET_SHCOMPACT) && TARGET_FPU_SINGLE"
1975 [(set_attr "type" "sfunc")
1976 (set_attr "needs_delay_slot" "yes")])
1978 (define_expand "divsi3"
1979 [(set (match_dup 3) (symbol_ref:SI "__sdivsi3"))
1980 (set (reg:SI R4_REG) (match_operand:SI 1 "general_operand" ""))
1981 (set (reg:SI R5_REG) (match_operand:SI 2 "general_operand" ""))
1982 (parallel [(set (match_operand:SI 0 "register_operand" "")
1983 (div:SI (reg:SI R4_REG)
1985 (clobber (reg:SI T_REG))
1986 (clobber (reg:SI PR_REG))
1987 (clobber (reg:SI R1_REG))
1988 (clobber (reg:SI R2_REG))
1989 (clobber (reg:SI R3_REG))
1990 (use (match_dup 3))])]
1996 operands[3] = gen_reg_rtx (Pmode);
1997 /* Emit the move of the address to a pseudo outside of the libcall. */
1998 if (TARGET_HARD_SH4 && TARGET_SH2E)
2000 function_symbol (operands[3], sh_divsi3_libfunc, SFUNC_STATIC);
2001 if (TARGET_FPU_SINGLE)
2002 last = gen_divsi3_i4_single (operands[0], operands[3]);
2004 last = gen_divsi3_i4 (operands[0], operands[3]);
2006 else if (TARGET_SH2A)
2008 operands[1] = force_reg (SImode, operands[1]);
2009 operands[2] = force_reg (SImode, operands[2]);
2010 emit_insn (gen_divsi3_sh2a (operands[0], operands[1], operands[2]));
2013 else if (TARGET_DIVIDE_INV)
2015 rtx dividend = operands[1];
2016 rtx divisor = operands[2];
2018 rtx nsb_res = gen_reg_rtx (DImode);
2019 rtx norm64 = gen_reg_rtx (DImode);
2020 rtx tab_ix = gen_reg_rtx (DImode);
2021 rtx norm32 = gen_reg_rtx (SImode);
2022 rtx i92 = force_reg (DImode, GEN_INT (92));
2023 rtx scratch0a = gen_reg_rtx (DImode);
2024 rtx scratch0b = gen_reg_rtx (DImode);
2025 rtx inv0 = gen_reg_rtx (SImode);
2026 rtx scratch1a = gen_reg_rtx (DImode);
2027 rtx scratch1b = gen_reg_rtx (DImode);
2028 rtx shift = gen_reg_rtx (DImode);
2030 rtx inv1 = gen_reg_rtx (SImode);
2031 rtx scratch2a = gen_reg_rtx (DImode);
2032 rtx scratch2b = gen_reg_rtx (SImode);
2033 rtx inv2 = gen_reg_rtx (SImode);
2034 rtx scratch3a = gen_reg_rtx (DImode);
2035 rtx scratch3b = gen_reg_rtx (DImode);
2036 rtx scratch3c = gen_reg_rtx (DImode);
2037 rtx scratch3d = gen_reg_rtx (SImode);
2038 rtx scratch3e = gen_reg_rtx (DImode);
2039 rtx result = gen_reg_rtx (SImode);
2041 if (! arith_reg_or_0_operand (dividend, SImode))
2042 dividend = force_reg (SImode, dividend);
2043 if (! arith_reg_operand (divisor, SImode))
2044 divisor = force_reg (SImode, divisor);
2045 if (flag_pic && Pmode != DImode)
2047 tab_base = gen_rtx_SYMBOL_REF (Pmode, \"__div_table\");
2048 tab_base = gen_datalabel_ref (tab_base);
2049 tab_base = force_reg (DImode, gen_rtx_SIGN_EXTEND (DImode, tab_base));
2053 tab_base = gen_rtx_SYMBOL_REF (DImode, \"__div_table\");
2054 tab_base = gen_datalabel_ref (tab_base);
2055 tab_base = force_reg (DImode, tab_base);
2057 if (TARGET_DIVIDE_INV20U)
2058 i2p27 = force_reg (DImode, GEN_INT (-2 << 27));
2060 i2p27 = GEN_INT (0);
2061 if (TARGET_DIVIDE_INV20U || TARGET_DIVIDE_INV20L)
2062 i43 = force_reg (DImode, GEN_INT (43));
2065 emit_insn (gen_nsbdi (nsb_res,
2066 simplify_gen_subreg (DImode, divisor, SImode, 0)));
2067 emit_insn (gen_ashldi3_media (norm64,
2068 gen_rtx_SUBREG (DImode, divisor, 0),
2070 emit_insn (gen_ashrdi3_media (tab_ix, norm64, GEN_INT (58)));
2071 emit_insn (gen_ashrdisi3_media_high (norm32, norm64, GEN_INT (32)));
2072 emit_insn (gen_divsi_inv_m1 (inv1, tab_base, tab_ix, norm32,
2073 inv0, scratch0a, scratch0b,
2074 scratch1a, scratch1b));
2075 emit_insn (gen_subdi3 (shift, i92, nsb_res));
2076 emit_insn (gen_divsi_inv_m2 (inv2, norm32, inv1, i92,
2078 emit_insn (gen_divsi_inv_m3 (result, dividend, inv1, inv2, shift,
2080 scratch3a, scratch3b, scratch3c,
2081 scratch2a, scratch2b, scratch3d, scratch3e));
2082 if (TARGET_DIVIDE_INV_CALL || TARGET_DIVIDE_INV_CALL2)
2083 emit_insn (gen_divsi_inv_call (operands[0], dividend, divisor, result));
2084 else if (TARGET_DIVIDE_INV_FP)
2085 emit_insn (gen_divsi_inv_fp (operands[0], dividend, divisor, result,
2086 gen_reg_rtx (SImode), gen_reg_rtx (SImode),
2087 gen_reg_rtx (DFmode), gen_reg_rtx (DFmode),
2088 gen_reg_rtx (DFmode)));
2090 emit_move_insn (operands[0], result);
2093 else if (TARGET_SHMEDIA_FPU && TARGET_DIVIDE_FP)
2095 operands[1] = force_reg (SImode, operands[1]);
2096 operands[2] = force_reg (SImode, operands[2]);
2097 emit_insn (gen_divsi3_i4_media (operands[0], operands[1], operands[2]));
2100 else if (TARGET_SH5)
2102 if (TARGET_DIVIDE_CALL2)
2104 rtx tab_base = gen_rtx_SYMBOL_REF (Pmode, \"__div_table\");
2105 tab_base = gen_datalabel_ref (tab_base);
2106 emit_move_insn (gen_rtx_REG (Pmode, R20_REG), tab_base);
2108 if (TARGET_FPU_ANY && TARGET_SH1)
2109 function_symbol (operands[3], sh_divsi3_libfunc, SFUNC_STATIC);
2110 else if (TARGET_DIVIDE_CALL2)
2111 function_symbol (operands[3], \"__sdivsi3_2\", SFUNC_STATIC);
2113 function_symbol (operands[3], sh_divsi3_libfunc, SFUNC_GOT);
2116 last = ((TARGET_DIVIDE_CALL2 ? gen_divsi3_media_2 : gen_divsi3_i1_media)
2117 (operands[0], operands[3]));
2118 else if (TARGET_FPU_ANY)
2119 last = gen_divsi3_i4_single (operands[0], operands[3]);
2121 last = gen_divsi3_i1 (operands[0], operands[3]);
2125 function_symbol (operands[3], sh_divsi3_libfunc, SFUNC_GOT);
2126 last = gen_divsi3_i1 (operands[0], operands[3]);
2128 first = emit_move_insn (gen_rtx_REG (SImode, 4), operands[1]);
2129 emit_move_insn (gen_rtx_REG (SImode, 5), operands[2]);
2130 last = emit_insn (last);
2131 /* Wrap the sequence in REG_LIBCALL / REG_RETVAL notes so that loop
2132 invariant code motion can move it. */
2133 REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last, REG_NOTES (first));
2134 REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first, REG_NOTES (last));
2138 ;; operands: inv0, tab_base, tab_ix, norm32
2139 ;; scratch equiv in sdivsi3_2: r19, r21
2140 (define_expand "divsi_inv_m0"
2141 [(set (match_operand:SI 0 "register_operand" "=r")
2142 (unspec:SI [(match_operand:DI 1 "register_operand" "r")
2143 (match_operand:DI 2 "register_operand" "r")
2144 (match_operand:SI 3 "register_operand" "r")]
2146 (clobber (match_operand:DI 4 "register_operand" "=r"))
2147 (clobber (match_operand:DI 5 "register_operand" "=r"))]
2155 ldx.ub r20, r21, r19 // u0.8
2157 muls.l r25, r19, r19 // s2.38
2158 ldx.w r20, r21, r21 // s2.14
2159 shari r19, 24, r19 // truncate to s2.14
2160 sub r21, r19, r19 // some 11 bit inverse in s1.14
2163 rtx inv0 = operands[0];
2164 rtx tab_base = operands[1];
2165 rtx tab_ix = operands[2];
2166 rtx norm32 = operands[3];
2167 rtx scratch0 = operands[4];
2168 rtx scratch0_si = simplify_gen_subreg (SImode, scratch0, DImode, SIDI_OFF);
2169 rtx scratch1 = operands[5];
2172 mem = gen_const_mem (QImode, gen_rtx_PLUS (DImode, tab_base, tab_ix));
2173 emit_insn (gen_zero_extendqidi2 (scratch0, mem));
2174 emit_insn (gen_ashldi3_media (scratch1, tab_ix, GEN_INT (1)));
2175 emit_insn (gen_mulsidi3_media (scratch0, norm32, scratch0_si));
2176 mem = gen_const_mem (HImode, gen_rtx_PLUS (DImode, tab_base, scratch1));
2177 emit_insn (gen_extendhidi2 (scratch1, mem));
2178 emit_insn (gen_ashrdi3_media (scratch0, scratch0, GEN_INT (24)));
2179 emit_insn (gen_subdisi3_media (inv0, scratch1, scratch0));
2183 ;; operands: inv1, tab_base, tab_ix, norm32
2184 (define_insn_and_split "divsi_inv_m1"
2185 [(set (match_operand:SI 0 "register_operand" "=r")
2186 (unspec:SI [(match_operand:DI 1 "register_operand" "r")
2187 (match_operand:DI 2 "register_operand" "r")
2188 (match_operand:SI 3 "register_operand" "r")]
2190 (clobber (match_operand:SI 4 "register_operand" "=r"))
2191 (clobber (match_operand:DI 5 "register_operand" "=r"))
2192 (clobber (match_operand:DI 6 "register_operand" "=r"))
2193 (clobber (match_operand:DI 7 "register_operand" "=r"))
2194 (clobber (match_operand:DI 8 "register_operand" "=r"))]
2202 muls.l r19, r19, r18 // u0.28
2203 muls.l r25, r18, r18 // s2.58
2204 shlli r19, 45, r0 // multiply by two and convert to s2.58
2206 shari r18, 28, r18 // some 18 bit inverse in s1.30
2209 rtx inv1 = operands[0];
2210 rtx tab_base = operands[1];
2211 rtx tab_ix = operands[2];
2212 rtx norm32 = operands[3];
2213 rtx inv0 = operands[4];
2214 rtx inv0_di = simplify_gen_subreg (DImode, inv0, SImode, 0);
2215 rtx scratch0a = operands[5];
2216 rtx scratch0b = operands[6];
2217 rtx scratch0 = operands[7];
2218 rtx scratch1 = operands[8];
2219 rtx scratch1_si = simplify_gen_subreg (SImode, scratch1, DImode, SIDI_OFF);
2221 emit_insn (gen_divsi_inv_m0 (inv0, tab_base, tab_ix, norm32,
2222 scratch0a, scratch0b));
2223 emit_insn (gen_mulsidi3_media (scratch1, inv0, inv0));
2224 emit_insn (gen_mulsidi3_media (scratch1, norm32, scratch1_si));
2225 emit_insn (gen_ashldi3_media (scratch0, inv0_di, GEN_INT (45)));
2226 emit_insn (gen_subdi3 (scratch1, scratch0, scratch1));
2227 emit_insn (gen_ashrdisi3_media_opaque (inv1, scratch1, GEN_INT (28)));
2231 ;; operands: inv2, norm32, inv1, i92
2232 (define_insn_and_split "divsi_inv_m2"
2233 [(set (match_operand:SI 0 "register_operand" "=r")
2234 (unspec:SI [(match_operand:SI 1 "register_operand" "r")
2235 (match_operand:SI 2 "register_operand" "r")
2236 (match_operand:DI 3 "register_operand" "r")]
2238 (clobber (match_operand:DI 4 "register_operand" "=r"))]
2246 muls.l r18, r25, r0 // s2.60
2247 shari r0, 16, r0 // s-16.44
2249 muls.l r0, r18, r19 // s-16.74
2250 shari r19, 30, r19 // s-16.44
2252 rtx inv2 = operands[0];
2253 rtx norm32 = operands[1];
2254 rtx inv1 = operands[2];
2255 rtx i92 = operands[3];
2256 rtx scratch0 = operands[4];
2257 rtx scratch0_si = simplify_gen_subreg (SImode, scratch0, DImode, SIDI_OFF);
2259 emit_insn (gen_mulsidi3_media (scratch0, inv1, norm32));
2260 emit_insn (gen_ashrdi3_media (scratch0, scratch0, GEN_INT (16)));
2261 emit_insn (gen_subdi3 (scratch0, i92, scratch0));
2262 emit_insn (gen_mulsidi3_media (scratch0, scratch0_si, inv1));
2263 emit_insn (gen_ashrdisi3_media_opaque (inv2, scratch0, GEN_INT (30)));
2267 (define_insn_and_split "divsi_inv_m3"
2268 [(set (match_operand:SI 0 "register_operand" "=r")
2269 (unspec:SI [(match_operand:SI 1 "arith_reg_or_0_operand" "rN")
2270 (match_operand:SI 2 "register_operand" "r")
2271 (match_operand:SI 3 "register_operand" "r")
2272 (match_operand:DI 4 "register_operand" "r")
2273 (match_operand:DI 5 "arith_reg_or_0_operand" "rN")
2274 (match_operand:DI 6 "arith_reg_or_0_operand" "rN")]
2276 (clobber (match_operand:DI 7 "register_operand" "=r"))
2277 (clobber (match_operand:DI 8 "register_operand" "=r"))
2278 (clobber (match_operand:DI 9 "register_operand" "=r"))
2279 (clobber (match_operand:DI 10 "register_operand" "=r"))
2280 (clobber (match_operand:SI 11 "register_operand" "=r"))
2281 (clobber (match_operand:SI 12 "register_operand" "=r"))
2282 (clobber (match_operand:DI 13 "register_operand" "=r"))]
2290 r0: result r1: shift r4: dividend r18: inv1 r19: inv2
2291 r0: scratch0 r19: scratch1 r21: scratch2
2293 muls.l r18, r4, r25 // s32.30
2294 muls.l r19, r4, r19 // s15.30
2296 shari r19, 14, r19 // s18.-14
2302 rtx result = operands[0];
2303 rtx dividend = operands[1];
2304 rtx inv1 = operands[2];
2305 rtx inv2 = operands[3];
2306 rtx shift = operands[4];
2307 rtx scratch0 = operands[7];
2308 rtx scratch1 = operands[8];
2309 rtx scratch2 = operands[9];
2311 emit_insn (gen_mulsidi3_media (scratch0, inv1, dividend));
2312 emit_insn (gen_mulsidi3_media (scratch1, inv2, dividend));
2313 emit_insn (gen_ashrdi3_media (scratch2, scratch0, GEN_INT (63)));
2314 emit_insn (gen_ashrdi3_media (scratch1, scratch1, GEN_INT (14)));
2315 emit_insn (gen_adddi3 (scratch0, scratch0, scratch1));
2316 emit_insn (gen_ashrdi3_media (scratch0, scratch0, shift));
2317 emit_insn (gen_subdisi3_media (result, scratch0, scratch2));
2321 ;; operands: quotient, dividend, inv1, inv2, shift, i2p27, i43
2322 ;; inv1: tab_base, tab_ix, norm32
2323 ;; inv2: norm32, inv1, i92
2324 (define_insn_and_split "divsi_inv_m1_3"
2325 [(set (match_operand:SI 0 "register_operand" "=r")
2326 (unspec:SI [(match_operand:SI 1 "arith_reg_or_0_operand" "rN")
2327 (unspec:SI [(match_operand:DI 2 "register_operand" "r")
2328 (match_operand:DI 3 "register_operand" "r")
2329 (match_operand:SI 4 "register_operand" "r")]
2331 (unspec:SI [(match_dup 4)
2332 (unspec:SI [(match_dup 2)
2334 (match_dup 4)] UNSPEC_DIV_INV_M1)
2335 (match_operand:SI 5 "" "")]
2337 (match_operand:DI 6 "register_operand" "r")
2338 (match_operand:DI 7 "arith_reg_or_0_operand" "rN")
2339 (match_operand:DI 8 "arith_reg_or_0_operand" "rN")]
2341 (clobber (match_operand:DI 9 "register_operand" "=r"))
2342 (clobber (match_operand:DI 10 "register_operand" "=r"))
2343 (clobber (match_operand:DI 11 "register_operand" "=r"))
2344 (clobber (match_operand:DI 12 "register_operand" "=r"))
2345 (clobber (match_operand:SI 13 "register_operand" "=r"))
2346 (clobber (match_operand:SI 14 "register_operand" "=r"))
2347 (clobber (match_operand:DI 15 "register_operand" "=r"))]
2349 && (TARGET_DIVIDE_INV_MINLAT
2350 || TARGET_DIVIDE_INV20U || TARGET_DIVIDE_INV20L)"
2356 rtx result = operands[0];
2357 rtx dividend = operands[1];
2358 rtx tab_base = operands[2];
2359 rtx tab_ix = operands[3];
2360 rtx norm32 = operands[4];
2361 /* rtx i92 = operands[5]; */
2362 rtx shift = operands[6];
2363 rtx i2p27 = operands[7];
2364 rtx i43 = operands[8];
2365 rtx scratch0 = operands[9];
2366 rtx scratch0_si = simplify_gen_subreg (SImode, scratch0, DImode, SIDI_OFF);
2367 rtx scratch1 = operands[10];
2368 rtx scratch1_si = simplify_gen_subreg (SImode, scratch1, DImode, SIDI_OFF);
2369 rtx scratch2 = operands[11];
2370 rtx scratch3 = operands[12];
2371 rtx scratch4 = operands[13];
2372 rtx scratch4_di = simplify_gen_subreg (DImode, scratch4, SImode, 0);
2373 rtx scratch5 = operands[14];
2374 rtx scratch5_di = simplify_gen_subreg (DImode, scratch5, SImode, 0);
2375 rtx scratch6 = operands[15];
2377 emit_insn (gen_divsi_inv_m0 (scratch4, tab_base, tab_ix, norm32,
2378 scratch0, scratch1));
2379 /* inv0 == scratch4 */
2380 if (! TARGET_DIVIDE_INV20U)
2382 emit_insn (gen_mulsidi3_media (scratch0, scratch4, scratch4));
2384 emit_insn (gen_mulsidi3_media (scratch1, norm32, scratch0_si));
2388 emit_insn (gen_mulsidi3_media (scratch1, scratch4, scratch4));
2389 emit_insn (gen_mulsidi3_media (scratch1, norm32, scratch1_si));
2391 emit_insn (gen_ashldi3_media (scratch2, scratch4_di, GEN_INT (45)));
2392 emit_insn (gen_subdi3 (scratch1, scratch2, scratch1));
2393 emit_insn (gen_ashrdisi3_media_opaque (scratch4, scratch1, GEN_INT (28)));
2394 /* inv1 == scratch4 */
2396 if (TARGET_DIVIDE_INV_MINLAT)
2398 emit_insn (gen_mulsidi3_media (scratch1, scratch4, norm32));
2399 emit_insn (gen_mulsidi3_media (scratch2, dividend, scratch4));
2400 emit_insn (gen_ashrdi3_media (scratch1, scratch1, GEN_INT (16)));
2401 emit_insn (gen_mulsidi3_media (scratch1, scratch1_si, scratch4));
2402 emit_insn (gen_ashrdi3_media (scratch3, scratch2, GEN_INT (63)));
2403 emit_insn (gen_ashrsi3_media (scratch5, dividend, GEN_INT (14)));
2404 emit_insn (gen_ashrdi3_media (scratch1, scratch1, GEN_INT (30)));
2405 emit_insn (gen_mulsidi3_media (scratch1, scratch1_si, scratch5));
2406 emit_insn (gen_xordi3 (scratch0, scratch3, i2p27));
2407 emit_insn (gen_adddi3 (scratch2, scratch2, scratch0));
2408 emit_insn (gen_subdi3 (scratch2, scratch2, scratch1));
2412 rtx label = gen_rtx_LABEL_REF (Pmode, gen_label_rtx ());
2413 /* Use separate scratch regs for nsb and sign to allow scheduling. */
2414 emit_insn (gen_nsbdi (scratch6,
2415 simplify_gen_subreg (DImode, dividend, SImode, 0)));
2416 emit_insn (gen_xorsi3 (scratch5, dividend, norm32));
2417 emit_insn (gen_ashrdi3_media (scratch3, scratch5_di, GEN_INT (63)));
2418 emit_insn (gen_divsi_inv20 (scratch2,
2419 norm32, scratch4, dividend,
2420 scratch6, scratch3, i43,
2421 /* scratch0 may be shared with i2p27. */
2422 scratch0, scratch1, scratch5,
2423 label, label, i2p27));
2425 emit_insn (gen_ashrdi3_media (scratch2, scratch2, shift));
2426 emit_insn (gen_subdisi3_media (result, scratch2, scratch3));
2430 (define_insn "divsi_inv20"
2431 [(set (match_operand:DI 0 "register_operand" "=&r")
2432 (unspec:DI [(match_operand:SI 1 "register_operand" "r")
2433 (match_operand:SI 2 "register_operand" "r")
2434 (match_operand:SI 3 "register_operand" "r")
2435 (match_operand:DI 4 "register_operand" "r")
2436 (match_operand:DI 5 "register_operand" "r")
2437 (match_operand:DI 6 "register_operand" "r")
2438 (match_operand:DI 12 "register_operand" "r")
2439 (match_operand 10 "target_operand" "b")
2440 (match_operand 11 "immediate_operand" "i")]
2442 (clobber (match_operand:DI 7 "register_operand" "=&r"))
2443 (clobber (match_operand:DI 8 "register_operand" "=&r"))
2444 (clobber (match_operand:SI 9 "register_operand" "=r"))]
2446 && (TARGET_DIVIDE_INV20U || TARGET_DIVIDE_INV20L)"
2449 /* operands: %0 div_result, %1 norm32, %2 inv1, %3 dividend,
2450 %4 dividend_nsb, %5 result_sign, %6 i43, %12 i2p27,
2451 %7 round_scratch, %8 scratch0 (di), %9 scratch1 (si)
2452 %10 label (tr), %11 label (imm)
2454 muls.l inv1, norm32, scratch0 // s2.60
2455 muls.l inv1, dividend, result // s32.30
2456 xor i2p27, result_sign, round_scratch
2457 bge/u dividend_nsb, i43, tr.. (label)
2458 shari scratch0, 16, scratch0 // s-16.44
2459 muls.l sratch0_si, inv1, scratch0 // s-16.74
2460 sub result, round_scratch, result
2461 shari dividend, 14, scratch1 // s19.-14
2462 shari scratch0, 30, scratch0 // s-16.44
2463 muls.l scratch0, scratch1, round_scratch // s15.30
2465 sub result, round_scratch, result */
2467 int likely = TARGET_DIVIDE_INV20L;
2469 if (! likely) output_asm_insn (\"muls.l\t%2, %1 , %8\", operands);
2470 output_asm_insn (\"muls.l\t%2, %3, %0\;xor\t%12, %5, %7\", operands);
2471 output_asm_insn (likely
2472 ? \"bge/l\t%4, %6, %10\;muls.l\t%2, %1 , %8\"
2473 : \"bge/u\t%4, %6, %10\", operands);
2474 output_asm_insn (\"shari\t%8, 16, %8\;muls.l\t%8, %2, %8\", operands);
2475 if (! likely) output_asm_insn (\"sub\t%0, %7, %0\", operands);
2476 output_asm_insn (\"shari\t%3, 14, %9\;shari\t%8, 30, %8\", operands);
2478 ? \"muls.l\t%8, %9, %8\;sub\t%0, %8, %0\n%11:\tadd\t%0, %7, %0\"
2479 : \"muls.l\t%8, %9, %7\n%11:\tsub\t%0, %7, %0\");
2482 (define_insn_and_split "divsi_inv_fp"
2483 [(set (match_operand:SI 0 "general_movdst_operand" "=rf")
2484 (div:SI (match_operand:SI 1 "general_movsrc_operand" "rf")
2485 (match_operand:SI 2 "register_operand" "rf")))
2486 (use (match_operand:SI 3 "general_movsrc_operand" "r"))
2487 (clobber (match_operand:SI 4 "register_operand" "=r"))
2488 (clobber (match_operand:SI 5 "register_operand" "=r"))
2489 (clobber (match_operand:DF 6 "register_operand" "=r"))
2490 (clobber (match_operand:DF 7 "register_operand" "=r"))
2491 (clobber (match_operand:DF 8 "register_operand" "=r"))]
2492 "TARGET_SHMEDIA_FPU"
2494 "&& (high_life_started || reload_completed)"
2495 [(set (match_dup 0) (match_dup 3))]
2497 [(set_attr "highpart" "must_split")])
2499 ;; If a matching group of divide-by-inverse instructions is in the same
2500 ;; basic block after gcse & loop optimizations, we want to transform them
2501 ;; to a straight division using floating point for TARGET_DIVIDE_INV_FP.
2502 (define_insn_and_split "*divsi_inv_fp_combine"
2503 [(set (match_operand:SI 0 "register_operand" "=f")
2504 (div:SI (match_operand:SI 1 "register_operand" "f")
2505 (match_operand:SI 2 "register_operand" "f")))
2506 (use (unspec:SI [(match_dup 1)
2507 (match_operand:SI 3 "" "")
2508 (unspec:SI [(match_operand:SI 4 "" "")
2510 (match_operand:DI 5 "" "")] UNSPEC_DIV_INV_M2)
2511 (match_operand:DI 6 "" "")
2513 (const_int 0)] UNSPEC_DIV_INV_M3))
2514 (clobber (match_operand:SI 7 "fp_arith_reg_operand" ""))
2515 (clobber (match_operand:SI 8 "fp_arith_reg_operand" ""))
2516 (clobber (match_operand:DF 9 "fp_arith_reg_operand" ""))
2517 (clobber (match_operand:DF 10 "fp_arith_reg_operand" ""))
2518 (clobber (match_operand:DF 11 "fp_arith_reg_operand" ""))]
2519 "TARGET_SHMEDIA_FPU && TARGET_DIVIDE_INV_FP && no_new_pseudos"
2522 [(set (match_dup 9) (float:DF (match_dup 1)))
2523 (set (match_dup 10) (float:DF (match_dup 2)))
2524 (set (match_dup 11) (div:DF (match_dup 9) (match_dup 10)))
2526 (fix:SI (match_dup 11)))
2527 (set (match_dup 0) (match_dup 8))]
2530 if (! fp_arith_reg_operand (operands[1], SImode))
2532 emit_move_insn (operands[7], operands[1]);
2533 operands[1] = operands[7];
2535 if (! fp_arith_reg_operand (operands[2], SImode))
2537 emit_move_insn (operands[8], operands[2]);
2538 operands[2] = operands[8];
2541 [(set_attr "highpart" "must_split")])
2543 ;; -------------------------------------------------------------------------
2544 ;; Multiplication instructions
2545 ;; -------------------------------------------------------------------------
2547 (define_insn "umulhisi3_i"
2548 [(set (reg:SI MACL_REG)
2549 (mult:SI (zero_extend:SI
2550 (match_operand:HI 0 "arith_reg_operand" "r"))
2552 (match_operand:HI 1 "arith_reg_operand" "r"))))]
2555 [(set_attr "type" "smpy")])
2557 (define_insn "mulhisi3_i"
2558 [(set (reg:SI MACL_REG)
2559 (mult:SI (sign_extend:SI
2560 (match_operand:HI 0 "arith_reg_operand" "r"))
2562 (match_operand:HI 1 "arith_reg_operand" "r"))))]
2565 [(set_attr "type" "smpy")])
2567 (define_expand "mulhisi3"
2568 [(set (reg:SI MACL_REG)
2569 (mult:SI (sign_extend:SI
2570 (match_operand:HI 1 "arith_reg_operand" ""))
2572 (match_operand:HI 2 "arith_reg_operand" ""))))
2573 (set (match_operand:SI 0 "arith_reg_operand" "")
2580 first = emit_insn (gen_mulhisi3_i (operands[1], operands[2]));
2581 last = emit_move_insn (operands[0], gen_rtx_REG (SImode, MACL_REG));
2582 /* Wrap the sequence in REG_LIBCALL / REG_RETVAL notes so that loop
2583 invariant code motion can move it. */
2584 REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last, REG_NOTES (first));
2585 REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first, REG_NOTES (last));
2586 /* expand_binop can't find a suitable code in umul_widen_optab to
2587 make a REG_EQUAL note from, so make one here.
2588 See also smulsi3_highpart.
2589 ??? Alternatively, we could put this at the calling site of expand_binop,
2590 i.e. expand_expr. */
2592 = gen_rtx_EXPR_LIST (REG_EQUAL, copy_rtx (SET_SRC (single_set (first))),
2597 (define_expand "umulhisi3"
2598 [(set (reg:SI MACL_REG)
2599 (mult:SI (zero_extend:SI
2600 (match_operand:HI 1 "arith_reg_operand" ""))
2602 (match_operand:HI 2 "arith_reg_operand" ""))))
2603 (set (match_operand:SI 0 "arith_reg_operand" "")
2610 first = emit_insn (gen_umulhisi3_i (operands[1], operands[2]));
2611 last = emit_move_insn (operands[0], gen_rtx_REG (SImode, MACL_REG));
2612 /* Wrap the sequence in REG_LIBCALL / REG_RETVAL notes so that loop
2613 invariant code motion can move it. */
2614 REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last, REG_NOTES (first));
2615 REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first, REG_NOTES (last));
2616 /* expand_binop can't find a suitable code in umul_widen_optab to
2617 make a REG_EQUAL note from, so make one here.
2618 See also smulsi3_highpart.
2619 ??? Alternatively, we could put this at the calling site of expand_binop,
2620 i.e. expand_expr. */
2622 = gen_rtx_EXPR_LIST (REG_EQUAL, copy_rtx (SET_SRC (single_set (first))),
2627 ;; mulsi3 on the SH2 can be done in one instruction, on the SH1 we generate
2628 ;; a call to a routine which clobbers known registers.
2631 [(set (match_operand:SI 1 "register_operand" "=z")
2632 (mult:SI (reg:SI R4_REG) (reg:SI R5_REG)))
2633 (clobber (reg:SI MACL_REG))
2634 (clobber (reg:SI T_REG))
2635 (clobber (reg:SI PR_REG))
2636 (clobber (reg:SI R3_REG))
2637 (clobber (reg:SI R2_REG))
2638 (clobber (reg:SI R1_REG))
2639 (use (match_operand:SI 0 "arith_reg_operand" "r"))]
2642 [(set_attr "type" "sfunc")
2643 (set_attr "needs_delay_slot" "yes")])
2645 (define_expand "mulsi3_call"
2646 [(set (reg:SI R4_REG) (match_operand:SI 1 "general_operand" ""))
2647 (set (reg:SI R5_REG) (match_operand:SI 2 "general_operand" ""))
2648 (parallel[(set (match_operand:SI 0 "register_operand" "")
2649 (mult:SI (reg:SI R4_REG)
2651 (clobber (reg:SI MACL_REG))
2652 (clobber (reg:SI T_REG))
2653 (clobber (reg:SI PR_REG))
2654 (clobber (reg:SI R3_REG))
2655 (clobber (reg:SI R2_REG))
2656 (clobber (reg:SI R1_REG))
2657 (use (match_operand:SI 3 "register_operand" ""))])]
2661 (define_insn "mul_r"
2662 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
2663 (mult:SI (match_operand:SI 1 "arith_reg_operand" "0")
2664 (match_operand:SI 2 "arith_reg_operand" "z")))]
2667 [(set_attr "type" "dmpy")])
2669 (define_insn "mul_l"
2670 [(set (reg:SI MACL_REG)
2671 (mult:SI (match_operand:SI 0 "arith_reg_operand" "r")
2672 (match_operand:SI 1 "arith_reg_operand" "r")))]
2675 [(set_attr "type" "dmpy")])
2677 (define_expand "mulsi3"
2678 [(set (reg:SI MACL_REG)
2679 (mult:SI (match_operand:SI 1 "arith_reg_operand" "")
2680 (match_operand:SI 2 "arith_reg_operand" "")))
2681 (set (match_operand:SI 0 "arith_reg_operand" "")
2690 /* The address must be set outside the libcall,
2691 since it goes into a pseudo. */
2692 rtx sym = function_symbol (NULL, \"__mulsi3\", SFUNC_STATIC);
2693 rtx addr = force_reg (SImode, sym);
2694 rtx insns = gen_mulsi3_call (operands[0], operands[1],
2697 last = emit_insn (insns);
2701 rtx macl = gen_rtx_REG (SImode, MACL_REG);
2703 first = emit_insn (gen_mul_l (operands[1], operands[2]));
2704 /* consec_sets_giv can only recognize the first insn that sets a
2705 giv as the giv insn. So we must tag this also with a REG_EQUAL
2707 last = emit_insn (gen_movsi_i ((operands[0]), macl));
2709 /* Wrap the sequence in REG_LIBCALL / REG_RETVAL notes so that loop
2710 invariant code motion can move it. */
2711 REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last, REG_NOTES (first));
2712 REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first, REG_NOTES (last));
2716 (define_insn "mulsidi3_i"
2717 [(set (reg:SI MACH_REG)
2721 (sign_extend:DI (match_operand:SI 0 "arith_reg_operand" "r"))
2722 (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" "r")))
2724 (set (reg:SI MACL_REG)
2725 (mult:SI (match_dup 0)
2729 [(set_attr "type" "dmpy")])
2731 (define_expand "mulsidi3"
2732 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
2733 (mult:DI (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" "r"))
2734 (sign_extend:DI (match_operand:SI 2 "arith_reg_operand" "r"))))]
2735 "TARGET_SH2 || TARGET_SHMEDIA"
2740 emit_insn (gen_mulsidi3_compact (operands[0], operands[1],
2746 (define_insn "mulsidi3_media"
2747 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
2748 (mult:DI (sign_extend:DI (match_operand:SI 1 "extend_reg_operand" "%r"))
2749 (sign_extend:DI (match_operand:SI 2 "extend_reg_operand" "r"))))]
2752 [(set_attr "type" "dmpy_media")
2753 (set_attr "highpart" "ignore")])
2755 (define_insn "mulsidi3_compact"
2756 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
2758 (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" "r"))
2759 (sign_extend:DI (match_operand:SI 2 "arith_reg_operand" "r"))))
2760 (clobber (reg:SI MACH_REG))
2761 (clobber (reg:SI MACL_REG))]
2766 [(set (match_operand:DI 0 "arith_reg_dest" "")
2768 (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" ""))
2769 (sign_extend:DI (match_operand:SI 2 "arith_reg_operand" ""))))
2770 (clobber (reg:SI MACH_REG))
2771 (clobber (reg:SI MACL_REG))]
2776 rtx low_dst = gen_lowpart (SImode, operands[0]);
2777 rtx high_dst = gen_highpart (SImode, operands[0]);
2779 emit_insn (gen_mulsidi3_i (operands[1], operands[2]));
2781 emit_move_insn (low_dst, gen_rtx_REG (SImode, MACL_REG));
2782 emit_move_insn (high_dst, gen_rtx_REG (SImode, MACH_REG));
2783 /* We need something to tag the possible REG_EQUAL notes on to. */
2784 emit_move_insn (operands[0], operands[0]);
2788 (define_insn "umulsidi3_i"
2789 [(set (reg:SI MACH_REG)
2793 (zero_extend:DI (match_operand:SI 0 "arith_reg_operand" "r"))
2794 (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" "r")))
2796 (set (reg:SI MACL_REG)
2797 (mult:SI (match_dup 0)
2801 [(set_attr "type" "dmpy")])
2803 (define_expand "umulsidi3"
2804 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
2805 (mult:DI (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" "r"))
2806 (zero_extend:DI (match_operand:SI 2 "arith_reg_operand" "r"))))]
2807 "TARGET_SH2 || TARGET_SHMEDIA"
2812 emit_insn (gen_umulsidi3_compact (operands[0], operands[1],
2818 (define_insn "umulsidi3_media"
2819 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
2820 (mult:DI (zero_extend:DI (match_operand:SI 1 "extend_reg_operand" "%r"))
2821 (zero_extend:DI (match_operand:SI 2 "extend_reg_operand" "r"))))]
2824 [(set_attr "type" "dmpy_media")
2825 (set_attr "highpart" "ignore")])
2827 (define_insn "umulsidi3_compact"
2828 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
2830 (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" "r"))
2831 (zero_extend:DI (match_operand:SI 2 "arith_reg_operand" "r"))))
2832 (clobber (reg:SI MACH_REG))
2833 (clobber (reg:SI MACL_REG))]
2838 [(set (match_operand:DI 0 "arith_reg_dest" "")
2839 (mult:DI (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" ""))
2840 (zero_extend:DI (match_operand:SI 2 "arith_reg_operand" ""))))
2841 (clobber (reg:SI MACH_REG))
2842 (clobber (reg:SI MACL_REG))]
2847 rtx low_dst = gen_lowpart (SImode, operands[0]);
2848 rtx high_dst = gen_highpart (SImode, operands[0]);
2850 emit_insn (gen_umulsidi3_i (operands[1], operands[2]));
2852 emit_move_insn (low_dst, gen_rtx_REG (SImode, MACL_REG));
2853 emit_move_insn (high_dst, gen_rtx_REG (SImode, MACH_REG));
2854 /* We need something to tag the possible REG_EQUAL notes on to. */
2855 emit_move_insn (operands[0], operands[0]);
2859 (define_insn "smulsi3_highpart_i"
2860 [(set (reg:SI MACH_REG)
2864 (sign_extend:DI (match_operand:SI 0 "arith_reg_operand" "r"))
2865 (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" "r")))
2867 (clobber (reg:SI MACL_REG))]
2870 [(set_attr "type" "dmpy")])
2872 (define_expand "smulsi3_highpart"
2874 [(set (reg:SI MACH_REG)
2878 (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" ""))
2879 (sign_extend:DI (match_operand:SI 2 "arith_reg_operand" "")))
2881 (clobber (reg:SI MACL_REG))])
2882 (set (match_operand:SI 0 "arith_reg_operand" "")
2889 first = emit_insn (gen_smulsi3_highpart_i (operands[1], operands[2]));
2890 last = emit_move_insn (operands[0], gen_rtx_REG (SImode, MACH_REG));
2891 /* Wrap the sequence in REG_LIBCALL / REG_RETVAL notes so that loop
2892 invariant code motion can move it. */
2893 REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last, REG_NOTES (first));
2894 REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first, REG_NOTES (last));
2895 /* expand_binop can't find a suitable code in mul_highpart_optab to
2896 make a REG_EQUAL note from, so make one here.
2897 See also {,u}mulhisi.
2898 ??? Alternatively, we could put this at the calling site of expand_binop,
2899 i.e. expand_mult_highpart. */
2901 = gen_rtx_EXPR_LIST (REG_EQUAL, copy_rtx (SET_SRC (single_set (first))),
2906 (define_insn "umulsi3_highpart_i"
2907 [(set (reg:SI MACH_REG)
2911 (zero_extend:DI (match_operand:SI 0 "arith_reg_operand" "r"))
2912 (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" "r")))
2914 (clobber (reg:SI MACL_REG))]
2917 [(set_attr "type" "dmpy")])
2919 (define_expand "umulsi3_highpart"
2921 [(set (reg:SI MACH_REG)
2925 (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" ""))
2926 (zero_extend:DI (match_operand:SI 2 "arith_reg_operand" "")))
2928 (clobber (reg:SI MACL_REG))])
2929 (set (match_operand:SI 0 "arith_reg_operand" "")
2936 first = emit_insn (gen_umulsi3_highpart_i (operands[1], operands[2]));
2937 last = emit_move_insn (operands[0], gen_rtx_REG (SImode, MACH_REG));
2938 /* Wrap the sequence in REG_LIBCALL / REG_RETVAL notes so that loop
2939 invariant code motion can move it. */
2940 REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last, REG_NOTES (first));
2941 REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first, REG_NOTES (last));
2945 (define_insn_and_split "muldi3"
2946 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
2947 (mult:DI (match_operand:DI 1 "arith_reg_operand" "r")
2948 (match_operand:DI 2 "arith_reg_operand" "r")))
2949 (clobber (match_scratch:DI 3 "=&r"))
2950 (clobber (match_scratch:DI 4 "=r"))]
2957 rtx op3_v2si, op2_v2si;
2959 op3_v2si = operands[3];
2960 if (GET_CODE (op3_v2si) == SIGN_EXTEND)
2962 op3_v2si = XEXP (op3_v2si, 0);
2963 op3_v2si = simplify_gen_subreg (DImode, op3_v2si, GET_MODE (op3_v2si), 0);
2965 op3_v2si = simplify_gen_subreg (V2SImode, op3_v2si, DImode, 0);
2966 op2_v2si = operands[2];
2967 if (GET_CODE (op2_v2si) == SIGN_EXTEND)
2969 op2_v2si = XEXP (op2_v2si, 0);
2970 op2_v2si = simplify_gen_subreg (DImode, op2_v2si, GET_MODE (op2_v2si), 0);
2972 op2_v2si = simplify_gen_subreg (V2SImode, op2_v2si, DImode, 0);
2973 emit_insn (gen_rotldi3 (operands[3], operands[1], GEN_INT (32)));
2974 emit_insn (gen_mulv2si3 (op3_v2si, op3_v2si, op2_v2si));
2975 emit_insn (gen_umulsidi3_media (operands[4],
2976 sh_gen_truncate (SImode, operands[1], 0),
2977 sh_gen_truncate (SImode, operands[2], 0)));
2978 emit_insn (gen_anddi3 (operands[0], operands[3], GEN_INT (0xffffffff00000000LL)));
2979 emit_insn (gen_ashldi3_media (operands[3], operands[3], GEN_INT (32)));
2980 emit_insn (gen_adddi3 (operands[0], operands[3], operands[0]));
2981 emit_insn (gen_adddi3 (operands[0], operands[4], operands[0]));
2986 ;; -------------------------------------------------------------------------
2987 ;; Logical operations
2988 ;; -------------------------------------------------------------------------
2990 (define_insn "*andsi3_compact"
2991 [(set (match_operand:SI 0 "arith_reg_dest" "=r,z")
2992 (and:SI (match_operand:SI 1 "arith_reg_operand" "%0,0")
2993 (match_operand:SI 2 "logical_operand" "r,K08")))]
2996 [(set_attr "type" "arith")])
2998 (define_insn "*andsi3_media"
2999 [(set (match_operand:SI 0 "arith_reg_dest" "=r,r")
3000 (and:SI (match_operand:SI 1 "logical_reg_operand" "%r,r")
3001 (match_operand:SI 2 "logical_operand" "r,I10")))]
3006 [(set_attr "type" "arith_media")])
3008 ;; If the constant is 255, then emit an extu.b instruction instead of an
3009 ;; and, since that will give better code.
3011 (define_expand "andsi3"
3012 [(set (match_operand:SI 0 "arith_reg_operand" "")
3013 (and:SI (match_operand:SI 1 "logical_reg_operand" "")
3014 (match_operand:SI 2 "logical_operand" "")))]
3019 && GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 255)
3021 emit_insn (gen_zero_extendqisi2 (operands[0],
3022 gen_lowpart (QImode, operands[1])));
3027 (define_insn_and_split "anddi3"
3028 [(set (match_operand:DI 0 "arith_reg_dest" "=r,r,r")
3029 (and:DI (match_operand:DI 1 "arith_reg_operand" "%r,r,r")
3030 (match_operand:DI 2 "and_operand" "r,I10,J16")))]
3037 && ! logical_operand (operands[2], DImode)"
3041 if ((unsigned)INTVAL (operands[2]) == (unsigned) 0xffffffff)
3042 emit_insn (gen_mshflo_l_di (operands[0], operands[1], CONST0_RTX (DImode)));
3044 emit_insn (gen_mshfhi_l_di (operands[0], CONST0_RTX (DImode), operands[1]));
3047 [(set_attr "type" "arith_media")])
3049 (define_insn "andcsi3"
3050 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
3051 (and:SI (match_operand:SI 1 "arith_reg_operand" "r")
3052 (not:SI (match_operand:SI 2 "arith_reg_operand" "r"))))]
3055 [(set_attr "type" "arith_media")])
3057 (define_insn "andcdi3"
3058 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
3059 (and:DI (match_operand:DI 1 "arith_reg_operand" "r")
3060 (not:DI (match_operand:DI 2 "arith_reg_operand" "r"))))]
3063 [(set_attr "type" "arith_media")])
3065 (define_expand "iorsi3"
3066 [(set (match_operand:SI 0 "arith_reg_operand" "")
3067 (ior:SI (match_operand:SI 1 "logical_reg_operand" "")
3068 (match_operand:SI 2 "logical_operand" "")))]
3072 (define_insn "*iorsi3_compact"
3073 [(set (match_operand:SI 0 "arith_reg_dest" "=r,z")
3074 (ior:SI (match_operand:SI 1 "arith_reg_operand" "%0,0")
3075 (match_operand:SI 2 "logical_operand" "r,K08")))]
3078 [(set_attr "type" "arith")])
3080 (define_insn "*iorsi3_media"
3081 [(set (match_operand:SI 0 "arith_reg_dest" "=r,r")
3082 (ior:SI (match_operand:SI 1 "logical_reg_operand" "%r,r")
3083 (match_operand:SI 2 "logical_operand" "r,I10")))]
3088 [(set_attr "type" "arith_media")])
3090 (define_insn "iordi3"
3091 [(set (match_operand:DI 0 "arith_reg_dest" "=r,r")
3092 (ior:DI (match_operand:DI 1 "arith_reg_operand" "%r,r")
3093 (match_operand:DI 2 "logical_operand" "r,I10")))]
3098 [(set_attr "type" "arith_media")])
3100 (define_insn_and_split "*logical_sidi3"
3101 [(set (match_operand:DI 0 "arith_reg_dest" "=r,r")
3102 (sign_extend:DI (match_operator:SI 3 "logical_operator"
3103 [(match_operand:SI 1 "arith_reg_operand" "%r,r")
3104 (match_operand:SI 2 "logical_operand" "r,I10")])))]
3107 "&& reload_completed"
3108 [(set (match_dup 0) (match_dup 3))]
3112 = gen_rtx_fmt_ee (GET_CODE (operands[3]), DImode,
3113 simplify_gen_subreg (DImode, operands[1], SImode, 0),
3114 simplify_gen_subreg (DImode, operands[2], SImode, 0));
3117 (define_insn_and_split "*logical_sidisi3"
3118 [(set (match_operand:SI 0 "arith_reg_dest" "=r,r")
3119 (truncate:SI (sign_extend:DI
3120 (match_operator:SI 3 "logical_operator"
3121 [(match_operand:SI 1 "arith_reg_operand" "%r,r")
3122 (match_operand:SI 2 "logical_operand" "r,I10")]))))]
3126 [(set (match_dup 0) (match_dup 3))])
3128 (define_insn_and_split "*logical_sidi3_2"
3129 [(set (match_operand:DI 0 "arith_reg_dest" "=r,r")
3130 (sign_extend:DI (truncate:SI (sign_extend:DI
3131 (match_operator:SI 3 "logical_operator"
3132 [(match_operand:SI 1 "arith_reg_operand" "%r,r")
3133 (match_operand:SI 2 "logical_operand" "r,I10")])))))]
3137 [(set (match_dup 0) (sign_extend:DI (match_dup 3)))])
3139 (define_expand "xorsi3"
3140 [(set (match_operand:SI 0 "arith_reg_operand" "")
3141 (xor:SI (match_operand:SI 1 "logical_reg_operand" "")
3142 (match_operand:SI 2 "xor_operand" "")))]
3146 (define_insn "*xorsi3_compact"
3147 [(set (match_operand:SI 0 "arith_reg_dest" "=z,r")
3148 (xor:SI (match_operand:SI 1 "arith_reg_operand" "%0,0")
3149 (match_operand:SI 2 "logical_operand" "K08,r")))]
3152 [(set_attr "type" "arith")])
3154 (define_insn "*xorsi3_media"
3155 [(set (match_operand:SI 0 "arith_reg_dest" "=r,r")
3156 (xor:SI (match_operand:SI 1 "logical_reg_operand" "%r,r")
3157 (match_operand:SI 2 "xor_operand" "r,I06")))]
3162 [(set_attr "type" "arith_media")])
3164 (define_insn "xordi3"
3165 [(set (match_operand:DI 0 "arith_reg_dest" "=r,r")
3166 (xor:DI (match_operand:DI 1 "arith_reg_operand" "%r,r")
3167 (match_operand:DI 2 "xor_operand" "r,I06")))]
3172 [(set_attr "type" "arith_media")])
3174 ;; Combiner bridge pattern for 2 * sign extend -> logical op -> truncate.
3175 ;; converts 2 * sign extend -> logical op into logical op -> sign extend
3177 [(set (match_operand:DI 0 "arith_reg_dest" "")
3178 (sign_extend:DI (match_operator 4 "binary_logical_operator"
3179 [(match_operand 1 "any_register_operand" "")
3180 (match_operand 2 "any_register_operand" "")])))]
3182 [(set (match_dup 5) (match_dup 4))
3183 (set (match_dup 0) (sign_extend:DI (match_dup 5)))]
3186 enum machine_mode inmode = GET_MODE (operands[1]);
3189 if (GET_CODE (operands[0]) == SUBREG)
3191 offset = SUBREG_BYTE (operands[0]);
3192 operands[0] = SUBREG_REG (operands[0]);
3194 gcc_assert (GET_CODE (operands[0]) == REG);
3195 if (! TARGET_LITTLE_ENDIAN)
3196 offset += 8 - GET_MODE_SIZE (inmode);
3197 operands[5] = gen_rtx_SUBREG (inmode, operands[0], offset);
3200 ;; -------------------------------------------------------------------------
3201 ;; Shifts and rotates
3202 ;; -------------------------------------------------------------------------
3204 (define_expand "rotldi3"
3205 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
3206 (rotate:DI (match_operand:DI 1 "arith_reg_operand" "r")
3207 (match_operand:HI 2 "mextr_bit_offset" "i")))]
3209 "if (! mextr_bit_offset (operands[2], HImode)) FAIL;")
3211 (define_insn "rotldi3_mextr"
3212 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
3213 (rotate:DI (match_operand:DI 1 "arith_reg_operand" "r")
3214 (match_operand:HI 2 "mextr_bit_offset" "i")))]
3218 static char templ[16];
3220 sprintf (templ, \"mextr%d\\t%%1,%%1,%%0\",
3221 8 - (int) (INTVAL (operands[2]) >> 3));
3224 [(set_attr "type" "arith_media")])
3226 (define_expand "rotrdi3"
3227 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
3228 (rotatert:DI (match_operand:DI 1 "arith_reg_operand" "r")
3229 (match_operand:HI 2 "mextr_bit_offset" "i")))]
3231 "if (! mextr_bit_offset (operands[2], HImode)) FAIL;")
3233 (define_insn "rotrdi3_mextr"
3234 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
3235 (rotatert:DI (match_operand:DI 1 "arith_reg_operand" "r")
3236 (match_operand:HI 2 "mextr_bit_offset" "i")))]
3240 static char templ[16];
3242 sprintf (templ, \"mextr%d\\t%%1,%%1,%%0\", (int) INTVAL (operands[2]) >> 3);
3245 [(set_attr "type" "arith_media")])
3248 [(set (match_operand:DI 0 "arith_reg_dest" "")
3249 (ior:DI (zero_extend:DI (mem:QI (match_operand 1
3250 "ua_address_operand" "")))
3251 (ashift:DI (match_operand:DI 2 "arith_reg_operand" "")
3253 (clobber (match_operand:DI 3 "register_operand" ""))]
3255 [(match_dup 4) (match_dup 5)]
3258 operands[4] = ((TARGET_LITTLE_ENDIAN ? gen_ldhi_q : gen_ldlo_q)
3259 (operands[3], operands[1]));
3260 operands[5] = gen_mextr_rl (operands[0], operands[3], operands[2],
3261 GEN_INT (56), GEN_INT (8));
3264 (define_insn "rotlsi3_1"
3265 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
3266 (rotate:SI (match_operand:SI 1 "arith_reg_operand" "0")
3269 (lshiftrt:SI (match_dup 1) (const_int 31)))]
3272 [(set_attr "type" "arith")])
3274 (define_insn "rotlsi3_31"
3275 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
3276 (rotate:SI (match_operand:SI 1 "arith_reg_operand" "0")
3278 (clobber (reg:SI T_REG))]
3281 [(set_attr "type" "arith")])
3283 (define_insn "rotlsi3_16"
3284 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
3285 (rotate:SI (match_operand:SI 1 "arith_reg_operand" "r")
3289 [(set_attr "type" "arith")])
3291 (define_expand "rotlsi3"
3292 [(set (match_operand:SI 0 "arith_reg_dest" "")
3293 (rotate:SI (match_operand:SI 1 "arith_reg_operand" "")
3294 (match_operand:SI 2 "immediate_operand" "")))]
3298 static const char rot_tab[] = {
3299 000, 000, 000, 000, 000, 000, 010, 001,
3300 001, 001, 011, 013, 003, 003, 003, 003,
3301 003, 003, 003, 003, 003, 013, 012, 002,
3302 002, 002, 010, 000, 000, 000, 000, 000,
3307 if (GET_CODE (operands[2]) != CONST_INT)
3309 count = INTVAL (operands[2]);
3310 choice = rot_tab[count];
3311 if (choice & 010 && SH_DYNAMIC_SHIFT_COST <= 1)
3317 emit_move_insn (operands[0], operands[1]);
3318 count -= (count & 16) * 2;
3321 emit_insn (gen_rotlsi3_16 (operands[0], operands[1]));
3328 parts[0] = gen_reg_rtx (SImode);
3329 parts[1] = gen_reg_rtx (SImode);
3330 emit_insn (gen_rotlsi3_16 (parts[2-choice], operands[1]));
3331 emit_move_insn (parts[choice-1], operands[1]);
3332 emit_insn (gen_ashlsi3 (parts[0], parts[0], GEN_INT (8)));
3333 emit_insn (gen_lshrsi3 (parts[1], parts[1], GEN_INT (8)));
3334 emit_insn (gen_iorsi3 (operands[0], parts[0], parts[1]));
3335 count = (count & ~16) - 8;
3339 for (; count > 0; count--)
3340 emit_insn (gen_rotlsi3_1 (operands[0], operands[0]));
3341 for (; count < 0; count++)
3342 emit_insn (gen_rotlsi3_31 (operands[0], operands[0]));
3347 (define_insn "*rotlhi3_8"
3348 [(set (match_operand:HI 0 "arith_reg_dest" "=r")
3349 (rotate:HI (match_operand:HI 1 "arith_reg_operand" "r")
3353 [(set_attr "type" "arith")])
3355 (define_expand "rotlhi3"
3356 [(set (match_operand:HI 0 "arith_reg_operand" "")
3357 (rotate:HI (match_operand:HI 1 "arith_reg_operand" "")
3358 (match_operand:HI 2 "immediate_operand" "")))]
3362 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 8)
3369 (define_insn "ashlsi3_sh2a"
3370 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
3371 (ashift:SI (match_operand:SI 1 "arith_reg_operand" "0")
3372 (match_operand:SI 2 "arith_reg_operand" "r")))]
3375 [(set_attr "type" "arith")
3376 (set_attr "length" "4")])
3378 ;; This pattern is used by init_expmed for computing the costs of shift
3381 (define_insn_and_split "ashlsi3_std"
3382 [(set (match_operand:SI 0 "arith_reg_dest" "=r,r,r,r")
3383 (ashift:SI (match_operand:SI 1 "arith_reg_operand" "0,0,0,0")
3384 (match_operand:SI 2 "nonmemory_operand" "r,M,P27,?ri")))
3385 (clobber (match_scratch:SI 3 "=X,X,X,&r"))]
3387 || (TARGET_SH1 && GET_CODE (operands[2]) == CONST_INT
3388 && CONST_OK_FOR_P27 (INTVAL (operands[2])))"
3396 && GET_CODE (operands[2]) == CONST_INT
3397 && ! CONST_OK_FOR_P27 (INTVAL (operands[2]))"
3398 [(set (match_dup 3) (match_dup 2))
3400 [(set (match_dup 0) (ashift:SI (match_dup 1) (match_dup 3)))
3401 (clobber (match_dup 4))])]
3402 "operands[4] = gen_rtx_SCRATCH (SImode);"
3403 [(set_attr "length" "*,*,*,4")
3404 (set_attr "type" "dyn_shift,arith,arith,arith")])
3406 (define_insn "ashlhi3_k"
3407 [(set (match_operand:HI 0 "arith_reg_dest" "=r,r")
3408 (ashift:HI (match_operand:HI 1 "arith_reg_operand" "0,0")
3409 (match_operand:HI 2 "const_int_operand" "M,P27")))]
3410 "TARGET_SH1 && CONST_OK_FOR_P27 (INTVAL (operands[2]))"
3414 [(set_attr "type" "arith")])
3416 (define_insn "ashlsi3_n"
3417 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
3418 (ashift:SI (match_operand:SI 1 "arith_reg_operand" "0")
3419 (match_operand:SI 2 "const_int_operand" "n")))
3420 (clobber (reg:SI T_REG))]
3421 "TARGET_SH1 && ! sh_dynamicalize_shift_p (operands[2])"
3423 [(set (attr "length")
3424 (cond [(eq (symbol_ref "shift_insns_rtx (insn)") (const_int 1))
3426 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 2))
3428 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 3))
3430 (const_string "8")))
3431 (set_attr "type" "arith")])
3434 [(set (match_operand:SI 0 "arith_reg_dest" "")
3435 (ashift:SI (match_operand:SI 1 "arith_reg_operand" "")
3436 (match_operand:SI 2 "const_int_operand" "")))
3437 (clobber (reg:SI T_REG))]
3438 "TARGET_SH1 && reload_completed"
3439 [(use (reg:SI R0_REG))]
3442 gen_shifty_op (ASHIFT, operands);
3446 (define_insn "ashlsi3_media"
3447 [(set (match_operand:SI 0 "arith_reg_dest" "=r,r")
3448 (ashift:SI (match_operand:SI 1 "extend_reg_operand" "r,r")
3449 (match_operand:SI 2 "shift_count_operand" "r,n")))]
3454 [(set_attr "type" "arith_media")
3455 (set_attr "highpart" "ignore")])
3457 (define_expand "ashlsi3"
3458 [(parallel [(set (match_operand:SI 0 "arith_reg_operand" "")
3459 (ashift:SI (match_operand:SI 1 "arith_reg_operand" "")
3460 (match_operand:SI 2 "nonmemory_operand" "")))
3461 (clobber (reg:SI T_REG))])]
3467 emit_insn (gen_ashlsi3_media (operands[0], operands[1], operands[2]));
3470 if (GET_CODE (operands[2]) == CONST_INT
3471 && sh_dynamicalize_shift_p (operands[2]))
3472 operands[2] = force_reg (SImode, operands[2]);
3475 emit_insn (gen_ashlsi3_std (operands[0], operands[1], operands[2]));
3478 if (! immediate_operand (operands[2], GET_MODE (operands[2])))
3482 (define_insn "*ashlhi3_n"
3483 [(set (match_operand:HI 0 "arith_reg_dest" "=r")
3484 (ashift:HI (match_operand:HI 1 "arith_reg_operand" "0")
3485 (match_operand:HI 2 "const_int_operand" "n")))
3486 (clobber (reg:SI T_REG))]
3489 [(set (attr "length")
3490 (cond [(eq (symbol_ref "shift_insns_rtx (insn)") (const_int 1))
3492 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 2))
3494 (const_string "6")))
3495 (set_attr "type" "arith")])
3497 (define_expand "ashlhi3"
3498 [(parallel [(set (match_operand:HI 0 "arith_reg_operand" "")
3499 (ashift:HI (match_operand:HI 1 "arith_reg_operand" "")
3500 (match_operand:SI 2 "nonmemory_operand" "")))
3501 (clobber (reg:SI T_REG))])]
3505 if (GET_CODE (operands[2]) != CONST_INT)
3507 /* It may be possible to call gen_ashlhi3 directly with more generic
3508 operands. Make sure operands[1] is a HImode register here. */
3509 if (!arith_reg_operand (operands[1], HImode))
3510 operands[1] = copy_to_mode_reg (HImode, operands[1]);
3514 [(set (match_operand:HI 0 "arith_reg_dest" "")
3515 (ashift:HI (match_operand:HI 1 "arith_reg_operand" "")
3516 (match_operand:HI 2 "const_int_operand" "")))
3517 (clobber (reg:SI T_REG))]
3518 "TARGET_SH1 && reload_completed"
3519 [(use (reg:SI R0_REG))]
3522 gen_shifty_hi_op (ASHIFT, operands);
3527 ; arithmetic shift right
3530 (define_insn "ashrsi3_sh2a"
3531 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
3532 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
3533 (neg:SI (match_operand:SI 2 "arith_reg_operand" "r"))))]
3536 [(set_attr "type" "dyn_shift")
3537 (set_attr "length" "4")])
3539 (define_insn "ashrsi3_k"
3540 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
3541 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
3542 (match_operand:SI 2 "const_int_operand" "M")))
3543 (clobber (reg:SI T_REG))]
3544 "TARGET_SH1 && INTVAL (operands[2]) == 1"
3546 [(set_attr "type" "arith")])
3548 ;; We can't do HImode right shifts correctly unless we start out with an
3549 ;; explicit zero / sign extension; doing that would result in worse overall
3550 ;; code, so just let the machine independent code widen the mode.
3551 ;; That's why we don't have ashrhi3_k / lshrhi3_k / lshrhi3_m / lshrhi3 .
3554 ;; ??? This should be a define expand.
3556 (define_insn "ashrsi2_16"
3557 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
3558 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "r")
3562 [(set_attr "length" "4")])
3565 [(set (match_operand:SI 0 "arith_reg_dest" "")
3566 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "")
3569 [(set (match_dup 0) (rotate:SI (match_dup 1) (const_int 16)))
3570 (set (match_dup 0) (sign_extend:SI (match_dup 2)))]
3571 "operands[2] = gen_lowpart (HImode, operands[0]);")
3573 ;; ??? This should be a define expand.
3575 (define_insn "ashrsi2_31"
3576 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
3577 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
3579 (clobber (reg:SI T_REG))]
3582 [(set_attr "length" "4")])
3585 [(set (match_operand:SI 0 "arith_reg_dest" "")
3586 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "")
3588 (clobber (reg:SI T_REG))]
3593 emit_insn (gen_ashlsi_c (operands[0], operands[1]));
3594 emit_insn (gen_mov_neg_si_t (operands[0]));
3599 [(set (match_operand:SI 0 "arith_reg_dest" "") (const_int 0))
3601 (gt:SI (match_dup 0) (match_operand:SI 1 "arith_reg_operand" "")))]
3603 && peep2_reg_dead_p (2, operands[0])
3604 && peep2_reg_dead_p (2, operands[1])"
3608 emit_insn (gen_ashlsi_c (operands[1], operands[1]));
3612 (define_insn "ashlsi_c"
3613 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
3614 (ashift:SI (match_operand:SI 1 "arith_reg_operand" "0") (const_int 1)))
3616 (lt:SI (match_dup 1) (const_int 0)))]
3619 [(set_attr "type" "arith")])
3621 (define_insn "*ashlsi_c_void"
3622 [(set (reg:SI T_REG)
3623 (lt:SI (match_operand:SI 0 "arith_reg_operand" "r") (const_int 0)))
3624 (clobber (match_scratch:SI 1 "=0"))]
3625 "TARGET_SH1 && cse_not_expected"
3627 [(set_attr "type" "arith")])
3629 (define_insn "ashrsi3_d"
3630 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
3631 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
3632 (neg:SI (match_operand:SI 2 "arith_reg_operand" "r"))))]
3635 [(set_attr "type" "dyn_shift")])
3637 (define_insn "ashrsi3_n"
3638 [(set (reg:SI R4_REG)
3639 (ashiftrt:SI (reg:SI R4_REG)
3640 (match_operand:SI 0 "const_int_operand" "i")))
3641 (clobber (reg:SI T_REG))
3642 (clobber (reg:SI PR_REG))
3643 (use (match_operand:SI 1 "arith_reg_operand" "r"))]
3646 [(set_attr "type" "sfunc")
3647 (set_attr "needs_delay_slot" "yes")])
3649 (define_insn "ashrsi3_media"
3650 [(set (match_operand:SI 0 "arith_reg_dest" "=r,r")
3651 (ashiftrt:SI (match_operand:SI 1 "extend_reg_operand" "r,r")
3652 (match_operand:SI 2 "shift_count_operand" "r,n")))]
3657 [(set_attr "type" "arith_media")
3658 (set_attr "highpart" "ignore")])
3660 (define_expand "ashrsi3"
3661 [(parallel [(set (match_operand:SI 0 "arith_reg_operand" "")
3662 (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "")
3663 (match_operand:SI 2 "nonmemory_operand" "")))
3664 (clobber (reg:SI T_REG))])]
3670 emit_insn (gen_ashrsi3_media (operands[0], operands[1], operands[2]));
3673 if (expand_ashiftrt (operands))
3679 ;; logical shift right
3681 (define_insn "lshrsi3_sh2a"
3682 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
3683 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
3684 (neg:SI (match_operand:SI 2 "arith_reg_operand" "r"))))]
3687 [(set_attr "type" "dyn_shift")
3688 (set_attr "length" "4")])
3690 (define_insn "lshrsi3_d"
3691 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
3692 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
3693 (neg:SI (match_operand:SI 2 "arith_reg_operand" "r"))))]
3696 [(set_attr "type" "dyn_shift")])
3698 ;; Only the single bit shift clobbers the T bit.
3700 (define_insn "lshrsi3_m"
3701 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
3702 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
3703 (match_operand:SI 2 "const_int_operand" "M")))
3704 (clobber (reg:SI T_REG))]
3705 "TARGET_SH1 && CONST_OK_FOR_M (INTVAL (operands[2]))"
3707 [(set_attr "type" "arith")])
3709 (define_insn "lshrsi3_k"
3710 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
3711 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
3712 (match_operand:SI 2 "const_int_operand" "P27")))]
3713 "TARGET_SH1 && CONST_OK_FOR_P27 (INTVAL (operands[2]))
3714 && ! CONST_OK_FOR_M (INTVAL (operands[2]))"
3716 [(set_attr "type" "arith")])
3718 (define_insn "lshrsi3_n"
3719 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
3720 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
3721 (match_operand:SI 2 "const_int_operand" "n")))
3722 (clobber (reg:SI T_REG))]
3723 "TARGET_SH1 && ! sh_dynamicalize_shift_p (operands[2])"
3725 [(set (attr "length")
3726 (cond [(eq (symbol_ref "shift_insns_rtx (insn)") (const_int 1))
3728 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 2))
3730 (eq (symbol_ref "shift_insns_rtx (insn)") (const_int 3))
3732 (const_string "8")))
3733 (set_attr "type" "arith")])
3736 [(set (match_operand:SI 0 "arith_reg_dest" "")
3737 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "")
3738 (match_operand:SI 2 "const_int_operand" "")))
3739 (clobber (reg:SI T_REG))]
3740 "TARGET_SH1 && reload_completed"
3741 [(use (reg:SI R0_REG))]
3744 gen_shifty_op (LSHIFTRT, operands);
3748 (define_insn "lshrsi3_media"
3749 [(set (match_operand:SI 0 "arith_reg_dest" "=r,r")
3750 (lshiftrt:SI (match_operand:SI 1 "extend_reg_operand" "r,r")
3751 (match_operand:SI 2 "shift_count_operand" "r,n")))]
3756 [(set_attr "type" "arith_media")
3757 (set_attr "highpart" "ignore")])
3759 (define_expand "lshrsi3"
3760 [(parallel [(set (match_operand:SI 0 "arith_reg_dest" "")
3761 (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "")
3762 (match_operand:SI 2 "nonmemory_operand" "")))
3763 (clobber (reg:SI T_REG))])]
3769 emit_insn (gen_lshrsi3_media (operands[0], operands[1], operands[2]));
3772 if (GET_CODE (operands[2]) == CONST_INT
3773 && sh_dynamicalize_shift_p (operands[2]))
3774 operands[2] = force_reg (SImode, operands[2]);
3775 if (TARGET_SH3 && arith_reg_operand (operands[2], GET_MODE (operands[2])))
3777 rtx count = copy_to_mode_reg (SImode, operands[2]);
3778 emit_insn (gen_negsi2 (count, count));
3779 emit_insn (gen_lshrsi3_d (operands[0], operands[1], count));
3782 if (! immediate_operand (operands[2], GET_MODE (operands[2])))
3786 ;; ??? This should be a define expand.
3788 (define_insn "ashldi3_k"
3789 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
3790 (ashift:DI (match_operand:DI 1 "arith_reg_operand" "0")
3792 (clobber (reg:SI T_REG))]
3794 "shll %R0\;rotcl %S0"
3795 [(set_attr "length" "4")
3796 (set_attr "type" "arith")])
3798 (define_insn "ashldi3_media"
3799 [(set (match_operand:DI 0 "arith_reg_dest" "=r,r")
3800 (ashift:DI (match_operand:DI 1 "arith_reg_operand" "r,r")
3801 (match_operand:DI 2 "shift_count_operand" "r,n")))]
3806 [(set_attr "type" "arith_media")])
3808 (define_insn "*ashldisi3_media"
3809 [(set (subreg:DI (match_operand:SI 0 "arith_reg_operand" "=r") 0)
3810 (ashift:DI (match_operand:DI 1 "arith_reg_operand" "r")
3811 (match_operand:DI 2 "const_int_operand" "n")))]
3812 "TARGET_SHMEDIA && INTVAL (operands[2]) < 32"
3813 "shlli.l %1, %2, %0"
3814 [(set_attr "type" "arith_media")
3815 (set_attr "highpart" "ignore")])
3817 (define_expand "ashldi3"
3818 [(parallel [(set (match_operand:DI 0 "arith_reg_operand" "")
3819 (ashift:DI (match_operand:DI 1 "arith_reg_operand" "")
3820 (match_operand:DI 2 "immediate_operand" "")))
3821 (clobber (reg:SI T_REG))])]
3827 emit_insn (gen_ashldi3_media (operands[0], operands[1], operands[2]));
3830 if (GET_CODE (operands[2]) != CONST_INT
3831 || INTVAL (operands[2]) != 1)
3835 ;; ??? This should be a define expand.
3837 (define_insn "lshrdi3_k"
3838 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
3839 (lshiftrt:DI (match_operand:DI 1 "arith_reg_operand" "0")
3841 (clobber (reg:SI T_REG))]
3843 "shlr %S0\;rotcr %R0"
3844 [(set_attr "length" "4")
3845 (set_attr "type" "arith")])
3847 (define_insn "lshrdi3_media"
3848 [(set (match_operand:DI 0 "ext_dest_operand" "=r,r")
3849 (lshiftrt:DI (match_operand:DI 1 "arith_reg_operand" "r,r")
3850 (match_operand:DI 2 "shift_count_operand" "r,n")))]
3852 && (arith_reg_dest (operands[0], DImode)
3853 || (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) > 32))"
3857 [(set_attr "type" "arith_media")])
3859 (define_insn "*lshrdisi3_media"
3860 [(set (subreg:DI (match_operand:SI 0 "arith_reg_operand" "=r") 0)
3861 (lshiftrt:DI (match_operand:DI 1 "arith_reg_operand" "r")
3862 (match_operand:DI 2 "const_int_operand" "n")))]
3863 "TARGET_SHMEDIA && INTVAL (operands[2]) < 32"
3864 "shlri.l %1, %2, %0"
3865 [(set_attr "type" "arith_media")
3866 (set_attr "highpart" "ignore")])
3868 (define_expand "lshrdi3"
3869 [(parallel [(set (match_operand:DI 0 "arith_reg_operand" "")
3870 (lshiftrt:DI (match_operand:DI 1 "arith_reg_operand" "")
3871 (match_operand:DI 2 "immediate_operand" "")))
3872 (clobber (reg:SI T_REG))])]
3878 emit_insn (gen_lshrdi3_media (operands[0], operands[1], operands[2]));
3881 if (GET_CODE (operands[2]) != CONST_INT
3882 || INTVAL (operands[2]) != 1)
3886 ;; ??? This should be a define expand.
3888 (define_insn "ashrdi3_k"
3889 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
3890 (ashiftrt:DI (match_operand:DI 1 "arith_reg_operand" "0")
3892 (clobber (reg:SI T_REG))]
3894 "shar %S0\;rotcr %R0"
3895 [(set_attr "length" "4")
3896 (set_attr "type" "arith")])
3898 (define_insn "ashrdi3_media"
3899 [(set (match_operand:DI 0 "ext_dest_operand" "=r,r")
3900 (ashiftrt:DI (match_operand:DI 1 "arith_reg_operand" "r,r")
3901 (match_operand:DI 2 "shift_count_operand" "r,n")))]
3903 && (arith_reg_dest (operands[0], DImode)
3904 || (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 32))"
3908 [(set_attr "type" "arith_media")])
3910 (define_insn "*ashrdisi3_media"
3911 [(set (subreg:DI (match_operand:SI 0 "arith_reg_operand" "=r") 0)
3912 (ashiftrt:DI (match_operand:DI 1 "arith_reg_operand" "r")
3913 (match_operand:DI 2 "const_int_operand" "n")))]
3914 "TARGET_SHMEDIA && INTVAL (operands[2]) < 32"
3915 "shari.l %1, %2, %0"
3916 [(set_attr "type" "arith_media")
3917 (set_attr "highpart" "ignore")])
3919 (define_insn "ashrdisi3_media_high"
3920 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
3922 (ashiftrt:DI (match_operand:DI 1 "arith_reg_operand" "r")
3923 (match_operand:DI 2 "const_int_operand" "n"))))]
3924 "TARGET_SHMEDIA && INTVAL (operands[2]) >= 32"
3926 [(set_attr "type" "arith_media")])
3928 (define_insn "ashrdisi3_media_opaque"
3929 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
3930 (unspec:SI [(match_operand:DI 1 "arith_reg_operand" "r")
3931 (match_operand:DI 2 "const_int_operand" "n")]
3935 [(set_attr "type" "arith_media")])
3937 (define_expand "ashrdi3"
3938 [(parallel [(set (match_operand:DI 0 "arith_reg_operand" "")
3939 (ashiftrt:DI (match_operand:DI 1 "arith_reg_operand" "")
3940 (match_operand:DI 2 "immediate_operand" "")))
3941 (clobber (reg:SI T_REG))])]
3947 emit_insn (gen_ashrdi3_media (operands[0], operands[1], operands[2]));
3950 if (GET_CODE (operands[2]) != CONST_INT
3951 || INTVAL (operands[2]) != 1)
3955 ;; combined left/right shift
3958 [(set (match_operand:SI 0 "register_operand" "")
3959 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
3960 (match_operand:SI 2 "const_int_operand" ""))
3961 (match_operand:SI 3 "const_int_operand" "")))]
3962 "TARGET_SH1 && reload_completed && (unsigned)INTVAL (operands[2]) < 32"
3963 [(use (reg:SI R0_REG))]
3964 "if (gen_shl_and (operands[0], operands[2], operands[3], operands[1])) FAIL;
3968 [(set (match_operand:SI 0 "register_operand" "")
3969 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
3970 (match_operand:SI 2 "const_int_operand" ""))
3971 (match_operand:SI 3 "const_int_operand" "")))
3972 (clobber (reg:SI T_REG))]
3973 "TARGET_SH1 && reload_completed && (unsigned)INTVAL (operands[2]) < 32"
3974 [(use (reg:SI R0_REG))]
3975 "if (gen_shl_and (operands[0], operands[2], operands[3], operands[1])) FAIL;
3979 [(set (match_operand:SI 0 "register_operand" "=r")
3980 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
3981 (match_operand:SI 2 "const_int_operand" "n"))
3982 (match_operand:SI 3 "const_int_operand" "n")))
3983 (clobber (reg:SI T_REG))]
3984 "TARGET_SH1 && shl_and_kind (operands[2], operands[3], 0) == 1"
3986 [(set (attr "length")
3987 (cond [(eq (symbol_ref "shl_and_length (insn)") (const_int 2))
3989 (eq (symbol_ref "shl_and_length (insn)") (const_int 3))
3991 (eq (symbol_ref "shl_and_length (insn)") (const_int 4))
3993 (eq (symbol_ref "shl_and_length (insn)") (const_int 5))
3995 (eq (symbol_ref "shl_and_length (insn)") (const_int 6))
3997 (eq (symbol_ref "shl_and_length (insn)") (const_int 7))
3999 (eq (symbol_ref "shl_and_length (insn)") (const_int 8))
4000 (const_string "16")]
4001 (const_string "18")))
4002 (set_attr "type" "arith")])
4005 [(set (match_operand:SI 0 "register_operand" "=z")
4006 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
4007 (match_operand:SI 2 "const_int_operand" "n"))
4008 (match_operand:SI 3 "const_int_operand" "n")))
4009 (clobber (reg:SI T_REG))]
4010 "TARGET_SH1 && shl_and_kind (operands[2], operands[3], 0) == 2"
4012 [(set (attr "length")
4013 (cond [(eq (symbol_ref "shl_and_length (insn)") (const_int 2))
4015 (eq (symbol_ref "shl_and_length (insn)") (const_int 3))
4017 (eq (symbol_ref "shl_and_length (insn)") (const_int 4))
4019 (const_string "10")))
4020 (set_attr "type" "arith")])
4022 ;; shift left / and combination with a scratch register: The combine pass
4023 ;; does not accept the individual instructions, even though they are
4024 ;; cheap. But it needs a precise description so that it is usable after
4026 (define_insn "and_shl_scratch"
4027 [(set (match_operand:SI 0 "register_operand" "=r,&r")
4031 (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,0")
4032 (match_operand:SI 2 "const_int_operand" "N,n"))
4033 (match_operand:SI 3 "" "0,r"))
4034 (match_operand:SI 4 "const_int_operand" "n,n"))
4035 (match_operand:SI 5 "const_int_operand" "n,n")))
4036 (clobber (reg:SI T_REG))]
4039 [(set (attr "length")
4040 (cond [(eq (symbol_ref "shl_and_scr_length (insn)") (const_int 2))
4042 (eq (symbol_ref "shl_and_scr_length (insn)") (const_int 3))
4044 (eq (symbol_ref "shl_and_scr_length (insn)") (const_int 4))
4046 (eq (symbol_ref "shl_and_scr_length (insn)") (const_int 5))
4047 (const_string "10")]
4048 (const_string "12")))
4049 (set_attr "type" "arith")])
4052 [(set (match_operand:SI 0 "register_operand" "")
4056 (lshiftrt:SI (match_operand:SI 1 "register_operand" "")
4057 (match_operand:SI 2 "const_int_operand" ""))
4058 (match_operand:SI 3 "register_operand" ""))
4059 (match_operand:SI 4 "const_int_operand" ""))
4060 (match_operand:SI 5 "const_int_operand" "")))
4061 (clobber (reg:SI T_REG))]
4063 [(use (reg:SI R0_REG))]
4066 rtx and_source = operands[rtx_equal_p (operands[0], operands[1]) ? 3 : 1];
4068 if (INTVAL (operands[2]))
4070 gen_shifty_op (LSHIFTRT, operands);
4072 emit_insn (gen_andsi3 (operands[0], operands[0], and_source));
4073 operands[2] = operands[4];
4074 gen_shifty_op (ASHIFT, operands);
4075 if (INTVAL (operands[5]))
4077 operands[2] = operands[5];
4078 gen_shifty_op (LSHIFTRT, operands);
4083 ;; signed left/right shift combination.
4085 [(set (match_operand:SI 0 "register_operand" "")
4087 (ashift:SI (match_operand:SI 1 "register_operand" "")
4088 (match_operand:SI 2 "const_int_operand" ""))
4089 (match_operand:SI 3 "const_int_operand" "")
4091 (clobber (reg:SI T_REG))]
4093 [(use (reg:SI R0_REG))]
4094 "if (gen_shl_sext (operands[0], operands[2], operands[3], operands[1])) FAIL;
4097 (define_insn "shl_sext_ext"
4098 [(set (match_operand:SI 0 "register_operand" "=r")
4100 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4101 (match_operand:SI 2 "const_int_operand" "n"))
4102 (match_operand:SI 3 "const_int_operand" "n")
4104 (clobber (reg:SI T_REG))]
4105 "TARGET_SH1 && (unsigned)shl_sext_kind (operands[2], operands[3], 0) - 1 < 5"
4107 [(set (attr "length")
4108 (cond [(eq (symbol_ref "shl_sext_length (insn)") (const_int 1))
4110 (eq (symbol_ref "shl_sext_length (insn)") (const_int 2))
4112 (eq (symbol_ref "shl_sext_length (insn)") (const_int 3))
4114 (eq (symbol_ref "shl_sext_length (insn)") (const_int 4))
4116 (eq (symbol_ref "shl_sext_length (insn)") (const_int 5))
4118 (eq (symbol_ref "shl_sext_length (insn)") (const_int 6))
4120 (eq (symbol_ref "shl_sext_length (insn)") (const_int 7))
4122 (eq (symbol_ref "shl_sext_length (insn)") (const_int 8))
4123 (const_string "16")]
4124 (const_string "18")))
4125 (set_attr "type" "arith")])
4127 (define_insn "shl_sext_sub"
4128 [(set (match_operand:SI 0 "register_operand" "=z")
4130 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4131 (match_operand:SI 2 "const_int_operand" "n"))
4132 (match_operand:SI 3 "const_int_operand" "n")
4134 (clobber (reg:SI T_REG))]
4135 "TARGET_SH1 && (shl_sext_kind (operands[2], operands[3], 0) & ~1) == 6"
4137 [(set (attr "length")
4138 (cond [(eq (symbol_ref "shl_sext_length (insn)") (const_int 3))
4140 (eq (symbol_ref "shl_sext_length (insn)") (const_int 4))
4142 (eq (symbol_ref "shl_sext_length (insn)") (const_int 5))
4144 (eq (symbol_ref "shl_sext_length (insn)") (const_int 6))
4145 (const_string "12")]
4146 (const_string "14")))
4147 (set_attr "type" "arith")])
4149 ;; These patterns are found in expansions of DImode shifts by 16, and
4150 ;; allow the xtrct instruction to be generated from C source.
4152 (define_insn "xtrct_left"
4153 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
4154 (ior:SI (ashift:SI (match_operand:SI 1 "arith_reg_operand" "r")
4156 (lshiftrt:SI (match_operand:SI 2 "arith_reg_operand" "0")
4160 [(set_attr "type" "arith")])
4162 (define_insn "xtrct_right"
4163 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
4164 (ior:SI (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
4166 (ashift:SI (match_operand:SI 2 "arith_reg_operand" "r")
4170 [(set_attr "type" "arith")])
4172 ;; -------------------------------------------------------------------------
4174 ;; -------------------------------------------------------------------------
4177 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
4178 (neg:SI (plus:SI (reg:SI T_REG)
4179 (match_operand:SI 1 "arith_reg_operand" "r"))))
4181 (ne:SI (ior:SI (reg:SI T_REG) (match_dup 1))
4185 [(set_attr "type" "arith")])
4187 (define_insn "*negdi_media"
4188 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
4189 (neg:DI (match_operand:DI 1 "arith_reg_operand" "r")))]
4192 [(set_attr "type" "arith_media")])
4194 (define_expand "negdi2"
4195 [(set (match_operand:DI 0 "arith_reg_operand" "")
4196 (neg:DI (match_operand:DI 1 "arith_reg_operand" "")))]
4202 int low_word = (TARGET_LITTLE_ENDIAN ? 0 : 1);
4203 int high_word = (TARGET_LITTLE_ENDIAN ? 1 : 0);
4205 rtx low_src = operand_subword (operands[1], low_word, 0, DImode);
4206 rtx high_src = operand_subword (operands[1], high_word, 0, DImode);
4208 rtx low_dst = operand_subword (operands[0], low_word, 1, DImode);
4209 rtx high_dst = operand_subword (operands[0], high_word, 1, DImode);
4211 emit_insn (gen_clrt ());
4212 emit_insn (gen_negc (low_dst, low_src));
4213 emit_insn (gen_negc (high_dst, high_src));
4218 (define_insn "negsi2"
4219 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
4220 (neg:SI (match_operand:SI 1 "arith_reg_operand" "r")))]
4223 [(set_attr "type" "arith")])
4225 (define_insn "one_cmplsi2"
4226 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
4227 (not:SI (match_operand:SI 1 "arith_reg_operand" "r")))]
4230 [(set_attr "type" "arith")])
4232 (define_expand "one_cmpldi2"
4233 [(set (match_operand:DI 0 "arith_reg_dest" "")
4234 (xor:DI (match_operand:DI 1 "arith_reg_operand" "")
4236 "TARGET_SHMEDIA" "")
4238 /* The SH4 202 can do zero-offset branches without pipeline stalls.
4239 This can be used as some kind of conditional execution, which is useful
4242 [(set (match_operand:SI 0 "arith_reg_dest" "")
4243 (plus:SI (xor:SI (neg:SI (reg:SI T_REG))
4244 (match_operand:SI 1 "arith_reg_operand" ""))
4248 "emit_insn (gen_movsi_i (operands[0], operands[1]));
4249 emit_insn (gen_cneg (operands[0], operands[0], operands[0]));
4253 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
4254 (if_then_else:SI (eq:SI (reg:SI T_REG) (const_int 0))
4255 (match_operand:SI 1 "arith_reg_operand" "0")
4256 (neg:SI (match_operand:SI 2 "arith_reg_operand" "r"))))]
4258 "bf 0f\;neg %2,%0\\n0:"
4259 [(set_attr "type" "arith") ;; poor approximation
4260 (set_attr "length" "4")])
4263 ;; -------------------------------------------------------------------------
4264 ;; Zero extension instructions
4265 ;; -------------------------------------------------------------------------
4267 (define_insn "zero_extendsidi2"
4268 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
4269 (zero_extend:DI (match_operand:SI 1 "extend_reg_operand" "r")))]
4271 "addz.l %1, r63, %0"
4272 [(set_attr "type" "arith_media")
4273 (set_attr "highpart" "extend")])
4275 (define_insn "zero_extendhidi2"
4276 [(set (match_operand:DI 0 "register_operand" "=r,r")
4277 (zero_extend:DI (match_operand:HI 1 "general_extend_operand" "r,m")))]
4282 [(set_attr "type" "*,load_media")
4283 (set (attr "highpart")
4284 (cond [(ne (symbol_ref "sh_contains_memref_p (insn)") (const_int 0))
4285 (const_string "user")]
4286 (const_string "ignore")))])
4289 [(set (match_operand:DI 0 "register_operand" "")
4290 (zero_extend:DI (match_operand:HI 1 "extend_reg_operand" "")))]
4291 "TARGET_SHMEDIA && reload_completed"
4292 [(set (match_dup 0) (ashift:DI (subreg:DI (match_dup 1) 0) (const_int 48)))
4293 (set (match_dup 0) (lshiftrt:DI (match_dup 0) (const_int 48)))]
4296 if (GET_CODE (operands[1]) == TRUNCATE)
4297 operands[1] = XEXP (operands[1], 0);
4300 ;; ??? when a truncated input to a zero_extend is reloaded, reload will
4301 ;; reload the entire truncate expression.
4302 (define_insn_and_split "*loaddi_trunc"
4303 [(set (match_operand 0 "any_register_operand" "=r")
4304 (truncate (match_operand:DI 1 "memory_operand" "m")))]
4305 "TARGET_SHMEDIA && reload_completed"
4307 "TARGET_SHMEDIA && reload_completed"
4308 [(set (match_dup 0) (match_dup 1))]
4309 "operands[0] = gen_rtx_REG (DImode, true_regnum (operands[0]));")
4311 (define_insn "zero_extendqidi2"
4312 [(set (match_operand:DI 0 "register_operand" "=r,r")
4313 (zero_extend:DI (match_operand:QI 1 "general_extend_operand" "r,m")))]
4318 [(set_attr "type" "arith_media,load_media")
4319 (set (attr "highpart")
4320 (cond [(ne (symbol_ref "sh_contains_memref_p (insn)") (const_int 0))
4321 (const_string "user")]
4322 (const_string "ignore")))])
4324 (define_expand "zero_extendhisi2"
4325 [(set (match_operand:SI 0 "arith_reg_operand" "")
4326 (zero_extend:SI (match_operand:HI 1 "general_extend_operand" "")))]
4330 if (! TARGET_SHMEDIA && ! arith_reg_operand (operands[1], HImode))
4331 operands[1] = copy_to_mode_reg (HImode, operands[1]);
4334 (define_insn "*zero_extendhisi2_compact"
4335 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
4336 (zero_extend:SI (match_operand:HI 1 "arith_reg_operand" "r")))]
4339 [(set_attr "type" "arith")])
4341 (define_insn "*zero_extendhisi2_media"
4342 [(set (match_operand:SI 0 "register_operand" "=r,r")
4343 (zero_extend:SI (match_operand:HI 1 "general_extend_operand" "r,m")))]
4348 [(set_attr "type" "arith_media,load_media")
4349 (set (attr "highpart")
4350 (cond [(ne (symbol_ref "sh_contains_memref_p (insn)") (const_int 0))
4351 (const_string "user")]
4352 (const_string "ignore")))])
4355 [(set (match_operand:SI 0 "register_operand" "")
4356 (zero_extend:SI (match_operand:HI 1 "extend_reg_operand" "")))]
4357 "TARGET_SHMEDIA && reload_completed"
4358 [(set (match_dup 0) (ashift:SI (match_dup 2) (const_int 16)))
4359 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 16)))]
4362 rtx op1 = operands[1];
4364 if (GET_CODE (op1) == TRUNCATE)
4365 op1 = XEXP (op1, 0);
4367 = simplify_gen_subreg (SImode, op1, GET_MODE (op1),
4368 subreg_lowpart_offset (SImode, GET_MODE (op1)));
4371 (define_expand "zero_extendqisi2"
4372 [(set (match_operand:SI 0 "arith_reg_operand" "")
4373 (zero_extend:SI (match_operand:QI 1 "general_extend_operand" "")))]
4377 if (! TARGET_SHMEDIA && ! arith_reg_operand (operands[1], QImode))
4378 operands[1] = copy_to_mode_reg (QImode, operands[1]);
4381 (define_insn "*zero_extendqisi2_compact"
4382 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
4383 (zero_extend:SI (match_operand:QI 1 "arith_reg_operand" "r")))]
4386 [(set_attr "type" "arith")])
4388 (define_insn "*zero_extendqisi2_media"
4389 [(set (match_operand:SI 0 "register_operand" "=r,r")
4390 (zero_extend:SI (match_operand:QI 1 "general_extend_operand" "r,m")))]
4395 [(set_attr "type" "arith_media,load_media")
4396 (set (attr "highpart")
4397 (cond [(ne (symbol_ref "sh_contains_memref_p (insn)") (const_int 0))
4398 (const_string "user")]
4399 (const_string "ignore")))])
4401 (define_insn "zero_extendqihi2"
4402 [(set (match_operand:HI 0 "arith_reg_dest" "=r")
4403 (zero_extend:HI (match_operand:QI 1 "arith_reg_operand" "r")))]
4406 [(set_attr "type" "arith")])
4408 ;; -------------------------------------------------------------------------
4409 ;; Sign extension instructions
4410 ;; -------------------------------------------------------------------------
4412 ;; ??? This should be a define expand.
4413 ;; ??? Or perhaps it should be dropped?
4415 ;; convert_move generates good code for SH[1-4].
4416 (define_insn "extendsidi2"
4417 [(set (match_operand:DI 0 "register_operand" "=r,r,r")
4418 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "r,m,?f")))]
4424 [(set_attr "type" "arith_media,load_media,fpconv_media")
4425 (set (attr "highpart")
4426 (cond [(ne (symbol_ref "sh_contains_memref_p (insn)") (const_int 0))
4427 (const_string "user")]
4428 (const_string "extend")))])
4430 (define_insn "extendhidi2"
4431 [(set (match_operand:DI 0 "register_operand" "=r,r")
4432 (sign_extend:DI (match_operand:HI 1 "general_extend_operand" "r,m")))]
4437 [(set_attr "type" "*,load_media")
4438 (set (attr "highpart")
4439 (cond [(ne (symbol_ref "sh_contains_memref_p (insn)") (const_int 0))
4440 (const_string "user")]
4441 (const_string "ignore")))])
4444 [(set (match_operand:DI 0 "register_operand" "")
4445 (sign_extend:DI (match_operand:HI 1 "extend_reg_operand" "")))]
4446 "TARGET_SHMEDIA && reload_completed"
4447 [(set (match_dup 0) (ashift:DI (subreg:DI (match_dup 1) 0) (const_int 48)))
4448 (set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 48)))]
4451 if (GET_CODE (operands[1]) == TRUNCATE)
4452 operands[1] = XEXP (operands[1], 0);
4455 (define_insn "extendqidi2"
4456 [(set (match_operand:DI 0 "register_operand" "=r,r")
4457 (sign_extend:DI (match_operand:QI 1 "general_extend_operand" "r,m")))]
4462 [(set_attr "type" "*,load_media")
4463 (set (attr "highpart")
4464 (cond [(ne (symbol_ref "sh_contains_memref_p (insn)") (const_int 0))
4465 (const_string "user")]
4466 (const_string "ignore")))])
4469 [(set (match_operand:DI 0 "register_operand" "")
4470 (sign_extend:DI (match_operand:QI 1 "extend_reg_operand" "")))]
4471 "TARGET_SHMEDIA && reload_completed"
4472 [(set (match_dup 0) (ashift:DI (subreg:DI (match_dup 1) 0) (const_int 56)))
4473 (set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 56)))]
4476 if (GET_CODE (operands[1]) == TRUNCATE)
4477 operands[1] = XEXP (operands[1], 0);
4480 (define_expand "extendhisi2"
4481 [(set (match_operand:SI 0 "arith_reg_dest" "=r,r")
4482 (sign_extend:SI (match_operand:HI 1 "general_extend_operand" "r,m")))]
4486 (define_insn "*extendhisi2_compact"
4487 [(set (match_operand:SI 0 "arith_reg_dest" "=r,r")
4488 (sign_extend:SI (match_operand:HI 1 "general_movsrc_operand" "r,m")))]
4493 [(set_attr "type" "arith,load")])
4495 (define_insn "*extendhisi2_media"
4496 [(set (match_operand:SI 0 "register_operand" "=r,r")
4497 (sign_extend:SI (match_operand:HI 1 "general_extend_operand" "r,m")))]
4502 [(set_attr "type" "arith_media,load_media")
4503 (set (attr "highpart")
4504 (cond [(ne (symbol_ref "sh_contains_memref_p (insn)") (const_int 0))
4505 (const_string "user")]
4506 (const_string "ignore")))])
4509 [(set (match_operand:SI 0 "register_operand" "")
4510 (sign_extend:SI (match_operand:HI 1 "extend_reg_operand" "")))]
4511 "TARGET_SHMEDIA && reload_completed"
4512 [(set (match_dup 0) (ashift:SI (match_dup 2) (const_int 16)))
4513 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 16)))]
4516 rtx op1 = operands[1];
4517 if (GET_CODE (op1) == TRUNCATE)
4518 op1 = XEXP (op1, 0);
4520 = simplify_gen_subreg (SImode, op1, GET_MODE (op1),
4521 subreg_lowpart_offset (SImode, GET_MODE (op1)));
4524 (define_expand "extendqisi2"
4525 [(set (match_operand:SI 0 "arith_reg_dest" "=r,r")
4526 (sign_extend:SI (match_operand:QI 1 "general_extend_operand" "r,m")))]
4530 (define_insn "*extendqisi2_compact"
4531 [(set (match_operand:SI 0 "arith_reg_dest" "=r,r")
4532 (sign_extend:SI (match_operand:QI 1 "general_movsrc_operand" "r,m")))]
4537 [(set_attr "type" "arith,load")])
4539 (define_insn "*extendqisi2_media"
4540 [(set (match_operand:SI 0 "register_operand" "=r,r")
4541 (sign_extend:SI (match_operand:QI 1 "general_extend_operand" "r,m")))]
4546 [(set_attr "type" "arith_media,load_media")
4547 (set (attr "highpart")
4548 (cond [(ne (symbol_ref "sh_contains_memref_p (insn)") (const_int 0))
4549 (const_string "user")]
4550 (const_string "ignore")))])
4553 [(set (match_operand:SI 0 "register_operand" "")
4554 (sign_extend:SI (match_operand:QI 1 "extend_reg_operand" "")))]
4555 "TARGET_SHMEDIA && reload_completed"
4556 [(set (match_dup 0) (ashift:SI (match_dup 2) (const_int 24)))
4557 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 24)))]
4560 rtx op1 = operands[1];
4561 if (GET_CODE (op1) == TRUNCATE)
4562 op1 = XEXP (op1, 0);
4564 = simplify_gen_subreg (SImode, op1, GET_MODE (op1),
4565 subreg_lowpart_offset (SImode, GET_MODE (op1)));
4568 (define_insn "extendqihi2"
4569 [(set (match_operand:HI 0 "arith_reg_dest" "=r,r")
4570 (sign_extend:HI (match_operand:QI 1 "general_movsrc_operand" "r,m")))]
4575 [(set_attr "type" "arith,load")])
4577 /* It would seem useful to combine the truncXi patterns into the movXi
4578 patterns, but unary operators are ignored when matching constraints,
4579 so we need separate patterns. */
4580 (define_insn "truncdisi2"
4581 [(set (match_operand:SI 0 "general_movdst_operand" "=r,m,m,f,r,f")
4582 (truncate:SI (match_operand:DI 1 "register_operand" "r,r,f,r,f,f")))]
4591 [(set_attr "type" "arith_media,store_media,fstore_media,fload_media,fpconv_media,fmove_media")
4592 (set (attr "highpart")
4593 (cond [(ne (symbol_ref "sh_contains_memref_p (insn)") (const_int 0))
4594 (const_string "user")]
4595 (const_string "extend")))])
4597 (define_insn "truncdihi2"
4598 [(set (match_operand:HI 0 "general_movdst_operand" "=?r,m")
4599 (truncate:HI (match_operand:DI 1 "register_operand" "r,r")))]
4602 shlli\\t%1,48,%0\;shlri\\t%0,48,%0
4604 [(set_attr "type" "arith_media,store_media")
4605 (set_attr "length" "8,4")
4606 (set (attr "highpart")
4607 (cond [(ne (symbol_ref "sh_contains_memref_p (insn)") (const_int 0))
4608 (const_string "user")]
4609 (const_string "extend")))])
4611 ; N.B. This should agree with LOAD_EXTEND_OP and movqi.
4612 ; Because we use zero extension, we can't provide signed QImode compares
4613 ; using a simple compare or conditional banch insn.
4614 (define_insn "truncdiqi2"
4615 [(set (match_operand:QI 0 "general_movdst_operand" "=r,m")
4616 (truncate:QI (match_operand:DI 1 "register_operand" "r,r")))]
4621 [(set_attr "type" "arith_media,store")
4622 (set (attr "highpart")
4623 (cond [(ne (symbol_ref "sh_contains_memref_p (insn)") (const_int 0))
4624 (const_string "user")]
4625 (const_string "extend")))])
4626 ;; -------------------------------------------------------------------------
4627 ;; Move instructions
4628 ;; -------------------------------------------------------------------------
4630 ;; define push and pop so it is easy for sh.c
4631 ;; We can't use push and pop on SHcompact because the stack must always
4632 ;; be 8-byte aligned.
4634 (define_expand "push"
4635 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4636 (match_operand:SI 0 "register_operand" "r,l,x"))]
4637 "TARGET_SH1 && ! TARGET_SH5"
4640 (define_expand "pop"
4641 [(set (match_operand:SI 0 "register_operand" "=r,l,x")
4642 (mem:SI (post_inc:SI (reg:SI SP_REG))))]
4643 "TARGET_SH1 && ! TARGET_SH5"
4646 (define_expand "push_e"
4647 [(parallel [(set (mem:SF (pre_dec:SI (reg:SI SP_REG)))
4648 (match_operand:SF 0 "" ""))
4649 (use (reg:PSI FPSCR_REG))
4650 (clobber (scratch:SI))])]
4651 "TARGET_SH1 && ! TARGET_SH5"
4654 (define_insn "push_fpul"
4655 [(set (mem:SF (pre_dec:SI (reg:SI SP_REG))) (reg:SF FPUL_REG))]
4656 "TARGET_SH2E && ! TARGET_SH5"
4658 [(set_attr "type" "store")
4659 (set_attr "late_fp_use" "yes")
4660 (set_attr "hit_stack" "yes")])
4662 ;; DFmode pushes for sh4 require a lot of what is defined for movdf_i4,
4664 (define_expand "push_4"
4665 [(parallel [(set (mem:DF (pre_dec:SI (reg:SI SP_REG)))
4666 (match_operand:DF 0 "" ""))
4667 (use (reg:PSI FPSCR_REG))
4668 (clobber (scratch:SI))])]
4669 "TARGET_SH1 && ! TARGET_SH5"
4672 (define_expand "pop_e"
4673 [(parallel [(set (match_operand:SF 0 "" "")
4674 (mem:SF (post_inc:SI (reg:SI SP_REG))))
4675 (use (reg:PSI FPSCR_REG))
4676 (clobber (scratch:SI))])]
4677 "TARGET_SH1 && ! TARGET_SH5"
4680 (define_insn "pop_fpul"
4681 [(set (reg:SF FPUL_REG) (mem:SF (post_inc:SI (reg:SI SP_REG))))]
4682 "TARGET_SH2E && ! TARGET_SH5"
4684 [(set_attr "type" "load")
4685 (set_attr "hit_stack" "yes")])
4687 (define_expand "pop_4"
4688 [(parallel [(set (match_operand:DF 0 "" "")
4689 (mem:DF (post_inc:SI (reg:SI SP_REG))))
4690 (use (reg:PSI FPSCR_REG))
4691 (clobber (scratch:SI))])]
4692 "TARGET_SH1 && ! TARGET_SH5"
4695 (define_expand "push_fpscr"
4700 rtx insn = emit_insn (gen_fpu_switch (gen_frame_mem (PSImode,
4701 gen_rtx_PRE_DEC (Pmode,
4702 stack_pointer_rtx)),
4704 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, stack_pointer_rtx, NULL_RTX);
4708 (define_expand "pop_fpscr"
4713 rtx insn = emit_insn (gen_fpu_switch (get_fpscr_rtx (),
4714 gen_frame_mem (PSImode,
4715 gen_rtx_POST_INC (Pmode,
4716 stack_pointer_rtx))));
4717 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, stack_pointer_rtx, NULL_RTX);
4721 ;; These two patterns can happen as the result of optimization, when
4722 ;; comparisons get simplified to a move of zero or 1 into the T reg.
4723 ;; They don't disappear completely, because the T reg is a fixed hard reg.
4726 [(set (reg:SI T_REG) (const_int 0))]
4731 [(set (reg:SI T_REG) (const_int 1))]
4735 ;; t/r must come after r/r, lest reload will try to reload stuff like
4736 ;; (set (subreg:SI (mem:QI (plus:SI (reg:SI SP_REG) (const_int 12)) 0) 0)
4737 ;; (made from (set (subreg:SI (reg:QI ###) 0) ) into T.
4738 (define_insn "movsi_i"
4739 [(set (match_operand:SI 0 "general_movdst_operand"
4740 "=r,r,t,r,r,r,r,m,<,<,x,l,x,l,r")
4741 (match_operand:SI 1 "general_movsrc_operand"
4742 "Q,rI08,r,mr,x,l,t,r,x,l,r,r,>,>,i"))]
4746 && (register_operand (operands[0], SImode)
4747 || register_operand (operands[1], SImode))"
4764 [(set_attr "type" "pcload_si,move,mt_group,load_si,mac_gp,prget,move,store,store,pstore,move,prset,load,pload,pcload_si")
4765 (set_attr "length" "*,*,*,*,*,*,*,*,*,*,*,*,*,*,*")])
4767 ;; t/r must come after r/r, lest reload will try to reload stuff like
4768 ;; (subreg:SI (reg:SF FR14_REG) 0) into T (compiling stdlib/strtod.c -m3e -O2)
4769 ;; ??? This allows moves from macl to fpul to be recognized, but these moves
4770 ;; will require a reload.
4771 ;; ??? We can't include f/f because we need the proper FPSCR setting when
4772 ;; TARGET_FMOVD is in effect, and mode switching is done before reload.
4773 (define_insn "movsi_ie"
4774 [(set (match_operand:SI 0 "general_movdst_operand"
4775 "=r,r,r,t,r,r,r,r,m,<,<,x,l,x,l,y,<,r,y,r,*f,y,*f,y")
4776 (match_operand:SI 1 "general_movsrc_operand"
4777 "Q,rI08,I20,r,mr,x,l,t,r,x,l,r,r,>,>,>,y,i,r,y,y,*f,*f,y"))]
4778 "(TARGET_SH2E || TARGET_SH2A)
4779 && (register_operand (operands[0], SImode)
4780 || register_operand (operands[1], SImode))"
4805 ! move optimized away"
4806 [(set_attr "type" "pcload_si,move,move,*,load_si,mac_gp,prget,move,store,store,pstore,move,prset,load,pload,load,store,pcload_si,gp_fpul,fpul_gp,fmove,fmove,fmove,nil")
4807 (set_attr "late_fp_use" "*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,yes,*,*,yes,*,*,*,*")
4808 (set_attr "length" "*,*,4,*,4,*,*,*,4,*,*,*,*,*,*,*,*,*,*,*,*,*,*,0")])
4810 (define_insn "movsi_i_lowpart"
4811 [(set (strict_low_part (match_operand:SI 0 "general_movdst_operand" "+r,r,r,r,r,r,m,r"))
4812 (match_operand:SI 1 "general_movsrc_operand" "Q,rI08,mr,x,l,t,r,i"))]
4814 && (register_operand (operands[0], SImode)
4815 || register_operand (operands[1], SImode))"
4825 [(set_attr "type" "pcload,move,load,move,prget,move,store,pcload")])
4827 (define_insn_and_split "load_ra"
4828 [(set (match_operand:SI 0 "general_movdst_operand" "")
4829 (unspec:SI [(match_operand:SI 1 "register_operand" "")] UNSPEC_RA))]
4832 "&& ! currently_expanding_to_rtl"
4833 [(set (match_dup 0) (match_dup 1))]
4836 if (TARGET_SHCOMPACT && current_function_has_nonlocal_label)
4837 operands[1] = gen_frame_mem (SImode, return_address_pointer_rtx);
4840 ;; The '?'s in the following constraints may not reflect the time taken
4841 ;; to perform the move. They are there to discourage the use of floating-
4842 ;; point registers for storing integer values.
4843 (define_insn "*movsi_media"
4844 [(set (match_operand:SI 0 "general_movdst_operand"
4845 "=r,r,r,r,m,f?,m,f?,r,f?,*b,r,b")
4846 (match_operand:SI 1 "general_movsrc_operand"
4847 "r,I16C16,nCpg,m,rZ,m,f?,rZ,f?,f?,r,*b,Csy"))]
4849 && (register_operand (operands[0], SImode)
4850 || sh_register_operand (operands[1], SImode)
4851 || GET_CODE (operands[1]) == TRUNCATE)"
4866 [(set_attr "type" "arith_media,arith_media,*,load_media,store_media,fload_media,fstore_media,fload_media,fpconv_media,fmove_media,ptabs_media,gettr_media,pt_media")
4867 (set_attr "length" "4,4,8,4,4,4,4,4,4,4,4,4,12")
4868 (set (attr "highpart")
4869 (cond [(ne (symbol_ref "sh_contains_memref_p (insn)") (const_int 0))
4870 (const_string "user")]
4871 (const_string "ignore")))])
4873 (define_insn "*movsi_media_nofpu"
4874 [(set (match_operand:SI 0 "general_movdst_operand"
4875 "=r,r,r,r,m,*b,r,*b")
4876 (match_operand:SI 1 "general_movsrc_operand"
4877 "r,I16C16,nCpg,m,rZ,r,*b,Csy"))]
4879 && (register_operand (operands[0], SImode)
4880 || sh_register_operand (operands[1], SImode)
4881 || GET_CODE (operands[1]) == TRUNCATE)"
4891 [(set_attr "type" "arith_media,arith_media,*,load_media,store_media,ptabs_media,gettr_media,pt_media")
4892 (set_attr "length" "4,4,8,4,4,4,4,12")
4893 (set (attr "highpart")
4894 (cond [(ne (symbol_ref "sh_contains_memref_p (insn)") (const_int 0))
4895 (const_string "user")]
4896 (const_string "ignore")))])
4898 (define_expand "movsi_const"
4899 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
4900 (const:SI (sign_extend:SI
4903 (match_operand:DI 1 "immediate_operand" "s")
4906 (ior:SI (ashift:SI (match_dup 0) (const_int 16))
4911 (truncate:HI (match_dup 1))))))))]
4912 "TARGET_SHMEDIA && reload_completed
4913 && MOVI_SHORI_BASE_OPERAND_P (operands[1])"
4916 if (GET_CODE (operands[1]) == LABEL_REF
4917 && GET_CODE (XEXP (operands[1], 0)) == CODE_LABEL)
4918 LABEL_NUSES (XEXP (operands[1], 0)) += 2;
4919 else if (GOTOFF_P (operands[1]))
4921 rtx unspec = XEXP (operands[1], 0);
4923 if (! UNSPEC_GOTOFF_P (unspec))
4925 unspec = XEXP (unspec, 0);
4926 if (! UNSPEC_GOTOFF_P (unspec))
4929 if (GET_CODE (XVECEXP (unspec , 0, 0)) == LABEL_REF
4930 && (GET_CODE (XEXP (XVECEXP (unspec, 0, 0), 0)) == CODE_LABEL))
4931 LABEL_NUSES (XEXP (XVECEXP (unspec, 0, 0), 0)) += 2;
4935 (define_expand "movsi_const_16bit"
4936 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
4937 (const:SI (sign_extend:SI
4939 (match_operand:DI 1 "immediate_operand" "s")))))]
4940 "TARGET_SHMEDIA && flag_pic && reload_completed
4941 && GET_CODE (operands[1]) == SYMBOL_REF"
4945 [(set (match_operand:SI 0 "arith_reg_dest" "")
4946 (match_operand:SI 1 "immediate_operand" ""))]
4947 "TARGET_SHMEDIA && reload_completed
4948 && MOVI_SHORI_BASE_OPERAND_P (operands[1])"
4952 rtx insn = emit_insn (gen_movsi_const (operands[0], operands[1]));
4954 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_EQUAL, operands[1],
4961 [(set (match_operand:SI 0 "register_operand" "")
4962 (match_operand:SI 1 "immediate_operand" ""))]
4963 "TARGET_SHMEDIA && reload_completed
4964 && ((GET_CODE (operands[1]) == CONST_INT
4965 && ! CONST_OK_FOR_I16 (INTVAL (operands[1])))
4966 || GET_CODE (operands[1]) == CONST_DOUBLE)"
4967 [(set (subreg:DI (match_dup 0) 0) (match_dup 1))])
4969 (define_expand "movsi"
4970 [(set (match_operand:SI 0 "general_movdst_operand" "")
4971 (match_operand:SI 1 "general_movsrc_operand" ""))]
4973 "{ if (prepare_move_operands (operands, SImode)) DONE; }")
4975 (define_expand "ic_invalidate_line"
4976 [(parallel [(unspec_volatile [(match_operand:SI 0 "register_operand" "+r")
4977 (match_dup 1)] UNSPEC_ICACHE)
4978 (clobber (scratch:SI))])]
4979 "TARGET_HARD_SH4 || TARGET_SH5"
4984 emit_insn (gen_ic_invalidate_line_media (operands[0]));
4987 else if (TARGET_SHCOMPACT)
4989 operands[1] = function_symbol (NULL, \"__ic_invalidate\", SFUNC_STATIC);
4990 operands[1] = force_reg (Pmode, operands[1]);
4991 emit_insn (gen_ic_invalidate_line_compact (operands[0], operands[1]));
4994 else if (TARGET_SH4A_ARCH)
4996 emit_insn (gen_ic_invalidate_line_sh4a (operands[0]));
4999 operands[0] = force_reg (Pmode, operands[0]);
5000 operands[1] = force_reg (Pmode, GEN_INT (trunc_int_for_mode (0xf0000008,
5004 ;; The address %0 is assumed to be 4-aligned at least. Thus, by ORing
5005 ;; 0xf0000008, we get the low-oder bits *1*00 (binary), which fits
5006 ;; the requirement *1*00 for associative address writes. The alignment of
5007 ;; %0 implies that its least significant bit is cleared,
5008 ;; thus we clear the V bit of a matching entry if there is one.
5009 (define_insn "ic_invalidate_line_i"
5010 [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")
5011 (match_operand:SI 1 "register_operand" "r")]
5013 (clobber (match_scratch:SI 2 "=&r"))]
5015 "ocbwb\\t@%0\;extu.w\\t%0,%2\;or\\t%1,%2\;mov.l\\t%0,@%2"
5016 [(set_attr "length" "8")
5017 (set_attr "type" "cwb")])
5019 (define_insn "ic_invalidate_line_sh4a"
5020 [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")]
5023 "ocbwb\\t@%0\;synco\;icbi\\t@%0"
5024 [(set_attr "length" "16")
5025 (set_attr "type" "cwb")])
5027 ;; ??? could make arg 0 an offsettable memory operand to allow to save
5028 ;; an add in the code that calculates the address.
5029 (define_insn "ic_invalidate_line_media"
5030 [(unspec_volatile [(match_operand 0 "any_register_operand" "r")]
5033 "ocbwb %0,0\;synco\;icbi %0, 0\;synci"
5034 [(set_attr "length" "16")
5035 (set_attr "type" "invalidate_line_media")])
5037 (define_insn "ic_invalidate_line_compact"
5038 [(unspec_volatile [(match_operand:SI 0 "register_operand" "z")
5039 (match_operand:SI 1 "register_operand" "r")]
5041 (clobber (reg:SI PR_REG))]
5044 [(set_attr "type" "sfunc")
5045 (set_attr "needs_delay_slot" "yes")])
5047 (define_expand "initialize_trampoline"
5048 [(match_operand:SI 0 "" "")
5049 (match_operand:SI 1 "" "")
5050 (match_operand:SI 2 "" "")]
5056 tramp = force_reg (Pmode, operands[0]);
5057 sfun = force_reg (Pmode, function_symbol (NULL, \"__init_trampoline\",
5059 emit_move_insn (gen_rtx_REG (SImode, R2_REG), operands[1]);
5060 emit_move_insn (gen_rtx_REG (SImode, R3_REG), operands[2]);
5062 emit_insn (gen_initialize_trampoline_compact (tramp, sfun));
5066 (define_insn "initialize_trampoline_compact"
5067 [(unspec_volatile [(match_operand:SI 0 "register_operand" "z")
5068 (match_operand:SI 1 "register_operand" "r")
5069 (reg:SI R2_REG) (reg:SI R3_REG)]
5072 (clobber (reg:SI PR_REG))]
5075 [(set_attr "type" "sfunc")
5076 (set_attr "needs_delay_slot" "yes")])
5078 (define_insn "movqi_i"
5079 [(set (match_operand:QI 0 "general_movdst_operand" "=r,r,m,r,r,l")
5080 (match_operand:QI 1 "general_movsrc_operand" "ri,m,r,t,l,r"))]
5082 && (arith_reg_operand (operands[0], QImode)
5083 || arith_reg_operand (operands[1], QImode))"
5091 [(set_attr "type" "move,load,store,move,move,move")])
5093 (define_insn "*movqi_media"
5094 [(set (match_operand:QI 0 "general_movdst_operand" "=r,r,r,m")
5095 (match_operand:QI 1 "general_movsrc_operand" "r,I16C16,m,rZ"))]
5097 && (arith_reg_operand (operands[0], QImode)
5098 || extend_reg_or_0_operand (operands[1], QImode))"
5104 [(set_attr "type" "arith_media,arith_media,load_media,store_media")
5105 (set (attr "highpart")
5106 (cond [(ne (symbol_ref "sh_contains_memref_p (insn)") (const_int 0))
5107 (const_string "user")]
5108 (const_string "ignore")))])
5110 (define_expand "movqi"
5111 [(set (match_operand:QI 0 "general_operand" "")
5112 (match_operand:QI 1 "general_operand" ""))]
5114 "{ if (prepare_move_operands (operands, QImode)) DONE; }")
5116 (define_expand "reload_inqi"
5117 [(set (match_operand:SI 2 "" "=&r")
5118 (match_operand:QI 1 "inqhi_operand" ""))
5119 (set (match_operand:QI 0 "arith_reg_operand" "=r")
5120 (truncate:QI (match_dup 3)))]
5124 rtx inner = XEXP (operands[1], 0);
5125 int regno = REGNO (inner);
5127 regno += HARD_REGNO_NREGS (regno, GET_MODE (inner)) - 1;
5128 operands[1] = gen_rtx_REG (SImode, regno);
5129 operands[3] = gen_rtx_REG (DImode, REGNO (operands[2]));
5132 /* When storing r0, we have to avoid reg+reg addressing. */
5133 (define_insn "movhi_i"
5134 [(set (match_operand:HI 0 "general_movdst_operand" "=r,r,r,r,m,r,l,r")
5135 (match_operand:HI 1 "general_movsrc_operand" "Q,rI08,m,t,r,l,r,i"))]
5137 && (arith_reg_operand (operands[0], HImode)
5138 || arith_reg_operand (operands[1], HImode))
5139 && (GET_CODE (operands[0]) != MEM
5140 || GET_CODE (XEXP (operands[0], 0)) != PLUS
5141 || GET_CODE (XEXP (XEXP (operands[0], 0), 1)) != REG
5142 || ! refers_to_regno_p (R0_REG, R0_REG + 1, operands[1], (rtx *)0))"
5152 [(set_attr "type" "pcload,move,load,move,store,move,move,pcload")])
5154 (define_insn "*movhi_media"
5155 [(set (match_operand:HI 0 "general_movdst_operand" "=r,r,r,r,m")
5156 (match_operand:HI 1 "general_movsrc_operand" "r,I16C16,n,m,rZ"))]
5158 && (arith_reg_operand (operands[0], HImode)
5159 || arith_reg_or_0_operand (operands[1], HImode))"
5166 [(set_attr "type" "arith_media,arith_media,*,load_media,store_media")
5167 (set (attr "highpart")
5168 (cond [(ne (symbol_ref "sh_contains_memref_p (insn)") (const_int 0))
5169 (const_string "user")]
5170 (const_string "ignore")))])
5173 [(set (match_operand:HI 0 "register_operand" "")
5174 (match_operand:HI 1 "immediate_operand" ""))]
5175 "TARGET_SHMEDIA && reload_completed
5176 && ! CONST_OK_FOR_I16 (INTVAL (operands[1]))"
5177 [(set (subreg:DI (match_dup 0) 0) (match_dup 1))])
5179 (define_expand "movhi"
5180 [(set (match_operand:HI 0 "general_movdst_operand" "")
5181 (match_operand:HI 1 "general_movsrc_operand" ""))]
5183 "{ if (prepare_move_operands (operands, HImode)) DONE; }")
5185 (define_expand "reload_inhi"
5186 [(set (match_operand:SI 2 "" "=&r")
5187 (match_operand:HI 1 "inqhi_operand" ""))
5188 (set (match_operand:HI 0 "arith_reg_operand" "=r")
5189 (truncate:HI (match_dup 3)))]
5193 rtx inner = XEXP (operands[1], 0);
5194 int regno = REGNO (inner);
5196 regno += HARD_REGNO_NREGS (regno, GET_MODE (inner)) - 1;
5197 operands[1] = gen_rtx_REG (SImode, regno);
5198 operands[3] = gen_rtx_REG (DImode, REGNO (operands[2]));
5201 ;; x/r can be created by inlining/cse, e.g. for execute/961213-1.c
5202 ;; compiled with -m2 -ml -O3 -funroll-loops
5203 (define_insn "*movdi_i"
5204 [(set (match_operand:DI 0 "general_movdst_operand" "=r,r,r,m,r,r,r,*!x")
5205 (match_operand:DI 1 "general_movsrc_operand" "Q,r,m,r,I08,i,x,r"))]
5207 && (arith_reg_operand (operands[0], DImode)
5208 || arith_reg_operand (operands[1], DImode))"
5209 "* return output_movedouble (insn, operands, DImode);"
5210 [(set_attr "length" "4")
5211 (set_attr "type" "pcload,move,load,store,move,pcload,move,move")])
5213 ;; If the output is a register and the input is memory or a register, we have
5214 ;; to be careful and see which word needs to be loaded first.
5217 [(set (match_operand:DI 0 "general_movdst_operand" "")
5218 (match_operand:DI 1 "general_movsrc_operand" ""))]
5219 "TARGET_SH1 && reload_completed"
5220 [(set (match_dup 2) (match_dup 3))
5221 (set (match_dup 4) (match_dup 5))]
5226 if ((GET_CODE (operands[0]) == MEM
5227 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
5228 || (GET_CODE (operands[1]) == MEM
5229 && GET_CODE (XEXP (operands[1], 0)) == POST_INC))
5232 switch (GET_CODE (operands[0]))
5235 regno = REGNO (operands[0]);
5238 regno = subreg_regno (operands[0]);
5248 || ! refers_to_regno_p (regno, regno + 1, operands[1], 0))
5250 operands[2] = operand_subword (operands[0], 0, 0, DImode);
5251 operands[3] = operand_subword (operands[1], 0, 0, DImode);
5252 operands[4] = operand_subword (operands[0], 1, 0, DImode);
5253 operands[5] = operand_subword (operands[1], 1, 0, DImode);
5257 operands[2] = operand_subword (operands[0], 1, 0, DImode);
5258 operands[3] = operand_subword (operands[1], 1, 0, DImode);
5259 operands[4] = operand_subword (operands[0], 0, 0, DImode);
5260 operands[5] = operand_subword (operands[1], 0, 0, DImode);
5263 if (operands[2] == 0 || operands[3] == 0
5264 || operands[4] == 0 || operands[5] == 0)
5268 ;; The '?'s in the following constraints may not reflect the time taken
5269 ;; to perform the move. They are there to discourage the use of floating-
5270 ;; point registers for storing integer values.
5271 (define_insn "*movdi_media"
5272 [(set (match_operand:DI 0 "general_movdst_operand"
5273 "=r,r,r,rl,m,f?,m,f?,r,f?,*b,r,*b")
5274 (match_operand:DI 1 "general_movsrc_operand"
5275 "r,I16C16,nCpgF,m,rlZ,m,f?,rZ,f?,f?,r,*b,Csy"))]
5277 && (register_operand (operands[0], DImode)
5278 || sh_register_operand (operands[1], DImode))"
5293 [(set_attr "type" "arith_media,arith_media,*,load_media,store_media,fload_media,fstore_media,fload_media,dfpconv_media,fmove_media,ptabs_media,gettr_media,pt_media")
5294 (set_attr "length" "4,4,16,4,4,4,4,4,4,4,4,4,*")])
5296 (define_insn "*movdi_media_nofpu"
5297 [(set (match_operand:DI 0 "general_movdst_operand" "=r,r,r,rl,m,*b,r,*b");
5298 (match_operand:DI 1 "general_movsrc_operand" "r,I16C16,nCpgF,m,rlZ,r,*b,Csy"))]
5300 && (register_operand (operands[0], DImode)
5301 || sh_register_operand (operands[1], DImode))"
5311 [(set_attr "type" "arith_media,arith_media,*,load_media,store_media,ptabs_media,gettr_media,pt_media")
5312 (set_attr "length" "4,4,16,4,4,4,4,*")])
5314 (define_insn "*movdi_media_I16"
5315 [(set (match_operand:DI 0 "ext_dest_operand" "=r")
5316 (match_operand:DI 1 "const_int_operand" "I16"))]
5317 "TARGET_SHMEDIA && reload_completed"
5319 [(set_attr "type" "arith_media")
5320 (set_attr "length" "4")])
5323 [(set (match_operand:DI 0 "arith_reg_dest" "")
5324 (match_operand:DI 1 "immediate_operand" ""))]
5325 "TARGET_SHMEDIA && reload_completed
5326 && MOVI_SHORI_BASE_OPERAND_P (operands[1])"
5327 [(set (match_dup 0) (match_dup 1))]
5332 if (TARGET_SHMEDIA64)
5333 insn = emit_insn (gen_movdi_const (operands[0], operands[1]));
5335 insn = emit_insn (gen_movdi_const_32bit (operands[0], operands[1]));
5337 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_EQUAL, operands[1],
5343 (define_expand "movdi_const"
5344 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
5345 (const:DI (sign_extend:DI
5348 (match_operand:DI 1 "immediate_operand" "s")
5351 (ior:DI (ashift:DI (match_dup 0) (const_int 16))
5359 (const_int 32)))))))))
5361 (ior:DI (ashift:DI (match_dup 0) (const_int 16))
5369 (const_int 16)))))))))
5371 (ior:DI (ashift:DI (match_dup 0) (const_int 16))
5377 (match_dup 1))))))))]
5378 "TARGET_SHMEDIA64 && reload_completed
5379 && MOVI_SHORI_BASE_OPERAND_P (operands[1])"
5382 sh_mark_label (operands[1], 4);
5385 (define_expand "movdi_const_32bit"
5386 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
5387 (const:DI (sign_extend:DI
5390 (match_operand:DI 1 "immediate_operand" "s")
5393 (ior:DI (ashift:DI (match_dup 0) (const_int 16))
5399 (match_dup 1))))))))]
5400 "TARGET_SHMEDIA32 && reload_completed
5401 && MOVI_SHORI_BASE_OPERAND_P (operands[1])"
5404 sh_mark_label (operands[1], 2);
5407 (define_expand "movdi_const_16bit"
5408 [(set (match_operand:DI 0 "arith_reg_operand" "=r")
5409 (const:DI (sign_extend:DI
5411 (match_operand:DI 1 "immediate_operand" "s")))))]
5412 "TARGET_SHMEDIA && flag_pic && reload_completed
5413 && GET_CODE (operands[1]) == SYMBOL_REF"
5417 [(set (match_operand:DI 0 "ext_dest_operand" "")
5418 (match_operand:DI 1 "immediate_operand" ""))]
5419 "TARGET_SHMEDIA && reload_completed
5420 && GET_CODE (operands[1]) == CONST_INT
5421 && ! CONST_OK_FOR_I16 (INTVAL (operands[1]))"
5422 [(set (match_dup 0) (match_dup 2))
5426 unsigned HOST_WIDE_INT val = INTVAL (operands[1]);
5427 unsigned HOST_WIDE_INT low = val;
5428 unsigned HOST_WIDE_INT high = val;
5429 unsigned HOST_WIDE_INT sign;
5430 unsigned HOST_WIDE_INT val2 = val ^ (val-1);
5432 /* Sign-extend the 16 least-significant bits. */
5437 /* Arithmetic shift right the word by 16 bits. */
5439 if (GET_CODE (operands[0]) == SUBREG
5440 && GET_MODE (SUBREG_REG (operands[0])) == SImode)
5449 sign <<= (HOST_BITS_PER_WIDE_INT - 16 - 1);
5455 /* If we can't generate the constant with a two-insn movi / shori
5456 sequence, try some other strategies. */
5457 if (! CONST_OK_FOR_I16 (high))
5459 /* Try constant load / left shift. We know VAL != 0. */
5460 val2 = val ^ (val-1);
5463 int trailing_zeroes = exact_log2 ((val2 >> 16) + 1) + 15;
5465 if (CONST_OK_FOR_I16 (val >> trailing_zeroes)
5466 || (! CONST_OK_FOR_I16 (high >> 16)
5467 && CONST_OK_FOR_I16 (val >> (trailing_zeroes + 16))))
5469 val2 = (HOST_WIDE_INT) val >> trailing_zeroes;
5470 operands[1] = gen_ashldi3_media (operands[0], operands[0],
5471 GEN_INT (trailing_zeroes));
5475 /* Try constant load / right shift. */
5476 val2 = (val >> 15) + 1;
5477 if (val2 == (val2 & -val2))
5479 int shift = 49 - exact_log2 (val2);
5481 val2 = trunc_int_for_mode (val << shift, DImode);
5482 if (CONST_OK_FOR_I16 (val2))
5484 operands[1] = gen_lshrdi3_media (operands[0], operands[0],
5490 val2 = val & 0xffff;
5491 if ((val >> 16 & 0xffff) == val2
5492 && (val >> 32 & 0xffff) == val2
5493 && (val >> 48 & 0xffff) == val2)
5495 val2 = (HOST_WIDE_INT) val >> 48;
5496 operands[1] = gen_rtx_REG (V4HImode, true_regnum (operands[0]));
5497 operands[1] = gen_mperm_w0 (operands[1], operands[1]);
5500 /* Try movi / mshflo.l */
5501 val2 = (HOST_WIDE_INT) val >> 32;
5502 if (val2 == ((unsigned HOST_WIDE_INT)
5503 trunc_int_for_mode (val, SImode)))
5505 operands[1] = gen_mshflo_l_di (operands[0], operands[0],
5509 /* Try movi / mshflo.l w/ r63. */
5510 val2 = val + ((HOST_WIDE_INT) -1 << 32);
5511 if ((HOST_WIDE_INT) val2 < 0 && CONST_OK_FOR_I16 (val2))
5513 operands[1] = gen_mshflo_l_di (operands[0], operands[0],
5519 operands[1] = gen_shori_media (operands[0], operands[0], GEN_INT (low));
5522 operands[2] = GEN_INT (val2);
5526 [(set (match_operand:DI 0 "ext_dest_operand" "")
5527 (match_operand:DI 1 "immediate_operand" ""))]
5528 "TARGET_SHMEDIA && reload_completed
5529 && GET_CODE (operands[1]) == CONST_DOUBLE"
5530 [(set (match_dup 0) (match_dup 2))
5532 (ior:DI (ashift:DI (match_dup 0) (const_int 16))
5533 (zero_extend:DI (truncate:HI (match_dup 1)))))]
5536 unsigned HOST_WIDE_INT low = CONST_DOUBLE_LOW (operands[1]);
5537 unsigned HOST_WIDE_INT high = CONST_DOUBLE_HIGH (operands[1]);
5538 unsigned HOST_WIDE_INT val = low;
5539 unsigned HOST_WIDE_INT sign;
5541 /* Sign-extend the 16 least-significant bits. */
5545 operands[1] = GEN_INT (val);
5547 /* Arithmetic shift right the double-word by 16 bits. */
5549 low |= (high & 0xffff) << (HOST_BITS_PER_WIDE_INT - 16);
5552 sign <<= (HOST_BITS_PER_WIDE_INT - 16 - 1);
5556 /* This will only be true if high is a sign-extension of low, i.e.,
5557 it must be either 0 or (unsigned)-1, and be zero iff the
5558 most-significant bit of low is set. */
5559 if (high + (low >> (HOST_BITS_PER_WIDE_INT - 1)) == 0)
5560 operands[2] = GEN_INT (low);
5562 operands[2] = immed_double_const (low, high, DImode);
5565 (define_insn "shori_media"
5566 [(set (match_operand:DI 0 "ext_dest_operand" "=r,r")
5567 (ior:DI (ashift:DI (match_operand:DI 1 "arith_reg_operand" "0,0")
5571 (match_operand:DI 2 "immediate_operand" "I16C16,nF")))))]
5572 "TARGET_SHMEDIA && (reload_completed || arith_reg_dest (operands[0], DImode))"
5576 [(set_attr "type" "arith_media,*")])
5578 (define_insn "*shori_media_si"
5579 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
5580 (ior:SI (ashift:SI (match_operand:SI 1 "arith_reg_operand" "0")
5584 (match_operand:SI 2 "immediate_operand" "I16C16")))))]
5588 (define_expand "movdi"
5589 [(set (match_operand:DI 0 "general_movdst_operand" "")
5590 (match_operand:DI 1 "general_movsrc_operand" ""))]
5592 "{ if (prepare_move_operands (operands, DImode)) DONE; }")
5594 (define_insn "movdf_media"
5595 [(set (match_operand:DF 0 "general_movdst_operand" "=f,f,r,r,r,f,m,r,m")
5596 (match_operand:DF 1 "general_movsrc_operand" "f,rZ,f,r,F,m,f,m,rZ"))]
5598 && (register_operand (operands[0], DFmode)
5599 || sh_register_operand (operands[1], DFmode))"
5610 [(set_attr "type" "fmove_media,fload_media,dfpconv_media,arith_media,*,fload_media,fstore_media,load_media,store_media")])
5612 (define_insn "movdf_media_nofpu"
5613 [(set (match_operand:DF 0 "general_movdst_operand" "=r,r,r,m")
5614 (match_operand:DF 1 "general_movsrc_operand" "r,F,m,rZ"))]
5616 && (register_operand (operands[0], DFmode)
5617 || sh_register_operand (operands[1], DFmode))"
5623 [(set_attr "type" "arith_media,*,load_media,store_media")])
5626 [(set (match_operand:DF 0 "arith_reg_dest" "")
5627 (match_operand:DF 1 "immediate_operand" ""))]
5628 "TARGET_SHMEDIA && reload_completed"
5629 [(set (match_dup 3) (match_dup 2))]
5632 int endian = WORDS_BIG_ENDIAN ? 1 : 0;
5634 REAL_VALUE_TYPE value;
5636 REAL_VALUE_FROM_CONST_DOUBLE (value, operands[1]);
5637 REAL_VALUE_TO_TARGET_DOUBLE (value, values);
5639 if (HOST_BITS_PER_WIDE_INT >= 64)
5640 operands[2] = immed_double_const ((unsigned long) values[endian]
5641 | ((HOST_WIDE_INT) values[1 - endian]
5645 gcc_assert (HOST_BITS_PER_WIDE_INT == 32);
5646 operands[2] = immed_double_const (values[endian], values[1 - endian],
5650 operands[3] = gen_rtx_REG (DImode, true_regnum (operands[0]));
5653 ;; ??? This should be a define expand.
5655 (define_insn "movdf_k"
5656 [(set (match_operand:DF 0 "general_movdst_operand" "=r,r,r,m")
5657 (match_operand:DF 1 "general_movsrc_operand" "r,FQ,m,r"))]
5659 && (! (TARGET_SH4 || TARGET_SH2A_DOUBLE) || reload_completed
5660 /* ??? We provide some insn so that direct_{load,store}[DFmode] get set */
5661 || (GET_CODE (operands[0]) == REG && REGNO (operands[0]) == 3)
5662 || (GET_CODE (operands[1]) == REG && REGNO (operands[1]) == 3))
5663 && (arith_reg_operand (operands[0], DFmode)
5664 || arith_reg_operand (operands[1], DFmode))"
5665 "* return output_movedouble (insn, operands, DFmode);"
5666 [(set_attr "length" "4")
5667 (set_attr "type" "move,pcload,load,store")])
5669 ;; All alternatives of movdf_i4 are split for ! TARGET_FMOVD.
5670 ;; However, the d/F/c/z alternative cannot be split directly; it is converted
5671 ;; with special code in machine_dependent_reorg into a load of the R0_REG and
5672 ;; the d/m/c/X alternative, which is split later into single-precision
5673 ;; instructions. And when not optimizing, no splits are done before fixing
5674 ;; up pcloads, so we need usable length information for that.
5675 (define_insn "movdf_i4"
5676 [(set (match_operand:DF 0 "general_movdst_operand" "=d,r,d,d,m,r,r,m,!??r,!???d")
5677 (match_operand:DF 1 "general_movsrc_operand" "d,r,F,m,d,FQ,m,r,d,r"))
5678 (use (match_operand:PSI 2 "fpscr_operand" "c,c,c,c,c,c,c,c,c,c"))
5679 (clobber (match_scratch:SI 3 "=X,X,&z,X,X,X,X,X,X,X"))]
5680 "(TARGET_SH4 || TARGET_SH2A_DOUBLE)
5681 && (arith_reg_operand (operands[0], DFmode)
5682 || arith_reg_operand (operands[1], DFmode))"
5694 [(set_attr_alternative "length"
5695 [(if_then_else (eq_attr "fmovd" "yes") (const_int 2) (const_int 4))
5697 (if_then_else (eq_attr "fmovd" "yes") (const_int 4) (const_int 6))
5698 (if_then_else (eq_attr "fmovd" "yes") (const_int 4) (const_int 6))
5699 (if_then_else (eq_attr "fmovd" "yes") (const_int 4) (const_int 6))
5701 (const_int 8) (const_int 8) ;; these need only 8 bytes for @(r0,rn)
5702 ;; We can't use 4-byte push/pop on SHcompact, so we have to
5703 ;; increment or decrement r15 explicitly.
5705 (ne (symbol_ref "TARGET_SHCOMPACT") (const_int 0))
5706 (const_int 10) (const_int 8))
5708 (ne (symbol_ref "TARGET_SHCOMPACT") (const_int 0))
5709 (const_int 10) (const_int 8))])
5710 (set_attr "type" "fmove,move,pcfload,fload,store,pcload,load,store,load,fload")
5711 (set_attr "late_fp_use" "*,*,*,*,yes,*,*,*,*,*")
5712 (set (attr "fp_mode") (if_then_else (eq_attr "fmovd" "yes")
5713 (const_string "double")
5714 (const_string "none")))])
5716 ;; Moving DFmode between fp/general registers through memory
5717 ;; (the top of the stack) is faster than moving through fpul even for
5718 ;; little endian. Because the type of an instruction is important for its
5719 ;; scheduling, it is beneficial to split these operations, rather than
5720 ;; emitting them in one single chunk, even if this will expose a stack
5721 ;; use that will prevent scheduling of other stack accesses beyond this
5724 [(set (match_operand:DF 0 "register_operand" "")
5725 (match_operand:DF 1 "register_operand" ""))
5726 (use (match_operand:PSI 2 "fpscr_operand" ""))
5727 (clobber (match_scratch:SI 3 "=X"))]
5728 "(TARGET_SH4 || TARGET_SH2A_DOUBLE) && reload_completed
5729 && (true_regnum (operands[0]) < 16) != (true_regnum (operands[1]) < 16)"
5735 if (TARGET_SH5 && true_regnum (operands[1]) < 16)
5737 emit_move_insn (stack_pointer_rtx,
5738 plus_constant (stack_pointer_rtx, -8));
5739 tos = gen_tmp_stack_mem (DFmode, stack_pointer_rtx);
5742 tos = gen_tmp_stack_mem (DFmode,
5743 gen_rtx_PRE_DEC (Pmode, stack_pointer_rtx));
5744 insn = emit_insn (gen_movdf_i4 (tos, operands[1], operands[2]));
5745 if (! (TARGET_SH5 && true_regnum (operands[1]) < 16))
5746 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, stack_pointer_rtx, NULL_RTX);
5747 if (TARGET_SH5 && true_regnum (operands[0]) < 16)
5748 tos = gen_tmp_stack_mem (DFmode, stack_pointer_rtx);
5750 tos = gen_tmp_stack_mem (DFmode,
5751 gen_rtx_POST_INC (Pmode, stack_pointer_rtx));
5752 insn = emit_insn (gen_movdf_i4 (operands[0], tos, operands[2]));
5753 if (TARGET_SH5 && true_regnum (operands[0]) < 16)
5754 emit_move_insn (stack_pointer_rtx, plus_constant (stack_pointer_rtx, 8));
5756 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, stack_pointer_rtx, NULL_RTX);
5760 ;; local-alloc sometimes allocates scratch registers even when not required,
5761 ;; so we must be prepared to handle these.
5763 ;; Remove the use and clobber from a movdf_i4 so that we can use movdf_k.
5765 [(set (match_operand:DF 0 "general_movdst_operand" "")
5766 (match_operand:DF 1 "general_movsrc_operand" ""))
5767 (use (match_operand:PSI 2 "fpscr_operand" ""))
5768 (clobber (match_scratch:SI 3 ""))]
5769 "(TARGET_SH4 || TARGET_SH2A_DOUBLE)
5771 && true_regnum (operands[0]) < 16
5772 && true_regnum (operands[1]) < 16"
5773 [(set (match_dup 0) (match_dup 1))]
5776 /* If this was a reg <-> mem operation with base + index reg addressing,
5777 we have to handle this in a special way. */
5778 rtx mem = operands[0];
5780 if (! memory_operand (mem, DFmode))
5785 if (GET_CODE (mem) == SUBREG && SUBREG_BYTE (mem) == 0)
5786 mem = SUBREG_REG (mem);
5787 if (GET_CODE (mem) == MEM)
5789 rtx addr = XEXP (mem, 0);
5790 if (GET_CODE (addr) == PLUS
5791 && GET_CODE (XEXP (addr, 0)) == REG
5792 && GET_CODE (XEXP (addr, 1)) == REG)
5795 rtx reg0 = gen_rtx_REG (Pmode, 0);
5796 rtx regop = operands[store_p], word0 ,word1;
5798 if (GET_CODE (regop) == SUBREG)
5799 alter_subreg (®op);
5800 if (REGNO (XEXP (addr, 0)) == REGNO (XEXP (addr, 1)))
5804 mem = copy_rtx (mem);
5805 PUT_MODE (mem, SImode);
5806 word0 = gen_rtx_SUBREG (SImode, regop, 0);
5807 alter_subreg (&word0);
5808 word1 = gen_rtx_SUBREG (SImode, regop, 4);
5809 alter_subreg (&word1);
5810 if (store_p || ! refers_to_regno_p (REGNO (word0),
5811 REGNO (word0) + 1, addr, 0))
5814 ? gen_movsi_ie (mem, word0)
5815 : gen_movsi_ie (word0, mem));
5816 emit_insn (gen_addsi3 (reg0, reg0, GEN_INT (offset)));
5817 mem = copy_rtx (mem);
5819 ? gen_movsi_ie (mem, word1)
5820 : gen_movsi_ie (word1, mem));
5821 emit_insn (gen_addsi3 (reg0, reg0, GEN_INT (-offset)));
5825 emit_insn (gen_addsi3 (reg0, reg0, GEN_INT (offset)));
5826 emit_insn (gen_movsi_ie (word1, mem));
5827 emit_insn (gen_addsi3 (reg0, reg0, GEN_INT (-offset)));
5828 mem = copy_rtx (mem);
5829 emit_insn (gen_movsi_ie (word0, mem));
5836 ;; Split away the clobber of r0 after machine_dependent_reorg has fixed pcloads.
5838 [(set (match_operand:DF 0 "register_operand" "")
5839 (match_operand:DF 1 "memory_operand" ""))
5840 (use (match_operand:PSI 2 "fpscr_operand" ""))
5841 (clobber (reg:SI R0_REG))]
5842 "(TARGET_SH4 || TARGET_SH2A_DOUBLE) && reload_completed"
5843 [(parallel [(set (match_dup 0) (match_dup 1))
5845 (clobber (scratch:SI))])]
5848 (define_expand "reload_indf__frn"
5849 [(parallel [(set (match_operand:DF 0 "register_operand" "=a")
5850 (match_operand:DF 1 "immediate_operand" "FQ"))
5851 (use (reg:PSI FPSCR_REG))
5852 (clobber (match_operand:SI 2 "register_operand" "=&z"))])]
5856 (define_expand "reload_outdf__RnFRm"
5857 [(parallel [(set (match_operand:DF 0 "register_operand" "=r,f")
5858 (match_operand:DF 1 "register_operand" "af,r"))
5859 (clobber (match_operand:SI 2 "register_operand" "=&y,y"))])]
5863 ;; Simplify no-op moves.
5865 [(set (match_operand:SF 0 "register_operand" "")
5866 (match_operand:SF 1 "register_operand" ""))
5867 (use (match_operand:PSI 2 "fpscr_operand" ""))
5868 (clobber (match_scratch:SI 3 ""))]
5869 "TARGET_SH2E && reload_completed
5870 && true_regnum (operands[0]) == true_regnum (operands[1])"
5871 [(set (match_dup 0) (match_dup 0))]
5874 ;; fmovd substitute post-reload splits
5876 [(set (match_operand:DF 0 "register_operand" "")
5877 (match_operand:DF 1 "register_operand" ""))
5878 (use (match_operand:PSI 2 "fpscr_operand" ""))
5879 (clobber (match_scratch:SI 3 ""))]
5880 "TARGET_SH4 && ! TARGET_FMOVD && reload_completed
5881 && FP_OR_XD_REGISTER_P (true_regnum (operands[0]))
5882 && FP_OR_XD_REGISTER_P (true_regnum (operands[1]))"
5886 int dst = true_regnum (operands[0]), src = true_regnum (operands[1]);
5887 emit_insn (gen_movsf_ie (gen_rtx_REG (SFmode, dst),
5888 gen_rtx_REG (SFmode, src), operands[2]));
5889 emit_insn (gen_movsf_ie (gen_rtx_REG (SFmode, dst + 1),
5890 gen_rtx_REG (SFmode, src + 1), operands[2]));
5895 [(set (match_operand:DF 0 "register_operand" "")
5896 (mem:DF (match_operand:SI 1 "register_operand" "")))
5897 (use (match_operand:PSI 2 "fpscr_operand" ""))
5898 (clobber (match_scratch:SI 3 ""))]
5899 "(TARGET_SH4 || TARGET_SH2A_DOUBLE) && ! TARGET_FMOVD && reload_completed
5900 && FP_OR_XD_REGISTER_P (true_regnum (operands[0]))
5901 && find_regno_note (insn, REG_DEAD, true_regnum (operands[1]))"
5905 int regno = true_regnum (operands[0]);
5907 rtx mem = SET_SRC (XVECEXP (PATTERN (curr_insn), 0, 0));
5909 = change_address (mem, SFmode, gen_rtx_POST_INC (Pmode, operands[1]));
5910 insn = emit_insn (gen_movsf_ie (gen_rtx_REG (SFmode,
5911 regno + !! TARGET_LITTLE_ENDIAN),
5912 mem2, operands[2]));
5913 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, operands[1], NULL_RTX);
5914 insn = emit_insn (gen_movsf_ie (gen_rtx_REG (SFmode,
5915 regno + ! TARGET_LITTLE_ENDIAN),
5916 change_address (mem, SFmode, NULL_RTX),
5922 [(set (match_operand:DF 0 "register_operand" "")
5923 (match_operand:DF 1 "memory_operand" ""))
5924 (use (match_operand:PSI 2 "fpscr_operand" ""))
5925 (clobber (match_scratch:SI 3 ""))]
5926 "(TARGET_SH4 || TARGET_SH2A_DOUBLE) && ! TARGET_FMOVD && reload_completed
5927 && FP_OR_XD_REGISTER_P (true_regnum (operands[0]))"
5931 int regno = true_regnum (operands[0]);
5932 rtx addr, insn, adjust = NULL_RTX;
5933 rtx mem2 = change_address (operands[1], SFmode, NULL_RTX);
5934 rtx reg0 = gen_rtx_REG (SFmode, regno + !! TARGET_LITTLE_ENDIAN);
5935 rtx reg1 = gen_rtx_REG (SFmode, regno + ! TARGET_LITTLE_ENDIAN);
5937 operands[1] = copy_rtx (mem2);
5938 addr = XEXP (mem2, 0);
5939 if (GET_CODE (addr) != POST_INC)
5941 /* If we have to modify the stack pointer, the value that we have
5942 read with post-increment might be modified by an interrupt,
5943 so write it back. */
5944 if (REGNO (addr) == STACK_POINTER_REGNUM)
5945 adjust = gen_push_e (reg0);
5947 adjust = gen_addsi3 (addr, addr, GEN_INT (-4));
5948 XEXP (mem2, 0) = addr = gen_rtx_POST_INC (SImode, addr);
5950 addr = XEXP (addr, 0);
5951 insn = emit_insn (gen_movsf_ie (reg0, mem2, operands[2]));
5952 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, addr, NULL_RTX);
5953 insn = emit_insn (gen_movsf_ie (reg1, operands[1], operands[2]));
5957 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, addr, NULL_RTX);
5962 [(set (match_operand:DF 0 "memory_operand" "")
5963 (match_operand:DF 1 "register_operand" ""))
5964 (use (match_operand:PSI 2 "fpscr_operand" ""))
5965 (clobber (match_scratch:SI 3 ""))]
5966 "(TARGET_SH4 || TARGET_SH2A_DOUBLE) && ! TARGET_FMOVD && reload_completed
5967 && FP_OR_XD_REGISTER_P (true_regnum (operands[1]))"
5971 int regno = true_regnum (operands[1]);
5972 rtx insn, addr, adjust = NULL_RTX;
5974 operands[0] = copy_rtx (operands[0]);
5975 PUT_MODE (operands[0], SFmode);
5976 insn = emit_insn (gen_movsf_ie (operands[0],
5977 gen_rtx_REG (SFmode,
5978 regno + ! TARGET_LITTLE_ENDIAN),
5980 operands[0] = copy_rtx (operands[0]);
5981 addr = XEXP (operands[0], 0);
5982 if (GET_CODE (addr) != PRE_DEC)
5984 adjust = gen_addsi3 (addr, addr, GEN_INT (4));
5985 emit_insn_before (adjust, insn);
5986 XEXP (operands[0], 0) = addr = gen_rtx_PRE_DEC (SImode, addr);
5988 addr = XEXP (addr, 0);
5990 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, addr, NULL_RTX);
5991 insn = emit_insn (gen_movsf_ie (operands[0],
5992 gen_rtx_REG (SFmode,
5993 regno + !! TARGET_LITTLE_ENDIAN),
5995 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, addr, NULL_RTX);
5999 ;; If the output is a register and the input is memory or a register, we have
6000 ;; to be careful and see which word needs to be loaded first.
6003 [(set (match_operand:DF 0 "general_movdst_operand" "")
6004 (match_operand:DF 1 "general_movsrc_operand" ""))]
6005 "TARGET_SH1 && reload_completed"
6006 [(set (match_dup 2) (match_dup 3))
6007 (set (match_dup 4) (match_dup 5))]
6012 if ((GET_CODE (operands[0]) == MEM
6013 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
6014 || (GET_CODE (operands[1]) == MEM
6015 && GET_CODE (XEXP (operands[1], 0)) == POST_INC))
6018 switch (GET_CODE (operands[0]))
6021 regno = REGNO (operands[0]);
6024 regno = subreg_regno (operands[0]);
6034 || ! refers_to_regno_p (regno, regno + 1, operands[1], 0))
6036 operands[2] = operand_subword (operands[0], 0, 0, DFmode);
6037 operands[3] = operand_subword (operands[1], 0, 0, DFmode);
6038 operands[4] = operand_subword (operands[0], 1, 0, DFmode);
6039 operands[5] = operand_subword (operands[1], 1, 0, DFmode);
6043 operands[2] = operand_subword (operands[0], 1, 0, DFmode);
6044 operands[3] = operand_subword (operands[1], 1, 0, DFmode);
6045 operands[4] = operand_subword (operands[0], 0, 0, DFmode);
6046 operands[5] = operand_subword (operands[1], 0, 0, DFmode);
6049 if (operands[2] == 0 || operands[3] == 0
6050 || operands[4] == 0 || operands[5] == 0)
6054 ;; If a base address generated by LEGITIMIZE_ADDRESS for SImode is
6055 ;; used only once, let combine add in the index again.
6058 [(set (match_operand:SI 0 "register_operand" "")
6059 (match_operand:SI 1 "" ""))
6060 (clobber (match_operand 2 "register_operand" ""))]
6061 "TARGET_SH1 && ! reload_in_progress && ! reload_completed
6062 && ALLOW_INDEXED_ADDRESS"
6063 [(use (reg:SI R0_REG))]
6066 rtx addr, reg, const_int;
6068 if (GET_CODE (operands[1]) != MEM)
6070 addr = XEXP (operands[1], 0);
6071 if (GET_CODE (addr) != PLUS)
6073 reg = XEXP (addr, 0);
6074 const_int = XEXP (addr, 1);
6075 if (! (BASE_REGISTER_RTX_P (reg) && INDEX_REGISTER_RTX_P (operands[2])
6076 && GET_CODE (const_int) == CONST_INT))
6078 emit_move_insn (operands[2], const_int);
6079 emit_move_insn (operands[0],
6080 change_address (operands[1], VOIDmode,
6081 gen_rtx_PLUS (SImode, reg, operands[2])));
6086 [(set (match_operand:SI 1 "" "")
6087 (match_operand:SI 0 "register_operand" ""))
6088 (clobber (match_operand 2 "register_operand" ""))]
6089 "TARGET_SH1 && ! reload_in_progress && ! reload_completed
6090 && ALLOW_INDEXED_ADDRESS"
6091 [(use (reg:SI R0_REG))]
6094 rtx addr, reg, const_int;
6096 if (GET_CODE (operands[1]) != MEM)
6098 addr = XEXP (operands[1], 0);
6099 if (GET_CODE (addr) != PLUS)
6101 reg = XEXP (addr, 0);
6102 const_int = XEXP (addr, 1);
6103 if (! (BASE_REGISTER_RTX_P (reg) && INDEX_REGISTER_RTX_P (operands[2])
6104 && GET_CODE (const_int) == CONST_INT))
6106 emit_move_insn (operands[2], const_int);
6107 emit_move_insn (change_address (operands[1], VOIDmode,
6108 gen_rtx_PLUS (SImode, reg, operands[2])),
6113 (define_expand "movdf"
6114 [(set (match_operand:DF 0 "general_movdst_operand" "")
6115 (match_operand:DF 1 "general_movsrc_operand" ""))]
6119 if (prepare_move_operands (operands, DFmode)) DONE;
6122 if (TARGET_SHMEDIA_FPU)
6123 emit_insn (gen_movdf_media (operands[0], operands[1]));
6125 emit_insn (gen_movdf_media_nofpu (operands[0], operands[1]));
6128 if (TARGET_SH4 || TARGET_SH2A_DOUBLE)
6130 emit_df_insn (gen_movdf_i4 (operands[0], operands[1], get_fpscr_rtx ()));
6135 ;;This is incompatible with the way gcc uses subregs.
6136 ;;(define_insn "movv2sf_i"
6137 ;; [(set (match_operand:V2SF 0 "nonimmediate_operand" "=f,f,m")
6138 ;; (match_operand:V2SF 1 "nonimmediate_operand" "f,m,f"))]
6139 ;; "TARGET_SHMEDIA_FPU
6140 ;; && (fp_arith_reg_operand (operands[0], V2SFmode)
6141 ;; || fp_arith_reg_operand (operands[1], V2SFmode))"
6145 ;; fst%M0.p %m0, %1"
6146 ;; [(set_attr "type" "*,fload_media,fstore_media")])
6148 (define_insn_and_split "movv2sf_i"
6149 [(set (match_operand:V2SF 0 "general_movdst_operand" "=f,rf,r,m,mf")
6150 (match_operand:V2SF 1 "general_operand" "fm,rfm?,F?,f,rfZ?"))]
6151 "TARGET_SHMEDIA_FPU"
6153 "TARGET_SHMEDIA_FPU && reload_completed"
6154 [(set (match_dup 0) (match_dup 1))]
6157 operands[0] = simplify_gen_subreg (DFmode, operands[0], V2SFmode, 0);
6158 operands[1] = simplify_gen_subreg (DFmode, operands[1], V2SFmode, 0);
6161 (define_expand "movv2sf"
6162 [(set (match_operand:V2SF 0 "general_movdst_operand" "")
6163 (match_operand:V2SF 1 "nonimmediate_operand" ""))]
6164 "TARGET_SHMEDIA_FPU"
6167 if (prepare_move_operands (operands, V2SFmode))
6171 (define_expand "addv2sf3"
6172 [(match_operand:V2SF 0 "fp_arith_reg_operand" "")
6173 (match_operand:V2SF 1 "fp_arith_reg_operand" "")
6174 (match_operand:V2SF 2 "fp_arith_reg_operand" "")]
6175 "TARGET_SHMEDIA_FPU"
6178 sh_expand_binop_v2sf (PLUS, operands[0], operands[1], operands[2]);
6182 (define_expand "subv2sf3"
6183 [(match_operand:V2SF 0 "fp_arith_reg_operand" "")
6184 (match_operand:V2SF 1 "fp_arith_reg_operand" "")
6185 (match_operand:V2SF 2 "fp_arith_reg_operand" "")]
6186 "TARGET_SHMEDIA_FPU"
6189 sh_expand_binop_v2sf (MINUS, operands[0], operands[1], operands[2]);
6193 (define_expand "mulv2sf3"
6194 [(match_operand:V2SF 0 "fp_arith_reg_operand" "")
6195 (match_operand:V2SF 1 "fp_arith_reg_operand" "")
6196 (match_operand:V2SF 2 "fp_arith_reg_operand" "")]
6197 "TARGET_SHMEDIA_FPU"
6200 sh_expand_binop_v2sf (MULT, operands[0], operands[1], operands[2]);
6204 (define_expand "divv2sf3"
6205 [(match_operand:V2SF 0 "fp_arith_reg_operand" "")
6206 (match_operand:V2SF 1 "fp_arith_reg_operand" "")
6207 (match_operand:V2SF 2 "fp_arith_reg_operand" "")]
6208 "TARGET_SHMEDIA_FPU"
6211 sh_expand_binop_v2sf (DIV, operands[0], operands[1], operands[2]);
6215 (define_insn_and_split "*movv4sf_i"
6216 [(set (match_operand:V4SF 0 "general_movdst_operand" "=f,rf,r,m,mf")
6217 (match_operand:V4SF 1 "general_operand" "fm,rfm?,F?,f,rfZ?"))]
6218 "TARGET_SHMEDIA_FPU"
6220 "&& reload_completed"
6226 for (i = 0; i < 4/2; i++)
6230 if (GET_CODE (operands[0]) == MEM)
6231 x = adjust_address (operands[0], V2SFmode,
6232 i * GET_MODE_SIZE (V2SFmode));
6234 x = simplify_gen_subreg (V2SFmode, operands[0], V4SFmode, i * 8);
6236 if (GET_CODE (operands[1]) == MEM)
6237 y = adjust_address (operands[1], V2SFmode,
6238 i * GET_MODE_SIZE (V2SFmode));
6240 y = simplify_gen_subreg (V2SFmode, operands[1], V4SFmode, i * 8);
6242 emit_insn (gen_movv2sf_i (x, y));
6247 [(set_attr "length" "8")])
6249 (define_expand "movv4sf"
6250 [(set (match_operand:V4SF 0 "nonimmediate_operand" "")
6251 (match_operand:V4SF 1 "general_operand" ""))]
6252 "TARGET_SHMEDIA_FPU"
6255 if (prepare_move_operands (operands, V4SFmode))
6259 (define_insn_and_split "*movv16sf_i"
6260 [(set (match_operand:V16SF 0 "nonimmediate_operand" "=f,f,m")
6261 (match_operand:V16SF 1 "nonimmediate_operand" "f,m,f"))]
6262 "TARGET_SHMEDIA_FPU"
6264 "&& reload_completed"
6270 for (i = 0; i < 16/2; i++)
6274 if (GET_CODE (operands[0]) == MEM)
6275 x = adjust_address (operands[0], V2SFmode,
6276 i * GET_MODE_SIZE (V2SFmode));
6279 x = gen_rtx_SUBREG (V2SFmode, operands[0], i * 8);
6283 if (GET_CODE (operands[1]) == MEM)
6284 y = adjust_address (operands[1], V2SFmode,
6285 i * GET_MODE_SIZE (V2SFmode));
6288 y = gen_rtx_SUBREG (V2SFmode, operands[1], i * 8);
6292 emit_insn (gen_movv2sf_i (x, y));
6297 [(set_attr "length" "32")])
6299 (define_expand "movv16sf"
6300 [(set (match_operand:V16SF 0 "nonimmediate_operand" "=f,f,m")
6301 (match_operand:V16SF 1 "nonimmediate_operand" "f,m,f"))]
6302 "TARGET_SHMEDIA_FPU"
6305 if (prepare_move_operands (operands, V16SFmode))
6309 (define_insn "movsf_media"
6310 [(set (match_operand:SF 0 "general_movdst_operand" "=f,f,r,r,r,f,m,r,m")
6311 (match_operand:SF 1 "general_movsrc_operand" "f,rZ,f,r,F,m,f,m,rZ"))]
6313 && (register_operand (operands[0], SFmode)
6314 || sh_register_operand (operands[1], SFmode))"
6325 [(set_attr "type" "fmove_media,fload_media,fpconv_media,arith_media,*,fload_media,fstore_media,load_media,store_media")
6326 (set (attr "highpart")
6327 (cond [(ne (symbol_ref "sh_contains_memref_p (insn)") (const_int 0))
6328 (const_string "user")]
6329 (const_string "ignore")))])
6331 (define_insn "movsf_media_nofpu"
6332 [(set (match_operand:SF 0 "general_movdst_operand" "=r,r,r,m")
6333 (match_operand:SF 1 "general_movsrc_operand" "r,F,m,rZ"))]
6335 && (register_operand (operands[0], SFmode)
6336 || sh_register_operand (operands[1], SFmode))"
6342 [(set_attr "type" "arith_media,*,load_media,store_media")
6343 (set (attr "highpart")
6344 (cond [(ne (symbol_ref "sh_contains_memref_p (insn)") (const_int 0))
6345 (const_string "user")]
6346 (const_string "ignore")))])
6349 [(set (match_operand:SF 0 "arith_reg_dest" "")
6350 (match_operand:SF 1 "immediate_operand" ""))]
6351 "TARGET_SHMEDIA && reload_completed
6352 && ! FP_REGISTER_P (true_regnum (operands[0]))"
6353 [(set (match_dup 3) (match_dup 2))]
6357 REAL_VALUE_TYPE value;
6359 REAL_VALUE_FROM_CONST_DOUBLE (value, operands[1]);
6360 REAL_VALUE_TO_TARGET_SINGLE (value, values);
6361 operands[2] = GEN_INT (values);
6363 operands[3] = gen_rtx_REG (DImode, true_regnum (operands[0]));
6366 (define_insn "movsf_i"
6367 [(set (match_operand:SF 0 "general_movdst_operand" "=r,r,r,r,m,l,r")
6368 (match_operand:SF 1 "general_movsrc_operand" "r,G,FQ,mr,r,r,l"))]
6371 /* ??? We provide some insn so that direct_{load,store}[SFmode] get set */
6372 || (GET_CODE (operands[0]) == REG && REGNO (operands[0]) == 3)
6373 || (GET_CODE (operands[1]) == REG && REGNO (operands[1]) == 3))
6374 && (arith_reg_operand (operands[0], SFmode)
6375 || arith_reg_operand (operands[1], SFmode))"
6384 [(set_attr "type" "move,move,pcload,load,store,move,move")])
6386 ;; We may not split the ry/yr/XX alternatives to movsi_ie, since
6387 ;; update_flow_info would not know where to put REG_EQUAL notes
6388 ;; when the destination changes mode.
6389 (define_insn "movsf_ie"
6390 [(set (match_operand:SF 0 "general_movdst_operand"
6391 "=f,r,f,f,fy,f,m,r,r,m,f,y,y,rf,r,y,<,y,y")
6392 (match_operand:SF 1 "general_movsrc_operand"
6393 "f,r,G,H,FQ,mf,f,FQ,mr,r,y,f,>,fr,y,r,y,>,y"))
6394 (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"))
6395 (clobber (match_scratch:SI 3 "=X,X,Bsc,Bsc,&z,X,X,X,X,X,X,X,X,y,X,X,X,X,X"))]
6398 && (arith_reg_operand (operands[0], SFmode)
6399 || arith_reg_operand (operands[1], SFmode)
6400 || arith_reg_operand (operands[3], SImode)
6401 || (fpul_operand (operands[0], SFmode)
6402 && memory_operand (operands[1], SFmode)
6403 && GET_CODE (XEXP (operands[1], 0)) == POST_INC)
6404 || (fpul_operand (operands[1], SFmode)
6405 && memory_operand (operands[0], SFmode)
6406 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC))"
6426 ! move optimized away"
6427 [(set_attr "type" "fmove,move,fmove,fmove,pcfload,fload,store,pcload,load,store,fmove,fmove,load,*,fpul_gp,gp_fpul,store,load,nil")
6428 (set_attr "late_fp_use" "*,*,*,*,*,*,yes,*,*,*,*,*,*,*,yes,*,yes,*,*")
6429 (set_attr "length" "*,*,*,*,4,4,4,*,*,*,2,2,2,4,2,2,2,2,0")
6430 (set (attr "fp_mode") (if_then_else (eq_attr "fmovd" "yes")
6431 (const_string "single")
6432 (const_string "none")))])
6435 [(set (match_operand:SF 0 "register_operand" "")
6436 (match_operand:SF 1 "register_operand" ""))
6437 (use (match_operand:PSI 2 "fpscr_operand" ""))
6438 (clobber (reg:SI FPUL_REG))]
6440 [(parallel [(set (reg:SF FPUL_REG) (match_dup 1))
6442 (clobber (scratch:SI))])
6443 (parallel [(set (match_dup 0) (reg:SF FPUL_REG))
6445 (clobber (scratch:SI))])]
6448 (define_expand "movsf"
6449 [(set (match_operand:SF 0 "general_movdst_operand" "")
6450 (match_operand:SF 1 "general_movsrc_operand" ""))]
6454 if (prepare_move_operands (operands, SFmode))
6458 if (TARGET_SHMEDIA_FPU)
6459 emit_insn (gen_movsf_media (operands[0], operands[1]));
6461 emit_insn (gen_movsf_media_nofpu (operands[0], operands[1]));
6466 emit_sf_insn (gen_movsf_ie (operands[0], operands[1], get_fpscr_rtx ()));
6471 (define_insn "mov_nop"
6472 [(set (match_operand 0 "any_register_operand" "") (match_dup 0))]
6475 [(set_attr "length" "0")
6476 (set_attr "type" "nil")])
6478 (define_expand "reload_insf__frn"
6479 [(parallel [(set (match_operand:SF 0 "register_operand" "=a")
6480 (match_operand:SF 1 "immediate_operand" "FQ"))
6481 (use (reg:PSI FPSCR_REG))
6482 (clobber (match_operand:SI 2 "register_operand" "=&z"))])]
6486 (define_expand "reload_insi__i_fpul"
6487 [(parallel [(set (match_operand:SI 0 "fpul_operand" "=y")
6488 (match_operand:SI 1 "immediate_operand" "i"))
6489 (clobber (match_operand:SI 2 "register_operand" "=&z"))])]
6493 (define_expand "ptabs"
6494 [(set (match_operand 0 "" "=b") (match_operand 1 "" "r"))]
6498 if (!TARGET_PT_FIXED)
6500 rtx eq = operands[1];
6502 /* ??? For canonical RTL we really should remove any CONST from EQ
6503 before wrapping it in the AND, and finally wrap the EQ into a
6504 const if is constant. However, for reload we must expose the
6505 input register or symbolic constant, and we can't have
6506 different insn structures outside of the operands for different
6507 alternatives of the same pattern. */
6508 eq = gen_rtx_EQ (SImode, gen_rtx_AND (Pmode, eq, GEN_INT (3)),
6511 = (gen_rtx_IF_THEN_ELSE
6514 gen_rtx_MEM (PDImode, operands[1]),
6515 gen_rtx_fmt_e (TARGET_SHMEDIA32 ? SIGN_EXTEND : TRUNCATE,
6516 PDImode, operands[1])));
6520 ;; expanded by ptabs expander.
6521 (define_insn "*extendsipdi_media"
6522 [(set (match_operand:PDI 0 "target_reg_operand" "=b,b");
6523 (if_then_else:PDI (eq (and:SI (match_operand:SI 1 "target_operand"
6527 (mem:PDI (match_dup 1))
6528 (sign_extend:PDI (match_dup 1))))]
6529 "TARGET_SHMEDIA && !TARGET_PT_FIXED"
6533 [(set_attr "type" "ptabs_media,pt_media")
6534 (set_attr "length" "4,*")])
6536 (define_insn "*truncdipdi_media"
6537 [(set (match_operand:PDI 0 "target_reg_operand" "=b,b");
6538 (if_then_else:PDI (eq (and:DI (match_operand:DI 1 "target_operand"
6542 (mem:PDI (match_dup 1))
6543 (truncate:PDI (match_dup 1))))]
6544 "TARGET_SHMEDIA && !TARGET_PT_FIXED"
6548 [(set_attr "type" "ptabs_media,pt_media")
6549 (set_attr "length" "4,*")])
6551 (define_insn "*movsi_y"
6552 [(set (match_operand:SI 0 "register_operand" "=y,y")
6553 (match_operand:SI 1 "immediate_operand" "Qi,I08"))
6554 (clobber (match_scratch:SI 2 "=&z,r"))]
6556 && (reload_in_progress || reload_completed)"
6558 [(set_attr "length" "4")
6559 (set_attr "type" "pcload,move")])
6562 [(set (match_operand:SI 0 "register_operand" "")
6563 (match_operand:SI 1 "immediate_operand" ""))
6564 (clobber (match_operand:SI 2 "register_operand" ""))]
6566 [(set (match_dup 2) (match_dup 1))
6567 (set (match_dup 0) (match_dup 2))]
6571 [(set (match_operand:SI 0 "register_operand" "")
6572 (match_operand:SI 1 "memory_operand" ""))
6573 (clobber (reg:SI R0_REG))]
6575 [(set (match_dup 0) (match_dup 1))]
6578 ;; ------------------------------------------------------------------------
6579 ;; Define the real conditional branch instructions.
6580 ;; ------------------------------------------------------------------------
6582 (define_insn "branch_true"
6583 [(set (pc) (if_then_else (ne (reg:SI T_REG) (const_int 0))
6584 (label_ref (match_operand 0 "" ""))
6587 "* return output_branch (1, insn, operands);"
6588 [(set_attr "type" "cbranch")])
6590 (define_insn "branch_false"
6591 [(set (pc) (if_then_else (eq (reg:SI T_REG) (const_int 0))
6592 (label_ref (match_operand 0 "" ""))
6595 "* return output_branch (0, insn, operands);"
6596 [(set_attr "type" "cbranch")])
6598 ;; Patterns to prevent reorg from re-combining a condbranch with a branch
6599 ;; which destination is too far away.
6600 ;; The const_int_operand is distinct for each branch target; it avoids
6601 ;; unwanted matches with redundant_insn.
6602 (define_insn "block_branch_redirect"
6603 [(set (pc) (unspec [(match_operand 0 "const_int_operand" "")] UNSPEC_BBR))]
6606 [(set_attr "length" "0")])
6608 ;; This one has the additional purpose to record a possible scratch register
6609 ;; for the following branch.
6610 ;; ??? Unfortunately, just setting the scratch register is not good enough,
6611 ;; because the insn then might be deemed dead and deleted. And we can't
6612 ;; make the use in the jump insn explicit because that would disable
6613 ;; delay slot scheduling from the target.
6614 (define_insn "indirect_jump_scratch"
6615 [(set (match_operand:SI 0 "register_operand" "=r")
6616 (unspec:SI [(match_operand 1 "const_int_operand" "")] UNSPEC_BBR))
6617 (set (pc) (unspec [(const_int 0)] UNSPEC_BBR))]
6620 [(set_attr "length" "0")])
6622 ;; This one is used to preemt an insn from beyond the bra / braf / jmp
6623 ;; being pulled into the delay slot of a condbranch that has been made to
6624 ;; jump around the unconditional jump because it was out of range.
6625 (define_insn "stuff_delay_slot"
6627 (unspec [(match_operand:SI 0 "const_int_operand" "") (pc)] UNSPEC_BBR))
6628 (set (reg:SI T_REG) (match_operand:SI 1 "const_int_operand" ""))]
6631 [(set_attr "length" "0")
6632 (set_attr "cond_delay_slot" "yes")])
6634 ;; Conditional branch insns
6636 (define_expand "beq_media"
6638 (if_then_else (eq (match_operand:DI 1 "arith_reg_operand" "r,r")
6639 (match_operand:DI 2 "arith_operand" "r,I06"))
6640 (match_operand 0 "" "")
6643 "operands[0] = gen_rtx_LABEL_REF (Pmode, operands[0]);")
6645 (define_insn "*beq_media_i"
6647 (if_then_else (match_operator 3 "equality_comparison_operator"
6648 [(match_operand:DI 1 "arith_reg_operand" "r,r")
6649 (match_operand:DI 2 "arith_operand" "r,I06")])
6650 (match_operand 0 "target_operand" "b,b")
6655 b%o3i%' %1, %2, %0%>"
6656 [(set_attr "type" "cbranch_media")])
6658 (define_insn "*beq_media_i32"
6660 (if_then_else (match_operator 3 "equality_comparison_operator"
6661 [(match_operand:SI 1 "arith_reg_operand" "r,r")
6662 (match_operand:SI 2 "arith_operand" "r,I06")])
6663 (match_operand 0 "target_operand" "b,b")
6668 b%o3i%' %1, %2, %0%>"
6669 [(set_attr "type" "cbranch_media")])
6671 (define_expand "bne_media"
6673 (if_then_else (ne (match_operand:DI 1 "arith_reg_operand" "r,r")
6674 (match_operand:DI 2 "arith_operand" "r,I06"))
6675 (match_operand 0 "" "")
6678 "operands[0] = gen_rtx_LABEL_REF (Pmode, operands[0]);")
6680 (define_expand "bgt_media"
6682 (if_then_else (gt (match_operand:DI 1 "arith_reg_or_0_operand" "")
6683 (match_operand:DI 2 "arith_reg_or_0_operand" ""))
6684 (match_operand 0 "" "")
6687 "operands[0] = gen_rtx_LABEL_REF (Pmode, operands[0]);")
6689 (define_expand "bge_media"
6691 (if_then_else (ge (match_operand:DI 1 "arith_reg_or_0_operand" "")
6692 (match_operand:DI 2 "arith_reg_or_0_operand" ""))
6693 (match_operand 0 "" "")
6696 "operands[0] = gen_rtx_LABEL_REF (Pmode, operands[0]);")
6698 (define_expand "bgtu_media"
6700 (if_then_else (gtu (match_operand:DI 1 "arith_reg_or_0_operand" "")
6701 (match_operand:DI 2 "arith_reg_or_0_operand" ""))
6702 (match_operand 0 "" "")
6705 "operands[0] = gen_rtx_LABEL_REF (Pmode, operands[0]);")
6707 (define_expand "bgeu_media"
6709 (if_then_else (geu (match_operand:DI 1 "arith_reg_or_0_operand" "")
6710 (match_operand:DI 2 "arith_reg_or_0_operand" ""))
6711 (match_operand 0 "" "")
6714 "operands[0] = gen_rtx_LABEL_REF (Pmode, operands[0]);")
6716 (define_insn "*bgt_media_i"
6718 (if_then_else (match_operator 3 "greater_comparison_operator"
6719 [(match_operand:DI 1 "arith_reg_or_0_operand" "rN")
6720 (match_operand:DI 2 "arith_reg_or_0_operand" "rN")])
6721 (match_operand 0 "target_operand" "b")
6724 "b%o3%' %N1, %N2, %0%>"
6725 [(set_attr "type" "cbranch_media")])
6727 (define_insn "*bgt_media_i32"
6729 (if_then_else (match_operator 3 "greater_comparison_operator"
6730 [(match_operand:SI 1 "arith_reg_or_0_operand" "rN")
6731 (match_operand:SI 2 "arith_reg_or_0_operand" "rN")])
6732 (match_operand 0 "target_operand" "b")
6735 "b%o3%' %N1, %N2, %0%>"
6736 [(set_attr "type" "cbranch_media")])
6738 ;; These are only needed to make invert_jump() happy - otherwise, jump
6739 ;; optimization will be silently disabled.
6740 (define_insn "*blt_media_i"
6742 (if_then_else (match_operator 3 "less_comparison_operator"
6743 [(match_operand:DI 1 "arith_reg_or_0_operand" "rN")
6744 (match_operand:DI 2 "arith_reg_or_0_operand" "rN")])
6745 (match_operand 0 "target_operand" "b")
6748 "b%o3%' %N2, %N1, %0%>"
6749 [(set_attr "type" "cbranch_media")])
6751 (define_insn "*blt_media_i32"
6753 (if_then_else (match_operator 3 "less_comparison_operator"
6754 [(match_operand:SI 1 "arith_reg_or_0_operand" "rN")
6755 (match_operand:SI 2 "arith_reg_or_0_operand" "rN")])
6756 (match_operand 0 "target_operand" "b")
6759 "b%o3%' %N2, %N1, %0%>"
6760 [(set_attr "type" "cbranch_media")])
6762 (define_expand "beq"
6764 (if_then_else (ne (reg:SI T_REG) (const_int 0))
6765 (label_ref (match_operand 0 "" ""))
6772 enum machine_mode mode = GET_MODE (sh_compare_op0);
6774 if (mode != DImode && mode != SImode)
6776 rtx tmp = gen_reg_rtx (DImode);
6778 emit_insn (gen_seq (tmp));
6779 emit_jump_insn (gen_bne_media (operands[0], tmp, const0_rtx));
6783 sh_compare_op0 = force_reg (mode, sh_compare_op0);
6784 if (CONSTANT_P (sh_compare_op1)
6785 && (GET_CODE (sh_compare_op1) != CONST_INT
6786 || ! CONST_OK_FOR_I06 (INTVAL (sh_compare_op1))))
6787 sh_compare_op1 = force_reg (mode, sh_compare_op1);
6788 emit_jump_insn (gen_beq_media (operands[0],
6789 sh_compare_op0, sh_compare_op1));
6793 from_compare (operands, EQ);
6796 (define_expand "bne"
6798 (if_then_else (eq (reg:SI T_REG) (const_int 0))
6799 (label_ref (match_operand 0 "" ""))
6806 enum machine_mode mode = GET_MODE (sh_compare_op0);
6808 if (mode != DImode && mode != SImode)
6810 rtx tmp = gen_reg_rtx (DImode);
6812 emit_insn (gen_seq (tmp));
6813 emit_jump_insn (gen_beq_media (operands[0], tmp, const0_rtx));
6817 sh_compare_op0 = force_reg (mode, sh_compare_op0);
6818 if (CONSTANT_P (sh_compare_op1)
6819 && (GET_CODE (sh_compare_op1) != CONST_INT
6820 || ! CONST_OK_FOR_I06 (INTVAL (sh_compare_op1))))
6821 sh_compare_op1 = force_reg (mode, sh_compare_op1);
6822 emit_jump_insn (gen_bne_media (operands[0],
6823 sh_compare_op0, sh_compare_op1));
6827 from_compare (operands, EQ);
6830 (define_expand "bgt"
6832 (if_then_else (ne (reg:SI T_REG) (const_int 0))
6833 (label_ref (match_operand 0 "" ""))
6840 enum machine_mode mode = GET_MODE (sh_compare_op0);
6842 if (mode != DImode && mode != SImode)
6844 rtx tmp = gen_reg_rtx (DImode);
6846 emit_insn (gen_sgt (tmp));
6847 emit_jump_insn (gen_bne_media (operands[0], tmp, const0_rtx));
6851 if (sh_compare_op0 != const0_rtx)
6852 sh_compare_op0 = force_reg (mode, sh_compare_op0);
6853 if (sh_compare_op1 != const0_rtx)
6854 sh_compare_op1 = force_reg (mode, sh_compare_op1);
6855 emit_jump_insn (gen_bgt_media (operands[0],
6856 sh_compare_op0, sh_compare_op1));
6860 from_compare (operands, GT);
6863 (define_expand "blt"
6865 (if_then_else (eq (reg:SI T_REG) (const_int 0))
6866 (label_ref (match_operand 0 "" ""))
6873 enum machine_mode mode = GET_MODE (sh_compare_op0);
6875 if (mode != DImode && mode != SImode)
6877 rtx tmp = gen_reg_rtx (DImode);
6879 emit_insn (gen_slt (tmp));
6880 emit_jump_insn (gen_bne_media (operands[0], tmp, const0_rtx));
6884 if (sh_compare_op0 != const0_rtx)
6885 sh_compare_op0 = force_reg (mode, sh_compare_op0);
6886 if (sh_compare_op1 != const0_rtx)
6887 sh_compare_op1 = force_reg (mode, sh_compare_op1);
6888 emit_jump_insn (gen_bgt_media (operands[0],
6889 sh_compare_op1, sh_compare_op0));
6893 if (GET_MODE_CLASS (GET_MODE (sh_compare_op0)) == MODE_FLOAT)
6895 rtx tmp = sh_compare_op0;
6896 sh_compare_op0 = sh_compare_op1;
6897 sh_compare_op1 = tmp;
6898 emit_insn (gen_bgt (operands[0]));
6901 from_compare (operands, GE);
6904 (define_expand "ble"
6906 (if_then_else (eq (reg:SI T_REG) (const_int 0))
6907 (label_ref (match_operand 0 "" ""))
6914 enum machine_mode mode = GET_MODE (sh_compare_op0);
6916 if (mode != DImode && mode != SImode)
6918 rtx tmp = gen_reg_rtx (DImode);
6920 emit_insn (gen_sle (tmp));
6921 emit_jump_insn (gen_bne_media (operands[0], tmp, const0_rtx));
6925 if (sh_compare_op0 != const0_rtx)
6926 sh_compare_op0 = force_reg (mode, sh_compare_op0);
6927 if (sh_compare_op1 != const0_rtx)
6928 sh_compare_op1 = force_reg (mode, sh_compare_op1);
6929 emit_jump_insn (gen_bge_media (operands[0],
6930 sh_compare_op1, sh_compare_op0));
6936 && GET_MODE_CLASS (GET_MODE (sh_compare_op0)) == MODE_FLOAT)
6938 rtx tmp = sh_compare_op0;
6939 sh_compare_op0 = sh_compare_op1;
6940 sh_compare_op1 = tmp;
6941 emit_insn (gen_bge (operands[0]));
6944 from_compare (operands, GT);
6947 (define_expand "bge"
6949 (if_then_else (ne (reg:SI T_REG) (const_int 0))
6950 (label_ref (match_operand 0 "" ""))
6957 enum machine_mode mode = GET_MODE (sh_compare_op0);
6959 if (mode != DImode && mode != SImode)
6961 rtx tmp = gen_reg_rtx (DImode);
6963 emit_insn (gen_sge (tmp));
6964 emit_jump_insn (gen_bne_media (operands[0], tmp, const0_rtx));
6968 if (sh_compare_op0 != const0_rtx)
6969 sh_compare_op0 = force_reg (mode, sh_compare_op0);
6970 if (sh_compare_op1 != const0_rtx)
6971 sh_compare_op1 = force_reg (mode, sh_compare_op1);
6972 emit_jump_insn (gen_bge_media (operands[0],
6973 sh_compare_op0, sh_compare_op1));
6979 && GET_MODE_CLASS (GET_MODE (sh_compare_op0)) == MODE_FLOAT)
6981 rtx tmp = sh_compare_op0;
6982 sh_compare_op0 = sh_compare_op1;
6983 sh_compare_op1 = tmp;
6984 emit_insn (gen_ble (operands[0]));
6987 from_compare (operands, GE);
6990 (define_expand "bgtu"
6992 (if_then_else (ne (reg:SI T_REG) (const_int 0))
6993 (label_ref (match_operand 0 "" ""))
7000 enum machine_mode mode = GET_MODE (sh_compare_op0);
7002 if (sh_compare_op0 != const0_rtx)
7003 sh_compare_op0 = force_reg (mode, sh_compare_op0);
7004 if (sh_compare_op1 != const0_rtx)
7005 sh_compare_op1 = force_reg (mode, sh_compare_op1);
7006 emit_jump_insn (gen_bgtu_media (operands[0],
7007 sh_compare_op0, sh_compare_op1));
7011 from_compare (operands, GTU);
7014 (define_expand "bltu"
7016 (if_then_else (eq (reg:SI T_REG) (const_int 0))
7017 (label_ref (match_operand 0 "" ""))
7024 enum machine_mode mode = GET_MODE (sh_compare_op0);
7026 if (sh_compare_op0 != const0_rtx)
7027 sh_compare_op0 = force_reg (mode, sh_compare_op0);
7028 if (sh_compare_op1 != const0_rtx)
7029 sh_compare_op1 = force_reg (mode, sh_compare_op1);
7030 emit_jump_insn (gen_bgtu_media (operands[0],
7031 sh_compare_op1, sh_compare_op0));
7035 from_compare (operands, GEU);
7038 (define_expand "bgeu"
7040 (if_then_else (ne (reg:SI T_REG) (const_int 0))
7041 (label_ref (match_operand 0 "" ""))
7048 enum machine_mode mode = GET_MODE (sh_compare_op0);
7050 if (sh_compare_op0 != const0_rtx)
7051 sh_compare_op0 = force_reg (mode, sh_compare_op0);
7052 if (sh_compare_op1 != const0_rtx)
7053 sh_compare_op1 = force_reg (mode, sh_compare_op1);
7054 emit_jump_insn (gen_bgeu_media (operands[0],
7055 sh_compare_op0, sh_compare_op1));
7059 from_compare (operands, GEU);
7062 (define_expand "bleu"
7064 (if_then_else (eq (reg:SI T_REG) (const_int 0))
7065 (label_ref (match_operand 0 "" ""))
7072 enum machine_mode mode = GET_MODE (sh_compare_op0);
7074 if (sh_compare_op0 != const0_rtx)
7075 sh_compare_op0 = force_reg (mode, sh_compare_op0);
7076 if (sh_compare_op1 != const0_rtx)
7077 sh_compare_op1 = force_reg (mode, sh_compare_op1);
7078 emit_jump_insn (gen_bgeu_media (operands[0],
7079 sh_compare_op1, sh_compare_op0));
7083 from_compare (operands, GTU);
7086 (define_expand "bunordered"
7087 [(set (match_dup 1) (unordered:DI (match_dup 2) (match_dup 3)))
7089 (if_then_else (ne (match_dup 1) (const_int 0))
7090 (match_operand 0 "" "")
7095 operands[0] = gen_rtx_LABEL_REF (Pmode, operands[0]);
7096 operands[1] = gen_reg_rtx (DImode);
7097 operands[2] = force_reg (GET_MODE (sh_compare_op0), sh_compare_op0);
7098 operands[3] = force_reg (GET_MODE (sh_compare_op1), sh_compare_op1);
7101 ;; combiner splitter for test-and-branch on single bit in register. This
7102 ;; is endian dependent because the non-paradoxical subreg looks different
7107 (match_operator 3 "equality_comparison_operator"
7108 [(subreg:SI (zero_extract:DI (subreg:DI (match_operand:SI 1
7109 "extend_reg_operand" "")
7113 "const_int_operand" "")) 0)
7115 (match_operand 0 "target_operand" "")
7117 (clobber (match_operand:SI 4 "arith_reg_dest" ""))]
7118 "TARGET_SHMEDIA && TARGET_LITTLE_ENDIAN"
7119 [(set (match_dup 4) (ashift:SI (match_dup 1) (match_dup 5)))
7120 (set (pc) (if_then_else (match_dup 6) (match_dup 0) (pc)))]
7124 operands[5] = GEN_INT (31 - INTVAL (operands[2]));
7125 operands[6] = (GET_CODE (operands[3]) == EQ
7126 ? gen_rtx_GE (VOIDmode, operands[4], const0_rtx)
7127 : gen_rtx_GT (VOIDmode, const0_rtx, operands[4]));
7130 ;; ------------------------------------------------------------------------
7131 ;; Jump and linkage insns
7132 ;; ------------------------------------------------------------------------
7134 (define_insn "jump_compact"
7136 (label_ref (match_operand 0 "" "")))]
7140 /* The length is 16 if the delay slot is unfilled. */
7141 if (get_attr_length(insn) > 4)
7142 return output_far_jump(insn, operands[0]);
7144 return \"bra %l0%#\";
7146 [(set_attr "type" "jump")
7147 (set_attr "needs_delay_slot" "yes")])
7149 ;; ??? It would be much saner to explicitly use the scratch register
7150 ;; in the jump insn, and have indirect_jump_scratch only set it,
7151 ;; but fill_simple_delay_slots would refuse to do delay slot filling
7152 ;; from the target then, as it uses simplejump_p.
7153 ;;(define_insn "jump_compact_far"
7155 ;; (label_ref (match_operand 0 "" "")))
7156 ;; (use (match_operand 1 "register_operand" "r")]
7158 ;; "* return output_far_jump(insn, operands[0], operands[1]);"
7159 ;; [(set_attr "type" "jump")
7160 ;; (set_attr "needs_delay_slot" "yes")])
7162 (define_insn "jump_media"
7164 (match_operand 0 "target_operand" "b"))]
7167 [(set_attr "type" "jump_media")])
7169 (define_expand "jump"
7171 (label_ref (match_operand 0 "" "")))]
7176 emit_jump_insn (gen_jump_compact (operands[0]));
7177 else if (TARGET_SHMEDIA)
7179 if (reload_in_progress || reload_completed)
7181 emit_jump_insn (gen_jump_media (gen_rtx_LABEL_REF (Pmode,
7187 (define_insn "force_mode_for_call"
7188 [(use (reg:PSI FPSCR_REG))]
7191 [(set_attr "length" "0")
7192 (set (attr "fp_mode")
7193 (if_then_else (eq_attr "fpu_single" "yes")
7194 (const_string "single") (const_string "double")))])
7196 (define_insn "calli"
7197 [(call (mem:SI (match_operand:SI 0 "arith_reg_operand" "r"))
7198 (match_operand 1 "" ""))
7199 (use (reg:PSI FPSCR_REG))
7200 (clobber (reg:SI PR_REG))]
7203 [(set_attr "type" "call")
7204 (set (attr "fp_mode")
7205 (if_then_else (eq_attr "fpu_single" "yes")
7206 (const_string "single") (const_string "double")))
7207 (set_attr "needs_delay_slot" "yes")
7208 (set_attr "fp_set" "unknown")])
7210 ;; This is a pc-rel call, using bsrf, for use with PIC.
7212 (define_insn "calli_pcrel"
7213 [(call (mem:SI (match_operand:SI 0 "arith_reg_operand" "r"))
7214 (match_operand 1 "" ""))
7215 (use (reg:PSI FPSCR_REG))
7216 (use (reg:SI PIC_REG))
7217 (use (match_operand 2 "" ""))
7218 (clobber (reg:SI PR_REG))]
7221 [(set_attr "type" "call")
7222 (set (attr "fp_mode")
7223 (if_then_else (eq_attr "fpu_single" "yes")
7224 (const_string "single") (const_string "double")))
7225 (set_attr "needs_delay_slot" "yes")
7226 (set_attr "fp_set" "unknown")])
7228 (define_insn_and_split "call_pcrel"
7229 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" ""))
7230 (match_operand 1 "" ""))
7231 (use (reg:PSI FPSCR_REG))
7232 (use (reg:SI PIC_REG))
7233 (clobber (reg:SI PR_REG))
7234 (clobber (match_scratch:SI 2 "=r"))]
7241 rtx lab = PATTERN (gen_call_site ());
7243 if (SYMBOL_REF_LOCAL_P (operands[0]))
7244 emit_insn (gen_sym_label2reg (operands[2], operands[0], lab));
7246 emit_insn (gen_symPLT_label2reg (operands[2], operands[0], lab));
7247 emit_call_insn (gen_calli_pcrel (operands[2], operands[1], lab));
7250 [(set_attr "type" "call")
7251 (set (attr "fp_mode")
7252 (if_then_else (eq_attr "fpu_single" "yes")
7253 (const_string "single") (const_string "double")))
7254 (set_attr "needs_delay_slot" "yes")
7255 (set_attr "fp_set" "unknown")])
7257 (define_insn "call_compact"
7258 [(call (mem:SI (match_operand:SI 0 "arith_reg_operand" "r"))
7259 (match_operand 1 "" ""))
7260 (match_operand 2 "immediate_operand" "n")
7261 (use (reg:SI R0_REG))
7262 (use (reg:SI R1_REG))
7263 (use (reg:PSI FPSCR_REG))
7264 (clobber (reg:SI PR_REG))]
7265 "TARGET_SHCOMPACT && ! (INTVAL (operands[2]) & CALL_COOKIE_RET_TRAMP (1))"
7267 [(set_attr "type" "call")
7268 (set (attr "fp_mode")
7269 (if_then_else (eq_attr "fpu_single" "yes")
7270 (const_string "single") (const_string "double")))
7271 (set_attr "needs_delay_slot" "yes")])
7273 (define_insn "call_compact_rettramp"
7274 [(call (mem:SI (match_operand:SI 0 "arith_reg_operand" "r"))
7275 (match_operand 1 "" ""))
7276 (match_operand 2 "immediate_operand" "n")
7277 (use (reg:SI R0_REG))
7278 (use (reg:SI R1_REG))
7279 (use (reg:PSI FPSCR_REG))
7280 (clobber (reg:SI R10_REG))
7281 (clobber (reg:SI PR_REG))]
7282 "TARGET_SHCOMPACT && (INTVAL (operands[2]) & CALL_COOKIE_RET_TRAMP (1))"
7284 [(set_attr "type" "call")
7285 (set (attr "fp_mode")
7286 (if_then_else (eq_attr "fpu_single" "yes")
7287 (const_string "single") (const_string "double")))
7288 (set_attr "needs_delay_slot" "yes")])
7290 (define_insn "call_media"
7291 [(call (mem:DI (match_operand 0 "target_reg_operand" "b"))
7292 (match_operand 1 "" ""))
7293 (clobber (reg:DI PR_MEDIA_REG))]
7296 [(set_attr "type" "jump_media")])
7298 (define_insn "call_valuei"
7299 [(set (match_operand 0 "" "=rf")
7300 (call (mem:SI (match_operand:SI 1 "arith_reg_operand" "r"))
7301 (match_operand 2 "" "")))
7302 (use (reg:PSI FPSCR_REG))
7303 (clobber (reg:SI PR_REG))]
7306 [(set_attr "type" "call")
7307 (set (attr "fp_mode")
7308 (if_then_else (eq_attr "fpu_single" "yes")
7309 (const_string "single") (const_string "double")))
7310 (set_attr "needs_delay_slot" "yes")
7311 (set_attr "fp_set" "unknown")])
7313 (define_insn "call_valuei_pcrel"
7314 [(set (match_operand 0 "" "=rf")
7315 (call (mem:SI (match_operand:SI 1 "arith_reg_operand" "r"))
7316 (match_operand 2 "" "")))
7317 (use (reg:PSI FPSCR_REG))
7318 (use (reg:SI PIC_REG))
7319 (use (match_operand 3 "" ""))
7320 (clobber (reg:SI PR_REG))]
7323 [(set_attr "type" "call")
7324 (set (attr "fp_mode")
7325 (if_then_else (eq_attr "fpu_single" "yes")
7326 (const_string "single") (const_string "double")))
7327 (set_attr "needs_delay_slot" "yes")
7328 (set_attr "fp_set" "unknown")])
7330 (define_insn_and_split "call_value_pcrel"
7331 [(set (match_operand 0 "" "=rf")
7332 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" ""))
7333 (match_operand 2 "" "")))
7334 (use (reg:PSI FPSCR_REG))
7335 (use (reg:SI PIC_REG))
7336 (clobber (reg:SI PR_REG))
7337 (clobber (match_scratch:SI 3 "=r"))]
7344 rtx lab = PATTERN (gen_call_site ());
7346 if (SYMBOL_REF_LOCAL_P (operands[1]))
7347 emit_insn (gen_sym_label2reg (operands[3], operands[1], lab));
7349 emit_insn (gen_symPLT_label2reg (operands[3], operands[1], lab));
7350 emit_call_insn (gen_call_valuei_pcrel (operands[0], operands[3],
7354 [(set_attr "type" "call")
7355 (set (attr "fp_mode")
7356 (if_then_else (eq_attr "fpu_single" "yes")
7357 (const_string "single") (const_string "double")))
7358 (set_attr "needs_delay_slot" "yes")
7359 (set_attr "fp_set" "unknown")])
7361 (define_insn "call_value_compact"
7362 [(set (match_operand 0 "" "=rf")
7363 (call (mem:SI (match_operand:SI 1 "arith_reg_operand" "r"))
7364 (match_operand 2 "" "")))
7365 (match_operand 3 "immediate_operand" "n")
7366 (use (reg:SI R0_REG))
7367 (use (reg:SI R1_REG))
7368 (use (reg:PSI FPSCR_REG))
7369 (clobber (reg:SI PR_REG))]
7370 "TARGET_SHCOMPACT && ! (INTVAL (operands[3]) & CALL_COOKIE_RET_TRAMP (1))"
7372 [(set_attr "type" "call")
7373 (set (attr "fp_mode")
7374 (if_then_else (eq_attr "fpu_single" "yes")
7375 (const_string "single") (const_string "double")))
7376 (set_attr "needs_delay_slot" "yes")])
7378 (define_insn "call_value_compact_rettramp"
7379 [(set (match_operand 0 "" "=rf")
7380 (call (mem:SI (match_operand:SI 1 "arith_reg_operand" "r"))
7381 (match_operand 2 "" "")))
7382 (match_operand 3 "immediate_operand" "n")
7383 (use (reg:SI R0_REG))
7384 (use (reg:SI R1_REG))
7385 (use (reg:PSI FPSCR_REG))
7386 (clobber (reg:SI R10_REG))
7387 (clobber (reg:SI PR_REG))]
7388 "TARGET_SHCOMPACT && (INTVAL (operands[3]) & CALL_COOKIE_RET_TRAMP (1))"
7390 [(set_attr "type" "call")
7391 (set (attr "fp_mode")
7392 (if_then_else (eq_attr "fpu_single" "yes")
7393 (const_string "single") (const_string "double")))
7394 (set_attr "needs_delay_slot" "yes")])
7396 (define_insn "call_value_media"
7397 [(set (match_operand 0 "" "=rf")
7398 (call (mem:DI (match_operand 1 "target_reg_operand" "b"))
7399 (match_operand 2 "" "")))
7400 (clobber (reg:DI PR_MEDIA_REG))]
7403 [(set_attr "type" "jump_media")])
7405 (define_expand "call"
7406 [(parallel [(call (mem:SI (match_operand 0 "arith_reg_operand" ""))
7407 (match_operand 1 "" ""))
7408 (match_operand 2 "" "")
7409 (use (reg:PSI FPSCR_REG))
7410 (clobber (reg:SI PR_REG))])]
7416 operands[0] = shmedia_prepare_call_address (operands[0], 0);
7417 emit_call_insn (gen_call_media (operands[0], operands[1]));
7420 else if (TARGET_SHCOMPACT && operands[2] && INTVAL (operands[2]))
7422 rtx cookie_rtx = operands[2];
7423 long cookie = INTVAL (cookie_rtx);
7424 rtx func = XEXP (operands[0], 0);
7429 if (GET_CODE (func) == SYMBOL_REF && ! SYMBOL_REF_LOCAL_P (func))
7431 rtx reg = gen_reg_rtx (Pmode);
7433 emit_insn (gen_symGOTPLT2reg (reg, func));
7437 func = legitimize_pic_address (func, Pmode, 0);
7440 r0 = gen_rtx_REG (SImode, R0_REG);
7441 r1 = gen_rtx_REG (SImode, R1_REG);
7443 /* Since such a call function may use all call-clobbered
7444 registers, we force a mode switch earlier, so that we don't
7445 run out of registers when adjusting fpscr for the call. */
7446 emit_insn (gen_force_mode_for_call ());
7449 = function_symbol (NULL, \"__GCC_shcompact_call_trampoline\",
7451 operands[0] = force_reg (SImode, operands[0]);
7453 emit_move_insn (r0, func);
7454 emit_move_insn (r1, cookie_rtx);
7456 if (cookie & CALL_COOKIE_RET_TRAMP (1))
7457 emit_call_insn (gen_call_compact_rettramp (operands[0], operands[1],
7460 emit_call_insn (gen_call_compact (operands[0], operands[1],
7465 else if (TARGET_SHCOMPACT && flag_pic
7466 && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
7467 && ! SYMBOL_REF_LOCAL_P (XEXP (operands[0], 0)))
7469 rtx reg = gen_reg_rtx (Pmode);
7471 emit_insn (gen_symGOTPLT2reg (reg, XEXP (operands[0], 0)));
7472 XEXP (operands[0], 0) = reg;
7474 if (flag_pic && TARGET_SH2
7475 && GET_CODE (operands[0]) == MEM
7476 && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF)
7478 emit_call_insn (gen_call_pcrel (XEXP (operands[0], 0), operands[1]));
7483 operands[0] = force_reg (SImode, XEXP (operands[0], 0));
7484 operands[1] = operands[2];
7487 emit_call_insn (gen_calli (operands[0], operands[1]));
7491 (define_insn "call_pop_compact"
7492 [(call (mem:SI (match_operand:SI 0 "arith_reg_operand" "r"))
7493 (match_operand 1 "" ""))
7494 (match_operand 2 "immediate_operand" "n")
7495 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
7496 (match_operand 3 "immediate_operand" "n")))
7497 (use (reg:SI R0_REG))
7498 (use (reg:SI R1_REG))
7499 (use (reg:PSI FPSCR_REG))
7500 (clobber (reg:SI PR_REG))]
7501 "TARGET_SHCOMPACT && ! (INTVAL (operands[2]) & CALL_COOKIE_RET_TRAMP (1))"
7503 [(set_attr "type" "call")
7504 (set (attr "fp_mode")
7505 (if_then_else (eq_attr "fpu_single" "yes")
7506 (const_string "single") (const_string "double")))
7507 (set_attr "needs_delay_slot" "yes")])
7509 (define_insn "call_pop_compact_rettramp"
7510 [(call (mem:SI (match_operand:SI 0 "arith_reg_operand" "r"))
7511 (match_operand 1 "" ""))
7512 (match_operand 2 "immediate_operand" "n")
7513 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
7514 (match_operand 3 "immediate_operand" "n")))
7515 (use (reg:SI R0_REG))
7516 (use (reg:SI R1_REG))
7517 (use (reg:PSI FPSCR_REG))
7518 (clobber (reg:SI R10_REG))
7519 (clobber (reg:SI PR_REG))]
7520 "TARGET_SHCOMPACT && (INTVAL (operands[2]) & CALL_COOKIE_RET_TRAMP (1))"
7522 [(set_attr "type" "call")
7523 (set (attr "fp_mode")
7524 (if_then_else (eq_attr "fpu_single" "yes")
7525 (const_string "single") (const_string "double")))
7526 (set_attr "needs_delay_slot" "yes")])
7528 (define_expand "call_pop"
7529 [(parallel [(call (mem:SI (match_operand 0 "arith_reg_operand" ""))
7530 (match_operand 1 "" ""))
7531 (match_operand 2 "" "")
7532 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
7533 (match_operand 3 "" "")))])]
7542 gcc_assert (operands[2] && INTVAL (operands[2]));
7543 cookie_rtx = operands[2];
7544 cookie = INTVAL (cookie_rtx);
7545 func = XEXP (operands[0], 0);
7549 if (GET_CODE (func) == SYMBOL_REF && ! SYMBOL_REF_LOCAL_P (func))
7551 rtx reg = gen_reg_rtx (Pmode);
7552 emit_insn (gen_symGOTPLT2reg (reg, func));
7556 func = legitimize_pic_address (func, Pmode, 0);
7559 r0 = gen_rtx_REG (SImode, R0_REG);
7560 r1 = gen_rtx_REG (SImode, R1_REG);
7562 /* Since such a call function may use all call-clobbered
7563 registers, we force a mode switch earlier, so that we don't
7564 run out of registers when adjusting fpscr for the call. */
7565 emit_insn (gen_force_mode_for_call ());
7567 operands[0] = function_symbol (NULL, \"__GCC_shcompact_call_trampoline\",
7569 operands[0] = force_reg (SImode, operands[0]);
7571 emit_move_insn (r0, func);
7572 emit_move_insn (r1, cookie_rtx);
7574 if (cookie & CALL_COOKIE_RET_TRAMP (1))
7575 emit_call_insn (gen_call_pop_compact_rettramp
7576 (operands[0], operands[1], operands[2], operands[3]));
7578 emit_call_insn (gen_call_pop_compact
7579 (operands[0], operands[1], operands[2], operands[3]));
7584 (define_expand "call_value"
7585 [(parallel [(set (match_operand 0 "arith_reg_operand" "")
7586 (call (mem:SI (match_operand 1 "arith_reg_operand" ""))
7587 (match_operand 2 "" "")))
7588 (match_operand 3 "" "")
7589 (use (reg:PSI FPSCR_REG))
7590 (clobber (reg:SI PR_REG))])]
7596 operands[1] = shmedia_prepare_call_address (operands[1], 0);
7597 emit_call_insn (gen_call_value_media (operands[0], operands[1],
7601 else if (TARGET_SHCOMPACT && operands[3] && INTVAL (operands[3]))
7603 rtx cookie_rtx = operands[3];
7604 long cookie = INTVAL (cookie_rtx);
7605 rtx func = XEXP (operands[1], 0);
7610 if (GET_CODE (func) == SYMBOL_REF && ! SYMBOL_REF_LOCAL_P (func))
7612 rtx reg = gen_reg_rtx (Pmode);
7614 emit_insn (gen_symGOTPLT2reg (reg, func));
7618 func = legitimize_pic_address (func, Pmode, 0);
7621 r0 = gen_rtx_REG (SImode, R0_REG);
7622 r1 = gen_rtx_REG (SImode, R1_REG);
7624 /* Since such a call function may use all call-clobbered
7625 registers, we force a mode switch earlier, so that we don't
7626 run out of registers when adjusting fpscr for the call. */
7627 emit_insn (gen_force_mode_for_call ());
7630 = function_symbol (NULL, \"__GCC_shcompact_call_trampoline\",
7632 operands[1] = force_reg (SImode, operands[1]);
7634 emit_move_insn (r0, func);
7635 emit_move_insn (r1, cookie_rtx);
7637 if (cookie & CALL_COOKIE_RET_TRAMP (1))
7638 emit_call_insn (gen_call_value_compact_rettramp (operands[0],
7643 emit_call_insn (gen_call_value_compact (operands[0], operands[1],
7644 operands[2], operands[3]));
7648 else if (TARGET_SHCOMPACT && flag_pic
7649 && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
7650 && ! SYMBOL_REF_LOCAL_P (XEXP (operands[1], 0)))
7652 rtx reg = gen_reg_rtx (Pmode);
7654 emit_insn (gen_symGOTPLT2reg (reg, XEXP (operands[1], 0)));
7655 XEXP (operands[1], 0) = reg;
7657 if (flag_pic && TARGET_SH2
7658 && GET_CODE (operands[1]) == MEM
7659 && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
7661 emit_call_insn (gen_call_value_pcrel (operands[0], XEXP (operands[1], 0),
7666 operands[1] = force_reg (SImode, XEXP (operands[1], 0));
7668 emit_call_insn (gen_call_valuei (operands[0], operands[1], operands[2]));
7672 (define_insn "sibcalli"
7673 [(call (mem:SI (match_operand:SI 0 "register_operand" "k"))
7674 (match_operand 1 "" ""))
7675 (use (reg:PSI FPSCR_REG))
7679 [(set_attr "needs_delay_slot" "yes")
7680 (set (attr "fp_mode")
7681 (if_then_else (eq_attr "fpu_single" "yes")
7682 (const_string "single") (const_string "double")))
7683 (set_attr "type" "jump_ind")])
7685 (define_insn "sibcalli_pcrel"
7686 [(call (mem:SI (match_operand:SI 0 "arith_reg_operand" "k"))
7687 (match_operand 1 "" ""))
7688 (use (match_operand 2 "" ""))
7689 (use (reg:PSI FPSCR_REG))
7693 [(set_attr "needs_delay_slot" "yes")
7694 (set (attr "fp_mode")
7695 (if_then_else (eq_attr "fpu_single" "yes")
7696 (const_string "single") (const_string "double")))
7697 (set_attr "type" "jump_ind")])
7699 ;; This uses an unspec to describe that the symbol_ref is very close.
7700 (define_insn "sibcalli_thunk"
7701 [(call (mem:SI (unspec:SI [(match_operand:SI 0 "symbol_ref_operand" "")]
7703 (match_operand 1 "" ""))
7704 (use (reg:PSI FPSCR_REG))
7708 [(set_attr "needs_delay_slot" "yes")
7709 (set (attr "fp_mode")
7710 (if_then_else (eq_attr "fpu_single" "yes")
7711 (const_string "single") (const_string "double")))
7712 (set_attr "type" "jump")
7713 (set_attr "length" "2")])
7715 (define_insn_and_split "sibcall_pcrel"
7716 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" ""))
7717 (match_operand 1 "" ""))
7718 (use (reg:PSI FPSCR_REG))
7719 (clobber (match_scratch:SI 2 "=k"))
7727 rtx lab = PATTERN (gen_call_site ());
7730 emit_insn (gen_sym_label2reg (operands[2], operands[0], lab));
7731 call_insn = emit_call_insn (gen_sibcalli_pcrel (operands[2], operands[1],
7733 SIBLING_CALL_P (call_insn) = 1;
7736 [(set_attr "needs_delay_slot" "yes")
7737 (set (attr "fp_mode")
7738 (if_then_else (eq_attr "fpu_single" "yes")
7739 (const_string "single") (const_string "double")))
7740 (set_attr "type" "jump_ind")])
7742 (define_insn "sibcall_compact"
7743 [(call (mem:SI (match_operand:SI 0 "register_operand" "k,k"))
7744 (match_operand 1 "" ""))
7746 (use (match_operand:SI 2 "register_operand" "z,x"))
7747 (use (reg:SI R1_REG))
7748 (use (reg:PSI FPSCR_REG))
7749 ;; We want to make sure the `x' above will only match MACH_REG
7750 ;; because sibcall_epilogue may clobber MACL_REG.
7751 (clobber (reg:SI MACL_REG))]
7755 jmp @%0\\n sts %2, r0"
7756 [(set_attr "needs_delay_slot" "yes,no")
7757 (set_attr "length" "2,4")
7758 (set (attr "fp_mode") (const_string "single"))
7759 (set_attr "type" "jump_ind")])
7761 (define_insn "sibcall_media"
7762 [(call (mem:DI (match_operand 0 "target_reg_operand" "k"))
7763 (match_operand 1 "" ""))
7764 (use (reg:SI PR_MEDIA_REG))
7768 [(set_attr "type" "jump_media")])
7770 (define_expand "sibcall"
7772 [(call (mem:SI (match_operand 0 "arith_reg_operand" ""))
7773 (match_operand 1 "" ""))
7774 (match_operand 2 "" "")
7775 (use (reg:PSI FPSCR_REG))
7782 operands[0] = shmedia_prepare_call_address (operands[0], 1);
7783 emit_call_insn (gen_sibcall_media (operands[0], operands[1]));
7786 else if (TARGET_SHCOMPACT && operands[2]
7787 && (INTVAL (operands[2]) & ~ CALL_COOKIE_RET_TRAMP (1)))
7789 rtx cookie_rtx = operands[2];
7790 long cookie = INTVAL (cookie_rtx);
7791 rtx func = XEXP (operands[0], 0);
7796 if (GET_CODE (func) == SYMBOL_REF && ! SYMBOL_REF_LOCAL_P (func))
7798 rtx reg = gen_reg_rtx (Pmode);
7800 emit_insn (gen_symGOT2reg (reg, func));
7804 func = legitimize_pic_address (func, Pmode, 0);
7807 /* FIXME: if we could tell whether all argument registers are
7808 already taken, we could decide whether to force the use of
7809 MACH_REG or to stick to R0_REG. Unfortunately, there's no
7810 simple way to tell. We could use the CALL_COOKIE, but we
7811 can't currently tell a register used for regular argument
7812 passing from one that is unused. If we leave it up to reload
7813 to decide which register to use, it seems to always choose
7814 R0_REG, which leaves no available registers in SIBCALL_REGS
7815 to hold the address of the trampoline. */
7816 mach = gen_rtx_REG (SImode, MACH_REG);
7817 r1 = gen_rtx_REG (SImode, R1_REG);
7819 /* Since such a call function may use all call-clobbered
7820 registers, we force a mode switch earlier, so that we don't
7821 run out of registers when adjusting fpscr for the call. */
7822 emit_insn (gen_force_mode_for_call ());
7825 = function_symbol (NULL, \"__GCC_shcompact_call_trampoline\",
7827 operands[0] = force_reg (SImode, operands[0]);
7829 /* We don't need a return trampoline, since the callee will
7830 return directly to the upper caller. */
7831 if (cookie & CALL_COOKIE_RET_TRAMP (1))
7833 cookie &= ~ CALL_COOKIE_RET_TRAMP (1);
7834 cookie_rtx = GEN_INT (cookie);
7837 emit_move_insn (mach, func);
7838 emit_move_insn (r1, cookie_rtx);
7840 emit_call_insn (gen_sibcall_compact (operands[0], operands[1], mach));
7843 else if (TARGET_SHCOMPACT && flag_pic
7844 && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
7845 && ! SYMBOL_REF_LOCAL_P (XEXP (operands[0], 0)))
7847 rtx reg = gen_reg_rtx (Pmode);
7849 emit_insn (gen_symGOT2reg (reg, XEXP (operands[0], 0)));
7850 XEXP (operands[0], 0) = reg;
7852 if (flag_pic && TARGET_SH2
7853 && GET_CODE (operands[0]) == MEM
7854 && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
7855 /* The PLT needs the PIC register, but the epilogue would have
7856 to restore it, so we can only use PC-relative PIC calls for
7857 static functions. */
7858 && SYMBOL_REF_LOCAL_P (XEXP (operands[0], 0)))
7860 emit_call_insn (gen_sibcall_pcrel (XEXP (operands[0], 0), operands[1]));
7864 operands[0] = force_reg (SImode, XEXP (operands[0], 0));
7866 emit_call_insn (gen_sibcalli (operands[0], operands[1]));
7870 (define_expand "sibcall_value"
7871 [(set (match_operand 0 "" "")
7872 (call (match_operand 1 "" "")
7873 (match_operand 2 "" "")))
7874 (match_operand 3 "" "")]
7878 emit_call_insn (gen_sibcall (operands[1], operands[2], operands[3]));
7882 (define_insn "call_value_pop_compact"
7883 [(set (match_operand 0 "" "=rf")
7884 (call (mem:SI (match_operand:SI 1 "arith_reg_operand" "r"))
7885 (match_operand 2 "" "")))
7886 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
7887 (match_operand 4 "immediate_operand" "n")))
7888 (match_operand 3 "immediate_operand" "n")
7889 (use (reg:SI R0_REG))
7890 (use (reg:SI R1_REG))
7891 (use (reg:PSI FPSCR_REG))
7892 (clobber (reg:SI PR_REG))]
7893 "TARGET_SHCOMPACT && ! (INTVAL (operands[3]) & CALL_COOKIE_RET_TRAMP (1))"
7895 [(set_attr "type" "call")
7896 (set (attr "fp_mode")
7897 (if_then_else (eq_attr "fpu_single" "yes")
7898 (const_string "single") (const_string "double")))
7899 (set_attr "needs_delay_slot" "yes")])
7901 (define_insn "call_value_pop_compact_rettramp"
7902 [(set (match_operand 0 "" "=rf")
7903 (call (mem:SI (match_operand:SI 1 "arith_reg_operand" "r"))
7904 (match_operand 2 "" "")))
7905 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
7906 (match_operand 4 "immediate_operand" "n")))
7907 (match_operand 3 "immediate_operand" "n")
7908 (use (reg:SI R0_REG))
7909 (use (reg:SI R1_REG))
7910 (use (reg:PSI FPSCR_REG))
7911 (clobber (reg:SI R10_REG))
7912 (clobber (reg:SI PR_REG))]
7913 "TARGET_SHCOMPACT && (INTVAL (operands[3]) & CALL_COOKIE_RET_TRAMP (1))"
7915 [(set_attr "type" "call")
7916 (set (attr "fp_mode")
7917 (if_then_else (eq_attr "fpu_single" "yes")
7918 (const_string "single") (const_string "double")))
7919 (set_attr "needs_delay_slot" "yes")])
7921 (define_expand "call_value_pop"
7922 [(parallel [(set (match_operand 0 "arith_reg_operand" "")
7923 (call (mem:SI (match_operand 1 "arith_reg_operand" ""))
7924 (match_operand 2 "" "")))
7925 (match_operand 3 "" "")
7926 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
7927 (match_operand 4 "" "")))])]
7936 gcc_assert (TARGET_SHCOMPACT && operands[3] && INTVAL (operands[3]));
7937 cookie_rtx = operands[3];
7938 cookie = INTVAL (cookie_rtx);
7939 func = XEXP (operands[1], 0);
7943 if (GET_CODE (func) == SYMBOL_REF && ! SYMBOL_REF_LOCAL_P (func))
7945 rtx reg = gen_reg_rtx (Pmode);
7947 emit_insn (gen_symGOTPLT2reg (reg, func));
7951 func = legitimize_pic_address (func, Pmode, 0);
7954 r0 = gen_rtx_REG (SImode, R0_REG);
7955 r1 = gen_rtx_REG (SImode, R1_REG);
7957 /* Since such a call function may use all call-clobbered
7958 registers, we force a mode switch earlier, so that we don't
7959 run out of registers when adjusting fpscr for the call. */
7960 emit_insn (gen_force_mode_for_call ());
7962 operands[1] = function_symbol (NULL, \"__GCC_shcompact_call_trampoline\",
7964 operands[1] = force_reg (SImode, operands[1]);
7966 emit_move_insn (r0, func);
7967 emit_move_insn (r1, cookie_rtx);
7969 if (cookie & CALL_COOKIE_RET_TRAMP (1))
7970 emit_call_insn (gen_call_value_pop_compact_rettramp
7971 (operands[0], operands[1], operands[2],
7972 operands[3], operands[4]));
7974 emit_call_insn (gen_call_value_pop_compact
7975 (operands[0], operands[1], operands[2],
7976 operands[3], operands[4]));
7981 (define_expand "sibcall_epilogue"
7986 sh_expand_epilogue (1);
7987 if (TARGET_SHCOMPACT)
7991 /* If epilogue clobbers r0, preserve it in macl. */
7992 for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
7993 if ((set = single_set (insn))
7994 && GET_CODE (SET_DEST (set)) == REG
7995 && REGNO (SET_DEST (set)) == R0_REG)
7997 rtx r0 = gen_rtx_REG (SImode, R0_REG);
7998 rtx tmp = gen_rtx_REG (SImode, MACL_REG);
8001 /* We can't tell at this point whether the sibcall is a
8002 sibcall_compact and, if it is, whether it uses r0 or
8003 mach as operand 2, so let the instructions that
8004 preserve r0 be optimized away if r0 turns out to be
8006 i = emit_insn_before (gen_rtx_SET (SImode, tmp, r0), insn);
8007 REG_NOTES (i) = gen_rtx_EXPR_LIST (REG_MAYBE_DEAD, const0_rtx,
8009 i = emit_move_insn (r0, tmp);
8010 REG_NOTES (i) = gen_rtx_EXPR_LIST (REG_MAYBE_DEAD, const0_rtx,
8018 (define_insn "indirect_jump_compact"
8020 (match_operand:SI 0 "arith_reg_operand" "r"))]
8023 [(set_attr "needs_delay_slot" "yes")
8024 (set_attr "type" "jump_ind")])
8026 (define_expand "indirect_jump"
8028 (match_operand 0 "register_operand" ""))]
8032 if (GET_MODE (operands[0]) != Pmode)
8033 operands[0] = gen_rtx_SUBREG (Pmode, operands[0], 0);
8036 ;; The use of operand 1 / 2 helps us distinguish case table jumps
8037 ;; which can be present in structured code from indirect jumps which can not
8038 ;; be present in structured code. This allows -fprofile-arcs to work.
8040 ;; For SH1 processors.
8041 (define_insn "casesi_jump_1"
8043 (match_operand:SI 0 "register_operand" "r"))
8044 (use (label_ref (match_operand 1 "" "")))]
8047 [(set_attr "needs_delay_slot" "yes")
8048 (set_attr "type" "jump_ind")])
8050 ;; For all later processors.
8051 (define_insn "casesi_jump_2"
8052 [(set (pc) (plus:SI (match_operand:SI 0 "register_operand" "r")
8053 (label_ref (match_operand 1 "" ""))))
8054 (use (label_ref (match_operand 2 "" "")))]
8056 && (! INSN_UID (operands[1]) || prev_real_insn (operands[1]) == insn)"
8058 [(set_attr "needs_delay_slot" "yes")
8059 (set_attr "type" "jump_ind")])
8061 (define_insn "casesi_jump_media"
8062 [(set (pc) (match_operand 0 "target_reg_operand" "b"))
8063 (use (label_ref (match_operand 1 "" "")))]
8066 [(set_attr "type" "jump_media")])
8068 ;; Call subroutine returning any type.
8069 ;; ??? This probably doesn't work.
8071 (define_expand "untyped_call"
8072 [(parallel [(call (match_operand 0 "" "")
8074 (match_operand 1 "" "")
8075 (match_operand 2 "" "")])]
8076 "(TARGET_SH2E || TARGET_SH2A) || TARGET_SHMEDIA"
8081 emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx));
8083 for (i = 0; i < XVECLEN (operands[2], 0); i++)
8085 rtx set = XVECEXP (operands[2], 0, i);
8086 emit_move_insn (SET_DEST (set), SET_SRC (set));
8089 /* The optimizer does not know that the call sets the function value
8090 registers we stored in the result block. We avoid problems by
8091 claiming that all hard registers are used and clobbered at this
8093 emit_insn (gen_blockage ());
8098 ;; ------------------------------------------------------------------------
8100 ;; ------------------------------------------------------------------------
8103 [(set (reg:SI T_REG)
8104 (eq:SI (match_operand:SI 0 "arith_reg_dest" "+r") (const_int 1)))
8105 (set (match_dup 0) (plus:SI (match_dup 0) (const_int -1)))]
8108 [(set_attr "type" "arith")])
8115 ;; Load address of a label. This is only generated by the casesi expand,
8116 ;; and by machine_dependent_reorg (fixing up fp moves).
8117 ;; This must use unspec, because this only works for labels that are
8121 [(set (reg:SI R0_REG)
8122 (unspec:SI [(label_ref (match_operand 0 "" ""))] UNSPEC_MOVA))]
8125 [(set_attr "in_delay_slot" "no")
8126 (set_attr "type" "arith")])
8128 ;; machine_dependent_reorg will make this a `mova'.
8129 (define_insn "mova_const"
8130 [(set (reg:SI R0_REG)
8131 (unspec:SI [(match_operand 0 "immediate_operand" "i")] UNSPEC_MOVA))]
8134 [(set_attr "in_delay_slot" "no")
8135 (set_attr "type" "arith")])
8137 (define_expand "GOTaddr2picreg"
8138 [(set (reg:SI R0_REG)
8139 (unspec:SI [(const:SI (unspec:SI [(match_dup 1)] UNSPEC_PIC))]
8141 (set (match_dup 0) (const:SI (unspec:SI [(match_dup 1)] UNSPEC_PIC)))
8142 (set (match_dup 0) (plus:SI (match_dup 0) (reg:SI R0_REG)))]
8145 operands[0] = gen_rtx_REG (Pmode, PIC_REG);
8146 operands[1] = gen_rtx_SYMBOL_REF (VOIDmode, GOT_SYMBOL_NAME);
8150 rtx tr = gen_rtx_REG (Pmode, TR0_REG);
8151 rtx pic = operands[0];
8152 rtx lab = PATTERN (gen_call_site ());
8155 equiv = operands[1];
8156 operands[1] = gen_rtx_MINUS (Pmode,
8160 gen_rtx_MINUS (Pmode,
8161 gen_rtx_CONST (Pmode,
8164 operands[1] = gen_sym2PIC (operands[1]);
8165 PUT_MODE (operands[1], Pmode);
8167 if (Pmode == SImode)
8169 emit_insn (gen_movsi_const (pic, operands[1]));
8170 emit_insn (gen_ptrel_si (tr, pic, lab));
8174 emit_insn (gen_movdi_const (pic, operands[1]));
8175 emit_insn (gen_ptrel_di (tr, pic, lab));
8178 insn = emit_move_insn (operands[0], tr);
8180 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_EQUAL, equiv,
8189 [(set (match_operand 0 "target_reg_operand" "=b")
8190 (const (unspec [(match_operand 1 "" "Csy")]
8191 UNSPEC_DATALABEL)))]
8192 "TARGET_SHMEDIA && flag_pic
8193 && EXTRA_CONSTRAINT_Csy (operands[1])"
8194 "ptb/u datalabel %1, %0"
8195 [(set_attr "type" "ptabs_media")
8196 (set_attr "length" "*")])
8198 (define_insn "ptrel_si"
8199 [(set (match_operand:SI 0 "target_reg_operand" "=b")
8200 (plus:SI (match_operand:SI 1 "register_operand" "r")
8202 (match_operand:SI 2 "" "")]
8204 "%O2: ptrel/u %1, %0"
8205 [(set_attr "type" "ptabs_media")])
8207 (define_insn "ptrel_di"
8208 [(set (match_operand:DI 0 "target_reg_operand" "=b")
8209 (plus:DI (match_operand:DI 1 "register_operand" "r")
8211 (match_operand:DI 2 "" "")]
8213 "%O2: ptrel/u %1, %0"
8214 [(set_attr "type" "ptabs_media")])
8216 (define_expand "builtin_setjmp_receiver"
8217 [(match_operand 0 "" "")]
8221 emit_insn (gen_GOTaddr2picreg ());
8225 (define_expand "call_site"
8226 [(unspec [(match_dup 0)] UNSPEC_CALLER)]
8230 static HOST_WIDE_INT i = 0;
8231 operands[0] = GEN_INT (i);
8235 (define_expand "sym_label2reg"
8236 [(set (match_operand:SI 0 "" "")
8239 (unspec:SI [(match_operand:SI 1 "" "")] UNSPEC_PIC))
8242 (match_operand:SI 2 "" "")
8246 (define_expand "symGOT_load"
8247 [(set (match_dup 2) (match_operand 1 "" ""))
8248 (set (match_dup 3) (plus (match_dup 2) (reg PIC_REG)))
8249 (set (match_operand 0 "" "") (mem (match_dup 3)))]
8255 operands[2] = no_new_pseudos ? operands[0] : gen_reg_rtx (Pmode);
8256 operands[3] = no_new_pseudos ? operands[0] : gen_reg_rtx (Pmode);
8260 rtx reg = operands[2];
8262 if (Pmode == DImode)
8265 emit_insn (gen_movdi_const_32bit (reg, operands[1]));
8267 emit_insn (gen_movdi_const_16bit (reg, operands[1]));
8272 emit_insn (gen_movsi_const (reg, operands[1]));
8274 emit_insn (gen_movsi_const_16bit (reg, operands[1]));
8278 emit_move_insn (operands[2], operands[1]);
8280 emit_move_insn (operands[3], gen_rtx_PLUS (Pmode,
8282 gen_rtx_REG (Pmode, PIC_REG)));
8284 /* N.B. This is not constant for a GOTPLT relocation. */
8285 mem = gen_rtx_MEM (Pmode, operands[3]);
8286 MEM_NOTRAP_P (mem) = 1;
8287 /* ??? Should we have a special alias set for the GOT? */
8288 insn = emit_move_insn (operands[0], mem);
8290 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_EQUAL, XVECEXP (XEXP (operands[1],
8297 (define_expand "sym2GOT"
8298 [(const (unspec [(match_operand 0 "" "")] UNSPEC_GOT))]
8302 (define_expand "symGOT2reg"
8303 [(match_operand 0 "" "") (match_operand 1 "" "")]
8309 gotsym = gen_sym2GOT (operands[1]);
8310 PUT_MODE (gotsym, Pmode);
8311 insn = emit_insn (gen_symGOT_load (operands[0], gotsym));
8313 MEM_READONLY_P (SET_SRC (PATTERN (insn))) = 1;
8318 (define_expand "sym2GOTPLT"
8319 [(const (unspec [(match_operand 0 "" "")] UNSPEC_GOTPLT))]
8323 (define_expand "symGOTPLT2reg"
8324 [(match_operand 0 "" "") (match_operand 1 "" "")]
8328 emit_insn (gen_symGOT_load (operands[0], gen_sym2GOTPLT (operands[1])));
8332 (define_expand "sym2GOTOFF"
8333 [(const (unspec [(match_operand 0 "" "")] UNSPEC_GOTOFF))]
8337 (define_expand "symGOTOFF2reg"
8338 [(match_operand 0 "" "") (match_operand 1 "" "")]
8342 rtx gotoffsym, insn;
8343 rtx t = no_new_pseudos ? operands[0] : gen_reg_rtx (GET_MODE (operands[0]));
8345 gotoffsym = gen_sym2GOTOFF (operands[1]);
8346 PUT_MODE (gotoffsym, Pmode);
8347 emit_move_insn (t, gotoffsym);
8348 insn = emit_move_insn (operands[0],
8349 gen_rtx_PLUS (Pmode, t,
8350 gen_rtx_REG (Pmode, PIC_REG)));
8352 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_EQUAL, operands[1],
8358 (define_expand "symPLT_label2reg"
8359 [(set (match_operand:SI 0 "" "")
8362 (unspec:SI [(match_operand:SI 1 "" "")] UNSPEC_PLT))
8366 (match_operand:SI 2 "" "")
8368 (const:SI (unspec:SI [(pc)] UNSPEC_PIC)))))))
8369 ;; Even though the PIC register is not really used by the call
8370 ;; sequence in which this is expanded, the PLT code assumes the PIC
8371 ;; register is set, so we must not skip its initialization. Since
8372 ;; we only use this expand as part of calling sequences, and never
8373 ;; to take the address of a function, this is the best point to
8374 ;; insert the (use). Using the PLT to take the address of a
8375 ;; function would be wrong, not only because the PLT entry could
8376 ;; then be called from a function that doesn't initialize the PIC
8377 ;; register to the proper GOT, but also because pointers to the
8378 ;; same function might not compare equal, should they be set by
8379 ;; different shared libraries.
8380 (use (reg:SI PIC_REG))]
8384 (define_expand "sym2PIC"
8385 [(const (unspec [(match_operand:SI 0 "" "")] UNSPEC_PIC))]
8389 ;; TLS code generation.
8390 ;; ??? this should be a define_insn_and_split
8391 ;; See the thread [PATCH/RFA] SH TLS support on gcc-patches
8392 ;; <http://gcc.gnu.org/ml/gcc-patches/2003-02/msg01898.html>
8395 (define_insn "tls_global_dynamic"
8396 [(set (match_operand:SI 0 "register_operand" "=&z")
8397 (call:SI (mem:SI (unspec:SI [(match_operand:SI 1 "" "")]
8400 (use (reg:PSI FPSCR_REG))
8401 (use (reg:SI PIC_REG))
8402 (clobber (reg:SI PR_REG))
8403 (clobber (scratch:SI))]
8409 \\tmova\\t2f,r0\\n\\
8410 \\tmov.l\\t2f,r1\\n\\
8413 \\tadd\\tr12,r4\\n\\
8417 1:\\t.long\\t%a1@TLSGD\\n\\
8418 2:\\t.long\\t__tls_get_addr@PLT\\n\\
8421 [(set_attr "type" "tls_load")
8422 (set_attr "length" "26")])
8424 (define_insn "tls_local_dynamic"
8425 [(set (match_operand:SI 0 "register_operand" "=&z")
8426 (call:SI (mem:SI (unspec:SI [(match_operand:SI 1 "" "")]
8429 (use (reg:PSI FPSCR_REG))
8430 (use (reg:SI PIC_REG))
8431 (clobber (reg:SI PR_REG))
8432 (clobber (scratch:SI))]
8438 \\tmova\\t2f,r0\\n\\
8439 \\tmov.l\\t2f,r1\\n\\
8442 \\tadd\\tr12,r4\\n\\
8446 1:\\t.long\\t%a1@TLSLDM\\n\\
8447 2:\\t.long\\t__tls_get_addr@PLT\\n\\
8450 [(set_attr "type" "tls_load")
8451 (set_attr "length" "26")])
8453 (define_expand "sym2DTPOFF"
8454 [(const (unspec [(match_operand 0 "" "")] UNSPEC_DTPOFF))]
8458 (define_expand "symDTPOFF2reg"
8459 [(match_operand 0 "" "") (match_operand 1 "" "") (match_operand 2 "" "")]
8463 rtx dtpoffsym, insn;
8464 rtx t = no_new_pseudos ? operands[0] : gen_reg_rtx (GET_MODE (operands[0]));
8466 dtpoffsym = gen_sym2DTPOFF (operands[1]);
8467 PUT_MODE (dtpoffsym, Pmode);
8468 emit_move_insn (t, dtpoffsym);
8469 insn = emit_move_insn (operands[0],
8470 gen_rtx_PLUS (Pmode, t, operands[2]));
8474 (define_expand "sym2GOTTPOFF"
8475 [(const (unspec [(match_operand 0 "" "")] UNSPEC_GOTTPOFF))]
8479 (define_insn "tls_initial_exec"
8480 [(set (match_operand:SI 0 "register_operand" "=&r")
8481 (unspec:SI [(match_operand:SI 1 "" "")]
8483 (use (reg:SI GBR_REG))
8484 (use (reg:SI PIC_REG))
8485 (clobber (reg:SI R0_REG))]
8491 \\tstc\\tgbr,%0\\n\\
8492 \\tmov.l\\t@(r0,r12),r0\\n\\
8496 1:\\t.long\\t%a1\\n\\
8499 [(set_attr "type" "tls_load")
8500 (set_attr "length" "16")])
8502 (define_expand "sym2TPOFF"
8503 [(const (unspec [(match_operand 0 "" "")] UNSPEC_TPOFF))]
8507 (define_expand "symTPOFF2reg"
8508 [(match_operand 0 "" "") (match_operand 1 "" "")]
8514 tpoffsym = gen_sym2TPOFF (operands[1]);
8515 PUT_MODE (tpoffsym, Pmode);
8516 insn = emit_move_insn (operands[0], tpoffsym);
8520 (define_insn "load_gbr"
8521 [(set (match_operand:SI 0 "register_operand" "") (reg:SI GBR_REG))
8522 (use (reg:SI GBR_REG))]
8525 [(set_attr "type" "tls_load")])
8527 ;; case instruction for switch statements.
8529 ;; Operand 0 is index
8530 ;; operand 1 is the minimum bound
8531 ;; operand 2 is the maximum bound - minimum bound + 1
8532 ;; operand 3 is CODE_LABEL for the table;
8533 ;; operand 4 is the CODE_LABEL to go to if index out of range.
8535 (define_expand "casesi"
8536 [(match_operand:SI 0 "arith_reg_operand" "")
8537 (match_operand:SI 1 "arith_reg_operand" "")
8538 (match_operand:SI 2 "arith_reg_operand" "")
8539 (match_operand 3 "" "") (match_operand 4 "" "")]
8543 rtx reg = gen_reg_rtx (SImode);
8544 rtx reg2 = gen_reg_rtx (SImode);
8547 rtx reg = gen_reg_rtx (DImode);
8548 rtx reg2 = gen_reg_rtx (DImode);
8549 rtx reg3 = gen_reg_rtx (Pmode);
8550 rtx reg4 = gen_reg_rtx (Pmode);
8551 rtx reg5 = gen_reg_rtx (Pmode);
8554 operands[0] = convert_modes (DImode, SImode, operands[0], 0);
8555 operands[1] = convert_modes (DImode, SImode, operands[1], 0);
8556 operands[2] = convert_modes (DImode, SImode, operands[2], 1);
8558 emit_jump_insn (gen_bgt_media (operands[4], operands[1], operands[0]));
8559 emit_move_insn (reg, gen_rtx_MINUS (DImode, operands[0], operands[1]));
8560 emit_jump_insn (gen_bgtu_media (operands[4], reg, operands[2]));
8561 emit_insn (gen_casesi_shift_media (reg2, reg, operands[3]));
8562 emit_move_insn (reg3, gen_datalabel_ref (gen_rtx_LABEL_REF
8563 (Pmode, operands[3])));
8564 /* Messy: can we subreg to clean this up? */
8565 if (Pmode == DImode)
8566 load = gen_casesi_load_media (reg4, reg3, reg2, operands[3]);
8568 load = gen_casesi_load_media (reg4,
8569 gen_rtx_SUBREG (DImode, reg3, 0),
8571 PUT_MODE (SET_SRC (load), Pmode);
8573 /* ??? The following add could be eliminated if we used ptrel. */
8574 emit_move_insn (reg5, gen_rtx_PLUS (Pmode, reg3, reg4));
8575 emit_jump_insn (gen_casesi_jump_media (reg5, operands[3]));
8579 operands[1] = copy_to_mode_reg (SImode, operands[1]);
8580 operands[2] = copy_to_mode_reg (SImode, operands[2]);
8581 /* If optimizing, casesi_worker depends on the mode of the instruction
8582 before label it 'uses' - operands[3]. */
8583 emit_insn (gen_casesi_0 (operands[0], operands[1], operands[2], operands[4],
8585 emit_insn (gen_casesi_worker_0 (reg2, reg, operands[3]));
8587 emit_jump_insn (gen_casesi_jump_2 (reg2, gen_label_rtx (), operands[3]));
8589 emit_jump_insn (gen_casesi_jump_1 (reg2, operands[3]));
8590 /* For SH2 and newer, the ADDR_DIFF_VEC is not actually relative to
8591 operands[3], but to lab. We will fix this up in
8592 machine_dependent_reorg. */
8597 (define_expand "casesi_0"
8598 [(set (match_operand:SI 4 "" "") (match_operand:SI 0 "arith_reg_operand" ""))
8599 (set (match_dup 4) (minus:SI (match_dup 4)
8600 (match_operand:SI 1 "arith_operand" "")))
8602 (gtu:SI (match_dup 4)
8603 (match_operand:SI 2 "arith_reg_operand" "")))
8605 (if_then_else (ne (reg:SI T_REG)
8607 (label_ref (match_operand 3 "" ""))
8612 ;; ??? reload might clobber r0 if we use it explicitly in the RTL before
8613 ;; reload; using a R0_REGS pseudo reg is likely to give poor code.
8614 ;; So we keep the use of r0 hidden in a R0_REGS clobber until after reload.
8616 (define_insn "casesi_worker_0"
8617 [(set (match_operand:SI 0 "register_operand" "=r,r")
8618 (unspec:SI [(match_operand:SI 1 "register_operand" "0,r")
8619 (label_ref (match_operand 2 "" ""))] UNSPEC_CASESI))
8620 (clobber (match_scratch:SI 3 "=X,1"))
8621 (clobber (match_scratch:SI 4 "=&z,z"))]
8626 [(set (match_operand:SI 0 "register_operand" "")
8627 (unspec:SI [(match_operand:SI 1 "register_operand" "")
8628 (label_ref (match_operand 2 "" ""))] UNSPEC_CASESI))
8629 (clobber (match_scratch:SI 3 ""))
8630 (clobber (match_scratch:SI 4 ""))]
8631 "TARGET_SH1 && ! TARGET_SH2 && reload_completed"
8632 [(set (reg:SI R0_REG) (unspec:SI [(label_ref (match_dup 2))] UNSPEC_MOVA))
8633 (parallel [(set (match_dup 0)
8634 (unspec:SI [(reg:SI R0_REG) (match_dup 1)
8635 (label_ref (match_dup 2))] UNSPEC_CASESI))
8636 (clobber (match_dup 3))])
8637 (set (match_dup 0) (plus:SI (match_dup 0) (reg:SI R0_REG)))]
8638 "if (GET_CODE (operands[2]) == CODE_LABEL) LABEL_NUSES (operands[2])++;")
8641 [(set (match_operand:SI 0 "register_operand" "")
8642 (unspec:SI [(match_operand:SI 1 "register_operand" "")
8643 (label_ref (match_operand 2 "" ""))] UNSPEC_CASESI))
8644 (clobber (match_scratch:SI 3 ""))
8645 (clobber (match_scratch:SI 4 ""))]
8646 "TARGET_SH2 && reload_completed"
8647 [(set (reg:SI R0_REG) (unspec:SI [(label_ref (match_dup 2))] UNSPEC_MOVA))
8648 (parallel [(set (match_dup 0)
8649 (unspec:SI [(reg:SI R0_REG) (match_dup 1)
8650 (label_ref (match_dup 2))] UNSPEC_CASESI))
8651 (clobber (match_dup 3))])]
8652 "if (GET_CODE (operands[2]) == CODE_LABEL) LABEL_NUSES (operands[2])++;")
8654 (define_insn "casesi_worker_1"
8655 [(set (match_operand:SI 0 "register_operand" "=r,r")
8656 (unspec:SI [(reg:SI R0_REG)
8657 (match_operand:SI 1 "register_operand" "0,r")
8658 (label_ref (match_operand 2 "" ""))] UNSPEC_CASESI))
8659 (clobber (match_scratch:SI 3 "=X,1"))]
8663 rtx diff_vec = PATTERN (next_real_insn (operands[2]));
8665 gcc_assert (GET_CODE (diff_vec) == ADDR_DIFF_VEC);
8667 switch (GET_MODE (diff_vec))
8670 return \"shll2 %1\;mov.l @(r0,%1),%0\";
8672 return \"add %1,%1\;mov.w @(r0,%1),%0\";
8674 if (ADDR_DIFF_VEC_FLAGS (diff_vec).offset_unsigned)
8675 return \"mov.b @(r0,%1),%0\;extu.b %0,%0\";
8676 return \"mov.b @(r0,%1),%0\";
8681 [(set_attr "length" "4")])
8683 (define_insn "casesi_worker_2"
8684 [(set (match_operand:SI 0 "register_operand" "=r,r")
8685 (unspec:SI [(reg:SI R0_REG)
8686 (match_operand:SI 1 "register_operand" "0,r")
8687 (label_ref (match_operand 2 "" ""))
8688 (label_ref (match_operand 3 "" ""))] UNSPEC_CASESI))
8689 (clobber (match_operand:SI 4 "" "=X,1"))]
8690 "TARGET_SH2 && reload_completed && flag_pic"
8693 rtx diff_vec = PATTERN (next_real_insn (operands[2]));
8696 gcc_assert (GET_CODE (diff_vec) == ADDR_DIFF_VEC);
8698 switch (GET_MODE (diff_vec))
8701 output_asm_insn (\"shll2 %1\", operands);
8702 load = \"mov.l @(r0,%1),%0\"; break;
8704 output_asm_insn (\"add %1,%1\", operands);
8705 load = \"mov.w @(r0,%1),%0\"; break;
8707 if (ADDR_DIFF_VEC_FLAGS (diff_vec).offset_unsigned)
8708 load = \"mov.b @(r0,%1),%0\;extu.b %0,%0\";
8710 load = \"mov.b @(r0,%1),%0\";
8715 output_asm_insn (\"add\tr0,%1\;mova\t%O3,r0\\n\", operands);
8718 [(set_attr "length" "8")])
8720 (define_insn "casesi_shift_media"
8721 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
8722 (ashift:DI (match_operand:DI 1 "arith_reg_operand" "r")
8723 (unspec:DI [(label_ref:DI (match_operand 2 "" ""))]
8728 rtx diff_vec = PATTERN (next_real_insn (operands[2]));
8730 gcc_assert (GET_CODE (diff_vec) == ADDR_DIFF_VEC);
8732 switch (GET_MODE (diff_vec))
8735 return \"shlli %1, 2, %0\";
8737 return \"shlli %1, 1, %0\";
8739 if (rtx_equal_p (operands[0], operands[1]))
8741 return \"add %1, r63, %0\";
8746 [(set_attr "type" "arith_media")])
8748 (define_insn "casesi_load_media"
8749 [(set (match_operand 0 "any_arith_reg_dest" "=r")
8750 (mem (unspec [(match_operand:DI 1 "arith_reg_operand" "r")
8751 (match_operand:DI 2 "arith_reg_operand" "r")
8752 (label_ref:DI (match_operand 3 "" ""))] UNSPEC_CASESI)))]
8756 rtx diff_vec = PATTERN (next_real_insn (operands[3]));
8758 gcc_assert (GET_CODE (diff_vec) == ADDR_DIFF_VEC);
8760 switch (GET_MODE (diff_vec))
8763 return \"ldx.l %1, %2, %0\";
8766 if (ADDR_DIFF_VEC_FLAGS (diff_vec).offset_unsigned)
8767 return \"ldx.uw %1, %2, %0\";
8769 return \"ldx.w %1, %2, %0\";
8771 if (ADDR_DIFF_VEC_FLAGS (diff_vec).offset_unsigned)
8772 return \"ldx.ub %1, %2, %0\";
8773 return \"ldx.b %1, %2, %0\";
8778 [(set_attr "type" "load_media")])
8780 (define_expand "return"
8782 "reload_completed && ! sh_need_epilogue ()"
8787 emit_jump_insn (gen_return_media ());
8791 if (TARGET_SHCOMPACT
8792 && (current_function_args_info.call_cookie & CALL_COOKIE_RET_TRAMP (1)))
8794 emit_jump_insn (gen_shcompact_return_tramp ());
8799 (define_insn "*return_i"
8801 "TARGET_SH1 && ! (TARGET_SHCOMPACT
8802 && (current_function_args_info.call_cookie
8803 & CALL_COOKIE_RET_TRAMP (1)))
8804 && reload_completed"
8806 [(set_attr "type" "return")
8807 (set_attr "needs_delay_slot" "yes")])
8809 (define_expand "shcompact_return_tramp"
8812 && (current_function_args_info.call_cookie & CALL_COOKIE_RET_TRAMP (1))"
8815 rtx reg = gen_rtx_REG (Pmode, R0_REG);
8817 function_symbol (reg, \"__GCC_shcompact_return_trampoline\", SFUNC_STATIC);
8818 emit_jump_insn (gen_shcompact_return_tramp_i ());
8822 (define_insn "shcompact_return_tramp_i"
8823 [(parallel [(return) (use (reg:SI R0_REG))])]
8825 && (current_function_args_info.call_cookie & CALL_COOKIE_RET_TRAMP (1))"
8827 [(set_attr "type" "jump_ind")
8828 (set_attr "needs_delay_slot" "yes")])
8830 (define_insn "return_media_i"
8831 [(parallel [(return) (use (match_operand 0 "target_reg_operand" "k"))])]
8832 "TARGET_SHMEDIA && reload_completed"
8834 [(set_attr "type" "jump_media")])
8836 (define_insn "return_media_rte"
8838 "TARGET_SHMEDIA && reload_completed && current_function_interrupt"
8840 [(set_attr "type" "jump_media")])
8842 (define_expand "return_media"
8844 "TARGET_SHMEDIA && reload_completed"
8847 int tr_regno = sh_media_register_for_return ();
8850 if (current_function_interrupt)
8852 emit_jump_insn (gen_return_media_rte ());
8857 rtx r18 = gen_rtx_REG (Pmode, PR_MEDIA_REG);
8859 gcc_assert (call_really_used_regs[TR0_REG] && !fixed_regs[TR0_REG]);
8861 tr = gen_rtx_REG (Pmode, tr_regno);
8862 emit_move_insn (tr, r18);
8865 tr = gen_rtx_REG (Pmode, tr_regno);
8867 emit_jump_insn (gen_return_media_i (tr));
8871 (define_insn "shcompact_preserve_incoming_args"
8872 [(set (match_operand:SI 0 "register_operand" "+r")
8873 (unspec:SI [(match_dup 0)] UNSPEC_COMPACT_ARGS))]
8876 [(set_attr "length" "0")])
8878 (define_insn "shcompact_incoming_args"
8879 [(set (reg:SI R2_REG) (unspec:SI [(reg:SI R2_REG)] UNSPEC_COMPACT_ARGS))
8880 (set (reg:SI R3_REG) (unspec:SI [(reg:SI R3_REG)] UNSPEC_COMPACT_ARGS))
8881 (set (reg:SI R4_REG) (unspec:SI [(reg:SI R4_REG)] UNSPEC_COMPACT_ARGS))
8882 (set (reg:SI R5_REG) (unspec:SI [(reg:SI R5_REG)] UNSPEC_COMPACT_ARGS))
8883 (set (reg:SI R6_REG) (unspec:SI [(reg:SI R6_REG)] UNSPEC_COMPACT_ARGS))
8884 (set (reg:SI R7_REG) (unspec:SI [(reg:SI R7_REG)] UNSPEC_COMPACT_ARGS))
8885 (set (reg:SI R8_REG) (unspec:SI [(reg:SI R8_REG)] UNSPEC_COMPACT_ARGS))
8886 (set (reg:SI R9_REG) (unspec:SI [(reg:SI R9_REG)] UNSPEC_COMPACT_ARGS))
8887 (set (mem:BLK (reg:SI MACL_REG))
8888 (unspec:BLK [(reg:SI MACH_REG)] UNSPEC_COMPACT_ARGS))
8889 (use (reg:SI R0_REG))
8890 (clobber (reg:SI R0_REG))
8891 (clobber (reg:SI MACL_REG))
8892 (clobber (reg:SI MACH_REG))
8893 (clobber (reg:SI PR_REG))]
8896 [(set_attr "needs_delay_slot" "yes")])
8898 (define_insn "shmedia_save_restore_regs_compact"
8899 [(set (reg:SI SP_REG)
8900 (plus:SI (reg:SI SP_REG)
8901 (match_operand:SI 0 "immediate_operand" "i")))
8902 (use (reg:SI R0_REG))
8903 (clobber (reg:SI PR_REG))]
8905 && (INTVAL (operands[0]) == SHMEDIA_REGS_STACK_ADJUST ()
8906 || INTVAL (operands[0]) == - SHMEDIA_REGS_STACK_ADJUST ())"
8908 [(set_attr "needs_delay_slot" "yes")])
8910 (define_expand "prologue"
8913 "sh_expand_prologue (); DONE;")
8915 (define_expand "epilogue"
8920 sh_expand_epilogue (0);
8921 emit_jump_insn (gen_return ());
8925 (define_expand "eh_return"
8926 [(use (match_operand 0 "register_operand" ""))]
8929 rtx ra = operands[0];
8931 if (TARGET_SHMEDIA64)
8932 emit_insn (gen_eh_set_ra_di (ra));
8934 emit_insn (gen_eh_set_ra_si (ra));
8939 ;; Clobber the return address on the stack. We can't expand this
8940 ;; until we know where it will be put in the stack frame.
8942 (define_insn "eh_set_ra_si"
8943 [(unspec [(match_operand:SI 0 "register_operand" "r")] UNSPEC_EH_RETURN)
8944 (clobber (match_scratch:SI 1 "=&r"))]
8945 "! TARGET_SHMEDIA64"
8948 (define_insn "eh_set_ra_di"
8949 [(unspec [(match_operand:DI 0 "register_operand" "r")] UNSPEC_EH_RETURN)
8950 (clobber (match_scratch:DI 1 "=&r"))]
8955 [(unspec [(match_operand 0 "register_operand" "")] UNSPEC_EH_RETURN)
8956 (clobber (match_scratch 1 ""))]
8961 sh_set_return_address (operands[0], operands[1]);
8965 (define_insn "blockage"
8966 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
8969 [(set_attr "length" "0")])
8971 ;; ------------------------------------------------------------------------
8973 ;; ------------------------------------------------------------------------
8976 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
8977 (eq:SI (reg:SI T_REG) (const_int 1)))]
8980 [(set_attr "type" "arith")])
8982 (define_expand "seq"
8983 [(set (match_operand:SI 0 "arith_reg_dest" "")
8990 sh_compare_op0 = force_reg (GET_MODE (sh_compare_op0), sh_compare_op0);
8991 if (sh_compare_op1 != const0_rtx)
8992 sh_compare_op1 = force_reg (GET_MODE (sh_compare_op1) == VOIDmode
8993 ? GET_MODE (sh_compare_op0)
8994 : GET_MODE (sh_compare_op1),
8996 if (GET_MODE_SIZE (GET_MODE (operands[0])) <= 4)
8998 if (GET_MODE (operands[0]) != SImode)
8999 operands[0] = gen_rtx_SUBREG (SImode, operands[0], 0);
9001 switch (GET_MODE (sh_compare_op0))
9004 emit_insn (gen_cmpsieqsi_media (operands[0],
9005 sh_compare_op0, sh_compare_op1));
9009 emit_insn (gen_cmpsieqdi_media (operands[0],
9010 sh_compare_op0, sh_compare_op1));
9014 if (! TARGET_SHMEDIA_FPU)
9016 emit_insn (gen_cmpsieqsf_media (operands[0],
9017 sh_compare_op0, sh_compare_op1));
9021 if (! TARGET_SHMEDIA_FPU)
9023 emit_insn (gen_cmpsieqdf_media (operands[0],
9024 sh_compare_op0, sh_compare_op1));
9033 if (GET_MODE (operands[0]) != DImode)
9034 operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
9036 switch (GET_MODE (sh_compare_op0))
9039 emit_insn (gen_cmpeqsi_media (operands[0],
9040 sh_compare_op0, sh_compare_op1));
9044 emit_insn (gen_cmpeqdi_media (operands[0],
9045 sh_compare_op0, sh_compare_op1));
9049 if (! TARGET_SHMEDIA_FPU)
9051 emit_insn (gen_cmpeqsf_media (operands[0],
9052 sh_compare_op0, sh_compare_op1));
9056 if (! TARGET_SHMEDIA_FPU)
9058 emit_insn (gen_cmpeqdf_media (operands[0],
9059 sh_compare_op0, sh_compare_op1));
9067 if (sh_expand_t_scc (EQ, operands[0]))
9069 if (! currently_expanding_to_rtl)
9071 operands[1] = prepare_scc_operands (EQ);
9074 (define_expand "slt"
9075 [(set (match_operand:SI 0 "arith_reg_operand" "")
9082 if (GET_MODE (operands[0]) != DImode)
9083 operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
9084 sh_compare_op0 = force_reg (GET_MODE (sh_compare_op0), sh_compare_op0);
9085 if (sh_compare_op1 != const0_rtx)
9086 sh_compare_op1 = force_reg (GET_MODE (sh_compare_op1) == VOIDmode
9087 ? GET_MODE (sh_compare_op0)
9088 : GET_MODE (sh_compare_op1),
9091 switch (GET_MODE (sh_compare_op0))
9094 emit_insn (gen_cmpgtsi_media (operands[0],
9095 sh_compare_op1, sh_compare_op0));
9099 emit_insn (gen_cmpgtdi_media (operands[0],
9100 sh_compare_op1, sh_compare_op0));
9104 if (! TARGET_SHMEDIA_FPU)
9106 emit_insn (gen_cmpgtsf_media (operands[0],
9107 sh_compare_op1, sh_compare_op0));
9111 if (! TARGET_SHMEDIA_FPU)
9113 emit_insn (gen_cmpgtdf_media (operands[0],
9114 sh_compare_op1, sh_compare_op0));
9122 if (! currently_expanding_to_rtl)
9124 operands[1] = prepare_scc_operands (LT);
9127 (define_expand "sle"
9128 [(match_operand:SI 0 "arith_reg_operand" "")]
9132 rtx tmp = sh_compare_op0;
9136 if (GET_MODE (operands[0]) != DImode)
9137 operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
9138 sh_compare_op0 = force_reg (GET_MODE (sh_compare_op0), sh_compare_op0);
9139 if (sh_compare_op1 != const0_rtx)
9140 sh_compare_op1 = force_reg (GET_MODE (sh_compare_op1) == VOIDmode
9141 ? GET_MODE (sh_compare_op0)
9142 : GET_MODE (sh_compare_op1),
9145 switch (GET_MODE (sh_compare_op0))
9149 tmp = no_new_pseudos ? operands[0] : gen_reg_rtx (DImode);
9151 emit_insn (gen_cmpgtsi_media (tmp,
9152 sh_compare_op0, sh_compare_op1));
9153 emit_insn (gen_cmpeqdi_media (operands[0], tmp, const0_rtx));
9159 tmp = no_new_pseudos ? operands[0] : gen_reg_rtx (DImode);
9161 emit_insn (gen_cmpgtdi_media (tmp,
9162 sh_compare_op0, sh_compare_op1));
9163 emit_insn (gen_cmpeqdi_media (operands[0], tmp, const0_rtx));
9168 if (! TARGET_SHMEDIA_FPU)
9170 emit_insn (gen_cmpgesf_media (operands[0],
9171 sh_compare_op1, sh_compare_op0));
9175 if (! TARGET_SHMEDIA_FPU)
9177 emit_insn (gen_cmpgedf_media (operands[0],
9178 sh_compare_op1, sh_compare_op0));
9187 sh_compare_op0 = sh_compare_op1;
9188 sh_compare_op1 = tmp;
9189 emit_insn (gen_sge (operands[0]));
9193 (define_expand "sgt"
9194 [(set (match_operand:SI 0 "arith_reg_operand" "")
9201 if (GET_MODE (operands[0]) != DImode)
9202 operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
9203 sh_compare_op0 = force_reg (GET_MODE (sh_compare_op0), sh_compare_op0);
9204 if (sh_compare_op1 != const0_rtx)
9205 sh_compare_op1 = force_reg (GET_MODE (sh_compare_op1) == VOIDmode
9206 ? GET_MODE (sh_compare_op0)
9207 : GET_MODE (sh_compare_op1),
9210 switch (GET_MODE (sh_compare_op0))
9213 emit_insn (gen_cmpgtsi_media (operands[0],
9214 sh_compare_op0, sh_compare_op1));
9218 emit_insn (gen_cmpgtdi_media (operands[0],
9219 sh_compare_op0, sh_compare_op1));
9223 if (! TARGET_SHMEDIA_FPU)
9225 emit_insn (gen_cmpgtsf_media (operands[0],
9226 sh_compare_op0, sh_compare_op1));
9230 if (! TARGET_SHMEDIA_FPU)
9232 emit_insn (gen_cmpgtdf_media (operands[0],
9233 sh_compare_op0, sh_compare_op1));
9241 if (! currently_expanding_to_rtl)
9243 operands[1] = prepare_scc_operands (GT);
9246 (define_expand "sge"
9247 [(set (match_operand:SI 0 "arith_reg_operand" "")
9254 enum machine_mode mode = GET_MODE (sh_compare_op0);
9256 if ((mode) == VOIDmode)
9257 mode = GET_MODE (sh_compare_op1);
9258 if (GET_MODE (operands[0]) != DImode)
9259 operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
9260 sh_compare_op0 = force_reg (mode, sh_compare_op0);
9261 if (sh_compare_op1 != const0_rtx)
9262 sh_compare_op1 = force_reg (mode, sh_compare_op1);
9268 rtx tmp = no_new_pseudos ? operands[0] : gen_reg_rtx (DImode);
9270 emit_insn (gen_cmpgtsi_media (tmp,
9271 sh_compare_op1, sh_compare_op0));
9272 emit_insn (gen_cmpeqdi_media (operands[0], tmp, const0_rtx));
9278 rtx tmp = no_new_pseudos ? operands[0] : gen_reg_rtx (DImode);
9280 emit_insn (gen_cmpgtdi_media (tmp,
9281 sh_compare_op1, sh_compare_op0));
9282 emit_insn (gen_cmpeqdi_media (operands[0], tmp, const0_rtx));
9287 if (! TARGET_SHMEDIA_FPU)
9289 emit_insn (gen_cmpgesf_media (operands[0],
9290 sh_compare_op0, sh_compare_op1));
9294 if (! TARGET_SHMEDIA_FPU)
9296 emit_insn (gen_cmpgedf_media (operands[0],
9297 sh_compare_op0, sh_compare_op1));
9306 if (! currently_expanding_to_rtl)
9308 if (GET_MODE_CLASS (GET_MODE (sh_compare_op0)) == MODE_FLOAT)
9312 rtx lab = gen_label_rtx ();
9313 prepare_scc_operands (EQ);
9314 emit_jump_insn (gen_branch_true (lab));
9315 prepare_scc_operands (GT);
9317 emit_insn (gen_movt (operands[0]));
9320 emit_insn (gen_movnegt (operands[0], prepare_scc_operands (LT)));
9323 operands[1] = prepare_scc_operands (GE);
9326 (define_expand "sgtu"
9327 [(set (match_operand:SI 0 "arith_reg_operand" "")
9334 if (GET_MODE (operands[0]) != DImode)
9335 operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
9336 sh_compare_op0 = force_reg (GET_MODE (sh_compare_op0), sh_compare_op0);
9337 if (sh_compare_op1 != const0_rtx)
9338 sh_compare_op1 = force_reg (GET_MODE (sh_compare_op1) == VOIDmode
9339 ? GET_MODE (sh_compare_op0)
9340 : GET_MODE (sh_compare_op1),
9343 emit_insn (gen_cmpgtudi_media (operands[0],
9344 sh_compare_op0, sh_compare_op1));
9347 if (! currently_expanding_to_rtl)
9349 operands[1] = prepare_scc_operands (GTU);
9352 (define_expand "sltu"
9353 [(set (match_operand:SI 0 "arith_reg_operand" "")
9360 if (GET_MODE (operands[0]) != DImode)
9361 operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
9362 sh_compare_op0 = force_reg (GET_MODE (sh_compare_op0), sh_compare_op0);
9363 if (sh_compare_op1 != const0_rtx)
9364 sh_compare_op1 = force_reg (GET_MODE (sh_compare_op1) == VOIDmode
9365 ? GET_MODE (sh_compare_op0)
9366 : GET_MODE (sh_compare_op1),
9369 emit_insn (gen_cmpgtudi_media (operands[0],
9370 sh_compare_op1, sh_compare_op0));
9373 if (! currently_expanding_to_rtl)
9375 operands[1] = prepare_scc_operands (LTU);
9378 (define_expand "sleu"
9379 [(set (match_operand:SI 0 "arith_reg_operand" "")
9388 if (GET_MODE (operands[0]) != DImode)
9389 operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
9390 sh_compare_op0 = force_reg (GET_MODE (sh_compare_op0), sh_compare_op0);
9391 if (sh_compare_op1 != const0_rtx)
9392 sh_compare_op1 = force_reg (GET_MODE (sh_compare_op1) == VOIDmode
9393 ? GET_MODE (sh_compare_op0)
9394 : GET_MODE (sh_compare_op1),
9397 tmp = no_new_pseudos ? operands[0] : gen_reg_rtx (DImode);
9399 emit_insn (gen_cmpgtudi_media (tmp, sh_compare_op0, sh_compare_op1));
9400 emit_insn (gen_cmpeqdi_media (operands[0], tmp, const0_rtx));
9404 if (! currently_expanding_to_rtl)
9406 operands[1] = prepare_scc_operands (LEU);
9409 (define_expand "sgeu"
9410 [(set (match_operand:SI 0 "arith_reg_operand" "")
9419 if (GET_MODE (operands[0]) != DImode)
9420 operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
9421 sh_compare_op0 = force_reg (GET_MODE (sh_compare_op0), sh_compare_op0);
9422 if (sh_compare_op1 != const0_rtx)
9423 sh_compare_op1 = force_reg (GET_MODE (sh_compare_op1) == VOIDmode
9424 ? GET_MODE (sh_compare_op0)
9425 : GET_MODE (sh_compare_op1),
9428 tmp = no_new_pseudos ? operands[0] : gen_reg_rtx (DImode);
9430 emit_insn (gen_cmpgtudi_media (tmp, sh_compare_op1, sh_compare_op0));
9431 emit_insn (gen_cmpeqdi_media (operands[0], tmp, const0_rtx));
9436 if (! currently_expanding_to_rtl)
9438 operands[1] = prepare_scc_operands (GEU);
9441 ;; sne moves the complement of the T reg to DEST like this:
9445 ;; This is better than xoring compare result with 1 because it does
9446 ;; not require r0 and further, the -1 may be CSE-ed or lifted out of a
9449 (define_expand "sne"
9450 [(set (match_dup 2) (const_int -1))
9451 (parallel [(set (match_operand:SI 0 "arith_reg_operand" "")
9452 (neg:SI (plus:SI (match_dup 1)
9455 (ne:SI (ior:SI (match_dup 1) (match_dup 2))
9464 if (GET_MODE (operands[0]) != DImode)
9465 operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
9467 if (! TARGET_SHMEDIA_FPU
9468 && GET_MODE (sh_compare_op0) != DImode
9469 && GET_MODE (sh_compare_op0) != SImode)
9472 sh_compare_op0 = force_reg (GET_MODE (sh_compare_op0), sh_compare_op0);
9473 if (sh_compare_op1 != const0_rtx)
9474 sh_compare_op1 = force_reg (GET_MODE (sh_compare_op1) == VOIDmode
9475 ? GET_MODE (sh_compare_op0)
9476 : GET_MODE (sh_compare_op1),
9479 tmp = no_new_pseudos ? operands[0] : gen_reg_rtx (DImode);
9481 emit_insn (gen_seq (tmp));
9482 emit_insn (gen_cmpeqdi_media (operands[0], tmp, const0_rtx));
9487 if (sh_expand_t_scc (NE, operands[0]))
9489 if (! currently_expanding_to_rtl)
9491 operands[1] = prepare_scc_operands (EQ);
9492 operands[2] = gen_reg_rtx (SImode);
9495 (define_expand "sunordered"
9496 [(set (match_operand:DI 0 "arith_reg_operand" "")
9497 (unordered:DI (match_dup 1) (match_dup 2)))]
9498 "TARGET_SHMEDIA_FPU"
9501 operands[1] = force_reg (GET_MODE (sh_compare_op0), sh_compare_op0);
9502 operands[2] = force_reg (GET_MODE (sh_compare_op1), sh_compare_op1);
9505 ;; Use the same trick for FP sle / sge
9507 ;; Apart from the constant use and the T setting, this is like movt,
9508 ;; except that it uses the logically negated value of T, i.e.
9509 ;; operand[0] := T ? 0 : 1.
9510 (define_expand "movnegt"
9511 [(set (match_dup 2) (const_int -1))
9512 (parallel [(set (match_operand 0 "" "")
9513 (neg:SI (plus:SI (match_dup 1)
9516 (ne:SI (ior:SI (match_operand 1 "" "") (match_dup 2))
9519 "operands[2] = gen_reg_rtx (SImode);")
9521 ;; Recognize mov #-1/negc/neg sequence, and change it to movt/add #-1.
9522 ;; This prevents a regression that occurred when we switched from xor to
9526 [(set (match_operand:SI 0 "arith_reg_dest" "")
9527 (plus:SI (reg:SI T_REG)
9530 [(set (match_dup 0) (eq:SI (reg:SI T_REG) (const_int 1)))
9531 (set (match_dup 0) (plus:SI (match_dup 0) (const_int -1)))]
9534 ;; -------------------------------------------------------------------------
9535 ;; Instructions to cope with inline literal tables
9536 ;; -------------------------------------------------------------------------
9538 ; 2 byte integer in line
9540 (define_insn "consttable_2"
9541 [(unspec_volatile [(match_operand:SI 0 "general_operand" "=g")
9542 (match_operand 1 "" "")]
9547 if (operands[1] != const0_rtx)
9548 assemble_integer (operands[0], 2, BITS_PER_UNIT * 2, 1);
9551 [(set_attr "length" "2")
9552 (set_attr "in_delay_slot" "no")])
9554 ; 4 byte integer in line
9556 (define_insn "consttable_4"
9557 [(unspec_volatile [(match_operand:SI 0 "general_operand" "=g")
9558 (match_operand 1 "" "")]
9563 if (operands[1] != const0_rtx)
9564 assemble_integer (operands[0], 4, BITS_PER_UNIT * 4, 1);
9567 [(set_attr "length" "4")
9568 (set_attr "in_delay_slot" "no")])
9570 ; 8 byte integer in line
9572 (define_insn "consttable_8"
9573 [(unspec_volatile [(match_operand:SI 0 "general_operand" "=g")
9574 (match_operand 1 "" "")]
9579 if (operands[1] != const0_rtx)
9580 assemble_integer (operands[0], 8, BITS_PER_UNIT * 8, 1);
9583 [(set_attr "length" "8")
9584 (set_attr "in_delay_slot" "no")])
9586 ; 4 byte floating point
9588 (define_insn "consttable_sf"
9589 [(unspec_volatile [(match_operand:SF 0 "general_operand" "=g")
9590 (match_operand 1 "" "")]
9595 if (operands[1] != const0_rtx)
9598 REAL_VALUE_FROM_CONST_DOUBLE (d, operands[0]);
9599 assemble_real (d, SFmode, GET_MODE_ALIGNMENT (SFmode));
9603 [(set_attr "length" "4")
9604 (set_attr "in_delay_slot" "no")])
9606 ; 8 byte floating point
9608 (define_insn "consttable_df"
9609 [(unspec_volatile [(match_operand:DF 0 "general_operand" "=g")
9610 (match_operand 1 "" "")]
9615 if (operands[1] != const0_rtx)
9618 REAL_VALUE_FROM_CONST_DOUBLE (d, operands[0]);
9619 assemble_real (d, DFmode, GET_MODE_ALIGNMENT (DFmode));
9623 [(set_attr "length" "8")
9624 (set_attr "in_delay_slot" "no")])
9626 ;; Alignment is needed for some constant tables; it may also be added for
9627 ;; Instructions at the start of loops, or after unconditional branches.
9628 ;; ??? We would get more accurate lengths if we did instruction
9629 ;; alignment based on the value of INSN_CURRENT_ADDRESS; the approach used
9630 ;; here is too conservative.
9632 ; align to a two byte boundary
9634 (define_expand "align_2"
9635 [(unspec_volatile [(const_int 1)] UNSPECV_ALIGN)]
9639 ; align to a four byte boundary
9640 ;; align_4 and align_log are instructions for the starts of loops, or
9641 ;; after unconditional branches, which may take up extra room.
9643 (define_expand "align_4"
9644 [(unspec_volatile [(const_int 2)] UNSPECV_ALIGN)]
9648 ; align to a cache line boundary
9650 (define_insn "align_log"
9651 [(unspec_volatile [(match_operand 0 "const_int_operand" "")] UNSPECV_ALIGN)]
9654 [(set_attr "length" "0")
9655 (set_attr "in_delay_slot" "no")])
9657 ; emitted at the end of the literal table, used to emit the
9658 ; 32bit branch labels if needed.
9660 (define_insn "consttable_end"
9661 [(unspec_volatile [(const_int 0)] UNSPECV_CONST_END)]
9663 "* return output_jump_label_table ();"
9664 [(set_attr "in_delay_slot" "no")])
9666 ; emitted at the end of the window in the literal table.
9668 (define_insn "consttable_window_end"
9669 [(unspec_volatile [(match_operand 0 "" "")] UNSPECV_WINDOW_END)]
9672 [(set_attr "length" "0")
9673 (set_attr "in_delay_slot" "no")])
9675 ;; -------------------------------------------------------------------------
9677 ;; -------------------------------------------------------------------------
9679 ;; String/block move insn.
9681 (define_expand "movmemsi"
9682 [(parallel [(set (mem:BLK (match_operand:BLK 0 "" ""))
9683 (mem:BLK (match_operand:BLK 1 "" "")))
9684 (use (match_operand:SI 2 "nonmemory_operand" ""))
9685 (use (match_operand:SI 3 "immediate_operand" ""))
9686 (clobber (reg:SI PR_REG))
9687 (clobber (reg:SI R4_REG))
9688 (clobber (reg:SI R5_REG))
9689 (clobber (reg:SI R0_REG))])]
9690 "TARGET_SH1 && ! TARGET_SH5"
9693 if(expand_block_move (operands))
9698 (define_insn "block_move_real"
9699 [(parallel [(set (mem:BLK (reg:SI R4_REG))
9700 (mem:BLK (reg:SI R5_REG)))
9701 (use (match_operand:SI 0 "arith_reg_operand" "r"))
9702 (clobber (reg:SI PR_REG))
9703 (clobber (reg:SI R0_REG))])]
9704 "TARGET_SH1 && ! TARGET_HARD_SH4"
9706 [(set_attr "type" "sfunc")
9707 (set_attr "needs_delay_slot" "yes")])
9709 (define_insn "block_lump_real"
9710 [(parallel [(set (mem:BLK (reg:SI R4_REG))
9711 (mem:BLK (reg:SI R5_REG)))
9712 (use (match_operand:SI 0 "arith_reg_operand" "r"))
9713 (use (reg:SI R6_REG))
9714 (clobber (reg:SI PR_REG))
9715 (clobber (reg:SI T_REG))
9716 (clobber (reg:SI R4_REG))
9717 (clobber (reg:SI R5_REG))
9718 (clobber (reg:SI R6_REG))
9719 (clobber (reg:SI R0_REG))])]
9720 "TARGET_SH1 && ! TARGET_HARD_SH4"
9722 [(set_attr "type" "sfunc")
9723 (set_attr "needs_delay_slot" "yes")])
9725 (define_insn "block_move_real_i4"
9726 [(parallel [(set (mem:BLK (reg:SI R4_REG))
9727 (mem:BLK (reg:SI R5_REG)))
9728 (use (match_operand:SI 0 "arith_reg_operand" "r"))
9729 (clobber (reg:SI PR_REG))
9730 (clobber (reg:SI R0_REG))
9731 (clobber (reg:SI R1_REG))
9732 (clobber (reg:SI R2_REG))])]
9735 [(set_attr "type" "sfunc")
9736 (set_attr "needs_delay_slot" "yes")])
9738 (define_insn "block_lump_real_i4"
9739 [(parallel [(set (mem:BLK (reg:SI R4_REG))
9740 (mem:BLK (reg:SI R5_REG)))
9741 (use (match_operand:SI 0 "arith_reg_operand" "r"))
9742 (use (reg:SI R6_REG))
9743 (clobber (reg:SI PR_REG))
9744 (clobber (reg:SI T_REG))
9745 (clobber (reg:SI R4_REG))
9746 (clobber (reg:SI R5_REG))
9747 (clobber (reg:SI R6_REG))
9748 (clobber (reg:SI R0_REG))
9749 (clobber (reg:SI R1_REG))
9750 (clobber (reg:SI R2_REG))
9751 (clobber (reg:SI R3_REG))])]
9754 [(set_attr "type" "sfunc")
9755 (set_attr "needs_delay_slot" "yes")])
9757 ;; -------------------------------------------------------------------------
9758 ;; Floating point instructions.
9759 ;; -------------------------------------------------------------------------
9761 ;; ??? All patterns should have a type attribute.
9763 (define_expand "movpsi"
9764 [(set (match_operand:PSI 0 "register_operand" "")
9765 (match_operand:PSI 1 "general_movsrc_operand" ""))]
9766 "(TARGET_SH4 || TARGET_SH2A_DOUBLE)"
9769 ;; The c / m alternative is a fake to guide reload to load directly into
9770 ;; fpscr, since reload doesn't know how to use post-increment.
9771 ;; GO_IF_LEGITIMATE_ADDRESS guards about bogus addresses before reload,
9772 ;; SECONDARY_INPUT_RELOAD_CLASS does this during reload, and the insn's
9773 ;; predicate after reload.
9774 ;; The mac_gp type for r/!c might look a bit odd, but it actually schedules
9775 ;; like a mac -> gpr move.
9776 (define_insn "fpu_switch"
9777 [(set (match_operand:PSI 0 "general_movdst_operand" "=c,c,r,c,c,r,m,r,<")
9778 (match_operand:PSI 1 "general_movsrc_operand" "c,>,m,m,r,r,r,!c,c"))]
9780 && (! reload_completed
9781 || true_regnum (operands[0]) != FPSCR_REG
9782 || GET_CODE (operands[1]) != MEM
9783 || GET_CODE (XEXP (operands[1], 0)) != PLUS)"
9785 ! precision stays the same
9794 [(set_attr "length" "0,2,2,4,2,2,2,2,2")
9795 (set_attr "type" "nil,mem_fpscr,load,mem_fpscr,gp_fpscr,move,store,mac_gp,store")])
9798 [(set (reg:PSI FPSCR_REG)
9799 (mem:PSI (match_operand:SI 0 "register_operand" "")))]
9800 "(TARGET_SH4 || TARGET_SH2A_DOUBLE) && peep2_reg_dead_p (1, operands[0])"
9803 rtx fpscr, mem, new_insn;
9805 fpscr = SET_DEST (PATTERN (curr_insn));
9806 mem = SET_SRC (PATTERN (curr_insn));
9807 mem = replace_equiv_address (mem, gen_rtx_POST_INC (Pmode, operands[0]));
9809 new_insn = emit_insn (gen_fpu_switch (fpscr, mem));
9810 REG_NOTES (new_insn) = gen_rtx_EXPR_LIST (REG_INC, operands[0], NULL_RTX);
9815 [(set (reg:PSI FPSCR_REG)
9816 (mem:PSI (match_operand:SI 0 "register_operand" "")))]
9817 "(TARGET_SH4 || TARGET_SH2A_DOUBLE)
9818 && (flag_peephole2 ? flow2_completed : reload_completed)"
9821 rtx fpscr, mem, new_insn;
9823 fpscr = SET_DEST (PATTERN (curr_insn));
9824 mem = SET_SRC (PATTERN (curr_insn));
9825 mem = replace_equiv_address (mem, gen_rtx_POST_INC (Pmode, operands[0]));
9827 new_insn = emit_insn (gen_fpu_switch (fpscr, mem));
9828 REG_NOTES (new_insn) = gen_rtx_EXPR_LIST (REG_INC, operands[0], NULL_RTX);
9830 if (!find_regno_note (curr_insn, REG_DEAD, true_regnum (operands[0])))
9831 emit_insn (gen_addsi3 (operands[0], operands[0], GEN_INT (-4)));
9835 ;; ??? This uses the fp unit, but has no type indicating that.
9836 ;; If we did that, this would either give a bogus latency or introduce
9837 ;; a bogus FIFO constraint.
9838 ;; Since this insn is currently only used for prologues/epilogues,
9839 ;; it is probably best to claim no function unit, which matches the
9841 (define_insn "toggle_sz"
9842 [(set (reg:PSI FPSCR_REG)
9843 (xor:PSI (reg:PSI FPSCR_REG) (const_int 1048576)))]
9844 "(TARGET_SH4 || TARGET_SH2A_DOUBLE)"
9846 [(set_attr "type" "fp") (set_attr "fp_set" "unknown")])
9848 ;; There's no way we can use it today, since optimize mode switching
9849 ;; doesn't enable us to know from which mode we're switching to the
9850 ;; mode it requests, to tell whether we can use a relative mode switch
9851 ;; (like toggle_pr) or an absolute switch (like loading fpscr from
9853 (define_insn "toggle_pr"
9854 [(set (reg:PSI FPSCR_REG)
9855 (xor:PSI (reg:PSI FPSCR_REG) (const_int 524288)))]
9856 "TARGET_SH4A_FP && ! TARGET_FPU_SINGLE"
9858 [(set_attr "type" "fp")])
9860 (define_expand "addsf3"
9861 [(set (match_operand:SF 0 "arith_reg_operand" "")
9862 (plus:SF (match_operand:SF 1 "arith_reg_operand" "")
9863 (match_operand:SF 2 "arith_reg_operand" "")))]
9864 "TARGET_SH2E || TARGET_SHMEDIA_FPU"
9869 expand_sf_binop (&gen_addsf3_i, operands);
9874 (define_insn "*addsf3_media"
9875 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
9876 (plus:SF (match_operand:SF 1 "fp_arith_reg_operand" "%f")
9877 (match_operand:SF 2 "fp_arith_reg_operand" "f")))]
9878 "TARGET_SHMEDIA_FPU"
9880 [(set_attr "type" "fparith_media")])
9882 (define_insn_and_split "unary_sf_op"
9883 [(set (match_operand:V2SF 0 "fp_arith_reg_operand" "=f")
9888 (parallel [(not:BI (match_operand 3 "const_int_operand" "n"))]))
9889 (match_operator:SF 2 "unary_float_operator"
9890 [(vec_select:SF (match_operand:V2SF 1 "fp_arith_reg_operand" "f")
9891 (parallel [(match_operand 4
9892 "const_int_operand" "n")]))]))
9893 (parallel [(not:BI (match_dup 3)) (match_dup 3)])))]
9894 "TARGET_SHMEDIA_FPU"
9896 "TARGET_SHMEDIA_FPU && reload_completed"
9897 [(set (match_dup 5) (match_dup 6))]
9900 int endian = TARGET_LITTLE_ENDIAN ? 0 : 1;
9901 rtx op1 = gen_rtx_REG (SFmode,
9902 (true_regnum (operands[1])
9903 + (INTVAL (operands[4]) ^ endian)));
9905 operands[7] = gen_rtx_REG (SFmode,
9906 (true_regnum (operands[0])
9907 + (INTVAL (operands[3]) ^ endian)));
9908 operands[6] = gen_rtx_fmt_e (GET_CODE (operands[2]), SFmode, op1);
9910 [(set_attr "type" "fparith_media")])
9912 (define_insn_and_split "binary_sf_op"
9913 [(set (match_operand:V2SF 0 "fp_arith_reg_operand" "=f")
9918 (parallel [(match_operand 7 "const_int_operand" "n")]))
9919 (match_operator:SF 3 "binary_float_operator"
9920 [(vec_select:SF (match_operand:V2SF 1 "fp_arith_reg_operand" "f")
9921 (parallel [(match_operand 5
9922 "const_int_operand" "n")]))
9923 (vec_select:SF (match_operand:V2SF 2 "fp_arith_reg_operand" "f")
9924 (parallel [(match_operand 6
9925 "const_int_operand" "n")]))]))
9926 (parallel [(match_dup 7) (match_operand 4 "const_int_operand" "n")])))]
9927 "TARGET_SHMEDIA_FPU && INTVAL (operands[4]) != INTVAL (operands[7])"
9929 "&& reload_completed"
9930 [(set (match_dup 8) (match_dup 9))]
9933 int endian = TARGET_LITTLE_ENDIAN ? 0 : 1;
9934 rtx op1 = gen_rtx_REG (SFmode,
9935 (true_regnum (operands[1])
9936 + (INTVAL (operands[5]) ^ endian)));
9937 rtx op2 = gen_rtx_REG (SFmode,
9938 (true_regnum (operands[2])
9939 + (INTVAL (operands[6]) ^ endian)));
9941 operands[8] = gen_rtx_REG (SFmode,
9942 (true_regnum (operands[0])
9943 + (INTVAL (operands[4]) ^ endian)));
9944 operands[9] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SFmode, op1, op2);
9946 [(set_attr "type" "fparith_media")])
9948 (define_insn "addsf3_i"
9949 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
9950 (plus:SF (match_operand:SF 1 "fp_arith_reg_operand" "%0")
9951 (match_operand:SF 2 "fp_arith_reg_operand" "f")))
9952 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
9955 [(set_attr "type" "fp")
9956 (set_attr "fp_mode" "single")])
9958 (define_expand "subsf3"
9959 [(set (match_operand:SF 0 "fp_arith_reg_operand" "")
9960 (minus:SF (match_operand:SF 1 "fp_arith_reg_operand" "")
9961 (match_operand:SF 2 "fp_arith_reg_operand" "")))]
9962 "TARGET_SH2E || TARGET_SHMEDIA_FPU"
9967 expand_sf_binop (&gen_subsf3_i, operands);
9972 (define_insn "*subsf3_media"
9973 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
9974 (minus:SF (match_operand:SF 1 "fp_arith_reg_operand" "f")
9975 (match_operand:SF 2 "fp_arith_reg_operand" "f")))]
9976 "TARGET_SHMEDIA_FPU"
9978 [(set_attr "type" "fparith_media")])
9980 (define_insn "subsf3_i"
9981 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
9982 (minus:SF (match_operand:SF 1 "fp_arith_reg_operand" "0")
9983 (match_operand:SF 2 "fp_arith_reg_operand" "f")))
9984 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
9987 [(set_attr "type" "fp")
9988 (set_attr "fp_mode" "single")])
9990 ;; Unfortunately, the combiner is unable to cope with the USE of the FPSCR
9991 ;; register in feeding fp instructions. Thus, we cannot generate fmac for
9992 ;; mixed-precision SH4 targets. To allow it to be still generated for the
9993 ;; SH3E, we use a separate insn for SH3E mulsf3.
9995 (define_expand "mulsf3"
9996 [(set (match_operand:SF 0 "fp_arith_reg_operand" "")
9997 (mult:SF (match_operand:SF 1 "fp_arith_reg_operand" "")
9998 (match_operand:SF 2 "fp_arith_reg_operand" "")))]
9999 "TARGET_SH2E || TARGET_SHMEDIA_FPU"
10002 if (TARGET_SH4 || TARGET_SH2A_SINGLE)
10003 expand_sf_binop (&gen_mulsf3_i4, operands);
10004 else if (TARGET_SH2E)
10005 emit_insn (gen_mulsf3_ie (operands[0], operands[1], operands[2]));
10006 if (! TARGET_SHMEDIA)
10010 (define_insn "*mulsf3_media"
10011 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
10012 (mult:SF (match_operand:SF 1 "fp_arith_reg_operand" "%f")
10013 (match_operand:SF 2 "fp_arith_reg_operand" "f")))]
10014 "TARGET_SHMEDIA_FPU"
10015 "fmul.s %1, %2, %0"
10016 [(set_attr "type" "fparith_media")])
10018 (define_insn "mulsf3_i4"
10019 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
10020 (mult:SF (match_operand:SF 1 "fp_arith_reg_operand" "%0")
10021 (match_operand:SF 2 "fp_arith_reg_operand" "f")))
10022 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
10025 [(set_attr "type" "fp")
10026 (set_attr "fp_mode" "single")])
10028 (define_insn "mulsf3_ie"
10029 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
10030 (mult:SF (match_operand:SF 1 "fp_arith_reg_operand" "%0")
10031 (match_operand:SF 2 "fp_arith_reg_operand" "f")))]
10032 "TARGET_SH2E && ! (TARGET_SH4 || TARGET_SH2A_SINGLE)"
10034 [(set_attr "type" "fp")])
10036 (define_insn "mac_media"
10037 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
10038 (plus:SF (mult:SF (match_operand:SF 1 "fp_arith_reg_operand" "%f")
10039 (match_operand:SF 2 "fp_arith_reg_operand" "f"))
10040 (match_operand:SF 3 "fp_arith_reg_operand" "0")))]
10041 "TARGET_SHMEDIA_FPU"
10042 "fmac.s %1, %2, %0"
10043 [(set_attr "type" "fparith_media")])
10045 (define_insn "*macsf3"
10046 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
10047 (plus:SF (mult:SF (match_operand:SF 1 "fp_arith_reg_operand" "%w")
10048 (match_operand:SF 2 "fp_arith_reg_operand" "f"))
10049 (match_operand:SF 3 "arith_reg_operand" "0")))
10050 (use (match_operand:PSI 4 "fpscr_operand" "c"))]
10051 "TARGET_SH2E && ! TARGET_SH4"
10053 [(set_attr "type" "fp")
10054 (set_attr "fp_mode" "single")])
10056 (define_expand "divsf3"
10057 [(set (match_operand:SF 0 "arith_reg_operand" "")
10058 (div:SF (match_operand:SF 1 "arith_reg_operand" "")
10059 (match_operand:SF 2 "arith_reg_operand" "")))]
10060 "TARGET_SH2E || TARGET_SHMEDIA_FPU"
10065 expand_sf_binop (&gen_divsf3_i, operands);
10070 (define_insn "*divsf3_media"
10071 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
10072 (div:SF (match_operand:SF 1 "fp_arith_reg_operand" "f")
10073 (match_operand:SF 2 "fp_arith_reg_operand" "f")))]
10074 "TARGET_SHMEDIA_FPU"
10075 "fdiv.s %1, %2, %0"
10076 [(set_attr "type" "fdiv_media")])
10078 (define_insn "divsf3_i"
10079 [(set (match_operand:SF 0 "arith_reg_dest" "=f")
10080 (div:SF (match_operand:SF 1 "arith_reg_operand" "0")
10081 (match_operand:SF 2 "arith_reg_operand" "f")))
10082 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
10085 [(set_attr "type" "fdiv")
10086 (set_attr "fp_mode" "single")])
10088 (define_insn "floatdisf2"
10089 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
10090 (float:SF (match_operand:DI 1 "fp_arith_reg_operand" "f")))]
10091 "TARGET_SHMEDIA_FPU"
10093 [(set_attr "type" "fpconv_media")])
10095 (define_expand "floatsisf2"
10096 [(set (match_operand:SF 0 "fp_arith_reg_operand" "")
10097 (float:SF (match_operand:SI 1 "fpul_operand" "")))]
10098 "TARGET_SH2E || TARGET_SHMEDIA_FPU"
10101 if (TARGET_SH4 || TARGET_SH2A_SINGLE)
10103 emit_sf_insn (gen_floatsisf2_i4 (operands[0], operands[1], get_fpscr_rtx ()));
10108 (define_insn "*floatsisf2_media"
10109 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
10110 (float:SF (match_operand:SI 1 "fp_arith_reg_operand" "f")))]
10111 "TARGET_SHMEDIA_FPU"
10113 [(set_attr "type" "fpconv_media")])
10115 (define_insn "floatsisf2_i4"
10116 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
10117 (float:SF (match_operand:SI 1 "fpul_operand" "y")))
10118 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
10119 "(TARGET_SH4 || TARGET_SH2A_SINGLE)"
10121 [(set_attr "type" "fp")
10122 (set_attr "fp_mode" "single")])
10124 (define_insn "*floatsisf2_ie"
10125 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
10126 (float:SF (match_operand:SI 1 "fpul_operand" "y")))]
10127 "TARGET_SH2E && ! (TARGET_SH4 || TARGET_SH2A_SINGLE)"
10129 [(set_attr "type" "fp")])
10131 (define_insn "fix_truncsfdi2"
10132 [(set (match_operand:DI 0 "fp_arith_reg_dest" "=f")
10133 (fix:DI (match_operand:SF 1 "fp_arith_reg_operand" "f")))]
10134 "TARGET_SHMEDIA_FPU"
10136 [(set_attr "type" "fpconv_media")])
10138 (define_expand "fix_truncsfsi2"
10139 [(set (match_operand:SI 0 "fpul_operand" "=y")
10140 (fix:SI (match_operand:SF 1 "fp_arith_reg_operand" "f")))]
10141 "TARGET_SH2E || TARGET_SHMEDIA_FPU"
10144 if (TARGET_SH4 || TARGET_SH2A_SINGLE)
10146 emit_sf_insn (gen_fix_truncsfsi2_i4 (operands[0], operands[1], get_fpscr_rtx ()));
10151 (define_insn "*fix_truncsfsi2_media"
10152 [(set (match_operand:SI 0 "fp_arith_reg_operand" "=f")
10153 (fix:SI (match_operand:SF 1 "fp_arith_reg_operand" "f")))]
10154 "TARGET_SHMEDIA_FPU"
10156 [(set_attr "type" "fpconv_media")])
10158 (define_insn "fix_truncsfsi2_i4"
10159 [(set (match_operand:SI 0 "fpul_operand" "=y")
10160 (fix:SI (match_operand:SF 1 "fp_arith_reg_operand" "f")))
10161 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
10162 "(TARGET_SH4 || TARGET_SH2A_SINGLE)"
10164 [(set_attr "type" "ftrc_s")
10165 (set_attr "fp_mode" "single")])
10167 ;; ??? This pattern is used nowhere. fix_truncsfsi2 always expands to
10168 ;; fix_truncsfsi2_i4.
10169 ;; (define_insn "fix_truncsfsi2_i4_2"
10170 ;; [(set (match_operand:SI 0 "arith_reg_operand" "=r")
10171 ;; (fix:SI (match_operand:SF 1 "arith_reg_operand" "f")))
10172 ;; (use (reg:PSI FPSCR_REG))
10173 ;; (clobber (reg:SI FPUL_REG))]
10176 ;; [(set_attr "length" "4")
10177 ;; (set_attr "fp_mode" "single")])
10180 ;; [(set (match_operand:SI 0 "arith_reg_operand" "=r")
10181 ;; (fix:SI (match_operand:SF 1 "arith_reg_operand" "f")))
10182 ;; (use (match_operand:PSI 2 "fpscr_operand" "c"))
10183 ;; (clobber (reg:SI FPUL_REG))]
10185 ;; [(parallel [(set (reg:SI FPUL_REG) (fix:SI (match_dup 1)))
10186 ;; (use (match_dup 2))])
10187 ;; (set (match_dup 0) (reg:SI FPUL_REG))])
10189 (define_insn "*fixsfsi"
10190 [(set (match_operand:SI 0 "fpul_operand" "=y")
10191 (fix:SI (match_operand:SF 1 "fp_arith_reg_operand" "f")))]
10192 "TARGET_SH2E && ! (TARGET_SH4 || TARGET_SH2A_SINGLE)"
10194 [(set_attr "type" "fp")])
10196 (define_insn "cmpgtsf_t"
10197 [(set (reg:SI T_REG)
10198 (gt:SI (match_operand:SF 0 "fp_arith_reg_operand" "f")
10199 (match_operand:SF 1 "fp_arith_reg_operand" "f")))]
10200 "TARGET_SH2E && ! (TARGET_SH4 || TARGET_SH2A_SINGLE)"
10202 [(set_attr "type" "fp")
10203 (set_attr "fp_mode" "single")])
10205 (define_insn "cmpeqsf_t"
10206 [(set (reg:SI T_REG)
10207 (eq:SI (match_operand:SF 0 "fp_arith_reg_operand" "f")
10208 (match_operand:SF 1 "fp_arith_reg_operand" "f")))]
10209 "TARGET_SH2E && ! (TARGET_SH4 || TARGET_SH2A_SINGLE)"
10211 [(set_attr "type" "fp")
10212 (set_attr "fp_mode" "single")])
10214 (define_insn "ieee_ccmpeqsf_t"
10215 [(set (reg:SI T_REG)
10216 (ior:SI (reg:SI T_REG)
10217 (eq:SI (match_operand:SF 0 "fp_arith_reg_operand" "f")
10218 (match_operand:SF 1 "fp_arith_reg_operand" "f"))))]
10219 "TARGET_SH2E && TARGET_IEEE && ! (TARGET_SH4 || TARGET_SH2A_SINGLE)"
10220 "* return output_ieee_ccmpeq (insn, operands);"
10221 [(set_attr "length" "4")])
10224 (define_insn "cmpgtsf_t_i4"
10225 [(set (reg:SI T_REG)
10226 (gt:SI (match_operand:SF 0 "fp_arith_reg_operand" "f")
10227 (match_operand:SF 1 "fp_arith_reg_operand" "f")))
10228 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
10229 "(TARGET_SH4 || TARGET_SH2A_SINGLE)"
10231 [(set_attr "type" "fp")
10232 (set_attr "fp_mode" "single")])
10234 (define_insn "cmpeqsf_t_i4"
10235 [(set (reg:SI T_REG)
10236 (eq:SI (match_operand:SF 0 "fp_arith_reg_operand" "f")
10237 (match_operand:SF 1 "fp_arith_reg_operand" "f")))
10238 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
10239 "(TARGET_SH4 || TARGET_SH2A_SINGLE)"
10241 [(set_attr "type" "fp")
10242 (set_attr "fp_mode" "single")])
10244 (define_insn "*ieee_ccmpeqsf_t_4"
10245 [(set (reg:SI T_REG)
10246 (ior:SI (reg:SI T_REG)
10247 (eq:SI (match_operand:SF 0 "fp_arith_reg_operand" "f")
10248 (match_operand:SF 1 "fp_arith_reg_operand" "f"))))
10249 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
10250 "TARGET_IEEE && (TARGET_SH4 || TARGET_SH2A_SINGLE)"
10251 "* return output_ieee_ccmpeq (insn, operands);"
10252 [(set_attr "length" "4")
10253 (set_attr "fp_mode" "single")])
10255 (define_insn "cmpeqsf_media"
10256 [(set (match_operand:DI 0 "register_operand" "=r")
10257 (eq:DI (match_operand:SF 1 "fp_arith_reg_operand" "f")
10258 (match_operand:SF 2 "fp_arith_reg_operand" "f")))]
10259 "TARGET_SHMEDIA_FPU"
10260 "fcmpeq.s %1, %2, %0"
10261 [(set_attr "type" "fcmp_media")])
10263 (define_insn "cmpsieqsf_media"
10264 [(set (match_operand:SI 0 "register_operand" "=r")
10265 (eq:SI (match_operand:SF 1 "fp_arith_reg_operand" "f")
10266 (match_operand:SF 2 "fp_arith_reg_operand" "f")))]
10267 "TARGET_SHMEDIA_FPU"
10268 "fcmpeq.s %1, %2, %0"
10269 [(set_attr "type" "fcmp_media")])
10271 (define_insn "cmpgtsf_media"
10272 [(set (match_operand:DI 0 "register_operand" "=r")
10273 (gt:DI (match_operand:SF 1 "fp_arith_reg_operand" "f")
10274 (match_operand:SF 2 "fp_arith_reg_operand" "f")))]
10275 "TARGET_SHMEDIA_FPU"
10276 "fcmpgt.s %1, %2, %0"
10277 [(set_attr "type" "fcmp_media")])
10279 (define_insn "cmpgesf_media"
10280 [(set (match_operand:DI 0 "register_operand" "=r")
10281 (ge:DI (match_operand:SF 1 "fp_arith_reg_operand" "f")
10282 (match_operand:SF 2 "fp_arith_reg_operand" "f")))]
10283 "TARGET_SHMEDIA_FPU"
10284 "fcmpge.s %1, %2, %0"
10285 [(set_attr "type" "fcmp_media")])
10287 (define_insn "cmpunsf_media"
10288 [(set (match_operand:DI 0 "register_operand" "=r")
10289 (unordered:DI (match_operand:SF 1 "fp_arith_reg_operand" "f")
10290 (match_operand:SF 2 "fp_arith_reg_operand" "f")))]
10291 "TARGET_SHMEDIA_FPU"
10292 "fcmpun.s %1, %2, %0"
10293 [(set_attr "type" "fcmp_media")])
10295 (define_expand "cmpsf"
10296 [(set (reg:SI T_REG)
10297 (compare (match_operand:SF 0 "arith_operand" "")
10298 (match_operand:SF 1 "arith_operand" "")))]
10299 "TARGET_SH2E || TARGET_SHMEDIA_FPU"
10302 sh_compare_op0 = operands[0];
10303 sh_compare_op1 = operands[1];
10307 (define_expand "negsf2"
10308 [(set (match_operand:SF 0 "fp_arith_reg_operand" "")
10309 (neg:SF (match_operand:SF 1 "fp_arith_reg_operand" "")))]
10310 "TARGET_SH2E || TARGET_SHMEDIA_FPU"
10315 expand_sf_unop (&gen_negsf2_i, operands);
10320 (define_insn "*negsf2_media"
10321 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
10322 (neg:SF (match_operand:SF 1 "fp_arith_reg_operand" "f")))]
10323 "TARGET_SHMEDIA_FPU"
10325 [(set_attr "type" "fmove_media")])
10327 (define_insn "negsf2_i"
10328 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
10329 (neg:SF (match_operand:SF 1 "fp_arith_reg_operand" "0")))
10330 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
10333 [(set_attr "type" "fmove")
10334 (set_attr "fp_mode" "single")])
10336 (define_expand "sqrtsf2"
10337 [(set (match_operand:SF 0 "fp_arith_reg_operand" "")
10338 (sqrt:SF (match_operand:SF 1 "fp_arith_reg_operand" "")))]
10339 "TARGET_SH3E || TARGET_SHMEDIA_FPU"
10344 expand_sf_unop (&gen_sqrtsf2_i, operands);
10349 (define_insn "*sqrtsf2_media"
10350 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
10351 (sqrt:SF (match_operand:SF 1 "fp_arith_reg_operand" "f")))]
10352 "TARGET_SHMEDIA_FPU"
10354 [(set_attr "type" "fdiv_media")])
10356 (define_insn "sqrtsf2_i"
10357 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
10358 (sqrt:SF (match_operand:SF 1 "fp_arith_reg_operand" "0")))
10359 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
10362 [(set_attr "type" "fdiv")
10363 (set_attr "fp_mode" "single")])
10365 (define_insn "rsqrtsf2"
10366 [(set (match_operand:SF 0 "register_operand" "=f")
10367 (div:SF (match_operand:SF 1 "immediate_operand" "i")
10368 (sqrt:SF (match_operand:SF 2 "register_operand" "0"))))
10369 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
10370 "TARGET_SH4A_FP && flag_unsafe_math_optimizations
10371 && operands[1] == CONST1_RTX (SFmode)"
10373 [(set_attr "type" "fsrra")
10374 (set_attr "fp_mode" "single")])
10376 (define_insn "fsca"
10377 [(set (match_operand:V2SF 0 "fp_arith_reg_operand" "=f")
10379 (unspec:SF [(mult:SF
10380 (float:SF (match_operand:SI 1 "fpul_operand" "y"))
10381 (match_operand:SF 2 "immediate_operand" "i"))
10383 (unspec:SF [(mult:SF (float:SF (match_dup 1)) (match_dup 2))
10385 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
10386 "TARGET_SH4A_FP && flag_unsafe_math_optimizations
10387 && operands[2] == sh_fsca_int2sf ()"
10389 [(set_attr "type" "fsca")
10390 (set_attr "fp_mode" "single")])
10392 (define_expand "sinsf2"
10393 [(set (match_operand:SF 0 "nonimmediate_operand" "")
10394 (unspec:SF [(match_operand:SF 1 "fp_arith_reg_operand" "")]
10396 "TARGET_SH4A_FP && flag_unsafe_math_optimizations"
10399 rtx scaled = gen_reg_rtx (SFmode);
10400 rtx truncated = gen_reg_rtx (SImode);
10401 rtx fsca = gen_reg_rtx (V2SFmode);
10402 rtx scale_reg = force_reg (SFmode, sh_fsca_sf2int ());
10404 emit_sf_insn (gen_mulsf3 (scaled, operands[1], scale_reg));
10405 emit_sf_insn (gen_fix_truncsfsi2 (truncated, scaled));
10406 emit_sf_insn (gen_fsca (fsca, truncated, sh_fsca_int2sf (),
10407 get_fpscr_rtx ()));
10408 emit_move_insn (operands[0], gen_rtx_SUBREG (SFmode, fsca, 0));
10412 (define_expand "cossf2"
10413 [(set (match_operand:SF 0 "nonimmediate_operand" "")
10414 (unspec:SF [(match_operand:SF 1 "fp_arith_reg_operand" "")]
10416 "TARGET_SH4A_FP && flag_unsafe_math_optimizations"
10419 rtx scaled = gen_reg_rtx (SFmode);
10420 rtx truncated = gen_reg_rtx (SImode);
10421 rtx fsca = gen_reg_rtx (V2SFmode);
10422 rtx scale_reg = force_reg (SFmode, sh_fsca_sf2int ());
10424 emit_sf_insn (gen_mulsf3 (scaled, operands[1], scale_reg));
10425 emit_sf_insn (gen_fix_truncsfsi2 (truncated, scaled));
10426 emit_sf_insn (gen_fsca (fsca, truncated, sh_fsca_int2sf (),
10427 get_fpscr_rtx ()));
10428 emit_move_insn (operands[0], gen_rtx_SUBREG (SFmode, fsca, 4));
10432 (define_expand "sindf2"
10433 [(set (match_operand:DF 0 "fp_arith_reg_operand" "")
10434 (unspec:DF [(match_operand:DF 1 "fp_arith_reg_operand" "")]
10436 "TARGET_SH4A_FP && ! TARGET_FPU_SINGLE && flag_unsafe_math_optimizations"
10439 rtx scaled = gen_reg_rtx (DFmode);
10440 rtx truncated = gen_reg_rtx (SImode);
10441 rtx fsca = gen_reg_rtx (V2SFmode);
10442 rtx scale_reg = force_reg (DFmode, sh_fsca_df2int ());
10443 rtx sfresult = gen_reg_rtx (SFmode);
10445 emit_df_insn (gen_muldf3 (scaled, operands[1], scale_reg));
10446 emit_df_insn (gen_fix_truncdfsi2 (truncated, scaled));
10447 emit_sf_insn (gen_fsca (fsca, truncated, sh_fsca_int2sf (),
10448 get_fpscr_rtx ()));
10449 emit_move_insn (sfresult, gen_rtx_SUBREG (SFmode, fsca, 0));
10450 emit_df_insn (gen_extendsfdf2 (operands[0], sfresult));
10454 (define_expand "cosdf2"
10455 [(set (match_operand:DF 0 "fp_arith_reg_operand" "")
10456 (unspec:DF [(match_operand:DF 1 "fp_arith_reg_operand" "")]
10458 "TARGET_SH4A_FP && ! TARGET_FPU_SINGLE && flag_unsafe_math_optimizations"
10461 rtx scaled = gen_reg_rtx (DFmode);
10462 rtx truncated = gen_reg_rtx (SImode);
10463 rtx fsca = gen_reg_rtx (V2SFmode);
10464 rtx scale_reg = force_reg (DFmode, sh_fsca_df2int ());
10465 rtx sfresult = gen_reg_rtx (SFmode);
10467 emit_df_insn (gen_muldf3 (scaled, operands[1], scale_reg));
10468 emit_df_insn (gen_fix_truncdfsi2 (truncated, scaled));
10469 emit_sf_insn (gen_fsca (fsca, truncated, sh_fsca_int2sf (),
10470 get_fpscr_rtx ()));
10471 emit_move_insn (sfresult, gen_rtx_SUBREG (SFmode, fsca, 4));
10472 emit_df_insn (gen_extendsfdf2 (operands[0], sfresult));
10476 (define_expand "abssf2"
10477 [(set (match_operand:SF 0 "fp_arith_reg_operand" "")
10478 (abs:SF (match_operand:SF 1 "fp_arith_reg_operand" "")))]
10479 "TARGET_SH2E || TARGET_SHMEDIA_FPU"
10484 expand_sf_unop (&gen_abssf2_i, operands);
10489 (define_insn "*abssf2_media"
10490 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
10491 (abs:SF (match_operand:SF 1 "fp_arith_reg_operand" "f")))]
10492 "TARGET_SHMEDIA_FPU"
10494 [(set_attr "type" "fmove_media")])
10496 (define_insn "abssf2_i"
10497 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
10498 (abs:SF (match_operand:SF 1 "fp_arith_reg_operand" "0")))
10499 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
10502 [(set_attr "type" "fmove")
10503 (set_attr "fp_mode" "single")])
10505 (define_expand "adddf3"
10506 [(set (match_operand:DF 0 "fp_arith_reg_operand" "")
10507 (plus:DF (match_operand:DF 1 "fp_arith_reg_operand" "")
10508 (match_operand:DF 2 "fp_arith_reg_operand" "")))]
10509 "(TARGET_SH4 || TARGET_SH2A_DOUBLE) || TARGET_SHMEDIA_FPU"
10512 if (TARGET_SH4 || TARGET_SH2A_DOUBLE)
10514 expand_df_binop (&gen_adddf3_i, operands);
10519 (define_insn "*adddf3_media"
10520 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
10521 (plus:DF (match_operand:DF 1 "fp_arith_reg_operand" "%f")
10522 (match_operand:DF 2 "fp_arith_reg_operand" "f")))]
10523 "TARGET_SHMEDIA_FPU"
10524 "fadd.d %1, %2, %0"
10525 [(set_attr "type" "dfparith_media")])
10527 (define_insn "adddf3_i"
10528 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
10529 (plus:DF (match_operand:DF 1 "fp_arith_reg_operand" "%0")
10530 (match_operand:DF 2 "fp_arith_reg_operand" "f")))
10531 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
10532 "(TARGET_SH4 || TARGET_SH2A_DOUBLE)"
10534 [(set_attr "type" "dfp_arith")
10535 (set_attr "fp_mode" "double")])
10537 (define_expand "subdf3"
10538 [(set (match_operand:DF 0 "fp_arith_reg_operand" "")
10539 (minus:DF (match_operand:DF 1 "fp_arith_reg_operand" "")
10540 (match_operand:DF 2 "fp_arith_reg_operand" "")))]
10541 "(TARGET_SH4 || TARGET_SH2A_DOUBLE) || TARGET_SHMEDIA_FPU"
10544 if (TARGET_SH4 || TARGET_SH2A_DOUBLE)
10546 expand_df_binop (&gen_subdf3_i, operands);
10551 (define_insn "*subdf3_media"
10552 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
10553 (minus:DF (match_operand:DF 1 "fp_arith_reg_operand" "f")
10554 (match_operand:DF 2 "fp_arith_reg_operand" "f")))]
10555 "TARGET_SHMEDIA_FPU"
10556 "fsub.d %1, %2, %0"
10557 [(set_attr "type" "dfparith_media")])
10559 (define_insn "subdf3_i"
10560 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
10561 (minus:DF (match_operand:DF 1 "fp_arith_reg_operand" "0")
10562 (match_operand:DF 2 "fp_arith_reg_operand" "f")))
10563 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
10564 "(TARGET_SH4 || TARGET_SH2A_DOUBLE)"
10566 [(set_attr "type" "dfp_arith")
10567 (set_attr "fp_mode" "double")])
10569 (define_expand "muldf3"
10570 [(set (match_operand:DF 0 "fp_arith_reg_operand" "")
10571 (mult:DF (match_operand:DF 1 "fp_arith_reg_operand" "")
10572 (match_operand:DF 2 "fp_arith_reg_operand" "")))]
10573 "(TARGET_SH4 || TARGET_SH2A_DOUBLE) || TARGET_SHMEDIA_FPU"
10576 if (TARGET_SH4 || TARGET_SH2A_DOUBLE)
10578 expand_df_binop (&gen_muldf3_i, operands);
10583 (define_insn "*muldf3_media"
10584 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
10585 (mult:DF (match_operand:DF 1 "fp_arith_reg_operand" "%f")
10586 (match_operand:DF 2 "fp_arith_reg_operand" "f")))]
10587 "TARGET_SHMEDIA_FPU"
10588 "fmul.d %1, %2, %0"
10589 [(set_attr "type" "dfmul_media")])
10591 (define_insn "muldf3_i"
10592 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
10593 (mult:DF (match_operand:DF 1 "fp_arith_reg_operand" "%0")
10594 (match_operand:DF 2 "fp_arith_reg_operand" "f")))
10595 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
10596 "(TARGET_SH4 || TARGET_SH2A_DOUBLE)"
10598 [(set_attr "type" "dfp_arith")
10599 (set_attr "fp_mode" "double")])
10601 (define_expand "divdf3"
10602 [(set (match_operand:DF 0 "fp_arith_reg_operand" "")
10603 (div:DF (match_operand:DF 1 "fp_arith_reg_operand" "")
10604 (match_operand:DF 2 "fp_arith_reg_operand" "")))]
10605 "(TARGET_SH4 || TARGET_SH2A_DOUBLE) || TARGET_SHMEDIA_FPU"
10608 if (TARGET_SH4 || TARGET_SH2A_DOUBLE)
10610 expand_df_binop (&gen_divdf3_i, operands);
10615 (define_insn "*divdf3_media"
10616 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
10617 (div:DF (match_operand:DF 1 "fp_arith_reg_operand" "f")
10618 (match_operand:DF 2 "fp_arith_reg_operand" "f")))]
10619 "TARGET_SHMEDIA_FPU"
10620 "fdiv.d %1, %2, %0"
10621 [(set_attr "type" "dfdiv_media")])
10623 (define_insn "divdf3_i"
10624 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
10625 (div:DF (match_operand:DF 1 "fp_arith_reg_operand" "0")
10626 (match_operand:DF 2 "fp_arith_reg_operand" "f")))
10627 (use (match_operand:PSI 3 "fpscr_operand" "c"))]
10628 "(TARGET_SH4 || TARGET_SH2A_DOUBLE)"
10630 [(set_attr "type" "dfdiv")
10631 (set_attr "fp_mode" "double")])
10633 (define_insn "floatdidf2"
10634 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
10635 (float:DF (match_operand:DI 1 "fp_arith_reg_operand" "f")))]
10636 "TARGET_SHMEDIA_FPU"
10638 [(set_attr "type" "dfpconv_media")])
10640 (define_expand "floatsidf2"
10641 [(set (match_operand:DF 0 "fp_arith_reg_operand" "")
10642 (float:DF (match_operand:SI 1 "fpul_operand" "")))]
10643 "(TARGET_SH4 || TARGET_SH2A_DOUBLE) || TARGET_SHMEDIA_FPU"
10646 if (TARGET_SH4 || TARGET_SH2A_DOUBLE)
10648 emit_df_insn (gen_floatsidf2_i (operands[0], operands[1],
10649 get_fpscr_rtx ()));
10654 (define_insn "*floatsidf2_media"
10655 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
10656 (float:DF (match_operand:SI 1 "fp_arith_reg_operand" "f")))]
10657 "TARGET_SHMEDIA_FPU"
10659 [(set_attr "type" "dfpconv_media")])
10661 (define_insn "floatsidf2_i"
10662 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
10663 (float:DF (match_operand:SI 1 "fpul_operand" "y")))
10664 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
10665 "(TARGET_SH4 || TARGET_SH2A_DOUBLE)"
10667 [(set_attr "type" "dfp_conv")
10668 (set_attr "fp_mode" "double")])
10670 (define_insn "fix_truncdfdi2"
10671 [(set (match_operand:DI 0 "fp_arith_reg_dest" "=f")
10672 (fix:DI (match_operand:DF 1 "fp_arith_reg_operand" "f")))]
10673 "TARGET_SHMEDIA_FPU"
10675 [(set_attr "type" "dfpconv_media")])
10677 (define_expand "fix_truncdfsi2"
10678 [(set (match_operand:SI 0 "fpul_operand" "")
10679 (fix:SI (match_operand:DF 1 "fp_arith_reg_operand" "")))]
10680 "(TARGET_SH4 || TARGET_SH2A_DOUBLE) || TARGET_SHMEDIA_FPU"
10683 if (TARGET_SH4 || TARGET_SH2A_DOUBLE)
10685 emit_df_insn (gen_fix_truncdfsi2_i (operands[0], operands[1],
10686 get_fpscr_rtx ()));
10691 (define_insn "*fix_truncdfsi2_media"
10692 [(set (match_operand:SI 0 "fp_arith_reg_operand" "=f")
10693 (fix:SI (match_operand:DF 1 "fp_arith_reg_operand" "f")))]
10694 "TARGET_SHMEDIA_FPU"
10696 [(set_attr "type" "dfpconv_media")])
10698 (define_insn "fix_truncdfsi2_i"
10699 [(set (match_operand:SI 0 "fpul_operand" "=y")
10700 (fix:SI (match_operand:DF 1 "fp_arith_reg_operand" "f")))
10701 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
10702 "(TARGET_SH4 || TARGET_SH2A_DOUBLE)"
10704 [(set_attr "type" "dfp_conv")
10705 (set_attr "dfp_comp" "no")
10706 (set_attr "fp_mode" "double")])
10708 ;; ??? This pattern is used nowhere. fix_truncdfsi2 always expands to
10709 ;; fix_truncdfsi2_i.
10710 ;; (define_insn "fix_truncdfsi2_i4"
10711 ;; [(set (match_operand:SI 0 "arith_reg_operand" "=r")
10712 ;; (fix:SI (match_operand:DF 1 "arith_reg_operand" "f")))
10713 ;; (use (match_operand:PSI 2 "fpscr_operand" "c"))
10714 ;; (clobber (reg:SI FPUL_REG))]
10717 ;; [(set_attr "length" "4")
10718 ;; (set_attr "fp_mode" "double")])
10721 ;; [(set (match_operand:SI 0 "arith_reg_operand" "=r")
10722 ;; (fix:SI (match_operand:DF 1 "arith_reg_operand" "f")))
10723 ;; (use (match_operand:PSI 2 "fpscr_operand" "c"))
10724 ;; (clobber (reg:SI FPUL_REG))]
10726 ;; [(parallel [(set (reg:SI FPUL_REG) (fix:SI (match_dup 1)))
10727 ;; (use (match_dup 2))])
10728 ;; (set (match_dup 0) (reg:SI FPUL_REG))])
10730 (define_insn "cmpgtdf_t"
10731 [(set (reg:SI T_REG)
10732 (gt:SI (match_operand:DF 0 "arith_reg_operand" "f")
10733 (match_operand:DF 1 "arith_reg_operand" "f")))
10734 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
10735 "(TARGET_SH4 || TARGET_SH2A_DOUBLE)"
10737 [(set_attr "type" "dfp_cmp")
10738 (set_attr "fp_mode" "double")])
10740 (define_insn "cmpeqdf_t"
10741 [(set (reg:SI T_REG)
10742 (eq:SI (match_operand:DF 0 "arith_reg_operand" "f")
10743 (match_operand:DF 1 "arith_reg_operand" "f")))
10744 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
10745 "(TARGET_SH4 || TARGET_SH2A_DOUBLE)"
10747 [(set_attr "type" "dfp_cmp")
10748 (set_attr "fp_mode" "double")])
10750 (define_insn "*ieee_ccmpeqdf_t"
10751 [(set (reg:SI T_REG)
10752 (ior:SI (reg:SI T_REG)
10753 (eq:SI (match_operand:DF 0 "arith_reg_operand" "f")
10754 (match_operand:DF 1 "arith_reg_operand" "f"))))
10755 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
10756 "TARGET_IEEE && (TARGET_SH4 || TARGET_SH2A_DOUBLE)"
10757 "* return output_ieee_ccmpeq (insn, operands);"
10758 [(set_attr "length" "4")
10759 (set_attr "fp_mode" "double")])
10761 (define_insn "cmpeqdf_media"
10762 [(set (match_operand:DI 0 "register_operand" "=r")
10763 (eq:DI (match_operand:DF 1 "fp_arith_reg_operand" "f")
10764 (match_operand:DF 2 "fp_arith_reg_operand" "f")))]
10765 "TARGET_SHMEDIA_FPU"
10766 "fcmpeq.d %1,%2,%0"
10767 [(set_attr "type" "fcmp_media")])
10769 (define_insn "cmpsieqdf_media"
10770 [(set (match_operand:SI 0 "register_operand" "=r")
10771 (eq:SI (match_operand:DF 1 "fp_arith_reg_operand" "f")
10772 (match_operand:DF 2 "fp_arith_reg_operand" "f")))]
10773 "TARGET_SHMEDIA_FPU"
10774 "fcmpeq.d %1,%2,%0"
10775 [(set_attr "type" "fcmp_media")])
10777 (define_insn "cmpgtdf_media"
10778 [(set (match_operand:DI 0 "register_operand" "=r")
10779 (gt:DI (match_operand:DF 1 "fp_arith_reg_operand" "f")
10780 (match_operand:DF 2 "fp_arith_reg_operand" "f")))]
10781 "TARGET_SHMEDIA_FPU"
10782 "fcmpgt.d %1,%2,%0"
10783 [(set_attr "type" "fcmp_media")])
10785 (define_insn "cmpgedf_media"
10786 [(set (match_operand:DI 0 "register_operand" "=r")
10787 (ge:DI (match_operand:DF 1 "fp_arith_reg_operand" "f")
10788 (match_operand:DF 2 "fp_arith_reg_operand" "f")))]
10789 "TARGET_SHMEDIA_FPU"
10790 "fcmpge.d %1,%2,%0"
10791 [(set_attr "type" "fcmp_media")])
10793 (define_insn "cmpundf_media"
10794 [(set (match_operand:DI 0 "register_operand" "=r")
10795 (unordered:DI (match_operand:DF 1 "fp_arith_reg_operand" "f")
10796 (match_operand:DF 2 "fp_arith_reg_operand" "f")))]
10797 "TARGET_SHMEDIA_FPU"
10798 "fcmpun.d %1,%2,%0"
10799 [(set_attr "type" "fcmp_media")])
10801 (define_expand "cmpdf"
10802 [(set (reg:SI T_REG)
10803 (compare (match_operand:DF 0 "arith_operand" "")
10804 (match_operand:DF 1 "arith_operand" "")))]
10805 "(TARGET_SH4 || TARGET_SH2A_DOUBLE) || TARGET_SHMEDIA_FPU"
10808 sh_compare_op0 = operands[0];
10809 sh_compare_op1 = operands[1];
10813 (define_expand "negdf2"
10814 [(set (match_operand:DF 0 "arith_reg_operand" "")
10815 (neg:DF (match_operand:DF 1 "arith_reg_operand" "")))]
10816 "(TARGET_SH4 || TARGET_SH2A_DOUBLE) || TARGET_SHMEDIA_FPU"
10819 if (TARGET_SH4 || TARGET_SH2A_DOUBLE)
10821 expand_df_unop (&gen_negdf2_i, operands);
10826 (define_insn "*negdf2_media"
10827 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
10828 (neg:DF (match_operand:DF 1 "fp_arith_reg_operand" "f")))]
10829 "TARGET_SHMEDIA_FPU"
10831 [(set_attr "type" "fmove_media")])
10833 (define_insn "negdf2_i"
10834 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
10835 (neg:DF (match_operand:DF 1 "fp_arith_reg_operand" "0")))
10836 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
10837 "(TARGET_SH4 || TARGET_SH2A_DOUBLE)"
10839 [(set_attr "type" "fmove")
10840 (set_attr "fp_mode" "double")])
10842 (define_expand "sqrtdf2"
10843 [(set (match_operand:DF 0 "arith_reg_operand" "")
10844 (sqrt:DF (match_operand:DF 1 "arith_reg_operand" "")))]
10845 "(TARGET_SH4 || TARGET_SH2A_DOUBLE) || TARGET_SHMEDIA_FPU"
10848 if (TARGET_SH4 || TARGET_SH2A_DOUBLE)
10850 expand_df_unop (&gen_sqrtdf2_i, operands);
10855 (define_insn "*sqrtdf2_media"
10856 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
10857 (sqrt:DF (match_operand:DF 1 "fp_arith_reg_operand" "f")))]
10858 "TARGET_SHMEDIA_FPU"
10860 [(set_attr "type" "dfdiv_media")])
10862 (define_insn "sqrtdf2_i"
10863 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
10864 (sqrt:DF (match_operand:DF 1 "fp_arith_reg_operand" "0")))
10865 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
10866 "(TARGET_SH4 || TARGET_SH2A_DOUBLE)"
10868 [(set_attr "type" "dfdiv")
10869 (set_attr "fp_mode" "double")])
10871 (define_expand "absdf2"
10872 [(set (match_operand:DF 0 "arith_reg_operand" "")
10873 (abs:DF (match_operand:DF 1 "arith_reg_operand" "")))]
10874 "(TARGET_SH4 || TARGET_SH2A_DOUBLE) || TARGET_SHMEDIA_FPU"
10877 if (TARGET_SH4 || TARGET_SH2A_DOUBLE)
10879 expand_df_unop (&gen_absdf2_i, operands);
10884 (define_insn "*absdf2_media"
10885 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
10886 (abs:DF (match_operand:DF 1 "fp_arith_reg_operand" "f")))]
10887 "TARGET_SHMEDIA_FPU"
10889 [(set_attr "type" "fmove_media")])
10891 (define_insn "absdf2_i"
10892 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
10893 (abs:DF (match_operand:DF 1 "fp_arith_reg_operand" "0")))
10894 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
10895 "(TARGET_SH4 || TARGET_SH2A_DOUBLE)"
10897 [(set_attr "type" "fmove")
10898 (set_attr "fp_mode" "double")])
10900 (define_expand "extendsfdf2"
10901 [(set (match_operand:DF 0 "fp_arith_reg_operand" "")
10902 (float_extend:DF (match_operand:SF 1 "fpul_operand" "")))]
10903 "(TARGET_SH4 || TARGET_SH2A_DOUBLE) || TARGET_SHMEDIA_FPU"
10906 if (TARGET_SH4 || TARGET_SH2A_DOUBLE)
10908 emit_df_insn (gen_extendsfdf2_i4 (operands[0], operands[1],
10909 get_fpscr_rtx ()));
10914 (define_insn "*extendsfdf2_media"
10915 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
10916 (float_extend:DF (match_operand:SF 1 "fp_arith_reg_operand" "f")))]
10917 "TARGET_SHMEDIA_FPU"
10919 [(set_attr "type" "dfpconv_media")])
10921 (define_insn "extendsfdf2_i4"
10922 [(set (match_operand:DF 0 "fp_arith_reg_operand" "=f")
10923 (float_extend:DF (match_operand:SF 1 "fpul_operand" "y")))
10924 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
10925 "(TARGET_SH4 || TARGET_SH2A_DOUBLE)"
10927 [(set_attr "type" "fp")
10928 (set_attr "fp_mode" "double")])
10930 (define_expand "truncdfsf2"
10931 [(set (match_operand:SF 0 "fpul_operand" "")
10932 (float_truncate:SF (match_operand:DF 1 "fp_arith_reg_operand" "")))]
10933 "(TARGET_SH4 || TARGET_SH2A_DOUBLE) || TARGET_SHMEDIA_FPU"
10936 if (TARGET_SH4 || TARGET_SH2A_DOUBLE)
10938 emit_df_insn (gen_truncdfsf2_i4 (operands[0], operands[1],
10939 get_fpscr_rtx ()));
10944 (define_insn "*truncdfsf2_media"
10945 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
10946 (float_truncate:SF (match_operand:DF 1 "fp_arith_reg_operand" "f")))]
10947 "TARGET_SHMEDIA_FPU"
10949 [(set_attr "type" "dfpconv_media")])
10951 (define_insn "truncdfsf2_i4"
10952 [(set (match_operand:SF 0 "fpul_operand" "=y")
10953 (float_truncate:SF (match_operand:DF 1 "fp_arith_reg_operand" "f")))
10954 (use (match_operand:PSI 2 "fpscr_operand" "c"))]
10955 "(TARGET_SH4 || TARGET_SH2A_DOUBLE)"
10957 [(set_attr "type" "fp")
10958 (set_attr "fp_mode" "double")])
10960 ;; Bit field extract patterns. These give better code for packed bitfields,
10961 ;; because they allow auto-increment addresses to be generated.
10963 (define_expand "insv"
10964 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "")
10965 (match_operand:SI 1 "immediate_operand" "")
10966 (match_operand:SI 2 "immediate_operand" ""))
10967 (match_operand:SI 3 "general_operand" ""))]
10968 "TARGET_SH1 && ! TARGET_LITTLE_ENDIAN"
10971 rtx addr_target, orig_address, shift_reg, qi_val;
10972 HOST_WIDE_INT bitsize, size, v = 0;
10973 rtx x = operands[3];
10975 /* ??? expmed doesn't care for non-register predicates. */
10976 if (! memory_operand (operands[0], VOIDmode)
10977 || ! immediate_operand (operands[1], VOIDmode)
10978 || ! immediate_operand (operands[2], VOIDmode)
10979 || ! general_operand (x, VOIDmode))
10981 /* If this isn't a 16 / 24 / 32 bit field, or if
10982 it doesn't start on a byte boundary, then fail. */
10983 bitsize = INTVAL (operands[1]);
10984 if (bitsize < 16 || bitsize > 32 || bitsize % 8 != 0
10985 || (INTVAL (operands[2]) % 8) != 0)
10988 size = bitsize / 8;
10989 orig_address = XEXP (operands[0], 0);
10990 shift_reg = gen_reg_rtx (SImode);
10991 if (GET_CODE (x) == CONST_INT)
10994 qi_val = force_reg (QImode, GEN_INT (trunc_int_for_mode (v, QImode)));
10998 emit_insn (gen_movsi (shift_reg, operands[3]));
10999 qi_val = gen_rtx_SUBREG (QImode, shift_reg, 3);
11001 addr_target = copy_addr_to_reg (plus_constant (orig_address, size - 1));
11003 operands[0] = replace_equiv_address (operands[0], addr_target);
11004 emit_insn (gen_movqi (operands[0], qi_val));
11008 if (GET_CODE (x) == CONST_INT)
11010 = force_reg (QImode, GEN_INT (trunc_int_for_mode (v >>= 8, QImode)));
11013 emit_insn (gen_lshrsi3_k (shift_reg, shift_reg, GEN_INT (8)));
11014 qi_val = gen_rtx_SUBREG (QImode, shift_reg, 3);
11016 emit_insn (gen_addsi3 (addr_target, addr_target, constm1_rtx));
11017 emit_insn (gen_movqi (operands[0], qi_val));
11023 (define_insn "movua"
11024 [(set (match_operand:SI 0 "register_operand" "=z")
11025 (sign_extract:SI (match_operand:SI 1 "unaligned_load_operand" "Sua>")
11026 (const_int 32) (const_int 0)))]
11029 [(set_attr "type" "movua")])
11031 ;; We shouldn't need this, but cse replaces increments with references
11032 ;; to other regs before flow has a chance to create post_inc
11033 ;; addressing modes, and only postreload's cse_move2add brings the
11034 ;; increments back to a usable form.
11036 [(set (match_operand:SI 0 "register_operand" "")
11037 (sign_extract:SI (mem:SI (match_operand:SI 1 "register_operand" ""))
11038 (const_int 32) (const_int 0)))
11039 (set (match_dup 1) (plus:SI (match_dup 1) (const_int 4)))]
11040 "TARGET_SH4A_ARCH && REGNO (operands[0]) != REGNO (operands[1])"
11041 [(set (match_operand:SI 0 "register_operand" "")
11042 (sign_extract:SI (mem:SI (post_inc:SI
11043 (match_operand:SI 1 "register_operand" "")))
11044 (const_int 32) (const_int 0)))]
11047 (define_expand "extv"
11048 [(set (match_operand:SI 0 "register_operand" "")
11049 (sign_extract:SI (match_operand:QI 1 "unaligned_load_operand" "")
11050 (match_operand 2 "const_int_operand" "")
11051 (match_operand 3 "const_int_operand" "")))]
11054 if (TARGET_SH4A_ARCH
11055 && INTVAL (operands[2]) == 32
11056 && INTVAL (operands[3]) == -24 * (BITS_BIG_ENDIAN != BYTES_BIG_ENDIAN)
11057 && GET_CODE (operands[1]) == MEM && MEM_ALIGN (operands[1]) < 32)
11059 emit_insn (gen_movua (operands[0],
11060 adjust_address (operands[1], SImode, 0)));
11067 (define_expand "extzv"
11068 [(set (match_operand:SI 0 "register_operand" "")
11069 (zero_extract:SI (match_operand:QI 1 "unaligned_load_operand" "")
11070 (match_operand 2 "const_int_operand" "")
11071 (match_operand 3 "const_int_operand" "")))]
11074 if (TARGET_SH4A_ARCH
11075 && INTVAL (operands[2]) == 32
11076 && INTVAL (operands[3]) == -24 * (BITS_BIG_ENDIAN != BYTES_BIG_ENDIAN)
11077 && GET_CODE (operands[1]) == MEM && MEM_ALIGN (operands[1]) < 32)
11079 emit_insn (gen_movua (operands[0],
11080 adjust_address (operands[1], SImode, 0)));
11088 ;; -------------------------------------------------------------------------
11090 ;; -------------------------------------------------------------------------
11092 ;; This matches cases where a stack pointer increment at the start of the
11093 ;; epilogue combines with a stack slot read loading the return value.
11096 [(set (match_operand:SI 0 "arith_reg_operand" "")
11097 (mem:SI (match_operand:SI 1 "arith_reg_operand" "")))
11098 (set (match_dup 1) (plus:SI (match_dup 1) (const_int 4)))]
11099 "TARGET_SH1 && REGNO (operands[1]) != REGNO (operands[0])"
11102 ;; See the comment on the dt combiner pattern above.
11105 [(set (match_operand:SI 0 "arith_reg_operand" "=r")
11106 (plus:SI (match_dup 0)
11108 (set (reg:SI T_REG)
11109 (eq:SI (match_dup 0)
11114 ;; These convert sequences such as `mov #k,r0; add r15,r0; mov.l @r0,rn'
11115 ;; to `mov #k,r0; mov.l @(r0,r15),rn'. These sequences are generated by
11116 ;; reload when the constant is too large for a reg+offset address.
11118 ;; ??? We would get much better code if this was done in reload. This would
11119 ;; require modifying find_reloads_address to recognize that if the constant
11120 ;; is out-of-range for an immediate add, then we get better code by reloading
11121 ;; the constant into a register than by reloading the sum into a register,
11122 ;; since the former is one instruction shorter if the address does not need
11123 ;; to be offsettable. Unfortunately this does not work, because there is
11124 ;; only one register, r0, that can be used as an index register. This register
11125 ;; is also the function return value register. So, if we try to force reload
11126 ;; to use double-reg addresses, then we end up with some instructions that
11127 ;; need to use r0 twice. The only way to fix this is to change the calling
11128 ;; convention so that r0 is not used to return values.
11131 [(set (match_operand:SI 0 "register_operand" "=r")
11132 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
11133 (set (mem:SI (match_dup 0))
11134 (match_operand:SI 2 "general_movsrc_operand" ""))]
11135 "TARGET_SH1 && REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
11136 "mov.l %2,@(%0,%1)")
11139 [(set (match_operand:SI 0 "register_operand" "=r")
11140 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
11141 (set (match_operand:SI 2 "general_movdst_operand" "")
11142 (mem:SI (match_dup 0)))]
11143 "TARGET_SH1 && REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
11144 "mov.l @(%0,%1),%2")
11147 [(set (match_operand:SI 0 "register_operand" "=r")
11148 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
11149 (set (mem:HI (match_dup 0))
11150 (match_operand:HI 2 "general_movsrc_operand" ""))]
11151 "TARGET_SH1 && REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
11152 "mov.w %2,@(%0,%1)")
11155 [(set (match_operand:SI 0 "register_operand" "=r")
11156 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
11157 (set (match_operand:HI 2 "general_movdst_operand" "")
11158 (mem:HI (match_dup 0)))]
11159 "TARGET_SH1 && REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
11160 "mov.w @(%0,%1),%2")
11163 [(set (match_operand:SI 0 "register_operand" "=r")
11164 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
11165 (set (mem:QI (match_dup 0))
11166 (match_operand:QI 2 "general_movsrc_operand" ""))]
11167 "TARGET_SH1 && REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
11168 "mov.b %2,@(%0,%1)")
11171 [(set (match_operand:SI 0 "register_operand" "=r")
11172 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
11173 (set (match_operand:QI 2 "general_movdst_operand" "")
11174 (mem:QI (match_dup 0)))]
11175 "TARGET_SH1 && REGNO (operands[0]) == 0 && reg_unused_after (operands[0], insn)"
11176 "mov.b @(%0,%1),%2")
11179 [(set (match_operand:SI 0 "register_operand" "=r")
11180 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
11181 (set (mem:SF (match_dup 0))
11182 (match_operand:SF 2 "general_movsrc_operand" ""))]
11183 "TARGET_SH1 && REGNO (operands[0]) == 0
11184 && ((GET_CODE (operands[2]) == REG && REGNO (operands[2]) < 16)
11185 || (GET_CODE (operands[2]) == SUBREG
11186 && REGNO (SUBREG_REG (operands[2])) < 16))
11187 && reg_unused_after (operands[0], insn)"
11188 "mov.l %2,@(%0,%1)")
11191 [(set (match_operand:SI 0 "register_operand" "=r")
11192 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
11193 (set (match_operand:SF 2 "general_movdst_operand" "")
11195 (mem:SF (match_dup 0)))]
11196 "TARGET_SH1 && REGNO (operands[0]) == 0
11197 && ((GET_CODE (operands[2]) == REG && REGNO (operands[2]) < 16)
11198 || (GET_CODE (operands[2]) == SUBREG
11199 && REGNO (SUBREG_REG (operands[2])) < 16))
11200 && reg_unused_after (operands[0], insn)"
11201 "mov.l @(%0,%1),%2")
11204 [(set (match_operand:SI 0 "register_operand" "=r")
11205 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
11206 (set (mem:SF (match_dup 0))
11207 (match_operand:SF 2 "general_movsrc_operand" ""))]
11208 "TARGET_SH2E && REGNO (operands[0]) == 0
11209 && ((GET_CODE (operands[2]) == REG
11210 && FP_OR_XD_REGISTER_P (REGNO (operands[2])))
11211 || (GET_CODE (operands[2]) == SUBREG
11212 && FP_OR_XD_REGISTER_P (REGNO (SUBREG_REG (operands[2])))))
11213 && reg_unused_after (operands[0], insn)"
11214 "fmov{.s|} %2,@(%0,%1)")
11217 [(set (match_operand:SI 0 "register_operand" "=r")
11218 (plus:SI (match_dup 0) (match_operand:SI 1 "register_operand" "r")))
11219 (set (match_operand:SF 2 "general_movdst_operand" "")
11221 (mem:SF (match_dup 0)))]
11222 "TARGET_SH2E && REGNO (operands[0]) == 0
11223 && ((GET_CODE (operands[2]) == REG
11224 && FP_OR_XD_REGISTER_P (REGNO (operands[2])))
11225 || (GET_CODE (operands[2]) == SUBREG
11226 && FP_OR_XD_REGISTER_P (REGNO (SUBREG_REG (operands[2])))))
11227 && reg_unused_after (operands[0], insn)"
11228 "fmov{.s|} @(%0,%1),%2")
11230 ;; Switch to a new stack with its address in sp_switch (a SYMBOL_REF). */
11231 (define_insn "sp_switch_1"
11238 xoperands[0] = sp_switch;
11239 output_asm_insn (\"mov.l r0,@-r15\;mov.l %0,r0\", xoperands);
11240 output_asm_insn (\"mov.l @r0,r0\;mov.l r15,@-r0\", xoperands);
11241 return \"mov r0,r15\";
11243 [(set_attr "length" "10")])
11245 ;; Switch back to the original stack for interrupt functions with the
11246 ;; sp_switch attribute. */
11247 (define_insn "sp_switch_2"
11250 "mov.l @r15+,r15\;mov.l @r15+,r0"
11251 [(set_attr "length" "4")])
11253 ;; Integer vector moves
11255 (define_expand "movv8qi"
11256 [(set (match_operand:V8QI 0 "general_movdst_operand" "")
11257 (match_operand:V8QI 1 "general_movsrc_operand" ""))]
11259 "{ if (prepare_move_operands (operands, V8QImode)) DONE; }")
11261 (define_insn "movv8qi_i"
11262 [(set (match_operand:V8QI 0 "general_movdst_operand" "=r,r,r,rl,m")
11263 (match_operand:V8QI 1 "general_movsrc_operand" "r,I16C16Z,nW,m,rlZ"))]
11265 && (register_operand (operands[0], V8QImode)
11266 || sh_register_operand (operands[1], V8QImode))"
11273 [(set_attr "type" "arith_media,arith_media,*,load_media,store_media")
11274 (set_attr "length" "4,4,16,4,4")])
11277 [(set (match_operand:V8QI 0 "arith_reg_dest" "")
11278 (subreg:V8QI (const_int 0) 0))]
11280 [(set (match_dup 0)
11281 (const_vector:V8QI [(const_int 0) (const_int 0) (const_int 0)
11282 (const_int 0) (const_int 0) (const_int 0)
11283 (const_int 0) (const_int 0)]))])
11286 [(set (match_operand 0 "arith_reg_dest" "")
11287 (match_operand 1 "sh_rep_vec" ""))]
11288 "TARGET_SHMEDIA && reload_completed
11289 && GET_MODE (operands[0]) == GET_MODE (operands[1])
11290 && sh_vector_mode_supported_p (GET_MODE (operands[0]))
11291 && GET_MODE_SIZE (GET_MODE (operands[0])) == 8
11292 && (XVECEXP (operands[1], 0, 0) != const0_rtx
11293 || XVECEXP (operands[1], 0, 1) != const0_rtx)
11294 && (XVECEXP (operands[1], 0, 0) != constm1_rtx
11295 || XVECEXP (operands[1], 0, 1) != constm1_rtx)"
11296 [(set (match_dup 0) (match_dup 1))
11300 int unit_size = GET_MODE_UNIT_SIZE (GET_MODE (operands[1]));
11301 rtx elt1 = XVECEXP (operands[1], 0, 1);
11304 operands[2] = gen_mshflo_l (operands[0], operands[0], operands[0]);
11308 operands[0] = gen_rtx_REG (V4HImode, true_regnum (operands[0]));
11309 operands[2] = gen_mperm_w0 (operands[0], operands[0]);
11311 operands[0] = gen_rtx_REG (DImode, true_regnum (operands[0]));
11312 operands[1] = XVECEXP (operands[1], 0, 0);
11315 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (elt1) == CONST_INT)
11317 = GEN_INT (TARGET_LITTLE_ENDIAN
11318 ? (INTVAL (operands[1]) & 0xff) + (INTVAL (elt1) << 8)
11319 : (INTVAL (operands[1]) << 8) + (INTVAL (elt1) & 0xff));
11322 operands[0] = gen_rtx_REG (V2QImode, true_regnum (operands[0]));
11324 = gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, operands[1], elt1));
11330 [(set (match_operand 0 "arith_reg_dest" "")
11331 (match_operand 1 "sh_const_vec" ""))]
11332 "TARGET_SHMEDIA && reload_completed
11333 && GET_MODE (operands[0]) == GET_MODE (operands[1])
11334 && sh_vector_mode_supported_p (GET_MODE (operands[0]))"
11335 [(set (match_dup 0) (match_dup 1))]
11338 rtx v = operands[1];
11339 enum machine_mode new_mode
11340 = mode_for_size (GET_MODE_BITSIZE (GET_MODE (v)), MODE_INT, 0);
11342 operands[0] = gen_rtx_REG (new_mode, true_regnum (operands[0]));
11344 = simplify_subreg (new_mode, operands[1], GET_MODE (operands[1]), 0);
11347 (define_expand "movv2hi"
11348 [(set (match_operand:V2HI 0 "general_movdst_operand" "")
11349 (match_operand:V2HI 1 "general_movsrc_operand" ""))]
11351 "{ if (prepare_move_operands (operands, V2HImode)) DONE; }")
11353 (define_insn "movv2hi_i"
11354 [(set (match_operand:V2HI 0 "general_movdst_operand" "=r,r,r,rl,m")
11355 (match_operand:V2HI 1 "general_movsrc_operand" "r,I16C16Z,nW,m,rlZ"))]
11357 && (register_operand (operands[0], V2HImode)
11358 || sh_register_operand (operands[1], V2HImode))"
11365 [(set_attr "type" "arith_media,arith_media,*,load_media,store_media")
11366 (set_attr "length" "4,4,16,4,4")
11367 (set (attr "highpart")
11368 (cond [(ne (symbol_ref "sh_contains_memref_p (insn)") (const_int 0))
11369 (const_string "user")]
11370 (const_string "ignore")))])
11372 (define_expand "movv4hi"
11373 [(set (match_operand:V4HI 0 "general_movdst_operand" "")
11374 (match_operand:V4HI 1 "general_movsrc_operand" ""))]
11376 "{ if (prepare_move_operands (operands, V4HImode)) DONE; }")
11378 (define_insn "movv4hi_i"
11379 [(set (match_operand:V4HI 0 "general_movdst_operand" "=r,r,r,rl,m")
11380 (match_operand:V4HI 1 "general_movsrc_operand" "r,I16C16Z,nW,m,rlZ"))]
11382 && (register_operand (operands[0], V4HImode)
11383 || sh_register_operand (operands[1], V4HImode))"
11390 [(set_attr "type" "arith_media,arith_media,*,load_media,store_media")
11391 (set_attr "length" "4,4,16,4,4")
11392 (set_attr "highpart" "depend")])
11394 (define_expand "movv2si"
11395 [(set (match_operand:V2SI 0 "general_movdst_operand" "")
11396 (match_operand:V2SI 1 "general_movsrc_operand" ""))]
11398 "{ if (prepare_move_operands (operands, V2SImode)) DONE; }")
11400 (define_insn "movv2si_i"
11401 [(set (match_operand:V2SI 0 "general_movdst_operand" "=r,r,r,rl,m")
11402 (match_operand:V2SI 1 "general_movsrc_operand" "r,I16C16Z,nW,m,rlZ"))]
11404 && (register_operand (operands[0], V2SImode)
11405 || sh_register_operand (operands[1], V2SImode))"
11412 [(set_attr "type" "arith_media,arith_media,*,load_media,store_media")
11413 (set_attr "length" "4,4,16,4,4")
11414 (set_attr "highpart" "depend")])
11416 ;; Multimedia Intrinsics
11418 (define_insn "absv2si2"
11419 [(set (match_operand:V2SI 0 "arith_reg_dest" "=r")
11420 (abs:V2SI (match_operand:V2SI 1 "arith_reg_operand" "r")))]
11423 [(set_attr "type" "mcmp_media")
11424 (set_attr "highpart" "depend")])
11426 (define_insn "absv4hi2"
11427 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
11428 (abs:V4HI (match_operand:V4HI 1 "arith_reg_operand" "r")))]
11431 [(set_attr "type" "mcmp_media")
11432 (set_attr "highpart" "depend")])
11434 (define_insn "addv2si3"
11435 [(set (match_operand:V2SI 0 "arith_reg_dest" "=r")
11436 (plus:V2SI (match_operand:V2SI 1 "arith_reg_operand" "%r")
11437 (match_operand:V2SI 2 "arith_reg_operand" "r")))]
11439 "madd.l %1, %2, %0"
11440 [(set_attr "type" "arith_media")
11441 (set_attr "highpart" "depend")])
11443 (define_insn "addv4hi3"
11444 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
11445 (plus:V4HI (match_operand:V4HI 1 "arith_reg_operand" "%r")
11446 (match_operand:V4HI 2 "arith_reg_operand" "r")))]
11448 "madd.w %1, %2, %0"
11449 [(set_attr "type" "arith_media")
11450 (set_attr "highpart" "depend")])
11452 (define_insn_and_split "addv2hi3"
11453 [(set (match_operand:V2HI 0 "arith_reg_dest" "=r")
11454 (plus:V2HI (match_operand:V2HI 1 "extend_reg_operand" "%r")
11455 (match_operand:V2HI 2 "extend_reg_operand" "r")))]
11462 rtx src0 = simplify_gen_subreg (V4HImode, operands[1], V2HImode, 0);
11463 rtx src1 = simplify_gen_subreg (V4HImode, operands[2], V2HImode, 0);
11464 rtx v4hi_dst = simplify_gen_subreg (V4HImode, operands[0], V2HImode, 0);
11465 rtx di_dst = simplify_gen_subreg (DImode, operands[0], V2HImode, 0);
11466 rtx si_dst = simplify_gen_subreg (SImode, operands[0], V2HImode, 0);
11468 emit_insn (gen_addv4hi3 (v4hi_dst, src0, src1));
11469 emit_insn (gen_truncdisi2 (si_dst, di_dst));
11472 [(set_attr "highpart" "must_split")])
11474 (define_insn "ssaddv2si3"
11475 [(set (match_operand:V2SI 0 "arith_reg_dest" "=r")
11476 (ss_plus:V2SI (match_operand:V2SI 1 "arith_reg_operand" "%r")
11477 (match_operand:V2SI 2 "arith_reg_operand" "r")))]
11479 "madds.l %1, %2, %0"
11480 [(set_attr "type" "mcmp_media")
11481 (set_attr "highpart" "depend")])
11483 (define_insn "usaddv8qi3"
11484 [(set (match_operand:V8QI 0 "arith_reg_dest" "=r")
11485 (us_plus:V8QI (match_operand:V8QI 1 "arith_reg_operand" "%r")
11486 (match_operand:V8QI 2 "arith_reg_operand" "r")))]
11488 "madds.ub %1, %2, %0"
11489 [(set_attr "type" "mcmp_media")
11490 (set_attr "highpart" "depend")])
11492 (define_insn "ssaddv4hi3"
11493 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
11494 (ss_plus:V4HI (match_operand:V4HI 1 "arith_reg_operand" "%r")
11495 (match_operand:V4HI 2 "arith_reg_operand" "r")))]
11497 "madds.w %1, %2, %0"
11498 [(set_attr "type" "mcmp_media")
11499 (set_attr "highpart" "depend")])
11501 (define_insn "negcmpeqv8qi"
11502 [(set (match_operand:V8QI 0 "arith_reg_dest" "=r")
11503 (neg:V8QI (eq:V8QI (match_operand:V8QI 1 "arith_reg_or_0_operand" "%rZ")
11504 (match_operand:V8QI 2 "arith_reg_or_0_operand" "rZ"))))]
11506 "mcmpeq.b %N1, %N2, %0"
11507 [(set_attr "type" "mcmp_media")
11508 (set_attr "highpart" "depend")])
11510 (define_insn "negcmpeqv2si"
11511 [(set (match_operand:V2SI 0 "arith_reg_dest" "=r")
11512 (neg:V2SI (eq:V2SI (match_operand:V2SI 1 "arith_reg_or_0_operand" "%rZ")
11513 (match_operand:V2SI 2 "arith_reg_or_0_operand" "rZ"))))]
11515 "mcmpeq.l %N1, %N2, %0"
11516 [(set_attr "type" "mcmp_media")
11517 (set_attr "highpart" "depend")])
11519 (define_insn "negcmpeqv4hi"
11520 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
11521 (neg:V4HI (eq:V4HI (match_operand:V4HI 1 "arith_reg_or_0_operand" "%rZ")
11522 (match_operand:V4HI 2 "arith_reg_or_0_operand" "rZ"))))]
11524 "mcmpeq.w %N1, %N2, %0"
11525 [(set_attr "type" "mcmp_media")
11526 (set_attr "highpart" "depend")])
11528 (define_insn "negcmpgtuv8qi"
11529 [(set (match_operand:V8QI 0 "arith_reg_dest" "=r")
11530 (neg:V8QI (gtu:V8QI (match_operand:V8QI 1 "arith_reg_or_0_operand" "%rZ")
11531 (match_operand:V8QI 2 "arith_reg_or_0_operand" "rZ"))))]
11533 "mcmpgt.ub %N1, %N2, %0"
11534 [(set_attr "type" "mcmp_media")
11535 (set_attr "highpart" "depend")])
11537 (define_insn "negcmpgtv2si"
11538 [(set (match_operand:V2SI 0 "arith_reg_dest" "=r")
11539 (neg:V2SI (gt:V2SI (match_operand:V2SI 1 "arith_reg_or_0_operand" "%rZ")
11540 (match_operand:V2SI 2 "arith_reg_or_0_operand" "rZ"))))]
11542 "mcmpgt.l %N1, %N2, %0"
11543 [(set_attr "type" "mcmp_media")
11544 (set_attr "highpart" "depend")])
11546 (define_insn "negcmpgtv4hi"
11547 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
11548 (neg:V4HI (gt:V4HI (match_operand:V4HI 1 "arith_reg_or_0_operand" "%rZ")
11549 (match_operand:V4HI 2 "arith_reg_or_0_operand" "rZ"))))]
11551 "mcmpgt.w %N1, %N2, %0"
11552 [(set_attr "type" "mcmp_media")
11553 (set_attr "highpart" "depend")])
11555 (define_insn "mcmv"
11556 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
11557 (ior:DI (and:DI (match_operand:DI 1 "arith_reg_or_0_operand" "rZ")
11558 (match_operand:DI 2 "arith_reg_operand" "r"))
11559 (and:DI (match_operand:DI 3 "arith_reg_operand" "0")
11560 (not:DI (match_dup 2)))))]
11563 [(set_attr "type" "arith_media")
11564 (set_attr "highpart" "depend")])
11566 (define_insn "mcnvs_lw"
11567 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
11569 (ss_truncate:V2HI (match_operand:V2SI 1 "arith_reg_or_0_operand" "rZ"))
11570 (ss_truncate:V2HI (match_operand:V2SI 2 "arith_reg_or_0_operand" "rZ"))))]
11572 "mcnvs.lw %N1, %N2, %0"
11573 [(set_attr "type" "mcmp_media")])
11575 (define_insn "mcnvs_wb"
11576 [(set (match_operand:V8QI 0 "arith_reg_dest" "=r")
11578 (ss_truncate:V4QI (match_operand:V4HI 1 "arith_reg_or_0_operand" "rZ"))
11579 (ss_truncate:V4QI (match_operand:V4HI 2 "arith_reg_or_0_operand" "rZ"))))]
11581 "mcnvs.wb %N1, %N2, %0"
11582 [(set_attr "type" "mcmp_media")])
11584 (define_insn "mcnvs_wub"
11585 [(set (match_operand:V8QI 0 "arith_reg_dest" "=r")
11587 (us_truncate:V4QI (match_operand:V4HI 1 "arith_reg_or_0_operand" "rZ"))
11588 (us_truncate:V4QI (match_operand:V4HI 2 "arith_reg_or_0_operand" "rZ"))))]
11590 "mcnvs.wub %N1, %N2, %0"
11591 [(set_attr "type" "mcmp_media")])
11593 (define_insn "mextr_rl"
11594 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
11595 (ior:DI (lshiftrt:DI (match_operand:DI 1 "arith_reg_or_0_operand" "rZ")
11596 (match_operand:HI 3 "mextr_bit_offset" "i"))
11597 (ashift:DI (match_operand:DI 2 "arith_reg_or_0_operand" "rZ")
11598 (match_operand:HI 4 "mextr_bit_offset" "i"))))]
11599 "TARGET_SHMEDIA && INTVAL (operands[3]) + INTVAL (operands[4]) == 64"
11602 static char templ[21];
11604 sprintf (templ, \"mextr%d\\t%%N1, %%N2, %%0\",
11605 (int) INTVAL (operands[3]) >> 3);
11608 [(set_attr "type" "arith_media")])
11610 (define_insn "*mextr_lr"
11611 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
11612 (ior:DI (ashift:DI (match_operand:DI 1 "arith_reg_or_0_operand" "rZ")
11613 (match_operand:HI 3 "mextr_bit_offset" "i"))
11614 (lshiftrt:DI (match_operand:DI 2 "arith_reg_or_0_operand" "rZ")
11615 (match_operand:HI 4 "mextr_bit_offset" "i"))))]
11616 "TARGET_SHMEDIA && INTVAL (operands[3]) + INTVAL (operands[4]) == 64"
11619 static char templ[21];
11621 sprintf (templ, \"mextr%d\\t%%N2, %%N1, %%0\",
11622 (int) INTVAL (operands[4]) >> 3);
11625 [(set_attr "type" "arith_media")])
11627 ; mextrN can be modelled with vec_select / vec_concat, but the selection
11628 ; vector then varies depending on endianness.
11629 (define_expand "mextr1"
11630 [(match_operand:DI 0 "arith_reg_dest" "")
11631 (match_operand:DI 1 "arith_reg_or_0_operand" "rZ")
11632 (match_operand:DI 2 "arith_reg_or_0_operand" "rZ")]
11636 emit_insn (gen_mextr_rl (operands[0], operands[1], operands[2],
11637 GEN_INT (1 * 8), GEN_INT (7 * 8)));
11641 (define_expand "mextr2"
11642 [(match_operand:DI 0 "arith_reg_dest" "")
11643 (match_operand:DI 1 "arith_reg_or_0_operand" "rZ")
11644 (match_operand:DI 2 "arith_reg_or_0_operand" "rZ")]
11648 emit_insn (gen_mextr_rl (operands[0], operands[1], operands[2],
11649 GEN_INT (2 * 8), GEN_INT (6 * 8)));
11653 (define_expand "mextr3"
11654 [(match_operand:DI 0 "arith_reg_dest" "")
11655 (match_operand:DI 1 "arith_reg_or_0_operand" "rZ")
11656 (match_operand:DI 2 "arith_reg_or_0_operand" "rZ")]
11660 emit_insn (gen_mextr_rl (operands[0], operands[1], operands[2],
11661 GEN_INT (3 * 8), GEN_INT (5 * 8)));
11665 (define_expand "mextr4"
11666 [(match_operand:DI 0 "arith_reg_dest" "")
11667 (match_operand:DI 1 "arith_reg_or_0_operand" "rZ")
11668 (match_operand:DI 2 "arith_reg_or_0_operand" "rZ")]
11672 emit_insn (gen_mextr_rl (operands[0], operands[1], operands[2],
11673 GEN_INT (4 * 8), GEN_INT (4 * 8)));
11677 (define_expand "mextr5"
11678 [(match_operand:DI 0 "arith_reg_dest" "")
11679 (match_operand:DI 1 "arith_reg_or_0_operand" "rZ")
11680 (match_operand:DI 2 "arith_reg_or_0_operand" "rZ")]
11684 emit_insn (gen_mextr_rl (operands[0], operands[1], operands[2],
11685 GEN_INT (5 * 8), GEN_INT (3 * 8)));
11689 (define_expand "mextr6"
11690 [(match_operand:DI 0 "arith_reg_dest" "")
11691 (match_operand:DI 1 "arith_reg_or_0_operand" "rZ")
11692 (match_operand:DI 2 "arith_reg_or_0_operand" "rZ")]
11696 emit_insn (gen_mextr_rl (operands[0], operands[1], operands[2],
11697 GEN_INT (6 * 8), GEN_INT (2 * 8)));
11701 (define_expand "mextr7"
11702 [(match_operand:DI 0 "arith_reg_dest" "")
11703 (match_operand:DI 1 "arith_reg_or_0_operand" "rZ")
11704 (match_operand:DI 2 "arith_reg_or_0_operand" "rZ")]
11708 emit_insn (gen_mextr_rl (operands[0], operands[1], operands[2],
11709 GEN_INT (7 * 8), GEN_INT (1 * 8)));
11713 (define_expand "mmacfx_wl"
11714 [(match_operand:V2SI 0 "arith_reg_dest" "")
11715 (match_operand:V2HI 1 "extend_reg_operand" "")
11716 (match_operand:V2HI 2 "extend_reg_operand" "")
11717 (match_operand:V2SI 3 "arith_reg_operand" "")]
11721 emit_insn (gen_mmacfx_wl_i (operands[0], operands[3],
11722 operands[1], operands[2]));
11726 ;; This could be highpart ignore if it only had inputs 2 or 3, but input 1
11728 (define_insn "mmacfx_wl_i"
11729 [(set (match_operand:V2SI 0 "arith_reg_dest" "=r")
11731 (match_operand:V2SI 1 "arith_reg_operand" "0")
11736 (sign_extend:V2SI (match_operand:V2HI 2 "extend_reg_operand" "r"))
11737 (sign_extend:V2SI (match_operand:V2HI 3 "extend_reg_operand" "r"))))
11740 "mmacfx.wl %2, %3, %0"
11741 [(set_attr "type" "mac_media")
11742 (set_attr "highpart" "depend")])
11744 (define_expand "mmacnfx_wl"
11745 [(match_operand:V2SI 0 "arith_reg_dest" "")
11746 (match_operand:V2HI 1 "extend_reg_operand" "")
11747 (match_operand:V2HI 2 "extend_reg_operand" "")
11748 (match_operand:V2SI 3 "arith_reg_operand" "")]
11752 emit_insn (gen_mmacnfx_wl_i (operands[0], operands[3],
11753 operands[1], operands[2]));
11757 (define_insn "mmacnfx_wl_i"
11758 [(set (match_operand:V2SI 0 "arith_reg_dest" "=r")
11760 (match_operand:V2SI 1 "arith_reg_operand" "0")
11765 (sign_extend:V2SI (match_operand:V2HI 2 "extend_reg_operand" "r"))
11766 (sign_extend:V2SI (match_operand:V2HI 3 "extend_reg_operand" "r"))))
11769 "mmacnfx.wl %2, %3, %0"
11770 [(set_attr "type" "mac_media")
11771 (set_attr "highpart" "depend")])
11773 (define_insn "mulv2si3"
11774 [(set (match_operand:V2SI 0 "arith_reg_dest" "=r")
11775 (mult:V2SI (match_operand:V2SI 1 "arith_reg_operand" "r")
11776 (match_operand:V2SI 2 "arith_reg_operand" "r")))]
11778 "mmul.l %1, %2, %0"
11779 [(set_attr "type" "d2mpy_media")
11780 (set_attr "highpart" "depend")])
11782 (define_insn "mulv4hi3"
11783 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
11784 (mult:V4HI (match_operand:V4HI 1 "arith_reg_operand" "r")
11785 (match_operand:V4HI 2 "arith_reg_operand" "r")))]
11787 "mmul.w %1, %2, %0"
11788 [(set_attr "type" "dmpy_media")
11789 (set_attr "highpart" "depend")])
11791 (define_insn "mmulfx_l"
11792 [(set (match_operand:V2SI 0 "arith_reg_dest" "=r")
11796 (sign_extend:V2DI (match_operand:V2SI 1 "arith_reg_operand" "r"))
11797 (sign_extend:V2DI (match_operand:V2SI 2 "arith_reg_operand" "r")))
11800 "mmulfx.l %1, %2, %0"
11801 [(set_attr "type" "d2mpy_media")
11802 (set_attr "highpart" "depend")])
11804 (define_insn "mmulfx_w"
11805 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
11809 (sign_extend:V4SI (match_operand:V4HI 1 "arith_reg_operand" "r"))
11810 (sign_extend:V4SI (match_operand:V4HI 2 "arith_reg_operand" "r")))
11813 "mmulfx.w %1, %2, %0"
11814 [(set_attr "type" "dmpy_media")
11815 (set_attr "highpart" "depend")])
11817 (define_insn "mmulfxrp_w"
11818 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
11823 (sign_extend:V4SI (match_operand:V4HI 1 "arith_reg_operand" "r"))
11824 (sign_extend:V4SI (match_operand:V4HI 2 "arith_reg_operand" "r")))
11828 "mmulfxrp.w %1, %2, %0"
11829 [(set_attr "type" "dmpy_media")
11830 (set_attr "highpart" "depend")])
11833 (define_expand "mmulhi_wl"
11834 [(match_operand:V2SI 0 "arith_reg_dest" "")
11835 (match_operand:V4HI 1 "arith_reg_operand" "")
11836 (match_operand:V4HI 2 "arith_reg_operand" "")]
11840 emit_insn ((TARGET_LITTLE_ENDIAN ? gen_mmul23_wl : gen_mmul01_wl)
11841 (operands[0], operands[1], operands[2]));
11845 (define_expand "mmullo_wl"
11846 [(match_operand:V2SI 0 "arith_reg_dest" "")
11847 (match_operand:V4HI 1 "arith_reg_operand" "")
11848 (match_operand:V4HI 2 "arith_reg_operand" "")]
11852 emit_insn ((TARGET_LITTLE_ENDIAN ? gen_mmul01_wl : gen_mmul23_wl)
11853 (operands[0], operands[1], operands[2]));
11857 (define_insn "mmul23_wl"
11858 [(set (match_operand:V2SI 0 "arith_reg_dest" "=r")
11861 (sign_extend:V4SI (match_operand:V4HI 1 "arith_reg_operand" "r"))
11862 (sign_extend:V4SI (match_operand:V4HI 2 "arith_reg_operand" "r")))
11863 (parallel [(const_int 2) (const_int 3)])))]
11865 "* return (TARGET_LITTLE_ENDIAN
11866 ? \"mmulhi.wl %1, %2, %0\"
11867 : \"mmullo.wl %1, %2, %0\");"
11868 [(set_attr "type" "dmpy_media")
11869 (set (attr "highpart")
11870 (cond [(eq_attr "endian" "big") (const_string "ignore")]
11871 (const_string "user")))])
11873 (define_insn "mmul01_wl"
11874 [(set (match_operand:V2SI 0 "arith_reg_dest" "=r")
11877 (sign_extend:V4SI (match_operand:V4HI 1 "arith_reg_operand" "r"))
11878 (sign_extend:V4SI (match_operand:V4HI 2 "arith_reg_operand" "r")))
11879 (parallel [(const_int 0) (const_int 1)])))]
11881 "* return (TARGET_LITTLE_ENDIAN
11882 ? \"mmullo.wl %1, %2, %0\"
11883 : \"mmulhi.wl %1, %2, %0\");"
11884 [(set_attr "type" "dmpy_media")
11885 (set (attr "highpart")
11886 (cond [(eq_attr "endian" "little") (const_string "ignore")]
11887 (const_string "user")))])
11890 (define_expand "mmulsum_wq"
11891 [(match_operand:DI 0 "arith_reg_dest" "")
11892 (match_operand:V4HI 1 "arith_reg_operand" "")
11893 (match_operand:V4HI 2 "arith_reg_operand" "")
11894 (match_operand:DI 3 "arith_reg_operand" "")]
11898 emit_insn (gen_mmulsum_wq_i (operands[0], operands[3],
11899 operands[1], operands[2]));
11903 (define_insn "mmulsum_wq_i"
11904 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
11905 (plus:DI (match_operand:DI 1 "arith_reg_operand" "0")
11910 (sign_extend:V4DI (match_operand:V4HI 2 "arith_reg_operand" "r"))
11911 (sign_extend:V4DI (match_operand:V4HI 3 "arith_reg_operand" "r")))
11912 (parallel [(const_int 0)]))
11913 (vec_select:DI (mult:V4DI (sign_extend:V4DI (match_dup 2))
11914 (sign_extend:V4DI (match_dup 3)))
11915 (parallel [(const_int 1)])))
11917 (vec_select:DI (mult:V4DI (sign_extend:V4DI (match_dup 2))
11918 (sign_extend:V4DI (match_dup 3)))
11919 (parallel [(const_int 2)]))
11920 (vec_select:DI (mult:V4DI (sign_extend:V4DI (match_dup 2))
11921 (sign_extend:V4DI (match_dup 3)))
11922 (parallel [(const_int 3)]))))))]
11924 "mmulsum.wq %2, %3, %0"
11925 [(set_attr "type" "mac_media")])
11927 (define_expand "mperm_w"
11928 [(match_operand:V4HI 0 "arith_reg_dest" "=r")
11929 (match_operand:V4HI 1 "arith_reg_operand" "r")
11930 (match_operand:QI 2 "extend_reg_or_0_operand" "rZ")]
11934 emit_insn ((TARGET_LITTLE_ENDIAN ? gen_mperm_w_little : gen_mperm_w_big)
11935 (operands[0], operands[1], operands[2]));
11939 ; This use of vec_select isn't exactly correct according to rtl.texi
11940 ; (because not constant), but it seems a straightforward extension.
11941 (define_insn "mperm_w_little"
11942 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
11944 (match_operand:V4HI 1 "arith_reg_operand" "r")
11946 [(zero_extract:QI (match_operand:QI 2 "extend_reg_or_0_operand" "rZ")
11947 (const_int 2) (const_int 0))
11948 (zero_extract:QI (match_dup 2) (const_int 2) (const_int 2))
11949 (zero_extract:QI (match_dup 2) (const_int 2) (const_int 4))
11950 (zero_extract:QI (match_dup 2) (const_int 2) (const_int 6))])))]
11951 "TARGET_SHMEDIA && TARGET_LITTLE_ENDIAN"
11952 "mperm.w %1, %N2, %0"
11953 [(set_attr "type" "arith_media")])
11955 (define_insn "mperm_w_big"
11956 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
11958 (match_operand:V4HI 1 "arith_reg_operand" "r")
11960 [(zero_extract:QI (not:QI (match_operand:QI 2
11961 "extend_reg_or_0_operand" "rZ"))
11962 (const_int 2) (const_int 0))
11963 (zero_extract:QI (not:QI (match_dup 2)) (const_int 2) (const_int 2))
11964 (zero_extract:QI (not:QI (match_dup 2)) (const_int 2) (const_int 4))
11965 (zero_extract:QI (not:QI (match_dup 2))
11966 (const_int 2) (const_int 6))])))]
11967 "TARGET_SHMEDIA && ! TARGET_LITTLE_ENDIAN"
11968 "mperm.w %1, %N2, %0"
11969 [(set_attr "type" "arith_media")])
11971 (define_insn "mperm_w0"
11972 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
11973 (vec_duplicate:V4HI (truncate:HI (match_operand 1
11974 "trunc_hi_operand" "r"))))]
11976 "mperm.w %1, r63, %0"
11977 [(set_attr "type" "arith_media")
11978 (set_attr "highpart" "ignore")])
11980 (define_expand "msad_ubq"
11981 [(match_operand:DI 0 "arith_reg_dest" "")
11982 (match_operand:V8QI 1 "arith_reg_or_0_operand" "")
11983 (match_operand:V8QI 2 "arith_reg_or_0_operand" "")
11984 (match_operand:DI 3 "arith_reg_operand" "")]
11988 emit_insn (gen_msad_ubq_i (operands[0], operands[3],
11989 operands[1], operands[2]));
11993 (define_insn "msad_ubq_i"
11994 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
11999 (match_operand:DI 1 "arith_reg_operand" "0")
12000 (abs:DI (vec_select:DI
12003 (match_operand:V8QI 2 "arith_reg_or_0_operand" "rZ"))
12005 (match_operand:V8QI 3 "arith_reg_or_0_operand" "rZ")))
12006 (parallel [(const_int 0)]))))
12007 (abs:DI (vec_select:DI (minus:V8DI (zero_extend:V8DI (match_dup 2))
12008 (zero_extend:V8DI (match_dup 3)))
12009 (parallel [(const_int 1)]))))
12011 (abs:DI (vec_select:DI (minus:V8DI (zero_extend:V8DI (match_dup 2))
12012 (zero_extend:V8DI (match_dup 3)))
12013 (parallel [(const_int 2)])))
12014 (abs:DI (vec_select:DI (minus:V8DI (zero_extend:V8DI (match_dup 2))
12015 (zero_extend:V8DI (match_dup 3)))
12016 (parallel [(const_int 3)])))))
12019 (abs:DI (vec_select:DI (minus:V8DI (zero_extend:V8DI (match_dup 2))
12020 (zero_extend:V8DI (match_dup 3)))
12021 (parallel [(const_int 4)])))
12022 (abs:DI (vec_select:DI (minus:V8DI (zero_extend:V8DI (match_dup 2))
12023 (zero_extend:V8DI (match_dup 3)))
12024 (parallel [(const_int 5)]))))
12026 (abs:DI (vec_select:DI (minus:V8DI (zero_extend:V8DI (match_dup 2))
12027 (zero_extend:V8DI (match_dup 3)))
12028 (parallel [(const_int 6)])))
12029 (abs:DI (vec_select:DI (minus:V8DI (zero_extend:V8DI (match_dup 2))
12030 (zero_extend:V8DI (match_dup 3)))
12031 (parallel [(const_int 7)])))))))]
12033 "msad.ubq %N2, %N3, %0"
12034 [(set_attr "type" "mac_media")])
12036 (define_insn "mshalds_l"
12037 [(set (match_operand:V2SI 0 "arith_reg_dest" "=r")
12040 (sign_extend:V2DI (match_operand:V2SI 1 "arith_reg_operand" "r"))
12041 (and:DI (match_operand:DI 2 "arith_reg_operand" "r")
12042 (const_int 31)))))]
12044 "mshalds.l %1, %2, %0"
12045 [(set_attr "type" "mcmp_media")
12046 (set_attr "highpart" "depend")])
12048 (define_insn "mshalds_w"
12049 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
12052 (sign_extend:V4SI (match_operand:V4HI 1 "arith_reg_operand" "r"))
12053 (and:DI (match_operand:DI 2 "arith_reg_operand" "r")
12054 (const_int 15)))))]
12056 "mshalds.w %1, %2, %0"
12057 [(set_attr "type" "mcmp_media")
12058 (set_attr "highpart" "depend")])
12060 (define_insn "ashrv2si3"
12061 [(set (match_operand:V2SI 0 "arith_reg_dest" "=r")
12062 (ashiftrt:V2SI (match_operand:V2SI 1 "arith_reg_operand" "r")
12063 (match_operand:DI 2 "arith_reg_operand" "r")))]
12065 "mshard.l %1, %2, %0"
12066 [(set_attr "type" "arith_media")
12067 (set_attr "highpart" "depend")])
12069 (define_insn "ashrv4hi3"
12070 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
12071 (ashiftrt:V4HI (match_operand:V4HI 1 "arith_reg_operand" "r")
12072 (match_operand:DI 2 "arith_reg_operand" "r")))]
12074 "mshard.w %1, %2, %0"
12075 [(set_attr "type" "arith_media")
12076 (set_attr "highpart" "depend")])
12078 (define_insn "mshards_q"
12079 [(set (match_operand:HI 0 "arith_reg_dest" "=r")
12081 (ashiftrt:DI (match_operand:DI 1 "arith_reg_operand" "r")
12082 (match_operand:DI 2 "arith_reg_or_0_operand" "rZ"))))]
12084 "mshards.q %1, %N2, %0"
12085 [(set_attr "type" "mcmp_media")])
12087 (define_expand "mshfhi_b"
12088 [(match_operand:V8QI 0 "arith_reg_dest" "")
12089 (match_operand:V8QI 1 "arith_reg_or_0_operand" "rZ")
12090 (match_operand:V8QI 2 "arith_reg_or_0_operand" "rZ")]
12094 emit_insn ((TARGET_LITTLE_ENDIAN ? gen_mshf4_b : gen_mshf0_b)
12095 (operands[0], operands[1], operands[2]));
12099 (define_expand "mshflo_b"
12100 [(match_operand:V8QI 0 "arith_reg_dest" "")
12101 (match_operand:V8QI 1 "arith_reg_or_0_operand" "rZ")
12102 (match_operand:V8QI 2 "arith_reg_or_0_operand" "rZ")]
12106 emit_insn ((TARGET_LITTLE_ENDIAN ? gen_mshf0_b : gen_mshf4_b)
12107 (operands[0], operands[1], operands[2]));
12111 (define_insn "mshf4_b"
12113 (match_operand:V8QI 0 "arith_reg_dest" "=r")
12115 (vec_concat:V16QI (match_operand:V8QI 1 "arith_reg_or_0_operand" "rZ")
12116 (match_operand:V8QI 2 "arith_reg_or_0_operand" "rZ"))
12117 (parallel [(const_int 4) (const_int 12) (const_int 5) (const_int 13)
12118 (const_int 6) (const_int 14) (const_int 7) (const_int 15)])))]
12120 "* return (TARGET_LITTLE_ENDIAN
12121 ? \"mshfhi.b %N1, %N2, %0\"
12122 : \"mshflo.b %N1, %N2, %0\");"
12123 [(set_attr "type" "arith_media")
12124 (set (attr "highpart")
12125 (cond [(eq_attr "endian" "big") (const_string "ignore")]
12126 (const_string "user")))])
12128 (define_insn "mshf0_b"
12130 (match_operand:V8QI 0 "arith_reg_dest" "=r")
12132 (vec_concat:V16QI (match_operand:V8QI 1 "arith_reg_or_0_operand" "rZ")
12133 (match_operand:V8QI 2 "arith_reg_or_0_operand" "rZ"))
12134 (parallel [(const_int 0) (const_int 8) (const_int 1) (const_int 9)
12135 (const_int 2) (const_int 10) (const_int 3) (const_int 11)])))]
12137 "* return (TARGET_LITTLE_ENDIAN
12138 ? \"mshflo.b %N1, %N2, %0\"
12139 : \"mshfhi.b %N1, %N2, %0\");"
12140 [(set_attr "type" "arith_media")
12141 (set (attr "highpart")
12142 (cond [(eq_attr "endian" "little") (const_string "ignore")]
12143 (const_string "user")))])
12145 (define_expand "mshfhi_l"
12146 [(match_operand:V2SI 0 "arith_reg_dest" "")
12147 (match_operand:V2SI 1 "arith_reg_or_0_operand" "rZ")
12148 (match_operand:V2SI 2 "arith_reg_or_0_operand" "rZ")]
12152 emit_insn ((TARGET_LITTLE_ENDIAN ? gen_mshf4_l : gen_mshf0_l)
12153 (operands[0], operands[1], operands[2]));
12157 (define_expand "mshflo_l"
12158 [(match_operand:V2SI 0 "arith_reg_dest" "")
12159 (match_operand:V2SI 1 "arith_reg_or_0_operand" "rZ")
12160 (match_operand:V2SI 2 "arith_reg_or_0_operand" "rZ")]
12164 emit_insn ((TARGET_LITTLE_ENDIAN ? gen_mshf0_l : gen_mshf4_l)
12165 (operands[0], operands[1], operands[2]));
12169 (define_insn "mshf4_l"
12170 [(set (match_operand:V2SI 0 "arith_reg_dest" "=r")
12172 (vec_concat:V4SI (match_operand:V2SI 1 "arith_reg_or_0_operand" "rZ")
12173 (match_operand:V2SI 2 "arith_reg_or_0_operand" "rZ"))
12174 (parallel [(const_int 1) (const_int 3)])))]
12176 "* return (TARGET_LITTLE_ENDIAN
12177 ? \"mshfhi.l %N1, %N2, %0\"
12178 : \"mshflo.l %N1, %N2, %0\");"
12179 [(set_attr "type" "arith_media")
12180 (set (attr "highpart")
12181 (cond [(eq_attr "endian" "big") (const_string "ignore")]
12182 (const_string "user")))])
12184 (define_insn "mshf0_l"
12185 [(set (match_operand:V2SI 0 "arith_reg_dest" "=r")
12187 (vec_concat:V4SI (match_operand:V2SI 1 "arith_reg_or_0_operand" "rZ")
12188 (match_operand:V2SI 2 "arith_reg_or_0_operand" "rZ"))
12189 (parallel [(const_int 0) (const_int 2)])))]
12191 "* return (TARGET_LITTLE_ENDIAN
12192 ? \"mshflo.l %N1, %N2, %0\"
12193 : \"mshfhi.l %N1, %N2, %0\");"
12194 [(set_attr "type" "arith_media")
12195 (set (attr "highpart")
12196 (cond [(eq_attr "endian" "little") (const_string "ignore")]
12197 (const_string "user")))])
12199 (define_expand "mshfhi_w"
12200 [(match_operand:V4HI 0 "arith_reg_dest" "")
12201 (match_operand:V4HI 1 "arith_reg_or_0_operand" "rZ")
12202 (match_operand:V4HI 2 "arith_reg_or_0_operand" "rZ")]
12206 emit_insn ((TARGET_LITTLE_ENDIAN ? gen_mshf4_w : gen_mshf0_w)
12207 (operands[0], operands[1], operands[2]));
12211 (define_expand "mshflo_w"
12212 [(match_operand:V4HI 0 "arith_reg_dest" "")
12213 (match_operand:V4HI 1 "arith_reg_or_0_operand" "rZ")
12214 (match_operand:V4HI 2 "arith_reg_or_0_operand" "rZ")]
12218 emit_insn ((TARGET_LITTLE_ENDIAN ? gen_mshf0_w : gen_mshf4_w)
12219 (operands[0], operands[1], operands[2]));
12223 (define_insn "mshf4_w"
12224 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
12226 (vec_concat:V8HI (match_operand:V4HI 1 "arith_reg_or_0_operand" "rZ")
12227 (match_operand:V4HI 2 "arith_reg_or_0_operand" "rZ"))
12228 (parallel [(const_int 2) (const_int 6) (const_int 3) (const_int 7)])))]
12230 "* return (TARGET_LITTLE_ENDIAN
12231 ? \"mshfhi.w %N1, %N2, %0\"
12232 : \"mshflo.w %N1, %N2, %0\");"
12233 [(set_attr "type" "arith_media")
12234 (set (attr "highpart")
12235 (cond [(eq_attr "endian" "big") (const_string "ignore")]
12236 (const_string "user")))])
12238 (define_insn "mshf0_w"
12239 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
12241 (vec_concat:V8HI (match_operand:V4HI 1 "arith_reg_or_0_operand" "rZ")
12242 (match_operand:V4HI 2 "arith_reg_or_0_operand" "rZ"))
12243 (parallel [(const_int 0) (const_int 4) (const_int 1) (const_int 5)])))]
12245 "* return (TARGET_LITTLE_ENDIAN
12246 ? \"mshflo.w %N1, %N2, %0\"
12247 : \"mshfhi.w %N1, %N2, %0\");"
12248 [(set_attr "type" "arith_media")
12249 (set (attr "highpart")
12250 (cond [(eq_attr "endian" "little") (const_string "ignore")]
12251 (const_string "user")))])
12253 (define_insn "mshflo_w_x"
12254 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
12256 (vec_concat:V4HI (match_operand:V2HI 1 "extend_reg_or_0_operand" "rZ")
12257 (match_operand:V2HI 2 "extend_reg_or_0_operand" "rZ"))
12258 (parallel [(const_int 2) (const_int 0) (const_int 3) (const_int 1)])))]
12260 "mshflo.w %N1, %N2, %0"
12261 [(set_attr "type" "arith_media")
12262 (set_attr "highpart" "ignore")])
12264 /* These are useful to expand ANDs and as combiner patterns. */
12265 (define_insn_and_split "mshfhi_l_di"
12266 [(set (match_operand:DI 0 "arith_reg_dest" "=r,f")
12267 (ior:DI (lshiftrt:DI (match_operand:DI 1 "arith_reg_or_0_operand" "rZ,f")
12269 (and:DI (match_operand:DI 2 "arith_reg_or_0_operand" "rZ,?f")
12270 (const_int -4294967296))))]
12273 mshfhi.l %N1, %N2, %0
12275 "TARGET_SHMEDIA && reload_completed
12276 && ! GENERAL_REGISTER_P (true_regnum (operands[0]))"
12277 [(set (match_dup 3) (match_dup 4))
12278 (set (match_dup 5) (match_dup 6))]
12281 operands[3] = gen_lowpart (SImode, operands[0]);
12282 operands[4] = gen_highpart (SImode, operands[1]);
12283 operands[5] = gen_highpart (SImode, operands[0]);
12284 operands[6] = gen_highpart (SImode, operands[2]);
12286 [(set_attr "type" "arith_media")])
12288 (define_insn "*mshfhi_l_di_rev"
12289 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
12290 (ior:DI (and:DI (match_operand:DI 1 "arith_reg_or_0_operand" "rZ")
12291 (const_int -4294967296))
12292 (lshiftrt:DI (match_operand:DI 2 "arith_reg_or_0_operand" "rZ")
12295 "mshfhi.l %N2, %N1, %0"
12296 [(set_attr "type" "arith_media")])
12299 [(set (match_operand:DI 0 "arith_reg_dest" "")
12300 (ior:DI (zero_extend:DI (match_operand:SI 1
12301 "extend_reg_or_0_operand" ""))
12302 (and:DI (match_operand:DI 2 "arith_reg_or_0_operand" "")
12303 (const_int -4294967296))))
12304 (clobber (match_operand:DI 3 "arith_reg_dest" ""))]
12309 emit_insn (gen_ashldi3_media (operands[3],
12310 simplify_gen_subreg (DImode, operands[1],
12313 emit_insn (gen_mshfhi_l_di (operands[0], operands[3], operands[2]));
12317 (define_insn "mshflo_l_di"
12318 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
12319 (ior:DI (and:DI (match_operand:DI 1 "arith_reg_or_0_operand" "rZ")
12320 (const_int 4294967295))
12321 (ashift:DI (match_operand:DI 2 "arith_reg_or_0_operand" "rZ")
12325 "mshflo.l %N1, %N2, %0"
12326 [(set_attr "type" "arith_media")
12327 (set_attr "highpart" "ignore")])
12329 (define_insn "*mshflo_l_di_rev"
12330 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
12331 (ior:DI (ashift:DI (match_operand:DI 1 "arith_reg_or_0_operand" "rZ")
12333 (and:DI (match_operand:DI 2 "arith_reg_or_0_operand" "rZ")
12334 (const_int 4294967295))))]
12337 "mshflo.l %N2, %N1, %0"
12338 [(set_attr "type" "arith_media")
12339 (set_attr "highpart" "ignore")])
12341 ;; Combiner pattern for trampoline initialization.
12342 (define_insn_and_split "*double_shori"
12343 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
12344 (ior:DI (ashift:DI (match_operand:DI 1 "arith_reg_operand" "0")
12346 (match_operand:DI 2 "const_int_operand" "n")))]
12348 && INTVAL (operands[2]) == trunc_int_for_mode (INTVAL (operands[2]), SImode)"
12350 "rtx_equal_p (operands[0], operands[1])"
12354 HOST_WIDE_INT v = INTVAL (operands[2]);
12356 emit_insn (gen_shori_media (operands[0], operands[0],
12357 gen_int_mode (INTVAL (operands[2]) >> 16, HImode)));
12358 emit_insn (gen_shori_media (operands[0], operands[0],
12359 gen_int_mode (v, HImode)));
12362 [(set_attr "highpart" "ignore")])
12365 (define_insn "*mshflo_l_di_x"
12366 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
12367 (ior:DI (zero_extend:DI (match_operand:SI 1 "extend_reg_or_0_operand"
12369 (ashift:DI (match_operand:DI 2 "arith_reg_or_0_operand" "rZ")
12373 "mshflo.l %N1, %N2, %0"
12374 [(set_attr "type" "arith_media")
12375 (set_attr "highpart" "ignore")])
12377 (define_insn_and_split "concat_v2sf"
12378 [(set (match_operand:V2SF 0 "register_operand" "=r,f,f?")
12379 ;; (vec_concat:V2SF (match_operand:SF 1 "register_operand" "rZ,0,f")
12380 (vec_concat:V2SF (match_operand:SF 1 "register_operand" "rZ,f,f")
12381 (match_operand:SF 2 "register_operand" "rZ,f,f")))]
12385 mshflo.l %N1, %N2, %0
12388 "TARGET_SHMEDIA && reload_completed
12389 && ! GENERAL_REGISTER_P (true_regnum (operands[0]))"
12390 [(set (match_dup 3) (match_dup 1))
12391 (set (match_dup 4) (match_dup 2))]
12394 operands[3] = simplify_gen_subreg (SFmode, operands[0], V2SFmode, 0);
12395 operands[4] = simplify_gen_subreg (SFmode, operands[0], V2SFmode, 4);
12397 [(set_attr "type" "arith_media")
12398 (set_attr "highpart" "ignore")])
12400 (define_insn "*mshflo_l_di_x_rev"
12401 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
12402 (ior:DI (ashift:DI (match_operand:DI 1 "arith_reg_or_0_operand" "rZ")
12404 (zero_extend:DI (match_operand:SI 2 "extend_reg_or_0_operand" "rZ"))))]
12407 "mshflo.l %N2, %N1, %0"
12408 [(set_attr "type" "arith_media")
12409 (set_attr "highpart" "ignore")])
12411 (define_insn "ashlv2si3"
12412 [(set (match_operand:V2SI 0 "arith_reg_dest" "=r")
12413 (ashift:V2SI (match_operand:V2SI 1 "arith_reg_operand" "r")
12414 (match_operand:DI 2 "shift_count_reg_operand" "r")))]
12416 "mshlld.l %1, %2, %0"
12417 [(set_attr "type" "arith_media")
12418 (set_attr "highpart" "depend")])
12421 [(set (match_operand 0 "any_register_operand" "")
12422 (match_operator 3 "shift_operator"
12423 [(match_operand 1 "any_register_operand" "")
12424 (match_operand 2 "shift_count_reg_operand" "")]))]
12425 "TARGET_SHMEDIA && ! register_operand (operands[2], VOIDmode)"
12426 [(set (match_dup 0) (match_dup 3))]
12429 rtx count = operands[2];
12430 enum machine_mode outer_mode = GET_MODE (operands[2]), inner_mode;
12432 while (GET_CODE (count) == ZERO_EXTEND || GET_CODE (count) == SIGN_EXTEND
12433 || (GET_CODE (count) == SUBREG && SUBREG_BYTE (count) == 0)
12434 || GET_CODE (count) == TRUNCATE)
12435 count = XEXP (count, 0);
12436 inner_mode = GET_MODE (count);
12437 count = simplify_gen_subreg (outer_mode, count, inner_mode,
12438 subreg_lowpart_offset (outer_mode, inner_mode));
12439 operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[3]), GET_MODE (operands[3]),
12440 operands[1], count);
12443 (define_insn "ashlv4hi3"
12444 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
12445 (ashift:V4HI (match_operand:V4HI 1 "arith_reg_operand" "r")
12446 (match_operand:DI 2 "shift_count_reg_operand" "r")))]
12448 "mshlld.w %1, %2, %0"
12449 [(set_attr "type" "arith_media")
12450 (set_attr "highpart" "depend")])
12452 (define_insn "lshrv2si3"
12453 [(set (match_operand:V2SI 0 "arith_reg_dest" "=r")
12454 (lshiftrt:V2SI (match_operand:V2SI 1 "arith_reg_operand" "r")
12455 (match_operand:DI 2 "shift_count_reg_operand" "r")))]
12457 "mshlrd.l %1, %2, %0"
12458 [(set_attr "type" "arith_media")
12459 (set_attr "highpart" "depend")])
12461 (define_insn "lshrv4hi3"
12462 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
12463 (lshiftrt:V4HI (match_operand:V4HI 1 "arith_reg_operand" "r")
12464 (match_operand:DI 2 "shift_count_reg_operand" "r")))]
12466 "mshlrd.w %1, %2, %0"
12467 [(set_attr "type" "arith_media")
12468 (set_attr "highpart" "depend")])
12470 (define_insn "subv2si3"
12471 [(set (match_operand:V2SI 0 "arith_reg_dest" "=r")
12472 (minus:V2SI (match_operand:V2SI 1 "arith_reg_or_0_operand" "rZ")
12473 (match_operand:V2SI 2 "arith_reg_operand" "r")))]
12475 "msub.l %N1, %2, %0"
12476 [(set_attr "type" "arith_media")
12477 (set_attr "highpart" "depend")])
12479 (define_insn "subv4hi3"
12480 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
12481 (minus:V4HI (match_operand:V4HI 1 "arith_reg_or_0_operand" "rZ")
12482 (match_operand:V4HI 2 "arith_reg_operand" "r")))]
12484 "msub.w %N1, %2, %0"
12485 [(set_attr "type" "arith_media")
12486 (set_attr "highpart" "depend")])
12488 (define_insn_and_split "subv2hi3"
12489 [(set (match_operand:V2HI 0 "arith_reg_dest" "=r")
12490 (minus:V2HI (match_operand:V2HI 1 "arith_reg_or_0_operand" "rZ")
12491 (match_operand:V2HI 2 "arith_reg_operand" "r")))]
12498 rtx src0 = simplify_gen_subreg (V4HImode, operands[1], V2HImode, 0);
12499 rtx src1 = simplify_gen_subreg (V4HImode, operands[2], V2HImode, 0);
12500 rtx v4hi_dst = simplify_gen_subreg (V4HImode, operands[0], V2HImode, 0);
12501 rtx di_dst = simplify_gen_subreg (DImode, operands[0], V2HImode, 0);
12502 rtx si_dst = simplify_gen_subreg (SImode, operands[0], V2HImode, 0);
12504 emit_insn (gen_subv4hi3 (v4hi_dst, src0, src1));
12505 emit_insn (gen_truncdisi2 (si_dst, di_dst));
12508 [(set_attr "highpart" "must_split")])
12510 (define_insn "sssubv2si3"
12511 [(set (match_operand:V2SI 0 "arith_reg_dest" "=r")
12512 (ss_minus:V2SI (match_operand:V2SI 1 "arith_reg_or_0_operand" "rZ")
12513 (match_operand:V2SI 2 "arith_reg_operand" "r")))]
12515 "msubs.l %N1, %2, %0"
12516 [(set_attr "type" "mcmp_media")
12517 (set_attr "highpart" "depend")])
12519 (define_insn "ussubv8qi3"
12520 [(set (match_operand:V8QI 0 "arith_reg_dest" "=r")
12521 (us_minus:V8QI (match_operand:V8QI 1 "arith_reg_or_0_operand" "rZ")
12522 (match_operand:V8QI 2 "arith_reg_operand" "r")))]
12524 "msubs.ub %N1, %2, %0"
12525 [(set_attr "type" "mcmp_media")
12526 (set_attr "highpart" "depend")])
12528 (define_insn "sssubv4hi3"
12529 [(set (match_operand:V4HI 0 "arith_reg_dest" "=r")
12530 (ss_minus:V4HI (match_operand:V4HI 1 "arith_reg_or_0_operand" "rZ")
12531 (match_operand:V4HI 2 "arith_reg_operand" "r")))]
12533 "msubs.w %N1, %2, %0"
12534 [(set_attr "type" "mcmp_media")
12535 (set_attr "highpart" "depend")])
12537 ;; Floating Point Intrinsics
12539 (define_insn "fcosa_s"
12540 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
12541 (unspec:SF [(match_operand:SI 1 "fp_arith_reg_operand" "f")]
12545 [(set_attr "type" "atrans_media")])
12547 (define_insn "fsina_s"
12548 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
12549 (unspec:SF [(match_operand:SI 1 "fp_arith_reg_operand" "f")]
12553 [(set_attr "type" "atrans_media")])
12555 (define_insn "fipr"
12556 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
12557 (plus:SF (plus:SF (vec_select:SF (mult:V4SF (match_operand:V4SF 1
12558 "fp_arith_reg_operand" "f")
12559 (match_operand:V4SF 2
12560 "fp_arith_reg_operand" "f"))
12561 (parallel [(const_int 0)]))
12562 (vec_select:SF (mult:V4SF (match_dup 1) (match_dup 2))
12563 (parallel [(const_int 1)])))
12564 (plus:SF (vec_select:SF (mult:V4SF (match_dup 1) (match_dup 2))
12565 (parallel [(const_int 2)]))
12566 (vec_select:SF (mult:V4SF (match_dup 1) (match_dup 2))
12567 (parallel [(const_int 3)])))))]
12569 "fipr.s %1, %2, %0"
12570 [(set_attr "type" "fparith_media")])
12572 (define_insn "fsrra_s"
12573 [(set (match_operand:SF 0 "fp_arith_reg_operand" "=f")
12574 (unspec:SF [(match_operand:SF 1 "fp_arith_reg_operand" "f")]
12578 [(set_attr "type" "atrans_media")])
12580 (define_insn "ftrv"
12581 [(set (match_operand:V4SF 0 "fp_arith_reg_operand" "=f")
12585 (vec_select:V4SF (match_operand:V16SF 1 "fp_arith_reg_operand" "f")
12586 (parallel [(const_int 0) (const_int 5)
12587 (const_int 10) (const_int 15)]))
12588 (match_operand:V4SF 2 "fp_arith_reg_operand" "f"))
12590 (vec_select:V4SF (match_dup 1)
12591 (parallel [(const_int 4) (const_int 9)
12592 (const_int 14) (const_int 3)]))
12593 (vec_select:V4SF (match_dup 2)
12594 (parallel [(const_int 1) (const_int 2)
12595 (const_int 3) (const_int 0)]))))
12598 (vec_select:V4SF (match_dup 1)
12599 (parallel [(const_int 8) (const_int 13)
12600 (const_int 2) (const_int 7)]))
12601 (vec_select:V4SF (match_dup 2)
12602 (parallel [(const_int 2) (const_int 3)
12603 (const_int 0) (const_int 1)])))
12605 (vec_select:V4SF (match_dup 1)
12606 (parallel [(const_int 12) (const_int 1)
12607 (const_int 6) (const_int 11)]))
12608 (vec_select:V4SF (match_dup 2)
12609 (parallel [(const_int 3) (const_int 0)
12610 (const_int 1) (const_int 2)]))))))]
12612 "ftrv.s %1, %2, %0"
12613 [(set_attr "type" "fparith_media")])
12615 (define_insn "ldhi_l"
12616 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
12618 (mem:SI (plus:SI (ior:SI (match_operand:QI 1 "ua_address_operand" "p")
12621 (plus:SI (and:SI (match_dup 1) (const_int 3)) (const_int 1))
12625 [(set_attr "type" "load_media")])
12627 (define_insn "ldhi_q"
12628 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
12630 (mem:DI (plus:SI (ior:SI (match_operand:QI 1 "ua_address_operand" "p")
12633 (plus:SI (and:SI (match_dup 1) (const_int 7)) (const_int 1))
12637 [(set_attr "type" "load_media")])
12639 (define_insn_and_split "*ldhi_q_comb0"
12640 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
12642 (mem:DI (plus:SI (ior:SI (plus:SI (match_operand:SI 1
12643 "register_operand" "r")
12644 (match_operand:SI 2
12645 "ua_offset" "I06"))
12648 (plus:SI (and:SI (match_dup 1) (const_int 7))
12651 "TARGET_SHMEDIA32 && (INTVAL (operands[2]) & 7) == 0"
12655 "emit_insn (gen_ldhi_q (operands[0],
12656 gen_rtx_PLUS (SImode, operands[1], operands[2])));
12660 (define_insn_and_split "*ldhi_q_comb1"
12661 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
12663 (mem:DI (plus:SI (ior:SI (plus:SI (match_operand:SI 1
12664 "register_operand" "r")
12665 (match_operand:SI 2
12666 "ua_offset" "I06"))
12669 (plus:SI (and:SI (plus:SI (match_dup 1) (match_operand:SI 3
12670 "ua_offset" "I06"))
12674 "TARGET_SHMEDIA32 && (INTVAL (operands[2]) & -8)
12675 && (INTVAL (operands[2]) & 7) == INTVAL (operands[3])"
12679 "emit_insn (gen_ldhi_q (operands[0],
12680 gen_rtx_PLUS (SImode, operands[1], operands[2])));
12684 (define_insn "ldlo_l"
12685 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
12687 (mem:SI (and:SI (match_operand:QI 1 "ua_address_operand" "p")
12689 (minus:SI (const_int 4) (and:SI (match_dup 1) (const_int 3)))
12690 (and:SI (match_dup 1) (const_int 3))))]
12693 [(set_attr "type" "load_media")])
12695 (define_insn "ldlo_q"
12696 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
12698 (mem:DI (and:SI (match_operand:QI 1 "ua_address_operand" "p")
12700 (minus:SI (const_int 8) (and:SI (match_dup 1) (const_int 7)))
12701 (and:SI (match_dup 1) (const_int 7))))]
12704 [(set_attr "type" "load_media")])
12706 (define_insn_and_split "*ldlo_q_comb0"
12707 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
12709 (mem:DI (and:SI (plus:SI (match_operand:SI 1 "register_operand" "r")
12710 (match_operand:SI 2 "ua_offset" "I06"))
12712 (minus:SI (const_int 8) (and:SI (match_dup 1) (const_int 7)))
12713 (and:SI (match_dup 1) (const_int 7))))]
12714 "TARGET_SHMEDIA32 && (INTVAL (operands[2]) & 7) == 0"
12718 "emit_insn (gen_ldlo_q (operands[0],
12719 gen_rtx_PLUS (SImode, operands[1], operands[2])));
12722 (define_insn_and_split "*ldlo_q_comb1"
12723 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
12725 (mem:DI (and:SI (plus:SI (match_operand:SI 1 "register_operand" "r")
12726 (match_operand:SI 2 "ua_offset" "I06"))
12728 (minus:SI (const_int 8)
12729 (and:SI (plus:SI (match_dup 1)
12730 (match_operand:SI 3 "ua_offset" "I06"))
12732 (and:SI (plus:SI (match_dup 1) (match_dup 3)) (const_int 7))))]
12733 "TARGET_SHMEDIA32 && (INTVAL (operands[2]) & -8)
12734 && (INTVAL (operands[2]) & 7) == INTVAL (operands[3])"
12738 "emit_insn (gen_ldlo_q (operands[0],
12739 gen_rtx_PLUS (SImode, operands[1], operands[2])));
12742 (define_insn "sthi_l"
12743 [(set (zero_extract:SI
12744 (mem:SI (plus:SI (ior:SI (match_operand:QI 0 "ua_address_operand" "p")
12747 (plus:SI (and:SI (match_dup 0) (const_int 3)) (const_int 1))
12749 (match_operand:SI 1 "arith_reg_operand" "r"))]
12752 [(set_attr "type" "ustore_media")])
12754 ;; All unaligned stores are considered to be 'narrow' because they typically
12755 ;; operate on less that a quadword, and when they operate on a full quadword,
12756 ;; the vanilla store high / store low sequence will cause a stall if not
12757 ;; scheduled apart.
12758 (define_insn "sthi_q"
12759 [(set (zero_extract:DI
12760 (mem:DI (plus:SI (ior:SI (match_operand:QI 0 "ua_address_operand" "p")
12763 (plus:SI (and:SI (match_dup 0) (const_int 7)) (const_int 1))
12765 (match_operand:DI 1 "arith_reg_operand" "r"))]
12768 [(set_attr "type" "ustore_media")])
12770 (define_insn_and_split "*sthi_q_comb0"
12771 [(set (zero_extract:DI
12772 (mem:DI (plus:SI (ior:SI (plus:SI (match_operand:SI 0
12773 "register_operand" "r")
12774 (match_operand:SI 1 "ua_offset"
12778 (plus:SI (and:SI (match_dup 0) (const_int 7)) (const_int 1))
12780 (match_operand:DI 2 "arith_reg_operand" "r"))]
12781 "TARGET_SHMEDIA32 && (INTVAL (operands[1]) & 7) == 0"
12785 "emit_insn (gen_sthi_q (gen_rtx_PLUS (SImode, operands[0], operands[1]),
12789 (define_insn_and_split "*sthi_q_comb1"
12790 [(set (zero_extract:DI
12791 (mem:DI (plus:SI (ior:SI (plus:SI (match_operand:SI 0
12792 "register_operand" "r")
12793 (match_operand:SI 1 "ua_offset"
12797 (plus:SI (and:SI (plus:SI (match_dup 0)
12798 (match_operand:SI 2 "ua_offset" "I06"))
12802 (match_operand:DI 3 "arith_reg_operand" "r"))]
12803 "TARGET_SHMEDIA32 && (INTVAL (operands[1]) & -8)
12804 && (INTVAL (operands[1]) & 7) == INTVAL (operands[2])"
12808 "emit_insn (gen_sthi_q (gen_rtx_PLUS (SImode, operands[0], operands[1]),
12812 ;; This is highpart user because the address is used as full 64 bit.
12813 (define_insn "stlo_l"
12814 [(set (zero_extract:SI
12815 (mem:SI (and:SI (match_operand:QI 0 "ua_address_operand" "p")
12817 (minus:SI (const_int 4) (and:SI (match_dup 0) (const_int 3)))
12818 (and:SI (match_dup 0) (const_int 3)))
12819 (match_operand:SI 1 "arith_reg_operand" "r"))]
12822 [(set_attr "type" "ustore_media")])
12824 (define_insn "stlo_q"
12825 [(set (zero_extract:DI
12826 (mem:DI (and:SI (match_operand:QI 0 "ua_address_operand" "p")
12828 (minus:SI (const_int 8) (and:SI (match_dup 0) (const_int 7)))
12829 (and:SI (match_dup 0) (const_int 7)))
12830 (match_operand:DI 1 "arith_reg_operand" "r"))]
12833 [(set_attr "type" "ustore_media")])
12835 (define_insn_and_split "*stlo_q_comb0"
12836 [(set (zero_extract:DI
12837 (mem:DI (and:SI (plus:SI (match_operand:SI 0 "register_operand" "r")
12838 (match_operand:SI 1 "ua_offset" "I06"))
12840 (minus:SI (const_int 8) (and:SI (match_dup 0) (const_int 7)))
12841 (and:SI (match_dup 0) (const_int 7)))
12842 (match_operand:DI 2 "arith_reg_operand" "r"))]
12843 "TARGET_SHMEDIA32 && (INTVAL (operands[1]) & 7) == 0"
12847 "emit_insn (gen_stlo_q (gen_rtx_PLUS (SImode, operands[0], operands[1]),
12851 (define_insn_and_split "*stlo_q_comb1"
12852 [(set (zero_extract:DI
12853 (mem:DI (and:SI (plus:SI (match_operand:SI 0 "register_operand" "r")
12854 (match_operand:SI 1 "ua_offset" "I06"))
12856 (minus:SI (const_int 8) (and:SI (plus:SI (match_dup 0)
12857 (match_operand:SI 2
12858 "ua_offset" "I06"))
12860 (and:SI (plus:SI (match_dup 0) (match_dup 2)) (const_int 7)))
12861 (match_operand:DI 3 "arith_reg_operand" "r"))]
12862 "TARGET_SHMEDIA32 && (INTVAL (operands[1]) & 7) == INTVAL (operands[2])"
12866 "emit_insn (gen_stlo_q (gen_rtx_PLUS (SImode, operands[0], operands[1]),
12870 (define_insn "ldhi_l64"
12871 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
12873 (mem:SI (plus:DI (ior:DI (match_operand:QI 1 "ua_address_operand" "p")
12876 (plus:DI (and:DI (match_dup 1) (const_int 3)) (const_int 1))
12880 [(set_attr "type" "load_media")])
12882 (define_insn "ldhi_q64"
12883 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
12885 (mem:DI (plus:DI (ior:DI (match_operand:QI 1 "ua_address_operand" "p")
12888 (plus:DI (and:DI (match_dup 1) (const_int 7)) (const_int 1))
12892 [(set_attr "type" "load_media")])
12894 (define_insn "ldlo_l64"
12895 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
12897 (mem:SI (and:DI (match_operand:QI 1 "ua_address_operand" "p")
12899 (minus:DI (const_int 4) (and:DI (match_dup 1) (const_int 3)))
12900 (and:DI (match_dup 1) (const_int 3))))]
12903 [(set_attr "type" "load_media")])
12905 (define_insn "ldlo_q64"
12906 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
12908 (mem:DI (and:DI (match_operand:QI 1 "ua_address_operand" "p")
12910 (minus:DI (const_int 8) (and:DI (match_dup 1) (const_int 7)))
12911 (and:DI (match_dup 1) (const_int 7))))]
12914 [(set_attr "type" "load_media")])
12916 (define_insn "sthi_l64"
12917 [(set (zero_extract:SI
12918 (mem:SI (plus:DI (ior:DI (match_operand:QI 0 "ua_address_operand" "p")
12921 (plus:DI (and:DI (match_dup 0) (const_int 3)) (const_int 1))
12923 (match_operand:SI 1 "arith_reg_operand" "r"))]
12926 [(set_attr "type" "ustore_media")])
12928 (define_insn "sthi_q64"
12929 [(set (zero_extract:DI
12930 (mem:DI (plus:DI (ior:DI (match_operand:QI 0 "ua_address_operand" "p")
12933 (plus:DI (and:DI (match_dup 0) (const_int 7)) (const_int 1))
12935 (match_operand:DI 1 "arith_reg_operand" "r"))]
12938 [(set_attr "type" "ustore_media")])
12940 (define_insn "stlo_l64"
12941 [(set (zero_extract:SI
12942 (mem:SI (and:DI (match_operand:QI 0 "ua_address_operand" "p")
12944 (minus:DI (const_int 4) (and:DI (match_dup 0) (const_int 3)))
12945 (and:DI (match_dup 0) (const_int 3)))
12946 (match_operand:SI 1 "arith_reg_operand" "r"))]
12949 [(set_attr "type" "ustore_media")])
12951 (define_insn "stlo_q64"
12952 [(set (zero_extract:DI
12953 (mem:DI (and:DI (match_operand:QI 0 "ua_address_operand" "p")
12955 (minus:DI (const_int 8) (and:DI (match_dup 0) (const_int 7)))
12956 (and:DI (match_dup 0) (const_int 7)))
12957 (match_operand:DI 1 "arith_reg_operand" "r"))]
12960 [(set_attr "type" "ustore_media")])
12963 [(set (match_operand:QI 0 "arith_reg_dest" "=r")
12964 (unspec:QI [(match_operand:DI 1 "arith_reg_operand" "r")]
12968 [(set_attr "type" "arith_media")])
12970 (define_insn "nsbsi"
12971 [(set (match_operand:SI 0 "arith_reg_dest" "=r")
12973 (unspec:QI [(match_operand:DI 1 "arith_reg_operand" "r")]
12977 [(set_attr "type" "arith_media")])
12979 (define_insn "nsbdi"
12980 [(set (match_operand:DI 0 "arith_reg_dest" "=r")
12982 (unspec:QI [(match_operand:DI 1 "arith_reg_operand" "r")]
12986 [(set_attr "type" "arith_media")])
12988 (define_expand "ffsdi2"
12989 [(set (match_operand:DI 0 "arith_reg_dest" "")
12990 (ffs:DI (match_operand:DI 1 "arith_reg_operand" "")))]
12994 rtx scratch = gen_reg_rtx (DImode);
12997 emit_insn (gen_adddi3 (scratch, operands[1], constm1_rtx));
12998 emit_insn (gen_xordi3 (scratch, operands[1], scratch));
12999 emit_insn (gen_lshrdi3_media (scratch, scratch, const1_rtx));
13000 emit_insn (gen_nsbdi (scratch, scratch));
13001 emit_insn (gen_adddi3 (scratch, scratch, GEN_INT (-64)));
13002 emit_insn (gen_movdicc_false (scratch, operands[1], const0_rtx, scratch));
13003 last = emit_insn (gen_subdi3 (operands[0], const0_rtx, scratch));
13005 = gen_rtx_EXPR_LIST (REG_EQUAL,
13006 gen_rtx_FFS (DImode, operands[0]), REG_NOTES (last));
13010 (define_expand "ffssi2"
13011 [(set (match_operand:SI 0 "arith_reg_dest" "")
13012 (ffs:SI (match_operand:SI 1 "arith_reg_operand" "")))]
13016 rtx scratch = gen_reg_rtx (SImode);
13017 rtx discratch = gen_reg_rtx (DImode);
13020 emit_insn (gen_adddi3 (discratch,
13021 simplify_gen_subreg (DImode, operands[1], SImode, 0),
13023 emit_insn (gen_andcdi3 (discratch,
13024 simplify_gen_subreg (DImode, operands[1], SImode, 0),
13026 emit_insn (gen_nsbsi (scratch, discratch));
13027 last = emit_insn (gen_subsi3 (operands[0],
13028 force_reg (SImode, GEN_INT (63)), scratch));
13030 = gen_rtx_EXPR_LIST (REG_EQUAL,
13031 gen_rtx_FFS (SImode, operands[0]), REG_NOTES (last));
13035 (define_insn "byterev"
13036 [(set (match_operand:V8QI 0 "arith_reg_dest" "=r")
13037 (vec_select:V8QI (match_operand:V8QI 1 "arith_reg_operand" "r")
13038 (parallel [(const_int 7) (const_int 6) (const_int 5)
13039 (const_int 4) (const_int 3) (const_int 2)
13040 (const_int 1) (const_int 0)])))]
13043 [(set_attr "type" "arith_media")])
13045 (define_insn "*prefetch_media"
13046 [(prefetch (match_operand:QI 0 "address_operand" "p")
13047 (match_operand:SI 1 "const_int_operand" "n")
13048 (match_operand:SI 2 "const_int_operand" "n"))]
13052 operands[0] = gen_rtx_MEM (QImode, operands[0]);
13053 output_asm_insn (\"ld%M0.b %m0,r63\", operands);
13056 [(set_attr "type" "other")])
13058 (define_insn "*prefetch_i4"
13059 [(prefetch (match_operand:SI 0 "register_operand" "r")
13060 (match_operand:SI 1 "const_int_operand" "n")
13061 (match_operand:SI 2 "const_int_operand" "n"))]
13062 "TARGET_HARD_SH4 || TARGET_SHCOMPACT"
13065 return \"pref @%0\";
13067 [(set_attr "type" "other")])
13069 (define_expand "prefetch"
13070 [(prefetch (match_operand 0 "address_operand" "p")
13071 (match_operand:SI 1 "const_int_operand" "n")
13072 (match_operand:SI 2 "const_int_operand" "n"))]
13073 "TARGET_HARD_SH4 || TARGET_SH5"
13076 if (GET_MODE (operands[0]) != Pmode
13077 || GET_CODE (operands[1]) != CONST_INT
13078 || GET_CODE (operands[2]) != CONST_INT)
13080 if (! TARGET_SHMEDIA)
13081 operands[0] = force_reg (Pmode, operands[0]);
13084 (define_insn "alloco_i"
13085 [(set (mem:BLK (match_operand:QI 0 "cache_address_operand" "p"))
13086 (unspec:BLK [(const_int 0)] UNSPEC_ALLOCO))]
13092 if (GET_CODE (operands[0]) == PLUS)
13094 xops[0] = XEXP (operands[0], 0);
13095 xops[1] = XEXP (operands[0], 1);
13099 xops[0] = operands[0];
13100 xops[1] = const0_rtx;
13102 output_asm_insn (\"alloco %0, %1\", xops);
13105 [(set_attr "type" "other")])
13108 [(set (match_operand 0 "any_register_operand" "")
13109 (match_operand 1 "" ""))]
13110 "TARGET_SHMEDIA && reload_completed"
13111 [(set (match_dup 0) (match_dup 1))]
13116 for_each_rtx (&operands[1], shmedia_cleanup_truncate, &n_changes);
13121 ; Stack Protector Patterns
13123 (define_expand "stack_protect_set"
13124 [(set (match_operand 0 "memory_operand" "")
13125 (match_operand 1 "memory_operand" ""))]
13128 if (TARGET_SHMEDIA)
13130 if (TARGET_SHMEDIA64)
13131 emit_insn (gen_stack_protect_set_di_media (operands[0], operands[1]));
13133 emit_insn (gen_stack_protect_set_si_media (operands[0], operands[1]));
13136 emit_insn (gen_stack_protect_set_si (operands[0], operands[1]));
13141 (define_insn "stack_protect_set_si"
13142 [(set (match_operand:SI 0 "memory_operand" "=m")
13143 (unspec:SI [(match_operand:SI 1 "memory_operand" "m")] UNSPEC_SP_SET))
13144 (set (match_scratch:SI 2 "=&r") (const_int 0))]
13146 "mov.l\t%1, %2\;mov.l\t%2, %0\;mov\t#0, %2"
13147 [(set_attr "type" "other")
13148 (set_attr "length" "6")])
13150 (define_insn "stack_protect_set_si_media"
13151 [(set (match_operand:SI 0 "memory_operand" "=m")
13152 (unspec:SI [(match_operand:SI 1 "memory_operand" "m")] UNSPEC_SP_SET))
13153 (set (match_scratch:SI 2 "=&r") (const_int 0))]
13155 "ld%M1.l\t%m1, %2\;st%M0.l\t%m0, %2\;movi\t0, %2"
13156 [(set_attr "type" "other")
13157 (set_attr "length" "12")])
13159 (define_insn "stack_protect_set_di_media"
13160 [(set (match_operand:DI 0 "memory_operand" "=m")
13161 (unspec:DI [(match_operand:DI 1 "memory_operand" "m")] UNSPEC_SP_SET))
13162 (set (match_scratch:DI 2 "=&r") (const_int 0))]
13164 "ld%M1.q\t%m1, %2\;st%M0.q\t%m0, %2\;movi\t0, %2"
13165 [(set_attr "type" "other")
13166 (set_attr "length" "12")])
13168 (define_expand "stack_protect_test"
13169 [(match_operand 0 "memory_operand" "")
13170 (match_operand 1 "memory_operand" "")
13171 (match_operand 2 "" "")]
13174 if (TARGET_SHMEDIA)
13176 rtx tmp = gen_reg_rtx (GET_MODE (operands[0]));
13178 if (TARGET_SHMEDIA64)
13179 emit_insn (gen_stack_protect_test_di_media (tmp, operands[0],
13182 emit_insn (gen_stack_protect_test_si_media (tmp, operands[0],
13185 emit_jump_insn (gen_bne_media (operands[2], tmp, const0_rtx));
13189 emit_insn (gen_stack_protect_test_si (operands[0], operands[1]));
13190 emit_jump_insn (gen_branch_true (operands[2]));
13196 (define_insn "stack_protect_test_si"
13197 [(set (reg:SI T_REG)
13198 (unspec:SI [(match_operand:SI 0 "memory_operand" "m")
13199 (match_operand:SI 1 "memory_operand" "m")]
13201 (set (match_scratch:SI 2 "=&r") (const_int 0))
13202 (set (match_scratch:SI 3 "=&r") (const_int 0))]
13204 "mov.l\t%0, %2\;mov.l\t%1, %3\;cmp/eq\t%2, %3\;mov\t#0, %2\;mov\t#0, %3"
13205 [(set_attr "type" "other")
13206 (set_attr "length" "10")])
13208 (define_insn "stack_protect_test_si_media"
13209 [(set (match_operand:SI 0 "register_operand" "=&r")
13210 (unspec:SI [(match_operand:SI 1 "memory_operand" "m")
13211 (match_operand:SI 2 "memory_operand" "m")]
13213 (set (match_scratch:SI 3 "=&r") (const_int 0))]
13215 "ld%M1.l\t%m1, %0\;ld%M2.l\t%m2, %3\;cmpeq\t%0, %3, %0\;movi\t0, %3"
13216 [(set_attr "type" "other")
13217 (set_attr "length" "16")])
13219 (define_insn "stack_protect_test_di_media"
13220 [(set (match_operand:DI 0 "register_operand" "=&r")
13221 (unspec:DI [(match_operand:DI 1 "memory_operand" "m")
13222 (match_operand:DI 2 "memory_operand" "m")]
13224 (set (match_scratch:DI 3 "=&r") (const_int 0))]
13226 "ld%M1.q\t%m1, %0\;ld%M2.q\t%m2, %3\;cmpeq\t%0, %3, %0\;movi\t0, %3"
13227 [(set_attr "type" "other")
13228 (set_attr "length" "16")])