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, 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, 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)
78 (include "predicates.md")
80 ;; ....................
84 ;; ....................
86 (define_attr "got" "unset,xgot_high,load"
87 (const_string "unset"))
89 ;; For jal instructions, this attribute is DIRECT when the target address
90 ;; is symbolic and INDIRECT when it is a register.
91 (define_attr "jal" "unset,direct,indirect"
92 (const_string "unset"))
94 ;; This attribute is YES if the instruction is a jal macro (not a
95 ;; real jal instruction).
97 ;; jal is always a macro in SVR4 PIC since it includes an instruction to
98 ;; restore $gp. Direct jals are also macros in NewABI PIC since they
99 ;; load the target address into $25.
100 (define_attr "jal_macro" "no,yes"
101 (cond [(eq_attr "jal" "direct")
102 (symbol_ref "TARGET_ABICALLS != 0")
103 (eq_attr "jal" "indirect")
104 (symbol_ref "(TARGET_ABICALLS && !TARGET_NEWABI) != 0")]
105 (const_string "no")))
107 ;; Classification of each insn.
108 ;; branch conditional branch
109 ;; jump unconditional jump
110 ;; call unconditional call
111 ;; load load instruction(s)
112 ;; fpload floating point load
113 ;; fpidxload floating point indexed load
114 ;; store store instruction(s)
115 ;; fpstore floating point store
116 ;; fpidxstore floating point indexed store
117 ;; prefetch memory prefetch (register + offset)
118 ;; prefetchx memory indexed prefetch (register + register)
119 ;; condmove conditional moves
120 ;; xfer transfer to/from coprocessor
121 ;; mthilo transfer to hi/lo registers
122 ;; mfhilo transfer from hi/lo registers
123 ;; const load constant
124 ;; arith integer arithmetic and logical instructions
125 ;; shift integer shift instructions
126 ;; slt set less than instructions
127 ;; clz the clz and clo instructions
128 ;; trap trap if instructions
129 ;; imul integer multiply 2 operands
130 ;; imul3 integer multiply 3 operands
131 ;; imadd integer multiply-add
132 ;; idiv integer divide
133 ;; fmove floating point register move
134 ;; fadd floating point add/subtract
135 ;; fmul floating point multiply
136 ;; fmadd floating point multiply-add
137 ;; fdiv floating point divide
138 ;; frdiv floating point reciprocal divide
139 ;; frdiv1 floating point reciprocal divide step 1
140 ;; frdiv2 floating point reciprocal divide step 2
141 ;; fabs floating point absolute value
142 ;; fneg floating point negation
143 ;; fcmp floating point compare
144 ;; fcvt floating point convert
145 ;; fsqrt floating point square root
146 ;; frsqrt floating point reciprocal square root
147 ;; frsqrt1 floating point reciprocal square root step1
148 ;; frsqrt2 floating point reciprocal square root step2
149 ;; multi multiword sequence (or user asm statements)
152 "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"
153 (cond [(eq_attr "jal" "!unset") (const_string "call")
154 (eq_attr "got" "load") (const_string "load")]
155 (const_string "unknown")))
157 ;; Main data type used by the insn
158 (define_attr "mode" "unknown,none,QI,HI,SI,DI,SF,DF,FPSW"
159 (const_string "unknown"))
161 ;; Mode for conversion types (fcvt)
162 ;; I2S integer to float single (SI/DI to SF)
163 ;; I2D integer to float double (SI/DI to DF)
164 ;; S2I float to integer (SF to SI/DI)
165 ;; D2I float to integer (DF to SI/DI)
166 ;; D2S double to float single
167 ;; S2D float single to double
169 (define_attr "cnv_mode" "unknown,I2S,I2D,S2I,D2I,D2S,S2D"
170 (const_string "unknown"))
172 ;; Is this an extended instruction in mips16 mode?
173 (define_attr "extended_mips16" "no,yes"
176 ;; Length of instruction in bytes.
177 (define_attr "length" ""
178 (cond [;; Direct branch instructions have a range of [-0x40000,0x3fffc].
179 ;; If a branch is outside this range, we have a choice of two
180 ;; sequences. For PIC, an out-of-range branch like:
185 ;; becomes the equivalent of:
194 ;; where the load address can be up to three instructions long
197 ;; The non-PIC case is similar except that we use a direct
198 ;; jump instead of an la/jr pair. Since the target of this
199 ;; jump is an absolute 28-bit bit address (the other bits
200 ;; coming from the address of the delay slot) this form cannot
201 ;; cross a 256MB boundary. We could provide the option of
202 ;; using la/jr in this case too, but we do not do so at
205 ;; Note that this value does not account for the delay slot
206 ;; instruction, whose length is added separately. If the RTL
207 ;; pattern has no explicit delay slot, mips_adjust_insn_length
208 ;; will add the length of the implicit nop. The values for
209 ;; forward and backward branches will be different as well.
210 (eq_attr "type" "branch")
211 (cond [(and (le (minus (match_dup 1) (pc)) (const_int 131064))
212 (le (minus (pc) (match_dup 1)) (const_int 131068)))
214 (ne (symbol_ref "flag_pic") (const_int 0))
218 (eq_attr "got" "load")
220 (eq_attr "got" "xgot_high")
223 (eq_attr "type" "const")
224 (symbol_ref "mips_const_insns (operands[1]) * 4")
225 (eq_attr "type" "load,fpload")
226 (symbol_ref "mips_fetch_insns (operands[1]) * 4")
227 (eq_attr "type" "store,fpstore")
228 (symbol_ref "mips_fetch_insns (operands[0]) * 4")
230 ;; In the worst case, a call macro will take 8 instructions:
232 ;; lui $25,%call_hi(FOO)
234 ;; lw $25,%call_lo(FOO)($25)
240 (eq_attr "jal_macro" "yes")
243 (and (eq_attr "extended_mips16" "yes")
244 (ne (symbol_ref "TARGET_MIPS16") (const_int 0)))
247 ;; Various VR4120 errata require a nop to be inserted after a macc
248 ;; instruction. The assembler does this for us, so account for
249 ;; the worst-case length here.
250 (and (eq_attr "type" "imadd")
251 (ne (symbol_ref "TARGET_FIX_VR4120") (const_int 0)))
254 ;; VR4120 errata MD(4): if there are consecutive dmult instructions,
255 ;; the result of the second one is missed. The assembler should work
256 ;; around this by inserting a nop after the first dmult.
257 (and (eq_attr "type" "imul,imul3")
258 (and (eq_attr "mode" "DI")
259 (ne (symbol_ref "TARGET_FIX_VR4120") (const_int 0))))
262 (eq_attr "type" "idiv")
263 (symbol_ref "mips_idiv_insns () * 4")
266 ;; Attribute describing the processor. This attribute must match exactly
267 ;; with the processor_type enumeration in mips.h.
269 "r3000,4kc,4kp,5kc,20kc,24k,24kx,m4k,r3900,r6000,r4000,r4100,r4111,r4120,r4130,r4300,r4600,r4650,r5000,r5400,r5500,r7000,r8000,r9000,sb1,sr71000"
270 (const (symbol_ref "mips_tune")))
272 ;; The type of hardware hazard associated with this instruction.
273 ;; DELAY means that the next instruction cannot read the result
274 ;; of this one. HILO means that the next two instructions cannot
275 ;; write to HI or LO.
276 (define_attr "hazard" "none,delay,hilo"
277 (cond [(and (eq_attr "type" "load,fpload,fpidxload")
278 (ne (symbol_ref "ISA_HAS_LOAD_DELAY") (const_int 0)))
279 (const_string "delay")
281 (and (eq_attr "type" "xfer")
282 (ne (symbol_ref "ISA_HAS_XFER_DELAY") (const_int 0)))
283 (const_string "delay")
285 (and (eq_attr "type" "fcmp")
286 (ne (symbol_ref "ISA_HAS_FCMP_DELAY") (const_int 0)))
287 (const_string "delay")
289 ;; The r4000 multiplication patterns include an mflo instruction.
290 (and (eq_attr "type" "imul")
291 (ne (symbol_ref "TARGET_FIX_R4000") (const_int 0)))
292 (const_string "hilo")
294 (and (eq_attr "type" "mfhilo")
295 (eq (symbol_ref "ISA_HAS_HILO_INTERLOCKS") (const_int 0)))
296 (const_string "hilo")]
297 (const_string "none")))
299 ;; Is it a single instruction?
300 (define_attr "single_insn" "no,yes"
301 (symbol_ref "get_attr_length (insn) == (TARGET_MIPS16 ? 2 : 4)"))
303 ;; Can the instruction be put into a delay slot?
304 (define_attr "can_delay" "no,yes"
305 (if_then_else (and (eq_attr "type" "!branch,call,jump")
306 (and (eq_attr "hazard" "none")
307 (eq_attr "single_insn" "yes")))
309 (const_string "no")))
311 ;; Attribute defining whether or not we can use the branch-likely instructions
312 (define_attr "branch_likely" "no,yes"
314 (if_then_else (ne (symbol_ref "GENERATE_BRANCHLIKELY") (const_int 0))
316 (const_string "no"))))
318 ;; True if an instruction might assign to hi or lo when reloaded.
319 ;; This is used by the TUNE_MACC_CHAINS code.
320 (define_attr "may_clobber_hilo" "no,yes"
321 (if_then_else (eq_attr "type" "imul,imul3,imadd,idiv,mthilo")
323 (const_string "no")))
325 ;; Describe a user's asm statement.
326 (define_asm_attributes
327 [(set_attr "type" "multi")
328 (set_attr "can_delay" "no")])
330 ;; This mode macro allows 32-bit and 64-bit GPR patterns to be generated
331 ;; from the same template.
332 (define_mode_macro GPR [SI (DI "TARGET_64BIT")])
334 ;; This mode macro allows :P to be used for patterns that operate on
335 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
336 (define_mode_macro P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
338 ;; This mode macro allows :MOVECC to be used anywhere that a
339 ;; conditional-move-type condition is needed.
340 (define_mode_macro MOVECC [SI (DI "TARGET_64BIT") (CC "TARGET_HARD_FLOAT")])
342 ;; This mode macro allows the QI and HI extension patterns to be defined from
343 ;; the same template.
344 (define_mode_macro SHORT [QI HI])
346 ;; This mode macro allows :ANYF to be used wherever a scalar or vector
347 ;; floating-point mode is allowed.
348 (define_mode_macro ANYF [(SF "TARGET_HARD_FLOAT")
349 (DF "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT")
350 (V2SF "TARGET_PAIRED_SINGLE_FLOAT")])
352 ;; Like ANYF, but only applies to scalar modes.
353 (define_mode_macro SCALARF [(SF "TARGET_HARD_FLOAT")
354 (DF "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT")])
356 ;; In GPR templates, a string like "<d>subu" will expand to "subu" in the
357 ;; 32-bit version and "dsubu" in the 64-bit version.
358 (define_mode_attr d [(SI "") (DI "d")])
360 ;; This attribute gives the length suffix for a sign- or zero-extension
362 (define_mode_attr size [(QI "b") (HI "h")])
364 ;; This attributes gives the mode mask of a SHORT.
365 (define_mode_attr mask [(QI "0x00ff") (HI "0xffff")])
367 ;; Mode attributes for GPR loads and stores.
368 (define_mode_attr load [(SI "lw") (DI "ld")])
369 (define_mode_attr store [(SI "sw") (DI "sd")])
371 ;; Similarly for MIPS IV indexed FPR loads and stores.
372 (define_mode_attr loadx [(SF "lwxc1") (DF "ldxc1") (V2SF "ldxc1")])
373 (define_mode_attr storex [(SF "swxc1") (DF "sdxc1") (V2SF "sdxc1")])
375 ;; The unextended ranges of the MIPS16 addiu and daddiu instructions
376 ;; are different. Some forms of unextended addiu have an 8-bit immediate
377 ;; field but the equivalent daddiu has only a 5-bit field.
378 (define_mode_attr si8_di5 [(SI "8") (DI "5")])
380 ;; This attribute gives the best constraint to use for registers of
382 (define_mode_attr reg [(SI "d") (DI "d") (CC "z")])
384 ;; This attribute gives the format suffix for floating-point operations.
385 (define_mode_attr fmt [(SF "s") (DF "d") (V2SF "ps")])
387 ;; This attribute gives the upper-case mode name for one unit of a
388 ;; floating-point mode.
389 (define_mode_attr UNITMODE [(SF "SF") (DF "DF") (V2SF "SF")])
391 ;; This attribute works around the early SB-1 rev2 core "F2" erratum:
393 ;; In certain cases, div.s and div.ps may have a rounding error
394 ;; and/or wrong inexact flag.
396 ;; Therefore, we only allow div.s if not working around SB-1 rev2
397 ;; errata or if a slight loss of precision is OK.
398 (define_mode_attr divide_condition
399 [DF (SF "!TARGET_FIX_SB1 || flag_unsafe_math_optimizations")
400 (V2SF "TARGET_SB1 && (!TARGET_FIX_SB1 || flag_unsafe_math_optimizations)")])
402 ; This attribute gives the condition for which sqrt instructions exist.
403 (define_mode_attr sqrt_condition
404 [(SF "!ISA_MIPS1") (DF "!ISA_MIPS1") (V2SF "TARGET_SB1")])
406 ; This attribute gives the condition for which recip and rsqrt instructions
408 (define_mode_attr recip_condition
409 [(SF "ISA_HAS_FP4") (DF "ISA_HAS_FP4") (V2SF "TARGET_SB1")])
411 ;; This code macro allows all branch instructions to be generated from
412 ;; a single define_expand template.
413 (define_code_macro any_cond [unordered ordered unlt unge uneq ltgt unle ungt
414 eq ne gt ge lt le gtu geu ltu leu])
416 ;; This code macro allows signed and unsigned widening multiplications
417 ;; to use the same template.
418 (define_code_macro any_extend [sign_extend zero_extend])
420 ;; This code macro allows the three shift instructions to be generated
421 ;; from the same template.
422 (define_code_macro any_shift [ashift ashiftrt lshiftrt])
424 ;; This code macro allows all native floating-point comparisons to be
425 ;; generated from the same template.
426 (define_code_macro fcond [unordered uneq unlt unle eq lt le])
428 ;; This code macro is used for comparisons that can be implemented
429 ;; by swapping the operands.
430 (define_code_macro swapped_fcond [ge gt unge ungt])
432 ;; <u> expands to an empty string when doing a signed operation and
433 ;; "u" when doing an unsigned operation.
434 (define_code_attr u [(sign_extend "") (zero_extend "u")])
436 ;; <su> is like <u>, but the signed form expands to "s" rather than "".
437 (define_code_attr su [(sign_extend "s") (zero_extend "u")])
439 ;; <optab> expands to the name of the optab for a particular code.
440 (define_code_attr optab [(ashift "ashl")
444 ;; <insn> expands to the name of the insn that implements a particular code.
445 (define_code_attr insn [(ashift "sll")
449 ;; <fcond> is the c.cond.fmt condition associated with a particular code.
450 (define_code_attr fcond [(unordered "un")
458 ;; Similar, but for swapped conditions.
459 (define_code_attr swapped_fcond [(ge "le")
464 ;; .........................
466 ;; Branch, call and jump delay slots
468 ;; .........................
470 (define_delay (and (eq_attr "type" "branch")
471 (eq (symbol_ref "TARGET_MIPS16") (const_int 0)))
472 [(eq_attr "can_delay" "yes")
474 (and (eq_attr "branch_likely" "yes")
475 (eq_attr "can_delay" "yes"))])
477 (define_delay (eq_attr "type" "jump")
478 [(eq_attr "can_delay" "yes")
482 (define_delay (and (eq_attr "type" "call")
483 (eq_attr "jal_macro" "no"))
484 [(eq_attr "can_delay" "yes")
488 ;; Pipeline descriptions.
490 ;; generic.md provides a fallback for processors without a specific
491 ;; pipeline description. It is derived from the old define_function_unit
492 ;; version and uses the "alu" and "imuldiv" units declared below.
494 ;; Some of the processor-specific files are also derived from old
495 ;; define_function_unit descriptions and simply override the parts of
496 ;; generic.md that don't apply. The other processor-specific files
497 ;; are self-contained.
498 (define_automaton "alu,imuldiv")
500 (define_cpu_unit "alu" "alu")
501 (define_cpu_unit "imuldiv" "imuldiv")
519 (include "generic.md")
522 ;; ....................
526 ;; ....................
530 [(trap_if (const_int 1) (const_int 0))]
533 if (ISA_HAS_COND_TRAP)
535 else if (TARGET_MIPS16)
540 [(set_attr "type" "trap")])
542 (define_expand "conditional_trap"
543 [(trap_if (match_operator 0 "comparison_operator"
544 [(match_dup 2) (match_dup 3)])
545 (match_operand 1 "const_int_operand"))]
548 if (GET_MODE_CLASS (GET_MODE (cmp_operands[0])) == MODE_INT
549 && operands[1] == const0_rtx)
551 mips_gen_conditional_trap (operands);
558 (define_insn "*conditional_trap<mode>"
559 [(trap_if (match_operator:GPR 0 "trap_comparison_operator"
560 [(match_operand:GPR 1 "reg_or_0_operand" "dJ")
561 (match_operand:GPR 2 "arith_operand" "dI")])
565 [(set_attr "type" "trap")])
568 ;; ....................
572 ;; ....................
575 (define_insn "add<mode>3"
576 [(set (match_operand:ANYF 0 "register_operand" "=f")
577 (plus:ANYF (match_operand:ANYF 1 "register_operand" "f")
578 (match_operand:ANYF 2 "register_operand" "f")))]
580 "add.<fmt>\t%0,%1,%2"
581 [(set_attr "type" "fadd")
582 (set_attr "mode" "<UNITMODE>")])
584 (define_expand "add<mode>3"
585 [(set (match_operand:GPR 0 "register_operand")
586 (plus:GPR (match_operand:GPR 1 "register_operand")
587 (match_operand:GPR 2 "arith_operand")))]
590 (define_insn "*add<mode>3"
591 [(set (match_operand:GPR 0 "register_operand" "=d,d")
592 (plus:GPR (match_operand:GPR 1 "register_operand" "d,d")
593 (match_operand:GPR 2 "arith_operand" "d,Q")))]
598 [(set_attr "type" "arith")
599 (set_attr "mode" "<MODE>")])
601 ;; We need to recognize MIPS16 stack pointer additions explicitly, since
602 ;; we don't have a constraint for $sp. These insns will be generated by
603 ;; the save_restore_insns functions.
605 (define_insn "*add<mode>3_sp1"
607 (plus:GPR (reg:GPR 29)
608 (match_operand:GPR 0 "const_arith_operand" "")))]
611 [(set_attr "type" "arith")
612 (set_attr "mode" "<MODE>")
613 (set (attr "length") (if_then_else (match_operand 0 "m16_simm8_8")
617 (define_insn "*add<mode>3_sp2"
618 [(set (match_operand:GPR 0 "register_operand" "=d")
619 (plus:GPR (reg:GPR 29)
620 (match_operand:GPR 1 "const_arith_operand" "")))]
623 [(set_attr "type" "arith")
624 (set_attr "mode" "<MODE>")
625 (set (attr "length") (if_then_else (match_operand 1 "m16_uimm<si8_di5>_4")
629 (define_insn "*add<mode>3_mips16"
630 [(set (match_operand:GPR 0 "register_operand" "=d,d,d")
631 (plus:GPR (match_operand:GPR 1 "register_operand" "0,d,d")
632 (match_operand:GPR 2 "arith_operand" "Q,O,d")))]
638 [(set_attr "type" "arith")
639 (set_attr "mode" "<MODE>")
640 (set_attr_alternative "length"
641 [(if_then_else (match_operand 2 "m16_simm<si8_di5>_1")
644 (if_then_else (match_operand 2 "m16_simm4_1")
650 ;; On the mips16, we can sometimes split an add of a constant which is
651 ;; a 4 byte instruction into two adds which are both 2 byte
652 ;; instructions. There are two cases: one where we are adding a
653 ;; constant plus a register to another register, and one where we are
654 ;; simply adding a constant to a register.
657 [(set (match_operand:SI 0 "register_operand")
658 (plus:SI (match_dup 0)
659 (match_operand:SI 1 "const_int_operand")))]
660 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
661 && REG_P (operands[0])
662 && M16_REG_P (REGNO (operands[0]))
663 && GET_CODE (operands[1]) == CONST_INT
664 && ((INTVAL (operands[1]) > 0x7f
665 && INTVAL (operands[1]) <= 0x7f + 0x7f)
666 || (INTVAL (operands[1]) < - 0x80
667 && INTVAL (operands[1]) >= - 0x80 - 0x80))"
668 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
669 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]
671 HOST_WIDE_INT val = INTVAL (operands[1]);
675 operands[1] = GEN_INT (0x7f);
676 operands[2] = GEN_INT (val - 0x7f);
680 operands[1] = GEN_INT (- 0x80);
681 operands[2] = GEN_INT (val + 0x80);
686 [(set (match_operand:SI 0 "register_operand")
687 (plus:SI (match_operand:SI 1 "register_operand")
688 (match_operand:SI 2 "const_int_operand")))]
689 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
690 && REG_P (operands[0])
691 && M16_REG_P (REGNO (operands[0]))
692 && REG_P (operands[1])
693 && M16_REG_P (REGNO (operands[1]))
694 && REGNO (operands[0]) != REGNO (operands[1])
695 && GET_CODE (operands[2]) == CONST_INT
696 && ((INTVAL (operands[2]) > 0x7
697 && INTVAL (operands[2]) <= 0x7 + 0x7f)
698 || (INTVAL (operands[2]) < - 0x8
699 && INTVAL (operands[2]) >= - 0x8 - 0x80))"
700 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))
701 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 3)))]
703 HOST_WIDE_INT val = INTVAL (operands[2]);
707 operands[2] = GEN_INT (0x7);
708 operands[3] = GEN_INT (val - 0x7);
712 operands[2] = GEN_INT (- 0x8);
713 operands[3] = GEN_INT (val + 0x8);
718 [(set (match_operand:DI 0 "register_operand")
719 (plus:DI (match_dup 0)
720 (match_operand:DI 1 "const_int_operand")))]
721 "TARGET_MIPS16 && TARGET_64BIT && reload_completed && !TARGET_DEBUG_D_MODE
722 && REG_P (operands[0])
723 && M16_REG_P (REGNO (operands[0]))
724 && GET_CODE (operands[1]) == CONST_INT
725 && ((INTVAL (operands[1]) > 0xf
726 && INTVAL (operands[1]) <= 0xf + 0xf)
727 || (INTVAL (operands[1]) < - 0x10
728 && INTVAL (operands[1]) >= - 0x10 - 0x10))"
729 [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1)))
730 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))]
732 HOST_WIDE_INT val = INTVAL (operands[1]);
736 operands[1] = GEN_INT (0xf);
737 operands[2] = GEN_INT (val - 0xf);
741 operands[1] = GEN_INT (- 0x10);
742 operands[2] = GEN_INT (val + 0x10);
747 [(set (match_operand:DI 0 "register_operand")
748 (plus:DI (match_operand:DI 1 "register_operand")
749 (match_operand:DI 2 "const_int_operand")))]
750 "TARGET_MIPS16 && TARGET_64BIT && reload_completed && !TARGET_DEBUG_D_MODE
751 && REG_P (operands[0])
752 && M16_REG_P (REGNO (operands[0]))
753 && REG_P (operands[1])
754 && M16_REG_P (REGNO (operands[1]))
755 && REGNO (operands[0]) != REGNO (operands[1])
756 && GET_CODE (operands[2]) == CONST_INT
757 && ((INTVAL (operands[2]) > 0x7
758 && INTVAL (operands[2]) <= 0x7 + 0xf)
759 || (INTVAL (operands[2]) < - 0x8
760 && INTVAL (operands[2]) >= - 0x8 - 0x10))"
761 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))
762 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
764 HOST_WIDE_INT val = INTVAL (operands[2]);
768 operands[2] = GEN_INT (0x7);
769 operands[3] = GEN_INT (val - 0x7);
773 operands[2] = GEN_INT (- 0x8);
774 operands[3] = GEN_INT (val + 0x8);
778 (define_insn "*addsi3_extended"
779 [(set (match_operand:DI 0 "register_operand" "=d,d")
781 (plus:SI (match_operand:SI 1 "register_operand" "d,d")
782 (match_operand:SI 2 "arith_operand" "d,Q"))))]
783 "TARGET_64BIT && !TARGET_MIPS16"
787 [(set_attr "type" "arith")
788 (set_attr "mode" "SI")])
790 ;; Split this insn so that the addiu splitters can have a crack at it.
791 ;; Use a conservative length estimate until the split.
792 (define_insn_and_split "*addsi3_extended_mips16"
793 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
795 (plus:SI (match_operand:SI 1 "register_operand" "0,d,d")
796 (match_operand:SI 2 "arith_operand" "Q,O,d"))))]
797 "TARGET_64BIT && TARGET_MIPS16"
799 "&& reload_completed"
800 [(set (match_dup 3) (plus:SI (match_dup 1) (match_dup 2)))]
801 { operands[3] = gen_lowpart (SImode, operands[0]); }
802 [(set_attr "type" "arith")
803 (set_attr "mode" "SI")
804 (set_attr "extended_mips16" "yes")])
807 ;; ....................
811 ;; ....................
814 (define_insn "sub<mode>3"
815 [(set (match_operand:ANYF 0 "register_operand" "=f")
816 (minus:ANYF (match_operand:ANYF 1 "register_operand" "f")
817 (match_operand:ANYF 2 "register_operand" "f")))]
819 "sub.<fmt>\t%0,%1,%2"
820 [(set_attr "type" "fadd")
821 (set_attr "mode" "<UNITMODE>")])
823 (define_insn "sub<mode>3"
824 [(set (match_operand:GPR 0 "register_operand" "=d")
825 (minus:GPR (match_operand:GPR 1 "register_operand" "d")
826 (match_operand:GPR 2 "register_operand" "d")))]
829 [(set_attr "type" "arith")
830 (set_attr "mode" "<MODE>")])
832 (define_insn "*subsi3_extended"
833 [(set (match_operand:DI 0 "register_operand" "=d")
835 (minus:SI (match_operand:SI 1 "register_operand" "d")
836 (match_operand:SI 2 "register_operand" "d"))))]
839 [(set_attr "type" "arith")
840 (set_attr "mode" "DI")])
843 ;; ....................
847 ;; ....................
850 (define_expand "mul<mode>3"
851 [(set (match_operand:SCALARF 0 "register_operand")
852 (mult:SCALARF (match_operand:SCALARF 1 "register_operand")
853 (match_operand:SCALARF 2 "register_operand")))]
857 (define_insn "*mul<mode>3"
858 [(set (match_operand:SCALARF 0 "register_operand" "=f")
859 (mult:SCALARF (match_operand:SCALARF 1 "register_operand" "f")
860 (match_operand:SCALARF 2 "register_operand" "f")))]
861 "!TARGET_4300_MUL_FIX"
862 "mul.<fmt>\t%0,%1,%2"
863 [(set_attr "type" "fmul")
864 (set_attr "mode" "<MODE>")])
866 ;; Early VR4300 silicon has a CPU bug where multiplies with certain
867 ;; operands may corrupt immediately following multiplies. This is a
868 ;; simple fix to insert NOPs.
870 (define_insn "*mul<mode>3_r4300"
871 [(set (match_operand:SCALARF 0 "register_operand" "=f")
872 (mult:SCALARF (match_operand:SCALARF 1 "register_operand" "f")
873 (match_operand:SCALARF 2 "register_operand" "f")))]
874 "TARGET_4300_MUL_FIX"
875 "mul.<fmt>\t%0,%1,%2\;nop"
876 [(set_attr "type" "fmul")
877 (set_attr "mode" "<MODE>")
878 (set_attr "length" "8")])
880 (define_insn "mulv2sf3"
881 [(set (match_operand:V2SF 0 "register_operand" "=f")
882 (mult:V2SF (match_operand:V2SF 1 "register_operand" "f")
883 (match_operand:V2SF 2 "register_operand" "f")))]
884 "TARGET_PAIRED_SINGLE_FLOAT"
886 [(set_attr "type" "fmul")
887 (set_attr "mode" "SF")])
889 ;; The original R4000 has a cpu bug. If a double-word or a variable
890 ;; shift executes while an integer multiplication is in progress, the
891 ;; shift may give an incorrect result. Avoid this by keeping the mflo
892 ;; with the mult on the R4000.
894 ;; From "MIPS R4000PC/SC Errata, Processor Revision 2.2 and 3.0"
895 ;; (also valid for MIPS R4000MC processors):
897 ;; "16. R4000PC, R4000SC: Please refer to errata 28 for an update to
898 ;; this errata description.
899 ;; The following code sequence causes the R4000 to incorrectly
900 ;; execute the Double Shift Right Arithmetic 32 (dsra32)
901 ;; instruction. If the dsra32 instruction is executed during an
902 ;; integer multiply, the dsra32 will only shift by the amount in
903 ;; specified in the instruction rather than the amount plus 32
905 ;; instruction 1: mult rs,rt integer multiply
906 ;; instruction 2-12: dsra32 rd,rt,rs doubleword shift
907 ;; right arithmetic + 32
908 ;; Workaround: A dsra32 instruction placed after an integer
909 ;; multiply should not be one of the 11 instructions after the
910 ;; multiply instruction."
914 ;; "28. R4000PC, R4000SC: The text from errata 16 should be replaced by
915 ;; the following description.
916 ;; All extended shifts (shift by n+32) and variable shifts (32 and
917 ;; 64-bit versions) may produce incorrect results under the
918 ;; following conditions:
919 ;; 1) An integer multiply is currently executing
920 ;; 2) These types of shift instructions are executed immediately
921 ;; following an integer divide instruction.
923 ;; 1) Make sure no integer multiply is running wihen these
924 ;; instruction are executed. If this cannot be predicted at
925 ;; compile time, then insert a "mfhi" to R0 instruction
926 ;; immediately after the integer multiply instruction. This
927 ;; will cause the integer multiply to complete before the shift
929 ;; 2) Separate integer divide and these two classes of shift
930 ;; instructions by another instruction or a noop."
932 ;; These processors have PRId values of 0x00004220 and 0x00004300,
935 (define_expand "mul<mode>3"
936 [(set (match_operand:GPR 0 "register_operand")
937 (mult:GPR (match_operand:GPR 1 "register_operand")
938 (match_operand:GPR 2 "register_operand")))]
941 if (GENERATE_MULT3_<MODE>)
942 emit_insn (gen_mul<mode>3_mult3 (operands[0], operands[1], operands[2]));
943 else if (!TARGET_FIX_R4000)
944 emit_insn (gen_mul<mode>3_internal (operands[0], operands[1],
947 emit_insn (gen_mul<mode>3_r4000 (operands[0], operands[1], operands[2]));
951 (define_insn "mulsi3_mult3"
952 [(set (match_operand:SI 0 "register_operand" "=d,l")
953 (mult:SI (match_operand:SI 1 "register_operand" "d,d")
954 (match_operand:SI 2 "register_operand" "d,d")))
955 (clobber (match_scratch:SI 3 "=h,h"))
956 (clobber (match_scratch:SI 4 "=l,X"))]
959 if (which_alternative == 1)
960 return "mult\t%1,%2";
969 return "mul\t%0,%1,%2";
970 return "mult\t%0,%1,%2";
972 [(set_attr "type" "imul3,imul")
973 (set_attr "mode" "SI")])
975 (define_insn "muldi3_mult3"
976 [(set (match_operand:DI 0 "register_operand" "=d")
977 (mult:DI (match_operand:DI 1 "register_operand" "d")
978 (match_operand:DI 2 "register_operand" "d")))
979 (clobber (match_scratch:DI 3 "=h"))
980 (clobber (match_scratch:DI 4 "=l"))]
981 "TARGET_64BIT && GENERATE_MULT3_DI"
983 [(set_attr "type" "imul3")
984 (set_attr "mode" "DI")])
986 ;; If a register gets allocated to LO, and we spill to memory, the reload
987 ;; will include a move from LO to a GPR. Merge it into the multiplication
988 ;; if it can set the GPR directly.
991 ;; Operand 1: GPR (1st multiplication operand)
992 ;; Operand 2: GPR (2nd multiplication operand)
994 ;; Operand 4: GPR (destination)
997 [(set (match_operand:SI 0 "register_operand")
998 (mult:SI (match_operand:SI 1 "register_operand")
999 (match_operand:SI 2 "register_operand")))
1000 (clobber (match_operand:SI 3 "register_operand"))
1001 (clobber (scratch:SI))])
1002 (set (match_operand:SI 4 "register_operand")
1003 (unspec [(match_dup 0) (match_dup 3)] UNSPEC_MFHILO))]
1004 "GENERATE_MULT3_SI && peep2_reg_dead_p (2, operands[0])"
1007 (mult:SI (match_dup 1)
1009 (clobber (match_dup 3))
1010 (clobber (match_dup 0))])])
1012 (define_insn "mul<mode>3_internal"
1013 [(set (match_operand:GPR 0 "register_operand" "=l")
1014 (mult:GPR (match_operand:GPR 1 "register_operand" "d")
1015 (match_operand:GPR 2 "register_operand" "d")))
1016 (clobber (match_scratch:GPR 3 "=h"))]
1019 [(set_attr "type" "imul")
1020 (set_attr "mode" "<MODE>")])
1022 (define_insn "mul<mode>3_r4000"
1023 [(set (match_operand:GPR 0 "register_operand" "=d")
1024 (mult:GPR (match_operand:GPR 1 "register_operand" "d")
1025 (match_operand:GPR 2 "register_operand" "d")))
1026 (clobber (match_scratch:GPR 3 "=h"))
1027 (clobber (match_scratch:GPR 4 "=l"))]
1029 "<d>mult\t%1,%2\;mflo\t%0"
1030 [(set_attr "type" "imul")
1031 (set_attr "mode" "<MODE>")
1032 (set_attr "length" "8")])
1034 ;; On the VR4120 and VR4130, it is better to use "mtlo $0; macc" instead
1035 ;; of "mult; mflo". They have the same latency, but the first form gives
1036 ;; us an extra cycle to compute the operands.
1039 ;; Operand 1: GPR (1st multiplication operand)
1040 ;; Operand 2: GPR (2nd multiplication operand)
1042 ;; Operand 4: GPR (destination)
1045 [(set (match_operand:SI 0 "register_operand")
1046 (mult:SI (match_operand:SI 1 "register_operand")
1047 (match_operand:SI 2 "register_operand")))
1048 (clobber (match_operand:SI 3 "register_operand"))])
1049 (set (match_operand:SI 4 "register_operand")
1050 (unspec:SI [(match_dup 0) (match_dup 3)] UNSPEC_MFHILO))]
1051 "ISA_HAS_MACC && !GENERATE_MULT3_SI"
1056 (plus:SI (mult:SI (match_dup 1)
1060 (plus:SI (mult:SI (match_dup 1)
1063 (clobber (match_dup 3))])])
1065 ;; Multiply-accumulate patterns
1067 ;; For processors that can copy the output to a general register:
1069 ;; The all-d alternative is needed because the combiner will find this
1070 ;; pattern and then register alloc/reload will move registers around to
1071 ;; make them fit, and we don't want to trigger unnecessary loads to LO.
1073 ;; The last alternative should be made slightly less desirable, but adding
1074 ;; "?" to the constraint is too strong, and causes values to be loaded into
1075 ;; LO even when that's more costly. For now, using "*d" mostly does the
1077 (define_insn "*mul_acc_si"
1078 [(set (match_operand:SI 0 "register_operand" "=l,*d,*d")
1079 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d,d")
1080 (match_operand:SI 2 "register_operand" "d,d,d"))
1081 (match_operand:SI 3 "register_operand" "0,l,*d")))
1082 (clobber (match_scratch:SI 4 "=h,h,h"))
1083 (clobber (match_scratch:SI 5 "=X,3,l"))
1084 (clobber (match_scratch:SI 6 "=X,X,&d"))]
1086 || ISA_HAS_MADD_MSUB)
1089 static const char *const madd[] = { "madd\t%1,%2", "madd\t%0,%1,%2" };
1090 if (which_alternative == 2)
1092 if (ISA_HAS_MADD_MSUB && which_alternative != 0)
1094 return madd[which_alternative];
1096 [(set_attr "type" "imadd,imadd,multi")
1097 (set_attr "mode" "SI")
1098 (set_attr "length" "4,4,8")])
1100 ;; Split the above insn if we failed to get LO allocated.
1102 [(set (match_operand:SI 0 "register_operand")
1103 (plus:SI (mult:SI (match_operand:SI 1 "register_operand")
1104 (match_operand:SI 2 "register_operand"))
1105 (match_operand:SI 3 "register_operand")))
1106 (clobber (match_scratch:SI 4))
1107 (clobber (match_scratch:SI 5))
1108 (clobber (match_scratch:SI 6))]
1109 "reload_completed && !TARGET_DEBUG_D_MODE
1110 && GP_REG_P (true_regnum (operands[0]))
1111 && GP_REG_P (true_regnum (operands[3]))"
1112 [(parallel [(set (match_dup 6)
1113 (mult:SI (match_dup 1) (match_dup 2)))
1114 (clobber (match_dup 4))
1115 (clobber (match_dup 5))])
1116 (set (match_dup 0) (plus:SI (match_dup 6) (match_dup 3)))]
1119 ;; Splitter to copy result of MADD to a general register
1121 [(set (match_operand:SI 0 "register_operand")
1122 (plus:SI (mult:SI (match_operand:SI 1 "register_operand")
1123 (match_operand:SI 2 "register_operand"))
1124 (match_operand:SI 3 "register_operand")))
1125 (clobber (match_scratch:SI 4))
1126 (clobber (match_scratch:SI 5))
1127 (clobber (match_scratch:SI 6))]
1128 "reload_completed && !TARGET_DEBUG_D_MODE
1129 && GP_REG_P (true_regnum (operands[0]))
1130 && true_regnum (operands[3]) == LO_REGNUM"
1131 [(parallel [(set (match_dup 3)
1132 (plus:SI (mult:SI (match_dup 1) (match_dup 2))
1134 (clobber (match_dup 4))
1135 (clobber (match_dup 5))
1136 (clobber (match_dup 6))])
1137 (set (match_dup 0) (unspec:SI [(match_dup 5) (match_dup 4)] UNSPEC_MFHILO))]
1140 (define_insn "*macc"
1141 [(set (match_operand:SI 0 "register_operand" "=l,d")
1142 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d")
1143 (match_operand:SI 2 "register_operand" "d,d"))
1144 (match_operand:SI 3 "register_operand" "0,l")))
1145 (clobber (match_scratch:SI 4 "=h,h"))
1146 (clobber (match_scratch:SI 5 "=X,3"))]
1149 if (which_alternative == 1)
1150 return "macc\t%0,%1,%2";
1151 else if (TARGET_MIPS5500)
1152 return "madd\t%1,%2";
1154 /* The VR4130 assumes that there is a two-cycle latency between a macc
1155 that "writes" to $0 and an instruction that reads from it. We avoid
1156 this by assigning to $1 instead. */
1157 return "%[macc\t%@,%1,%2%]";
1159 [(set_attr "type" "imadd")
1160 (set_attr "mode" "SI")])
1162 (define_insn "*msac"
1163 [(set (match_operand:SI 0 "register_operand" "=l,d")
1164 (minus:SI (match_operand:SI 1 "register_operand" "0,l")
1165 (mult:SI (match_operand:SI 2 "register_operand" "d,d")
1166 (match_operand:SI 3 "register_operand" "d,d"))))
1167 (clobber (match_scratch:SI 4 "=h,h"))
1168 (clobber (match_scratch:SI 5 "=X,1"))]
1171 if (which_alternative == 1)
1172 return "msac\t%0,%2,%3";
1173 else if (TARGET_MIPS5500)
1174 return "msub\t%2,%3";
1176 return "msac\t$0,%2,%3";
1178 [(set_attr "type" "imadd")
1179 (set_attr "mode" "SI")])
1181 ;; An msac-like instruction implemented using negation and a macc.
1182 (define_insn_and_split "*msac_using_macc"
1183 [(set (match_operand:SI 0 "register_operand" "=l,d")
1184 (minus:SI (match_operand:SI 1 "register_operand" "0,l")
1185 (mult:SI (match_operand:SI 2 "register_operand" "d,d")
1186 (match_operand:SI 3 "register_operand" "d,d"))))
1187 (clobber (match_scratch:SI 4 "=h,h"))
1188 (clobber (match_scratch:SI 5 "=X,1"))
1189 (clobber (match_scratch:SI 6 "=d,d"))]
1190 "ISA_HAS_MACC && !ISA_HAS_MSAC"
1192 "&& reload_completed"
1194 (neg:SI (match_dup 3)))
1197 (plus:SI (mult:SI (match_dup 2)
1200 (clobber (match_dup 4))
1201 (clobber (match_dup 5))])]
1203 [(set_attr "type" "imadd")
1204 (set_attr "length" "8")])
1206 ;; Patterns generated by the define_peephole2 below.
1208 (define_insn "*macc2"
1209 [(set (match_operand:SI 0 "register_operand" "=l")
1210 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d")
1211 (match_operand:SI 2 "register_operand" "d"))
1213 (set (match_operand:SI 3 "register_operand" "=d")
1214 (plus:SI (mult:SI (match_dup 1)
1217 (clobber (match_scratch:SI 4 "=h"))]
1218 "ISA_HAS_MACC && reload_completed"
1220 [(set_attr "type" "imadd")
1221 (set_attr "mode" "SI")])
1223 (define_insn "*msac2"
1224 [(set (match_operand:SI 0 "register_operand" "=l")
1225 (minus:SI (match_dup 0)
1226 (mult:SI (match_operand:SI 1 "register_operand" "d")
1227 (match_operand:SI 2 "register_operand" "d"))))
1228 (set (match_operand:SI 3 "register_operand" "=d")
1229 (minus:SI (match_dup 0)
1230 (mult:SI (match_dup 1)
1232 (clobber (match_scratch:SI 4 "=h"))]
1233 "ISA_HAS_MSAC && reload_completed"
1235 [(set_attr "type" "imadd")
1236 (set_attr "mode" "SI")])
1238 ;; Convert macc $0,<r1>,<r2> & mflo <r3> into macc <r3>,<r1>,<r2>
1242 ;; Operand 1: macc/msac
1244 ;; Operand 3: GPR (destination)
1247 [(set (match_operand:SI 0 "register_operand")
1248 (match_operand:SI 1 "macc_msac_operand"))
1249 (clobber (match_operand:SI 2 "register_operand"))
1250 (clobber (scratch:SI))])
1251 (set (match_operand:SI 3 "register_operand")
1252 (unspec:SI [(match_dup 0) (match_dup 2)] UNSPEC_MFHILO))]
1254 [(parallel [(set (match_dup 0)
1258 (clobber (match_dup 2))])]
1261 ;; When we have a three-address multiplication instruction, it should
1262 ;; be faster to do a separate multiply and add, rather than moving
1263 ;; something into LO in order to use a macc instruction.
1265 ;; This peephole needs a scratch register to cater for the case when one
1266 ;; of the multiplication operands is the same as the destination.
1268 ;; Operand 0: GPR (scratch)
1270 ;; Operand 2: GPR (addend)
1271 ;; Operand 3: GPR (destination)
1272 ;; Operand 4: macc/msac
1274 ;; Operand 6: new multiplication
1275 ;; Operand 7: new addition/subtraction
1277 [(match_scratch:SI 0 "d")
1278 (set (match_operand:SI 1 "register_operand")
1279 (match_operand:SI 2 "register_operand"))
1282 [(set (match_operand:SI 3 "register_operand")
1283 (match_operand:SI 4 "macc_msac_operand"))
1284 (clobber (match_operand:SI 5 "register_operand"))
1285 (clobber (match_dup 1))])]
1287 && true_regnum (operands[1]) == LO_REGNUM
1288 && peep2_reg_dead_p (2, operands[1])
1289 && GP_REG_P (true_regnum (operands[3]))"
1290 [(parallel [(set (match_dup 0)
1292 (clobber (match_dup 5))
1293 (clobber (match_dup 1))])
1297 operands[6] = XEXP (operands[4], GET_CODE (operands[4]) == PLUS ? 0 : 1);
1298 operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[4]), SImode,
1299 operands[2], operands[0]);
1302 ;; Same as above, except LO is the initial target of the macc.
1304 ;; Operand 0: GPR (scratch)
1306 ;; Operand 2: GPR (addend)
1307 ;; Operand 3: macc/msac
1309 ;; Operand 5: GPR (destination)
1310 ;; Operand 6: new multiplication
1311 ;; Operand 7: new addition/subtraction
1313 [(match_scratch:SI 0 "d")
1314 (set (match_operand:SI 1 "register_operand")
1315 (match_operand:SI 2 "register_operand"))
1319 (match_operand:SI 3 "macc_msac_operand"))
1320 (clobber (match_operand:SI 4 "register_operand"))
1321 (clobber (scratch:SI))])
1323 (set (match_operand:SI 5 "register_operand")
1324 (unspec:SI [(match_dup 1) (match_dup 4)] UNSPEC_MFHILO))]
1325 "GENERATE_MULT3_SI && peep2_reg_dead_p (3, operands[1])"
1326 [(parallel [(set (match_dup 0)
1328 (clobber (match_dup 4))
1329 (clobber (match_dup 1))])
1333 operands[6] = XEXP (operands[4], GET_CODE (operands[4]) == PLUS ? 0 : 1);
1334 operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[4]), SImode,
1335 operands[2], operands[0]);
1338 (define_insn "*mul_sub_si"
1339 [(set (match_operand:SI 0 "register_operand" "=l,*d,*d")
1340 (minus:SI (match_operand:SI 1 "register_operand" "0,l,*d")
1341 (mult:SI (match_operand:SI 2 "register_operand" "d,d,d")
1342 (match_operand:SI 3 "register_operand" "d,d,d"))))
1343 (clobber (match_scratch:SI 4 "=h,h,h"))
1344 (clobber (match_scratch:SI 5 "=X,1,l"))
1345 (clobber (match_scratch:SI 6 "=X,X,&d"))]
1351 [(set_attr "type" "imadd,multi,multi")
1352 (set_attr "mode" "SI")
1353 (set_attr "length" "4,8,8")])
1355 ;; Split the above insn if we failed to get LO allocated.
1357 [(set (match_operand:SI 0 "register_operand")
1358 (minus:SI (match_operand:SI 1 "register_operand")
1359 (mult:SI (match_operand:SI 2 "register_operand")
1360 (match_operand:SI 3 "register_operand"))))
1361 (clobber (match_scratch:SI 4))
1362 (clobber (match_scratch:SI 5))
1363 (clobber (match_scratch:SI 6))]
1364 "reload_completed && !TARGET_DEBUG_D_MODE
1365 && GP_REG_P (true_regnum (operands[0]))
1366 && GP_REG_P (true_regnum (operands[1]))"
1367 [(parallel [(set (match_dup 6)
1368 (mult:SI (match_dup 2) (match_dup 3)))
1369 (clobber (match_dup 4))
1370 (clobber (match_dup 5))])
1371 (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 6)))]
1374 ;; Splitter to copy result of MSUB to a general register
1376 [(set (match_operand:SI 0 "register_operand")
1377 (minus:SI (match_operand:SI 1 "register_operand")
1378 (mult:SI (match_operand:SI 2 "register_operand")
1379 (match_operand:SI 3 "register_operand"))))
1380 (clobber (match_scratch:SI 4))
1381 (clobber (match_scratch:SI 5))
1382 (clobber (match_scratch:SI 6))]
1383 "reload_completed && !TARGET_DEBUG_D_MODE
1384 && GP_REG_P (true_regnum (operands[0]))
1385 && true_regnum (operands[1]) == LO_REGNUM"
1386 [(parallel [(set (match_dup 1)
1387 (minus:SI (match_dup 1)
1388 (mult:SI (match_dup 2) (match_dup 3))))
1389 (clobber (match_dup 4))
1390 (clobber (match_dup 5))
1391 (clobber (match_dup 6))])
1392 (set (match_dup 0) (unspec:SI [(match_dup 5) (match_dup 4)] UNSPEC_MFHILO))]
1395 (define_insn "*muls"
1396 [(set (match_operand:SI 0 "register_operand" "=l,d")
1397 (neg:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d")
1398 (match_operand:SI 2 "register_operand" "d,d"))))
1399 (clobber (match_scratch:SI 3 "=h,h"))
1400 (clobber (match_scratch:SI 4 "=X,l"))]
1405 [(set_attr "type" "imul,imul3")
1406 (set_attr "mode" "SI")])
1408 ;; ??? We could define a mulditi3 pattern when TARGET_64BIT.
1410 (define_expand "<u>mulsidi3"
1412 [(set (match_operand:DI 0 "register_operand")
1413 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand"))
1414 (any_extend:DI (match_operand:SI 2 "register_operand"))))
1415 (clobber (scratch:DI))
1416 (clobber (scratch:DI))
1417 (clobber (scratch:DI))])]
1418 "!TARGET_64BIT || !TARGET_FIX_R4000"
1422 if (!TARGET_FIX_R4000)
1423 emit_insn (gen_<u>mulsidi3_32bit_internal (operands[0], operands[1],
1426 emit_insn (gen_<u>mulsidi3_32bit_r4000 (operands[0], operands[1],
1432 (define_insn "<u>mulsidi3_32bit_internal"
1433 [(set (match_operand:DI 0 "register_operand" "=x")
1434 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1435 (any_extend:DI (match_operand:SI 2 "register_operand" "d"))))]
1436 "!TARGET_64BIT && !TARGET_FIX_R4000"
1438 [(set_attr "type" "imul")
1439 (set_attr "mode" "SI")])
1441 (define_insn "<u>mulsidi3_32bit_r4000"
1442 [(set (match_operand:DI 0 "register_operand" "=d")
1443 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1444 (any_extend:DI (match_operand:SI 2 "register_operand" "d"))))
1445 (clobber (match_scratch:DI 3 "=x"))]
1446 "!TARGET_64BIT && TARGET_FIX_R4000"
1447 "mult<u>\t%1,%2\;mflo\t%L0;mfhi\t%M0"
1448 [(set_attr "type" "imul")
1449 (set_attr "mode" "SI")
1450 (set_attr "length" "12")])
1452 (define_insn_and_split "*<u>mulsidi3_64bit"
1453 [(set (match_operand:DI 0 "register_operand" "=d")
1454 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1455 (any_extend:DI (match_operand:SI 2 "register_operand" "d"))))
1456 (clobber (match_scratch:DI 3 "=l"))
1457 (clobber (match_scratch:DI 4 "=h"))
1458 (clobber (match_scratch:DI 5 "=d"))]
1459 "TARGET_64BIT && !TARGET_FIX_R4000"
1461 "&& reload_completed"
1465 (mult:SI (match_dup 1)
1469 (mult:DI (any_extend:DI (match_dup 1))
1470 (any_extend:DI (match_dup 2)))
1473 ;; OP5 <- LO, OP0 <- HI
1474 (set (match_dup 5) (unspec:DI [(match_dup 3) (match_dup 4)] UNSPEC_MFHILO))
1475 (set (match_dup 0) (unspec:DI [(match_dup 4) (match_dup 3)] UNSPEC_MFHILO))
1479 (ashift:DI (match_dup 5)
1482 (lshiftrt:DI (match_dup 5)
1485 ;; Shift OP0 into place.
1487 (ashift:DI (match_dup 0)
1490 ;; OR the two halves together
1492 (ior:DI (match_dup 0)
1495 [(set_attr "type" "imul")
1496 (set_attr "mode" "SI")
1497 (set_attr "length" "24")])
1499 (define_insn "*<u>mulsidi3_64bit_parts"
1500 [(set (match_operand:DI 0 "register_operand" "=l")
1502 (mult:SI (match_operand:SI 2 "register_operand" "d")
1503 (match_operand:SI 3 "register_operand" "d"))))
1504 (set (match_operand:DI 1 "register_operand" "=h")
1506 (mult:DI (any_extend:DI (match_dup 2))
1507 (any_extend:DI (match_dup 3)))
1509 "TARGET_64BIT && !TARGET_FIX_R4000"
1511 [(set_attr "type" "imul")
1512 (set_attr "mode" "SI")])
1514 ;; Widening multiply with negation.
1515 (define_insn "*muls<u>_di"
1516 [(set (match_operand:DI 0 "register_operand" "=x")
1519 (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1520 (any_extend:DI (match_operand:SI 2 "register_operand" "d")))))]
1521 "!TARGET_64BIT && ISA_HAS_MULS"
1523 [(set_attr "type" "imul")
1524 (set_attr "mode" "SI")])
1526 (define_insn "*msac<u>_di"
1527 [(set (match_operand:DI 0 "register_operand" "=x")
1529 (match_operand:DI 3 "register_operand" "0")
1531 (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1532 (any_extend:DI (match_operand:SI 2 "register_operand" "d")))))]
1533 "!TARGET_64BIT && ISA_HAS_MSAC"
1535 if (TARGET_MIPS5500)
1536 return "msub<u>\t%1,%2";
1538 return "msac<u>\t$0,%1,%2";
1540 [(set_attr "type" "imadd")
1541 (set_attr "mode" "SI")])
1543 ;; _highpart patterns
1545 (define_expand "<su>mulsi3_highpart"
1546 [(set (match_operand:SI 0 "register_operand")
1549 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand"))
1550 (any_extend:DI (match_operand:SI 2 "register_operand")))
1552 "ISA_HAS_MULHI || !TARGET_FIX_R4000"
1555 emit_insn (gen_<su>mulsi3_highpart_mulhi_internal (operands[0],
1559 emit_insn (gen_<su>mulsi3_highpart_internal (operands[0], operands[1],
1564 (define_insn "<su>mulsi3_highpart_internal"
1565 [(set (match_operand:SI 0 "register_operand" "=h")
1568 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1569 (any_extend:DI (match_operand:SI 2 "register_operand" "d")))
1571 (clobber (match_scratch:SI 3 "=l"))]
1572 "!ISA_HAS_MULHI && !TARGET_FIX_R4000"
1574 [(set_attr "type" "imul")
1575 (set_attr "mode" "SI")])
1577 (define_insn "<su>mulsi3_highpart_mulhi_internal"
1578 [(set (match_operand:SI 0 "register_operand" "=h,d")
1582 (any_extend:DI (match_operand:SI 1 "register_operand" "d,d"))
1583 (any_extend:DI (match_operand:SI 2 "register_operand" "d,d")))
1585 (clobber (match_scratch:SI 3 "=l,l"))
1586 (clobber (match_scratch:SI 4 "=X,h"))]
1591 [(set_attr "type" "imul,imul3")
1592 (set_attr "mode" "SI")])
1594 (define_insn "*<su>mulsi3_highpart_neg_mulhi_internal"
1595 [(set (match_operand:SI 0 "register_operand" "=h,d")
1600 (any_extend:DI (match_operand:SI 1 "register_operand" "d,d"))
1601 (any_extend:DI (match_operand:SI 2 "register_operand" "d,d"))))
1603 (clobber (match_scratch:SI 3 "=l,l"))
1604 (clobber (match_scratch:SI 4 "=X,h"))]
1608 mulshi<u>\t%0,%1,%2"
1609 [(set_attr "type" "imul,imul3")
1610 (set_attr "mode" "SI")])
1612 ;; Disable unsigned multiplication for -mfix-vr4120. This is for VR4120
1613 ;; errata MD(0), which says that dmultu does not always produce the
1615 (define_insn "<su>muldi3_highpart"
1616 [(set (match_operand:DI 0 "register_operand" "=h")
1620 (any_extend:TI (match_operand:DI 1 "register_operand" "d"))
1621 (any_extend:TI (match_operand:DI 2 "register_operand" "d")))
1623 (clobber (match_scratch:DI 3 "=l"))]
1624 "TARGET_64BIT && !TARGET_FIX_R4000
1625 && !(<CODE> == ZERO_EXTEND && TARGET_FIX_VR4120)"
1627 [(set_attr "type" "imul")
1628 (set_attr "mode" "DI")])
1630 ;; The R4650 supports a 32 bit multiply/ 64 bit accumulate
1631 ;; instruction. The HI/LO registers are used as a 64 bit accumulator.
1633 (define_insn "madsi"
1634 [(set (match_operand:SI 0 "register_operand" "+l")
1635 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d")
1636 (match_operand:SI 2 "register_operand" "d"))
1638 (clobber (match_scratch:SI 3 "=h"))]
1641 [(set_attr "type" "imadd")
1642 (set_attr "mode" "SI")])
1644 (define_insn "*<su>mul_acc_di"
1645 [(set (match_operand:DI 0 "register_operand" "=x")
1647 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1648 (any_extend:DI (match_operand:SI 2 "register_operand" "d")))
1649 (match_operand:DI 3 "register_operand" "0")))]
1650 "(TARGET_MAD || ISA_HAS_MACC)
1654 return "mad<u>\t%1,%2";
1655 else if (TARGET_MIPS5500)
1656 return "madd<u>\t%1,%2";
1658 /* See comment in *macc. */
1659 return "%[macc<u>\t%@,%1,%2%]";
1661 [(set_attr "type" "imadd")
1662 (set_attr "mode" "SI")])
1664 ;; Floating point multiply accumulate instructions.
1666 (define_insn "*madd<mode>"
1667 [(set (match_operand:ANYF 0 "register_operand" "=f")
1668 (plus:ANYF (mult:ANYF (match_operand:ANYF 1 "register_operand" "f")
1669 (match_operand:ANYF 2 "register_operand" "f"))
1670 (match_operand:ANYF 3 "register_operand" "f")))]
1671 "ISA_HAS_FP4 && TARGET_FUSED_MADD"
1672 "madd.<fmt>\t%0,%3,%1,%2"
1673 [(set_attr "type" "fmadd")
1674 (set_attr "mode" "<UNITMODE>")])
1676 (define_insn "*msub<mode>"
1677 [(set (match_operand:ANYF 0 "register_operand" "=f")
1678 (minus:ANYF (mult:ANYF (match_operand:ANYF 1 "register_operand" "f")
1679 (match_operand:ANYF 2 "register_operand" "f"))
1680 (match_operand:ANYF 3 "register_operand" "f")))]
1681 "ISA_HAS_FP4 && TARGET_FUSED_MADD"
1682 "msub.<fmt>\t%0,%3,%1,%2"
1683 [(set_attr "type" "fmadd")
1684 (set_attr "mode" "<UNITMODE>")])
1686 (define_insn "*nmadd<mode>"
1687 [(set (match_operand:ANYF 0 "register_operand" "=f")
1688 (neg:ANYF (plus:ANYF
1689 (mult:ANYF (match_operand:ANYF 1 "register_operand" "f")
1690 (match_operand:ANYF 2 "register_operand" "f"))
1691 (match_operand:ANYF 3 "register_operand" "f"))))]
1692 "ISA_HAS_NMADD_NMSUB && TARGET_FUSED_MADD
1693 && HONOR_SIGNED_ZEROS (<MODE>mode)"
1694 "nmadd.<fmt>\t%0,%3,%1,%2"
1695 [(set_attr "type" "fmadd")
1696 (set_attr "mode" "<UNITMODE>")])
1698 (define_insn "*nmadd<mode>_fastmath"
1699 [(set (match_operand:ANYF 0 "register_operand" "=f")
1701 (mult:ANYF (neg:ANYF (match_operand:ANYF 1 "register_operand" "f"))
1702 (match_operand:ANYF 2 "register_operand" "f"))
1703 (match_operand:ANYF 3 "register_operand" "f")))]
1704 "ISA_HAS_NMADD_NMSUB && TARGET_FUSED_MADD
1705 && !HONOR_SIGNED_ZEROS (<MODE>mode)"
1706 "nmadd.<fmt>\t%0,%3,%1,%2"
1707 [(set_attr "type" "fmadd")
1708 (set_attr "mode" "<UNITMODE>")])
1710 (define_insn "*nmsub<mode>"
1711 [(set (match_operand:ANYF 0 "register_operand" "=f")
1712 (neg:ANYF (minus:ANYF
1713 (mult:ANYF (match_operand:ANYF 2 "register_operand" "f")
1714 (match_operand:ANYF 3 "register_operand" "f"))
1715 (match_operand:ANYF 1 "register_operand" "f"))))]
1716 "ISA_HAS_NMADD_NMSUB && TARGET_FUSED_MADD
1717 && HONOR_SIGNED_ZEROS (<MODE>mode)"
1718 "nmsub.<fmt>\t%0,%1,%2,%3"
1719 [(set_attr "type" "fmadd")
1720 (set_attr "mode" "<UNITMODE>")])
1722 (define_insn "*nmsub<mode>_fastmath"
1723 [(set (match_operand:ANYF 0 "register_operand" "=f")
1725 (match_operand:ANYF 1 "register_operand" "f")
1726 (mult:ANYF (match_operand:ANYF 2 "register_operand" "f")
1727 (match_operand:ANYF 3 "register_operand" "f"))))]
1728 "ISA_HAS_NMADD_NMSUB && TARGET_FUSED_MADD
1729 && !HONOR_SIGNED_ZEROS (<MODE>mode)"
1730 "nmsub.<fmt>\t%0,%1,%2,%3"
1731 [(set_attr "type" "fmadd")
1732 (set_attr "mode" "<UNITMODE>")])
1735 ;; ....................
1737 ;; DIVISION and REMAINDER
1739 ;; ....................
1742 (define_expand "div<mode>3"
1743 [(set (match_operand:ANYF 0 "register_operand")
1744 (div:ANYF (match_operand:ANYF 1 "reg_or_1_operand")
1745 (match_operand:ANYF 2 "register_operand")))]
1746 "<divide_condition>"
1748 if (const_1_operand (operands[1], <MODE>mode))
1749 if (!(ISA_HAS_FP4 && flag_unsafe_math_optimizations))
1750 operands[1] = force_reg (<MODE>mode, operands[1]);
1753 ;; These patterns work around the early SB-1 rev2 core "F1" erratum:
1755 ;; If an mfc1 or dmfc1 happens to access the floating point register
1756 ;; file at the same time a long latency operation (div, sqrt, recip,
1757 ;; sqrt) iterates an intermediate result back through the floating
1758 ;; point register file bypass, then instead returning the correct
1759 ;; register value the mfc1 or dmfc1 operation returns the intermediate
1760 ;; result of the long latency operation.
1762 ;; The workaround is to insert an unconditional 'mov' from/to the
1763 ;; long latency op destination register.
1765 (define_insn "*div<mode>3"
1766 [(set (match_operand:ANYF 0 "register_operand" "=f")
1767 (div:ANYF (match_operand:ANYF 1 "register_operand" "f")
1768 (match_operand:ANYF 2 "register_operand" "f")))]
1769 "<divide_condition>"
1772 return "div.<fmt>\t%0,%1,%2\;mov.<fmt>\t%0,%0";
1774 return "div.<fmt>\t%0,%1,%2";
1776 [(set_attr "type" "fdiv")
1777 (set_attr "mode" "<UNITMODE>")
1778 (set (attr "length")
1779 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
1783 (define_insn "*recip<mode>3"
1784 [(set (match_operand:ANYF 0 "register_operand" "=f")
1785 (div:ANYF (match_operand:ANYF 1 "const_1_operand" "")
1786 (match_operand:ANYF 2 "register_operand" "f")))]
1787 "<recip_condition> && flag_unsafe_math_optimizations"
1790 return "recip.<fmt>\t%0,%2\;mov.<fmt>\t%0,%0";
1792 return "recip.<fmt>\t%0,%2";
1794 [(set_attr "type" "frdiv")
1795 (set_attr "mode" "<UNITMODE>")
1796 (set (attr "length")
1797 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
1801 ;; VR4120 errata MD(A1): signed division instructions do not work correctly
1802 ;; with negative operands. We use special libgcc functions instead.
1803 (define_insn "divmod<mode>4"
1804 [(set (match_operand:GPR 0 "register_operand" "=l")
1805 (div:GPR (match_operand:GPR 1 "register_operand" "d")
1806 (match_operand:GPR 2 "register_operand" "d")))
1807 (set (match_operand:GPR 3 "register_operand" "=h")
1808 (mod:GPR (match_dup 1)
1810 "!TARGET_FIX_VR4120"
1811 { return mips_output_division ("<d>div\t$0,%1,%2", operands); }
1812 [(set_attr "type" "idiv")
1813 (set_attr "mode" "<MODE>")])
1815 (define_insn "udivmod<mode>4"
1816 [(set (match_operand:GPR 0 "register_operand" "=l")
1817 (udiv:GPR (match_operand:GPR 1 "register_operand" "d")
1818 (match_operand:GPR 2 "register_operand" "d")))
1819 (set (match_operand:GPR 3 "register_operand" "=h")
1820 (umod:GPR (match_dup 1)
1823 { return mips_output_division ("<d>divu\t$0,%1,%2", operands); }
1824 [(set_attr "type" "idiv")
1825 (set_attr "mode" "<MODE>")])
1828 ;; ....................
1832 ;; ....................
1834 ;; These patterns work around the early SB-1 rev2 core "F1" erratum (see
1835 ;; "*div[sd]f3" comment for details).
1837 (define_insn "sqrt<mode>2"
1838 [(set (match_operand:ANYF 0 "register_operand" "=f")
1839 (sqrt:ANYF (match_operand:ANYF 1 "register_operand" "f")))]
1843 return "sqrt.<fmt>\t%0,%1\;mov.<fmt>\t%0,%0";
1845 return "sqrt.<fmt>\t%0,%1";
1847 [(set_attr "type" "fsqrt")
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 "*rsqrt<mode>a"
1855 [(set (match_operand:ANYF 0 "register_operand" "=f")
1856 (div:ANYF (match_operand:ANYF 1 "const_1_operand" "")
1857 (sqrt:ANYF (match_operand:ANYF 2 "register_operand" "f"))))]
1858 "<recip_condition> && flag_unsafe_math_optimizations"
1861 return "rsqrt.<fmt>\t%0,%2\;mov.<fmt>\t%0,%0";
1863 return "rsqrt.<fmt>\t%0,%2";
1865 [(set_attr "type" "frsqrt")
1866 (set_attr "mode" "<UNITMODE>")
1867 (set (attr "length")
1868 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
1872 (define_insn "*rsqrt<mode>b"
1873 [(set (match_operand:ANYF 0 "register_operand" "=f")
1874 (sqrt:ANYF (div:ANYF (match_operand:ANYF 1 "const_1_operand" "")
1875 (match_operand:ANYF 2 "register_operand" "f"))))]
1876 "<recip_condition> && flag_unsafe_math_optimizations"
1879 return "rsqrt.<fmt>\t%0,%2\;mov.<fmt>\t%0,%0";
1881 return "rsqrt.<fmt>\t%0,%2";
1883 [(set_attr "type" "frsqrt")
1884 (set_attr "mode" "<UNITMODE>")
1885 (set (attr "length")
1886 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
1891 ;; ....................
1895 ;; ....................
1897 ;; Do not use the integer abs macro instruction, since that signals an
1898 ;; exception on -2147483648 (sigh).
1900 (define_insn "abs<mode>2"
1901 [(set (match_operand:GPR 0 "register_operand" "=d")
1902 (abs:GPR (match_operand:GPR 1 "register_operand" "d")))]
1905 if (REGNO (operands[0]) == REGNO (operands[1]) && GENERATE_BRANCHLIKELY)
1906 return "%(bltzl\t%1,1f\;<d>subu\t%0,%.,%0\n%~1:%)";
1908 return "%(bgez\t%1,1f\;move\t%0,%1\;<d>subu\t%0,%.,%0\n%~1:%)";
1910 [(set_attr "type" "multi")
1911 (set_attr "mode" "<MODE>")
1912 (set_attr "length" "12")])
1914 (define_insn "abs<mode>2"
1915 [(set (match_operand:ANYF 0 "register_operand" "=f")
1916 (abs:ANYF (match_operand:ANYF 1 "register_operand" "f")))]
1919 [(set_attr "type" "fabs")
1920 (set_attr "mode" "<UNITMODE>")])
1923 ;; ....................
1925 ;; FIND FIRST BIT INSTRUCTION
1927 ;; ....................
1930 (define_insn "ffs<mode>2"
1931 [(set (match_operand:GPR 0 "register_operand" "=&d")
1932 (ffs:GPR (match_operand:GPR 1 "register_operand" "d")))
1933 (clobber (match_scratch:GPR 2 "=&d"))
1934 (clobber (match_scratch:GPR 3 "=&d"))]
1937 if (optimize && find_reg_note (insn, REG_DEAD, operands[1]))
1941 %~1:\tand\t%2,%1,0x0001\;\
1951 %~1:\tand\t%2,%3,0x0001\;\
1957 [(set_attr "type" "multi")
1958 (set_attr "mode" "<MODE>")
1959 (set_attr "length" "28")])
1962 ;; ...................
1964 ;; Count leading zeroes.
1966 ;; ...................
1969 (define_insn "clz<mode>2"
1970 [(set (match_operand:GPR 0 "register_operand" "=d")
1971 (clz:GPR (match_operand:GPR 1 "register_operand" "d")))]
1974 [(set_attr "type" "clz")
1975 (set_attr "mode" "<MODE>")])
1978 ;; ....................
1980 ;; NEGATION and ONE'S COMPLEMENT
1982 ;; ....................
1984 (define_insn "negsi2"
1985 [(set (match_operand:SI 0 "register_operand" "=d")
1986 (neg:SI (match_operand:SI 1 "register_operand" "d")))]
1990 return "neg\t%0,%1";
1992 return "subu\t%0,%.,%1";
1994 [(set_attr "type" "arith")
1995 (set_attr "mode" "SI")])
1997 (define_insn "negdi2"
1998 [(set (match_operand:DI 0 "register_operand" "=d")
1999 (neg:DI (match_operand:DI 1 "register_operand" "d")))]
2000 "TARGET_64BIT && !TARGET_MIPS16"
2002 [(set_attr "type" "arith")
2003 (set_attr "mode" "DI")])
2005 (define_insn "neg<mode>2"
2006 [(set (match_operand:ANYF 0 "register_operand" "=f")
2007 (neg:ANYF (match_operand:ANYF 1 "register_operand" "f")))]
2010 [(set_attr "type" "fneg")
2011 (set_attr "mode" "<UNITMODE>")])
2013 (define_insn "one_cmpl<mode>2"
2014 [(set (match_operand:GPR 0 "register_operand" "=d")
2015 (not:GPR (match_operand:GPR 1 "register_operand" "d")))]
2019 return "not\t%0,%1";
2021 return "nor\t%0,%.,%1";
2023 [(set_attr "type" "arith")
2024 (set_attr "mode" "<MODE>")])
2027 ;; ....................
2031 ;; ....................
2034 ;; Many of these instructions use trivial define_expands, because we
2035 ;; want to use a different set of constraints when TARGET_MIPS16.
2037 (define_expand "and<mode>3"
2038 [(set (match_operand:GPR 0 "register_operand")
2039 (and:GPR (match_operand:GPR 1 "register_operand")
2040 (match_operand:GPR 2 "uns_arith_operand")))]
2044 operands[2] = force_reg (<MODE>mode, operands[2]);
2047 (define_insn "*and<mode>3"
2048 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2049 (and:GPR (match_operand:GPR 1 "register_operand" "%d,d")
2050 (match_operand:GPR 2 "uns_arith_operand" "d,K")))]
2055 [(set_attr "type" "arith")
2056 (set_attr "mode" "<MODE>")])
2058 (define_insn "*and<mode>3_mips16"
2059 [(set (match_operand:GPR 0 "register_operand" "=d")
2060 (and:GPR (match_operand:GPR 1 "register_operand" "%0")
2061 (match_operand:GPR 2 "register_operand" "d")))]
2064 [(set_attr "type" "arith")
2065 (set_attr "mode" "<MODE>")])
2067 (define_expand "ior<mode>3"
2068 [(set (match_operand:GPR 0 "register_operand")
2069 (ior:GPR (match_operand:GPR 1 "register_operand")
2070 (match_operand:GPR 2 "uns_arith_operand")))]
2074 operands[2] = force_reg (<MODE>mode, operands[2]);
2077 (define_insn "*ior<mode>3"
2078 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2079 (ior:GPR (match_operand:GPR 1 "register_operand" "%d,d")
2080 (match_operand:GPR 2 "uns_arith_operand" "d,K")))]
2085 [(set_attr "type" "arith")
2086 (set_attr "mode" "<MODE>")])
2088 (define_insn "*ior<mode>3_mips16"
2089 [(set (match_operand:GPR 0 "register_operand" "=d")
2090 (ior:GPR (match_operand:GPR 1 "register_operand" "%0")
2091 (match_operand:GPR 2 "register_operand" "d")))]
2094 [(set_attr "type" "arith")
2095 (set_attr "mode" "<MODE>")])
2097 (define_expand "xor<mode>3"
2098 [(set (match_operand:GPR 0 "register_operand")
2099 (xor:GPR (match_operand:GPR 1 "register_operand")
2100 (match_operand:GPR 2 "uns_arith_operand")))]
2105 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2106 (xor:GPR (match_operand:GPR 1 "register_operand" "%d,d")
2107 (match_operand:GPR 2 "uns_arith_operand" "d,K")))]
2112 [(set_attr "type" "arith")
2113 (set_attr "mode" "<MODE>")])
2116 [(set (match_operand:GPR 0 "register_operand" "=d,t,t")
2117 (xor:GPR (match_operand:GPR 1 "register_operand" "%0,d,d")
2118 (match_operand:GPR 2 "uns_arith_operand" "d,K,d")))]
2124 [(set_attr "type" "arith")
2125 (set_attr "mode" "<MODE>")
2126 (set_attr_alternative "length"
2128 (if_then_else (match_operand:VOID 2 "m16_uimm8_1")
2133 (define_insn "*nor<mode>3"
2134 [(set (match_operand:GPR 0 "register_operand" "=d")
2135 (and:GPR (not:GPR (match_operand:GPR 1 "register_operand" "d"))
2136 (not:GPR (match_operand:GPR 2 "register_operand" "d"))))]
2139 [(set_attr "type" "arith")
2140 (set_attr "mode" "<MODE>")])
2143 ;; ....................
2147 ;; ....................
2151 (define_insn "truncdfsf2"
2152 [(set (match_operand:SF 0 "register_operand" "=f")
2153 (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
2154 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2156 [(set_attr "type" "fcvt")
2157 (set_attr "cnv_mode" "D2S")
2158 (set_attr "mode" "SF")])
2160 ;; Integer truncation patterns. Truncating SImode values to smaller
2161 ;; modes is a no-op, as it is for most other GCC ports. Truncating
2162 ;; DImode values to SImode is not a no-op for TARGET_64BIT since we
2163 ;; need to make sure that the lower 32 bits are properly sign-extended
2164 ;; (see TRULY_NOOP_TRUNCATION). Truncating DImode values into modes
2165 ;; smaller than SImode is equivalent to two separate truncations:
2168 ;; DI ---> HI == DI ---> SI ---> HI
2169 ;; DI ---> QI == DI ---> SI ---> QI
2171 ;; Step A needs a real instruction but step B does not.
2173 (define_insn "truncdisi2"
2174 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,m")
2175 (truncate:SI (match_operand:DI 1 "register_operand" "d,d")))]
2180 [(set_attr "type" "shift,store")
2181 (set_attr "mode" "SI")
2182 (set_attr "extended_mips16" "yes,*")])
2184 (define_insn "truncdihi2"
2185 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,m")
2186 (truncate:HI (match_operand:DI 1 "register_operand" "d,d")))]
2191 [(set_attr "type" "shift,store")
2192 (set_attr "mode" "SI")
2193 (set_attr "extended_mips16" "yes,*")])
2195 (define_insn "truncdiqi2"
2196 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,m")
2197 (truncate:QI (match_operand:DI 1 "register_operand" "d,d")))]
2202 [(set_attr "type" "shift,store")
2203 (set_attr "mode" "SI")
2204 (set_attr "extended_mips16" "yes,*")])
2206 ;; Combiner patterns to optimize shift/truncate combinations.
2209 [(set (match_operand:SI 0 "register_operand" "=d")
2211 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
2212 (match_operand:DI 2 "const_arith_operand" ""))))]
2213 "TARGET_64BIT && !TARGET_MIPS16 && INTVAL (operands[2]) >= 32"
2215 [(set_attr "type" "shift")
2216 (set_attr "mode" "SI")])
2219 [(set (match_operand:SI 0 "register_operand" "=d")
2220 (truncate:SI (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
2222 "TARGET_64BIT && !TARGET_MIPS16"
2224 [(set_attr "type" "shift")
2225 (set_attr "mode" "SI")])
2228 ;; Combiner patterns for truncate/sign_extend combinations. They use
2229 ;; the shift/truncate patterns above.
2231 (define_insn_and_split ""
2232 [(set (match_operand:SI 0 "register_operand" "=d")
2234 (truncate:HI (match_operand:DI 1 "register_operand" "d"))))]
2235 "TARGET_64BIT && !TARGET_MIPS16"
2237 "&& reload_completed"
2239 (ashift:DI (match_dup 1)
2242 (truncate:SI (ashiftrt:DI (match_dup 2)
2244 { operands[2] = gen_lowpart (DImode, operands[0]); })
2246 (define_insn_and_split ""
2247 [(set (match_operand:SI 0 "register_operand" "=d")
2249 (truncate:QI (match_operand:DI 1 "register_operand" "d"))))]
2250 "TARGET_64BIT && !TARGET_MIPS16"
2252 "&& reload_completed"
2254 (ashift:DI (match_dup 1)
2257 (truncate:SI (ashiftrt:DI (match_dup 2)
2259 { operands[2] = gen_lowpart (DImode, operands[0]); })
2262 ;; Combiner patterns to optimize truncate/zero_extend combinations.
2265 [(set (match_operand:SI 0 "register_operand" "=d")
2266 (zero_extend:SI (truncate:HI
2267 (match_operand:DI 1 "register_operand" "d"))))]
2268 "TARGET_64BIT && !TARGET_MIPS16"
2269 "andi\t%0,%1,0xffff"
2270 [(set_attr "type" "arith")
2271 (set_attr "mode" "SI")])
2274 [(set (match_operand:SI 0 "register_operand" "=d")
2275 (zero_extend:SI (truncate:QI
2276 (match_operand:DI 1 "register_operand" "d"))))]
2277 "TARGET_64BIT && !TARGET_MIPS16"
2279 [(set_attr "type" "arith")
2280 (set_attr "mode" "SI")])
2283 [(set (match_operand:HI 0 "register_operand" "=d")
2284 (zero_extend:HI (truncate:QI
2285 (match_operand:DI 1 "register_operand" "d"))))]
2286 "TARGET_64BIT && !TARGET_MIPS16"
2288 [(set_attr "type" "arith")
2289 (set_attr "mode" "HI")])
2292 ;; ....................
2296 ;; ....................
2300 (define_insn_and_split "zero_extendsidi2"
2301 [(set (match_operand:DI 0 "register_operand" "=d,d")
2302 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,W")))]
2307 "&& reload_completed && REG_P (operands[1])"
2309 (ashift:DI (match_dup 1) (const_int 32)))
2311 (lshiftrt:DI (match_dup 0) (const_int 32)))]
2312 { operands[1] = gen_lowpart (DImode, operands[1]); }
2313 [(set_attr "type" "multi,load")
2314 (set_attr "mode" "DI")
2315 (set_attr "length" "8,*")])
2317 (define_expand "zero_extend<SHORT:mode><GPR:mode>2"
2318 [(set (match_operand:GPR 0 "register_operand")
2319 (zero_extend:GPR (match_operand:SHORT 1 "nonimmediate_operand")))]
2322 if (TARGET_MIPS16 && !GENERATE_MIPS16E
2323 && !memory_operand (operands[1], <SHORT:MODE>mode))
2325 emit_insn (gen_and<GPR:mode>3 (operands[0],
2326 gen_lowpart (<GPR:MODE>mode, operands[1]),
2327 force_reg (<GPR:MODE>mode,
2328 GEN_INT (<SHORT:mask>))));
2333 (define_insn "*zero_extend<SHORT:mode><GPR:mode>2"
2334 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2336 (match_operand:SHORT 1 "nonimmediate_operand" "d,m")))]
2339 andi\t%0,%1,<SHORT:mask>
2340 l<SHORT:size>u\t%0,%1"
2341 [(set_attr "type" "arith,load")
2342 (set_attr "mode" "<GPR:MODE>")])
2344 (define_insn "*zero_extend<SHORT:mode><GPR:mode>2_mips16e"
2345 [(set (match_operand:GPR 0 "register_operand" "=d")
2346 (zero_extend:GPR (match_operand:SHORT 1 "register_operand" "0")))]
2348 "ze<SHORT:size>\t%0"
2349 [(set_attr "type" "arith")
2350 (set_attr "mode" "<GPR:MODE>")])
2352 (define_insn "*zero_extend<SHORT:mode><GPR:mode>2_mips16"
2353 [(set (match_operand:GPR 0 "register_operand" "=d")
2354 (zero_extend:GPR (match_operand:SHORT 1 "memory_operand" "m")))]
2356 "l<SHORT:size>u\t%0,%1"
2357 [(set_attr "type" "load")
2358 (set_attr "mode" "<GPR:MODE>")])
2360 (define_expand "zero_extendqihi2"
2361 [(set (match_operand:HI 0 "register_operand")
2362 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand")))]
2365 if (TARGET_MIPS16 && !memory_operand (operands[1], QImode))
2367 emit_insn (gen_zero_extendqisi2 (gen_lowpart (SImode, operands[0]),
2373 (define_insn "*zero_extendqihi2"
2374 [(set (match_operand:HI 0 "register_operand" "=d,d")
2375 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
2380 [(set_attr "type" "arith,load")
2381 (set_attr "mode" "HI")])
2383 (define_insn "*zero_extendqihi2_mips16"
2384 [(set (match_operand:HI 0 "register_operand" "=d")
2385 (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
2388 [(set_attr "type" "load")
2389 (set_attr "mode" "HI")])
2392 ;; ....................
2396 ;; ....................
2399 ;; Those for integer source operand are ordered widest source type first.
2401 ;; When TARGET_64BIT, all SImode integer registers should already be in
2402 ;; sign-extended form (see TRULY_NOOP_TRUNCATION and truncdisi2). We can
2403 ;; therefore get rid of register->register instructions if we constrain
2404 ;; the source to be in the same register as the destination.
2406 ;; The register alternative has type "arith" so that the pre-reload
2407 ;; scheduler will treat it as a move. This reflects what happens if
2408 ;; the register alternative needs a reload.
2409 (define_insn_and_split "extendsidi2"
2410 [(set (match_operand:DI 0 "register_operand" "=d,d")
2411 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "0,m")))]
2416 "&& reload_completed && register_operand (operands[1], VOIDmode)"
2419 emit_note (NOTE_INSN_DELETED);
2422 [(set_attr "type" "arith,load")
2423 (set_attr "mode" "DI")])
2425 (define_expand "extend<SHORT:mode><GPR:mode>2"
2426 [(set (match_operand:GPR 0 "register_operand")
2427 (sign_extend:GPR (match_operand:SHORT 1 "nonimmediate_operand")))]
2430 (define_insn "*extend<SHORT:mode><GPR:mode>2_mips16e"
2431 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2432 (sign_extend:GPR (match_operand:SHORT 1 "nonimmediate_operand" "0,m")))]
2436 l<SHORT:size>\t%0,%1"
2437 [(set_attr "type" "arith,load")
2438 (set_attr "mode" "<GPR:MODE>")])
2440 (define_insn_and_split "*extend<SHORT:mode><GPR:mode>2"
2441 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2443 (match_operand:SHORT 1 "nonimmediate_operand" "d,m")))]
2444 "!ISA_HAS_SEB_SEH && !GENERATE_MIPS16E"
2447 l<SHORT:size>\t%0,%1"
2448 "&& reload_completed && REG_P (operands[1])"
2449 [(set (match_dup 0) (ashift:GPR (match_dup 1) (match_dup 2)))
2450 (set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))]
2452 operands[1] = gen_lowpart (<GPR:MODE>mode, operands[1]);
2453 operands[2] = GEN_INT (GET_MODE_BITSIZE (<GPR:MODE>mode)
2454 - GET_MODE_BITSIZE (<SHORT:MODE>mode));
2456 [(set_attr "type" "arith,load")
2457 (set_attr "mode" "<GPR:MODE>")
2458 (set_attr "length" "8,*")])
2460 (define_insn "*extend<SHORT:mode><GPR:mode>2_se<SHORT:size>"
2461 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2463 (match_operand:SHORT 1 "nonimmediate_operand" "d,m")))]
2466 se<SHORT:size>\t%0,%1
2467 l<SHORT:size>\t%0,%1"
2468 [(set_attr "type" "arith,load")
2469 (set_attr "mode" "<GPR:MODE>")])
2471 ;; This pattern generates the same code as extendqisi2; split it into
2472 ;; that form after reload.
2473 (define_insn_and_split "extendqihi2"
2474 [(set (match_operand:HI 0 "register_operand" "=d,d")
2475 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
2479 [(set (match_dup 0) (sign_extend:SI (match_dup 1)))]
2480 { operands[0] = gen_lowpart (SImode, operands[0]); }
2481 [(set_attr "type" "arith,load")
2482 (set_attr "mode" "SI")
2483 (set_attr "length" "8,*")])
2485 (define_insn "extendsfdf2"
2486 [(set (match_operand:DF 0 "register_operand" "=f")
2487 (float_extend:DF (match_operand:SF 1 "register_operand" "f")))]
2488 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2490 [(set_attr "type" "fcvt")
2491 (set_attr "cnv_mode" "S2D")
2492 (set_attr "mode" "DF")])
2495 ;; ....................
2499 ;; ....................
2501 (define_expand "fix_truncdfsi2"
2502 [(set (match_operand:SI 0 "register_operand")
2503 (fix:SI (match_operand:DF 1 "register_operand")))]
2504 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2506 if (!ISA_HAS_TRUNC_W)
2508 emit_insn (gen_fix_truncdfsi2_macro (operands[0], operands[1]));
2513 (define_insn "fix_truncdfsi2_insn"
2514 [(set (match_operand:SI 0 "register_operand" "=f")
2515 (fix:SI (match_operand:DF 1 "register_operand" "f")))]
2516 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && ISA_HAS_TRUNC_W"
2518 [(set_attr "type" "fcvt")
2519 (set_attr "mode" "DF")
2520 (set_attr "cnv_mode" "D2I")
2521 (set_attr "length" "4")])
2523 (define_insn "fix_truncdfsi2_macro"
2524 [(set (match_operand:SI 0 "register_operand" "=f")
2525 (fix:SI (match_operand:DF 1 "register_operand" "f")))
2526 (clobber (match_scratch:DF 2 "=d"))]
2527 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !ISA_HAS_TRUNC_W"
2530 return ".set\tmacro\;trunc.w.d %0,%1,%2\;.set\tnomacro";
2532 return "trunc.w.d %0,%1,%2";
2534 [(set_attr "type" "fcvt")
2535 (set_attr "mode" "DF")
2536 (set_attr "cnv_mode" "D2I")
2537 (set_attr "length" "36")])
2539 (define_expand "fix_truncsfsi2"
2540 [(set (match_operand:SI 0 "register_operand")
2541 (fix:SI (match_operand:SF 1 "register_operand")))]
2544 if (!ISA_HAS_TRUNC_W)
2546 emit_insn (gen_fix_truncsfsi2_macro (operands[0], operands[1]));
2551 (define_insn "fix_truncsfsi2_insn"
2552 [(set (match_operand:SI 0 "register_operand" "=f")
2553 (fix:SI (match_operand:SF 1 "register_operand" "f")))]
2554 "TARGET_HARD_FLOAT && ISA_HAS_TRUNC_W"
2556 [(set_attr "type" "fcvt")
2557 (set_attr "mode" "SF")
2558 (set_attr "cnv_mode" "S2I")
2559 (set_attr "length" "4")])
2561 (define_insn "fix_truncsfsi2_macro"
2562 [(set (match_operand:SI 0 "register_operand" "=f")
2563 (fix:SI (match_operand:SF 1 "register_operand" "f")))
2564 (clobber (match_scratch:SF 2 "=d"))]
2565 "TARGET_HARD_FLOAT && !ISA_HAS_TRUNC_W"
2568 return ".set\tmacro\;trunc.w.s %0,%1,%2\;.set\tnomacro";
2570 return "trunc.w.s %0,%1,%2";
2572 [(set_attr "type" "fcvt")
2573 (set_attr "mode" "SF")
2574 (set_attr "cnv_mode" "S2I")
2575 (set_attr "length" "36")])
2578 (define_insn "fix_truncdfdi2"
2579 [(set (match_operand:DI 0 "register_operand" "=f")
2580 (fix:DI (match_operand:DF 1 "register_operand" "f")))]
2581 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
2583 [(set_attr "type" "fcvt")
2584 (set_attr "mode" "DF")
2585 (set_attr "cnv_mode" "D2I")
2586 (set_attr "length" "4")])
2589 (define_insn "fix_truncsfdi2"
2590 [(set (match_operand:DI 0 "register_operand" "=f")
2591 (fix:DI (match_operand:SF 1 "register_operand" "f")))]
2592 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
2594 [(set_attr "type" "fcvt")
2595 (set_attr "mode" "SF")
2596 (set_attr "cnv_mode" "S2I")
2597 (set_attr "length" "4")])
2600 (define_insn "floatsidf2"
2601 [(set (match_operand:DF 0 "register_operand" "=f")
2602 (float:DF (match_operand:SI 1 "register_operand" "f")))]
2603 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2605 [(set_attr "type" "fcvt")
2606 (set_attr "mode" "DF")
2607 (set_attr "cnv_mode" "I2D")
2608 (set_attr "length" "4")])
2611 (define_insn "floatdidf2"
2612 [(set (match_operand:DF 0 "register_operand" "=f")
2613 (float:DF (match_operand:DI 1 "register_operand" "f")))]
2614 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
2616 [(set_attr "type" "fcvt")
2617 (set_attr "mode" "DF")
2618 (set_attr "cnv_mode" "I2D")
2619 (set_attr "length" "4")])
2622 (define_insn "floatsisf2"
2623 [(set (match_operand:SF 0 "register_operand" "=f")
2624 (float:SF (match_operand:SI 1 "register_operand" "f")))]
2627 [(set_attr "type" "fcvt")
2628 (set_attr "mode" "SF")
2629 (set_attr "cnv_mode" "I2S")
2630 (set_attr "length" "4")])
2633 (define_insn "floatdisf2"
2634 [(set (match_operand:SF 0 "register_operand" "=f")
2635 (float:SF (match_operand:DI 1 "register_operand" "f")))]
2636 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
2638 [(set_attr "type" "fcvt")
2639 (set_attr "mode" "SF")
2640 (set_attr "cnv_mode" "I2S")
2641 (set_attr "length" "4")])
2644 (define_expand "fixuns_truncdfsi2"
2645 [(set (match_operand:SI 0 "register_operand")
2646 (unsigned_fix:SI (match_operand:DF 1 "register_operand")))]
2647 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2649 rtx reg1 = gen_reg_rtx (DFmode);
2650 rtx reg2 = gen_reg_rtx (DFmode);
2651 rtx reg3 = gen_reg_rtx (SImode);
2652 rtx label1 = gen_label_rtx ();
2653 rtx label2 = gen_label_rtx ();
2654 REAL_VALUE_TYPE offset;
2656 real_2expN (&offset, 31);
2658 if (reg1) /* Turn off complaints about unreached code. */
2660 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, DFmode));
2661 do_pending_stack_adjust ();
2663 emit_insn (gen_cmpdf (operands[1], reg1));
2664 emit_jump_insn (gen_bge (label1));
2666 emit_insn (gen_fix_truncdfsi2 (operands[0], operands[1]));
2667 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
2668 gen_rtx_LABEL_REF (VOIDmode, label2)));
2671 emit_label (label1);
2672 emit_move_insn (reg2, gen_rtx_MINUS (DFmode, operands[1], reg1));
2673 emit_move_insn (reg3, GEN_INT (trunc_int_for_mode
2674 (BITMASK_HIGH, SImode)));
2676 emit_insn (gen_fix_truncdfsi2 (operands[0], reg2));
2677 emit_insn (gen_iorsi3 (operands[0], operands[0], reg3));
2679 emit_label (label2);
2681 /* Allow REG_NOTES to be set on last insn (labels don't have enough
2682 fields, and can't be used for REG_NOTES anyway). */
2683 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
2689 (define_expand "fixuns_truncdfdi2"
2690 [(set (match_operand:DI 0 "register_operand")
2691 (unsigned_fix:DI (match_operand:DF 1 "register_operand")))]
2692 "TARGET_HARD_FLOAT && TARGET_64BIT && TARGET_DOUBLE_FLOAT"
2694 rtx reg1 = gen_reg_rtx (DFmode);
2695 rtx reg2 = gen_reg_rtx (DFmode);
2696 rtx reg3 = gen_reg_rtx (DImode);
2697 rtx label1 = gen_label_rtx ();
2698 rtx label2 = gen_label_rtx ();
2699 REAL_VALUE_TYPE offset;
2701 real_2expN (&offset, 63);
2703 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, DFmode));
2704 do_pending_stack_adjust ();
2706 emit_insn (gen_cmpdf (operands[1], reg1));
2707 emit_jump_insn (gen_bge (label1));
2709 emit_insn (gen_fix_truncdfdi2 (operands[0], operands[1]));
2710 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
2711 gen_rtx_LABEL_REF (VOIDmode, label2)));
2714 emit_label (label1);
2715 emit_move_insn (reg2, gen_rtx_MINUS (DFmode, operands[1], reg1));
2716 emit_move_insn (reg3, GEN_INT (BITMASK_HIGH));
2717 emit_insn (gen_ashldi3 (reg3, reg3, GEN_INT (32)));
2719 emit_insn (gen_fix_truncdfdi2 (operands[0], reg2));
2720 emit_insn (gen_iordi3 (operands[0], operands[0], reg3));
2722 emit_label (label2);
2724 /* Allow REG_NOTES to be set on last insn (labels don't have enough
2725 fields, and can't be used for REG_NOTES anyway). */
2726 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
2731 (define_expand "fixuns_truncsfsi2"
2732 [(set (match_operand:SI 0 "register_operand")
2733 (unsigned_fix:SI (match_operand:SF 1 "register_operand")))]
2736 rtx reg1 = gen_reg_rtx (SFmode);
2737 rtx reg2 = gen_reg_rtx (SFmode);
2738 rtx reg3 = gen_reg_rtx (SImode);
2739 rtx label1 = gen_label_rtx ();
2740 rtx label2 = gen_label_rtx ();
2741 REAL_VALUE_TYPE offset;
2743 real_2expN (&offset, 31);
2745 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, SFmode));
2746 do_pending_stack_adjust ();
2748 emit_insn (gen_cmpsf (operands[1], reg1));
2749 emit_jump_insn (gen_bge (label1));
2751 emit_insn (gen_fix_truncsfsi2 (operands[0], operands[1]));
2752 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
2753 gen_rtx_LABEL_REF (VOIDmode, label2)));
2756 emit_label (label1);
2757 emit_move_insn (reg2, gen_rtx_MINUS (SFmode, operands[1], reg1));
2758 emit_move_insn (reg3, GEN_INT (trunc_int_for_mode
2759 (BITMASK_HIGH, SImode)));
2761 emit_insn (gen_fix_truncsfsi2 (operands[0], reg2));
2762 emit_insn (gen_iorsi3 (operands[0], operands[0], reg3));
2764 emit_label (label2);
2766 /* Allow REG_NOTES to be set on last insn (labels don't have enough
2767 fields, and can't be used for REG_NOTES anyway). */
2768 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
2773 (define_expand "fixuns_truncsfdi2"
2774 [(set (match_operand:DI 0 "register_operand")
2775 (unsigned_fix:DI (match_operand:SF 1 "register_operand")))]
2776 "TARGET_HARD_FLOAT && TARGET_64BIT && TARGET_DOUBLE_FLOAT"
2778 rtx reg1 = gen_reg_rtx (SFmode);
2779 rtx reg2 = gen_reg_rtx (SFmode);
2780 rtx reg3 = gen_reg_rtx (DImode);
2781 rtx label1 = gen_label_rtx ();
2782 rtx label2 = gen_label_rtx ();
2783 REAL_VALUE_TYPE offset;
2785 real_2expN (&offset, 63);
2787 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, SFmode));
2788 do_pending_stack_adjust ();
2790 emit_insn (gen_cmpsf (operands[1], reg1));
2791 emit_jump_insn (gen_bge (label1));
2793 emit_insn (gen_fix_truncsfdi2 (operands[0], operands[1]));
2794 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
2795 gen_rtx_LABEL_REF (VOIDmode, label2)));
2798 emit_label (label1);
2799 emit_move_insn (reg2, gen_rtx_MINUS (SFmode, operands[1], reg1));
2800 emit_move_insn (reg3, GEN_INT (BITMASK_HIGH));
2801 emit_insn (gen_ashldi3 (reg3, reg3, GEN_INT (32)));
2803 emit_insn (gen_fix_truncsfdi2 (operands[0], reg2));
2804 emit_insn (gen_iordi3 (operands[0], operands[0], reg3));
2806 emit_label (label2);
2808 /* Allow REG_NOTES to be set on last insn (labels don't have enough
2809 fields, and can't be used for REG_NOTES anyway). */
2810 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
2815 ;; ....................
2819 ;; ....................
2821 ;; Bit field extract patterns which use lwl/lwr or ldl/ldr.
2823 (define_expand "extv"
2824 [(set (match_operand 0 "register_operand")
2825 (sign_extract (match_operand:QI 1 "memory_operand")
2826 (match_operand 2 "immediate_operand")
2827 (match_operand 3 "immediate_operand")))]
2830 if (mips_expand_unaligned_load (operands[0], operands[1],
2831 INTVAL (operands[2]),
2832 INTVAL (operands[3])))
2838 (define_expand "extzv"
2839 [(set (match_operand 0 "register_operand")
2840 (zero_extract (match_operand 1 "nonimmediate_operand")
2841 (match_operand 2 "immediate_operand")
2842 (match_operand 3 "immediate_operand")))]
2845 if (mips_expand_unaligned_load (operands[0], operands[1],
2846 INTVAL (operands[2]),
2847 INTVAL (operands[3])))
2849 else if (mips_use_ins_ext_p (operands[1], operands[2], operands[3]))
2851 if (GET_MODE (operands[0]) == DImode)
2852 emit_insn (gen_extzvdi (operands[0], operands[1], operands[2],
2855 emit_insn (gen_extzvsi (operands[0], operands[1], operands[2],
2863 (define_insn "extzv<mode>"
2864 [(set (match_operand:GPR 0 "register_operand" "=d")
2865 (zero_extract:GPR (match_operand:GPR 1 "register_operand" "d")
2866 (match_operand:SI 2 "immediate_operand" "I")
2867 (match_operand:SI 3 "immediate_operand" "I")))]
2868 "mips_use_ins_ext_p (operands[1], operands[2], operands[3])"
2869 "<d>ext\t%0,%1,%3,%2"
2870 [(set_attr "type" "arith")
2871 (set_attr "mode" "<MODE>")])
2874 (define_expand "insv"
2875 [(set (zero_extract (match_operand 0 "nonimmediate_operand")
2876 (match_operand 1 "immediate_operand")
2877 (match_operand 2 "immediate_operand"))
2878 (match_operand 3 "reg_or_0_operand"))]
2881 if (mips_expand_unaligned_store (operands[0], operands[3],
2882 INTVAL (operands[1]),
2883 INTVAL (operands[2])))
2885 else if (mips_use_ins_ext_p (operands[0], operands[1], operands[2]))
2887 if (GET_MODE (operands[0]) == DImode)
2888 emit_insn (gen_insvdi (operands[0], operands[1], operands[2],
2891 emit_insn (gen_insvsi (operands[0], operands[1], operands[2],
2899 (define_insn "insv<mode>"
2900 [(set (zero_extract:GPR (match_operand:GPR 0 "register_operand" "+d")
2901 (match_operand:SI 1 "immediate_operand" "I")
2902 (match_operand:SI 2 "immediate_operand" "I"))
2903 (match_operand:GPR 3 "reg_or_0_operand" "dJ"))]
2904 "mips_use_ins_ext_p (operands[0], operands[1], operands[2])"
2905 "<d>ins\t%0,%z3,%2,%1"
2906 [(set_attr "type" "arith")
2907 (set_attr "mode" "<MODE>")])
2909 ;; Unaligned word moves generated by the bit field patterns.
2911 ;; As far as the rtl is concerned, both the left-part and right-part
2912 ;; instructions can access the whole field. However, the real operand
2913 ;; refers to just the first or the last byte (depending on endianness).
2914 ;; We therefore use two memory operands to each instruction, one to
2915 ;; describe the rtl effect and one to use in the assembly output.
2917 ;; Operands 0 and 1 are the rtl-level target and source respectively.
2918 ;; This allows us to use the standard length calculations for the "load"
2919 ;; and "store" type attributes.
2921 (define_insn "mov_<load>l"
2922 [(set (match_operand:GPR 0 "register_operand" "=d")
2923 (unspec:GPR [(match_operand:BLK 1 "memory_operand" "m")
2924 (match_operand:QI 2 "memory_operand" "m")]
2928 [(set_attr "type" "load")
2929 (set_attr "mode" "<MODE>")])
2931 (define_insn "mov_<load>r"
2932 [(set (match_operand:GPR 0 "register_operand" "=d")
2933 (unspec:GPR [(match_operand:BLK 1 "memory_operand" "m")
2934 (match_operand:QI 2 "memory_operand" "m")
2935 (match_operand:GPR 3 "register_operand" "0")]
2936 UNSPEC_LOAD_RIGHT))]
2939 [(set_attr "type" "load")
2940 (set_attr "mode" "<MODE>")])
2942 (define_insn "mov_<store>l"
2943 [(set (match_operand:BLK 0 "memory_operand" "=m")
2944 (unspec:BLK [(match_operand:GPR 1 "reg_or_0_operand" "dJ")
2945 (match_operand:QI 2 "memory_operand" "m")]
2946 UNSPEC_STORE_LEFT))]
2949 [(set_attr "type" "store")
2950 (set_attr "mode" "<MODE>")])
2952 (define_insn "mov_<store>r"
2953 [(set (match_operand:BLK 0 "memory_operand" "+m")
2954 (unspec:BLK [(match_operand:GPR 1 "reg_or_0_operand" "dJ")
2955 (match_operand:QI 2 "memory_operand" "m")
2957 UNSPEC_STORE_RIGHT))]
2960 [(set_attr "type" "store")
2961 (set_attr "mode" "<MODE>")])
2963 ;; An instruction to calculate the high part of a 64-bit SYMBOL_GENERAL.
2964 ;; The required value is:
2966 ;; (%highest(op1) << 48) + (%higher(op1) << 32) + (%hi(op1) << 16)
2968 ;; which translates to:
2970 ;; lui op0,%highest(op1)
2971 ;; daddiu op0,op0,%higher(op1)
2973 ;; daddiu op0,op0,%hi(op1)
2976 ;; The split is deferred until after flow2 to allow the peephole2 below
2978 (define_insn_and_split "*lea_high64"
2979 [(set (match_operand:DI 0 "register_operand" "=d")
2980 (high:DI (match_operand:DI 1 "general_symbolic_operand" "")))]
2981 "TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS"
2983 "&& flow2_completed"
2984 [(set (match_dup 0) (high:DI (match_dup 2)))
2985 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 2)))
2986 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 16)))
2987 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 3)))
2988 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 16)))]
2990 operands[2] = mips_unspec_address (operands[1], SYMBOL_64_HIGH);
2991 operands[3] = mips_unspec_address (operands[1], SYMBOL_64_MID);
2993 [(set_attr "length" "20")])
2995 ;; Use a scratch register to reduce the latency of the above pattern
2996 ;; on superscalar machines. The optimized sequence is:
2998 ;; lui op1,%highest(op2)
3000 ;; daddiu op1,op1,%higher(op2)
3002 ;; daddu op1,op1,op0
3004 [(set (match_operand:DI 1 "register_operand")
3005 (high:DI (match_operand:DI 2 "general_symbolic_operand")))
3006 (match_scratch:DI 0 "d")]
3007 "TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS"
3008 [(set (match_dup 1) (high:DI (match_dup 3)))
3009 (set (match_dup 0) (high:DI (match_dup 4)))
3010 (set (match_dup 1) (lo_sum:DI (match_dup 1) (match_dup 3)))
3011 (set (match_dup 1) (ashift:DI (match_dup 1) (const_int 32)))
3012 (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 0)))]
3014 operands[3] = mips_unspec_address (operands[2], SYMBOL_64_HIGH);
3015 operands[4] = mips_unspec_address (operands[2], SYMBOL_64_LOW);
3018 ;; On most targets, the expansion of (lo_sum (high X) X) for a 64-bit
3019 ;; SYMBOL_GENERAL X will take 6 cycles. This next pattern allows combine
3020 ;; to merge the HIGH and LO_SUM parts of a move if the HIGH part is only
3021 ;; used once. We can then use the sequence:
3023 ;; lui op0,%highest(op1)
3025 ;; daddiu op0,op0,%higher(op1)
3026 ;; daddiu op2,op2,%lo(op1)
3028 ;; daddu op0,op0,op2
3030 ;; which takes 4 cycles on most superscalar targets.
3031 (define_insn_and_split "*lea64"
3032 [(set (match_operand:DI 0 "register_operand" "=d")
3033 (match_operand:DI 1 "general_symbolic_operand" ""))
3034 (clobber (match_scratch:DI 2 "=&d"))]
3035 "TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS && cse_not_expected"
3037 "&& reload_completed"
3038 [(set (match_dup 0) (high:DI (match_dup 3)))
3039 (set (match_dup 2) (high:DI (match_dup 4)))
3040 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 3)))
3041 (set (match_dup 2) (lo_sum:DI (match_dup 2) (match_dup 4)))
3042 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
3043 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))]
3045 operands[3] = mips_unspec_address (operands[1], SYMBOL_64_HIGH);
3046 operands[4] = mips_unspec_address (operands[1], SYMBOL_64_LOW);
3048 [(set_attr "length" "24")])
3050 ;; Insns to fetch a global symbol from a big GOT.
3052 (define_insn_and_split "*xgot_hi<mode>"
3053 [(set (match_operand:P 0 "register_operand" "=d")
3054 (high:P (match_operand:P 1 "global_got_operand" "")))]
3055 "TARGET_EXPLICIT_RELOCS && TARGET_XGOT"
3057 "&& reload_completed"
3058 [(set (match_dup 0) (high:P (match_dup 2)))
3059 (set (match_dup 0) (plus:P (match_dup 0) (match_dup 3)))]
3061 operands[2] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_GLOBAL);
3062 operands[3] = pic_offset_table_rtx;
3064 [(set_attr "got" "xgot_high")
3065 (set_attr "mode" "<MODE>")])
3067 (define_insn_and_split "*xgot_lo<mode>"
3068 [(set (match_operand:P 0 "register_operand" "=d")
3069 (lo_sum:P (match_operand:P 1 "register_operand" "d")
3070 (match_operand:P 2 "global_got_operand" "")))]
3071 "TARGET_EXPLICIT_RELOCS && TARGET_XGOT"
3073 "&& reload_completed"
3075 (unspec:P [(match_dup 1) (match_dup 3)] UNSPEC_LOAD_GOT))]
3076 { operands[3] = mips_unspec_address (operands[2], SYMBOL_GOTOFF_GLOBAL); }
3077 [(set_attr "got" "load")
3078 (set_attr "mode" "<MODE>")])
3080 ;; Insns to fetch a global symbol from a normal GOT.
3082 (define_insn_and_split "*got_disp<mode>"
3083 [(set (match_operand:P 0 "register_operand" "=d")
3084 (match_operand:P 1 "global_got_operand" ""))]
3085 "TARGET_EXPLICIT_RELOCS && !TARGET_XGOT"
3087 "&& reload_completed"
3089 (unspec:P [(match_dup 2) (match_dup 3)] UNSPEC_LOAD_GOT))]
3091 operands[2] = pic_offset_table_rtx;
3092 operands[3] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_GLOBAL);
3094 [(set_attr "got" "load")
3095 (set_attr "mode" "<MODE>")])
3097 ;; Insns for loading the high part of a local symbol.
3099 (define_insn_and_split "*got_page<mode>"
3100 [(set (match_operand:P 0 "register_operand" "=d")
3101 (high:P (match_operand:P 1 "local_got_operand" "")))]
3102 "TARGET_EXPLICIT_RELOCS"
3104 "&& reload_completed"
3106 (unspec:P [(match_dup 2) (match_dup 3)] UNSPEC_LOAD_GOT))]
3108 operands[2] = pic_offset_table_rtx;
3109 operands[3] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_PAGE);
3111 [(set_attr "got" "load")
3112 (set_attr "mode" "<MODE>")])
3114 ;; Lower-level instructions for loading an address from the GOT.
3115 ;; We could use MEMs, but an unspec gives more optimization
3118 (define_insn "load_got<mode>"
3119 [(set (match_operand:P 0 "register_operand" "=d")
3120 (unspec:P [(match_operand:P 1 "register_operand" "d")
3121 (match_operand:P 2 "immediate_operand" "")]
3124 "<load>\t%0,%R2(%1)"
3125 [(set_attr "type" "load")
3126 (set_attr "mode" "<MODE>")
3127 (set_attr "length" "4")])
3129 ;; Instructions for adding the low 16 bits of an address to a register.
3130 ;; Operand 2 is the address: print_operand works out which relocation
3131 ;; should be applied.
3133 (define_insn "*low<mode>"
3134 [(set (match_operand:P 0 "register_operand" "=d")
3135 (lo_sum:P (match_operand:P 1 "register_operand" "d")
3136 (match_operand:P 2 "immediate_operand" "")))]
3138 "<d>addiu\t%0,%1,%R2"
3139 [(set_attr "type" "arith")
3140 (set_attr "mode" "<MODE>")])
3142 (define_insn "*low<mode>_mips16"
3143 [(set (match_operand:P 0 "register_operand" "=d")
3144 (lo_sum:P (match_operand:P 1 "register_operand" "0")
3145 (match_operand:P 2 "immediate_operand" "")))]
3148 [(set_attr "type" "arith")
3149 (set_attr "mode" "<MODE>")
3150 (set_attr "length" "8")])
3152 ;; 64-bit integer moves
3154 ;; Unlike most other insns, the move insns can't be split with
3155 ;; different predicates, because register spilling and other parts of
3156 ;; the compiler, have memoized the insn number already.
3158 (define_expand "movdi"
3159 [(set (match_operand:DI 0 "")
3160 (match_operand:DI 1 ""))]
3163 if (mips_legitimize_move (DImode, operands[0], operands[1]))
3167 ;; For mips16, we need a special case to handle storing $31 into
3168 ;; memory, since we don't have a constraint to match $31. This
3169 ;; instruction can be generated by save_restore_insns.
3171 (define_insn "*mov<mode>_ra"
3172 [(set (match_operand:GPR 0 "stack_operand" "=m")
3176 [(set_attr "type" "store")
3177 (set_attr "mode" "<MODE>")])
3179 (define_insn "*movdi_32bit"
3180 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,m,*x,*d,*B*C*D,*B*C*D,*d,*m")
3181 (match_operand:DI 1 "move_operand" "d,i,m,d,*J*d,*x,*d,*m,*B*C*D,*B*C*D"))]
3182 "!TARGET_64BIT && !TARGET_MIPS16
3183 && (register_operand (operands[0], DImode)
3184 || reg_or_0_operand (operands[1], DImode))"
3185 { return mips_output_move (operands[0], operands[1]); }
3186 [(set_attr "type" "arith,arith,load,store,mthilo,mfhilo,xfer,load,xfer,store")
3187 (set_attr "mode" "DI")
3188 (set_attr "length" "8,16,*,*,8,8,8,*,8,*")])
3190 (define_insn "*movdi_32bit_mips16"
3191 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m,*d")
3192 (match_operand:DI 1 "move_operand" "d,d,y,K,N,m,d,*x"))]
3193 "!TARGET_64BIT && TARGET_MIPS16
3194 && (register_operand (operands[0], DImode)
3195 || register_operand (operands[1], DImode))"
3196 { return mips_output_move (operands[0], operands[1]); }
3197 [(set_attr "type" "arith,arith,arith,arith,arith,load,store,mfhilo")
3198 (set_attr "mode" "DI")
3199 (set_attr "length" "8,8,8,8,12,*,*,8")])
3201 (define_insn "*movdi_64bit"
3202 [(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")
3203 (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"))]
3204 "TARGET_64BIT && !TARGET_MIPS16
3205 && (register_operand (operands[0], DImode)
3206 || reg_or_0_operand (operands[1], DImode))"
3207 { return mips_output_move (operands[0], operands[1]); }
3208 [(set_attr "type" "arith,const,const,load,store,fmove,xfer,fpload,xfer,fpstore,mthilo,xfer,load,xfer,store")
3209 (set_attr "mode" "DI")
3210 (set_attr "length" "4,*,*,*,*,4,4,*,4,*,4,8,*,8,*")])
3212 (define_insn "*movdi_64bit_mips16"
3213 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,y,d,d,d,d,d,m")
3214 (match_operand:DI 1 "move_operand" "d,d,y,K,N,U,m,d"))]
3215 "TARGET_64BIT && TARGET_MIPS16
3216 && (register_operand (operands[0], DImode)
3217 || register_operand (operands[1], DImode))"
3218 { return mips_output_move (operands[0], operands[1]); }
3219 [(set_attr "type" "arith,arith,arith,arith,arith,const,load,store")
3220 (set_attr "mode" "DI")
3221 (set_attr_alternative "length"
3225 (if_then_else (match_operand:VOID 1 "m16_uimm8_1")
3228 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1")
3233 (const_string "*")])])
3236 ;; On the mips16, we can split ld $r,N($r) into an add and a load,
3237 ;; when the original load is a 4 byte instruction but the add and the
3238 ;; load are 2 2 byte instructions.
3241 [(set (match_operand:DI 0 "register_operand")
3242 (mem:DI (plus:DI (match_dup 0)
3243 (match_operand:DI 1 "const_int_operand"))))]
3244 "TARGET_64BIT && TARGET_MIPS16 && reload_completed
3245 && !TARGET_DEBUG_D_MODE
3246 && REG_P (operands[0])
3247 && M16_REG_P (REGNO (operands[0]))
3248 && GET_CODE (operands[1]) == CONST_INT
3249 && ((INTVAL (operands[1]) < 0
3250 && INTVAL (operands[1]) >= -0x10)
3251 || (INTVAL (operands[1]) >= 32 * 8
3252 && INTVAL (operands[1]) <= 31 * 8 + 0x8)
3253 || (INTVAL (operands[1]) >= 0
3254 && INTVAL (operands[1]) < 32 * 8
3255 && (INTVAL (operands[1]) & 7) != 0))"
3256 [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1)))
3257 (set (match_dup 0) (mem:DI (plus:DI (match_dup 0) (match_dup 2))))]
3259 HOST_WIDE_INT val = INTVAL (operands[1]);
3262 operands[2] = const0_rtx;
3263 else if (val >= 32 * 8)
3267 operands[1] = GEN_INT (0x8 + off);
3268 operands[2] = GEN_INT (val - off - 0x8);
3274 operands[1] = GEN_INT (off);
3275 operands[2] = GEN_INT (val - off);
3279 ;; 32-bit Integer moves
3281 ;; Unlike most other insns, the move insns can't be split with
3282 ;; different predicates, because register spilling and other parts of
3283 ;; the compiler, have memoized the insn number already.
3285 (define_expand "movsi"
3286 [(set (match_operand:SI 0 "")
3287 (match_operand:SI 1 ""))]
3290 if (mips_legitimize_move (SImode, operands[0], operands[1]))
3294 ;; The difference between these two is whether or not ints are allowed
3295 ;; in FP registers (off by default, use -mdebugh to enable).
3297 (define_insn "*movsi_internal"
3298 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,e,d,m,*f,*f,*f,*d,*m,*d,*z,*x,*B*C*D,*B*C*D,*d,*m")
3299 (match_operand:SI 1 "move_operand" "d,U,T,m,dJ,*f,*d*J,*m,*f,*f,*z,*d,*J*d,*d,*m,*B*C*D,*B*C*D"))]
3301 && (register_operand (operands[0], SImode)
3302 || reg_or_0_operand (operands[1], SImode))"
3303 { return mips_output_move (operands[0], operands[1]); }
3304 [(set_attr "type" "arith,const,const,load,store,fmove,xfer,fpload,xfer,fpstore,xfer,xfer,mthilo,xfer,load,xfer,store")
3305 (set_attr "mode" "SI")
3306 (set_attr "length" "4,*,*,*,*,4,4,*,4,*,4,4,4,4,*,4,*")])
3308 (define_insn "*movsi_mips16"
3309 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,y,d,d,d,d,d,m")
3310 (match_operand:SI 1 "move_operand" "d,d,y,K,N,U,m,d"))]
3312 && (register_operand (operands[0], SImode)
3313 || register_operand (operands[1], SImode))"
3314 { return mips_output_move (operands[0], operands[1]); }
3315 [(set_attr "type" "arith,arith,arith,arith,arith,const,load,store")
3316 (set_attr "mode" "SI")
3317 (set_attr_alternative "length"
3321 (if_then_else (match_operand:VOID 1 "m16_uimm8_1")
3324 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1")
3329 (const_string "*")])])
3331 ;; On the mips16, we can split lw $r,N($r) into an add and a load,
3332 ;; when the original load is a 4 byte instruction but the add and the
3333 ;; load are 2 2 byte instructions.
3336 [(set (match_operand:SI 0 "register_operand")
3337 (mem:SI (plus:SI (match_dup 0)
3338 (match_operand:SI 1 "const_int_operand"))))]
3339 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
3340 && REG_P (operands[0])
3341 && M16_REG_P (REGNO (operands[0]))
3342 && GET_CODE (operands[1]) == CONST_INT
3343 && ((INTVAL (operands[1]) < 0
3344 && INTVAL (operands[1]) >= -0x80)
3345 || (INTVAL (operands[1]) >= 32 * 4
3346 && INTVAL (operands[1]) <= 31 * 4 + 0x7c)
3347 || (INTVAL (operands[1]) >= 0
3348 && INTVAL (operands[1]) < 32 * 4
3349 && (INTVAL (operands[1]) & 3) != 0))"
3350 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
3351 (set (match_dup 0) (mem:SI (plus:SI (match_dup 0) (match_dup 2))))]
3353 HOST_WIDE_INT val = INTVAL (operands[1]);
3356 operands[2] = const0_rtx;
3357 else if (val >= 32 * 4)
3361 operands[1] = GEN_INT (0x7c + off);
3362 operands[2] = GEN_INT (val - off - 0x7c);
3368 operands[1] = GEN_INT (off);
3369 operands[2] = GEN_INT (val - off);
3373 ;; On the mips16, we can split a load of certain constants into a load
3374 ;; and an add. This turns a 4 byte instruction into 2 2 byte
3378 [(set (match_operand:SI 0 "register_operand")
3379 (match_operand:SI 1 "const_int_operand"))]
3380 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
3381 && REG_P (operands[0])
3382 && M16_REG_P (REGNO (operands[0]))
3383 && GET_CODE (operands[1]) == CONST_INT
3384 && INTVAL (operands[1]) >= 0x100
3385 && INTVAL (operands[1]) <= 0xff + 0x7f"
3386 [(set (match_dup 0) (match_dup 1))
3387 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]
3389 int val = INTVAL (operands[1]);
3391 operands[1] = GEN_INT (0xff);
3392 operands[2] = GEN_INT (val - 0xff);
3395 ;; This insn handles moving CCmode values. It's really just a
3396 ;; slightly simplified copy of movsi_internal2, with additional cases
3397 ;; to move a condition register to a general register and to move
3398 ;; between the general registers and the floating point registers.
3400 (define_insn "movcc"
3401 [(set (match_operand:CC 0 "nonimmediate_operand" "=d,*d,*d,*m,*d,*f,*f,*f,*m")
3402 (match_operand:CC 1 "general_operand" "z,*d,*m,*d,*f,*d,*f,*m,*f"))]
3403 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
3404 { return mips_output_move (operands[0], operands[1]); }
3405 [(set_attr "type" "xfer,arith,load,store,xfer,xfer,fmove,fpload,fpstore")
3406 (set_attr "mode" "SI")
3407 (set_attr "length" "8,4,*,*,4,4,4,*,*")])
3409 ;; Reload condition code registers. reload_incc and reload_outcc
3410 ;; both handle moves from arbitrary operands into condition code
3411 ;; registers. reload_incc handles the more common case in which
3412 ;; a source operand is constrained to be in a condition-code
3413 ;; register, but has not been allocated to one.
3415 ;; Sometimes, such as in movcc, we have a CCmode destination whose
3416 ;; constraints do not include 'z'. reload_outcc handles the case
3417 ;; when such an operand is allocated to a condition-code register.
3419 ;; Note that reloads from a condition code register to some
3420 ;; other location can be done using ordinary moves. Moving
3421 ;; into a GPR takes a single movcc, moving elsewhere takes
3422 ;; two. We can leave these cases to the generic reload code.
3423 (define_expand "reload_incc"
3424 [(set (match_operand:CC 0 "fcc_reload_operand" "=z")
3425 (match_operand:CC 1 "general_operand" ""))
3426 (clobber (match_operand:TF 2 "register_operand" "=&f"))]
3427 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
3429 mips_emit_fcc_reload (operands[0], operands[1], operands[2]);
3433 (define_expand "reload_outcc"
3434 [(set (match_operand:CC 0 "fcc_reload_operand" "=z")
3435 (match_operand:CC 1 "register_operand" ""))
3436 (clobber (match_operand:TF 2 "register_operand" "=&f"))]
3437 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
3439 mips_emit_fcc_reload (operands[0], operands[1], operands[2]);
3443 ;; MIPS4 supports loading and storing a floating point register from
3444 ;; the sum of two general registers. We use two versions for each of
3445 ;; these four instructions: one where the two general registers are
3446 ;; SImode, and one where they are DImode. This is because general
3447 ;; registers will be in SImode when they hold 32 bit values, but,
3448 ;; since the 32 bit values are always sign extended, the [ls][wd]xc1
3449 ;; instructions will still work correctly.
3451 ;; ??? Perhaps it would be better to support these instructions by
3452 ;; modifying GO_IF_LEGITIMATE_ADDRESS and friends. However, since
3453 ;; these instructions can only be used to load and store floating
3454 ;; point registers, that would probably cause trouble in reload.
3456 (define_insn "*<ANYF:loadx>_<P:mode>"
3457 [(set (match_operand:ANYF 0 "register_operand" "=f")
3458 (mem:ANYF (plus:P (match_operand:P 1 "register_operand" "d")
3459 (match_operand:P 2 "register_operand" "d"))))]
3461 "<ANYF:loadx>\t%0,%1(%2)"
3462 [(set_attr "type" "fpidxload")
3463 (set_attr "mode" "<ANYF:UNITMODE>")])
3465 (define_insn "*<ANYF:storex>_<P:mode>"
3466 [(set (mem:ANYF (plus:P (match_operand:P 1 "register_operand" "d")
3467 (match_operand:P 2 "register_operand" "d")))
3468 (match_operand:ANYF 0 "register_operand" "f"))]
3470 "<ANYF:storex>\t%0,%1(%2)"
3471 [(set_attr "type" "fpidxstore")
3472 (set_attr "mode" "<ANYF:UNITMODE>")])
3474 ;; 16-bit Integer moves
3476 ;; Unlike most other insns, the move insns can't be split with
3477 ;; different predicates, because register spilling and other parts of
3478 ;; the compiler, have memoized the insn number already.
3479 ;; Unsigned loads are used because LOAD_EXTEND_OP returns ZERO_EXTEND.
3481 (define_expand "movhi"
3482 [(set (match_operand:HI 0 "")
3483 (match_operand:HI 1 ""))]
3486 if (mips_legitimize_move (HImode, operands[0], operands[1]))
3490 (define_insn "*movhi_internal"
3491 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,m,*d,*f,*f,*x")
3492 (match_operand:HI 1 "move_operand" "d,I,m,dJ,*f,*d,*f,*d"))]
3494 && (register_operand (operands[0], HImode)
3495 || reg_or_0_operand (operands[1], HImode))"
3505 [(set_attr "type" "arith,arith,load,store,xfer,xfer,fmove,mthilo")
3506 (set_attr "mode" "HI")
3507 (set_attr "length" "4,4,*,*,4,4,4,4")])
3509 (define_insn "*movhi_mips16"
3510 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m")
3511 (match_operand:HI 1 "move_operand" "d,d,y,K,N,m,d"))]
3513 && (register_operand (operands[0], HImode)
3514 || register_operand (operands[1], HImode))"
3523 [(set_attr "type" "arith,arith,arith,arith,arith,load,store")
3524 (set_attr "mode" "HI")
3525 (set_attr_alternative "length"
3529 (if_then_else (match_operand:VOID 1 "m16_uimm8_1")
3532 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1")
3536 (const_string "*")])])
3539 ;; On the mips16, we can split lh $r,N($r) into an add and a load,
3540 ;; when the original load is a 4 byte instruction but the add and the
3541 ;; load are 2 2 byte instructions.
3544 [(set (match_operand:HI 0 "register_operand")
3545 (mem:HI (plus:SI (match_dup 0)
3546 (match_operand:SI 1 "const_int_operand"))))]
3547 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
3548 && REG_P (operands[0])
3549 && M16_REG_P (REGNO (operands[0]))
3550 && GET_CODE (operands[1]) == CONST_INT
3551 && ((INTVAL (operands[1]) < 0
3552 && INTVAL (operands[1]) >= -0x80)
3553 || (INTVAL (operands[1]) >= 32 * 2
3554 && INTVAL (operands[1]) <= 31 * 2 + 0x7e)
3555 || (INTVAL (operands[1]) >= 0
3556 && INTVAL (operands[1]) < 32 * 2
3557 && (INTVAL (operands[1]) & 1) != 0))"
3558 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
3559 (set (match_dup 0) (mem:HI (plus:SI (match_dup 0) (match_dup 2))))]
3561 HOST_WIDE_INT val = INTVAL (operands[1]);
3564 operands[2] = const0_rtx;
3565 else if (val >= 32 * 2)
3569 operands[1] = GEN_INT (0x7e + off);
3570 operands[2] = GEN_INT (val - off - 0x7e);
3576 operands[1] = GEN_INT (off);
3577 operands[2] = GEN_INT (val - off);
3581 ;; 8-bit Integer moves
3583 ;; Unlike most other insns, the move insns can't be split with
3584 ;; different predicates, because register spilling and other parts of
3585 ;; the compiler, have memoized the insn number already.
3586 ;; Unsigned loads are used because LOAD_EXTEND_OP returns ZERO_EXTEND.
3588 (define_expand "movqi"
3589 [(set (match_operand:QI 0 "")
3590 (match_operand:QI 1 ""))]
3593 if (mips_legitimize_move (QImode, operands[0], operands[1]))
3597 (define_insn "*movqi_internal"
3598 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,m,*d,*f,*f,*x")
3599 (match_operand:QI 1 "move_operand" "d,I,m,dJ,*f,*d,*f,*d"))]
3601 && (register_operand (operands[0], QImode)
3602 || reg_or_0_operand (operands[1], QImode))"
3612 [(set_attr "type" "arith,arith,load,store,xfer,xfer,fmove,mthilo")
3613 (set_attr "mode" "QI")
3614 (set_attr "length" "4,4,*,*,4,4,4,4")])
3616 (define_insn "*movqi_mips16"
3617 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m")
3618 (match_operand:QI 1 "move_operand" "d,d,y,K,N,m,d"))]
3620 && (register_operand (operands[0], QImode)
3621 || register_operand (operands[1], QImode))"
3630 [(set_attr "type" "arith,arith,arith,arith,arith,load,store")
3631 (set_attr "mode" "QI")
3632 (set_attr "length" "4,4,4,4,8,*,*")])
3634 ;; On the mips16, we can split lb $r,N($r) into an add and a load,
3635 ;; when the original load is a 4 byte instruction but the add and the
3636 ;; load are 2 2 byte instructions.
3639 [(set (match_operand:QI 0 "register_operand")
3640 (mem:QI (plus:SI (match_dup 0)
3641 (match_operand:SI 1 "const_int_operand"))))]
3642 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
3643 && REG_P (operands[0])
3644 && M16_REG_P (REGNO (operands[0]))
3645 && GET_CODE (operands[1]) == CONST_INT
3646 && ((INTVAL (operands[1]) < 0
3647 && INTVAL (operands[1]) >= -0x80)
3648 || (INTVAL (operands[1]) >= 32
3649 && INTVAL (operands[1]) <= 31 + 0x7f))"
3650 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
3651 (set (match_dup 0) (mem:QI (plus:SI (match_dup 0) (match_dup 2))))]
3653 HOST_WIDE_INT val = INTVAL (operands[1]);
3656 operands[2] = const0_rtx;
3659 operands[1] = GEN_INT (0x7f);
3660 operands[2] = GEN_INT (val - 0x7f);
3664 ;; 32-bit floating point moves
3666 (define_expand "movsf"
3667 [(set (match_operand:SF 0 "")
3668 (match_operand:SF 1 ""))]
3671 if (mips_legitimize_move (SFmode, operands[0], operands[1]))
3675 (define_insn "*movsf_hardfloat"
3676 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m")
3677 (match_operand:SF 1 "move_operand" "f,G,m,f,G,*d,*f,*G*d,*m,*d"))]
3679 && (register_operand (operands[0], SFmode)
3680 || reg_or_0_operand (operands[1], SFmode))"
3681 { return mips_output_move (operands[0], operands[1]); }
3682 [(set_attr "type" "fmove,xfer,fpload,fpstore,store,xfer,xfer,arith,load,store")
3683 (set_attr "mode" "SF")
3684 (set_attr "length" "4,4,*,*,*,4,4,4,*,*")])
3686 (define_insn "*movsf_softfloat"
3687 [(set (match_operand:SF 0 "nonimmediate_operand" "=d,d,m")
3688 (match_operand:SF 1 "move_operand" "Gd,m,d"))]
3689 "TARGET_SOFT_FLOAT && !TARGET_MIPS16
3690 && (register_operand (operands[0], SFmode)
3691 || reg_or_0_operand (operands[1], SFmode))"
3692 { return mips_output_move (operands[0], operands[1]); }
3693 [(set_attr "type" "arith,load,store")
3694 (set_attr "mode" "SF")
3695 (set_attr "length" "4,*,*")])
3697 (define_insn "*movsf_mips16"
3698 [(set (match_operand:SF 0 "nonimmediate_operand" "=d,y,d,d,m")
3699 (match_operand:SF 1 "move_operand" "d,d,y,m,d"))]
3701 && (register_operand (operands[0], SFmode)
3702 || register_operand (operands[1], SFmode))"
3703 { return mips_output_move (operands[0], operands[1]); }
3704 [(set_attr "type" "arith,arith,arith,load,store")
3705 (set_attr "mode" "SF")
3706 (set_attr "length" "4,4,4,*,*")])
3709 ;; 64-bit floating point moves
3711 (define_expand "movdf"
3712 [(set (match_operand:DF 0 "")
3713 (match_operand:DF 1 ""))]
3716 if (mips_legitimize_move (DFmode, operands[0], operands[1]))
3720 (define_insn "*movdf_hardfloat_64bit"
3721 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m")
3722 (match_operand:DF 1 "move_operand" "f,G,m,f,G,*d,*f,*d*G,*m,*d"))]
3723 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_64BIT
3724 && (register_operand (operands[0], DFmode)
3725 || reg_or_0_operand (operands[1], DFmode))"
3726 { return mips_output_move (operands[0], operands[1]); }
3727 [(set_attr "type" "fmove,xfer,fpload,fpstore,store,xfer,xfer,arith,load,store")
3728 (set_attr "mode" "DF")
3729 (set_attr "length" "4,4,*,*,*,4,4,4,*,*")])
3731 (define_insn "*movdf_hardfloat_32bit"
3732 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m")
3733 (match_operand:DF 1 "move_operand" "f,G,m,f,G,*d,*f,*d*G,*m,*d"))]
3734 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT
3735 && (register_operand (operands[0], DFmode)
3736 || reg_or_0_operand (operands[1], DFmode))"
3737 { return mips_output_move (operands[0], operands[1]); }
3738 [(set_attr "type" "fmove,xfer,fpload,fpstore,store,xfer,xfer,arith,load,store")
3739 (set_attr "mode" "DF")
3740 (set_attr "length" "4,8,*,*,*,8,8,8,*,*")])
3742 (define_insn "*movdf_softfloat"
3743 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,m,d,f,f")
3744 (match_operand:DF 1 "move_operand" "dG,m,dG,f,d,f"))]
3745 "(TARGET_SOFT_FLOAT || TARGET_SINGLE_FLOAT) && !TARGET_MIPS16
3746 && (register_operand (operands[0], DFmode)
3747 || reg_or_0_operand (operands[1], DFmode))"
3748 { return mips_output_move (operands[0], operands[1]); }
3749 [(set_attr "type" "arith,load,store,xfer,xfer,fmove")
3750 (set_attr "mode" "DF")
3751 (set_attr "length" "8,*,*,4,4,4")])
3753 (define_insn "*movdf_mips16"
3754 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,y,d,d,m")
3755 (match_operand:DF 1 "move_operand" "d,d,y,m,d"))]
3757 && (register_operand (operands[0], DFmode)
3758 || register_operand (operands[1], DFmode))"
3759 { return mips_output_move (operands[0], operands[1]); }
3760 [(set_attr "type" "arith,arith,arith,load,store")
3761 (set_attr "mode" "DF")
3762 (set_attr "length" "8,8,8,*,*")])
3765 [(set (match_operand:DI 0 "nonimmediate_operand")
3766 (match_operand:DI 1 "move_operand"))]
3767 "reload_completed && !TARGET_64BIT
3768 && mips_split_64bit_move_p (operands[0], operands[1])"
3771 mips_split_64bit_move (operands[0], operands[1]);
3776 [(set (match_operand:DF 0 "nonimmediate_operand")
3777 (match_operand:DF 1 "move_operand"))]
3778 "reload_completed && !TARGET_64BIT
3779 && mips_split_64bit_move_p (operands[0], operands[1])"
3782 mips_split_64bit_move (operands[0], operands[1]);
3786 ;; When generating mips16 code, split moves of negative constants into
3787 ;; a positive "li" followed by a negation.
3789 [(set (match_operand 0 "register_operand")
3790 (match_operand 1 "const_int_operand"))]
3791 "TARGET_MIPS16 && reload_completed && INTVAL (operands[1]) < 0"
3795 (neg:SI (match_dup 2)))]
3797 operands[2] = gen_lowpart (SImode, operands[0]);
3798 operands[3] = GEN_INT (-INTVAL (operands[1]));
3801 ;; 64-bit paired-single floating point moves
3803 (define_expand "movv2sf"
3804 [(set (match_operand:V2SF 0)
3805 (match_operand:V2SF 1))]
3806 "TARGET_PAIRED_SINGLE_FLOAT"
3808 if (mips_legitimize_move (V2SFmode, operands[0], operands[1]))
3812 (define_insn "movv2sf_hardfloat_64bit"
3813 [(set (match_operand:V2SF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m")
3814 (match_operand:V2SF 1 "move_operand" "f,YG,m,f,YG,*d,*f,*d*YG,*m,*d"))]
3815 "TARGET_PAIRED_SINGLE_FLOAT
3817 && (register_operand (operands[0], V2SFmode)
3818 || reg_or_0_operand (operands[1], V2SFmode))"
3819 { return mips_output_move (operands[0], operands[1]); }
3820 [(set_attr "type" "fmove,xfer,fpload,fpstore,store,xfer,xfer,arith,load,store")
3821 (set_attr "mode" "SF")
3822 (set_attr "length" "4,4,*,*,*,4,4,4,*,*")])
3824 ;; The HI and LO registers are not truly independent. If we move an mthi
3825 ;; instruction before an mflo instruction, it will make the result of the
3826 ;; mflo unpredictable. The same goes for mtlo and mfhi.
3828 ;; We cope with this by making the mflo and mfhi patterns use both HI and LO.
3829 ;; Operand 1 is the register we want, operand 2 is the other one.
3831 ;; When generating VR4120 or VR4130 code, we use macc{,hi} and
3832 ;; dmacc{,hi} instead of mfhi and mflo. This avoids both the normal
3833 ;; MIPS III hi/lo hazards and the errata related to -mfix-vr4130.
3835 (define_expand "mfhilo_<mode>"
3836 [(set (match_operand:GPR 0 "register_operand")
3837 (unspec:GPR [(match_operand:GPR 1 "register_operand")
3838 (match_operand:GPR 2 "register_operand")]
3841 (define_insn "*mfhilo_<mode>"
3842 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3843 (unspec:GPR [(match_operand:GPR 1 "register_operand" "h,l")
3844 (match_operand:GPR 2 "register_operand" "l,h")]
3848 [(set_attr "type" "mfhilo")
3849 (set_attr "mode" "<MODE>")])
3851 (define_insn "*mfhilo_<mode>_macc"
3852 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3853 (unspec:GPR [(match_operand:GPR 1 "register_operand" "h,l")
3854 (match_operand:GPR 2 "register_operand" "l,h")]
3858 if (REGNO (operands[1]) == HI_REGNUM)
3859 return "<d>macchi\t%0,%.,%.";
3861 return "<d>macc\t%0,%.,%.";
3863 [(set_attr "type" "mfhilo")
3864 (set_attr "mode" "<MODE>")])
3866 ;; Patterns for loading or storing part of a paired floating point
3867 ;; register. We need them because odd-numbered floating-point registers
3868 ;; are not fully independent: see mips_split_64bit_move.
3870 ;; Load the low word of operand 0 with operand 1.
3871 (define_insn "load_df_low"
3872 [(set (match_operand:DF 0 "register_operand" "=f,f")
3873 (unspec:DF [(match_operand:SI 1 "general_operand" "dJ,m")]
3874 UNSPEC_LOAD_DF_LOW))]
3875 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT"
3877 operands[0] = mips_subword (operands[0], 0);
3878 return mips_output_move (operands[0], operands[1]);
3880 [(set_attr "type" "xfer,fpload")
3881 (set_attr "mode" "SF")])
3883 ;; Load the high word of operand 0 from operand 1, preserving the value
3885 (define_insn "load_df_high"
3886 [(set (match_operand:DF 0 "register_operand" "=f,f")
3887 (unspec:DF [(match_operand:SI 1 "general_operand" "dJ,m")
3888 (match_operand:DF 2 "register_operand" "0,0")]
3889 UNSPEC_LOAD_DF_HIGH))]
3890 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT"
3892 operands[0] = mips_subword (operands[0], 1);
3893 return mips_output_move (operands[0], operands[1]);
3895 [(set_attr "type" "xfer,fpload")
3896 (set_attr "mode" "SF")])
3898 ;; Store the high word of operand 1 in operand 0. The corresponding
3899 ;; low-word move is done in the normal way.
3900 (define_insn "store_df_high"
3901 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,m")
3902 (unspec:SI [(match_operand:DF 1 "register_operand" "f,f")]
3903 UNSPEC_STORE_DF_HIGH))]
3904 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT"
3906 operands[1] = mips_subword (operands[1], 1);
3907 return mips_output_move (operands[0], operands[1]);
3909 [(set_attr "type" "xfer,fpstore")
3910 (set_attr "mode" "SF")])
3912 ;; Insn to initialize $gp for n32/n64 abicalls. Operand 0 is the offset
3913 ;; of _gp from the start of this function. Operand 1 is the incoming
3914 ;; function address.
3915 (define_insn_and_split "loadgp"
3916 [(unspec_volatile [(match_operand 0 "" "")
3917 (match_operand 1 "register_operand" "")] UNSPEC_LOADGP)]
3918 "TARGET_ABICALLS && TARGET_NEWABI"
3921 [(set (match_dup 2) (match_dup 3))
3922 (set (match_dup 2) (match_dup 4))
3923 (set (match_dup 2) (match_dup 5))]
3925 operands[2] = pic_offset_table_rtx;
3926 operands[3] = gen_rtx_HIGH (Pmode, operands[0]);
3927 operands[4] = gen_rtx_PLUS (Pmode, operands[2], operands[1]);
3928 operands[5] = gen_rtx_LO_SUM (Pmode, operands[2], operands[0]);
3930 [(set_attr "length" "12")])
3932 ;; The use of gp is hidden when not using explicit relocations.
3933 ;; This blockage instruction prevents the gp load from being
3934 ;; scheduled after an implicit use of gp. It also prevents
3935 ;; the load from being deleted as dead.
3936 (define_insn "loadgp_blockage"
3937 [(unspec_volatile [(reg:DI 28)] UNSPEC_BLOCKAGE)]
3940 [(set_attr "type" "unknown")
3941 (set_attr "mode" "none")
3942 (set_attr "length" "0")])
3944 ;; Emit a .cprestore directive, which normally expands to a single store
3945 ;; instruction. Note that we continue to use .cprestore for explicit reloc
3946 ;; code so that jals inside inline asms will work correctly.
3947 (define_insn "cprestore"
3948 [(unspec_volatile [(match_operand 0 "const_int_operand" "I,i")]
3952 if (set_nomacro && which_alternative == 1)
3953 return ".set\tmacro\;.cprestore\t%0\;.set\tnomacro";
3955 return ".cprestore\t%0";
3957 [(set_attr "type" "store")
3958 (set_attr "length" "4,12")])
3960 ;; Block moves, see mips.c for more details.
3961 ;; Argument 0 is the destination
3962 ;; Argument 1 is the source
3963 ;; Argument 2 is the length
3964 ;; Argument 3 is the alignment
3966 (define_expand "movmemsi"
3967 [(parallel [(set (match_operand:BLK 0 "general_operand")
3968 (match_operand:BLK 1 "general_operand"))
3969 (use (match_operand:SI 2 ""))
3970 (use (match_operand:SI 3 "const_int_operand"))])]
3971 "!TARGET_MIPS16 && !TARGET_MEMCPY"
3973 if (mips_expand_block_move (operands[0], operands[1], operands[2]))
3980 ;; ....................
3984 ;; ....................
3986 (define_expand "<optab><mode>3"
3987 [(set (match_operand:GPR 0 "register_operand")
3988 (any_shift:GPR (match_operand:GPR 1 "register_operand")
3989 (match_operand:SI 2 "arith_operand")))]
3992 /* On the mips16, a shift of more than 8 is a four byte instruction,
3993 so, for a shift between 8 and 16, it is just as fast to do two
3994 shifts of 8 or less. If there is a lot of shifting going on, we
3995 may win in CSE. Otherwise combine will put the shifts back
3996 together again. This can be called by function_arg, so we must
3997 be careful not to allocate a new register if we've reached the
4001 && GET_CODE (operands[2]) == CONST_INT
4002 && INTVAL (operands[2]) > 8
4003 && INTVAL (operands[2]) <= 16
4004 && !reload_in_progress
4005 && !reload_completed)
4007 rtx temp = gen_reg_rtx (<MODE>mode);
4009 emit_insn (gen_<optab><mode>3 (temp, operands[1], GEN_INT (8)));
4010 emit_insn (gen_<optab><mode>3 (operands[0], temp,
4011 GEN_INT (INTVAL (operands[2]) - 8)));
4016 (define_insn "*<optab><mode>3"
4017 [(set (match_operand:GPR 0 "register_operand" "=d")
4018 (any_shift:GPR (match_operand:GPR 1 "register_operand" "d")
4019 (match_operand:SI 2 "arith_operand" "dI")))]
4022 if (GET_CODE (operands[2]) == CONST_INT)
4023 operands[2] = GEN_INT (INTVAL (operands[2])
4024 & (GET_MODE_BITSIZE (<MODE>mode) - 1));
4026 return "<d><insn>\t%0,%1,%2";
4028 [(set_attr "type" "shift")
4029 (set_attr "mode" "<MODE>")])
4031 (define_insn "*<optab>si3_extend"
4032 [(set (match_operand:DI 0 "register_operand" "=d")
4034 (any_shift:SI (match_operand:SI 1 "register_operand" "d")
4035 (match_operand:SI 2 "arith_operand" "dI"))))]
4036 "TARGET_64BIT && !TARGET_MIPS16"
4038 if (GET_CODE (operands[2]) == CONST_INT)
4039 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
4041 return "<insn>\t%0,%1,%2";
4043 [(set_attr "type" "shift")
4044 (set_attr "mode" "SI")])
4046 (define_insn "*<optab>si3_mips16"
4047 [(set (match_operand:SI 0 "register_operand" "=d,d")
4048 (any_shift:SI (match_operand:SI 1 "register_operand" "0,d")
4049 (match_operand:SI 2 "arith_operand" "d,I")))]
4052 if (which_alternative == 0)
4053 return "<insn>\t%0,%2";
4055 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
4056 return "<insn>\t%0,%1,%2";
4058 [(set_attr "type" "shift")
4059 (set_attr "mode" "SI")
4060 (set_attr_alternative "length"
4062 (if_then_else (match_operand 2 "m16_uimm3_b")
4066 ;; We need separate DImode MIPS16 patterns because of the irregularity
4068 (define_insn "*ashldi3_mips16"
4069 [(set (match_operand:DI 0 "register_operand" "=d,d")
4070 (ashift:DI (match_operand:DI 1 "register_operand" "0,d")
4071 (match_operand:SI 2 "arith_operand" "d,I")))]
4072 "TARGET_64BIT && TARGET_MIPS16"
4074 if (which_alternative == 0)
4075 return "dsll\t%0,%2";
4077 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
4078 return "dsll\t%0,%1,%2";
4080 [(set_attr "type" "shift")
4081 (set_attr "mode" "DI")
4082 (set_attr_alternative "length"
4084 (if_then_else (match_operand 2 "m16_uimm3_b")
4088 (define_insn "*ashrdi3_mips16"
4089 [(set (match_operand:DI 0 "register_operand" "=d,d")
4090 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0,0")
4091 (match_operand:SI 2 "arith_operand" "d,I")))]
4092 "TARGET_64BIT && TARGET_MIPS16"
4094 if (GET_CODE (operands[2]) == CONST_INT)
4095 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
4097 return "dsra\t%0,%2";
4099 [(set_attr "type" "shift")
4100 (set_attr "mode" "DI")
4101 (set_attr_alternative "length"
4103 (if_then_else (match_operand 2 "m16_uimm3_b")
4107 (define_insn "*lshrdi3_mips16"
4108 [(set (match_operand:DI 0 "register_operand" "=d,d")
4109 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0,0")
4110 (match_operand:SI 2 "arith_operand" "d,I")))]
4111 "TARGET_64BIT && TARGET_MIPS16"
4113 if (GET_CODE (operands[2]) == CONST_INT)
4114 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
4116 return "dsrl\t%0,%2";
4118 [(set_attr "type" "shift")
4119 (set_attr "mode" "DI")
4120 (set_attr_alternative "length"
4122 (if_then_else (match_operand 2 "m16_uimm3_b")
4126 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
4129 [(set (match_operand:GPR 0 "register_operand")
4130 (any_shift:GPR (match_operand:GPR 1 "register_operand")
4131 (match_operand:GPR 2 "const_int_operand")))]
4132 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
4133 && GET_CODE (operands[2]) == CONST_INT
4134 && INTVAL (operands[2]) > 8
4135 && INTVAL (operands[2]) <= 16"
4136 [(set (match_dup 0) (any_shift:GPR (match_dup 1) (const_int 8)))
4137 (set (match_dup 0) (any_shift:GPR (match_dup 0) (match_dup 2)))]
4138 { operands[2] = GEN_INT (INTVAL (operands[2]) - 8); })
4140 ;; If we load a byte on the mips16 as a bitfield, the resulting
4141 ;; sequence of instructions is too complicated for combine, because it
4142 ;; involves four instructions: a load, a shift, a constant load into a
4143 ;; register, and an and (the key problem here is that the mips16 does
4144 ;; not have and immediate). We recognize a shift of a load in order
4145 ;; to make it simple enough for combine to understand.
4147 ;; The length here is the worst case: the length of the split version
4148 ;; will be more accurate.
4149 (define_insn_and_split ""
4150 [(set (match_operand:SI 0 "register_operand" "=d")
4151 (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
4152 (match_operand:SI 2 "immediate_operand" "I")))]
4156 [(set (match_dup 0) (match_dup 1))
4157 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
4159 [(set_attr "type" "load")
4160 (set_attr "mode" "SI")
4161 (set_attr "length" "16")])
4163 (define_insn "rotr<mode>3"
4164 [(set (match_operand:GPR 0 "register_operand" "=d")
4165 (rotatert:GPR (match_operand:GPR 1 "register_operand" "d")
4166 (match_operand:SI 2 "arith_operand" "dI")))]
4167 "ISA_HAS_ROTR_<MODE>"
4169 if (GET_CODE (operands[2]) == CONST_INT)
4170 gcc_assert (INTVAL (operands[2]) >= 0
4171 && INTVAL (operands[2]) < GET_MODE_BITSIZE (<MODE>mode));
4173 return "<d>ror\t%0,%1,%2";
4175 [(set_attr "type" "shift")
4176 (set_attr "mode" "<MODE>")])
4179 ;; ....................
4183 ;; ....................
4185 ;; Flow here is rather complex:
4187 ;; 1) The cmp{si,di,sf,df} routine is called. It deposits the arguments
4188 ;; into cmp_operands[] but generates no RTL.
4190 ;; 2) The appropriate branch define_expand is called, which then
4191 ;; creates the appropriate RTL for the comparison and branch.
4192 ;; Different CC modes are used, based on what type of branch is
4193 ;; done, so that we can constrain things appropriately. There
4194 ;; are assumptions in the rest of GCC that break if we fold the
4195 ;; operands into the branches for integer operations, and use cc0
4196 ;; for floating point, so we use the fp status register instead.
4197 ;; If needed, an appropriate temporary is created to hold the
4198 ;; of the integer compare.
4200 (define_expand "cmp<mode>"
4202 (compare:CC (match_operand:GPR 0 "register_operand")
4203 (match_operand:GPR 1 "nonmemory_operand")))]
4206 cmp_operands[0] = operands[0];
4207 cmp_operands[1] = operands[1];
4211 (define_expand "cmp<mode>"
4213 (compare:CC (match_operand:SCALARF 0 "register_operand")
4214 (match_operand:SCALARF 1 "register_operand")))]
4217 cmp_operands[0] = operands[0];
4218 cmp_operands[1] = operands[1];
4223 ;; ....................
4225 ;; CONDITIONAL BRANCHES
4227 ;; ....................
4229 ;; Conditional branches on floating-point equality tests.
4231 (define_insn "branch_fp"
4234 (match_operator:CC 0 "comparison_operator"
4235 [(match_operand:CC 2 "register_operand" "z")
4237 (label_ref (match_operand 1 "" ""))
4241 return mips_output_conditional_branch (insn,
4243 /*two_operands_p=*/0,
4246 get_attr_length (insn));
4248 [(set_attr "type" "branch")
4249 (set_attr "mode" "none")])
4251 (define_insn "branch_fp_inverted"
4254 (match_operator:CC 0 "comparison_operator"
4255 [(match_operand:CC 2 "register_operand" "z")
4258 (label_ref (match_operand 1 "" ""))))]
4261 return mips_output_conditional_branch (insn,
4263 /*two_operands_p=*/0,
4266 get_attr_length (insn));
4268 [(set_attr "type" "branch")
4269 (set_attr "mode" "none")])
4271 ;; Conditional branches on comparisons with zero.
4273 (define_insn "*branch_zero<mode>"
4276 (match_operator:GPR 0 "comparison_operator"
4277 [(match_operand:GPR 2 "register_operand" "d")
4279 (label_ref (match_operand 1 "" ""))
4283 return mips_output_conditional_branch (insn,
4285 /*two_operands_p=*/0,
4288 get_attr_length (insn));
4290 [(set_attr "type" "branch")
4291 (set_attr "mode" "none")])
4293 (define_insn "*branch_zero<mode>_inverted"
4296 (match_operator:GPR 0 "comparison_operator"
4297 [(match_operand:GPR 2 "register_operand" "d")
4300 (label_ref (match_operand 1 "" ""))))]
4303 return mips_output_conditional_branch (insn,
4305 /*two_operands_p=*/0,
4308 get_attr_length (insn));
4310 [(set_attr "type" "branch")
4311 (set_attr "mode" "none")])
4313 ;; Conditional branch on equality comparison.
4315 (define_insn "*branch_equality<mode>"
4318 (match_operator:GPR 0 "equality_operator"
4319 [(match_operand:GPR 2 "register_operand" "d")
4320 (match_operand:GPR 3 "register_operand" "d")])
4321 (label_ref (match_operand 1 "" ""))
4325 return mips_output_conditional_branch (insn,
4327 /*two_operands_p=*/1,
4330 get_attr_length (insn));
4332 [(set_attr "type" "branch")
4333 (set_attr "mode" "none")])
4335 (define_insn "*branch_equality<mode>_inverted"
4338 (match_operator:GPR 0 "equality_operator"
4339 [(match_operand:GPR 2 "register_operand" "d")
4340 (match_operand:GPR 3 "register_operand" "d")])
4342 (label_ref (match_operand 1 "" ""))))]
4345 return mips_output_conditional_branch (insn,
4347 /*two_operands_p=*/1,
4350 get_attr_length (insn));
4352 [(set_attr "type" "branch")
4353 (set_attr "mode" "none")])
4357 (define_insn "*branch_equality<mode>_mips16"
4360 (match_operator:GPR 0 "equality_operator"
4361 [(match_operand:GPR 1 "register_operand" "d,t")
4363 (match_operand 2 "pc_or_label_operand" "")
4364 (match_operand 3 "pc_or_label_operand" "")))]
4367 if (operands[2] != pc_rtx)
4369 if (which_alternative == 0)
4370 return "b%C0z\t%1,%2";
4372 return "bt%C0z\t%2";
4376 if (which_alternative == 0)
4377 return "b%N0z\t%1,%3";
4379 return "bt%N0z\t%3";
4382 [(set_attr "type" "branch")
4383 (set_attr "mode" "none")
4384 (set_attr "length" "8")])
4386 (define_expand "b<code>"
4388 (if_then_else (any_cond:CC (cc0)
4390 (label_ref (match_operand 0 ""))
4394 gen_conditional_branch (operands, <CODE>);
4399 ;; ....................
4401 ;; SETTING A REGISTER FROM A COMPARISON
4403 ;; ....................
4405 (define_expand "seq"
4406 [(set (match_operand:SI 0 "register_operand")
4407 (eq:SI (match_dup 1)
4410 { if (mips_emit_scc (EQ, operands[0])) DONE; else FAIL; })
4412 (define_insn "*seq_<mode>"
4413 [(set (match_operand:GPR 0 "register_operand" "=d")
4414 (eq:GPR (match_operand:GPR 1 "register_operand" "d")
4418 [(set_attr "type" "slt")
4419 (set_attr "mode" "<MODE>")])
4421 (define_insn "*seq_<mode>_mips16"
4422 [(set (match_operand:GPR 0 "register_operand" "=t")
4423 (eq:GPR (match_operand:GPR 1 "register_operand" "d")
4427 [(set_attr "type" "slt")
4428 (set_attr "mode" "<MODE>")])
4430 ;; "sne" uses sltu instructions in which the first operand is $0.
4431 ;; This isn't possible in mips16 code.
4433 (define_expand "sne"
4434 [(set (match_operand:SI 0 "register_operand")
4435 (ne:SI (match_dup 1)
4438 { if (mips_emit_scc (NE, operands[0])) DONE; else FAIL; })
4440 (define_insn "*sne_<mode>"
4441 [(set (match_operand:GPR 0 "register_operand" "=d")
4442 (ne:GPR (match_operand:GPR 1 "register_operand" "d")
4446 [(set_attr "type" "slt")
4447 (set_attr "mode" "<MODE>")])
4449 (define_expand "sgt"
4450 [(set (match_operand:SI 0 "register_operand")
4451 (gt:SI (match_dup 1)
4454 { if (mips_emit_scc (GT, operands[0])) DONE; else FAIL; })
4456 (define_insn "*sgt_<mode>"
4457 [(set (match_operand:GPR 0 "register_operand" "=d")
4458 (gt:GPR (match_operand:GPR 1 "register_operand" "d")
4459 (match_operand:GPR 2 "reg_or_0_operand" "dJ")))]
4462 [(set_attr "type" "slt")
4463 (set_attr "mode" "<MODE>")])
4465 (define_insn "*sgt_<mode>_mips16"
4466 [(set (match_operand:GPR 0 "register_operand" "=t")
4467 (gt:GPR (match_operand:GPR 1 "register_operand" "d")
4468 (match_operand:GPR 2 "register_operand" "d")))]
4471 [(set_attr "type" "slt")
4472 (set_attr "mode" "<MODE>")])
4474 (define_expand "sge"
4475 [(set (match_operand:SI 0 "register_operand")
4476 (ge:SI (match_dup 1)
4479 { if (mips_emit_scc (GE, operands[0])) DONE; else FAIL; })
4481 (define_insn "*sge_<mode>"
4482 [(set (match_operand:GPR 0 "register_operand" "=d")
4483 (ge:GPR (match_operand:GPR 1 "register_operand" "d")
4487 [(set_attr "type" "slt")
4488 (set_attr "mode" "<MODE>")])
4490 (define_expand "slt"
4491 [(set (match_operand:SI 0 "register_operand")
4492 (lt:SI (match_dup 1)
4495 { if (mips_emit_scc (LT, operands[0])) DONE; else FAIL; })
4497 (define_insn "*slt_<mode>"
4498 [(set (match_operand:GPR 0 "register_operand" "=d")
4499 (lt:GPR (match_operand:GPR 1 "register_operand" "d")
4500 (match_operand:GPR 2 "arith_operand" "dI")))]
4503 [(set_attr "type" "slt")
4504 (set_attr "mode" "<MODE>")])
4506 (define_insn "*slt_<mode>_mips16"
4507 [(set (match_operand:GPR 0 "register_operand" "=t,t")
4508 (lt:GPR (match_operand:GPR 1 "register_operand" "d,d")
4509 (match_operand:GPR 2 "arith_operand" "d,I")))]
4512 [(set_attr "type" "slt")
4513 (set_attr "mode" "<MODE>")
4514 (set_attr_alternative "length"
4516 (if_then_else (match_operand 2 "m16_uimm8_1")
4520 (define_expand "sle"
4521 [(set (match_operand:SI 0 "register_operand")
4522 (le:SI (match_dup 1)
4525 { if (mips_emit_scc (LE, operands[0])) DONE; else FAIL; })
4527 (define_insn "*sle_<mode>"
4528 [(set (match_operand:GPR 0 "register_operand" "=d")
4529 (le:GPR (match_operand:GPR 1 "register_operand" "d")
4530 (match_operand:GPR 2 "sle_operand" "")))]
4533 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
4534 return "slt\t%0,%1,%2";
4536 [(set_attr "type" "slt")
4537 (set_attr "mode" "<MODE>")])
4539 (define_insn "*sle_<mode>_mips16"
4540 [(set (match_operand:GPR 0 "register_operand" "=t")
4541 (le:GPR (match_operand:GPR 1 "register_operand" "d")
4542 (match_operand:GPR 2 "sle_operand" "")))]
4545 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
4546 return "slt\t%1,%2";
4548 [(set_attr "type" "slt")
4549 (set_attr "mode" "<MODE>")
4550 (set (attr "length") (if_then_else (match_operand 2 "m16_uimm8_m1_1")
4554 (define_expand "sgtu"
4555 [(set (match_operand:SI 0 "register_operand")
4556 (gtu:SI (match_dup 1)
4559 { if (mips_emit_scc (GTU, operands[0])) DONE; else FAIL; })
4561 (define_insn "*sgtu_<mode>"
4562 [(set (match_operand:GPR 0 "register_operand" "=d")
4563 (gtu:GPR (match_operand:GPR 1 "register_operand" "d")
4564 (match_operand:GPR 2 "reg_or_0_operand" "dJ")))]
4567 [(set_attr "type" "slt")
4568 (set_attr "mode" "<MODE>")])
4570 (define_insn "*sgtu_<mode>_mips16"
4571 [(set (match_operand:GPR 0 "register_operand" "=t")
4572 (gtu:GPR (match_operand:GPR 1 "register_operand" "d")
4573 (match_operand:GPR 2 "register_operand" "d")))]
4576 [(set_attr "type" "slt")
4577 (set_attr "mode" "<MODE>")])
4579 (define_expand "sgeu"
4580 [(set (match_operand:SI 0 "register_operand")
4581 (geu:SI (match_dup 1)
4584 { if (mips_emit_scc (GEU, operands[0])) DONE; else FAIL; })
4586 (define_insn "*sge_<mode>"
4587 [(set (match_operand:GPR 0 "register_operand" "=d")
4588 (geu:GPR (match_operand:GPR 1 "register_operand" "d")
4592 [(set_attr "type" "slt")
4593 (set_attr "mode" "<MODE>")])
4595 (define_expand "sltu"
4596 [(set (match_operand:SI 0 "register_operand")
4597 (ltu:SI (match_dup 1)
4600 { if (mips_emit_scc (LTU, operands[0])) DONE; else FAIL; })
4602 (define_insn "*sltu_<mode>"
4603 [(set (match_operand:GPR 0 "register_operand" "=d")
4604 (ltu:GPR (match_operand:GPR 1 "register_operand" "d")
4605 (match_operand:GPR 2 "arith_operand" "dI")))]
4608 [(set_attr "type" "slt")
4609 (set_attr "mode" "<MODE>")])
4611 (define_insn "*sltu_<mode>_mips16"
4612 [(set (match_operand:GPR 0 "register_operand" "=t,t")
4613 (ltu:GPR (match_operand:GPR 1 "register_operand" "d,d")
4614 (match_operand:GPR 2 "arith_operand" "d,I")))]
4617 [(set_attr "type" "slt")
4618 (set_attr "mode" "<MODE>")
4619 (set_attr_alternative "length"
4621 (if_then_else (match_operand 2 "m16_uimm8_1")
4625 (define_expand "sleu"
4626 [(set (match_operand:SI 0 "register_operand")
4627 (leu:SI (match_dup 1)
4630 { if (mips_emit_scc (LEU, operands[0])) DONE; else FAIL; })
4632 (define_insn "*sleu_<mode>"
4633 [(set (match_operand:GPR 0 "register_operand" "=d")
4634 (leu:GPR (match_operand:GPR 1 "register_operand" "d")
4635 (match_operand:GPR 2 "sleu_operand" "")))]
4638 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
4639 return "sltu\t%0,%1,%2";
4641 [(set_attr "type" "slt")
4642 (set_attr "mode" "<MODE>")])
4644 (define_insn "*sleu_<mode>_mips16"
4645 [(set (match_operand:GPR 0 "register_operand" "=t")
4646 (leu:GPR (match_operand:GPR 1 "register_operand" "d")
4647 (match_operand:GPR 2 "sleu_operand" "")))]
4650 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
4651 return "sltu\t%1,%2";
4653 [(set_attr "type" "slt")
4654 (set_attr "mode" "<MODE>")
4655 (set (attr "length") (if_then_else (match_operand 2 "m16_uimm8_m1_1")
4660 ;; ....................
4662 ;; FLOATING POINT COMPARISONS
4664 ;; ....................
4666 (define_insn "s<code>_<mode>"
4667 [(set (match_operand:CC 0 "register_operand" "=z")
4668 (fcond:CC (match_operand:SCALARF 1 "register_operand" "f")
4669 (match_operand:SCALARF 2 "register_operand" "f")))]
4671 "c.<fcond>.<fmt>\t%Z0%1,%2"
4672 [(set_attr "type" "fcmp")
4673 (set_attr "mode" "FPSW")])
4675 (define_insn "s<code>_<mode>"
4676 [(set (match_operand:CC 0 "register_operand" "=z")
4677 (swapped_fcond:CC (match_operand:SCALARF 1 "register_operand" "f")
4678 (match_operand:SCALARF 2 "register_operand" "f")))]
4680 "c.<swapped_fcond>.<fmt>\t%Z0%2,%1"
4681 [(set_attr "type" "fcmp")
4682 (set_attr "mode" "FPSW")])
4685 ;; ....................
4687 ;; UNCONDITIONAL BRANCHES
4689 ;; ....................
4691 ;; Unconditional branches.
4695 (label_ref (match_operand 0 "" "")))]
4700 if (get_attr_length (insn) <= 8)
4701 return "%*b\t%l0%/";
4704 output_asm_insn (mips_output_load_label (), operands);
4705 return "%*jr\t%@%/%]";
4709 return "%*j\t%l0%/";
4711 [(set_attr "type" "jump")
4712 (set_attr "mode" "none")
4713 (set (attr "length")
4714 ;; We can't use `j' when emitting PIC. Emit a branch if it's
4715 ;; in range, otherwise load the address of the branch target into
4716 ;; $at and then jump to it.
4718 (ior (eq (symbol_ref "flag_pic") (const_int 0))
4719 (lt (abs (minus (match_dup 0)
4720 (plus (pc) (const_int 4))))
4721 (const_int 131072)))
4722 (const_int 4) (const_int 16)))])
4724 ;; We need a different insn for the mips16, because a mips16 branch
4725 ;; does not have a delay slot.
4729 (label_ref (match_operand 0 "" "")))]
4732 [(set_attr "type" "branch")
4733 (set_attr "mode" "none")
4734 (set_attr "length" "8")])
4736 (define_expand "indirect_jump"
4737 [(set (pc) (match_operand 0 "register_operand"))]
4740 operands[0] = force_reg (Pmode, operands[0]);
4741 if (Pmode == SImode)
4742 emit_jump_insn (gen_indirect_jumpsi (operands[0]));
4744 emit_jump_insn (gen_indirect_jumpdi (operands[0]));
4748 (define_insn "indirect_jump<mode>"
4749 [(set (pc) (match_operand:P 0 "register_operand" "d"))]
4752 [(set_attr "type" "jump")
4753 (set_attr "mode" "none")])
4755 (define_expand "tablejump"
4757 (match_operand 0 "register_operand"))
4758 (use (label_ref (match_operand 1 "")))]
4762 operands[0] = expand_binop (Pmode, add_optab,
4763 convert_to_mode (Pmode, operands[0], false),
4764 gen_rtx_LABEL_REF (Pmode, operands[1]),
4766 else if (TARGET_GPWORD)
4767 operands[0] = expand_binop (Pmode, add_optab, operands[0],
4768 pic_offset_table_rtx, 0, 0, OPTAB_WIDEN);
4770 if (Pmode == SImode)
4771 emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
4773 emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
4777 (define_insn "tablejump<mode>"
4779 (match_operand:P 0 "register_operand" "d"))
4780 (use (label_ref (match_operand 1 "" "")))]
4783 [(set_attr "type" "jump")
4784 (set_attr "mode" "none")])
4786 ;; For TARGET_ABICALLS, we save the gp in the jmp_buf as well.
4787 ;; While it is possible to either pull it off the stack (in the
4788 ;; o32 case) or recalculate it given t9 and our target label,
4789 ;; it takes 3 or 4 insns to do so.
4791 (define_expand "builtin_setjmp_setup"
4792 [(use (match_operand 0 "register_operand"))]
4797 addr = plus_constant (operands[0], GET_MODE_SIZE (Pmode) * 3);
4798 emit_move_insn (gen_rtx_MEM (Pmode, addr), pic_offset_table_rtx);
4802 ;; Restore the gp that we saved above. Despite the earlier comment, it seems
4803 ;; that older code did recalculate the gp from $25. Continue to jump through
4804 ;; $25 for compatibility (we lose nothing by doing so).
4806 (define_expand "builtin_longjmp"
4807 [(use (match_operand 0 "register_operand"))]
4810 /* The elements of the buffer are, in order: */
4811 int W = GET_MODE_SIZE (Pmode);
4812 rtx fp = gen_rtx_MEM (Pmode, operands[0]);
4813 rtx lab = gen_rtx_MEM (Pmode, plus_constant (operands[0], 1*W));
4814 rtx stack = gen_rtx_MEM (Pmode, plus_constant (operands[0], 2*W));
4815 rtx gpv = gen_rtx_MEM (Pmode, plus_constant (operands[0], 3*W));
4816 rtx pv = gen_rtx_REG (Pmode, PIC_FUNCTION_ADDR_REGNUM);
4817 /* Use gen_raw_REG to avoid being given pic_offset_table_rtx.
4818 The target is bound to be using $28 as the global pointer
4819 but the current function might not be. */
4820 rtx gp = gen_raw_REG (Pmode, GLOBAL_POINTER_REGNUM);
4822 /* This bit is similar to expand_builtin_longjmp except that it
4823 restores $gp as well. */
4824 emit_move_insn (hard_frame_pointer_rtx, fp);
4825 emit_move_insn (pv, lab);
4826 emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
4827 emit_move_insn (gp, gpv);
4828 emit_insn (gen_rtx_USE (VOIDmode, hard_frame_pointer_rtx));
4829 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
4830 emit_insn (gen_rtx_USE (VOIDmode, gp));
4831 emit_indirect_jump (pv);
4836 ;; ....................
4838 ;; Function prologue/epilogue
4840 ;; ....................
4843 (define_expand "prologue"
4847 mips_expand_prologue ();
4851 ;; Block any insns from being moved before this point, since the
4852 ;; profiling call to mcount can use various registers that aren't
4853 ;; saved or used to pass arguments.
4855 (define_insn "blockage"
4856 [(unspec_volatile [(const_int 0)] UNSPEC_BLOCKAGE)]
4859 [(set_attr "type" "unknown")
4860 (set_attr "mode" "none")
4861 (set_attr "length" "0")])
4863 (define_expand "epilogue"
4867 mips_expand_epilogue (false);
4871 (define_expand "sibcall_epilogue"
4875 mips_expand_epilogue (true);
4879 ;; Trivial return. Make it look like a normal return insn as that
4880 ;; allows jump optimizations to work better.
4882 (define_insn "return"
4884 "mips_can_use_return_insn ()"
4886 [(set_attr "type" "jump")
4887 (set_attr "mode" "none")])
4891 (define_insn "return_internal"
4893 (use (match_operand 0 "pmode_register_operand" ""))]
4896 [(set_attr "type" "jump")
4897 (set_attr "mode" "none")])
4899 ;; This is used in compiling the unwind routines.
4900 (define_expand "eh_return"
4901 [(use (match_operand 0 "general_operand"))]
4904 enum machine_mode gpr_mode = TARGET_64BIT ? DImode : SImode;
4906 if (GET_MODE (operands[0]) != gpr_mode)
4907 operands[0] = convert_to_mode (gpr_mode, operands[0], 0);
4909 emit_insn (gen_eh_set_lr_di (operands[0]));
4911 emit_insn (gen_eh_set_lr_si (operands[0]));
4916 ;; Clobber the return address on the stack. We can't expand this
4917 ;; until we know where it will be put in the stack frame.
4919 (define_insn "eh_set_lr_si"
4920 [(unspec [(match_operand:SI 0 "register_operand" "d")] UNSPEC_EH_RETURN)
4921 (clobber (match_scratch:SI 1 "=&d"))]
4925 (define_insn "eh_set_lr_di"
4926 [(unspec [(match_operand:DI 0 "register_operand" "d")] UNSPEC_EH_RETURN)
4927 (clobber (match_scratch:DI 1 "=&d"))]
4932 [(unspec [(match_operand 0 "register_operand")] UNSPEC_EH_RETURN)
4933 (clobber (match_scratch 1))]
4934 "reload_completed && !TARGET_DEBUG_D_MODE"
4937 mips_set_return_address (operands[0], operands[1]);
4941 (define_insn_and_split "exception_receiver"
4943 (unspec_volatile:SI [(const_int 0)] UNSPEC_EH_RECEIVER))]
4944 "TARGET_ABICALLS && TARGET_OLDABI"
4946 "&& reload_completed"
4952 [(set_attr "type" "load")
4953 (set_attr "length" "12")])
4956 ;; ....................
4960 ;; ....................
4962 ;; Instructions to load a call address from the GOT. The address might
4963 ;; point to a function or to a lazy binding stub. In the latter case,
4964 ;; the stub will use the dynamic linker to resolve the function, which
4965 ;; in turn will change the GOT entry to point to the function's real
4968 ;; This means that every call, even pure and constant ones, can
4969 ;; potentially modify the GOT entry. And once a stub has been called,
4970 ;; we must not call it again.
4972 ;; We represent this restriction using an imaginary fixed register that
4973 ;; acts like a GOT version number. By making the register call-clobbered,
4974 ;; we tell the target-independent code that the address could be changed
4975 ;; by any call insn.
4976 (define_insn "load_call<mode>"
4977 [(set (match_operand:P 0 "register_operand" "=c")
4978 (unspec:P [(match_operand:P 1 "register_operand" "r")
4979 (match_operand:P 2 "immediate_operand" "")
4980 (reg:P FAKE_CALL_REGNO)]
4983 "<load>\t%0,%R2(%1)"
4984 [(set_attr "type" "load")
4985 (set_attr "mode" "<MODE>")
4986 (set_attr "length" "4")])
4988 ;; Sibling calls. All these patterns use jump instructions.
4990 ;; If TARGET_SIBCALLS, call_insn_operand will only accept constant
4991 ;; addresses if a direct jump is acceptable. Since the 'S' constraint
4992 ;; is defined in terms of call_insn_operand, the same is true of the
4995 ;; When we use an indirect jump, we need a register that will be
4996 ;; preserved by the epilogue. Since TARGET_ABICALLS forces us to
4997 ;; use $25 for this purpose -- and $25 is never clobbered by the
4998 ;; epilogue -- we might as well use it for !TARGET_ABICALLS as well.
5000 (define_expand "sibcall"
5001 [(parallel [(call (match_operand 0 "")
5002 (match_operand 1 ""))
5003 (use (match_operand 2 "")) ;; next_arg_reg
5004 (use (match_operand 3 ""))])] ;; struct_value_size_rtx
5007 mips_expand_call (0, XEXP (operands[0], 0), operands[1], operands[2], true);
5011 (define_insn "sibcall_internal"
5012 [(call (mem:SI (match_operand 0 "call_insn_operand" "j,S"))
5013 (match_operand 1 "" ""))]
5014 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
5018 [(set_attr "type" "call")])
5020 (define_expand "sibcall_value"
5021 [(parallel [(set (match_operand 0 "")
5022 (call (match_operand 1 "")
5023 (match_operand 2 "")))
5024 (use (match_operand 3 ""))])] ;; next_arg_reg
5027 mips_expand_call (operands[0], XEXP (operands[1], 0),
5028 operands[2], operands[3], true);
5032 (define_insn "sibcall_value_internal"
5033 [(set (match_operand 0 "register_operand" "=df,df")
5034 (call (mem:SI (match_operand 1 "call_insn_operand" "j,S"))
5035 (match_operand 2 "" "")))]
5036 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
5040 [(set_attr "type" "call")])
5042 (define_insn "sibcall_value_multiple_internal"
5043 [(set (match_operand 0 "register_operand" "=df,df")
5044 (call (mem:SI (match_operand 1 "call_insn_operand" "j,S"))
5045 (match_operand 2 "" "")))
5046 (set (match_operand 3 "register_operand" "=df,df")
5047 (call (mem:SI (match_dup 1))
5049 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
5053 [(set_attr "type" "call")])
5055 (define_expand "call"
5056 [(parallel [(call (match_operand 0 "")
5057 (match_operand 1 ""))
5058 (use (match_operand 2 "")) ;; next_arg_reg
5059 (use (match_operand 3 ""))])] ;; struct_value_size_rtx
5062 mips_expand_call (0, XEXP (operands[0], 0), operands[1], operands[2], false);
5066 ;; This instruction directly corresponds to an assembly-language "jal".
5067 ;; There are four cases:
5070 ;; Both symbolic and register destinations are OK. The pattern
5071 ;; always expands to a single mips instruction.
5073 ;; - -mabicalls/-mno-explicit-relocs:
5074 ;; Again, both symbolic and register destinations are OK.
5075 ;; The call is treated as a multi-instruction black box.
5077 ;; - -mabicalls/-mexplicit-relocs with n32 or n64:
5078 ;; Only "jal $25" is allowed. This expands to a single "jalr $25"
5081 ;; - -mabicalls/-mexplicit-relocs with o32 or o64:
5082 ;; Only "jal $25" is allowed. The call is actually two instructions:
5083 ;; "jalr $25" followed by an insn to reload $gp.
5085 ;; In the last case, we can generate the individual instructions with
5086 ;; a define_split. There are several things to be wary of:
5088 ;; - We can't expose the load of $gp before reload. If we did,
5089 ;; it might get removed as dead, but reload can introduce new
5090 ;; uses of $gp by rematerializing constants.
5092 ;; - We shouldn't restore $gp after calls that never return.
5093 ;; It isn't valid to insert instructions between a noreturn
5094 ;; call and the following barrier.
5096 ;; - The splitter deliberately changes the liveness of $gp. The unsplit
5097 ;; instruction preserves $gp and so have no effect on its liveness.
5098 ;; But once we generate the separate insns, it becomes obvious that
5099 ;; $gp is not live on entry to the call.
5101 ;; ??? The operands[2] = insn check is a hack to make the original insn
5102 ;; available to the splitter.
5103 (define_insn_and_split "call_internal"
5104 [(call (mem:SI (match_operand 0 "call_insn_operand" "c,S"))
5105 (match_operand 1 "" ""))
5106 (clobber (reg:SI 31))]
5108 { return TARGET_SPLIT_CALLS ? "#" : "%*jal\t%0%/"; }
5109 "reload_completed && TARGET_SPLIT_CALLS && (operands[2] = insn)"
5112 emit_call_insn (gen_call_split (operands[0], operands[1]));
5113 if (!find_reg_note (operands[2], REG_NORETURN, 0))
5117 [(set_attr "jal" "indirect,direct")
5118 (set_attr "extended_mips16" "no,yes")])
5120 (define_insn "call_split"
5121 [(call (mem:SI (match_operand 0 "call_insn_operand" "c"))
5122 (match_operand 1 "" ""))
5123 (clobber (reg:SI 31))
5124 (clobber (reg:SI 28))]
5125 "TARGET_SPLIT_CALLS"
5127 [(set_attr "type" "call")])
5129 (define_expand "call_value"
5130 [(parallel [(set (match_operand 0 "")
5131 (call (match_operand 1 "")
5132 (match_operand 2 "")))
5133 (use (match_operand 3 ""))])] ;; next_arg_reg
5136 mips_expand_call (operands[0], XEXP (operands[1], 0),
5137 operands[2], operands[3], false);
5141 ;; See comment for call_internal.
5142 (define_insn_and_split "call_value_internal"
5143 [(set (match_operand 0 "register_operand" "=df,df")
5144 (call (mem:SI (match_operand 1 "call_insn_operand" "c,S"))
5145 (match_operand 2 "" "")))
5146 (clobber (reg:SI 31))]
5148 { return TARGET_SPLIT_CALLS ? "#" : "%*jal\t%1%/"; }
5149 "reload_completed && TARGET_SPLIT_CALLS && (operands[3] = insn)"
5152 emit_call_insn (gen_call_value_split (operands[0], operands[1],
5154 if (!find_reg_note (operands[3], REG_NORETURN, 0))
5158 [(set_attr "jal" "indirect,direct")
5159 (set_attr "extended_mips16" "no,yes")])
5161 (define_insn "call_value_split"
5162 [(set (match_operand 0 "register_operand" "=df")
5163 (call (mem:SI (match_operand 1 "call_insn_operand" "c"))
5164 (match_operand 2 "" "")))
5165 (clobber (reg:SI 31))
5166 (clobber (reg:SI 28))]
5167 "TARGET_SPLIT_CALLS"
5169 [(set_attr "type" "call")])
5171 ;; See comment for call_internal.
5172 (define_insn_and_split "call_value_multiple_internal"
5173 [(set (match_operand 0 "register_operand" "=df,df")
5174 (call (mem:SI (match_operand 1 "call_insn_operand" "c,S"))
5175 (match_operand 2 "" "")))
5176 (set (match_operand 3 "register_operand" "=df,df")
5177 (call (mem:SI (match_dup 1))
5179 (clobber (reg:SI 31))]
5181 { return TARGET_SPLIT_CALLS ? "#" : "%*jal\t%1%/"; }
5182 "reload_completed && TARGET_SPLIT_CALLS && (operands[4] = insn)"
5185 emit_call_insn (gen_call_value_multiple_split (operands[0], operands[1],
5186 operands[2], operands[3]));
5187 if (!find_reg_note (operands[4], REG_NORETURN, 0))
5191 [(set_attr "jal" "indirect,direct")
5192 (set_attr "extended_mips16" "no,yes")])
5194 (define_insn "call_value_multiple_split"
5195 [(set (match_operand 0 "register_operand" "=df")
5196 (call (mem:SI (match_operand 1 "call_insn_operand" "c"))
5197 (match_operand 2 "" "")))
5198 (set (match_operand 3 "register_operand" "=df")
5199 (call (mem:SI (match_dup 1))
5201 (clobber (reg:SI 31))
5202 (clobber (reg:SI 28))]
5203 "TARGET_SPLIT_CALLS"
5205 [(set_attr "type" "call")])
5207 ;; Call subroutine returning any type.
5209 (define_expand "untyped_call"
5210 [(parallel [(call (match_operand 0 "")
5212 (match_operand 1 "")
5213 (match_operand 2 "")])]
5218 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
5220 for (i = 0; i < XVECLEN (operands[2], 0); i++)
5222 rtx set = XVECEXP (operands[2], 0, i);
5223 emit_move_insn (SET_DEST (set), SET_SRC (set));
5226 emit_insn (gen_blockage ());
5231 ;; ....................
5235 ;; ....................
5239 (define_insn "prefetch"
5240 [(prefetch (match_operand:QI 0 "address_operand" "p")
5241 (match_operand 1 "const_int_operand" "n")
5242 (match_operand 2 "const_int_operand" "n"))]
5243 "ISA_HAS_PREFETCH && TARGET_EXPLICIT_RELOCS"
5245 operands[1] = mips_prefetch_cookie (operands[1], operands[2]);
5246 return "pref\t%1,%a0";
5248 [(set_attr "type" "prefetch")])
5250 (define_insn "*prefetch_indexed_<mode>"
5251 [(prefetch (plus:P (match_operand:P 0 "register_operand" "d")
5252 (match_operand:P 1 "register_operand" "d"))
5253 (match_operand 2 "const_int_operand" "n")
5254 (match_operand 3 "const_int_operand" "n"))]
5255 "ISA_HAS_PREFETCHX && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
5257 operands[2] = mips_prefetch_cookie (operands[2], operands[3]);
5258 return "prefx\t%2,%1(%0)";
5260 [(set_attr "type" "prefetchx")])
5266 [(set_attr "type" "nop")
5267 (set_attr "mode" "none")])
5269 ;; Like nop, but commented out when outside a .set noreorder block.
5270 (define_insn "hazard_nop"
5279 [(set_attr "type" "nop")])
5281 ;; MIPS4 Conditional move instructions.
5283 (define_insn "*mov<GPR:mode>_on_<MOVECC:mode>"
5284 [(set (match_operand:GPR 0 "register_operand" "=d,d")
5286 (match_operator:MOVECC 4 "equality_operator"
5287 [(match_operand:MOVECC 1 "register_operand" "<MOVECC:reg>,<MOVECC:reg>")
5289 (match_operand:GPR 2 "reg_or_0_operand" "dJ,0")
5290 (match_operand:GPR 3 "reg_or_0_operand" "0,dJ")))]
5295 [(set_attr "type" "condmove")
5296 (set_attr "mode" "<GPR:MODE>")])
5298 (define_insn "*mov<SCALARF:mode>_on_<MOVECC:mode>"
5299 [(set (match_operand:SCALARF 0 "register_operand" "=f,f")
5300 (if_then_else:SCALARF
5301 (match_operator:MOVECC 4 "equality_operator"
5302 [(match_operand:MOVECC 1 "register_operand" "<MOVECC:reg>,<MOVECC:reg>")
5304 (match_operand:SCALARF 2 "register_operand" "f,0")
5305 (match_operand:SCALARF 3 "register_operand" "0,f")))]
5308 mov%T4.<fmt>\t%0,%2,%1
5309 mov%t4.<fmt>\t%0,%3,%1"
5310 [(set_attr "type" "condmove")
5311 (set_attr "mode" "<SCALARF:MODE>")])
5313 ;; These are the main define_expand's used to make conditional moves.
5315 (define_expand "mov<mode>cc"
5316 [(set (match_dup 4) (match_operand 1 "comparison_operator"))
5317 (set (match_operand:GPR 0 "register_operand")
5318 (if_then_else:GPR (match_dup 5)
5319 (match_operand:GPR 2 "reg_or_0_operand")
5320 (match_operand:GPR 3 "reg_or_0_operand")))]
5323 gen_conditional_move (operands);
5327 (define_expand "mov<mode>cc"
5328 [(set (match_dup 4) (match_operand 1 "comparison_operator"))
5329 (set (match_operand:SCALARF 0 "register_operand")
5330 (if_then_else:SCALARF (match_dup 5)
5331 (match_operand:SCALARF 2 "register_operand")
5332 (match_operand:SCALARF 3 "register_operand")))]
5335 gen_conditional_move (operands);
5340 ;; ....................
5342 ;; mips16 inline constant tables
5344 ;; ....................
5347 (define_insn "consttable_int"
5348 [(unspec_volatile [(match_operand 0 "consttable_operand" "")
5349 (match_operand 1 "const_int_operand" "")]
5350 UNSPEC_CONSTTABLE_INT)]
5353 assemble_integer (operands[0], INTVAL (operands[1]),
5354 BITS_PER_UNIT * INTVAL (operands[1]), 1);
5357 [(set (attr "length") (symbol_ref "INTVAL (operands[1])"))])
5359 (define_insn "consttable_float"
5360 [(unspec_volatile [(match_operand 0 "consttable_operand" "")]
5361 UNSPEC_CONSTTABLE_FLOAT)]
5366 gcc_assert (GET_CODE (operands[0]) == CONST_DOUBLE);
5367 REAL_VALUE_FROM_CONST_DOUBLE (d, operands[0]);
5368 assemble_real (d, GET_MODE (operands[0]),
5369 GET_MODE_BITSIZE (GET_MODE (operands[0])));
5372 [(set (attr "length")
5373 (symbol_ref "GET_MODE_SIZE (GET_MODE (operands[0]))"))])
5375 (define_insn "align"
5376 [(unspec_volatile [(match_operand 0 "const_int_operand" "")] UNSPEC_ALIGN)]
5379 [(set (attr "length") (symbol_ref "(1 << INTVAL (operands[0])) - 1"))])
5382 [(match_operand 0 "small_data_pattern")]
5385 { operands[0] = mips_rewrite_small_data (operands[0]); })
5387 ; Thread-Local Storage
5389 ; The TLS base pointer is accessed via "rdhwr $v1, $29". No current
5390 ; MIPS architecture defines this register, and no current
5391 ; implementation provides it; instead, any OS which supports TLS is
5392 ; expected to trap and emulate this instruction. rdhwr is part of the
5393 ; MIPS 32r2 specification, but we use it on any architecture because
5394 ; we expect it to be emulated. Use .set to force the assembler to
5397 (define_insn "tls_get_tp_<mode>"
5398 [(set (match_operand:P 0 "register_operand" "=v")
5399 (unspec:P [(const_int 0)]
5400 UNSPEC_TLS_GET_TP))]
5401 "HAVE_AS_TLS && !TARGET_MIPS16"
5402 ".set\tpush\;.set\tmips32r2\t\;rdhwr\t%0,$29\;.set\tpop"
5403 [(set_attr "type" "unknown")
5404 (set_attr "mode" "<MODE>")])
5406 ; The MIPS Paired-Single Floating Point and MIPS-3D Instructions.
5408 (include "mips-ps-3d.md")