1 ;; Mips.md Machine Description for MIPS based processors
2 ;; Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 ;; 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4 ;; Contributed by A. Lichnewsky, lich@inria.inria.fr
5 ;; Changes by Michael Meissner, meissner@osf.org
6 ;; 64 bit r4000 support by Ian Lance Taylor, ian@cygnus.com, and
7 ;; Brendan Eich, brendan@microunity.com.
9 ;; This file is part of GCC.
11 ;; GCC is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GCC is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GCC; see the file COPYING. If not, write to
23 ;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
27 [(UNSPEC_LOAD_DF_LOW 0)
28 (UNSPEC_LOAD_DF_HIGH 1)
29 (UNSPEC_STORE_DF_HIGH 2)
33 (UNSPEC_EH_RECEIVER 6)
35 (UNSPEC_CONSTTABLE_INT 8)
36 (UNSPEC_CONSTTABLE_FLOAT 9)
40 (UNSPEC_LOAD_RIGHT 19)
41 (UNSPEC_STORE_LEFT 20)
42 (UNSPEC_STORE_RIGHT 21)
49 (UNSPEC_TLS_GET_TP 28)
51 (UNSPEC_ADDRESS_FIRST 100)
55 ;; For MIPS Paired-Singled Floating Point Instructions.
57 (UNSPEC_MOVE_TF_PS 200)
60 ;; MIPS64/MIPS32R2 alnv.ps
63 ;; MIPS-3D instructions
67 (UNSPEC_CVT_PW_PS 205)
68 (UNSPEC_CVT_PS_PW 206)
76 ;; MIPS DSP ASE Revision 0.98 3/24/2005
84 (UNSPEC_RADDU_W_QB 307)
86 (UNSPEC_PRECRQ_QB_PH 309)
87 (UNSPEC_PRECRQ_PH_W 310)
88 (UNSPEC_PRECRQ_RS_PH_W 311)
89 (UNSPEC_PRECRQU_S_QB_PH 312)
90 (UNSPEC_PRECEQ_W_PHL 313)
91 (UNSPEC_PRECEQ_W_PHR 314)
92 (UNSPEC_PRECEQU_PH_QBL 315)
93 (UNSPEC_PRECEQU_PH_QBR 316)
94 (UNSPEC_PRECEQU_PH_QBLA 317)
95 (UNSPEC_PRECEQU_PH_QBRA 318)
96 (UNSPEC_PRECEU_PH_QBL 319)
97 (UNSPEC_PRECEU_PH_QBR 320)
98 (UNSPEC_PRECEU_PH_QBLA 321)
99 (UNSPEC_PRECEU_PH_QBRA 322)
105 (UNSPEC_MULEU_S_PH_QBL 328)
106 (UNSPEC_MULEU_S_PH_QBR 329)
107 (UNSPEC_MULQ_RS_PH 330)
108 (UNSPEC_MULEQ_S_W_PHL 331)
109 (UNSPEC_MULEQ_S_W_PHR 332)
110 (UNSPEC_DPAU_H_QBL 333)
111 (UNSPEC_DPAU_H_QBR 334)
112 (UNSPEC_DPSU_H_QBL 335)
113 (UNSPEC_DPSU_H_QBR 336)
114 (UNSPEC_DPAQ_S_W_PH 337)
115 (UNSPEC_DPSQ_S_W_PH 338)
116 (UNSPEC_MULSAQ_S_W_PH 339)
117 (UNSPEC_DPAQ_SA_L_W 340)
118 (UNSPEC_DPSQ_SA_L_W 341)
119 (UNSPEC_MAQ_S_W_PHL 342)
120 (UNSPEC_MAQ_S_W_PHR 343)
121 (UNSPEC_MAQ_SA_W_PHL 344)
122 (UNSPEC_MAQ_SA_W_PHR 345)
130 (UNSPEC_CMPGU_EQ_QB 353)
131 (UNSPEC_CMPGU_LT_QB 354)
132 (UNSPEC_CMPGU_LE_QB 355)
134 (UNSPEC_PACKRL_PH 357)
136 (UNSPEC_EXTR_R_W 359)
137 (UNSPEC_EXTR_RS_W 360)
138 (UNSPEC_EXTR_S_H 361)
148 (include "predicates.md")
150 ;; ....................
154 ;; ....................
156 (define_attr "got" "unset,xgot_high,load"
157 (const_string "unset"))
159 ;; For jal instructions, this attribute is DIRECT when the target address
160 ;; is symbolic and INDIRECT when it is a register.
161 (define_attr "jal" "unset,direct,indirect"
162 (const_string "unset"))
164 ;; This attribute is YES if the instruction is a jal macro (not a
165 ;; real jal instruction).
167 ;; jal is always a macro in SVR4 PIC since it includes an instruction to
168 ;; restore $gp. Direct jals are also macros in NewABI PIC since they
169 ;; load the target address into $25.
170 (define_attr "jal_macro" "no,yes"
171 (cond [(eq_attr "jal" "direct")
172 (symbol_ref "TARGET_ABICALLS != 0")
173 (eq_attr "jal" "indirect")
174 (symbol_ref "(TARGET_ABICALLS && !TARGET_NEWABI) != 0")]
175 (const_string "no")))
177 ;; Classification of each insn.
178 ;; branch conditional branch
179 ;; jump unconditional jump
180 ;; call unconditional call
181 ;; load load instruction(s)
182 ;; fpload floating point load
183 ;; fpidxload floating point indexed load
184 ;; store store instruction(s)
185 ;; fpstore floating point store
186 ;; fpidxstore floating point indexed store
187 ;; prefetch memory prefetch (register + offset)
188 ;; prefetchx memory indexed prefetch (register + register)
189 ;; condmove conditional moves
190 ;; xfer transfer to/from coprocessor
191 ;; mthilo transfer to hi/lo registers
192 ;; mfhilo transfer from hi/lo registers
193 ;; const load constant
194 ;; arith integer arithmetic and logical instructions
195 ;; shift integer shift instructions
196 ;; slt set less than instructions
197 ;; clz the clz and clo instructions
198 ;; trap trap if instructions
199 ;; imul integer multiply 2 operands
200 ;; imul3 integer multiply 3 operands
201 ;; imadd integer multiply-add
202 ;; idiv integer divide
203 ;; fmove floating point register move
204 ;; fadd floating point add/subtract
205 ;; fmul floating point multiply
206 ;; fmadd floating point multiply-add
207 ;; fdiv floating point divide
208 ;; frdiv floating point reciprocal divide
209 ;; frdiv1 floating point reciprocal divide step 1
210 ;; frdiv2 floating point reciprocal divide step 2
211 ;; fabs floating point absolute value
212 ;; fneg floating point negation
213 ;; fcmp floating point compare
214 ;; fcvt floating point convert
215 ;; fsqrt floating point square root
216 ;; frsqrt floating point reciprocal square root
217 ;; frsqrt1 floating point reciprocal square root step1
218 ;; frsqrt2 floating point reciprocal square root step2
219 ;; multi multiword sequence (or user asm statements)
222 "unknown,branch,jump,call,load,fpload,fpidxload,store,fpstore,fpidxstore,prefetch,prefetchx,condmove,xfer,mthilo,mfhilo,const,arith,shift,slt,clz,trap,imul,imul3,imadd,idiv,fmove,fadd,fmul,fmadd,fdiv,frdiv,frdiv1,frdiv2,fabs,fneg,fcmp,fcvt,fsqrt,frsqrt,frsqrt1,frsqrt2,multi,nop"
223 (cond [(eq_attr "jal" "!unset") (const_string "call")
224 (eq_attr "got" "load") (const_string "load")]
225 (const_string "unknown")))
227 ;; Main data type used by the insn
228 (define_attr "mode" "unknown,none,QI,HI,SI,DI,SF,DF,FPSW"
229 (const_string "unknown"))
231 ;; Mode for conversion types (fcvt)
232 ;; I2S integer to float single (SI/DI to SF)
233 ;; I2D integer to float double (SI/DI to DF)
234 ;; S2I float to integer (SF to SI/DI)
235 ;; D2I float to integer (DF to SI/DI)
236 ;; D2S double to float single
237 ;; S2D float single to double
239 (define_attr "cnv_mode" "unknown,I2S,I2D,S2I,D2I,D2S,S2D"
240 (const_string "unknown"))
242 ;; Is this an extended instruction in mips16 mode?
243 (define_attr "extended_mips16" "no,yes"
246 ;; Length of instruction in bytes.
247 (define_attr "length" ""
248 (cond [;; Direct branch instructions have a range of [-0x40000,0x3fffc].
249 ;; If a branch is outside this range, we have a choice of two
250 ;; sequences. For PIC, an out-of-range branch like:
255 ;; becomes the equivalent of:
264 ;; where the load address can be up to three instructions long
267 ;; The non-PIC case is similar except that we use a direct
268 ;; jump instead of an la/jr pair. Since the target of this
269 ;; jump is an absolute 28-bit bit address (the other bits
270 ;; coming from the address of the delay slot) this form cannot
271 ;; cross a 256MB boundary. We could provide the option of
272 ;; using la/jr in this case too, but we do not do so at
275 ;; Note that this value does not account for the delay slot
276 ;; instruction, whose length is added separately. If the RTL
277 ;; pattern has no explicit delay slot, mips_adjust_insn_length
278 ;; will add the length of the implicit nop. The values for
279 ;; forward and backward branches will be different as well.
280 (eq_attr "type" "branch")
281 (cond [(and (le (minus (match_dup 1) (pc)) (const_int 131064))
282 (le (minus (pc) (match_dup 1)) (const_int 131068)))
284 (ne (symbol_ref "flag_pic") (const_int 0))
288 (eq_attr "got" "load")
290 (eq_attr "got" "xgot_high")
293 (eq_attr "type" "const")
294 (symbol_ref "mips_const_insns (operands[1]) * 4")
295 (eq_attr "type" "load,fpload")
296 (symbol_ref "mips_fetch_insns (operands[1]) * 4")
297 (eq_attr "type" "store,fpstore")
298 (symbol_ref "mips_fetch_insns (operands[0]) * 4")
300 ;; In the worst case, a call macro will take 8 instructions:
302 ;; lui $25,%call_hi(FOO)
304 ;; lw $25,%call_lo(FOO)($25)
310 (eq_attr "jal_macro" "yes")
313 (and (eq_attr "extended_mips16" "yes")
314 (ne (symbol_ref "TARGET_MIPS16") (const_int 0)))
317 ;; Various VR4120 errata require a nop to be inserted after a macc
318 ;; instruction. The assembler does this for us, so account for
319 ;; the worst-case length here.
320 (and (eq_attr "type" "imadd")
321 (ne (symbol_ref "TARGET_FIX_VR4120") (const_int 0)))
324 ;; VR4120 errata MD(4): if there are consecutive dmult instructions,
325 ;; the result of the second one is missed. The assembler should work
326 ;; around this by inserting a nop after the first dmult.
327 (and (eq_attr "type" "imul,imul3")
328 (and (eq_attr "mode" "DI")
329 (ne (symbol_ref "TARGET_FIX_VR4120") (const_int 0))))
332 (eq_attr "type" "idiv")
333 (symbol_ref "mips_idiv_insns () * 4")
336 ;; Attribute describing the processor. This attribute must match exactly
337 ;; with the processor_type enumeration in mips.h.
339 "r3000,4kc,4kp,5kc,5kf,20kc,24k,24kx,m4k,r3900,r6000,r4000,r4100,r4111,r4120,r4130,r4300,r4600,r4650,r5000,r5400,r5500,r7000,r8000,r9000,sb1,sr71000"
340 (const (symbol_ref "mips_tune")))
342 ;; The type of hardware hazard associated with this instruction.
343 ;; DELAY means that the next instruction cannot read the result
344 ;; of this one. HILO means that the next two instructions cannot
345 ;; write to HI or LO.
346 (define_attr "hazard" "none,delay,hilo"
347 (cond [(and (eq_attr "type" "load,fpload,fpidxload")
348 (ne (symbol_ref "ISA_HAS_LOAD_DELAY") (const_int 0)))
349 (const_string "delay")
351 (and (eq_attr "type" "xfer")
352 (ne (symbol_ref "ISA_HAS_XFER_DELAY") (const_int 0)))
353 (const_string "delay")
355 (and (eq_attr "type" "fcmp")
356 (ne (symbol_ref "ISA_HAS_FCMP_DELAY") (const_int 0)))
357 (const_string "delay")
359 ;; The r4000 multiplication patterns include an mflo instruction.
360 (and (eq_attr "type" "imul")
361 (ne (symbol_ref "TARGET_FIX_R4000") (const_int 0)))
362 (const_string "hilo")
364 (and (eq_attr "type" "mfhilo")
365 (eq (symbol_ref "ISA_HAS_HILO_INTERLOCKS") (const_int 0)))
366 (const_string "hilo")]
367 (const_string "none")))
369 ;; Is it a single instruction?
370 (define_attr "single_insn" "no,yes"
371 (symbol_ref "get_attr_length (insn) == (TARGET_MIPS16 ? 2 : 4)"))
373 ;; Can the instruction be put into a delay slot?
374 (define_attr "can_delay" "no,yes"
375 (if_then_else (and (eq_attr "type" "!branch,call,jump")
376 (and (eq_attr "hazard" "none")
377 (eq_attr "single_insn" "yes")))
379 (const_string "no")))
381 ;; Attribute defining whether or not we can use the branch-likely instructions
382 (define_attr "branch_likely" "no,yes"
384 (if_then_else (ne (symbol_ref "GENERATE_BRANCHLIKELY") (const_int 0))
386 (const_string "no"))))
388 ;; True if an instruction might assign to hi or lo when reloaded.
389 ;; This is used by the TUNE_MACC_CHAINS code.
390 (define_attr "may_clobber_hilo" "no,yes"
391 (if_then_else (eq_attr "type" "imul,imul3,imadd,idiv,mthilo")
393 (const_string "no")))
395 ;; Describe a user's asm statement.
396 (define_asm_attributes
397 [(set_attr "type" "multi")
398 (set_attr "can_delay" "no")])
400 ;; This mode macro allows 32-bit and 64-bit GPR patterns to be generated
401 ;; from the same template.
402 (define_mode_macro GPR [SI (DI "TARGET_64BIT")])
404 ;; This mode macro allows :P to be used for patterns that operate on
405 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
406 (define_mode_macro P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
408 ;; This mode macro allows :MOVECC to be used anywhere that a
409 ;; conditional-move-type condition is needed.
410 (define_mode_macro MOVECC [SI (DI "TARGET_64BIT") (CC "TARGET_HARD_FLOAT")])
412 ;; This mode macro allows the QI and HI extension patterns to be defined from
413 ;; the same template.
414 (define_mode_macro SHORT [QI HI])
416 ;; This mode macro allows :ANYF to be used wherever a scalar or vector
417 ;; floating-point mode is allowed.
418 (define_mode_macro ANYF [(SF "TARGET_HARD_FLOAT")
419 (DF "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT")
420 (V2SF "TARGET_PAIRED_SINGLE_FLOAT")])
422 ;; Like ANYF, but only applies to scalar modes.
423 (define_mode_macro SCALARF [(SF "TARGET_HARD_FLOAT")
424 (DF "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT")])
426 ;; In GPR templates, a string like "<d>subu" will expand to "subu" in the
427 ;; 32-bit version and "dsubu" in the 64-bit version.
428 (define_mode_attr d [(SI "") (DI "d")])
430 ;; This attribute gives the length suffix for a sign- or zero-extension
432 (define_mode_attr size [(QI "b") (HI "h")])
434 ;; This attributes gives the mode mask of a SHORT.
435 (define_mode_attr mask [(QI "0x00ff") (HI "0xffff")])
437 ;; Mode attributes for GPR loads and stores.
438 (define_mode_attr load [(SI "lw") (DI "ld")])
439 (define_mode_attr store [(SI "sw") (DI "sd")])
441 ;; Similarly for MIPS IV indexed FPR loads and stores.
442 (define_mode_attr loadx [(SF "lwxc1") (DF "ldxc1") (V2SF "ldxc1")])
443 (define_mode_attr storex [(SF "swxc1") (DF "sdxc1") (V2SF "sdxc1")])
445 ;; The unextended ranges of the MIPS16 addiu and daddiu instructions
446 ;; are different. Some forms of unextended addiu have an 8-bit immediate
447 ;; field but the equivalent daddiu has only a 5-bit field.
448 (define_mode_attr si8_di5 [(SI "8") (DI "5")])
450 ;; This attribute gives the best constraint to use for registers of
452 (define_mode_attr reg [(SI "d") (DI "d") (CC "z")])
454 ;; This attribute gives the format suffix for floating-point operations.
455 (define_mode_attr fmt [(SF "s") (DF "d") (V2SF "ps")])
457 ;; This attribute gives the upper-case mode name for one unit of a
458 ;; floating-point mode.
459 (define_mode_attr UNITMODE [(SF "SF") (DF "DF") (V2SF "SF")])
461 ;; This attribute works around the early SB-1 rev2 core "F2" erratum:
463 ;; In certain cases, div.s and div.ps may have a rounding error
464 ;; and/or wrong inexact flag.
466 ;; Therefore, we only allow div.s if not working around SB-1 rev2
467 ;; errata or if a slight loss of precision is OK.
468 (define_mode_attr divide_condition
469 [DF (SF "!TARGET_FIX_SB1 || flag_unsafe_math_optimizations")
470 (V2SF "TARGET_SB1 && (!TARGET_FIX_SB1 || flag_unsafe_math_optimizations)")])
472 ; This attribute gives the condition for which sqrt instructions exist.
473 (define_mode_attr sqrt_condition
474 [(SF "!ISA_MIPS1") (DF "!ISA_MIPS1") (V2SF "TARGET_SB1")])
476 ; This attribute gives the condition for which recip and rsqrt instructions
478 (define_mode_attr recip_condition
479 [(SF "ISA_HAS_FP4") (DF "ISA_HAS_FP4") (V2SF "TARGET_SB1")])
481 ;; This code macro allows all branch instructions to be generated from
482 ;; a single define_expand template.
483 (define_code_macro any_cond [unordered ordered unlt unge uneq ltgt unle ungt
484 eq ne gt ge lt le gtu geu ltu leu])
486 ;; This code macro allows signed and unsigned widening multiplications
487 ;; to use the same template.
488 (define_code_macro any_extend [sign_extend zero_extend])
490 ;; This code macro allows the three shift instructions to be generated
491 ;; from the same template.
492 (define_code_macro any_shift [ashift ashiftrt lshiftrt])
494 ;; This code macro allows all native floating-point comparisons to be
495 ;; generated from the same template.
496 (define_code_macro fcond [unordered uneq unlt unle eq lt le])
498 ;; This code macro is used for comparisons that can be implemented
499 ;; by swapping the operands.
500 (define_code_macro swapped_fcond [ge gt unge ungt])
502 ;; <u> expands to an empty string when doing a signed operation and
503 ;; "u" when doing an unsigned operation.
504 (define_code_attr u [(sign_extend "") (zero_extend "u")])
506 ;; <su> is like <u>, but the signed form expands to "s" rather than "".
507 (define_code_attr su [(sign_extend "s") (zero_extend "u")])
509 ;; <optab> expands to the name of the optab for a particular code.
510 (define_code_attr optab [(ashift "ashl")
514 ;; <insn> expands to the name of the insn that implements a particular code.
515 (define_code_attr insn [(ashift "sll")
519 ;; <fcond> is the c.cond.fmt condition associated with a particular code.
520 (define_code_attr fcond [(unordered "un")
528 ;; Similar, but for swapped conditions.
529 (define_code_attr swapped_fcond [(ge "le")
534 ;; .........................
536 ;; Branch, call and jump delay slots
538 ;; .........................
540 (define_delay (and (eq_attr "type" "branch")
541 (eq (symbol_ref "TARGET_MIPS16") (const_int 0)))
542 [(eq_attr "can_delay" "yes")
544 (and (eq_attr "branch_likely" "yes")
545 (eq_attr "can_delay" "yes"))])
547 (define_delay (eq_attr "type" "jump")
548 [(eq_attr "can_delay" "yes")
552 (define_delay (and (eq_attr "type" "call")
553 (eq_attr "jal_macro" "no"))
554 [(eq_attr "can_delay" "yes")
558 ;; Pipeline descriptions.
560 ;; generic.md provides a fallback for processors without a specific
561 ;; pipeline description. It is derived from the old define_function_unit
562 ;; version and uses the "alu" and "imuldiv" units declared below.
564 ;; Some of the processor-specific files are also derived from old
565 ;; define_function_unit descriptions and simply override the parts of
566 ;; generic.md that don't apply. The other processor-specific files
567 ;; are self-contained.
568 (define_automaton "alu,imuldiv")
570 (define_cpu_unit "alu" "alu")
571 (define_cpu_unit "imuldiv" "imuldiv")
590 (include "generic.md")
593 ;; ....................
597 ;; ....................
601 [(trap_if (const_int 1) (const_int 0))]
604 if (ISA_HAS_COND_TRAP)
606 else if (TARGET_MIPS16)
611 [(set_attr "type" "trap")])
613 (define_expand "conditional_trap"
614 [(trap_if (match_operator 0 "comparison_operator"
615 [(match_dup 2) (match_dup 3)])
616 (match_operand 1 "const_int_operand"))]
619 if (GET_MODE_CLASS (GET_MODE (cmp_operands[0])) == MODE_INT
620 && operands[1] == const0_rtx)
622 mips_gen_conditional_trap (operands);
629 (define_insn "*conditional_trap<mode>"
630 [(trap_if (match_operator:GPR 0 "trap_comparison_operator"
631 [(match_operand:GPR 1 "reg_or_0_operand" "dJ")
632 (match_operand:GPR 2 "arith_operand" "dI")])
636 [(set_attr "type" "trap")])
639 ;; ....................
643 ;; ....................
646 (define_insn "add<mode>3"
647 [(set (match_operand:ANYF 0 "register_operand" "=f")
648 (plus:ANYF (match_operand:ANYF 1 "register_operand" "f")
649 (match_operand:ANYF 2 "register_operand" "f")))]
651 "add.<fmt>\t%0,%1,%2"
652 [(set_attr "type" "fadd")
653 (set_attr "mode" "<UNITMODE>")])
655 (define_expand "add<mode>3"
656 [(set (match_operand:GPR 0 "register_operand")
657 (plus:GPR (match_operand:GPR 1 "register_operand")
658 (match_operand:GPR 2 "arith_operand")))]
661 (define_insn "*add<mode>3"
662 [(set (match_operand:GPR 0 "register_operand" "=d,d")
663 (plus:GPR (match_operand:GPR 1 "register_operand" "d,d")
664 (match_operand:GPR 2 "arith_operand" "d,Q")))]
669 [(set_attr "type" "arith")
670 (set_attr "mode" "<MODE>")])
672 ;; We need to recognize MIPS16 stack pointer additions explicitly, since
673 ;; we don't have a constraint for $sp. These insns will be generated by
674 ;; the save_restore_insns functions.
676 (define_insn "*add<mode>3_sp1"
678 (plus:GPR (reg:GPR 29)
679 (match_operand:GPR 0 "const_arith_operand" "")))]
682 [(set_attr "type" "arith")
683 (set_attr "mode" "<MODE>")
684 (set (attr "length") (if_then_else (match_operand 0 "m16_simm8_8")
688 (define_insn "*add<mode>3_sp2"
689 [(set (match_operand:GPR 0 "register_operand" "=d")
690 (plus:GPR (reg:GPR 29)
691 (match_operand:GPR 1 "const_arith_operand" "")))]
694 [(set_attr "type" "arith")
695 (set_attr "mode" "<MODE>")
696 (set (attr "length") (if_then_else (match_operand 1 "m16_uimm<si8_di5>_4")
700 (define_insn "*add<mode>3_mips16"
701 [(set (match_operand:GPR 0 "register_operand" "=d,d,d")
702 (plus:GPR (match_operand:GPR 1 "register_operand" "0,d,d")
703 (match_operand:GPR 2 "arith_operand" "Q,O,d")))]
709 [(set_attr "type" "arith")
710 (set_attr "mode" "<MODE>")
711 (set_attr_alternative "length"
712 [(if_then_else (match_operand 2 "m16_simm<si8_di5>_1")
715 (if_then_else (match_operand 2 "m16_simm4_1")
721 ;; On the mips16, we can sometimes split an add of a constant which is
722 ;; a 4 byte instruction into two adds which are both 2 byte
723 ;; instructions. There are two cases: one where we are adding a
724 ;; constant plus a register to another register, and one where we are
725 ;; simply adding a constant to a register.
728 [(set (match_operand:SI 0 "register_operand")
729 (plus:SI (match_dup 0)
730 (match_operand:SI 1 "const_int_operand")))]
731 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
732 && REG_P (operands[0])
733 && M16_REG_P (REGNO (operands[0]))
734 && GET_CODE (operands[1]) == CONST_INT
735 && ((INTVAL (operands[1]) > 0x7f
736 && INTVAL (operands[1]) <= 0x7f + 0x7f)
737 || (INTVAL (operands[1]) < - 0x80
738 && INTVAL (operands[1]) >= - 0x80 - 0x80))"
739 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
740 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]
742 HOST_WIDE_INT val = INTVAL (operands[1]);
746 operands[1] = GEN_INT (0x7f);
747 operands[2] = GEN_INT (val - 0x7f);
751 operands[1] = GEN_INT (- 0x80);
752 operands[2] = GEN_INT (val + 0x80);
757 [(set (match_operand:SI 0 "register_operand")
758 (plus:SI (match_operand:SI 1 "register_operand")
759 (match_operand:SI 2 "const_int_operand")))]
760 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
761 && REG_P (operands[0])
762 && M16_REG_P (REGNO (operands[0]))
763 && REG_P (operands[1])
764 && M16_REG_P (REGNO (operands[1]))
765 && REGNO (operands[0]) != REGNO (operands[1])
766 && GET_CODE (operands[2]) == CONST_INT
767 && ((INTVAL (operands[2]) > 0x7
768 && INTVAL (operands[2]) <= 0x7 + 0x7f)
769 || (INTVAL (operands[2]) < - 0x8
770 && INTVAL (operands[2]) >= - 0x8 - 0x80))"
771 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))
772 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 3)))]
774 HOST_WIDE_INT val = INTVAL (operands[2]);
778 operands[2] = GEN_INT (0x7);
779 operands[3] = GEN_INT (val - 0x7);
783 operands[2] = GEN_INT (- 0x8);
784 operands[3] = GEN_INT (val + 0x8);
789 [(set (match_operand:DI 0 "register_operand")
790 (plus:DI (match_dup 0)
791 (match_operand:DI 1 "const_int_operand")))]
792 "TARGET_MIPS16 && TARGET_64BIT && reload_completed && !TARGET_DEBUG_D_MODE
793 && REG_P (operands[0])
794 && M16_REG_P (REGNO (operands[0]))
795 && GET_CODE (operands[1]) == CONST_INT
796 && ((INTVAL (operands[1]) > 0xf
797 && INTVAL (operands[1]) <= 0xf + 0xf)
798 || (INTVAL (operands[1]) < - 0x10
799 && INTVAL (operands[1]) >= - 0x10 - 0x10))"
800 [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1)))
801 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))]
803 HOST_WIDE_INT val = INTVAL (operands[1]);
807 operands[1] = GEN_INT (0xf);
808 operands[2] = GEN_INT (val - 0xf);
812 operands[1] = GEN_INT (- 0x10);
813 operands[2] = GEN_INT (val + 0x10);
818 [(set (match_operand:DI 0 "register_operand")
819 (plus:DI (match_operand:DI 1 "register_operand")
820 (match_operand:DI 2 "const_int_operand")))]
821 "TARGET_MIPS16 && TARGET_64BIT && reload_completed && !TARGET_DEBUG_D_MODE
822 && REG_P (operands[0])
823 && M16_REG_P (REGNO (operands[0]))
824 && REG_P (operands[1])
825 && M16_REG_P (REGNO (operands[1]))
826 && REGNO (operands[0]) != REGNO (operands[1])
827 && GET_CODE (operands[2]) == CONST_INT
828 && ((INTVAL (operands[2]) > 0x7
829 && INTVAL (operands[2]) <= 0x7 + 0xf)
830 || (INTVAL (operands[2]) < - 0x8
831 && INTVAL (operands[2]) >= - 0x8 - 0x10))"
832 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))
833 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
835 HOST_WIDE_INT val = INTVAL (operands[2]);
839 operands[2] = GEN_INT (0x7);
840 operands[3] = GEN_INT (val - 0x7);
844 operands[2] = GEN_INT (- 0x8);
845 operands[3] = GEN_INT (val + 0x8);
849 (define_insn "*addsi3_extended"
850 [(set (match_operand:DI 0 "register_operand" "=d,d")
852 (plus:SI (match_operand:SI 1 "register_operand" "d,d")
853 (match_operand:SI 2 "arith_operand" "d,Q"))))]
854 "TARGET_64BIT && !TARGET_MIPS16"
858 [(set_attr "type" "arith")
859 (set_attr "mode" "SI")])
861 ;; Split this insn so that the addiu splitters can have a crack at it.
862 ;; Use a conservative length estimate until the split.
863 (define_insn_and_split "*addsi3_extended_mips16"
864 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
866 (plus:SI (match_operand:SI 1 "register_operand" "0,d,d")
867 (match_operand:SI 2 "arith_operand" "Q,O,d"))))]
868 "TARGET_64BIT && TARGET_MIPS16"
870 "&& reload_completed"
871 [(set (match_dup 3) (plus:SI (match_dup 1) (match_dup 2)))]
872 { operands[3] = gen_lowpart (SImode, operands[0]); }
873 [(set_attr "type" "arith")
874 (set_attr "mode" "SI")
875 (set_attr "extended_mips16" "yes")])
878 ;; ....................
882 ;; ....................
885 (define_insn "sub<mode>3"
886 [(set (match_operand:ANYF 0 "register_operand" "=f")
887 (minus:ANYF (match_operand:ANYF 1 "register_operand" "f")
888 (match_operand:ANYF 2 "register_operand" "f")))]
890 "sub.<fmt>\t%0,%1,%2"
891 [(set_attr "type" "fadd")
892 (set_attr "mode" "<UNITMODE>")])
894 (define_insn "sub<mode>3"
895 [(set (match_operand:GPR 0 "register_operand" "=d")
896 (minus:GPR (match_operand:GPR 1 "register_operand" "d")
897 (match_operand:GPR 2 "register_operand" "d")))]
900 [(set_attr "type" "arith")
901 (set_attr "mode" "<MODE>")])
903 (define_insn "*subsi3_extended"
904 [(set (match_operand:DI 0 "register_operand" "=d")
906 (minus:SI (match_operand:SI 1 "register_operand" "d")
907 (match_operand:SI 2 "register_operand" "d"))))]
910 [(set_attr "type" "arith")
911 (set_attr "mode" "DI")])
914 ;; ....................
918 ;; ....................
921 (define_expand "mul<mode>3"
922 [(set (match_operand:SCALARF 0 "register_operand")
923 (mult:SCALARF (match_operand:SCALARF 1 "register_operand")
924 (match_operand:SCALARF 2 "register_operand")))]
928 (define_insn "*mul<mode>3"
929 [(set (match_operand:SCALARF 0 "register_operand" "=f")
930 (mult:SCALARF (match_operand:SCALARF 1 "register_operand" "f")
931 (match_operand:SCALARF 2 "register_operand" "f")))]
932 "!TARGET_4300_MUL_FIX"
933 "mul.<fmt>\t%0,%1,%2"
934 [(set_attr "type" "fmul")
935 (set_attr "mode" "<MODE>")])
937 ;; Early VR4300 silicon has a CPU bug where multiplies with certain
938 ;; operands may corrupt immediately following multiplies. This is a
939 ;; simple fix to insert NOPs.
941 (define_insn "*mul<mode>3_r4300"
942 [(set (match_operand:SCALARF 0 "register_operand" "=f")
943 (mult:SCALARF (match_operand:SCALARF 1 "register_operand" "f")
944 (match_operand:SCALARF 2 "register_operand" "f")))]
945 "TARGET_4300_MUL_FIX"
946 "mul.<fmt>\t%0,%1,%2\;nop"
947 [(set_attr "type" "fmul")
948 (set_attr "mode" "<MODE>")
949 (set_attr "length" "8")])
951 (define_insn "mulv2sf3"
952 [(set (match_operand:V2SF 0 "register_operand" "=f")
953 (mult:V2SF (match_operand:V2SF 1 "register_operand" "f")
954 (match_operand:V2SF 2 "register_operand" "f")))]
955 "TARGET_PAIRED_SINGLE_FLOAT"
957 [(set_attr "type" "fmul")
958 (set_attr "mode" "SF")])
960 ;; The original R4000 has a cpu bug. If a double-word or a variable
961 ;; shift executes while an integer multiplication is in progress, the
962 ;; shift may give an incorrect result. Avoid this by keeping the mflo
963 ;; with the mult on the R4000.
965 ;; From "MIPS R4000PC/SC Errata, Processor Revision 2.2 and 3.0"
966 ;; (also valid for MIPS R4000MC processors):
968 ;; "16. R4000PC, R4000SC: Please refer to errata 28 for an update to
969 ;; this errata description.
970 ;; The following code sequence causes the R4000 to incorrectly
971 ;; execute the Double Shift Right Arithmetic 32 (dsra32)
972 ;; instruction. If the dsra32 instruction is executed during an
973 ;; integer multiply, the dsra32 will only shift by the amount in
974 ;; specified in the instruction rather than the amount plus 32
976 ;; instruction 1: mult rs,rt integer multiply
977 ;; instruction 2-12: dsra32 rd,rt,rs doubleword shift
978 ;; right arithmetic + 32
979 ;; Workaround: A dsra32 instruction placed after an integer
980 ;; multiply should not be one of the 11 instructions after the
981 ;; multiply instruction."
985 ;; "28. R4000PC, R4000SC: The text from errata 16 should be replaced by
986 ;; the following description.
987 ;; All extended shifts (shift by n+32) and variable shifts (32 and
988 ;; 64-bit versions) may produce incorrect results under the
989 ;; following conditions:
990 ;; 1) An integer multiply is currently executing
991 ;; 2) These types of shift instructions are executed immediately
992 ;; following an integer divide instruction.
994 ;; 1) Make sure no integer multiply is running wihen these
995 ;; instruction are executed. If this cannot be predicted at
996 ;; compile time, then insert a "mfhi" to R0 instruction
997 ;; immediately after the integer multiply instruction. This
998 ;; will cause the integer multiply to complete before the shift
1000 ;; 2) Separate integer divide and these two classes of shift
1001 ;; instructions by another instruction or a noop."
1003 ;; These processors have PRId values of 0x00004220 and 0x00004300,
1006 (define_expand "mul<mode>3"
1007 [(set (match_operand:GPR 0 "register_operand")
1008 (mult:GPR (match_operand:GPR 1 "register_operand")
1009 (match_operand:GPR 2 "register_operand")))]
1012 if (GENERATE_MULT3_<MODE>)
1013 emit_insn (gen_mul<mode>3_mult3 (operands[0], operands[1], operands[2]));
1014 else if (!TARGET_FIX_R4000)
1015 emit_insn (gen_mul<mode>3_internal (operands[0], operands[1],
1018 emit_insn (gen_mul<mode>3_r4000 (operands[0], operands[1], operands[2]));
1022 (define_insn "mulsi3_mult3"
1023 [(set (match_operand:SI 0 "register_operand" "=d,l")
1024 (mult:SI (match_operand:SI 1 "register_operand" "d,d")
1025 (match_operand:SI 2 "register_operand" "d,d")))
1026 (clobber (match_scratch:SI 3 "=h,h"))
1027 (clobber (match_scratch:SI 4 "=l,X"))]
1030 if (which_alternative == 1)
1031 return "mult\t%1,%2";
1040 return "mul\t%0,%1,%2";
1041 return "mult\t%0,%1,%2";
1043 [(set_attr "type" "imul3,imul")
1044 (set_attr "mode" "SI")])
1046 (define_insn "muldi3_mult3"
1047 [(set (match_operand:DI 0 "register_operand" "=d")
1048 (mult:DI (match_operand:DI 1 "register_operand" "d")
1049 (match_operand:DI 2 "register_operand" "d")))
1050 (clobber (match_scratch:DI 3 "=h"))
1051 (clobber (match_scratch:DI 4 "=l"))]
1052 "TARGET_64BIT && GENERATE_MULT3_DI"
1054 [(set_attr "type" "imul3")
1055 (set_attr "mode" "DI")])
1057 ;; If a register gets allocated to LO, and we spill to memory, the reload
1058 ;; will include a move from LO to a GPR. Merge it into the multiplication
1059 ;; if it can set the GPR directly.
1062 ;; Operand 1: GPR (1st multiplication operand)
1063 ;; Operand 2: GPR (2nd multiplication operand)
1065 ;; Operand 4: GPR (destination)
1068 [(set (match_operand:SI 0 "register_operand")
1069 (mult:SI (match_operand:SI 1 "register_operand")
1070 (match_operand:SI 2 "register_operand")))
1071 (clobber (match_operand:SI 3 "register_operand"))
1072 (clobber (scratch:SI))])
1073 (set (match_operand:SI 4 "register_operand")
1074 (unspec [(match_dup 0) (match_dup 3)] UNSPEC_MFHILO))]
1075 "GENERATE_MULT3_SI && peep2_reg_dead_p (2, operands[0])"
1078 (mult:SI (match_dup 1)
1080 (clobber (match_dup 3))
1081 (clobber (match_dup 0))])])
1083 (define_insn "mul<mode>3_internal"
1084 [(set (match_operand:GPR 0 "register_operand" "=l")
1085 (mult:GPR (match_operand:GPR 1 "register_operand" "d")
1086 (match_operand:GPR 2 "register_operand" "d")))
1087 (clobber (match_scratch:GPR 3 "=h"))]
1090 [(set_attr "type" "imul")
1091 (set_attr "mode" "<MODE>")])
1093 (define_insn "mul<mode>3_r4000"
1094 [(set (match_operand:GPR 0 "register_operand" "=d")
1095 (mult:GPR (match_operand:GPR 1 "register_operand" "d")
1096 (match_operand:GPR 2 "register_operand" "d")))
1097 (clobber (match_scratch:GPR 3 "=h"))
1098 (clobber (match_scratch:GPR 4 "=l"))]
1100 "<d>mult\t%1,%2\;mflo\t%0"
1101 [(set_attr "type" "imul")
1102 (set_attr "mode" "<MODE>")
1103 (set_attr "length" "8")])
1105 ;; On the VR4120 and VR4130, it is better to use "mtlo $0; macc" instead
1106 ;; of "mult; mflo". They have the same latency, but the first form gives
1107 ;; us an extra cycle to compute the operands.
1110 ;; Operand 1: GPR (1st multiplication operand)
1111 ;; Operand 2: GPR (2nd multiplication operand)
1113 ;; Operand 4: GPR (destination)
1116 [(set (match_operand:SI 0 "register_operand")
1117 (mult:SI (match_operand:SI 1 "register_operand")
1118 (match_operand:SI 2 "register_operand")))
1119 (clobber (match_operand:SI 3 "register_operand"))])
1120 (set (match_operand:SI 4 "register_operand")
1121 (unspec:SI [(match_dup 0) (match_dup 3)] UNSPEC_MFHILO))]
1122 "ISA_HAS_MACC && !GENERATE_MULT3_SI"
1127 (plus:SI (mult:SI (match_dup 1)
1131 (plus:SI (mult:SI (match_dup 1)
1134 (clobber (match_dup 3))])])
1136 ;; Multiply-accumulate patterns
1138 ;; For processors that can copy the output to a general register:
1140 ;; The all-d alternative is needed because the combiner will find this
1141 ;; pattern and then register alloc/reload will move registers around to
1142 ;; make them fit, and we don't want to trigger unnecessary loads to LO.
1144 ;; The last alternative should be made slightly less desirable, but adding
1145 ;; "?" to the constraint is too strong, and causes values to be loaded into
1146 ;; LO even when that's more costly. For now, using "*d" mostly does the
1148 (define_insn "*mul_acc_si"
1149 [(set (match_operand:SI 0 "register_operand" "=l,*d,*d")
1150 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d,d")
1151 (match_operand:SI 2 "register_operand" "d,d,d"))
1152 (match_operand:SI 3 "register_operand" "0,l,*d")))
1153 (clobber (match_scratch:SI 4 "=h,h,h"))
1154 (clobber (match_scratch:SI 5 "=X,3,l"))
1155 (clobber (match_scratch:SI 6 "=X,X,&d"))]
1157 || ISA_HAS_MADD_MSUB)
1160 static const char *const madd[] = { "madd\t%1,%2", "madd\t%0,%1,%2" };
1161 if (which_alternative == 2)
1163 if (ISA_HAS_MADD_MSUB && which_alternative != 0)
1165 return madd[which_alternative];
1167 [(set_attr "type" "imadd,imadd,multi")
1168 (set_attr "mode" "SI")
1169 (set_attr "length" "4,4,8")])
1171 ;; Split the above insn if we failed to get LO allocated.
1173 [(set (match_operand:SI 0 "register_operand")
1174 (plus:SI (mult:SI (match_operand:SI 1 "register_operand")
1175 (match_operand:SI 2 "register_operand"))
1176 (match_operand:SI 3 "register_operand")))
1177 (clobber (match_scratch:SI 4))
1178 (clobber (match_scratch:SI 5))
1179 (clobber (match_scratch:SI 6))]
1180 "reload_completed && !TARGET_DEBUG_D_MODE
1181 && GP_REG_P (true_regnum (operands[0]))
1182 && GP_REG_P (true_regnum (operands[3]))"
1183 [(parallel [(set (match_dup 6)
1184 (mult:SI (match_dup 1) (match_dup 2)))
1185 (clobber (match_dup 4))
1186 (clobber (match_dup 5))])
1187 (set (match_dup 0) (plus:SI (match_dup 6) (match_dup 3)))]
1190 ;; Splitter to copy result of MADD to a general register
1192 [(set (match_operand:SI 0 "register_operand")
1193 (plus:SI (mult:SI (match_operand:SI 1 "register_operand")
1194 (match_operand:SI 2 "register_operand"))
1195 (match_operand:SI 3 "register_operand")))
1196 (clobber (match_scratch:SI 4))
1197 (clobber (match_scratch:SI 5))
1198 (clobber (match_scratch:SI 6))]
1199 "reload_completed && !TARGET_DEBUG_D_MODE
1200 && GP_REG_P (true_regnum (operands[0]))
1201 && true_regnum (operands[3]) == LO_REGNUM"
1202 [(parallel [(set (match_dup 3)
1203 (plus:SI (mult:SI (match_dup 1) (match_dup 2))
1205 (clobber (match_dup 4))
1206 (clobber (match_dup 5))
1207 (clobber (match_dup 6))])
1208 (set (match_dup 0) (unspec:SI [(match_dup 5) (match_dup 4)] UNSPEC_MFHILO))]
1211 (define_insn "*macc"
1212 [(set (match_operand:SI 0 "register_operand" "=l,d")
1213 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d")
1214 (match_operand:SI 2 "register_operand" "d,d"))
1215 (match_operand:SI 3 "register_operand" "0,l")))
1216 (clobber (match_scratch:SI 4 "=h,h"))
1217 (clobber (match_scratch:SI 5 "=X,3"))]
1220 if (which_alternative == 1)
1221 return "macc\t%0,%1,%2";
1222 else if (TARGET_MIPS5500)
1223 return "madd\t%1,%2";
1225 /* The VR4130 assumes that there is a two-cycle latency between a macc
1226 that "writes" to $0 and an instruction that reads from it. We avoid
1227 this by assigning to $1 instead. */
1228 return "%[macc\t%@,%1,%2%]";
1230 [(set_attr "type" "imadd")
1231 (set_attr "mode" "SI")])
1233 (define_insn "*msac"
1234 [(set (match_operand:SI 0 "register_operand" "=l,d")
1235 (minus:SI (match_operand:SI 1 "register_operand" "0,l")
1236 (mult:SI (match_operand:SI 2 "register_operand" "d,d")
1237 (match_operand:SI 3 "register_operand" "d,d"))))
1238 (clobber (match_scratch:SI 4 "=h,h"))
1239 (clobber (match_scratch:SI 5 "=X,1"))]
1242 if (which_alternative == 1)
1243 return "msac\t%0,%2,%3";
1244 else if (TARGET_MIPS5500)
1245 return "msub\t%2,%3";
1247 return "msac\t$0,%2,%3";
1249 [(set_attr "type" "imadd")
1250 (set_attr "mode" "SI")])
1252 ;; An msac-like instruction implemented using negation and a macc.
1253 (define_insn_and_split "*msac_using_macc"
1254 [(set (match_operand:SI 0 "register_operand" "=l,d")
1255 (minus:SI (match_operand:SI 1 "register_operand" "0,l")
1256 (mult:SI (match_operand:SI 2 "register_operand" "d,d")
1257 (match_operand:SI 3 "register_operand" "d,d"))))
1258 (clobber (match_scratch:SI 4 "=h,h"))
1259 (clobber (match_scratch:SI 5 "=X,1"))
1260 (clobber (match_scratch:SI 6 "=d,d"))]
1261 "ISA_HAS_MACC && !ISA_HAS_MSAC"
1263 "&& reload_completed"
1265 (neg:SI (match_dup 3)))
1268 (plus:SI (mult:SI (match_dup 2)
1271 (clobber (match_dup 4))
1272 (clobber (match_dup 5))])]
1274 [(set_attr "type" "imadd")
1275 (set_attr "length" "8")])
1277 ;; Patterns generated by the define_peephole2 below.
1279 (define_insn "*macc2"
1280 [(set (match_operand:SI 0 "register_operand" "=l")
1281 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d")
1282 (match_operand:SI 2 "register_operand" "d"))
1284 (set (match_operand:SI 3 "register_operand" "=d")
1285 (plus:SI (mult:SI (match_dup 1)
1288 (clobber (match_scratch:SI 4 "=h"))]
1289 "ISA_HAS_MACC && reload_completed"
1291 [(set_attr "type" "imadd")
1292 (set_attr "mode" "SI")])
1294 (define_insn "*msac2"
1295 [(set (match_operand:SI 0 "register_operand" "=l")
1296 (minus:SI (match_dup 0)
1297 (mult:SI (match_operand:SI 1 "register_operand" "d")
1298 (match_operand:SI 2 "register_operand" "d"))))
1299 (set (match_operand:SI 3 "register_operand" "=d")
1300 (minus:SI (match_dup 0)
1301 (mult:SI (match_dup 1)
1303 (clobber (match_scratch:SI 4 "=h"))]
1304 "ISA_HAS_MSAC && reload_completed"
1306 [(set_attr "type" "imadd")
1307 (set_attr "mode" "SI")])
1309 ;; Convert macc $0,<r1>,<r2> & mflo <r3> into macc <r3>,<r1>,<r2>
1313 ;; Operand 1: macc/msac
1315 ;; Operand 3: GPR (destination)
1318 [(set (match_operand:SI 0 "register_operand")
1319 (match_operand:SI 1 "macc_msac_operand"))
1320 (clobber (match_operand:SI 2 "register_operand"))
1321 (clobber (scratch:SI))])
1322 (set (match_operand:SI 3 "register_operand")
1323 (unspec:SI [(match_dup 0) (match_dup 2)] UNSPEC_MFHILO))]
1325 [(parallel [(set (match_dup 0)
1329 (clobber (match_dup 2))])]
1332 ;; When we have a three-address multiplication instruction, it should
1333 ;; be faster to do a separate multiply and add, rather than moving
1334 ;; something into LO in order to use a macc instruction.
1336 ;; This peephole needs a scratch register to cater for the case when one
1337 ;; of the multiplication operands is the same as the destination.
1339 ;; Operand 0: GPR (scratch)
1341 ;; Operand 2: GPR (addend)
1342 ;; Operand 3: GPR (destination)
1343 ;; Operand 4: macc/msac
1345 ;; Operand 6: new multiplication
1346 ;; Operand 7: new addition/subtraction
1348 [(match_scratch:SI 0 "d")
1349 (set (match_operand:SI 1 "register_operand")
1350 (match_operand:SI 2 "register_operand"))
1353 [(set (match_operand:SI 3 "register_operand")
1354 (match_operand:SI 4 "macc_msac_operand"))
1355 (clobber (match_operand:SI 5 "register_operand"))
1356 (clobber (match_dup 1))])]
1358 && true_regnum (operands[1]) == LO_REGNUM
1359 && peep2_reg_dead_p (2, operands[1])
1360 && GP_REG_P (true_regnum (operands[3]))"
1361 [(parallel [(set (match_dup 0)
1363 (clobber (match_dup 5))
1364 (clobber (match_dup 1))])
1368 operands[6] = XEXP (operands[4], GET_CODE (operands[4]) == PLUS ? 0 : 1);
1369 operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[4]), SImode,
1370 operands[2], operands[0]);
1373 ;; Same as above, except LO is the initial target of the macc.
1375 ;; Operand 0: GPR (scratch)
1377 ;; Operand 2: GPR (addend)
1378 ;; Operand 3: macc/msac
1380 ;; Operand 5: GPR (destination)
1381 ;; Operand 6: new multiplication
1382 ;; Operand 7: new addition/subtraction
1384 [(match_scratch:SI 0 "d")
1385 (set (match_operand:SI 1 "register_operand")
1386 (match_operand:SI 2 "register_operand"))
1390 (match_operand:SI 3 "macc_msac_operand"))
1391 (clobber (match_operand:SI 4 "register_operand"))
1392 (clobber (scratch:SI))])
1394 (set (match_operand:SI 5 "register_operand")
1395 (unspec:SI [(match_dup 1) (match_dup 4)] UNSPEC_MFHILO))]
1396 "GENERATE_MULT3_SI && peep2_reg_dead_p (3, operands[1])"
1397 [(parallel [(set (match_dup 0)
1399 (clobber (match_dup 4))
1400 (clobber (match_dup 1))])
1404 operands[6] = XEXP (operands[4], GET_CODE (operands[4]) == PLUS ? 0 : 1);
1405 operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[4]), SImode,
1406 operands[2], operands[0]);
1409 (define_insn "*mul_sub_si"
1410 [(set (match_operand:SI 0 "register_operand" "=l,*d,*d")
1411 (minus:SI (match_operand:SI 1 "register_operand" "0,l,*d")
1412 (mult:SI (match_operand:SI 2 "register_operand" "d,d,d")
1413 (match_operand:SI 3 "register_operand" "d,d,d"))))
1414 (clobber (match_scratch:SI 4 "=h,h,h"))
1415 (clobber (match_scratch:SI 5 "=X,1,l"))
1416 (clobber (match_scratch:SI 6 "=X,X,&d"))]
1422 [(set_attr "type" "imadd,multi,multi")
1423 (set_attr "mode" "SI")
1424 (set_attr "length" "4,8,8")])
1426 ;; Split the above insn if we failed to get LO allocated.
1428 [(set (match_operand:SI 0 "register_operand")
1429 (minus:SI (match_operand:SI 1 "register_operand")
1430 (mult:SI (match_operand:SI 2 "register_operand")
1431 (match_operand:SI 3 "register_operand"))))
1432 (clobber (match_scratch:SI 4))
1433 (clobber (match_scratch:SI 5))
1434 (clobber (match_scratch:SI 6))]
1435 "reload_completed && !TARGET_DEBUG_D_MODE
1436 && GP_REG_P (true_regnum (operands[0]))
1437 && GP_REG_P (true_regnum (operands[1]))"
1438 [(parallel [(set (match_dup 6)
1439 (mult:SI (match_dup 2) (match_dup 3)))
1440 (clobber (match_dup 4))
1441 (clobber (match_dup 5))])
1442 (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 6)))]
1445 ;; Splitter to copy result of MSUB to a general register
1447 [(set (match_operand:SI 0 "register_operand")
1448 (minus:SI (match_operand:SI 1 "register_operand")
1449 (mult:SI (match_operand:SI 2 "register_operand")
1450 (match_operand:SI 3 "register_operand"))))
1451 (clobber (match_scratch:SI 4))
1452 (clobber (match_scratch:SI 5))
1453 (clobber (match_scratch:SI 6))]
1454 "reload_completed && !TARGET_DEBUG_D_MODE
1455 && GP_REG_P (true_regnum (operands[0]))
1456 && true_regnum (operands[1]) == LO_REGNUM"
1457 [(parallel [(set (match_dup 1)
1458 (minus:SI (match_dup 1)
1459 (mult:SI (match_dup 2) (match_dup 3))))
1460 (clobber (match_dup 4))
1461 (clobber (match_dup 5))
1462 (clobber (match_dup 6))])
1463 (set (match_dup 0) (unspec:SI [(match_dup 5) (match_dup 4)] UNSPEC_MFHILO))]
1466 (define_insn "*muls"
1467 [(set (match_operand:SI 0 "register_operand" "=l,d")
1468 (neg:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d")
1469 (match_operand:SI 2 "register_operand" "d,d"))))
1470 (clobber (match_scratch:SI 3 "=h,h"))
1471 (clobber (match_scratch:SI 4 "=X,l"))]
1476 [(set_attr "type" "imul,imul3")
1477 (set_attr "mode" "SI")])
1479 ;; ??? We could define a mulditi3 pattern when TARGET_64BIT.
1481 (define_expand "<u>mulsidi3"
1483 [(set (match_operand:DI 0 "register_operand")
1484 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand"))
1485 (any_extend:DI (match_operand:SI 2 "register_operand"))))
1486 (clobber (scratch:DI))
1487 (clobber (scratch:DI))
1488 (clobber (scratch:DI))])]
1489 "!TARGET_64BIT || !TARGET_FIX_R4000"
1493 if (!TARGET_FIX_R4000)
1494 emit_insn (gen_<u>mulsidi3_32bit_internal (operands[0], operands[1],
1497 emit_insn (gen_<u>mulsidi3_32bit_r4000 (operands[0], operands[1],
1503 (define_insn "<u>mulsidi3_32bit_internal"
1504 [(set (match_operand:DI 0 "register_operand" "=x")
1505 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1506 (any_extend:DI (match_operand:SI 2 "register_operand" "d"))))]
1507 "!TARGET_64BIT && !TARGET_FIX_R4000"
1509 [(set_attr "type" "imul")
1510 (set_attr "mode" "SI")])
1512 (define_insn "<u>mulsidi3_32bit_r4000"
1513 [(set (match_operand:DI 0 "register_operand" "=d")
1514 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1515 (any_extend:DI (match_operand:SI 2 "register_operand" "d"))))
1516 (clobber (match_scratch:DI 3 "=x"))]
1517 "!TARGET_64BIT && TARGET_FIX_R4000"
1518 "mult<u>\t%1,%2\;mflo\t%L0;mfhi\t%M0"
1519 [(set_attr "type" "imul")
1520 (set_attr "mode" "SI")
1521 (set_attr "length" "12")])
1523 (define_insn_and_split "*<u>mulsidi3_64bit"
1524 [(set (match_operand:DI 0 "register_operand" "=d")
1525 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1526 (any_extend:DI (match_operand:SI 2 "register_operand" "d"))))
1527 (clobber (match_scratch:DI 3 "=l"))
1528 (clobber (match_scratch:DI 4 "=h"))
1529 (clobber (match_scratch:DI 5 "=d"))]
1530 "TARGET_64BIT && !TARGET_FIX_R4000"
1532 "&& reload_completed"
1536 (mult:SI (match_dup 1)
1540 (mult:DI (any_extend:DI (match_dup 1))
1541 (any_extend:DI (match_dup 2)))
1544 ;; OP5 <- LO, OP0 <- HI
1545 (set (match_dup 5) (unspec:DI [(match_dup 3) (match_dup 4)] UNSPEC_MFHILO))
1546 (set (match_dup 0) (unspec:DI [(match_dup 4) (match_dup 3)] UNSPEC_MFHILO))
1550 (ashift:DI (match_dup 5)
1553 (lshiftrt:DI (match_dup 5)
1556 ;; Shift OP0 into place.
1558 (ashift:DI (match_dup 0)
1561 ;; OR the two halves together
1563 (ior:DI (match_dup 0)
1566 [(set_attr "type" "imul")
1567 (set_attr "mode" "SI")
1568 (set_attr "length" "24")])
1570 (define_insn "*<u>mulsidi3_64bit_parts"
1571 [(set (match_operand:DI 0 "register_operand" "=l")
1573 (mult:SI (match_operand:SI 2 "register_operand" "d")
1574 (match_operand:SI 3 "register_operand" "d"))))
1575 (set (match_operand:DI 1 "register_operand" "=h")
1577 (mult:DI (any_extend:DI (match_dup 2))
1578 (any_extend:DI (match_dup 3)))
1580 "TARGET_64BIT && !TARGET_FIX_R4000"
1582 [(set_attr "type" "imul")
1583 (set_attr "mode" "SI")])
1585 ;; Widening multiply with negation.
1586 (define_insn "*muls<u>_di"
1587 [(set (match_operand:DI 0 "register_operand" "=x")
1590 (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1591 (any_extend:DI (match_operand:SI 2 "register_operand" "d")))))]
1592 "!TARGET_64BIT && ISA_HAS_MULS"
1594 [(set_attr "type" "imul")
1595 (set_attr "mode" "SI")])
1597 (define_insn "*msac<u>_di"
1598 [(set (match_operand:DI 0 "register_operand" "=x")
1600 (match_operand:DI 3 "register_operand" "0")
1602 (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1603 (any_extend:DI (match_operand:SI 2 "register_operand" "d")))))]
1604 "!TARGET_64BIT && ISA_HAS_MSAC"
1606 if (TARGET_MIPS5500)
1607 return "msub<u>\t%1,%2";
1609 return "msac<u>\t$0,%1,%2";
1611 [(set_attr "type" "imadd")
1612 (set_attr "mode" "SI")])
1614 ;; _highpart patterns
1616 (define_expand "<su>mulsi3_highpart"
1617 [(set (match_operand:SI 0 "register_operand")
1620 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand"))
1621 (any_extend:DI (match_operand:SI 2 "register_operand")))
1623 "ISA_HAS_MULHI || !TARGET_FIX_R4000"
1626 emit_insn (gen_<su>mulsi3_highpart_mulhi_internal (operands[0],
1630 emit_insn (gen_<su>mulsi3_highpart_internal (operands[0], operands[1],
1635 (define_insn "<su>mulsi3_highpart_internal"
1636 [(set (match_operand:SI 0 "register_operand" "=h")
1639 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1640 (any_extend:DI (match_operand:SI 2 "register_operand" "d")))
1642 (clobber (match_scratch:SI 3 "=l"))]
1643 "!ISA_HAS_MULHI && !TARGET_FIX_R4000"
1645 [(set_attr "type" "imul")
1646 (set_attr "mode" "SI")])
1648 (define_insn "<su>mulsi3_highpart_mulhi_internal"
1649 [(set (match_operand:SI 0 "register_operand" "=h,d")
1653 (any_extend:DI (match_operand:SI 1 "register_operand" "d,d"))
1654 (any_extend:DI (match_operand:SI 2 "register_operand" "d,d")))
1656 (clobber (match_scratch:SI 3 "=l,l"))
1657 (clobber (match_scratch:SI 4 "=X,h"))]
1662 [(set_attr "type" "imul,imul3")
1663 (set_attr "mode" "SI")])
1665 (define_insn "*<su>mulsi3_highpart_neg_mulhi_internal"
1666 [(set (match_operand:SI 0 "register_operand" "=h,d")
1671 (any_extend:DI (match_operand:SI 1 "register_operand" "d,d"))
1672 (any_extend:DI (match_operand:SI 2 "register_operand" "d,d"))))
1674 (clobber (match_scratch:SI 3 "=l,l"))
1675 (clobber (match_scratch:SI 4 "=X,h"))]
1679 mulshi<u>\t%0,%1,%2"
1680 [(set_attr "type" "imul,imul3")
1681 (set_attr "mode" "SI")])
1683 ;; Disable unsigned multiplication for -mfix-vr4120. This is for VR4120
1684 ;; errata MD(0), which says that dmultu does not always produce the
1686 (define_insn "<su>muldi3_highpart"
1687 [(set (match_operand:DI 0 "register_operand" "=h")
1691 (any_extend:TI (match_operand:DI 1 "register_operand" "d"))
1692 (any_extend:TI (match_operand:DI 2 "register_operand" "d")))
1694 (clobber (match_scratch:DI 3 "=l"))]
1695 "TARGET_64BIT && !TARGET_FIX_R4000
1696 && !(<CODE> == ZERO_EXTEND && TARGET_FIX_VR4120)"
1698 [(set_attr "type" "imul")
1699 (set_attr "mode" "DI")])
1701 ;; The R4650 supports a 32 bit multiply/ 64 bit accumulate
1702 ;; instruction. The HI/LO registers are used as a 64 bit accumulator.
1704 (define_insn "madsi"
1705 [(set (match_operand:SI 0 "register_operand" "+l")
1706 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d")
1707 (match_operand:SI 2 "register_operand" "d"))
1709 (clobber (match_scratch:SI 3 "=h"))]
1712 [(set_attr "type" "imadd")
1713 (set_attr "mode" "SI")])
1715 (define_insn "*<su>mul_acc_di"
1716 [(set (match_operand:DI 0 "register_operand" "=x")
1718 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1719 (any_extend:DI (match_operand:SI 2 "register_operand" "d")))
1720 (match_operand:DI 3 "register_operand" "0")))]
1721 "(TARGET_MAD || ISA_HAS_MACC)
1725 return "mad<u>\t%1,%2";
1726 else if (TARGET_MIPS5500)
1727 return "madd<u>\t%1,%2";
1729 /* See comment in *macc. */
1730 return "%[macc<u>\t%@,%1,%2%]";
1732 [(set_attr "type" "imadd")
1733 (set_attr "mode" "SI")])
1735 ;; Floating point multiply accumulate instructions.
1737 (define_insn "*madd<mode>"
1738 [(set (match_operand:ANYF 0 "register_operand" "=f")
1739 (plus:ANYF (mult:ANYF (match_operand:ANYF 1 "register_operand" "f")
1740 (match_operand:ANYF 2 "register_operand" "f"))
1741 (match_operand:ANYF 3 "register_operand" "f")))]
1742 "ISA_HAS_FP4 && TARGET_FUSED_MADD"
1743 "madd.<fmt>\t%0,%3,%1,%2"
1744 [(set_attr "type" "fmadd")
1745 (set_attr "mode" "<UNITMODE>")])
1747 (define_insn "*msub<mode>"
1748 [(set (match_operand:ANYF 0 "register_operand" "=f")
1749 (minus:ANYF (mult:ANYF (match_operand:ANYF 1 "register_operand" "f")
1750 (match_operand:ANYF 2 "register_operand" "f"))
1751 (match_operand:ANYF 3 "register_operand" "f")))]
1752 "ISA_HAS_FP4 && TARGET_FUSED_MADD"
1753 "msub.<fmt>\t%0,%3,%1,%2"
1754 [(set_attr "type" "fmadd")
1755 (set_attr "mode" "<UNITMODE>")])
1757 (define_insn "*nmadd<mode>"
1758 [(set (match_operand:ANYF 0 "register_operand" "=f")
1759 (neg:ANYF (plus:ANYF
1760 (mult:ANYF (match_operand:ANYF 1 "register_operand" "f")
1761 (match_operand:ANYF 2 "register_operand" "f"))
1762 (match_operand:ANYF 3 "register_operand" "f"))))]
1763 "ISA_HAS_NMADD_NMSUB && TARGET_FUSED_MADD
1764 && HONOR_SIGNED_ZEROS (<MODE>mode)"
1765 "nmadd.<fmt>\t%0,%3,%1,%2"
1766 [(set_attr "type" "fmadd")
1767 (set_attr "mode" "<UNITMODE>")])
1769 (define_insn "*nmadd<mode>_fastmath"
1770 [(set (match_operand:ANYF 0 "register_operand" "=f")
1772 (mult:ANYF (neg:ANYF (match_operand:ANYF 1 "register_operand" "f"))
1773 (match_operand:ANYF 2 "register_operand" "f"))
1774 (match_operand:ANYF 3 "register_operand" "f")))]
1775 "ISA_HAS_NMADD_NMSUB && TARGET_FUSED_MADD
1776 && !HONOR_SIGNED_ZEROS (<MODE>mode)"
1777 "nmadd.<fmt>\t%0,%3,%1,%2"
1778 [(set_attr "type" "fmadd")
1779 (set_attr "mode" "<UNITMODE>")])
1781 (define_insn "*nmsub<mode>"
1782 [(set (match_operand:ANYF 0 "register_operand" "=f")
1783 (neg:ANYF (minus:ANYF
1784 (mult:ANYF (match_operand:ANYF 2 "register_operand" "f")
1785 (match_operand:ANYF 3 "register_operand" "f"))
1786 (match_operand:ANYF 1 "register_operand" "f"))))]
1787 "ISA_HAS_NMADD_NMSUB && TARGET_FUSED_MADD
1788 && HONOR_SIGNED_ZEROS (<MODE>mode)"
1789 "nmsub.<fmt>\t%0,%1,%2,%3"
1790 [(set_attr "type" "fmadd")
1791 (set_attr "mode" "<UNITMODE>")])
1793 (define_insn "*nmsub<mode>_fastmath"
1794 [(set (match_operand:ANYF 0 "register_operand" "=f")
1796 (match_operand:ANYF 1 "register_operand" "f")
1797 (mult:ANYF (match_operand:ANYF 2 "register_operand" "f")
1798 (match_operand:ANYF 3 "register_operand" "f"))))]
1799 "ISA_HAS_NMADD_NMSUB && TARGET_FUSED_MADD
1800 && !HONOR_SIGNED_ZEROS (<MODE>mode)"
1801 "nmsub.<fmt>\t%0,%1,%2,%3"
1802 [(set_attr "type" "fmadd")
1803 (set_attr "mode" "<UNITMODE>")])
1806 ;; ....................
1808 ;; DIVISION and REMAINDER
1810 ;; ....................
1813 (define_expand "div<mode>3"
1814 [(set (match_operand:ANYF 0 "register_operand")
1815 (div:ANYF (match_operand:ANYF 1 "reg_or_1_operand")
1816 (match_operand:ANYF 2 "register_operand")))]
1817 "<divide_condition>"
1819 if (const_1_operand (operands[1], <MODE>mode))
1820 if (!(ISA_HAS_FP4 && flag_unsafe_math_optimizations))
1821 operands[1] = force_reg (<MODE>mode, operands[1]);
1824 ;; These patterns work around the early SB-1 rev2 core "F1" erratum:
1826 ;; If an mfc1 or dmfc1 happens to access the floating point register
1827 ;; file at the same time a long latency operation (div, sqrt, recip,
1828 ;; sqrt) iterates an intermediate result back through the floating
1829 ;; point register file bypass, then instead returning the correct
1830 ;; register value the mfc1 or dmfc1 operation returns the intermediate
1831 ;; result of the long latency operation.
1833 ;; The workaround is to insert an unconditional 'mov' from/to the
1834 ;; long latency op destination register.
1836 (define_insn "*div<mode>3"
1837 [(set (match_operand:ANYF 0 "register_operand" "=f")
1838 (div:ANYF (match_operand:ANYF 1 "register_operand" "f")
1839 (match_operand:ANYF 2 "register_operand" "f")))]
1840 "<divide_condition>"
1843 return "div.<fmt>\t%0,%1,%2\;mov.<fmt>\t%0,%0";
1845 return "div.<fmt>\t%0,%1,%2";
1847 [(set_attr "type" "fdiv")
1848 (set_attr "mode" "<UNITMODE>")
1849 (set (attr "length")
1850 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
1854 (define_insn "*recip<mode>3"
1855 [(set (match_operand:ANYF 0 "register_operand" "=f")
1856 (div:ANYF (match_operand:ANYF 1 "const_1_operand" "")
1857 (match_operand:ANYF 2 "register_operand" "f")))]
1858 "<recip_condition> && flag_unsafe_math_optimizations"
1861 return "recip.<fmt>\t%0,%2\;mov.<fmt>\t%0,%0";
1863 return "recip.<fmt>\t%0,%2";
1865 [(set_attr "type" "frdiv")
1866 (set_attr "mode" "<UNITMODE>")
1867 (set (attr "length")
1868 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
1872 ;; VR4120 errata MD(A1): signed division instructions do not work correctly
1873 ;; with negative operands. We use special libgcc functions instead.
1874 (define_insn "divmod<mode>4"
1875 [(set (match_operand:GPR 0 "register_operand" "=l")
1876 (div:GPR (match_operand:GPR 1 "register_operand" "d")
1877 (match_operand:GPR 2 "register_operand" "d")))
1878 (set (match_operand:GPR 3 "register_operand" "=h")
1879 (mod:GPR (match_dup 1)
1881 "!TARGET_FIX_VR4120"
1882 { return mips_output_division ("<d>div\t$0,%1,%2", operands); }
1883 [(set_attr "type" "idiv")
1884 (set_attr "mode" "<MODE>")])
1886 (define_insn "udivmod<mode>4"
1887 [(set (match_operand:GPR 0 "register_operand" "=l")
1888 (udiv:GPR (match_operand:GPR 1 "register_operand" "d")
1889 (match_operand:GPR 2 "register_operand" "d")))
1890 (set (match_operand:GPR 3 "register_operand" "=h")
1891 (umod:GPR (match_dup 1)
1894 { return mips_output_division ("<d>divu\t$0,%1,%2", operands); }
1895 [(set_attr "type" "idiv")
1896 (set_attr "mode" "<MODE>")])
1899 ;; ....................
1903 ;; ....................
1905 ;; These patterns work around the early SB-1 rev2 core "F1" erratum (see
1906 ;; "*div[sd]f3" comment for details).
1908 (define_insn "sqrt<mode>2"
1909 [(set (match_operand:ANYF 0 "register_operand" "=f")
1910 (sqrt:ANYF (match_operand:ANYF 1 "register_operand" "f")))]
1914 return "sqrt.<fmt>\t%0,%1\;mov.<fmt>\t%0,%0";
1916 return "sqrt.<fmt>\t%0,%1";
1918 [(set_attr "type" "fsqrt")
1919 (set_attr "mode" "<UNITMODE>")
1920 (set (attr "length")
1921 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
1925 (define_insn "*rsqrt<mode>a"
1926 [(set (match_operand:ANYF 0 "register_operand" "=f")
1927 (div:ANYF (match_operand:ANYF 1 "const_1_operand" "")
1928 (sqrt:ANYF (match_operand:ANYF 2 "register_operand" "f"))))]
1929 "<recip_condition> && flag_unsafe_math_optimizations"
1932 return "rsqrt.<fmt>\t%0,%2\;mov.<fmt>\t%0,%0";
1934 return "rsqrt.<fmt>\t%0,%2";
1936 [(set_attr "type" "frsqrt")
1937 (set_attr "mode" "<UNITMODE>")
1938 (set (attr "length")
1939 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
1943 (define_insn "*rsqrt<mode>b"
1944 [(set (match_operand:ANYF 0 "register_operand" "=f")
1945 (sqrt:ANYF (div:ANYF (match_operand:ANYF 1 "const_1_operand" "")
1946 (match_operand:ANYF 2 "register_operand" "f"))))]
1947 "<recip_condition> && flag_unsafe_math_optimizations"
1950 return "rsqrt.<fmt>\t%0,%2\;mov.<fmt>\t%0,%0";
1952 return "rsqrt.<fmt>\t%0,%2";
1954 [(set_attr "type" "frsqrt")
1955 (set_attr "mode" "<UNITMODE>")
1956 (set (attr "length")
1957 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
1962 ;; ....................
1966 ;; ....................
1968 ;; Do not use the integer abs macro instruction, since that signals an
1969 ;; exception on -2147483648 (sigh).
1971 (define_insn "abs<mode>2"
1972 [(set (match_operand:ANYF 0 "register_operand" "=f")
1973 (abs:ANYF (match_operand:ANYF 1 "register_operand" "f")))]
1976 [(set_attr "type" "fabs")
1977 (set_attr "mode" "<UNITMODE>")])
1980 ;; ...................
1982 ;; Count leading zeroes.
1984 ;; ...................
1987 (define_insn "clz<mode>2"
1988 [(set (match_operand:GPR 0 "register_operand" "=d")
1989 (clz:GPR (match_operand:GPR 1 "register_operand" "d")))]
1992 [(set_attr "type" "clz")
1993 (set_attr "mode" "<MODE>")])
1996 ;; ....................
1998 ;; NEGATION and ONE'S COMPLEMENT
2000 ;; ....................
2002 (define_insn "negsi2"
2003 [(set (match_operand:SI 0 "register_operand" "=d")
2004 (neg:SI (match_operand:SI 1 "register_operand" "d")))]
2008 return "neg\t%0,%1";
2010 return "subu\t%0,%.,%1";
2012 [(set_attr "type" "arith")
2013 (set_attr "mode" "SI")])
2015 (define_insn "negdi2"
2016 [(set (match_operand:DI 0 "register_operand" "=d")
2017 (neg:DI (match_operand:DI 1 "register_operand" "d")))]
2018 "TARGET_64BIT && !TARGET_MIPS16"
2020 [(set_attr "type" "arith")
2021 (set_attr "mode" "DI")])
2023 (define_insn "neg<mode>2"
2024 [(set (match_operand:ANYF 0 "register_operand" "=f")
2025 (neg:ANYF (match_operand:ANYF 1 "register_operand" "f")))]
2028 [(set_attr "type" "fneg")
2029 (set_attr "mode" "<UNITMODE>")])
2031 (define_insn "one_cmpl<mode>2"
2032 [(set (match_operand:GPR 0 "register_operand" "=d")
2033 (not:GPR (match_operand:GPR 1 "register_operand" "d")))]
2037 return "not\t%0,%1";
2039 return "nor\t%0,%.,%1";
2041 [(set_attr "type" "arith")
2042 (set_attr "mode" "<MODE>")])
2045 ;; ....................
2049 ;; ....................
2052 ;; Many of these instructions use trivial define_expands, because we
2053 ;; want to use a different set of constraints when TARGET_MIPS16.
2055 (define_expand "and<mode>3"
2056 [(set (match_operand:GPR 0 "register_operand")
2057 (and:GPR (match_operand:GPR 1 "register_operand")
2058 (match_operand:GPR 2 "uns_arith_operand")))]
2062 operands[2] = force_reg (<MODE>mode, operands[2]);
2065 (define_insn "*and<mode>3"
2066 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2067 (and:GPR (match_operand:GPR 1 "register_operand" "%d,d")
2068 (match_operand:GPR 2 "uns_arith_operand" "d,K")))]
2073 [(set_attr "type" "arith")
2074 (set_attr "mode" "<MODE>")])
2076 (define_insn "*and<mode>3_mips16"
2077 [(set (match_operand:GPR 0 "register_operand" "=d")
2078 (and:GPR (match_operand:GPR 1 "register_operand" "%0")
2079 (match_operand:GPR 2 "register_operand" "d")))]
2082 [(set_attr "type" "arith")
2083 (set_attr "mode" "<MODE>")])
2085 (define_expand "ior<mode>3"
2086 [(set (match_operand:GPR 0 "register_operand")
2087 (ior:GPR (match_operand:GPR 1 "register_operand")
2088 (match_operand:GPR 2 "uns_arith_operand")))]
2092 operands[2] = force_reg (<MODE>mode, operands[2]);
2095 (define_insn "*ior<mode>3"
2096 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2097 (ior:GPR (match_operand:GPR 1 "register_operand" "%d,d")
2098 (match_operand:GPR 2 "uns_arith_operand" "d,K")))]
2103 [(set_attr "type" "arith")
2104 (set_attr "mode" "<MODE>")])
2106 (define_insn "*ior<mode>3_mips16"
2107 [(set (match_operand:GPR 0 "register_operand" "=d")
2108 (ior:GPR (match_operand:GPR 1 "register_operand" "%0")
2109 (match_operand:GPR 2 "register_operand" "d")))]
2112 [(set_attr "type" "arith")
2113 (set_attr "mode" "<MODE>")])
2115 (define_expand "xor<mode>3"
2116 [(set (match_operand:GPR 0 "register_operand")
2117 (xor:GPR (match_operand:GPR 1 "register_operand")
2118 (match_operand:GPR 2 "uns_arith_operand")))]
2123 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2124 (xor:GPR (match_operand:GPR 1 "register_operand" "%d,d")
2125 (match_operand:GPR 2 "uns_arith_operand" "d,K")))]
2130 [(set_attr "type" "arith")
2131 (set_attr "mode" "<MODE>")])
2134 [(set (match_operand:GPR 0 "register_operand" "=d,t,t")
2135 (xor:GPR (match_operand:GPR 1 "register_operand" "%0,d,d")
2136 (match_operand:GPR 2 "uns_arith_operand" "d,K,d")))]
2142 [(set_attr "type" "arith")
2143 (set_attr "mode" "<MODE>")
2144 (set_attr_alternative "length"
2146 (if_then_else (match_operand:VOID 2 "m16_uimm8_1")
2151 (define_insn "*nor<mode>3"
2152 [(set (match_operand:GPR 0 "register_operand" "=d")
2153 (and:GPR (not:GPR (match_operand:GPR 1 "register_operand" "d"))
2154 (not:GPR (match_operand:GPR 2 "register_operand" "d"))))]
2157 [(set_attr "type" "arith")
2158 (set_attr "mode" "<MODE>")])
2161 ;; ....................
2165 ;; ....................
2169 (define_insn "truncdfsf2"
2170 [(set (match_operand:SF 0 "register_operand" "=f")
2171 (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
2172 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2174 [(set_attr "type" "fcvt")
2175 (set_attr "cnv_mode" "D2S")
2176 (set_attr "mode" "SF")])
2178 ;; Integer truncation patterns. Truncating SImode values to smaller
2179 ;; modes is a no-op, as it is for most other GCC ports. Truncating
2180 ;; DImode values to SImode is not a no-op for TARGET_64BIT since we
2181 ;; need to make sure that the lower 32 bits are properly sign-extended
2182 ;; (see TRULY_NOOP_TRUNCATION). Truncating DImode values into modes
2183 ;; smaller than SImode is equivalent to two separate truncations:
2186 ;; DI ---> HI == DI ---> SI ---> HI
2187 ;; DI ---> QI == DI ---> SI ---> QI
2189 ;; Step A needs a real instruction but step B does not.
2191 (define_insn "truncdisi2"
2192 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,m")
2193 (truncate:SI (match_operand:DI 1 "register_operand" "d,d")))]
2198 [(set_attr "type" "shift,store")
2199 (set_attr "mode" "SI")
2200 (set_attr "extended_mips16" "yes,*")])
2202 (define_insn "truncdihi2"
2203 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,m")
2204 (truncate:HI (match_operand:DI 1 "register_operand" "d,d")))]
2209 [(set_attr "type" "shift,store")
2210 (set_attr "mode" "SI")
2211 (set_attr "extended_mips16" "yes,*")])
2213 (define_insn "truncdiqi2"
2214 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,m")
2215 (truncate:QI (match_operand:DI 1 "register_operand" "d,d")))]
2220 [(set_attr "type" "shift,store")
2221 (set_attr "mode" "SI")
2222 (set_attr "extended_mips16" "yes,*")])
2224 ;; Combiner patterns to optimize shift/truncate combinations.
2227 [(set (match_operand:SI 0 "register_operand" "=d")
2229 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
2230 (match_operand:DI 2 "const_arith_operand" ""))))]
2231 "TARGET_64BIT && !TARGET_MIPS16 && INTVAL (operands[2]) >= 32"
2233 [(set_attr "type" "shift")
2234 (set_attr "mode" "SI")])
2237 [(set (match_operand:SI 0 "register_operand" "=d")
2238 (truncate:SI (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
2240 "TARGET_64BIT && !TARGET_MIPS16"
2242 [(set_attr "type" "shift")
2243 (set_attr "mode" "SI")])
2246 ;; Combiner patterns for truncate/sign_extend combinations. They use
2247 ;; the shift/truncate patterns above.
2249 (define_insn_and_split ""
2250 [(set (match_operand:SI 0 "register_operand" "=d")
2252 (truncate:HI (match_operand:DI 1 "register_operand" "d"))))]
2253 "TARGET_64BIT && !TARGET_MIPS16"
2255 "&& reload_completed"
2257 (ashift:DI (match_dup 1)
2260 (truncate:SI (ashiftrt:DI (match_dup 2)
2262 { operands[2] = gen_lowpart (DImode, operands[0]); })
2264 (define_insn_and_split ""
2265 [(set (match_operand:SI 0 "register_operand" "=d")
2267 (truncate:QI (match_operand:DI 1 "register_operand" "d"))))]
2268 "TARGET_64BIT && !TARGET_MIPS16"
2270 "&& reload_completed"
2272 (ashift:DI (match_dup 1)
2275 (truncate:SI (ashiftrt:DI (match_dup 2)
2277 { operands[2] = gen_lowpart (DImode, operands[0]); })
2280 ;; Combiner patterns to optimize truncate/zero_extend combinations.
2283 [(set (match_operand:SI 0 "register_operand" "=d")
2284 (zero_extend:SI (truncate:HI
2285 (match_operand:DI 1 "register_operand" "d"))))]
2286 "TARGET_64BIT && !TARGET_MIPS16"
2287 "andi\t%0,%1,0xffff"
2288 [(set_attr "type" "arith")
2289 (set_attr "mode" "SI")])
2292 [(set (match_operand:SI 0 "register_operand" "=d")
2293 (zero_extend:SI (truncate:QI
2294 (match_operand:DI 1 "register_operand" "d"))))]
2295 "TARGET_64BIT && !TARGET_MIPS16"
2297 [(set_attr "type" "arith")
2298 (set_attr "mode" "SI")])
2301 [(set (match_operand:HI 0 "register_operand" "=d")
2302 (zero_extend:HI (truncate:QI
2303 (match_operand:DI 1 "register_operand" "d"))))]
2304 "TARGET_64BIT && !TARGET_MIPS16"
2306 [(set_attr "type" "arith")
2307 (set_attr "mode" "HI")])
2310 ;; ....................
2314 ;; ....................
2318 (define_insn_and_split "zero_extendsidi2"
2319 [(set (match_operand:DI 0 "register_operand" "=d,d")
2320 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,W")))]
2325 "&& reload_completed && REG_P (operands[1])"
2327 (ashift:DI (match_dup 1) (const_int 32)))
2329 (lshiftrt:DI (match_dup 0) (const_int 32)))]
2330 { operands[1] = gen_lowpart (DImode, operands[1]); }
2331 [(set_attr "type" "multi,load")
2332 (set_attr "mode" "DI")
2333 (set_attr "length" "8,*")])
2335 (define_expand "zero_extend<SHORT:mode><GPR:mode>2"
2336 [(set (match_operand:GPR 0 "register_operand")
2337 (zero_extend:GPR (match_operand:SHORT 1 "nonimmediate_operand")))]
2340 if (TARGET_MIPS16 && !GENERATE_MIPS16E
2341 && !memory_operand (operands[1], <SHORT:MODE>mode))
2343 emit_insn (gen_and<GPR:mode>3 (operands[0],
2344 gen_lowpart (<GPR:MODE>mode, operands[1]),
2345 force_reg (<GPR:MODE>mode,
2346 GEN_INT (<SHORT:mask>))));
2351 (define_insn "*zero_extend<SHORT:mode><GPR:mode>2"
2352 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2354 (match_operand:SHORT 1 "nonimmediate_operand" "d,m")))]
2357 andi\t%0,%1,<SHORT:mask>
2358 l<SHORT:size>u\t%0,%1"
2359 [(set_attr "type" "arith,load")
2360 (set_attr "mode" "<GPR:MODE>")])
2362 (define_insn "*zero_extend<SHORT:mode><GPR:mode>2_mips16e"
2363 [(set (match_operand:GPR 0 "register_operand" "=d")
2364 (zero_extend:GPR (match_operand:SHORT 1 "register_operand" "0")))]
2366 "ze<SHORT:size>\t%0"
2367 [(set_attr "type" "arith")
2368 (set_attr "mode" "<GPR:MODE>")])
2370 (define_insn "*zero_extend<SHORT:mode><GPR:mode>2_mips16"
2371 [(set (match_operand:GPR 0 "register_operand" "=d")
2372 (zero_extend:GPR (match_operand:SHORT 1 "memory_operand" "m")))]
2374 "l<SHORT:size>u\t%0,%1"
2375 [(set_attr "type" "load")
2376 (set_attr "mode" "<GPR:MODE>")])
2378 (define_expand "zero_extendqihi2"
2379 [(set (match_operand:HI 0 "register_operand")
2380 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand")))]
2383 if (TARGET_MIPS16 && !memory_operand (operands[1], QImode))
2385 emit_insn (gen_zero_extendqisi2 (gen_lowpart (SImode, operands[0]),
2391 (define_insn "*zero_extendqihi2"
2392 [(set (match_operand:HI 0 "register_operand" "=d,d")
2393 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
2398 [(set_attr "type" "arith,load")
2399 (set_attr "mode" "HI")])
2401 (define_insn "*zero_extendqihi2_mips16"
2402 [(set (match_operand:HI 0 "register_operand" "=d")
2403 (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
2406 [(set_attr "type" "load")
2407 (set_attr "mode" "HI")])
2410 ;; ....................
2414 ;; ....................
2417 ;; Those for integer source operand are ordered widest source type first.
2419 ;; When TARGET_64BIT, all SImode integer registers should already be in
2420 ;; sign-extended form (see TRULY_NOOP_TRUNCATION and truncdisi2). We can
2421 ;; therefore get rid of register->register instructions if we constrain
2422 ;; the source to be in the same register as the destination.
2424 ;; The register alternative has type "arith" so that the pre-reload
2425 ;; scheduler will treat it as a move. This reflects what happens if
2426 ;; the register alternative needs a reload.
2427 (define_insn_and_split "extendsidi2"
2428 [(set (match_operand:DI 0 "register_operand" "=d,d")
2429 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "0,m")))]
2434 "&& reload_completed && register_operand (operands[1], VOIDmode)"
2437 emit_note (NOTE_INSN_DELETED);
2440 [(set_attr "type" "arith,load")
2441 (set_attr "mode" "DI")])
2443 (define_expand "extend<SHORT:mode><GPR:mode>2"
2444 [(set (match_operand:GPR 0 "register_operand")
2445 (sign_extend:GPR (match_operand:SHORT 1 "nonimmediate_operand")))]
2448 (define_insn "*extend<SHORT:mode><GPR:mode>2_mips16e"
2449 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2450 (sign_extend:GPR (match_operand:SHORT 1 "nonimmediate_operand" "0,m")))]
2454 l<SHORT:size>\t%0,%1"
2455 [(set_attr "type" "arith,load")
2456 (set_attr "mode" "<GPR:MODE>")])
2458 (define_insn_and_split "*extend<SHORT:mode><GPR:mode>2"
2459 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2461 (match_operand:SHORT 1 "nonimmediate_operand" "d,m")))]
2462 "!ISA_HAS_SEB_SEH && !GENERATE_MIPS16E"
2465 l<SHORT:size>\t%0,%1"
2466 "&& reload_completed && REG_P (operands[1])"
2467 [(set (match_dup 0) (ashift:GPR (match_dup 1) (match_dup 2)))
2468 (set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))]
2470 operands[1] = gen_lowpart (<GPR:MODE>mode, operands[1]);
2471 operands[2] = GEN_INT (GET_MODE_BITSIZE (<GPR:MODE>mode)
2472 - GET_MODE_BITSIZE (<SHORT:MODE>mode));
2474 [(set_attr "type" "arith,load")
2475 (set_attr "mode" "<GPR:MODE>")
2476 (set_attr "length" "8,*")])
2478 (define_insn "*extend<SHORT:mode><GPR:mode>2_se<SHORT:size>"
2479 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2481 (match_operand:SHORT 1 "nonimmediate_operand" "d,m")))]
2484 se<SHORT:size>\t%0,%1
2485 l<SHORT:size>\t%0,%1"
2486 [(set_attr "type" "arith,load")
2487 (set_attr "mode" "<GPR:MODE>")])
2489 ;; This pattern generates the same code as extendqisi2; split it into
2490 ;; that form after reload.
2491 (define_insn_and_split "extendqihi2"
2492 [(set (match_operand:HI 0 "register_operand" "=d,d")
2493 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
2497 [(set (match_dup 0) (sign_extend:SI (match_dup 1)))]
2498 { operands[0] = gen_lowpart (SImode, operands[0]); }
2499 [(set_attr "type" "arith,load")
2500 (set_attr "mode" "SI")
2501 (set_attr "length" "8,*")])
2503 (define_insn "extendsfdf2"
2504 [(set (match_operand:DF 0 "register_operand" "=f")
2505 (float_extend:DF (match_operand:SF 1 "register_operand" "f")))]
2506 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2508 [(set_attr "type" "fcvt")
2509 (set_attr "cnv_mode" "S2D")
2510 (set_attr "mode" "DF")])
2513 ;; ....................
2517 ;; ....................
2519 (define_expand "fix_truncdfsi2"
2520 [(set (match_operand:SI 0 "register_operand")
2521 (fix:SI (match_operand:DF 1 "register_operand")))]
2522 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2524 if (!ISA_HAS_TRUNC_W)
2526 emit_insn (gen_fix_truncdfsi2_macro (operands[0], operands[1]));
2531 (define_insn "fix_truncdfsi2_insn"
2532 [(set (match_operand:SI 0 "register_operand" "=f")
2533 (fix:SI (match_operand:DF 1 "register_operand" "f")))]
2534 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && ISA_HAS_TRUNC_W"
2536 [(set_attr "type" "fcvt")
2537 (set_attr "mode" "DF")
2538 (set_attr "cnv_mode" "D2I")
2539 (set_attr "length" "4")])
2541 (define_insn "fix_truncdfsi2_macro"
2542 [(set (match_operand:SI 0 "register_operand" "=f")
2543 (fix:SI (match_operand:DF 1 "register_operand" "f")))
2544 (clobber (match_scratch:DF 2 "=d"))]
2545 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !ISA_HAS_TRUNC_W"
2548 return ".set\tmacro\;trunc.w.d %0,%1,%2\;.set\tnomacro";
2550 return "trunc.w.d %0,%1,%2";
2552 [(set_attr "type" "fcvt")
2553 (set_attr "mode" "DF")
2554 (set_attr "cnv_mode" "D2I")
2555 (set_attr "length" "36")])
2557 (define_expand "fix_truncsfsi2"
2558 [(set (match_operand:SI 0 "register_operand")
2559 (fix:SI (match_operand:SF 1 "register_operand")))]
2562 if (!ISA_HAS_TRUNC_W)
2564 emit_insn (gen_fix_truncsfsi2_macro (operands[0], operands[1]));
2569 (define_insn "fix_truncsfsi2_insn"
2570 [(set (match_operand:SI 0 "register_operand" "=f")
2571 (fix:SI (match_operand:SF 1 "register_operand" "f")))]
2572 "TARGET_HARD_FLOAT && ISA_HAS_TRUNC_W"
2574 [(set_attr "type" "fcvt")
2575 (set_attr "mode" "SF")
2576 (set_attr "cnv_mode" "S2I")
2577 (set_attr "length" "4")])
2579 (define_insn "fix_truncsfsi2_macro"
2580 [(set (match_operand:SI 0 "register_operand" "=f")
2581 (fix:SI (match_operand:SF 1 "register_operand" "f")))
2582 (clobber (match_scratch:SF 2 "=d"))]
2583 "TARGET_HARD_FLOAT && !ISA_HAS_TRUNC_W"
2586 return ".set\tmacro\;trunc.w.s %0,%1,%2\;.set\tnomacro";
2588 return "trunc.w.s %0,%1,%2";
2590 [(set_attr "type" "fcvt")
2591 (set_attr "mode" "SF")
2592 (set_attr "cnv_mode" "S2I")
2593 (set_attr "length" "36")])
2596 (define_insn "fix_truncdfdi2"
2597 [(set (match_operand:DI 0 "register_operand" "=f")
2598 (fix:DI (match_operand:DF 1 "register_operand" "f")))]
2599 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
2601 [(set_attr "type" "fcvt")
2602 (set_attr "mode" "DF")
2603 (set_attr "cnv_mode" "D2I")
2604 (set_attr "length" "4")])
2607 (define_insn "fix_truncsfdi2"
2608 [(set (match_operand:DI 0 "register_operand" "=f")
2609 (fix:DI (match_operand:SF 1 "register_operand" "f")))]
2610 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
2612 [(set_attr "type" "fcvt")
2613 (set_attr "mode" "SF")
2614 (set_attr "cnv_mode" "S2I")
2615 (set_attr "length" "4")])
2618 (define_insn "floatsidf2"
2619 [(set (match_operand:DF 0 "register_operand" "=f")
2620 (float:DF (match_operand:SI 1 "register_operand" "f")))]
2621 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2623 [(set_attr "type" "fcvt")
2624 (set_attr "mode" "DF")
2625 (set_attr "cnv_mode" "I2D")
2626 (set_attr "length" "4")])
2629 (define_insn "floatdidf2"
2630 [(set (match_operand:DF 0 "register_operand" "=f")
2631 (float:DF (match_operand:DI 1 "register_operand" "f")))]
2632 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
2634 [(set_attr "type" "fcvt")
2635 (set_attr "mode" "DF")
2636 (set_attr "cnv_mode" "I2D")
2637 (set_attr "length" "4")])
2640 (define_insn "floatsisf2"
2641 [(set (match_operand:SF 0 "register_operand" "=f")
2642 (float:SF (match_operand:SI 1 "register_operand" "f")))]
2645 [(set_attr "type" "fcvt")
2646 (set_attr "mode" "SF")
2647 (set_attr "cnv_mode" "I2S")
2648 (set_attr "length" "4")])
2651 (define_insn "floatdisf2"
2652 [(set (match_operand:SF 0 "register_operand" "=f")
2653 (float:SF (match_operand:DI 1 "register_operand" "f")))]
2654 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
2656 [(set_attr "type" "fcvt")
2657 (set_attr "mode" "SF")
2658 (set_attr "cnv_mode" "I2S")
2659 (set_attr "length" "4")])
2662 (define_expand "fixuns_truncdfsi2"
2663 [(set (match_operand:SI 0 "register_operand")
2664 (unsigned_fix:SI (match_operand:DF 1 "register_operand")))]
2665 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2667 rtx reg1 = gen_reg_rtx (DFmode);
2668 rtx reg2 = gen_reg_rtx (DFmode);
2669 rtx reg3 = gen_reg_rtx (SImode);
2670 rtx label1 = gen_label_rtx ();
2671 rtx label2 = gen_label_rtx ();
2672 REAL_VALUE_TYPE offset;
2674 real_2expN (&offset, 31);
2676 if (reg1) /* Turn off complaints about unreached code. */
2678 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, DFmode));
2679 do_pending_stack_adjust ();
2681 emit_insn (gen_cmpdf (operands[1], reg1));
2682 emit_jump_insn (gen_bge (label1));
2684 emit_insn (gen_fix_truncdfsi2 (operands[0], operands[1]));
2685 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
2686 gen_rtx_LABEL_REF (VOIDmode, label2)));
2689 emit_label (label1);
2690 emit_move_insn (reg2, gen_rtx_MINUS (DFmode, operands[1], reg1));
2691 emit_move_insn (reg3, GEN_INT (trunc_int_for_mode
2692 (BITMASK_HIGH, SImode)));
2694 emit_insn (gen_fix_truncdfsi2 (operands[0], reg2));
2695 emit_insn (gen_iorsi3 (operands[0], operands[0], reg3));
2697 emit_label (label2);
2699 /* Allow REG_NOTES to be set on last insn (labels don't have enough
2700 fields, and can't be used for REG_NOTES anyway). */
2701 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
2707 (define_expand "fixuns_truncdfdi2"
2708 [(set (match_operand:DI 0 "register_operand")
2709 (unsigned_fix:DI (match_operand:DF 1 "register_operand")))]
2710 "TARGET_HARD_FLOAT && TARGET_64BIT && TARGET_DOUBLE_FLOAT"
2712 rtx reg1 = gen_reg_rtx (DFmode);
2713 rtx reg2 = gen_reg_rtx (DFmode);
2714 rtx reg3 = gen_reg_rtx (DImode);
2715 rtx label1 = gen_label_rtx ();
2716 rtx label2 = gen_label_rtx ();
2717 REAL_VALUE_TYPE offset;
2719 real_2expN (&offset, 63);
2721 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, DFmode));
2722 do_pending_stack_adjust ();
2724 emit_insn (gen_cmpdf (operands[1], reg1));
2725 emit_jump_insn (gen_bge (label1));
2727 emit_insn (gen_fix_truncdfdi2 (operands[0], operands[1]));
2728 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
2729 gen_rtx_LABEL_REF (VOIDmode, label2)));
2732 emit_label (label1);
2733 emit_move_insn (reg2, gen_rtx_MINUS (DFmode, operands[1], reg1));
2734 emit_move_insn (reg3, GEN_INT (BITMASK_HIGH));
2735 emit_insn (gen_ashldi3 (reg3, reg3, GEN_INT (32)));
2737 emit_insn (gen_fix_truncdfdi2 (operands[0], reg2));
2738 emit_insn (gen_iordi3 (operands[0], operands[0], reg3));
2740 emit_label (label2);
2742 /* Allow REG_NOTES to be set on last insn (labels don't have enough
2743 fields, and can't be used for REG_NOTES anyway). */
2744 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
2749 (define_expand "fixuns_truncsfsi2"
2750 [(set (match_operand:SI 0 "register_operand")
2751 (unsigned_fix:SI (match_operand:SF 1 "register_operand")))]
2754 rtx reg1 = gen_reg_rtx (SFmode);
2755 rtx reg2 = gen_reg_rtx (SFmode);
2756 rtx reg3 = gen_reg_rtx (SImode);
2757 rtx label1 = gen_label_rtx ();
2758 rtx label2 = gen_label_rtx ();
2759 REAL_VALUE_TYPE offset;
2761 real_2expN (&offset, 31);
2763 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, SFmode));
2764 do_pending_stack_adjust ();
2766 emit_insn (gen_cmpsf (operands[1], reg1));
2767 emit_jump_insn (gen_bge (label1));
2769 emit_insn (gen_fix_truncsfsi2 (operands[0], operands[1]));
2770 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
2771 gen_rtx_LABEL_REF (VOIDmode, label2)));
2774 emit_label (label1);
2775 emit_move_insn (reg2, gen_rtx_MINUS (SFmode, operands[1], reg1));
2776 emit_move_insn (reg3, GEN_INT (trunc_int_for_mode
2777 (BITMASK_HIGH, SImode)));
2779 emit_insn (gen_fix_truncsfsi2 (operands[0], reg2));
2780 emit_insn (gen_iorsi3 (operands[0], operands[0], reg3));
2782 emit_label (label2);
2784 /* Allow REG_NOTES to be set on last insn (labels don't have enough
2785 fields, and can't be used for REG_NOTES anyway). */
2786 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
2791 (define_expand "fixuns_truncsfdi2"
2792 [(set (match_operand:DI 0 "register_operand")
2793 (unsigned_fix:DI (match_operand:SF 1 "register_operand")))]
2794 "TARGET_HARD_FLOAT && TARGET_64BIT && TARGET_DOUBLE_FLOAT"
2796 rtx reg1 = gen_reg_rtx (SFmode);
2797 rtx reg2 = gen_reg_rtx (SFmode);
2798 rtx reg3 = gen_reg_rtx (DImode);
2799 rtx label1 = gen_label_rtx ();
2800 rtx label2 = gen_label_rtx ();
2801 REAL_VALUE_TYPE offset;
2803 real_2expN (&offset, 63);
2805 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, SFmode));
2806 do_pending_stack_adjust ();
2808 emit_insn (gen_cmpsf (operands[1], reg1));
2809 emit_jump_insn (gen_bge (label1));
2811 emit_insn (gen_fix_truncsfdi2 (operands[0], operands[1]));
2812 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
2813 gen_rtx_LABEL_REF (VOIDmode, label2)));
2816 emit_label (label1);
2817 emit_move_insn (reg2, gen_rtx_MINUS (SFmode, operands[1], reg1));
2818 emit_move_insn (reg3, GEN_INT (BITMASK_HIGH));
2819 emit_insn (gen_ashldi3 (reg3, reg3, GEN_INT (32)));
2821 emit_insn (gen_fix_truncsfdi2 (operands[0], reg2));
2822 emit_insn (gen_iordi3 (operands[0], operands[0], reg3));
2824 emit_label (label2);
2826 /* Allow REG_NOTES to be set on last insn (labels don't have enough
2827 fields, and can't be used for REG_NOTES anyway). */
2828 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
2833 ;; ....................
2837 ;; ....................
2839 ;; Bit field extract patterns which use lwl/lwr or ldl/ldr.
2841 (define_expand "extv"
2842 [(set (match_operand 0 "register_operand")
2843 (sign_extract (match_operand:QI 1 "memory_operand")
2844 (match_operand 2 "immediate_operand")
2845 (match_operand 3 "immediate_operand")))]
2848 if (mips_expand_unaligned_load (operands[0], operands[1],
2849 INTVAL (operands[2]),
2850 INTVAL (operands[3])))
2856 (define_expand "extzv"
2857 [(set (match_operand 0 "register_operand")
2858 (zero_extract (match_operand 1 "nonimmediate_operand")
2859 (match_operand 2 "immediate_operand")
2860 (match_operand 3 "immediate_operand")))]
2863 if (mips_expand_unaligned_load (operands[0], operands[1],
2864 INTVAL (operands[2]),
2865 INTVAL (operands[3])))
2867 else if (mips_use_ins_ext_p (operands[1], operands[2], operands[3]))
2869 if (GET_MODE (operands[0]) == DImode)
2870 emit_insn (gen_extzvdi (operands[0], operands[1], operands[2],
2873 emit_insn (gen_extzvsi (operands[0], operands[1], operands[2],
2881 (define_insn "extzv<mode>"
2882 [(set (match_operand:GPR 0 "register_operand" "=d")
2883 (zero_extract:GPR (match_operand:GPR 1 "register_operand" "d")
2884 (match_operand:SI 2 "immediate_operand" "I")
2885 (match_operand:SI 3 "immediate_operand" "I")))]
2886 "mips_use_ins_ext_p (operands[1], operands[2], operands[3])"
2887 "<d>ext\t%0,%1,%3,%2"
2888 [(set_attr "type" "arith")
2889 (set_attr "mode" "<MODE>")])
2892 (define_expand "insv"
2893 [(set (zero_extract (match_operand 0 "nonimmediate_operand")
2894 (match_operand 1 "immediate_operand")
2895 (match_operand 2 "immediate_operand"))
2896 (match_operand 3 "reg_or_0_operand"))]
2899 if (mips_expand_unaligned_store (operands[0], operands[3],
2900 INTVAL (operands[1]),
2901 INTVAL (operands[2])))
2903 else if (mips_use_ins_ext_p (operands[0], operands[1], operands[2]))
2905 if (GET_MODE (operands[0]) == DImode)
2906 emit_insn (gen_insvdi (operands[0], operands[1], operands[2],
2909 emit_insn (gen_insvsi (operands[0], operands[1], operands[2],
2917 (define_insn "insv<mode>"
2918 [(set (zero_extract:GPR (match_operand:GPR 0 "register_operand" "+d")
2919 (match_operand:SI 1 "immediate_operand" "I")
2920 (match_operand:SI 2 "immediate_operand" "I"))
2921 (match_operand:GPR 3 "reg_or_0_operand" "dJ"))]
2922 "mips_use_ins_ext_p (operands[0], operands[1], operands[2])"
2923 "<d>ins\t%0,%z3,%2,%1"
2924 [(set_attr "type" "arith")
2925 (set_attr "mode" "<MODE>")])
2927 ;; Unaligned word moves generated by the bit field patterns.
2929 ;; As far as the rtl is concerned, both the left-part and right-part
2930 ;; instructions can access the whole field. However, the real operand
2931 ;; refers to just the first or the last byte (depending on endianness).
2932 ;; We therefore use two memory operands to each instruction, one to
2933 ;; describe the rtl effect and one to use in the assembly output.
2935 ;; Operands 0 and 1 are the rtl-level target and source respectively.
2936 ;; This allows us to use the standard length calculations for the "load"
2937 ;; and "store" type attributes.
2939 (define_insn "mov_<load>l"
2940 [(set (match_operand:GPR 0 "register_operand" "=d")
2941 (unspec:GPR [(match_operand:BLK 1 "memory_operand" "m")
2942 (match_operand:QI 2 "memory_operand" "m")]
2944 "!TARGET_MIPS16 && mips_mem_fits_mode_p (<MODE>mode, operands[1])"
2946 [(set_attr "type" "load")
2947 (set_attr "mode" "<MODE>")])
2949 (define_insn "mov_<load>r"
2950 [(set (match_operand:GPR 0 "register_operand" "=d")
2951 (unspec:GPR [(match_operand:BLK 1 "memory_operand" "m")
2952 (match_operand:QI 2 "memory_operand" "m")
2953 (match_operand:GPR 3 "register_operand" "0")]
2954 UNSPEC_LOAD_RIGHT))]
2955 "!TARGET_MIPS16 && mips_mem_fits_mode_p (<MODE>mode, operands[1])"
2957 [(set_attr "type" "load")
2958 (set_attr "mode" "<MODE>")])
2960 (define_insn "mov_<store>l"
2961 [(set (match_operand:BLK 0 "memory_operand" "=m")
2962 (unspec:BLK [(match_operand:GPR 1 "reg_or_0_operand" "dJ")
2963 (match_operand:QI 2 "memory_operand" "m")]
2964 UNSPEC_STORE_LEFT))]
2965 "!TARGET_MIPS16 && mips_mem_fits_mode_p (<MODE>mode, operands[0])"
2967 [(set_attr "type" "store")
2968 (set_attr "mode" "<MODE>")])
2970 (define_insn "mov_<store>r"
2971 [(set (match_operand:BLK 0 "memory_operand" "+m")
2972 (unspec:BLK [(match_operand:GPR 1 "reg_or_0_operand" "dJ")
2973 (match_operand:QI 2 "memory_operand" "m")
2975 UNSPEC_STORE_RIGHT))]
2976 "!TARGET_MIPS16 && mips_mem_fits_mode_p (<MODE>mode, operands[0])"
2978 [(set_attr "type" "store")
2979 (set_attr "mode" "<MODE>")])
2981 ;; An instruction to calculate the high part of a 64-bit SYMBOL_GENERAL.
2982 ;; The required value is:
2984 ;; (%highest(op1) << 48) + (%higher(op1) << 32) + (%hi(op1) << 16)
2986 ;; which translates to:
2988 ;; lui op0,%highest(op1)
2989 ;; daddiu op0,op0,%higher(op1)
2991 ;; daddiu op0,op0,%hi(op1)
2994 ;; The split is deferred until after flow2 to allow the peephole2 below
2996 (define_insn_and_split "*lea_high64"
2997 [(set (match_operand:DI 0 "register_operand" "=d")
2998 (high:DI (match_operand:DI 1 "general_symbolic_operand" "")))]
2999 "TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS"
3001 "&& flow2_completed"
3002 [(set (match_dup 0) (high:DI (match_dup 2)))
3003 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 2)))
3004 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 16)))
3005 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 3)))
3006 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 16)))]
3008 operands[2] = mips_unspec_address (operands[1], SYMBOL_64_HIGH);
3009 operands[3] = mips_unspec_address (operands[1], SYMBOL_64_MID);
3011 [(set_attr "length" "20")])
3013 ;; Use a scratch register to reduce the latency of the above pattern
3014 ;; on superscalar machines. The optimized sequence is:
3016 ;; lui op1,%highest(op2)
3018 ;; daddiu op1,op1,%higher(op2)
3020 ;; daddu op1,op1,op0
3022 [(set (match_operand:DI 1 "register_operand")
3023 (high:DI (match_operand:DI 2 "general_symbolic_operand")))
3024 (match_scratch:DI 0 "d")]
3025 "TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS"
3026 [(set (match_dup 1) (high:DI (match_dup 3)))
3027 (set (match_dup 0) (high:DI (match_dup 4)))
3028 (set (match_dup 1) (lo_sum:DI (match_dup 1) (match_dup 3)))
3029 (set (match_dup 1) (ashift:DI (match_dup 1) (const_int 32)))
3030 (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 0)))]
3032 operands[3] = mips_unspec_address (operands[2], SYMBOL_64_HIGH);
3033 operands[4] = mips_unspec_address (operands[2], SYMBOL_64_LOW);
3036 ;; On most targets, the expansion of (lo_sum (high X) X) for a 64-bit
3037 ;; SYMBOL_GENERAL X will take 6 cycles. This next pattern allows combine
3038 ;; to merge the HIGH and LO_SUM parts of a move if the HIGH part is only
3039 ;; used once. We can then use the sequence:
3041 ;; lui op0,%highest(op1)
3043 ;; daddiu op0,op0,%higher(op1)
3044 ;; daddiu op2,op2,%lo(op1)
3046 ;; daddu op0,op0,op2
3048 ;; which takes 4 cycles on most superscalar targets.
3049 (define_insn_and_split "*lea64"
3050 [(set (match_operand:DI 0 "register_operand" "=d")
3051 (match_operand:DI 1 "general_symbolic_operand" ""))
3052 (clobber (match_scratch:DI 2 "=&d"))]
3053 "TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS && cse_not_expected"
3055 "&& reload_completed"
3056 [(set (match_dup 0) (high:DI (match_dup 3)))
3057 (set (match_dup 2) (high:DI (match_dup 4)))
3058 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 3)))
3059 (set (match_dup 2) (lo_sum:DI (match_dup 2) (match_dup 4)))
3060 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
3061 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))]
3063 operands[3] = mips_unspec_address (operands[1], SYMBOL_64_HIGH);
3064 operands[4] = mips_unspec_address (operands[1], SYMBOL_64_LOW);
3066 [(set_attr "length" "24")])
3068 ;; Insns to fetch a global symbol from a big GOT.
3070 (define_insn_and_split "*xgot_hi<mode>"
3071 [(set (match_operand:P 0 "register_operand" "=d")
3072 (high:P (match_operand:P 1 "global_got_operand" "")))]
3073 "TARGET_EXPLICIT_RELOCS && TARGET_XGOT"
3075 "&& reload_completed"
3076 [(set (match_dup 0) (high:P (match_dup 2)))
3077 (set (match_dup 0) (plus:P (match_dup 0) (match_dup 3)))]
3079 operands[2] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_GLOBAL);
3080 operands[3] = pic_offset_table_rtx;
3082 [(set_attr "got" "xgot_high")
3083 (set_attr "mode" "<MODE>")])
3085 (define_insn_and_split "*xgot_lo<mode>"
3086 [(set (match_operand:P 0 "register_operand" "=d")
3087 (lo_sum:P (match_operand:P 1 "register_operand" "d")
3088 (match_operand:P 2 "global_got_operand" "")))]
3089 "TARGET_EXPLICIT_RELOCS && TARGET_XGOT"
3091 "&& reload_completed"
3093 (unspec:P [(match_dup 1) (match_dup 3)] UNSPEC_LOAD_GOT))]
3094 { operands[3] = mips_unspec_address (operands[2], SYMBOL_GOTOFF_GLOBAL); }
3095 [(set_attr "got" "load")
3096 (set_attr "mode" "<MODE>")])
3098 ;; Insns to fetch a global symbol from a normal GOT.
3100 (define_insn_and_split "*got_disp<mode>"
3101 [(set (match_operand:P 0 "register_operand" "=d")
3102 (match_operand:P 1 "global_got_operand" ""))]
3103 "TARGET_EXPLICIT_RELOCS && !TARGET_XGOT"
3105 "&& reload_completed"
3107 (unspec:P [(match_dup 2) (match_dup 3)] UNSPEC_LOAD_GOT))]
3109 operands[2] = pic_offset_table_rtx;
3110 operands[3] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_GLOBAL);
3112 [(set_attr "got" "load")
3113 (set_attr "mode" "<MODE>")])
3115 ;; Insns for loading the high part of a local symbol.
3117 (define_insn_and_split "*got_page<mode>"
3118 [(set (match_operand:P 0 "register_operand" "=d")
3119 (high:P (match_operand:P 1 "local_got_operand" "")))]
3120 "TARGET_EXPLICIT_RELOCS"
3122 "&& reload_completed"
3124 (unspec:P [(match_dup 2) (match_dup 3)] UNSPEC_LOAD_GOT))]
3126 operands[2] = pic_offset_table_rtx;
3127 operands[3] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_PAGE);
3129 [(set_attr "got" "load")
3130 (set_attr "mode" "<MODE>")])
3132 ;; Lower-level instructions for loading an address from the GOT.
3133 ;; We could use MEMs, but an unspec gives more optimization
3136 (define_insn "load_got<mode>"
3137 [(set (match_operand:P 0 "register_operand" "=d")
3138 (unspec:P [(match_operand:P 1 "register_operand" "d")
3139 (match_operand:P 2 "immediate_operand" "")]
3142 "<load>\t%0,%R2(%1)"
3143 [(set_attr "type" "load")
3144 (set_attr "mode" "<MODE>")
3145 (set_attr "length" "4")])
3147 ;; Instructions for adding the low 16 bits of an address to a register.
3148 ;; Operand 2 is the address: print_operand works out which relocation
3149 ;; should be applied.
3151 (define_insn "*low<mode>"
3152 [(set (match_operand:P 0 "register_operand" "=d")
3153 (lo_sum:P (match_operand:P 1 "register_operand" "d")
3154 (match_operand:P 2 "immediate_operand" "")))]
3156 "<d>addiu\t%0,%1,%R2"
3157 [(set_attr "type" "arith")
3158 (set_attr "mode" "<MODE>")])
3160 (define_insn "*low<mode>_mips16"
3161 [(set (match_operand:P 0 "register_operand" "=d")
3162 (lo_sum:P (match_operand:P 1 "register_operand" "0")
3163 (match_operand:P 2 "immediate_operand" "")))]
3166 [(set_attr "type" "arith")
3167 (set_attr "mode" "<MODE>")
3168 (set_attr "length" "8")])
3170 ;; 64-bit integer moves
3172 ;; Unlike most other insns, the move insns can't be split with
3173 ;; different predicates, because register spilling and other parts of
3174 ;; the compiler, have memoized the insn number already.
3176 (define_expand "movdi"
3177 [(set (match_operand:DI 0 "")
3178 (match_operand:DI 1 ""))]
3181 if (mips_legitimize_move (DImode, operands[0], operands[1]))
3185 ;; For mips16, we need a special case to handle storing $31 into
3186 ;; memory, since we don't have a constraint to match $31. This
3187 ;; instruction can be generated by save_restore_insns.
3189 (define_insn "*mov<mode>_ra"
3190 [(set (match_operand:GPR 0 "stack_operand" "=m")
3194 [(set_attr "type" "store")
3195 (set_attr "mode" "<MODE>")])
3197 (define_insn "*movdi_32bit"
3198 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,m,*a,*d,*B*C*D,*B*C*D,*d,*m")
3199 (match_operand:DI 1 "move_operand" "d,i,m,d,*J*d,*a,*d,*m,*B*C*D,*B*C*D"))]
3200 "!TARGET_64BIT && !TARGET_MIPS16
3201 && (register_operand (operands[0], DImode)
3202 || reg_or_0_operand (operands[1], DImode))"
3203 { return mips_output_move (operands[0], operands[1]); }
3204 [(set_attr "type" "arith,arith,load,store,mthilo,mfhilo,xfer,load,xfer,store")
3205 (set_attr "mode" "DI")
3206 (set_attr "length" "8,16,*,*,8,8,8,*,8,*")])
3208 (define_insn "*movdi_32bit_mips16"
3209 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m,*d")
3210 (match_operand:DI 1 "move_operand" "d,d,y,K,N,m,d,*x"))]
3211 "!TARGET_64BIT && TARGET_MIPS16
3212 && (register_operand (operands[0], DImode)
3213 || register_operand (operands[1], DImode))"
3214 { return mips_output_move (operands[0], operands[1]); }
3215 [(set_attr "type" "arith,arith,arith,arith,arith,load,store,mfhilo")
3216 (set_attr "mode" "DI")
3217 (set_attr "length" "8,8,8,8,12,*,*,8")])
3219 (define_insn "*movdi_64bit"
3220 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,e,d,m,*f,*f,*f,*d,*m,*x,*B*C*D,*B*C*D,*d,*m")
3221 (match_operand:DI 1 "move_operand" "d,U,T,m,dJ,*f,*d*J,*m,*f,*f,*J*d,*d,*m,*B*C*D,*B*C*D"))]
3222 "TARGET_64BIT && !TARGET_MIPS16
3223 && (register_operand (operands[0], DImode)
3224 || reg_or_0_operand (operands[1], DImode))"
3225 { return mips_output_move (operands[0], operands[1]); }
3226 [(set_attr "type" "arith,const,const,load,store,fmove,xfer,fpload,xfer,fpstore,mthilo,xfer,load,xfer,store")
3227 (set_attr "mode" "DI")
3228 (set_attr "length" "4,*,*,*,*,4,4,*,4,*,4,8,*,8,*")])
3230 (define_insn "*movdi_64bit_mips16"
3231 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,y,d,d,d,d,d,m")
3232 (match_operand:DI 1 "move_operand" "d,d,y,K,N,U,m,d"))]
3233 "TARGET_64BIT && TARGET_MIPS16
3234 && (register_operand (operands[0], DImode)
3235 || register_operand (operands[1], DImode))"
3236 { return mips_output_move (operands[0], operands[1]); }
3237 [(set_attr "type" "arith,arith,arith,arith,arith,const,load,store")
3238 (set_attr "mode" "DI")
3239 (set_attr_alternative "length"
3243 (if_then_else (match_operand:VOID 1 "m16_uimm8_1")
3246 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1")
3251 (const_string "*")])])
3254 ;; On the mips16, we can split ld $r,N($r) into an add and a load,
3255 ;; when the original load is a 4 byte instruction but the add and the
3256 ;; load are 2 2 byte instructions.
3259 [(set (match_operand:DI 0 "register_operand")
3260 (mem:DI (plus:DI (match_dup 0)
3261 (match_operand:DI 1 "const_int_operand"))))]
3262 "TARGET_64BIT && TARGET_MIPS16 && reload_completed
3263 && !TARGET_DEBUG_D_MODE
3264 && REG_P (operands[0])
3265 && M16_REG_P (REGNO (operands[0]))
3266 && GET_CODE (operands[1]) == CONST_INT
3267 && ((INTVAL (operands[1]) < 0
3268 && INTVAL (operands[1]) >= -0x10)
3269 || (INTVAL (operands[1]) >= 32 * 8
3270 && INTVAL (operands[1]) <= 31 * 8 + 0x8)
3271 || (INTVAL (operands[1]) >= 0
3272 && INTVAL (operands[1]) < 32 * 8
3273 && (INTVAL (operands[1]) & 7) != 0))"
3274 [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1)))
3275 (set (match_dup 0) (mem:DI (plus:DI (match_dup 0) (match_dup 2))))]
3277 HOST_WIDE_INT val = INTVAL (operands[1]);
3280 operands[2] = const0_rtx;
3281 else if (val >= 32 * 8)
3285 operands[1] = GEN_INT (0x8 + off);
3286 operands[2] = GEN_INT (val - off - 0x8);
3292 operands[1] = GEN_INT (off);
3293 operands[2] = GEN_INT (val - off);
3297 ;; 32-bit Integer moves
3299 ;; Unlike most other insns, the move insns can't be split with
3300 ;; different predicates, because register spilling and other parts of
3301 ;; the compiler, have memoized the insn number already.
3303 (define_expand "movsi"
3304 [(set (match_operand:SI 0 "")
3305 (match_operand:SI 1 ""))]
3308 if (mips_legitimize_move (SImode, operands[0], operands[1]))
3312 ;; The difference between these two is whether or not ints are allowed
3313 ;; in FP registers (off by default, use -mdebugh to enable).
3315 (define_insn "*movsi_internal"
3316 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,e,d,m,*f,*f,*f,*d,*m,*d,*z,*a,*d,*B*C*D,*B*C*D,*d,*m")
3317 (match_operand:SI 1 "move_operand" "d,U,T,m,dJ,*f,*d*J,*m,*f,*f,*z,*d,*J*d,*A,*d,*m,*B*C*D,*B*C*D"))]
3319 && (register_operand (operands[0], SImode)
3320 || reg_or_0_operand (operands[1], SImode))"
3321 { return mips_output_move (operands[0], operands[1]); }
3322 [(set_attr "type" "arith,const,const,load,store,fmove,xfer,fpload,xfer,fpstore,xfer,xfer,mthilo,mfhilo,xfer,load,xfer,store")
3323 (set_attr "mode" "SI")
3324 (set_attr "length" "4,*,*,*,*,4,4,*,4,*,4,4,4,4,4,*,4,*")])
3326 (define_insn "*movsi_mips16"
3327 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,y,d,d,d,d,d,m")
3328 (match_operand:SI 1 "move_operand" "d,d,y,K,N,U,m,d"))]
3330 && (register_operand (operands[0], SImode)
3331 || register_operand (operands[1], SImode))"
3332 { return mips_output_move (operands[0], operands[1]); }
3333 [(set_attr "type" "arith,arith,arith,arith,arith,const,load,store")
3334 (set_attr "mode" "SI")
3335 (set_attr_alternative "length"
3339 (if_then_else (match_operand:VOID 1 "m16_uimm8_1")
3342 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1")
3347 (const_string "*")])])
3349 ;; On the mips16, we can split lw $r,N($r) into an add and a load,
3350 ;; when the original load is a 4 byte instruction but the add and the
3351 ;; load are 2 2 byte instructions.
3354 [(set (match_operand:SI 0 "register_operand")
3355 (mem:SI (plus:SI (match_dup 0)
3356 (match_operand:SI 1 "const_int_operand"))))]
3357 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
3358 && REG_P (operands[0])
3359 && M16_REG_P (REGNO (operands[0]))
3360 && GET_CODE (operands[1]) == CONST_INT
3361 && ((INTVAL (operands[1]) < 0
3362 && INTVAL (operands[1]) >= -0x80)
3363 || (INTVAL (operands[1]) >= 32 * 4
3364 && INTVAL (operands[1]) <= 31 * 4 + 0x7c)
3365 || (INTVAL (operands[1]) >= 0
3366 && INTVAL (operands[1]) < 32 * 4
3367 && (INTVAL (operands[1]) & 3) != 0))"
3368 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
3369 (set (match_dup 0) (mem:SI (plus:SI (match_dup 0) (match_dup 2))))]
3371 HOST_WIDE_INT val = INTVAL (operands[1]);
3374 operands[2] = const0_rtx;
3375 else if (val >= 32 * 4)
3379 operands[1] = GEN_INT (0x7c + off);
3380 operands[2] = GEN_INT (val - off - 0x7c);
3386 operands[1] = GEN_INT (off);
3387 operands[2] = GEN_INT (val - off);
3391 ;; On the mips16, we can split a load of certain constants into a load
3392 ;; and an add. This turns a 4 byte instruction into 2 2 byte
3396 [(set (match_operand:SI 0 "register_operand")
3397 (match_operand:SI 1 "const_int_operand"))]
3398 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
3399 && REG_P (operands[0])
3400 && M16_REG_P (REGNO (operands[0]))
3401 && GET_CODE (operands[1]) == CONST_INT
3402 && INTVAL (operands[1]) >= 0x100
3403 && INTVAL (operands[1]) <= 0xff + 0x7f"
3404 [(set (match_dup 0) (match_dup 1))
3405 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]
3407 int val = INTVAL (operands[1]);
3409 operands[1] = GEN_INT (0xff);
3410 operands[2] = GEN_INT (val - 0xff);
3413 ;; This insn handles moving CCmode values. It's really just a
3414 ;; slightly simplified copy of movsi_internal2, with additional cases
3415 ;; to move a condition register to a general register and to move
3416 ;; between the general registers and the floating point registers.
3418 (define_insn "movcc"
3419 [(set (match_operand:CC 0 "nonimmediate_operand" "=d,*d,*d,*m,*d,*f,*f,*f,*m")
3420 (match_operand:CC 1 "general_operand" "z,*d,*m,*d,*f,*d,*f,*m,*f"))]
3421 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
3422 { return mips_output_move (operands[0], operands[1]); }
3423 [(set_attr "type" "xfer,arith,load,store,xfer,xfer,fmove,fpload,fpstore")
3424 (set_attr "mode" "SI")
3425 (set_attr "length" "8,4,*,*,4,4,4,*,*")])
3427 ;; Reload condition code registers. reload_incc and reload_outcc
3428 ;; both handle moves from arbitrary operands into condition code
3429 ;; registers. reload_incc handles the more common case in which
3430 ;; a source operand is constrained to be in a condition-code
3431 ;; register, but has not been allocated to one.
3433 ;; Sometimes, such as in movcc, we have a CCmode destination whose
3434 ;; constraints do not include 'z'. reload_outcc handles the case
3435 ;; when such an operand is allocated to a condition-code register.
3437 ;; Note that reloads from a condition code register to some
3438 ;; other location can be done using ordinary moves. Moving
3439 ;; into a GPR takes a single movcc, moving elsewhere takes
3440 ;; two. We can leave these cases to the generic reload code.
3441 (define_expand "reload_incc"
3442 [(set (match_operand:CC 0 "fcc_reload_operand" "=z")
3443 (match_operand:CC 1 "general_operand" ""))
3444 (clobber (match_operand:TF 2 "register_operand" "=&f"))]
3445 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
3447 mips_emit_fcc_reload (operands[0], operands[1], operands[2]);
3451 (define_expand "reload_outcc"
3452 [(set (match_operand:CC 0 "fcc_reload_operand" "=z")
3453 (match_operand:CC 1 "register_operand" ""))
3454 (clobber (match_operand:TF 2 "register_operand" "=&f"))]
3455 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
3457 mips_emit_fcc_reload (operands[0], operands[1], operands[2]);
3461 ;; MIPS4 supports loading and storing a floating point register from
3462 ;; the sum of two general registers. We use two versions for each of
3463 ;; these four instructions: one where the two general registers are
3464 ;; SImode, and one where they are DImode. This is because general
3465 ;; registers will be in SImode when they hold 32 bit values, but,
3466 ;; since the 32 bit values are always sign extended, the [ls][wd]xc1
3467 ;; instructions will still work correctly.
3469 ;; ??? Perhaps it would be better to support these instructions by
3470 ;; modifying GO_IF_LEGITIMATE_ADDRESS and friends. However, since
3471 ;; these instructions can only be used to load and store floating
3472 ;; point registers, that would probably cause trouble in reload.
3474 (define_insn "*<ANYF:loadx>_<P:mode>"
3475 [(set (match_operand:ANYF 0 "register_operand" "=f")
3476 (mem:ANYF (plus:P (match_operand:P 1 "register_operand" "d")
3477 (match_operand:P 2 "register_operand" "d"))))]
3479 "<ANYF:loadx>\t%0,%1(%2)"
3480 [(set_attr "type" "fpidxload")
3481 (set_attr "mode" "<ANYF:UNITMODE>")])
3483 (define_insn "*<ANYF:storex>_<P:mode>"
3484 [(set (mem:ANYF (plus:P (match_operand:P 1 "register_operand" "d")
3485 (match_operand:P 2 "register_operand" "d")))
3486 (match_operand:ANYF 0 "register_operand" "f"))]
3488 "<ANYF:storex>\t%0,%1(%2)"
3489 [(set_attr "type" "fpidxstore")
3490 (set_attr "mode" "<ANYF:UNITMODE>")])
3492 ;; 16-bit Integer moves
3494 ;; Unlike most other insns, the move insns can't be split with
3495 ;; different predicates, because register spilling and other parts of
3496 ;; the compiler, have memoized the insn number already.
3497 ;; Unsigned loads are used because LOAD_EXTEND_OP returns ZERO_EXTEND.
3499 (define_expand "movhi"
3500 [(set (match_operand:HI 0 "")
3501 (match_operand:HI 1 ""))]
3504 if (mips_legitimize_move (HImode, operands[0], operands[1]))
3508 (define_insn "*movhi_internal"
3509 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,m,*d,*f,*f,*x")
3510 (match_operand:HI 1 "move_operand" "d,I,m,dJ,*f,*d,*f,*d"))]
3512 && (register_operand (operands[0], HImode)
3513 || reg_or_0_operand (operands[1], HImode))"
3523 [(set_attr "type" "arith,arith,load,store,xfer,xfer,fmove,mthilo")
3524 (set_attr "mode" "HI")
3525 (set_attr "length" "4,4,*,*,4,4,4,4")])
3527 (define_insn "*movhi_mips16"
3528 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m")
3529 (match_operand:HI 1 "move_operand" "d,d,y,K,N,m,d"))]
3531 && (register_operand (operands[0], HImode)
3532 || register_operand (operands[1], HImode))"
3541 [(set_attr "type" "arith,arith,arith,arith,arith,load,store")
3542 (set_attr "mode" "HI")
3543 (set_attr_alternative "length"
3547 (if_then_else (match_operand:VOID 1 "m16_uimm8_1")
3550 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1")
3554 (const_string "*")])])
3557 ;; On the mips16, we can split lh $r,N($r) into an add and a load,
3558 ;; when the original load is a 4 byte instruction but the add and the
3559 ;; load are 2 2 byte instructions.
3562 [(set (match_operand:HI 0 "register_operand")
3563 (mem:HI (plus:SI (match_dup 0)
3564 (match_operand:SI 1 "const_int_operand"))))]
3565 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
3566 && REG_P (operands[0])
3567 && M16_REG_P (REGNO (operands[0]))
3568 && GET_CODE (operands[1]) == CONST_INT
3569 && ((INTVAL (operands[1]) < 0
3570 && INTVAL (operands[1]) >= -0x80)
3571 || (INTVAL (operands[1]) >= 32 * 2
3572 && INTVAL (operands[1]) <= 31 * 2 + 0x7e)
3573 || (INTVAL (operands[1]) >= 0
3574 && INTVAL (operands[1]) < 32 * 2
3575 && (INTVAL (operands[1]) & 1) != 0))"
3576 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
3577 (set (match_dup 0) (mem:HI (plus:SI (match_dup 0) (match_dup 2))))]
3579 HOST_WIDE_INT val = INTVAL (operands[1]);
3582 operands[2] = const0_rtx;
3583 else if (val >= 32 * 2)
3587 operands[1] = GEN_INT (0x7e + off);
3588 operands[2] = GEN_INT (val - off - 0x7e);
3594 operands[1] = GEN_INT (off);
3595 operands[2] = GEN_INT (val - off);
3599 ;; 8-bit Integer moves
3601 ;; Unlike most other insns, the move insns can't be split with
3602 ;; different predicates, because register spilling and other parts of
3603 ;; the compiler, have memoized the insn number already.
3604 ;; Unsigned loads are used because LOAD_EXTEND_OP returns ZERO_EXTEND.
3606 (define_expand "movqi"
3607 [(set (match_operand:QI 0 "")
3608 (match_operand:QI 1 ""))]
3611 if (mips_legitimize_move (QImode, operands[0], operands[1]))
3615 (define_insn "*movqi_internal"
3616 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,m,*d,*f,*f,*x")
3617 (match_operand:QI 1 "move_operand" "d,I,m,dJ,*f,*d,*f,*d"))]
3619 && (register_operand (operands[0], QImode)
3620 || reg_or_0_operand (operands[1], QImode))"
3630 [(set_attr "type" "arith,arith,load,store,xfer,xfer,fmove,mthilo")
3631 (set_attr "mode" "QI")
3632 (set_attr "length" "4,4,*,*,4,4,4,4")])
3634 (define_insn "*movqi_mips16"
3635 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m")
3636 (match_operand:QI 1 "move_operand" "d,d,y,K,N,m,d"))]
3638 && (register_operand (operands[0], QImode)
3639 || register_operand (operands[1], QImode))"
3648 [(set_attr "type" "arith,arith,arith,arith,arith,load,store")
3649 (set_attr "mode" "QI")
3650 (set_attr "length" "4,4,4,4,8,*,*")])
3652 ;; On the mips16, we can split lb $r,N($r) into an add and a load,
3653 ;; when the original load is a 4 byte instruction but the add and the
3654 ;; load are 2 2 byte instructions.
3657 [(set (match_operand:QI 0 "register_operand")
3658 (mem:QI (plus:SI (match_dup 0)
3659 (match_operand:SI 1 "const_int_operand"))))]
3660 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
3661 && REG_P (operands[0])
3662 && M16_REG_P (REGNO (operands[0]))
3663 && GET_CODE (operands[1]) == CONST_INT
3664 && ((INTVAL (operands[1]) < 0
3665 && INTVAL (operands[1]) >= -0x80)
3666 || (INTVAL (operands[1]) >= 32
3667 && INTVAL (operands[1]) <= 31 + 0x7f))"
3668 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
3669 (set (match_dup 0) (mem:QI (plus:SI (match_dup 0) (match_dup 2))))]
3671 HOST_WIDE_INT val = INTVAL (operands[1]);
3674 operands[2] = const0_rtx;
3677 operands[1] = GEN_INT (0x7f);
3678 operands[2] = GEN_INT (val - 0x7f);
3682 ;; 32-bit floating point moves
3684 (define_expand "movsf"
3685 [(set (match_operand:SF 0 "")
3686 (match_operand:SF 1 ""))]
3689 if (mips_legitimize_move (SFmode, operands[0], operands[1]))
3693 (define_insn "*movsf_hardfloat"
3694 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m")
3695 (match_operand:SF 1 "move_operand" "f,G,m,f,G,*d,*f,*G*d,*m,*d"))]
3697 && (register_operand (operands[0], SFmode)
3698 || reg_or_0_operand (operands[1], SFmode))"
3699 { return mips_output_move (operands[0], operands[1]); }
3700 [(set_attr "type" "fmove,xfer,fpload,fpstore,store,xfer,xfer,arith,load,store")
3701 (set_attr "mode" "SF")
3702 (set_attr "length" "4,4,*,*,*,4,4,4,*,*")])
3704 (define_insn "*movsf_softfloat"
3705 [(set (match_operand:SF 0 "nonimmediate_operand" "=d,d,m")
3706 (match_operand:SF 1 "move_operand" "Gd,m,d"))]
3707 "TARGET_SOFT_FLOAT && !TARGET_MIPS16
3708 && (register_operand (operands[0], SFmode)
3709 || reg_or_0_operand (operands[1], SFmode))"
3710 { return mips_output_move (operands[0], operands[1]); }
3711 [(set_attr "type" "arith,load,store")
3712 (set_attr "mode" "SF")
3713 (set_attr "length" "4,*,*")])
3715 (define_insn "*movsf_mips16"
3716 [(set (match_operand:SF 0 "nonimmediate_operand" "=d,y,d,d,m")
3717 (match_operand:SF 1 "move_operand" "d,d,y,m,d"))]
3719 && (register_operand (operands[0], SFmode)
3720 || register_operand (operands[1], SFmode))"
3721 { return mips_output_move (operands[0], operands[1]); }
3722 [(set_attr "type" "arith,arith,arith,load,store")
3723 (set_attr "mode" "SF")
3724 (set_attr "length" "4,4,4,*,*")])
3727 ;; 64-bit floating point moves
3729 (define_expand "movdf"
3730 [(set (match_operand:DF 0 "")
3731 (match_operand:DF 1 ""))]
3734 if (mips_legitimize_move (DFmode, operands[0], operands[1]))
3738 (define_insn "*movdf_hardfloat_64bit"
3739 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m")
3740 (match_operand:DF 1 "move_operand" "f,G,m,f,G,*d,*f,*d*G,*m,*d"))]
3741 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_64BIT
3742 && (register_operand (operands[0], DFmode)
3743 || reg_or_0_operand (operands[1], DFmode))"
3744 { return mips_output_move (operands[0], operands[1]); }
3745 [(set_attr "type" "fmove,xfer,fpload,fpstore,store,xfer,xfer,arith,load,store")
3746 (set_attr "mode" "DF")
3747 (set_attr "length" "4,4,*,*,*,4,4,4,*,*")])
3749 (define_insn "*movdf_hardfloat_32bit"
3750 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m")
3751 (match_operand:DF 1 "move_operand" "f,G,m,f,G,*d,*f,*d*G,*m,*d"))]
3752 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT
3753 && (register_operand (operands[0], DFmode)
3754 || reg_or_0_operand (operands[1], DFmode))"
3755 { return mips_output_move (operands[0], operands[1]); }
3756 [(set_attr "type" "fmove,xfer,fpload,fpstore,store,xfer,xfer,arith,load,store")
3757 (set_attr "mode" "DF")
3758 (set_attr "length" "4,8,*,*,*,8,8,8,*,*")])
3760 (define_insn "*movdf_softfloat"
3761 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,m,d,f,f")
3762 (match_operand:DF 1 "move_operand" "dG,m,dG,f,d,f"))]
3763 "(TARGET_SOFT_FLOAT || TARGET_SINGLE_FLOAT) && !TARGET_MIPS16
3764 && (register_operand (operands[0], DFmode)
3765 || reg_or_0_operand (operands[1], DFmode))"
3766 { return mips_output_move (operands[0], operands[1]); }
3767 [(set_attr "type" "arith,load,store,xfer,xfer,fmove")
3768 (set_attr "mode" "DF")
3769 (set_attr "length" "8,*,*,4,4,4")])
3771 (define_insn "*movdf_mips16"
3772 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,y,d,d,m")
3773 (match_operand:DF 1 "move_operand" "d,d,y,m,d"))]
3775 && (register_operand (operands[0], DFmode)
3776 || register_operand (operands[1], DFmode))"
3777 { return mips_output_move (operands[0], operands[1]); }
3778 [(set_attr "type" "arith,arith,arith,load,store")
3779 (set_attr "mode" "DF")
3780 (set_attr "length" "8,8,8,*,*")])
3783 [(set (match_operand:DI 0 "nonimmediate_operand")
3784 (match_operand:DI 1 "move_operand"))]
3785 "reload_completed && !TARGET_64BIT
3786 && mips_split_64bit_move_p (operands[0], operands[1])"
3789 mips_split_64bit_move (operands[0], operands[1]);
3794 [(set (match_operand:DF 0 "nonimmediate_operand")
3795 (match_operand:DF 1 "move_operand"))]
3796 "reload_completed && !TARGET_64BIT
3797 && mips_split_64bit_move_p (operands[0], operands[1])"
3800 mips_split_64bit_move (operands[0], operands[1]);
3804 ;; When generating mips16 code, split moves of negative constants into
3805 ;; a positive "li" followed by a negation.
3807 [(set (match_operand 0 "register_operand")
3808 (match_operand 1 "const_int_operand"))]
3809 "TARGET_MIPS16 && reload_completed && INTVAL (operands[1]) < 0"
3813 (neg:SI (match_dup 2)))]
3815 operands[2] = gen_lowpart (SImode, operands[0]);
3816 operands[3] = GEN_INT (-INTVAL (operands[1]));
3819 ;; 64-bit paired-single floating point moves
3821 (define_expand "movv2sf"
3822 [(set (match_operand:V2SF 0)
3823 (match_operand:V2SF 1))]
3824 "TARGET_PAIRED_SINGLE_FLOAT"
3826 if (mips_legitimize_move (V2SFmode, operands[0], operands[1]))
3830 (define_insn "movv2sf_hardfloat_64bit"
3831 [(set (match_operand:V2SF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m")
3832 (match_operand:V2SF 1 "move_operand" "f,YG,m,f,YG,*d,*f,*d*YG,*m,*d"))]
3833 "TARGET_PAIRED_SINGLE_FLOAT
3835 && (register_operand (operands[0], V2SFmode)
3836 || reg_or_0_operand (operands[1], V2SFmode))"
3837 { return mips_output_move (operands[0], operands[1]); }
3838 [(set_attr "type" "fmove,xfer,fpload,fpstore,store,xfer,xfer,arith,load,store")
3839 (set_attr "mode" "SF")
3840 (set_attr "length" "4,4,*,*,*,4,4,4,*,*")])
3842 ;; The HI and LO registers are not truly independent. If we move an mthi
3843 ;; instruction before an mflo instruction, it will make the result of the
3844 ;; mflo unpredictable. The same goes for mtlo and mfhi.
3846 ;; We cope with this by making the mflo and mfhi patterns use both HI and LO.
3847 ;; Operand 1 is the register we want, operand 2 is the other one.
3849 ;; When generating VR4120 or VR4130 code, we use macc{,hi} and
3850 ;; dmacc{,hi} instead of mfhi and mflo. This avoids both the normal
3851 ;; MIPS III hi/lo hazards and the errata related to -mfix-vr4130.
3853 (define_expand "mfhilo_<mode>"
3854 [(set (match_operand:GPR 0 "register_operand")
3855 (unspec:GPR [(match_operand:GPR 1 "register_operand")
3856 (match_operand:GPR 2 "register_operand")]
3859 (define_insn "*mfhilo_<mode>"
3860 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3861 (unspec:GPR [(match_operand:GPR 1 "register_operand" "h,l")
3862 (match_operand:GPR 2 "register_operand" "l,h")]
3866 [(set_attr "type" "mfhilo")
3867 (set_attr "mode" "<MODE>")])
3869 (define_insn "*mfhilo_<mode>_macc"
3870 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3871 (unspec:GPR [(match_operand:GPR 1 "register_operand" "h,l")
3872 (match_operand:GPR 2 "register_operand" "l,h")]
3876 if (REGNO (operands[1]) == HI_REGNUM)
3877 return "<d>macchi\t%0,%.,%.";
3879 return "<d>macc\t%0,%.,%.";
3881 [(set_attr "type" "mfhilo")
3882 (set_attr "mode" "<MODE>")])
3884 ;; Patterns for loading or storing part of a paired floating point
3885 ;; register. We need them because odd-numbered floating-point registers
3886 ;; are not fully independent: see mips_split_64bit_move.
3888 ;; Load the low word of operand 0 with operand 1.
3889 (define_insn "load_df_low"
3890 [(set (match_operand:DF 0 "register_operand" "=f,f")
3891 (unspec:DF [(match_operand:SI 1 "general_operand" "dJ,m")]
3892 UNSPEC_LOAD_DF_LOW))]
3893 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT"
3895 operands[0] = mips_subword (operands[0], 0);
3896 return mips_output_move (operands[0], operands[1]);
3898 [(set_attr "type" "xfer,fpload")
3899 (set_attr "mode" "SF")])
3901 ;; Load the high word of operand 0 from operand 1, preserving the value
3903 (define_insn "load_df_high"
3904 [(set (match_operand:DF 0 "register_operand" "=f,f")
3905 (unspec:DF [(match_operand:SI 1 "general_operand" "dJ,m")
3906 (match_operand:DF 2 "register_operand" "0,0")]
3907 UNSPEC_LOAD_DF_HIGH))]
3908 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT"
3910 operands[0] = mips_subword (operands[0], 1);
3911 return mips_output_move (operands[0], operands[1]);
3913 [(set_attr "type" "xfer,fpload")
3914 (set_attr "mode" "SF")])
3916 ;; Store the high word of operand 1 in operand 0. The corresponding
3917 ;; low-word move is done in the normal way.
3918 (define_insn "store_df_high"
3919 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,m")
3920 (unspec:SI [(match_operand:DF 1 "register_operand" "f,f")]
3921 UNSPEC_STORE_DF_HIGH))]
3922 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT"
3924 operands[1] = mips_subword (operands[1], 1);
3925 return mips_output_move (operands[0], operands[1]);
3927 [(set_attr "type" "xfer,fpstore")
3928 (set_attr "mode" "SF")])
3930 ;; Insn to initialize $gp for n32/n64 abicalls. Operand 0 is the offset
3931 ;; of _gp from the start of this function. Operand 1 is the incoming
3932 ;; function address.
3933 (define_insn_and_split "loadgp"
3934 [(unspec_volatile [(match_operand 0 "" "")
3935 (match_operand 1 "register_operand" "")] UNSPEC_LOADGP)]
3936 "TARGET_ABICALLS && TARGET_NEWABI"
3939 [(set (match_dup 2) (match_dup 3))
3940 (set (match_dup 2) (match_dup 4))
3941 (set (match_dup 2) (match_dup 5))]
3943 operands[2] = pic_offset_table_rtx;
3944 operands[3] = gen_rtx_HIGH (Pmode, operands[0]);
3945 operands[4] = gen_rtx_PLUS (Pmode, operands[2], operands[1]);
3946 operands[5] = gen_rtx_LO_SUM (Pmode, operands[2], operands[0]);
3948 [(set_attr "length" "12")])
3950 ;; This blockage instruction prevents the gp load from being
3951 ;; scheduled after an implicit use of gp. It also prevents
3952 ;; the load from being deleted as dead.
3953 (define_insn "loadgp_blockage"
3954 [(unspec_volatile [(reg:SI 28)] UNSPEC_BLOCKAGE)]
3957 [(set_attr "type" "unknown")
3958 (set_attr "mode" "none")
3959 (set_attr "length" "0")])
3961 ;; Emit a .cprestore directive, which normally expands to a single store
3962 ;; instruction. Note that we continue to use .cprestore for explicit reloc
3963 ;; code so that jals inside inline asms will work correctly.
3964 (define_insn "cprestore"
3965 [(unspec_volatile [(match_operand 0 "const_int_operand" "I,i")]
3969 if (set_nomacro && which_alternative == 1)
3970 return ".set\tmacro\;.cprestore\t%0\;.set\tnomacro";
3972 return ".cprestore\t%0";
3974 [(set_attr "type" "store")
3975 (set_attr "length" "4,12")])
3977 ;; Block moves, see mips.c for more details.
3978 ;; Argument 0 is the destination
3979 ;; Argument 1 is the source
3980 ;; Argument 2 is the length
3981 ;; Argument 3 is the alignment
3983 (define_expand "movmemsi"
3984 [(parallel [(set (match_operand:BLK 0 "general_operand")
3985 (match_operand:BLK 1 "general_operand"))
3986 (use (match_operand:SI 2 ""))
3987 (use (match_operand:SI 3 "const_int_operand"))])]
3988 "!TARGET_MIPS16 && !TARGET_MEMCPY"
3990 if (mips_expand_block_move (operands[0], operands[1], operands[2]))
3997 ;; ....................
4001 ;; ....................
4003 (define_expand "<optab><mode>3"
4004 [(set (match_operand:GPR 0 "register_operand")
4005 (any_shift:GPR (match_operand:GPR 1 "register_operand")
4006 (match_operand:SI 2 "arith_operand")))]
4009 /* On the mips16, a shift of more than 8 is a four byte instruction,
4010 so, for a shift between 8 and 16, it is just as fast to do two
4011 shifts of 8 or less. If there is a lot of shifting going on, we
4012 may win in CSE. Otherwise combine will put the shifts back
4013 together again. This can be called by function_arg, so we must
4014 be careful not to allocate a new register if we've reached the
4018 && GET_CODE (operands[2]) == CONST_INT
4019 && INTVAL (operands[2]) > 8
4020 && INTVAL (operands[2]) <= 16
4021 && !reload_in_progress
4022 && !reload_completed)
4024 rtx temp = gen_reg_rtx (<MODE>mode);
4026 emit_insn (gen_<optab><mode>3 (temp, operands[1], GEN_INT (8)));
4027 emit_insn (gen_<optab><mode>3 (operands[0], temp,
4028 GEN_INT (INTVAL (operands[2]) - 8)));
4033 (define_insn "*<optab><mode>3"
4034 [(set (match_operand:GPR 0 "register_operand" "=d")
4035 (any_shift:GPR (match_operand:GPR 1 "register_operand" "d")
4036 (match_operand:SI 2 "arith_operand" "dI")))]
4039 if (GET_CODE (operands[2]) == CONST_INT)
4040 operands[2] = GEN_INT (INTVAL (operands[2])
4041 & (GET_MODE_BITSIZE (<MODE>mode) - 1));
4043 return "<d><insn>\t%0,%1,%2";
4045 [(set_attr "type" "shift")
4046 (set_attr "mode" "<MODE>")])
4048 (define_insn "*<optab>si3_extend"
4049 [(set (match_operand:DI 0 "register_operand" "=d")
4051 (any_shift:SI (match_operand:SI 1 "register_operand" "d")
4052 (match_operand:SI 2 "arith_operand" "dI"))))]
4053 "TARGET_64BIT && !TARGET_MIPS16"
4055 if (GET_CODE (operands[2]) == CONST_INT)
4056 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
4058 return "<insn>\t%0,%1,%2";
4060 [(set_attr "type" "shift")
4061 (set_attr "mode" "SI")])
4063 (define_insn "*<optab>si3_mips16"
4064 [(set (match_operand:SI 0 "register_operand" "=d,d")
4065 (any_shift:SI (match_operand:SI 1 "register_operand" "0,d")
4066 (match_operand:SI 2 "arith_operand" "d,I")))]
4069 if (which_alternative == 0)
4070 return "<insn>\t%0,%2";
4072 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
4073 return "<insn>\t%0,%1,%2";
4075 [(set_attr "type" "shift")
4076 (set_attr "mode" "SI")
4077 (set_attr_alternative "length"
4079 (if_then_else (match_operand 2 "m16_uimm3_b")
4083 ;; We need separate DImode MIPS16 patterns because of the irregularity
4085 (define_insn "*ashldi3_mips16"
4086 [(set (match_operand:DI 0 "register_operand" "=d,d")
4087 (ashift:DI (match_operand:DI 1 "register_operand" "0,d")
4088 (match_operand:SI 2 "arith_operand" "d,I")))]
4089 "TARGET_64BIT && TARGET_MIPS16"
4091 if (which_alternative == 0)
4092 return "dsll\t%0,%2";
4094 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
4095 return "dsll\t%0,%1,%2";
4097 [(set_attr "type" "shift")
4098 (set_attr "mode" "DI")
4099 (set_attr_alternative "length"
4101 (if_then_else (match_operand 2 "m16_uimm3_b")
4105 (define_insn "*ashrdi3_mips16"
4106 [(set (match_operand:DI 0 "register_operand" "=d,d")
4107 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0,0")
4108 (match_operand:SI 2 "arith_operand" "d,I")))]
4109 "TARGET_64BIT && TARGET_MIPS16"
4111 if (GET_CODE (operands[2]) == CONST_INT)
4112 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
4114 return "dsra\t%0,%2";
4116 [(set_attr "type" "shift")
4117 (set_attr "mode" "DI")
4118 (set_attr_alternative "length"
4120 (if_then_else (match_operand 2 "m16_uimm3_b")
4124 (define_insn "*lshrdi3_mips16"
4125 [(set (match_operand:DI 0 "register_operand" "=d,d")
4126 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0,0")
4127 (match_operand:SI 2 "arith_operand" "d,I")))]
4128 "TARGET_64BIT && TARGET_MIPS16"
4130 if (GET_CODE (operands[2]) == CONST_INT)
4131 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
4133 return "dsrl\t%0,%2";
4135 [(set_attr "type" "shift")
4136 (set_attr "mode" "DI")
4137 (set_attr_alternative "length"
4139 (if_then_else (match_operand 2 "m16_uimm3_b")
4143 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
4146 [(set (match_operand:GPR 0 "register_operand")
4147 (any_shift:GPR (match_operand:GPR 1 "register_operand")
4148 (match_operand:GPR 2 "const_int_operand")))]
4149 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
4150 && GET_CODE (operands[2]) == CONST_INT
4151 && INTVAL (operands[2]) > 8
4152 && INTVAL (operands[2]) <= 16"
4153 [(set (match_dup 0) (any_shift:GPR (match_dup 1) (const_int 8)))
4154 (set (match_dup 0) (any_shift:GPR (match_dup 0) (match_dup 2)))]
4155 { operands[2] = GEN_INT (INTVAL (operands[2]) - 8); })
4157 ;; If we load a byte on the mips16 as a bitfield, the resulting
4158 ;; sequence of instructions is too complicated for combine, because it
4159 ;; involves four instructions: a load, a shift, a constant load into a
4160 ;; register, and an and (the key problem here is that the mips16 does
4161 ;; not have and immediate). We recognize a shift of a load in order
4162 ;; to make it simple enough for combine to understand.
4164 ;; The length here is the worst case: the length of the split version
4165 ;; will be more accurate.
4166 (define_insn_and_split ""
4167 [(set (match_operand:SI 0 "register_operand" "=d")
4168 (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
4169 (match_operand:SI 2 "immediate_operand" "I")))]
4173 [(set (match_dup 0) (match_dup 1))
4174 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
4176 [(set_attr "type" "load")
4177 (set_attr "mode" "SI")
4178 (set_attr "length" "16")])
4180 (define_insn "rotr<mode>3"
4181 [(set (match_operand:GPR 0 "register_operand" "=d")
4182 (rotatert:GPR (match_operand:GPR 1 "register_operand" "d")
4183 (match_operand:SI 2 "arith_operand" "dI")))]
4184 "ISA_HAS_ROTR_<MODE>"
4186 if (GET_CODE (operands[2]) == CONST_INT)
4187 gcc_assert (INTVAL (operands[2]) >= 0
4188 && INTVAL (operands[2]) < GET_MODE_BITSIZE (<MODE>mode));
4190 return "<d>ror\t%0,%1,%2";
4192 [(set_attr "type" "shift")
4193 (set_attr "mode" "<MODE>")])
4196 ;; ....................
4200 ;; ....................
4202 ;; Flow here is rather complex:
4204 ;; 1) The cmp{si,di,sf,df} routine is called. It deposits the arguments
4205 ;; into cmp_operands[] but generates no RTL.
4207 ;; 2) The appropriate branch define_expand is called, which then
4208 ;; creates the appropriate RTL for the comparison and branch.
4209 ;; Different CC modes are used, based on what type of branch is
4210 ;; done, so that we can constrain things appropriately. There
4211 ;; are assumptions in the rest of GCC that break if we fold the
4212 ;; operands into the branches for integer operations, and use cc0
4213 ;; for floating point, so we use the fp status register instead.
4214 ;; If needed, an appropriate temporary is created to hold the
4215 ;; of the integer compare.
4217 (define_expand "cmp<mode>"
4219 (compare:CC (match_operand:GPR 0 "register_operand")
4220 (match_operand:GPR 1 "nonmemory_operand")))]
4223 cmp_operands[0] = operands[0];
4224 cmp_operands[1] = operands[1];
4228 (define_expand "cmp<mode>"
4230 (compare:CC (match_operand:SCALARF 0 "register_operand")
4231 (match_operand:SCALARF 1 "register_operand")))]
4234 cmp_operands[0] = operands[0];
4235 cmp_operands[1] = operands[1];
4240 ;; ....................
4242 ;; CONDITIONAL BRANCHES
4244 ;; ....................
4246 ;; Conditional branches on floating-point equality tests.
4248 (define_insn "branch_fp"
4251 (match_operator:CC 0 "comparison_operator"
4252 [(match_operand:CC 2 "register_operand" "z")
4254 (label_ref (match_operand 1 "" ""))
4258 return mips_output_conditional_branch (insn,
4260 /*two_operands_p=*/0,
4263 get_attr_length (insn));
4265 [(set_attr "type" "branch")
4266 (set_attr "mode" "none")])
4268 (define_insn "branch_fp_inverted"
4271 (match_operator:CC 0 "comparison_operator"
4272 [(match_operand:CC 2 "register_operand" "z")
4275 (label_ref (match_operand 1 "" ""))))]
4278 return mips_output_conditional_branch (insn,
4280 /*two_operands_p=*/0,
4283 get_attr_length (insn));
4285 [(set_attr "type" "branch")
4286 (set_attr "mode" "none")])
4288 ;; Conditional branches on comparisons with zero.
4290 (define_insn "*branch_zero<mode>"
4293 (match_operator:GPR 0 "comparison_operator"
4294 [(match_operand:GPR 2 "register_operand" "d")
4296 (label_ref (match_operand 1 "" ""))
4300 return mips_output_conditional_branch (insn,
4302 /*two_operands_p=*/0,
4305 get_attr_length (insn));
4307 [(set_attr "type" "branch")
4308 (set_attr "mode" "none")])
4310 (define_insn "*branch_zero<mode>_inverted"
4313 (match_operator:GPR 0 "comparison_operator"
4314 [(match_operand:GPR 2 "register_operand" "d")
4317 (label_ref (match_operand 1 "" ""))))]
4320 return mips_output_conditional_branch (insn,
4322 /*two_operands_p=*/0,
4325 get_attr_length (insn));
4327 [(set_attr "type" "branch")
4328 (set_attr "mode" "none")])
4330 ;; Conditional branch on equality comparison.
4332 (define_insn "*branch_equality<mode>"
4335 (match_operator:GPR 0 "equality_operator"
4336 [(match_operand:GPR 2 "register_operand" "d")
4337 (match_operand:GPR 3 "register_operand" "d")])
4338 (label_ref (match_operand 1 "" ""))
4342 return mips_output_conditional_branch (insn,
4344 /*two_operands_p=*/1,
4347 get_attr_length (insn));
4349 [(set_attr "type" "branch")
4350 (set_attr "mode" "none")])
4352 (define_insn "*branch_equality<mode>_inverted"
4355 (match_operator:GPR 0 "equality_operator"
4356 [(match_operand:GPR 2 "register_operand" "d")
4357 (match_operand:GPR 3 "register_operand" "d")])
4359 (label_ref (match_operand 1 "" ""))))]
4362 return mips_output_conditional_branch (insn,
4364 /*two_operands_p=*/1,
4367 get_attr_length (insn));
4369 [(set_attr "type" "branch")
4370 (set_attr "mode" "none")])
4374 (define_insn "*branch_equality<mode>_mips16"
4377 (match_operator:GPR 0 "equality_operator"
4378 [(match_operand:GPR 1 "register_operand" "d,t")
4380 (match_operand 2 "pc_or_label_operand" "")
4381 (match_operand 3 "pc_or_label_operand" "")))]
4384 if (operands[2] != pc_rtx)
4386 if (which_alternative == 0)
4387 return "b%C0z\t%1,%2";
4389 return "bt%C0z\t%2";
4393 if (which_alternative == 0)
4394 return "b%N0z\t%1,%3";
4396 return "bt%N0z\t%3";
4399 [(set_attr "type" "branch")
4400 (set_attr "mode" "none")
4401 (set_attr "length" "8")])
4403 (define_expand "b<code>"
4405 (if_then_else (any_cond:CC (cc0)
4407 (label_ref (match_operand 0 ""))
4411 gen_conditional_branch (operands, <CODE>);
4416 ;; ....................
4418 ;; SETTING A REGISTER FROM A COMPARISON
4420 ;; ....................
4422 (define_expand "seq"
4423 [(set (match_operand:SI 0 "register_operand")
4424 (eq:SI (match_dup 1)
4427 { if (mips_emit_scc (EQ, operands[0])) DONE; else FAIL; })
4429 (define_insn "*seq_<mode>"
4430 [(set (match_operand:GPR 0 "register_operand" "=d")
4431 (eq:GPR (match_operand:GPR 1 "register_operand" "d")
4435 [(set_attr "type" "slt")
4436 (set_attr "mode" "<MODE>")])
4438 (define_insn "*seq_<mode>_mips16"
4439 [(set (match_operand:GPR 0 "register_operand" "=t")
4440 (eq:GPR (match_operand:GPR 1 "register_operand" "d")
4444 [(set_attr "type" "slt")
4445 (set_attr "mode" "<MODE>")])
4447 ;; "sne" uses sltu instructions in which the first operand is $0.
4448 ;; This isn't possible in mips16 code.
4450 (define_expand "sne"
4451 [(set (match_operand:SI 0 "register_operand")
4452 (ne:SI (match_dup 1)
4455 { if (mips_emit_scc (NE, operands[0])) DONE; else FAIL; })
4457 (define_insn "*sne_<mode>"
4458 [(set (match_operand:GPR 0 "register_operand" "=d")
4459 (ne:GPR (match_operand:GPR 1 "register_operand" "d")
4463 [(set_attr "type" "slt")
4464 (set_attr "mode" "<MODE>")])
4466 (define_expand "sgt"
4467 [(set (match_operand:SI 0 "register_operand")
4468 (gt:SI (match_dup 1)
4471 { if (mips_emit_scc (GT, operands[0])) DONE; else FAIL; })
4473 (define_insn "*sgt_<mode>"
4474 [(set (match_operand:GPR 0 "register_operand" "=d")
4475 (gt:GPR (match_operand:GPR 1 "register_operand" "d")
4476 (match_operand:GPR 2 "reg_or_0_operand" "dJ")))]
4479 [(set_attr "type" "slt")
4480 (set_attr "mode" "<MODE>")])
4482 (define_insn "*sgt_<mode>_mips16"
4483 [(set (match_operand:GPR 0 "register_operand" "=t")
4484 (gt:GPR (match_operand:GPR 1 "register_operand" "d")
4485 (match_operand:GPR 2 "register_operand" "d")))]
4488 [(set_attr "type" "slt")
4489 (set_attr "mode" "<MODE>")])
4491 (define_expand "sge"
4492 [(set (match_operand:SI 0 "register_operand")
4493 (ge:SI (match_dup 1)
4496 { if (mips_emit_scc (GE, operands[0])) DONE; else FAIL; })
4498 (define_insn "*sge_<mode>"
4499 [(set (match_operand:GPR 0 "register_operand" "=d")
4500 (ge:GPR (match_operand:GPR 1 "register_operand" "d")
4504 [(set_attr "type" "slt")
4505 (set_attr "mode" "<MODE>")])
4507 (define_expand "slt"
4508 [(set (match_operand:SI 0 "register_operand")
4509 (lt:SI (match_dup 1)
4512 { if (mips_emit_scc (LT, operands[0])) DONE; else FAIL; })
4514 (define_insn "*slt_<mode>"
4515 [(set (match_operand:GPR 0 "register_operand" "=d")
4516 (lt:GPR (match_operand:GPR 1 "register_operand" "d")
4517 (match_operand:GPR 2 "arith_operand" "dI")))]
4520 [(set_attr "type" "slt")
4521 (set_attr "mode" "<MODE>")])
4523 (define_insn "*slt_<mode>_mips16"
4524 [(set (match_operand:GPR 0 "register_operand" "=t,t")
4525 (lt:GPR (match_operand:GPR 1 "register_operand" "d,d")
4526 (match_operand:GPR 2 "arith_operand" "d,I")))]
4529 [(set_attr "type" "slt")
4530 (set_attr "mode" "<MODE>")
4531 (set_attr_alternative "length"
4533 (if_then_else (match_operand 2 "m16_uimm8_1")
4537 (define_expand "sle"
4538 [(set (match_operand:SI 0 "register_operand")
4539 (le:SI (match_dup 1)
4542 { if (mips_emit_scc (LE, operands[0])) DONE; else FAIL; })
4544 (define_insn "*sle_<mode>"
4545 [(set (match_operand:GPR 0 "register_operand" "=d")
4546 (le:GPR (match_operand:GPR 1 "register_operand" "d")
4547 (match_operand:GPR 2 "sle_operand" "")))]
4550 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
4551 return "slt\t%0,%1,%2";
4553 [(set_attr "type" "slt")
4554 (set_attr "mode" "<MODE>")])
4556 (define_insn "*sle_<mode>_mips16"
4557 [(set (match_operand:GPR 0 "register_operand" "=t")
4558 (le:GPR (match_operand:GPR 1 "register_operand" "d")
4559 (match_operand:GPR 2 "sle_operand" "")))]
4562 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
4563 return "slt\t%1,%2";
4565 [(set_attr "type" "slt")
4566 (set_attr "mode" "<MODE>")
4567 (set (attr "length") (if_then_else (match_operand 2 "m16_uimm8_m1_1")
4571 (define_expand "sgtu"
4572 [(set (match_operand:SI 0 "register_operand")
4573 (gtu:SI (match_dup 1)
4576 { if (mips_emit_scc (GTU, operands[0])) DONE; else FAIL; })
4578 (define_insn "*sgtu_<mode>"
4579 [(set (match_operand:GPR 0 "register_operand" "=d")
4580 (gtu:GPR (match_operand:GPR 1 "register_operand" "d")
4581 (match_operand:GPR 2 "reg_or_0_operand" "dJ")))]
4584 [(set_attr "type" "slt")
4585 (set_attr "mode" "<MODE>")])
4587 (define_insn "*sgtu_<mode>_mips16"
4588 [(set (match_operand:GPR 0 "register_operand" "=t")
4589 (gtu:GPR (match_operand:GPR 1 "register_operand" "d")
4590 (match_operand:GPR 2 "register_operand" "d")))]
4593 [(set_attr "type" "slt")
4594 (set_attr "mode" "<MODE>")])
4596 (define_expand "sgeu"
4597 [(set (match_operand:SI 0 "register_operand")
4598 (geu:SI (match_dup 1)
4601 { if (mips_emit_scc (GEU, operands[0])) DONE; else FAIL; })
4603 (define_insn "*sge_<mode>"
4604 [(set (match_operand:GPR 0 "register_operand" "=d")
4605 (geu:GPR (match_operand:GPR 1 "register_operand" "d")
4609 [(set_attr "type" "slt")
4610 (set_attr "mode" "<MODE>")])
4612 (define_expand "sltu"
4613 [(set (match_operand:SI 0 "register_operand")
4614 (ltu:SI (match_dup 1)
4617 { if (mips_emit_scc (LTU, operands[0])) DONE; else FAIL; })
4619 (define_insn "*sltu_<mode>"
4620 [(set (match_operand:GPR 0 "register_operand" "=d")
4621 (ltu:GPR (match_operand:GPR 1 "register_operand" "d")
4622 (match_operand:GPR 2 "arith_operand" "dI")))]
4625 [(set_attr "type" "slt")
4626 (set_attr "mode" "<MODE>")])
4628 (define_insn "*sltu_<mode>_mips16"
4629 [(set (match_operand:GPR 0 "register_operand" "=t,t")
4630 (ltu:GPR (match_operand:GPR 1 "register_operand" "d,d")
4631 (match_operand:GPR 2 "arith_operand" "d,I")))]
4634 [(set_attr "type" "slt")
4635 (set_attr "mode" "<MODE>")
4636 (set_attr_alternative "length"
4638 (if_then_else (match_operand 2 "m16_uimm8_1")
4642 (define_expand "sleu"
4643 [(set (match_operand:SI 0 "register_operand")
4644 (leu:SI (match_dup 1)
4647 { if (mips_emit_scc (LEU, operands[0])) DONE; else FAIL; })
4649 (define_insn "*sleu_<mode>"
4650 [(set (match_operand:GPR 0 "register_operand" "=d")
4651 (leu:GPR (match_operand:GPR 1 "register_operand" "d")
4652 (match_operand:GPR 2 "sleu_operand" "")))]
4655 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
4656 return "sltu\t%0,%1,%2";
4658 [(set_attr "type" "slt")
4659 (set_attr "mode" "<MODE>")])
4661 (define_insn "*sleu_<mode>_mips16"
4662 [(set (match_operand:GPR 0 "register_operand" "=t")
4663 (leu:GPR (match_operand:GPR 1 "register_operand" "d")
4664 (match_operand:GPR 2 "sleu_operand" "")))]
4667 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
4668 return "sltu\t%1,%2";
4670 [(set_attr "type" "slt")
4671 (set_attr "mode" "<MODE>")
4672 (set (attr "length") (if_then_else (match_operand 2 "m16_uimm8_m1_1")
4677 ;; ....................
4679 ;; FLOATING POINT COMPARISONS
4681 ;; ....................
4683 (define_insn "s<code>_<mode>"
4684 [(set (match_operand:CC 0 "register_operand" "=z")
4685 (fcond:CC (match_operand:SCALARF 1 "register_operand" "f")
4686 (match_operand:SCALARF 2 "register_operand" "f")))]
4688 "c.<fcond>.<fmt>\t%Z0%1,%2"
4689 [(set_attr "type" "fcmp")
4690 (set_attr "mode" "FPSW")])
4692 (define_insn "s<code>_<mode>"
4693 [(set (match_operand:CC 0 "register_operand" "=z")
4694 (swapped_fcond:CC (match_operand:SCALARF 1 "register_operand" "f")
4695 (match_operand:SCALARF 2 "register_operand" "f")))]
4697 "c.<swapped_fcond>.<fmt>\t%Z0%2,%1"
4698 [(set_attr "type" "fcmp")
4699 (set_attr "mode" "FPSW")])
4702 ;; ....................
4704 ;; UNCONDITIONAL BRANCHES
4706 ;; ....................
4708 ;; Unconditional branches.
4712 (label_ref (match_operand 0 "" "")))]
4717 if (get_attr_length (insn) <= 8)
4718 return "%*b\t%l0%/";
4721 output_asm_insn (mips_output_load_label (), operands);
4722 return "%*jr\t%@%/%]";
4726 return "%*j\t%l0%/";
4728 [(set_attr "type" "jump")
4729 (set_attr "mode" "none")
4730 (set (attr "length")
4731 ;; We can't use `j' when emitting PIC. Emit a branch if it's
4732 ;; in range, otherwise load the address of the branch target into
4733 ;; $at and then jump to it.
4735 (ior (eq (symbol_ref "flag_pic") (const_int 0))
4736 (lt (abs (minus (match_dup 0)
4737 (plus (pc) (const_int 4))))
4738 (const_int 131072)))
4739 (const_int 4) (const_int 16)))])
4741 ;; We need a different insn for the mips16, because a mips16 branch
4742 ;; does not have a delay slot.
4746 (label_ref (match_operand 0 "" "")))]
4749 [(set_attr "type" "branch")
4750 (set_attr "mode" "none")
4751 (set_attr "length" "8")])
4753 (define_expand "indirect_jump"
4754 [(set (pc) (match_operand 0 "register_operand"))]
4757 operands[0] = force_reg (Pmode, operands[0]);
4758 if (Pmode == SImode)
4759 emit_jump_insn (gen_indirect_jumpsi (operands[0]));
4761 emit_jump_insn (gen_indirect_jumpdi (operands[0]));
4765 (define_insn "indirect_jump<mode>"
4766 [(set (pc) (match_operand:P 0 "register_operand" "d"))]
4769 [(set_attr "type" "jump")
4770 (set_attr "mode" "none")])
4772 (define_expand "tablejump"
4774 (match_operand 0 "register_operand"))
4775 (use (label_ref (match_operand 1 "")))]
4779 operands[0] = expand_binop (Pmode, add_optab,
4780 convert_to_mode (Pmode, operands[0], false),
4781 gen_rtx_LABEL_REF (Pmode, operands[1]),
4783 else if (TARGET_GPWORD)
4784 operands[0] = expand_binop (Pmode, add_optab, operands[0],
4785 pic_offset_table_rtx, 0, 0, OPTAB_WIDEN);
4787 if (Pmode == SImode)
4788 emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
4790 emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
4794 (define_insn "tablejump<mode>"
4796 (match_operand:P 0 "register_operand" "d"))
4797 (use (label_ref (match_operand 1 "" "")))]
4800 [(set_attr "type" "jump")
4801 (set_attr "mode" "none")])
4803 ;; For TARGET_ABICALLS, we save the gp in the jmp_buf as well.
4804 ;; While it is possible to either pull it off the stack (in the
4805 ;; o32 case) or recalculate it given t9 and our target label,
4806 ;; it takes 3 or 4 insns to do so.
4808 (define_expand "builtin_setjmp_setup"
4809 [(use (match_operand 0 "register_operand"))]
4814 addr = plus_constant (operands[0], GET_MODE_SIZE (Pmode) * 3);
4815 emit_move_insn (gen_rtx_MEM (Pmode, addr), pic_offset_table_rtx);
4819 ;; Restore the gp that we saved above. Despite the earlier comment, it seems
4820 ;; that older code did recalculate the gp from $25. Continue to jump through
4821 ;; $25 for compatibility (we lose nothing by doing so).
4823 (define_expand "builtin_longjmp"
4824 [(use (match_operand 0 "register_operand"))]
4827 /* The elements of the buffer are, in order: */
4828 int W = GET_MODE_SIZE (Pmode);
4829 rtx fp = gen_rtx_MEM (Pmode, operands[0]);
4830 rtx lab = gen_rtx_MEM (Pmode, plus_constant (operands[0], 1*W));
4831 rtx stack = gen_rtx_MEM (Pmode, plus_constant (operands[0], 2*W));
4832 rtx gpv = gen_rtx_MEM (Pmode, plus_constant (operands[0], 3*W));
4833 rtx pv = gen_rtx_REG (Pmode, PIC_FUNCTION_ADDR_REGNUM);
4834 /* Use gen_raw_REG to avoid being given pic_offset_table_rtx.
4835 The target is bound to be using $28 as the global pointer
4836 but the current function might not be. */
4837 rtx gp = gen_raw_REG (Pmode, GLOBAL_POINTER_REGNUM);
4839 /* This bit is similar to expand_builtin_longjmp except that it
4840 restores $gp as well. */
4841 emit_move_insn (hard_frame_pointer_rtx, fp);
4842 emit_move_insn (pv, lab);
4843 emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
4844 emit_move_insn (gp, gpv);
4845 emit_insn (gen_rtx_USE (VOIDmode, hard_frame_pointer_rtx));
4846 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
4847 emit_insn (gen_rtx_USE (VOIDmode, gp));
4848 emit_indirect_jump (pv);
4853 ;; ....................
4855 ;; Function prologue/epilogue
4857 ;; ....................
4860 (define_expand "prologue"
4864 mips_expand_prologue ();
4868 ;; Block any insns from being moved before this point, since the
4869 ;; profiling call to mcount can use various registers that aren't
4870 ;; saved or used to pass arguments.
4872 (define_insn "blockage"
4873 [(unspec_volatile [(const_int 0)] UNSPEC_BLOCKAGE)]
4876 [(set_attr "type" "unknown")
4877 (set_attr "mode" "none")
4878 (set_attr "length" "0")])
4880 (define_expand "epilogue"
4884 mips_expand_epilogue (false);
4888 (define_expand "sibcall_epilogue"
4892 mips_expand_epilogue (true);
4896 ;; Trivial return. Make it look like a normal return insn as that
4897 ;; allows jump optimizations to work better.
4899 (define_insn "return"
4901 "mips_can_use_return_insn ()"
4903 [(set_attr "type" "jump")
4904 (set_attr "mode" "none")])
4908 (define_insn "return_internal"
4910 (use (match_operand 0 "pmode_register_operand" ""))]
4913 [(set_attr "type" "jump")
4914 (set_attr "mode" "none")])
4916 ;; This is used in compiling the unwind routines.
4917 (define_expand "eh_return"
4918 [(use (match_operand 0 "general_operand"))]
4921 enum machine_mode gpr_mode = TARGET_64BIT ? DImode : SImode;
4923 if (GET_MODE (operands[0]) != gpr_mode)
4924 operands[0] = convert_to_mode (gpr_mode, operands[0], 0);
4926 emit_insn (gen_eh_set_lr_di (operands[0]));
4928 emit_insn (gen_eh_set_lr_si (operands[0]));
4933 ;; Clobber the return address on the stack. We can't expand this
4934 ;; until we know where it will be put in the stack frame.
4936 (define_insn "eh_set_lr_si"
4937 [(unspec [(match_operand:SI 0 "register_operand" "d")] UNSPEC_EH_RETURN)
4938 (clobber (match_scratch:SI 1 "=&d"))]
4942 (define_insn "eh_set_lr_di"
4943 [(unspec [(match_operand:DI 0 "register_operand" "d")] UNSPEC_EH_RETURN)
4944 (clobber (match_scratch:DI 1 "=&d"))]
4949 [(unspec [(match_operand 0 "register_operand")] UNSPEC_EH_RETURN)
4950 (clobber (match_scratch 1))]
4951 "reload_completed && !TARGET_DEBUG_D_MODE"
4954 mips_set_return_address (operands[0], operands[1]);
4958 (define_insn_and_split "exception_receiver"
4960 (unspec_volatile:SI [(const_int 0)] UNSPEC_EH_RECEIVER))]
4961 "TARGET_ABICALLS && TARGET_OLDABI"
4963 "&& reload_completed"
4969 [(set_attr "type" "load")
4970 (set_attr "length" "12")])
4973 ;; ....................
4977 ;; ....................
4979 ;; Instructions to load a call address from the GOT. The address might
4980 ;; point to a function or to a lazy binding stub. In the latter case,
4981 ;; the stub will use the dynamic linker to resolve the function, which
4982 ;; in turn will change the GOT entry to point to the function's real
4985 ;; This means that every call, even pure and constant ones, can
4986 ;; potentially modify the GOT entry. And once a stub has been called,
4987 ;; we must not call it again.
4989 ;; We represent this restriction using an imaginary fixed register that
4990 ;; acts like a GOT version number. By making the register call-clobbered,
4991 ;; we tell the target-independent code that the address could be changed
4992 ;; by any call insn.
4993 (define_insn "load_call<mode>"
4994 [(set (match_operand:P 0 "register_operand" "=c")
4995 (unspec:P [(match_operand:P 1 "register_operand" "r")
4996 (match_operand:P 2 "immediate_operand" "")
4997 (reg:P FAKE_CALL_REGNO)]
5000 "<load>\t%0,%R2(%1)"
5001 [(set_attr "type" "load")
5002 (set_attr "mode" "<MODE>")
5003 (set_attr "length" "4")])
5005 ;; Sibling calls. All these patterns use jump instructions.
5007 ;; If TARGET_SIBCALLS, call_insn_operand will only accept constant
5008 ;; addresses if a direct jump is acceptable. Since the 'S' constraint
5009 ;; is defined in terms of call_insn_operand, the same is true of the
5012 ;; When we use an indirect jump, we need a register that will be
5013 ;; preserved by the epilogue. Since TARGET_ABICALLS forces us to
5014 ;; use $25 for this purpose -- and $25 is never clobbered by the
5015 ;; epilogue -- we might as well use it for !TARGET_ABICALLS as well.
5017 (define_expand "sibcall"
5018 [(parallel [(call (match_operand 0 "")
5019 (match_operand 1 ""))
5020 (use (match_operand 2 "")) ;; next_arg_reg
5021 (use (match_operand 3 ""))])] ;; struct_value_size_rtx
5024 mips_expand_call (0, XEXP (operands[0], 0), operands[1], operands[2], true);
5028 (define_insn "sibcall_internal"
5029 [(call (mem:SI (match_operand 0 "call_insn_operand" "j,S"))
5030 (match_operand 1 "" ""))]
5031 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
5035 [(set_attr "type" "call")])
5037 (define_expand "sibcall_value"
5038 [(parallel [(set (match_operand 0 "")
5039 (call (match_operand 1 "")
5040 (match_operand 2 "")))
5041 (use (match_operand 3 ""))])] ;; next_arg_reg
5044 mips_expand_call (operands[0], XEXP (operands[1], 0),
5045 operands[2], operands[3], true);
5049 (define_insn "sibcall_value_internal"
5050 [(set (match_operand 0 "register_operand" "=df,df")
5051 (call (mem:SI (match_operand 1 "call_insn_operand" "j,S"))
5052 (match_operand 2 "" "")))]
5053 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
5057 [(set_attr "type" "call")])
5059 (define_insn "sibcall_value_multiple_internal"
5060 [(set (match_operand 0 "register_operand" "=df,df")
5061 (call (mem:SI (match_operand 1 "call_insn_operand" "j,S"))
5062 (match_operand 2 "" "")))
5063 (set (match_operand 3 "register_operand" "=df,df")
5064 (call (mem:SI (match_dup 1))
5066 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
5070 [(set_attr "type" "call")])
5072 (define_expand "call"
5073 [(parallel [(call (match_operand 0 "")
5074 (match_operand 1 ""))
5075 (use (match_operand 2 "")) ;; next_arg_reg
5076 (use (match_operand 3 ""))])] ;; struct_value_size_rtx
5079 mips_expand_call (0, XEXP (operands[0], 0), operands[1], operands[2], false);
5083 ;; This instruction directly corresponds to an assembly-language "jal".
5084 ;; There are four cases:
5087 ;; Both symbolic and register destinations are OK. The pattern
5088 ;; always expands to a single mips instruction.
5090 ;; - -mabicalls/-mno-explicit-relocs:
5091 ;; Again, both symbolic and register destinations are OK.
5092 ;; The call is treated as a multi-instruction black box.
5094 ;; - -mabicalls/-mexplicit-relocs with n32 or n64:
5095 ;; Only "jal $25" is allowed. This expands to a single "jalr $25"
5098 ;; - -mabicalls/-mexplicit-relocs with o32 or o64:
5099 ;; Only "jal $25" is allowed. The call is actually two instructions:
5100 ;; "jalr $25" followed by an insn to reload $gp.
5102 ;; In the last case, we can generate the individual instructions with
5103 ;; a define_split. There are several things to be wary of:
5105 ;; - We can't expose the load of $gp before reload. If we did,
5106 ;; it might get removed as dead, but reload can introduce new
5107 ;; uses of $gp by rematerializing constants.
5109 ;; - We shouldn't restore $gp after calls that never return.
5110 ;; It isn't valid to insert instructions between a noreturn
5111 ;; call and the following barrier.
5113 ;; - The splitter deliberately changes the liveness of $gp. The unsplit
5114 ;; instruction preserves $gp and so have no effect on its liveness.
5115 ;; But once we generate the separate insns, it becomes obvious that
5116 ;; $gp is not live on entry to the call.
5118 ;; ??? The operands[2] = insn check is a hack to make the original insn
5119 ;; available to the splitter.
5120 (define_insn_and_split "call_internal"
5121 [(call (mem:SI (match_operand 0 "call_insn_operand" "c,S"))
5122 (match_operand 1 "" ""))
5123 (clobber (reg:SI 31))]
5125 { return TARGET_SPLIT_CALLS ? "#" : "%*jal\t%0%/"; }
5126 "reload_completed && TARGET_SPLIT_CALLS && (operands[2] = insn)"
5129 emit_call_insn (gen_call_split (operands[0], operands[1]));
5130 if (!find_reg_note (operands[2], REG_NORETURN, 0))
5134 [(set_attr "jal" "indirect,direct")
5135 (set_attr "extended_mips16" "no,yes")])
5137 (define_insn "call_split"
5138 [(call (mem:SI (match_operand 0 "call_insn_operand" "c"))
5139 (match_operand 1 "" ""))
5140 (clobber (reg:SI 31))
5141 (clobber (reg:SI 28))]
5142 "TARGET_SPLIT_CALLS"
5144 [(set_attr "type" "call")])
5146 (define_expand "call_value"
5147 [(parallel [(set (match_operand 0 "")
5148 (call (match_operand 1 "")
5149 (match_operand 2 "")))
5150 (use (match_operand 3 ""))])] ;; next_arg_reg
5153 mips_expand_call (operands[0], XEXP (operands[1], 0),
5154 operands[2], operands[3], false);
5158 ;; See comment for call_internal.
5159 (define_insn_and_split "call_value_internal"
5160 [(set (match_operand 0 "register_operand" "=df,df")
5161 (call (mem:SI (match_operand 1 "call_insn_operand" "c,S"))
5162 (match_operand 2 "" "")))
5163 (clobber (reg:SI 31))]
5165 { return TARGET_SPLIT_CALLS ? "#" : "%*jal\t%1%/"; }
5166 "reload_completed && TARGET_SPLIT_CALLS && (operands[3] = insn)"
5169 emit_call_insn (gen_call_value_split (operands[0], operands[1],
5171 if (!find_reg_note (operands[3], REG_NORETURN, 0))
5175 [(set_attr "jal" "indirect,direct")
5176 (set_attr "extended_mips16" "no,yes")])
5178 (define_insn "call_value_split"
5179 [(set (match_operand 0 "register_operand" "=df")
5180 (call (mem:SI (match_operand 1 "call_insn_operand" "c"))
5181 (match_operand 2 "" "")))
5182 (clobber (reg:SI 31))
5183 (clobber (reg:SI 28))]
5184 "TARGET_SPLIT_CALLS"
5186 [(set_attr "type" "call")])
5188 ;; See comment for call_internal.
5189 (define_insn_and_split "call_value_multiple_internal"
5190 [(set (match_operand 0 "register_operand" "=df,df")
5191 (call (mem:SI (match_operand 1 "call_insn_operand" "c,S"))
5192 (match_operand 2 "" "")))
5193 (set (match_operand 3 "register_operand" "=df,df")
5194 (call (mem:SI (match_dup 1))
5196 (clobber (reg:SI 31))]
5198 { return TARGET_SPLIT_CALLS ? "#" : "%*jal\t%1%/"; }
5199 "reload_completed && TARGET_SPLIT_CALLS && (operands[4] = insn)"
5202 emit_call_insn (gen_call_value_multiple_split (operands[0], operands[1],
5203 operands[2], operands[3]));
5204 if (!find_reg_note (operands[4], REG_NORETURN, 0))
5208 [(set_attr "jal" "indirect,direct")
5209 (set_attr "extended_mips16" "no,yes")])
5211 (define_insn "call_value_multiple_split"
5212 [(set (match_operand 0 "register_operand" "=df")
5213 (call (mem:SI (match_operand 1 "call_insn_operand" "c"))
5214 (match_operand 2 "" "")))
5215 (set (match_operand 3 "register_operand" "=df")
5216 (call (mem:SI (match_dup 1))
5218 (clobber (reg:SI 31))
5219 (clobber (reg:SI 28))]
5220 "TARGET_SPLIT_CALLS"
5222 [(set_attr "type" "call")])
5224 ;; Call subroutine returning any type.
5226 (define_expand "untyped_call"
5227 [(parallel [(call (match_operand 0 "")
5229 (match_operand 1 "")
5230 (match_operand 2 "")])]
5235 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
5237 for (i = 0; i < XVECLEN (operands[2], 0); i++)
5239 rtx set = XVECEXP (operands[2], 0, i);
5240 emit_move_insn (SET_DEST (set), SET_SRC (set));
5243 emit_insn (gen_blockage ());
5248 ;; ....................
5252 ;; ....................
5256 (define_insn "prefetch"
5257 [(prefetch (match_operand:QI 0 "address_operand" "p")
5258 (match_operand 1 "const_int_operand" "n")
5259 (match_operand 2 "const_int_operand" "n"))]
5260 "ISA_HAS_PREFETCH && TARGET_EXPLICIT_RELOCS"
5262 operands[1] = mips_prefetch_cookie (operands[1], operands[2]);
5263 return "pref\t%1,%a0";
5265 [(set_attr "type" "prefetch")])
5267 (define_insn "*prefetch_indexed_<mode>"
5268 [(prefetch (plus:P (match_operand:P 0 "register_operand" "d")
5269 (match_operand:P 1 "register_operand" "d"))
5270 (match_operand 2 "const_int_operand" "n")
5271 (match_operand 3 "const_int_operand" "n"))]
5272 "ISA_HAS_PREFETCHX && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
5274 operands[2] = mips_prefetch_cookie (operands[2], operands[3]);
5275 return "prefx\t%2,%1(%0)";
5277 [(set_attr "type" "prefetchx")])
5283 [(set_attr "type" "nop")
5284 (set_attr "mode" "none")])
5286 ;; Like nop, but commented out when outside a .set noreorder block.
5287 (define_insn "hazard_nop"
5296 [(set_attr "type" "nop")])
5298 ;; MIPS4 Conditional move instructions.
5300 (define_insn "*mov<GPR:mode>_on_<MOVECC:mode>"
5301 [(set (match_operand:GPR 0 "register_operand" "=d,d")
5303 (match_operator:MOVECC 4 "equality_operator"
5304 [(match_operand:MOVECC 1 "register_operand" "<MOVECC:reg>,<MOVECC:reg>")
5306 (match_operand:GPR 2 "reg_or_0_operand" "dJ,0")
5307 (match_operand:GPR 3 "reg_or_0_operand" "0,dJ")))]
5312 [(set_attr "type" "condmove")
5313 (set_attr "mode" "<GPR:MODE>")])
5315 (define_insn "*mov<SCALARF:mode>_on_<MOVECC:mode>"
5316 [(set (match_operand:SCALARF 0 "register_operand" "=f,f")
5317 (if_then_else:SCALARF
5318 (match_operator:MOVECC 4 "equality_operator"
5319 [(match_operand:MOVECC 1 "register_operand" "<MOVECC:reg>,<MOVECC:reg>")
5321 (match_operand:SCALARF 2 "register_operand" "f,0")
5322 (match_operand:SCALARF 3 "register_operand" "0,f")))]
5325 mov%T4.<fmt>\t%0,%2,%1
5326 mov%t4.<fmt>\t%0,%3,%1"
5327 [(set_attr "type" "condmove")
5328 (set_attr "mode" "<SCALARF:MODE>")])
5330 ;; These are the main define_expand's used to make conditional moves.
5332 (define_expand "mov<mode>cc"
5333 [(set (match_dup 4) (match_operand 1 "comparison_operator"))
5334 (set (match_operand:GPR 0 "register_operand")
5335 (if_then_else:GPR (match_dup 5)
5336 (match_operand:GPR 2 "reg_or_0_operand")
5337 (match_operand:GPR 3 "reg_or_0_operand")))]
5340 gen_conditional_move (operands);
5344 (define_expand "mov<mode>cc"
5345 [(set (match_dup 4) (match_operand 1 "comparison_operator"))
5346 (set (match_operand:SCALARF 0 "register_operand")
5347 (if_then_else:SCALARF (match_dup 5)
5348 (match_operand:SCALARF 2 "register_operand")
5349 (match_operand:SCALARF 3 "register_operand")))]
5352 gen_conditional_move (operands);
5357 ;; ....................
5359 ;; mips16 inline constant tables
5361 ;; ....................
5364 (define_insn "consttable_int"
5365 [(unspec_volatile [(match_operand 0 "consttable_operand" "")
5366 (match_operand 1 "const_int_operand" "")]
5367 UNSPEC_CONSTTABLE_INT)]
5370 assemble_integer (operands[0], INTVAL (operands[1]),
5371 BITS_PER_UNIT * INTVAL (operands[1]), 1);
5374 [(set (attr "length") (symbol_ref "INTVAL (operands[1])"))])
5376 (define_insn "consttable_float"
5377 [(unspec_volatile [(match_operand 0 "consttable_operand" "")]
5378 UNSPEC_CONSTTABLE_FLOAT)]
5383 gcc_assert (GET_CODE (operands[0]) == CONST_DOUBLE);
5384 REAL_VALUE_FROM_CONST_DOUBLE (d, operands[0]);
5385 assemble_real (d, GET_MODE (operands[0]),
5386 GET_MODE_BITSIZE (GET_MODE (operands[0])));
5389 [(set (attr "length")
5390 (symbol_ref "GET_MODE_SIZE (GET_MODE (operands[0]))"))])
5392 (define_insn "align"
5393 [(unspec_volatile [(match_operand 0 "const_int_operand" "")] UNSPEC_ALIGN)]
5396 [(set (attr "length") (symbol_ref "(1 << INTVAL (operands[0])) - 1"))])
5399 [(match_operand 0 "small_data_pattern")]
5402 { operands[0] = mips_rewrite_small_data (operands[0]); })
5404 ; Thread-Local Storage
5406 ; The TLS base pointer is accessed via "rdhwr $v1, $29". No current
5407 ; MIPS architecture defines this register, and no current
5408 ; implementation provides it; instead, any OS which supports TLS is
5409 ; expected to trap and emulate this instruction. rdhwr is part of the
5410 ; MIPS 32r2 specification, but we use it on any architecture because
5411 ; we expect it to be emulated. Use .set to force the assembler to
5414 (define_insn "tls_get_tp_<mode>"
5415 [(set (match_operand:P 0 "register_operand" "=v")
5416 (unspec:P [(const_int 0)]
5417 UNSPEC_TLS_GET_TP))]
5418 "HAVE_AS_TLS && !TARGET_MIPS16"
5419 ".set\tpush\;.set\tmips32r2\t\;rdhwr\t%0,$29\;.set\tpop"
5420 [(set_attr "type" "unknown")
5421 (set_attr "mode" "<MODE>")])
5423 ; The MIPS Paired-Single Floating Point and MIPS-3D Instructions.
5425 (include "mips-ps-3d.md")
5427 ; The MIPS DSP Instructions.
5429 (include "mips-dsp.md")