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 && !memory_operand (operands[1], <SHORT:MODE>mode))
2324 emit_insn (gen_and<GPR:mode>3 (operands[0],
2325 gen_lowpart (<GPR:MODE>mode, operands[1]),
2326 force_reg (<GPR:MODE>mode,
2327 GEN_INT (<SHORT:mask>))));
2332 (define_insn "*zero_extend<SHORT:mode><GPR:mode>2"
2333 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2335 (match_operand:SHORT 1 "nonimmediate_operand" "d,m")))]
2338 andi\t%0,%1,<SHORT:mask>
2339 l<SHORT:size>u\t%0,%1"
2340 [(set_attr "type" "arith,load")
2341 (set_attr "mode" "<GPR:MODE>")])
2343 (define_insn "*zero_extend<SHORT:mode><GPR:mode>2_mips16"
2344 [(set (match_operand:GPR 0 "register_operand" "=d")
2345 (zero_extend:GPR (match_operand:SHORT 1 "memory_operand" "m")))]
2347 "l<SHORT:size>u\t%0,%1"
2348 [(set_attr "type" "load")
2349 (set_attr "mode" "<GPR:MODE>")])
2351 (define_expand "zero_extendqihi2"
2352 [(set (match_operand:HI 0 "register_operand")
2353 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand")))]
2356 if (TARGET_MIPS16 && !memory_operand (operands[1], QImode))
2358 emit_insn (gen_zero_extendqisi2 (gen_lowpart (SImode, operands[0]),
2364 (define_insn "*zero_extendqihi2"
2365 [(set (match_operand:HI 0 "register_operand" "=d,d")
2366 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
2371 [(set_attr "type" "arith,load")
2372 (set_attr "mode" "HI")])
2374 (define_insn "*zero_extendqihi2_mips16"
2375 [(set (match_operand:HI 0 "register_operand" "=d")
2376 (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
2379 [(set_attr "type" "load")
2380 (set_attr "mode" "HI")])
2383 ;; ....................
2387 ;; ....................
2390 ;; Those for integer source operand are ordered widest source type first.
2392 ;; When TARGET_64BIT, all SImode integer registers should already be in
2393 ;; sign-extended form (see TRULY_NOOP_TRUNCATION and truncdisi2). We can
2394 ;; therefore get rid of register->register instructions if we constrain
2395 ;; the source to be in the same register as the destination.
2397 ;; The register alternative has type "arith" so that the pre-reload
2398 ;; scheduler will treat it as a move. This reflects what happens if
2399 ;; the register alternative needs a reload.
2400 (define_insn_and_split "extendsidi2"
2401 [(set (match_operand:DI 0 "register_operand" "=d,d")
2402 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "0,m")))]
2407 "&& reload_completed && register_operand (operands[1], VOIDmode)"
2410 emit_note (NOTE_INSN_DELETED);
2413 [(set_attr "type" "arith,load")
2414 (set_attr "mode" "DI")])
2416 (define_expand "extend<SHORT:mode><GPR:mode>2"
2417 [(set (match_operand:GPR 0 "register_operand")
2418 (sign_extend:GPR (match_operand:SHORT 1 "nonimmediate_operand")))]
2421 (define_insn_and_split "*extend<SHORT:mode><GPR:mode>2"
2422 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2424 (match_operand:SHORT 1 "nonimmediate_operand" "d,m")))]
2428 l<SHORT:size>\t%0,%1"
2429 "&& reload_completed && REG_P (operands[1])"
2430 [(set (match_dup 0) (ashift:GPR (match_dup 1) (match_dup 2)))
2431 (set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))]
2433 operands[1] = gen_lowpart (<GPR:MODE>mode, operands[1]);
2434 operands[2] = GEN_INT (GET_MODE_BITSIZE (<GPR:MODE>mode)
2435 - GET_MODE_BITSIZE (<SHORT:MODE>mode));
2437 [(set_attr "type" "arith,load")
2438 (set_attr "mode" "<GPR:MODE>")
2439 (set_attr "length" "8,*")])
2441 (define_insn "*extend<SHORT:mode><GPR:mode>2_se<SHORT:size>"
2442 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2444 (match_operand:SHORT 1 "nonimmediate_operand" "d,m")))]
2447 se<SHORT:size>\t%0,%1
2448 l<SHORT:size>\t%0,%1"
2449 [(set_attr "type" "arith,load")
2450 (set_attr "mode" "<GPR:MODE>")])
2452 ;; This pattern generates the same code as extendqisi2; split it into
2453 ;; that form after reload.
2454 (define_insn_and_split "extendqihi2"
2455 [(set (match_operand:HI 0 "register_operand" "=d,d")
2456 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
2460 [(set (match_dup 0) (sign_extend:SI (match_dup 1)))]
2461 { operands[0] = gen_lowpart (SImode, operands[0]); }
2462 [(set_attr "type" "arith,load")
2463 (set_attr "mode" "SI")
2464 (set_attr "length" "8,*")])
2466 (define_insn "extendsfdf2"
2467 [(set (match_operand:DF 0 "register_operand" "=f")
2468 (float_extend:DF (match_operand:SF 1 "register_operand" "f")))]
2469 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2471 [(set_attr "type" "fcvt")
2472 (set_attr "cnv_mode" "S2D")
2473 (set_attr "mode" "DF")])
2476 ;; ....................
2480 ;; ....................
2482 (define_expand "fix_truncdfsi2"
2483 [(set (match_operand:SI 0 "register_operand")
2484 (fix:SI (match_operand:DF 1 "register_operand")))]
2485 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2487 if (!ISA_HAS_TRUNC_W)
2489 emit_insn (gen_fix_truncdfsi2_macro (operands[0], operands[1]));
2494 (define_insn "fix_truncdfsi2_insn"
2495 [(set (match_operand:SI 0 "register_operand" "=f")
2496 (fix:SI (match_operand:DF 1 "register_operand" "f")))]
2497 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && ISA_HAS_TRUNC_W"
2499 [(set_attr "type" "fcvt")
2500 (set_attr "mode" "DF")
2501 (set_attr "cnv_mode" "D2I")
2502 (set_attr "length" "4")])
2504 (define_insn "fix_truncdfsi2_macro"
2505 [(set (match_operand:SI 0 "register_operand" "=f")
2506 (fix:SI (match_operand:DF 1 "register_operand" "f")))
2507 (clobber (match_scratch:DF 2 "=d"))]
2508 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !ISA_HAS_TRUNC_W"
2511 return ".set\tmacro\;trunc.w.d %0,%1,%2\;.set\tnomacro";
2513 return "trunc.w.d %0,%1,%2";
2515 [(set_attr "type" "fcvt")
2516 (set_attr "mode" "DF")
2517 (set_attr "cnv_mode" "D2I")
2518 (set_attr "length" "36")])
2520 (define_expand "fix_truncsfsi2"
2521 [(set (match_operand:SI 0 "register_operand")
2522 (fix:SI (match_operand:SF 1 "register_operand")))]
2525 if (!ISA_HAS_TRUNC_W)
2527 emit_insn (gen_fix_truncsfsi2_macro (operands[0], operands[1]));
2532 (define_insn "fix_truncsfsi2_insn"
2533 [(set (match_operand:SI 0 "register_operand" "=f")
2534 (fix:SI (match_operand:SF 1 "register_operand" "f")))]
2535 "TARGET_HARD_FLOAT && ISA_HAS_TRUNC_W"
2537 [(set_attr "type" "fcvt")
2538 (set_attr "mode" "SF")
2539 (set_attr "cnv_mode" "S2I")
2540 (set_attr "length" "4")])
2542 (define_insn "fix_truncsfsi2_macro"
2543 [(set (match_operand:SI 0 "register_operand" "=f")
2544 (fix:SI (match_operand:SF 1 "register_operand" "f")))
2545 (clobber (match_scratch:SF 2 "=d"))]
2546 "TARGET_HARD_FLOAT && !ISA_HAS_TRUNC_W"
2549 return ".set\tmacro\;trunc.w.s %0,%1,%2\;.set\tnomacro";
2551 return "trunc.w.s %0,%1,%2";
2553 [(set_attr "type" "fcvt")
2554 (set_attr "mode" "SF")
2555 (set_attr "cnv_mode" "S2I")
2556 (set_attr "length" "36")])
2559 (define_insn "fix_truncdfdi2"
2560 [(set (match_operand:DI 0 "register_operand" "=f")
2561 (fix:DI (match_operand:DF 1 "register_operand" "f")))]
2562 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
2564 [(set_attr "type" "fcvt")
2565 (set_attr "mode" "DF")
2566 (set_attr "cnv_mode" "D2I")
2567 (set_attr "length" "4")])
2570 (define_insn "fix_truncsfdi2"
2571 [(set (match_operand:DI 0 "register_operand" "=f")
2572 (fix:DI (match_operand:SF 1 "register_operand" "f")))]
2573 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
2575 [(set_attr "type" "fcvt")
2576 (set_attr "mode" "SF")
2577 (set_attr "cnv_mode" "S2I")
2578 (set_attr "length" "4")])
2581 (define_insn "floatsidf2"
2582 [(set (match_operand:DF 0 "register_operand" "=f")
2583 (float:DF (match_operand:SI 1 "register_operand" "f")))]
2584 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2586 [(set_attr "type" "fcvt")
2587 (set_attr "mode" "DF")
2588 (set_attr "cnv_mode" "I2D")
2589 (set_attr "length" "4")])
2592 (define_insn "floatdidf2"
2593 [(set (match_operand:DF 0 "register_operand" "=f")
2594 (float:DF (match_operand:DI 1 "register_operand" "f")))]
2595 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
2597 [(set_attr "type" "fcvt")
2598 (set_attr "mode" "DF")
2599 (set_attr "cnv_mode" "I2D")
2600 (set_attr "length" "4")])
2603 (define_insn "floatsisf2"
2604 [(set (match_operand:SF 0 "register_operand" "=f")
2605 (float:SF (match_operand:SI 1 "register_operand" "f")))]
2608 [(set_attr "type" "fcvt")
2609 (set_attr "mode" "SF")
2610 (set_attr "cnv_mode" "I2S")
2611 (set_attr "length" "4")])
2614 (define_insn "floatdisf2"
2615 [(set (match_operand:SF 0 "register_operand" "=f")
2616 (float:SF (match_operand:DI 1 "register_operand" "f")))]
2617 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
2619 [(set_attr "type" "fcvt")
2620 (set_attr "mode" "SF")
2621 (set_attr "cnv_mode" "I2S")
2622 (set_attr "length" "4")])
2625 (define_expand "fixuns_truncdfsi2"
2626 [(set (match_operand:SI 0 "register_operand")
2627 (unsigned_fix:SI (match_operand:DF 1 "register_operand")))]
2628 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2630 rtx reg1 = gen_reg_rtx (DFmode);
2631 rtx reg2 = gen_reg_rtx (DFmode);
2632 rtx reg3 = gen_reg_rtx (SImode);
2633 rtx label1 = gen_label_rtx ();
2634 rtx label2 = gen_label_rtx ();
2635 REAL_VALUE_TYPE offset;
2637 real_2expN (&offset, 31);
2639 if (reg1) /* Turn off complaints about unreached code. */
2641 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, DFmode));
2642 do_pending_stack_adjust ();
2644 emit_insn (gen_cmpdf (operands[1], reg1));
2645 emit_jump_insn (gen_bge (label1));
2647 emit_insn (gen_fix_truncdfsi2 (operands[0], operands[1]));
2648 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
2649 gen_rtx_LABEL_REF (VOIDmode, label2)));
2652 emit_label (label1);
2653 emit_move_insn (reg2, gen_rtx_MINUS (DFmode, operands[1], reg1));
2654 emit_move_insn (reg3, GEN_INT (trunc_int_for_mode
2655 (BITMASK_HIGH, SImode)));
2657 emit_insn (gen_fix_truncdfsi2 (operands[0], reg2));
2658 emit_insn (gen_iorsi3 (operands[0], operands[0], reg3));
2660 emit_label (label2);
2662 /* Allow REG_NOTES to be set on last insn (labels don't have enough
2663 fields, and can't be used for REG_NOTES anyway). */
2664 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
2670 (define_expand "fixuns_truncdfdi2"
2671 [(set (match_operand:DI 0 "register_operand")
2672 (unsigned_fix:DI (match_operand:DF 1 "register_operand")))]
2673 "TARGET_HARD_FLOAT && TARGET_64BIT && TARGET_DOUBLE_FLOAT"
2675 rtx reg1 = gen_reg_rtx (DFmode);
2676 rtx reg2 = gen_reg_rtx (DFmode);
2677 rtx reg3 = gen_reg_rtx (DImode);
2678 rtx label1 = gen_label_rtx ();
2679 rtx label2 = gen_label_rtx ();
2680 REAL_VALUE_TYPE offset;
2682 real_2expN (&offset, 63);
2684 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, DFmode));
2685 do_pending_stack_adjust ();
2687 emit_insn (gen_cmpdf (operands[1], reg1));
2688 emit_jump_insn (gen_bge (label1));
2690 emit_insn (gen_fix_truncdfdi2 (operands[0], operands[1]));
2691 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
2692 gen_rtx_LABEL_REF (VOIDmode, label2)));
2695 emit_label (label1);
2696 emit_move_insn (reg2, gen_rtx_MINUS (DFmode, operands[1], reg1));
2697 emit_move_insn (reg3, GEN_INT (BITMASK_HIGH));
2698 emit_insn (gen_ashldi3 (reg3, reg3, GEN_INT (32)));
2700 emit_insn (gen_fix_truncdfdi2 (operands[0], reg2));
2701 emit_insn (gen_iordi3 (operands[0], operands[0], reg3));
2703 emit_label (label2);
2705 /* Allow REG_NOTES to be set on last insn (labels don't have enough
2706 fields, and can't be used for REG_NOTES anyway). */
2707 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
2712 (define_expand "fixuns_truncsfsi2"
2713 [(set (match_operand:SI 0 "register_operand")
2714 (unsigned_fix:SI (match_operand:SF 1 "register_operand")))]
2717 rtx reg1 = gen_reg_rtx (SFmode);
2718 rtx reg2 = gen_reg_rtx (SFmode);
2719 rtx reg3 = gen_reg_rtx (SImode);
2720 rtx label1 = gen_label_rtx ();
2721 rtx label2 = gen_label_rtx ();
2722 REAL_VALUE_TYPE offset;
2724 real_2expN (&offset, 31);
2726 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, SFmode));
2727 do_pending_stack_adjust ();
2729 emit_insn (gen_cmpsf (operands[1], reg1));
2730 emit_jump_insn (gen_bge (label1));
2732 emit_insn (gen_fix_truncsfsi2 (operands[0], operands[1]));
2733 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
2734 gen_rtx_LABEL_REF (VOIDmode, label2)));
2737 emit_label (label1);
2738 emit_move_insn (reg2, gen_rtx_MINUS (SFmode, operands[1], reg1));
2739 emit_move_insn (reg3, GEN_INT (trunc_int_for_mode
2740 (BITMASK_HIGH, SImode)));
2742 emit_insn (gen_fix_truncsfsi2 (operands[0], reg2));
2743 emit_insn (gen_iorsi3 (operands[0], operands[0], reg3));
2745 emit_label (label2);
2747 /* Allow REG_NOTES to be set on last insn (labels don't have enough
2748 fields, and can't be used for REG_NOTES anyway). */
2749 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
2754 (define_expand "fixuns_truncsfdi2"
2755 [(set (match_operand:DI 0 "register_operand")
2756 (unsigned_fix:DI (match_operand:SF 1 "register_operand")))]
2757 "TARGET_HARD_FLOAT && TARGET_64BIT && TARGET_DOUBLE_FLOAT"
2759 rtx reg1 = gen_reg_rtx (SFmode);
2760 rtx reg2 = gen_reg_rtx (SFmode);
2761 rtx reg3 = gen_reg_rtx (DImode);
2762 rtx label1 = gen_label_rtx ();
2763 rtx label2 = gen_label_rtx ();
2764 REAL_VALUE_TYPE offset;
2766 real_2expN (&offset, 63);
2768 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, SFmode));
2769 do_pending_stack_adjust ();
2771 emit_insn (gen_cmpsf (operands[1], reg1));
2772 emit_jump_insn (gen_bge (label1));
2774 emit_insn (gen_fix_truncsfdi2 (operands[0], operands[1]));
2775 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
2776 gen_rtx_LABEL_REF (VOIDmode, label2)));
2779 emit_label (label1);
2780 emit_move_insn (reg2, gen_rtx_MINUS (SFmode, operands[1], reg1));
2781 emit_move_insn (reg3, GEN_INT (BITMASK_HIGH));
2782 emit_insn (gen_ashldi3 (reg3, reg3, GEN_INT (32)));
2784 emit_insn (gen_fix_truncsfdi2 (operands[0], reg2));
2785 emit_insn (gen_iordi3 (operands[0], operands[0], reg3));
2787 emit_label (label2);
2789 /* Allow REG_NOTES to be set on last insn (labels don't have enough
2790 fields, and can't be used for REG_NOTES anyway). */
2791 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
2796 ;; ....................
2800 ;; ....................
2802 ;; Bit field extract patterns which use lwl/lwr or ldl/ldr.
2804 (define_expand "extv"
2805 [(set (match_operand 0 "register_operand")
2806 (sign_extract (match_operand:QI 1 "memory_operand")
2807 (match_operand 2 "immediate_operand")
2808 (match_operand 3 "immediate_operand")))]
2811 if (mips_expand_unaligned_load (operands[0], operands[1],
2812 INTVAL (operands[2]),
2813 INTVAL (operands[3])))
2819 (define_expand "extzv"
2820 [(set (match_operand 0 "register_operand")
2821 (zero_extract (match_operand 1 "nonimmediate_operand")
2822 (match_operand 2 "immediate_operand")
2823 (match_operand 3 "immediate_operand")))]
2826 if (mips_expand_unaligned_load (operands[0], operands[1],
2827 INTVAL (operands[2]),
2828 INTVAL (operands[3])))
2830 else if (mips_use_ins_ext_p (operands[1], operands[2], operands[3]))
2832 if (GET_MODE (operands[0]) == DImode)
2833 emit_insn (gen_extzvdi (operands[0], operands[1], operands[2],
2836 emit_insn (gen_extzvsi (operands[0], operands[1], operands[2],
2844 (define_insn "extzv<mode>"
2845 [(set (match_operand:GPR 0 "register_operand" "=d")
2846 (zero_extract:GPR (match_operand:GPR 1 "register_operand" "d")
2847 (match_operand:SI 2 "immediate_operand" "I")
2848 (match_operand:SI 3 "immediate_operand" "I")))]
2849 "mips_use_ins_ext_p (operands[1], operands[2], operands[3])"
2850 "<d>ext\t%0,%1,%3,%2"
2851 [(set_attr "type" "arith")
2852 (set_attr "mode" "<MODE>")])
2855 (define_expand "insv"
2856 [(set (zero_extract (match_operand 0 "nonimmediate_operand")
2857 (match_operand 1 "immediate_operand")
2858 (match_operand 2 "immediate_operand"))
2859 (match_operand 3 "reg_or_0_operand"))]
2862 if (mips_expand_unaligned_store (operands[0], operands[3],
2863 INTVAL (operands[1]),
2864 INTVAL (operands[2])))
2866 else if (mips_use_ins_ext_p (operands[0], operands[1], operands[2]))
2868 if (GET_MODE (operands[0]) == DImode)
2869 emit_insn (gen_insvdi (operands[0], operands[1], operands[2],
2872 emit_insn (gen_insvsi (operands[0], operands[1], operands[2],
2880 (define_insn "insv<mode>"
2881 [(set (zero_extract:GPR (match_operand:GPR 0 "register_operand" "+d")
2882 (match_operand:SI 1 "immediate_operand" "I")
2883 (match_operand:SI 2 "immediate_operand" "I"))
2884 (match_operand:GPR 3 "reg_or_0_operand" "dJ"))]
2885 "mips_use_ins_ext_p (operands[0], operands[1], operands[2])"
2886 "<d>ins\t%0,%z3,%2,%1"
2887 [(set_attr "type" "arith")
2888 (set_attr "mode" "<MODE>")])
2890 ;; Unaligned word moves generated by the bit field patterns.
2892 ;; As far as the rtl is concerned, both the left-part and right-part
2893 ;; instructions can access the whole field. However, the real operand
2894 ;; refers to just the first or the last byte (depending on endianness).
2895 ;; We therefore use two memory operands to each instruction, one to
2896 ;; describe the rtl effect and one to use in the assembly output.
2898 ;; Operands 0 and 1 are the rtl-level target and source respectively.
2899 ;; This allows us to use the standard length calculations for the "load"
2900 ;; and "store" type attributes.
2902 (define_insn "mov_<load>l"
2903 [(set (match_operand:GPR 0 "register_operand" "=d")
2904 (unspec:GPR [(match_operand:BLK 1 "memory_operand" "m")
2905 (match_operand:QI 2 "memory_operand" "m")]
2909 [(set_attr "type" "load")
2910 (set_attr "mode" "<MODE>")])
2912 (define_insn "mov_<load>r"
2913 [(set (match_operand:GPR 0 "register_operand" "=d")
2914 (unspec:GPR [(match_operand:BLK 1 "memory_operand" "m")
2915 (match_operand:QI 2 "memory_operand" "m")
2916 (match_operand:GPR 3 "register_operand" "0")]
2917 UNSPEC_LOAD_RIGHT))]
2920 [(set_attr "type" "load")
2921 (set_attr "mode" "<MODE>")])
2923 (define_insn "mov_<store>l"
2924 [(set (match_operand:BLK 0 "memory_operand" "=m")
2925 (unspec:BLK [(match_operand:GPR 1 "reg_or_0_operand" "dJ")
2926 (match_operand:QI 2 "memory_operand" "m")]
2927 UNSPEC_STORE_LEFT))]
2930 [(set_attr "type" "store")
2931 (set_attr "mode" "<MODE>")])
2933 (define_insn "mov_<store>r"
2934 [(set (match_operand:BLK 0 "memory_operand" "+m")
2935 (unspec:BLK [(match_operand:GPR 1 "reg_or_0_operand" "dJ")
2936 (match_operand:QI 2 "memory_operand" "m")
2938 UNSPEC_STORE_RIGHT))]
2941 [(set_attr "type" "store")
2942 (set_attr "mode" "<MODE>")])
2944 ;; An instruction to calculate the high part of a 64-bit SYMBOL_GENERAL.
2945 ;; The required value is:
2947 ;; (%highest(op1) << 48) + (%higher(op1) << 32) + (%hi(op1) << 16)
2949 ;; which translates to:
2951 ;; lui op0,%highest(op1)
2952 ;; daddiu op0,op0,%higher(op1)
2954 ;; daddiu op0,op0,%hi(op1)
2957 ;; The split is deferred until after flow2 to allow the peephole2 below
2959 (define_insn_and_split "*lea_high64"
2960 [(set (match_operand:DI 0 "register_operand" "=d")
2961 (high:DI (match_operand:DI 1 "general_symbolic_operand" "")))]
2962 "TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS"
2964 "&& flow2_completed"
2965 [(set (match_dup 0) (high:DI (match_dup 2)))
2966 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 2)))
2967 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 16)))
2968 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 3)))
2969 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 16)))]
2971 operands[2] = mips_unspec_address (operands[1], SYMBOL_64_HIGH);
2972 operands[3] = mips_unspec_address (operands[1], SYMBOL_64_MID);
2974 [(set_attr "length" "20")])
2976 ;; Use a scratch register to reduce the latency of the above pattern
2977 ;; on superscalar machines. The optimized sequence is:
2979 ;; lui op1,%highest(op2)
2981 ;; daddiu op1,op1,%higher(op2)
2983 ;; daddu op1,op1,op0
2985 [(set (match_operand:DI 1 "register_operand")
2986 (high:DI (match_operand:DI 2 "general_symbolic_operand")))
2987 (match_scratch:DI 0 "d")]
2988 "TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS"
2989 [(set (match_dup 1) (high:DI (match_dup 3)))
2990 (set (match_dup 0) (high:DI (match_dup 4)))
2991 (set (match_dup 1) (lo_sum:DI (match_dup 1) (match_dup 3)))
2992 (set (match_dup 1) (ashift:DI (match_dup 1) (const_int 32)))
2993 (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 0)))]
2995 operands[3] = mips_unspec_address (operands[2], SYMBOL_64_HIGH);
2996 operands[4] = mips_unspec_address (operands[2], SYMBOL_64_LOW);
2999 ;; On most targets, the expansion of (lo_sum (high X) X) for a 64-bit
3000 ;; SYMBOL_GENERAL X will take 6 cycles. This next pattern allows combine
3001 ;; to merge the HIGH and LO_SUM parts of a move if the HIGH part is only
3002 ;; used once. We can then use the sequence:
3004 ;; lui op0,%highest(op1)
3006 ;; daddiu op0,op0,%higher(op1)
3007 ;; daddiu op2,op2,%lo(op1)
3009 ;; daddu op0,op0,op2
3011 ;; which takes 4 cycles on most superscalar targets.
3012 (define_insn_and_split "*lea64"
3013 [(set (match_operand:DI 0 "register_operand" "=d")
3014 (match_operand:DI 1 "general_symbolic_operand" ""))
3015 (clobber (match_scratch:DI 2 "=&d"))]
3016 "TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS && cse_not_expected"
3018 "&& reload_completed"
3019 [(set (match_dup 0) (high:DI (match_dup 3)))
3020 (set (match_dup 2) (high:DI (match_dup 4)))
3021 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 3)))
3022 (set (match_dup 2) (lo_sum:DI (match_dup 2) (match_dup 4)))
3023 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
3024 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))]
3026 operands[3] = mips_unspec_address (operands[1], SYMBOL_64_HIGH);
3027 operands[4] = mips_unspec_address (operands[1], SYMBOL_64_LOW);
3029 [(set_attr "length" "24")])
3031 ;; Insns to fetch a global symbol from a big GOT.
3033 (define_insn_and_split "*xgot_hi<mode>"
3034 [(set (match_operand:P 0 "register_operand" "=d")
3035 (high:P (match_operand:P 1 "global_got_operand" "")))]
3036 "TARGET_EXPLICIT_RELOCS && TARGET_XGOT"
3038 "&& reload_completed"
3039 [(set (match_dup 0) (high:P (match_dup 2)))
3040 (set (match_dup 0) (plus:P (match_dup 0) (match_dup 3)))]
3042 operands[2] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_GLOBAL);
3043 operands[3] = pic_offset_table_rtx;
3045 [(set_attr "got" "xgot_high")
3046 (set_attr "mode" "<MODE>")])
3048 (define_insn_and_split "*xgot_lo<mode>"
3049 [(set (match_operand:P 0 "register_operand" "=d")
3050 (lo_sum:P (match_operand:P 1 "register_operand" "d")
3051 (match_operand:P 2 "global_got_operand" "")))]
3052 "TARGET_EXPLICIT_RELOCS && TARGET_XGOT"
3054 "&& reload_completed"
3056 (unspec:P [(match_dup 1) (match_dup 3)] UNSPEC_LOAD_GOT))]
3057 { operands[3] = mips_unspec_address (operands[2], SYMBOL_GOTOFF_GLOBAL); }
3058 [(set_attr "got" "load")
3059 (set_attr "mode" "<MODE>")])
3061 ;; Insns to fetch a global symbol from a normal GOT.
3063 (define_insn_and_split "*got_disp<mode>"
3064 [(set (match_operand:P 0 "register_operand" "=d")
3065 (match_operand:P 1 "global_got_operand" ""))]
3066 "TARGET_EXPLICIT_RELOCS && !TARGET_XGOT"
3068 "&& reload_completed"
3070 (unspec:P [(match_dup 2) (match_dup 3)] UNSPEC_LOAD_GOT))]
3072 operands[2] = pic_offset_table_rtx;
3073 operands[3] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_GLOBAL);
3075 [(set_attr "got" "load")
3076 (set_attr "mode" "<MODE>")])
3078 ;; Insns for loading the high part of a local symbol.
3080 (define_insn_and_split "*got_page<mode>"
3081 [(set (match_operand:P 0 "register_operand" "=d")
3082 (high:P (match_operand:P 1 "local_got_operand" "")))]
3083 "TARGET_EXPLICIT_RELOCS"
3085 "&& reload_completed"
3087 (unspec:P [(match_dup 2) (match_dup 3)] UNSPEC_LOAD_GOT))]
3089 operands[2] = pic_offset_table_rtx;
3090 operands[3] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_PAGE);
3092 [(set_attr "got" "load")
3093 (set_attr "mode" "<MODE>")])
3095 ;; Lower-level instructions for loading an address from the GOT.
3096 ;; We could use MEMs, but an unspec gives more optimization
3099 (define_insn "load_got<mode>"
3100 [(set (match_operand:P 0 "register_operand" "=d")
3101 (unspec:P [(match_operand:P 1 "register_operand" "d")
3102 (match_operand:P 2 "immediate_operand" "")]
3105 "<load>\t%0,%R2(%1)"
3106 [(set_attr "type" "load")
3107 (set_attr "mode" "<MODE>")
3108 (set_attr "length" "4")])
3110 ;; Instructions for adding the low 16 bits of an address to a register.
3111 ;; Operand 2 is the address: print_operand works out which relocation
3112 ;; should be applied.
3114 (define_insn "*low<mode>"
3115 [(set (match_operand:P 0 "register_operand" "=d")
3116 (lo_sum:P (match_operand:P 1 "register_operand" "d")
3117 (match_operand:P 2 "immediate_operand" "")))]
3119 "<d>addiu\t%0,%1,%R2"
3120 [(set_attr "type" "arith")
3121 (set_attr "mode" "<MODE>")])
3123 (define_insn "*low<mode>_mips16"
3124 [(set (match_operand:P 0 "register_operand" "=d")
3125 (lo_sum:P (match_operand:P 1 "register_operand" "0")
3126 (match_operand:P 2 "immediate_operand" "")))]
3129 [(set_attr "type" "arith")
3130 (set_attr "mode" "<MODE>")
3131 (set_attr "length" "8")])
3133 ;; 64-bit integer moves
3135 ;; Unlike most other insns, the move insns can't be split with
3136 ;; different predicates, because register spilling and other parts of
3137 ;; the compiler, have memoized the insn number already.
3139 (define_expand "movdi"
3140 [(set (match_operand:DI 0 "")
3141 (match_operand:DI 1 ""))]
3144 if (mips_legitimize_move (DImode, operands[0], operands[1]))
3148 ;; For mips16, we need a special case to handle storing $31 into
3149 ;; memory, since we don't have a constraint to match $31. This
3150 ;; instruction can be generated by save_restore_insns.
3152 (define_insn "*mov<mode>_ra"
3153 [(set (match_operand:GPR 0 "stack_operand" "=m")
3157 [(set_attr "type" "store")
3158 (set_attr "mode" "<MODE>")])
3160 (define_insn "*movdi_32bit"
3161 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,m,*x,*d,*B*C*D,*B*C*D,*d,*m")
3162 (match_operand:DI 1 "move_operand" "d,i,m,d,*J*d,*x,*d,*m,*B*C*D,*B*C*D"))]
3163 "!TARGET_64BIT && !TARGET_MIPS16
3164 && (register_operand (operands[0], DImode)
3165 || reg_or_0_operand (operands[1], DImode))"
3166 { return mips_output_move (operands[0], operands[1]); }
3167 [(set_attr "type" "arith,arith,load,store,mthilo,mfhilo,xfer,load,xfer,store")
3168 (set_attr "mode" "DI")
3169 (set_attr "length" "8,16,*,*,8,8,8,*,8,*")])
3171 (define_insn "*movdi_32bit_mips16"
3172 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m,*d")
3173 (match_operand:DI 1 "move_operand" "d,d,y,K,N,m,d,*x"))]
3174 "!TARGET_64BIT && TARGET_MIPS16
3175 && (register_operand (operands[0], DImode)
3176 || register_operand (operands[1], DImode))"
3177 { return mips_output_move (operands[0], operands[1]); }
3178 [(set_attr "type" "arith,arith,arith,arith,arith,load,store,mfhilo")
3179 (set_attr "mode" "DI")
3180 (set_attr "length" "8,8,8,8,12,*,*,8")])
3182 (define_insn "*movdi_64bit"
3183 [(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")
3184 (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"))]
3185 "TARGET_64BIT && !TARGET_MIPS16
3186 && (register_operand (operands[0], DImode)
3187 || reg_or_0_operand (operands[1], DImode))"
3188 { return mips_output_move (operands[0], operands[1]); }
3189 [(set_attr "type" "arith,const,const,load,store,fmove,xfer,fpload,xfer,fpstore,mthilo,xfer,load,xfer,store")
3190 (set_attr "mode" "DI")
3191 (set_attr "length" "4,*,*,*,*,4,4,*,4,*,4,8,*,8,*")])
3193 (define_insn "*movdi_64bit_mips16"
3194 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,y,d,d,d,d,d,m")
3195 (match_operand:DI 1 "move_operand" "d,d,y,K,N,U,m,d"))]
3196 "TARGET_64BIT && TARGET_MIPS16
3197 && (register_operand (operands[0], DImode)
3198 || register_operand (operands[1], DImode))"
3199 { return mips_output_move (operands[0], operands[1]); }
3200 [(set_attr "type" "arith,arith,arith,arith,arith,const,load,store")
3201 (set_attr "mode" "DI")
3202 (set_attr_alternative "length"
3206 (if_then_else (match_operand:VOID 1 "m16_uimm8_1")
3209 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1")
3214 (const_string "*")])])
3217 ;; On the mips16, we can split ld $r,N($r) into an add and a load,
3218 ;; when the original load is a 4 byte instruction but the add and the
3219 ;; load are 2 2 byte instructions.
3222 [(set (match_operand:DI 0 "register_operand")
3223 (mem:DI (plus:DI (match_dup 0)
3224 (match_operand:DI 1 "const_int_operand"))))]
3225 "TARGET_64BIT && TARGET_MIPS16 && reload_completed
3226 && !TARGET_DEBUG_D_MODE
3227 && REG_P (operands[0])
3228 && M16_REG_P (REGNO (operands[0]))
3229 && GET_CODE (operands[1]) == CONST_INT
3230 && ((INTVAL (operands[1]) < 0
3231 && INTVAL (operands[1]) >= -0x10)
3232 || (INTVAL (operands[1]) >= 32 * 8
3233 && INTVAL (operands[1]) <= 31 * 8 + 0x8)
3234 || (INTVAL (operands[1]) >= 0
3235 && INTVAL (operands[1]) < 32 * 8
3236 && (INTVAL (operands[1]) & 7) != 0))"
3237 [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1)))
3238 (set (match_dup 0) (mem:DI (plus:DI (match_dup 0) (match_dup 2))))]
3240 HOST_WIDE_INT val = INTVAL (operands[1]);
3243 operands[2] = const0_rtx;
3244 else if (val >= 32 * 8)
3248 operands[1] = GEN_INT (0x8 + off);
3249 operands[2] = GEN_INT (val - off - 0x8);
3255 operands[1] = GEN_INT (off);
3256 operands[2] = GEN_INT (val - off);
3260 ;; 32-bit Integer moves
3262 ;; Unlike most other insns, the move insns can't be split with
3263 ;; different predicates, because register spilling and other parts of
3264 ;; the compiler, have memoized the insn number already.
3266 (define_expand "movsi"
3267 [(set (match_operand:SI 0 "")
3268 (match_operand:SI 1 ""))]
3271 if (mips_legitimize_move (SImode, operands[0], operands[1]))
3275 ;; The difference between these two is whether or not ints are allowed
3276 ;; in FP registers (off by default, use -mdebugh to enable).
3278 (define_insn "*movsi_internal"
3279 [(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")
3280 (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"))]
3282 && (register_operand (operands[0], SImode)
3283 || reg_or_0_operand (operands[1], SImode))"
3284 { return mips_output_move (operands[0], operands[1]); }
3285 [(set_attr "type" "arith,const,const,load,store,fmove,xfer,fpload,xfer,fpstore,xfer,xfer,mthilo,xfer,load,xfer,store")
3286 (set_attr "mode" "SI")
3287 (set_attr "length" "4,*,*,*,*,4,4,*,4,*,4,4,4,4,*,4,*")])
3289 (define_insn "*movsi_mips16"
3290 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,y,d,d,d,d,d,m")
3291 (match_operand:SI 1 "move_operand" "d,d,y,K,N,U,m,d"))]
3293 && (register_operand (operands[0], SImode)
3294 || register_operand (operands[1], SImode))"
3295 { return mips_output_move (operands[0], operands[1]); }
3296 [(set_attr "type" "arith,arith,arith,arith,arith,const,load,store")
3297 (set_attr "mode" "SI")
3298 (set_attr_alternative "length"
3302 (if_then_else (match_operand:VOID 1 "m16_uimm8_1")
3305 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1")
3310 (const_string "*")])])
3312 ;; On the mips16, we can split lw $r,N($r) into an add and a load,
3313 ;; when the original load is a 4 byte instruction but the add and the
3314 ;; load are 2 2 byte instructions.
3317 [(set (match_operand:SI 0 "register_operand")
3318 (mem:SI (plus:SI (match_dup 0)
3319 (match_operand:SI 1 "const_int_operand"))))]
3320 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
3321 && REG_P (operands[0])
3322 && M16_REG_P (REGNO (operands[0]))
3323 && GET_CODE (operands[1]) == CONST_INT
3324 && ((INTVAL (operands[1]) < 0
3325 && INTVAL (operands[1]) >= -0x80)
3326 || (INTVAL (operands[1]) >= 32 * 4
3327 && INTVAL (operands[1]) <= 31 * 4 + 0x7c)
3328 || (INTVAL (operands[1]) >= 0
3329 && INTVAL (operands[1]) < 32 * 4
3330 && (INTVAL (operands[1]) & 3) != 0))"
3331 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
3332 (set (match_dup 0) (mem:SI (plus:SI (match_dup 0) (match_dup 2))))]
3334 HOST_WIDE_INT val = INTVAL (operands[1]);
3337 operands[2] = const0_rtx;
3338 else if (val >= 32 * 4)
3342 operands[1] = GEN_INT (0x7c + off);
3343 operands[2] = GEN_INT (val - off - 0x7c);
3349 operands[1] = GEN_INT (off);
3350 operands[2] = GEN_INT (val - off);
3354 ;; On the mips16, we can split a load of certain constants into a load
3355 ;; and an add. This turns a 4 byte instruction into 2 2 byte
3359 [(set (match_operand:SI 0 "register_operand")
3360 (match_operand:SI 1 "const_int_operand"))]
3361 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
3362 && REG_P (operands[0])
3363 && M16_REG_P (REGNO (operands[0]))
3364 && GET_CODE (operands[1]) == CONST_INT
3365 && INTVAL (operands[1]) >= 0x100
3366 && INTVAL (operands[1]) <= 0xff + 0x7f"
3367 [(set (match_dup 0) (match_dup 1))
3368 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]
3370 int val = INTVAL (operands[1]);
3372 operands[1] = GEN_INT (0xff);
3373 operands[2] = GEN_INT (val - 0xff);
3376 ;; This insn handles moving CCmode values. It's really just a
3377 ;; slightly simplified copy of movsi_internal2, with additional cases
3378 ;; to move a condition register to a general register and to move
3379 ;; between the general registers and the floating point registers.
3381 (define_insn "movcc"
3382 [(set (match_operand:CC 0 "nonimmediate_operand" "=d,*d,*d,*m,*d,*f,*f,*f,*m")
3383 (match_operand:CC 1 "general_operand" "z,*d,*m,*d,*f,*d,*f,*m,*f"))]
3384 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
3385 { return mips_output_move (operands[0], operands[1]); }
3386 [(set_attr "type" "xfer,arith,load,store,xfer,xfer,fmove,fpload,fpstore")
3387 (set_attr "mode" "SI")
3388 (set_attr "length" "8,4,*,*,4,4,4,*,*")])
3390 ;; Reload condition code registers. reload_incc and reload_outcc
3391 ;; both handle moves from arbitrary operands into condition code
3392 ;; registers. reload_incc handles the more common case in which
3393 ;; a source operand is constrained to be in a condition-code
3394 ;; register, but has not been allocated to one.
3396 ;; Sometimes, such as in movcc, we have a CCmode destination whose
3397 ;; constraints do not include 'z'. reload_outcc handles the case
3398 ;; when such an operand is allocated to a condition-code register.
3400 ;; Note that reloads from a condition code register to some
3401 ;; other location can be done using ordinary moves. Moving
3402 ;; into a GPR takes a single movcc, moving elsewhere takes
3403 ;; two. We can leave these cases to the generic reload code.
3404 (define_expand "reload_incc"
3405 [(set (match_operand:CC 0 "fcc_reload_operand" "=z")
3406 (match_operand:CC 1 "general_operand" ""))
3407 (clobber (match_operand:TF 2 "register_operand" "=&f"))]
3408 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
3410 mips_emit_fcc_reload (operands[0], operands[1], operands[2]);
3414 (define_expand "reload_outcc"
3415 [(set (match_operand:CC 0 "fcc_reload_operand" "=z")
3416 (match_operand:CC 1 "register_operand" ""))
3417 (clobber (match_operand:TF 2 "register_operand" "=&f"))]
3418 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
3420 mips_emit_fcc_reload (operands[0], operands[1], operands[2]);
3424 ;; MIPS4 supports loading and storing a floating point register from
3425 ;; the sum of two general registers. We use two versions for each of
3426 ;; these four instructions: one where the two general registers are
3427 ;; SImode, and one where they are DImode. This is because general
3428 ;; registers will be in SImode when they hold 32 bit values, but,
3429 ;; since the 32 bit values are always sign extended, the [ls][wd]xc1
3430 ;; instructions will still work correctly.
3432 ;; ??? Perhaps it would be better to support these instructions by
3433 ;; modifying GO_IF_LEGITIMATE_ADDRESS and friends. However, since
3434 ;; these instructions can only be used to load and store floating
3435 ;; point registers, that would probably cause trouble in reload.
3437 (define_insn "*<ANYF:loadx>_<P:mode>"
3438 [(set (match_operand:ANYF 0 "register_operand" "=f")
3439 (mem:ANYF (plus:P (match_operand:P 1 "register_operand" "d")
3440 (match_operand:P 2 "register_operand" "d"))))]
3442 "<ANYF:loadx>\t%0,%1(%2)"
3443 [(set_attr "type" "fpidxload")
3444 (set_attr "mode" "<ANYF:UNITMODE>")])
3446 (define_insn "*<ANYF:storex>_<P:mode>"
3447 [(set (mem:ANYF (plus:P (match_operand:P 1 "register_operand" "d")
3448 (match_operand:P 2 "register_operand" "d")))
3449 (match_operand:ANYF 0 "register_operand" "f"))]
3451 "<ANYF:storex>\t%0,%1(%2)"
3452 [(set_attr "type" "fpidxstore")
3453 (set_attr "mode" "<ANYF:UNITMODE>")])
3455 ;; 16-bit Integer moves
3457 ;; Unlike most other insns, the move insns can't be split with
3458 ;; different predicates, because register spilling and other parts of
3459 ;; the compiler, have memoized the insn number already.
3460 ;; Unsigned loads are used because LOAD_EXTEND_OP returns ZERO_EXTEND.
3462 (define_expand "movhi"
3463 [(set (match_operand:HI 0 "")
3464 (match_operand:HI 1 ""))]
3467 if (mips_legitimize_move (HImode, operands[0], operands[1]))
3471 (define_insn "*movhi_internal"
3472 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,m,*d,*f,*f,*x")
3473 (match_operand:HI 1 "move_operand" "d,I,m,dJ,*f,*d,*f,*d"))]
3475 && (register_operand (operands[0], HImode)
3476 || reg_or_0_operand (operands[1], HImode))"
3486 [(set_attr "type" "arith,arith,load,store,xfer,xfer,fmove,mthilo")
3487 (set_attr "mode" "HI")
3488 (set_attr "length" "4,4,*,*,4,4,4,4")])
3490 (define_insn "*movhi_mips16"
3491 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m")
3492 (match_operand:HI 1 "move_operand" "d,d,y,K,N,m,d"))]
3494 && (register_operand (operands[0], HImode)
3495 || register_operand (operands[1], HImode))"
3504 [(set_attr "type" "arith,arith,arith,arith,arith,load,store")
3505 (set_attr "mode" "HI")
3506 (set_attr_alternative "length"
3510 (if_then_else (match_operand:VOID 1 "m16_uimm8_1")
3513 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1")
3517 (const_string "*")])])
3520 ;; On the mips16, we can split lh $r,N($r) into an add and a load,
3521 ;; when the original load is a 4 byte instruction but the add and the
3522 ;; load are 2 2 byte instructions.
3525 [(set (match_operand:HI 0 "register_operand")
3526 (mem:HI (plus:SI (match_dup 0)
3527 (match_operand:SI 1 "const_int_operand"))))]
3528 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
3529 && REG_P (operands[0])
3530 && M16_REG_P (REGNO (operands[0]))
3531 && GET_CODE (operands[1]) == CONST_INT
3532 && ((INTVAL (operands[1]) < 0
3533 && INTVAL (operands[1]) >= -0x80)
3534 || (INTVAL (operands[1]) >= 32 * 2
3535 && INTVAL (operands[1]) <= 31 * 2 + 0x7e)
3536 || (INTVAL (operands[1]) >= 0
3537 && INTVAL (operands[1]) < 32 * 2
3538 && (INTVAL (operands[1]) & 1) != 0))"
3539 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
3540 (set (match_dup 0) (mem:HI (plus:SI (match_dup 0) (match_dup 2))))]
3542 HOST_WIDE_INT val = INTVAL (operands[1]);
3545 operands[2] = const0_rtx;
3546 else if (val >= 32 * 2)
3550 operands[1] = GEN_INT (0x7e + off);
3551 operands[2] = GEN_INT (val - off - 0x7e);
3557 operands[1] = GEN_INT (off);
3558 operands[2] = GEN_INT (val - off);
3562 ;; 8-bit Integer moves
3564 ;; Unlike most other insns, the move insns can't be split with
3565 ;; different predicates, because register spilling and other parts of
3566 ;; the compiler, have memoized the insn number already.
3567 ;; Unsigned loads are used because LOAD_EXTEND_OP returns ZERO_EXTEND.
3569 (define_expand "movqi"
3570 [(set (match_operand:QI 0 "")
3571 (match_operand:QI 1 ""))]
3574 if (mips_legitimize_move (QImode, operands[0], operands[1]))
3578 (define_insn "*movqi_internal"
3579 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,m,*d,*f,*f,*x")
3580 (match_operand:QI 1 "move_operand" "d,I,m,dJ,*f,*d,*f,*d"))]
3582 && (register_operand (operands[0], QImode)
3583 || reg_or_0_operand (operands[1], QImode))"
3593 [(set_attr "type" "arith,arith,load,store,xfer,xfer,fmove,mthilo")
3594 (set_attr "mode" "QI")
3595 (set_attr "length" "4,4,*,*,4,4,4,4")])
3597 (define_insn "*movqi_mips16"
3598 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m")
3599 (match_operand:QI 1 "move_operand" "d,d,y,K,N,m,d"))]
3601 && (register_operand (operands[0], QImode)
3602 || register_operand (operands[1], QImode))"
3611 [(set_attr "type" "arith,arith,arith,arith,arith,load,store")
3612 (set_attr "mode" "QI")
3613 (set_attr "length" "4,4,4,4,8,*,*")])
3615 ;; On the mips16, we can split lb $r,N($r) into an add and a load,
3616 ;; when the original load is a 4 byte instruction but the add and the
3617 ;; load are 2 2 byte instructions.
3620 [(set (match_operand:QI 0 "register_operand")
3621 (mem:QI (plus:SI (match_dup 0)
3622 (match_operand:SI 1 "const_int_operand"))))]
3623 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
3624 && REG_P (operands[0])
3625 && M16_REG_P (REGNO (operands[0]))
3626 && GET_CODE (operands[1]) == CONST_INT
3627 && ((INTVAL (operands[1]) < 0
3628 && INTVAL (operands[1]) >= -0x80)
3629 || (INTVAL (operands[1]) >= 32
3630 && INTVAL (operands[1]) <= 31 + 0x7f))"
3631 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
3632 (set (match_dup 0) (mem:QI (plus:SI (match_dup 0) (match_dup 2))))]
3634 HOST_WIDE_INT val = INTVAL (operands[1]);
3637 operands[2] = const0_rtx;
3640 operands[1] = GEN_INT (0x7f);
3641 operands[2] = GEN_INT (val - 0x7f);
3645 ;; 32-bit floating point moves
3647 (define_expand "movsf"
3648 [(set (match_operand:SF 0 "")
3649 (match_operand:SF 1 ""))]
3652 if (mips_legitimize_move (SFmode, operands[0], operands[1]))
3656 (define_insn "*movsf_hardfloat"
3657 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m")
3658 (match_operand:SF 1 "move_operand" "f,G,m,f,G,*d,*f,*G*d,*m,*d"))]
3660 && (register_operand (operands[0], SFmode)
3661 || reg_or_0_operand (operands[1], SFmode))"
3662 { return mips_output_move (operands[0], operands[1]); }
3663 [(set_attr "type" "fmove,xfer,fpload,fpstore,store,xfer,xfer,arith,load,store")
3664 (set_attr "mode" "SF")
3665 (set_attr "length" "4,4,*,*,*,4,4,4,*,*")])
3667 (define_insn "*movsf_softfloat"
3668 [(set (match_operand:SF 0 "nonimmediate_operand" "=d,d,m")
3669 (match_operand:SF 1 "move_operand" "Gd,m,d"))]
3670 "TARGET_SOFT_FLOAT && !TARGET_MIPS16
3671 && (register_operand (operands[0], SFmode)
3672 || reg_or_0_operand (operands[1], SFmode))"
3673 { return mips_output_move (operands[0], operands[1]); }
3674 [(set_attr "type" "arith,load,store")
3675 (set_attr "mode" "SF")
3676 (set_attr "length" "4,*,*")])
3678 (define_insn "*movsf_mips16"
3679 [(set (match_operand:SF 0 "nonimmediate_operand" "=d,y,d,d,m")
3680 (match_operand:SF 1 "move_operand" "d,d,y,m,d"))]
3682 && (register_operand (operands[0], SFmode)
3683 || register_operand (operands[1], SFmode))"
3684 { return mips_output_move (operands[0], operands[1]); }
3685 [(set_attr "type" "arith,arith,arith,load,store")
3686 (set_attr "mode" "SF")
3687 (set_attr "length" "4,4,4,*,*")])
3690 ;; 64-bit floating point moves
3692 (define_expand "movdf"
3693 [(set (match_operand:DF 0 "")
3694 (match_operand:DF 1 ""))]
3697 if (mips_legitimize_move (DFmode, operands[0], operands[1]))
3701 (define_insn "*movdf_hardfloat_64bit"
3702 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m")
3703 (match_operand:DF 1 "move_operand" "f,G,m,f,G,*d,*f,*d*G,*m,*d"))]
3704 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_64BIT
3705 && (register_operand (operands[0], DFmode)
3706 || reg_or_0_operand (operands[1], DFmode))"
3707 { return mips_output_move (operands[0], operands[1]); }
3708 [(set_attr "type" "fmove,xfer,fpload,fpstore,store,xfer,xfer,arith,load,store")
3709 (set_attr "mode" "DF")
3710 (set_attr "length" "4,4,*,*,*,4,4,4,*,*")])
3712 (define_insn "*movdf_hardfloat_32bit"
3713 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m")
3714 (match_operand:DF 1 "move_operand" "f,G,m,f,G,*d,*f,*d*G,*m,*d"))]
3715 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT
3716 && (register_operand (operands[0], DFmode)
3717 || reg_or_0_operand (operands[1], DFmode))"
3718 { return mips_output_move (operands[0], operands[1]); }
3719 [(set_attr "type" "fmove,xfer,fpload,fpstore,store,xfer,xfer,arith,load,store")
3720 (set_attr "mode" "DF")
3721 (set_attr "length" "4,8,*,*,*,8,8,8,*,*")])
3723 (define_insn "*movdf_softfloat"
3724 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,m,d,f,f")
3725 (match_operand:DF 1 "move_operand" "dG,m,dG,f,d,f"))]
3726 "(TARGET_SOFT_FLOAT || TARGET_SINGLE_FLOAT) && !TARGET_MIPS16
3727 && (register_operand (operands[0], DFmode)
3728 || reg_or_0_operand (operands[1], DFmode))"
3729 { return mips_output_move (operands[0], operands[1]); }
3730 [(set_attr "type" "arith,load,store,xfer,xfer,fmove")
3731 (set_attr "mode" "DF")
3732 (set_attr "length" "8,*,*,4,4,4")])
3734 (define_insn "*movdf_mips16"
3735 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,y,d,d,m")
3736 (match_operand:DF 1 "move_operand" "d,d,y,m,d"))]
3738 && (register_operand (operands[0], DFmode)
3739 || register_operand (operands[1], DFmode))"
3740 { return mips_output_move (operands[0], operands[1]); }
3741 [(set_attr "type" "arith,arith,arith,load,store")
3742 (set_attr "mode" "DF")
3743 (set_attr "length" "8,8,8,*,*")])
3746 [(set (match_operand:DI 0 "nonimmediate_operand")
3747 (match_operand:DI 1 "move_operand"))]
3748 "reload_completed && !TARGET_64BIT
3749 && mips_split_64bit_move_p (operands[0], operands[1])"
3752 mips_split_64bit_move (operands[0], operands[1]);
3757 [(set (match_operand:DF 0 "nonimmediate_operand")
3758 (match_operand:DF 1 "move_operand"))]
3759 "reload_completed && !TARGET_64BIT
3760 && mips_split_64bit_move_p (operands[0], operands[1])"
3763 mips_split_64bit_move (operands[0], operands[1]);
3767 ;; When generating mips16 code, split moves of negative constants into
3768 ;; a positive "li" followed by a negation.
3770 [(set (match_operand 0 "register_operand")
3771 (match_operand 1 "const_int_operand"))]
3772 "TARGET_MIPS16 && reload_completed && INTVAL (operands[1]) < 0"
3776 (neg:SI (match_dup 2)))]
3778 operands[2] = gen_lowpart (SImode, operands[0]);
3779 operands[3] = GEN_INT (-INTVAL (operands[1]));
3782 ;; 64-bit paired-single floating point moves
3784 (define_expand "movv2sf"
3785 [(set (match_operand:V2SF 0)
3786 (match_operand:V2SF 1))]
3787 "TARGET_PAIRED_SINGLE_FLOAT"
3789 if (mips_legitimize_move (V2SFmode, operands[0], operands[1]))
3793 (define_insn "movv2sf_hardfloat_64bit"
3794 [(set (match_operand:V2SF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m")
3795 (match_operand:V2SF 1 "move_operand" "f,YG,m,f,YG,*d,*f,*d*YG,*m,*d"))]
3796 "TARGET_PAIRED_SINGLE_FLOAT
3798 && (register_operand (operands[0], V2SFmode)
3799 || reg_or_0_operand (operands[1], V2SFmode))"
3800 { return mips_output_move (operands[0], operands[1]); }
3801 [(set_attr "type" "fmove,xfer,fpload,fpstore,store,xfer,xfer,arith,load,store")
3802 (set_attr "mode" "SF")
3803 (set_attr "length" "4,4,*,*,*,4,4,4,*,*")])
3805 ;; The HI and LO registers are not truly independent. If we move an mthi
3806 ;; instruction before an mflo instruction, it will make the result of the
3807 ;; mflo unpredictable. The same goes for mtlo and mfhi.
3809 ;; We cope with this by making the mflo and mfhi patterns use both HI and LO.
3810 ;; Operand 1 is the register we want, operand 2 is the other one.
3812 ;; When generating VR4120 or VR4130 code, we use macc{,hi} and
3813 ;; dmacc{,hi} instead of mfhi and mflo. This avoids both the normal
3814 ;; MIPS III hi/lo hazards and the errata related to -mfix-vr4130.
3816 (define_expand "mfhilo_<mode>"
3817 [(set (match_operand:GPR 0 "register_operand")
3818 (unspec:GPR [(match_operand:GPR 1 "register_operand")
3819 (match_operand:GPR 2 "register_operand")]
3822 (define_insn "*mfhilo_<mode>"
3823 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3824 (unspec:GPR [(match_operand:GPR 1 "register_operand" "h,l")
3825 (match_operand:GPR 2 "register_operand" "l,h")]
3829 [(set_attr "type" "mfhilo")
3830 (set_attr "mode" "<MODE>")])
3832 (define_insn "*mfhilo_<mode>_macc"
3833 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3834 (unspec:GPR [(match_operand:GPR 1 "register_operand" "h,l")
3835 (match_operand:GPR 2 "register_operand" "l,h")]
3839 if (REGNO (operands[1]) == HI_REGNUM)
3840 return "<d>macchi\t%0,%.,%.";
3842 return "<d>macc\t%0,%.,%.";
3844 [(set_attr "type" "mfhilo")
3845 (set_attr "mode" "<MODE>")])
3847 ;; Patterns for loading or storing part of a paired floating point
3848 ;; register. We need them because odd-numbered floating-point registers
3849 ;; are not fully independent: see mips_split_64bit_move.
3851 ;; Load the low word of operand 0 with operand 1.
3852 (define_insn "load_df_low"
3853 [(set (match_operand:DF 0 "register_operand" "=f,f")
3854 (unspec:DF [(match_operand:SI 1 "general_operand" "dJ,m")]
3855 UNSPEC_LOAD_DF_LOW))]
3856 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT"
3858 operands[0] = mips_subword (operands[0], 0);
3859 return mips_output_move (operands[0], operands[1]);
3861 [(set_attr "type" "xfer,fpload")
3862 (set_attr "mode" "SF")])
3864 ;; Load the high word of operand 0 from operand 1, preserving the value
3866 (define_insn "load_df_high"
3867 [(set (match_operand:DF 0 "register_operand" "=f,f")
3868 (unspec:DF [(match_operand:SI 1 "general_operand" "dJ,m")
3869 (match_operand:DF 2 "register_operand" "0,0")]
3870 UNSPEC_LOAD_DF_HIGH))]
3871 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT"
3873 operands[0] = mips_subword (operands[0], 1);
3874 return mips_output_move (operands[0], operands[1]);
3876 [(set_attr "type" "xfer,fpload")
3877 (set_attr "mode" "SF")])
3879 ;; Store the high word of operand 1 in operand 0. The corresponding
3880 ;; low-word move is done in the normal way.
3881 (define_insn "store_df_high"
3882 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,m")
3883 (unspec:SI [(match_operand:DF 1 "register_operand" "f,f")]
3884 UNSPEC_STORE_DF_HIGH))]
3885 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT"
3887 operands[1] = mips_subword (operands[1], 1);
3888 return mips_output_move (operands[0], operands[1]);
3890 [(set_attr "type" "xfer,fpstore")
3891 (set_attr "mode" "SF")])
3893 ;; Insn to initialize $gp for n32/n64 abicalls. Operand 0 is the offset
3894 ;; of _gp from the start of this function. Operand 1 is the incoming
3895 ;; function address.
3896 (define_insn_and_split "loadgp"
3897 [(unspec_volatile [(match_operand 0 "" "")
3898 (match_operand 1 "register_operand" "")] UNSPEC_LOADGP)]
3899 "TARGET_ABICALLS && TARGET_NEWABI"
3902 [(set (match_dup 2) (match_dup 3))
3903 (set (match_dup 2) (match_dup 4))
3904 (set (match_dup 2) (match_dup 5))]
3906 operands[2] = pic_offset_table_rtx;
3907 operands[3] = gen_rtx_HIGH (Pmode, operands[0]);
3908 operands[4] = gen_rtx_PLUS (Pmode, operands[2], operands[1]);
3909 operands[5] = gen_rtx_LO_SUM (Pmode, operands[2], operands[0]);
3911 [(set_attr "length" "12")])
3913 ;; The use of gp is hidden when not using explicit relocations.
3914 ;; This blockage instruction prevents the gp load from being
3915 ;; scheduled after an implicit use of gp. It also prevents
3916 ;; the load from being deleted as dead.
3917 (define_insn "loadgp_blockage"
3918 [(unspec_volatile [(reg:DI 28)] UNSPEC_BLOCKAGE)]
3921 [(set_attr "type" "unknown")
3922 (set_attr "mode" "none")
3923 (set_attr "length" "0")])
3925 ;; Emit a .cprestore directive, which normally expands to a single store
3926 ;; instruction. Note that we continue to use .cprestore for explicit reloc
3927 ;; code so that jals inside inline asms will work correctly.
3928 (define_insn "cprestore"
3929 [(unspec_volatile [(match_operand 0 "const_int_operand" "I,i")]
3933 if (set_nomacro && which_alternative == 1)
3934 return ".set\tmacro\;.cprestore\t%0\;.set\tnomacro";
3936 return ".cprestore\t%0";
3938 [(set_attr "type" "store")
3939 (set_attr "length" "4,12")])
3941 ;; Block moves, see mips.c for more details.
3942 ;; Argument 0 is the destination
3943 ;; Argument 1 is the source
3944 ;; Argument 2 is the length
3945 ;; Argument 3 is the alignment
3947 (define_expand "movmemsi"
3948 [(parallel [(set (match_operand:BLK 0 "general_operand")
3949 (match_operand:BLK 1 "general_operand"))
3950 (use (match_operand:SI 2 ""))
3951 (use (match_operand:SI 3 "const_int_operand"))])]
3952 "!TARGET_MIPS16 && !TARGET_MEMCPY"
3954 if (mips_expand_block_move (operands[0], operands[1], operands[2]))
3961 ;; ....................
3965 ;; ....................
3967 (define_expand "<optab><mode>3"
3968 [(set (match_operand:GPR 0 "register_operand")
3969 (any_shift:GPR (match_operand:GPR 1 "register_operand")
3970 (match_operand:SI 2 "arith_operand")))]
3973 /* On the mips16, a shift of more than 8 is a four byte instruction,
3974 so, for a shift between 8 and 16, it is just as fast to do two
3975 shifts of 8 or less. If there is a lot of shifting going on, we
3976 may win in CSE. Otherwise combine will put the shifts back
3977 together again. This can be called by function_arg, so we must
3978 be careful not to allocate a new register if we've reached the
3982 && GET_CODE (operands[2]) == CONST_INT
3983 && INTVAL (operands[2]) > 8
3984 && INTVAL (operands[2]) <= 16
3985 && !reload_in_progress
3986 && !reload_completed)
3988 rtx temp = gen_reg_rtx (<MODE>mode);
3990 emit_insn (gen_<optab><mode>3 (temp, operands[1], GEN_INT (8)));
3991 emit_insn (gen_<optab><mode>3 (operands[0], temp,
3992 GEN_INT (INTVAL (operands[2]) - 8)));
3997 (define_insn "*<optab><mode>3"
3998 [(set (match_operand:GPR 0 "register_operand" "=d")
3999 (any_shift:GPR (match_operand:GPR 1 "register_operand" "d")
4000 (match_operand:SI 2 "arith_operand" "dI")))]
4003 if (GET_CODE (operands[2]) == CONST_INT)
4004 operands[2] = GEN_INT (INTVAL (operands[2])
4005 & (GET_MODE_BITSIZE (<MODE>mode) - 1));
4007 return "<d><insn>\t%0,%1,%2";
4009 [(set_attr "type" "shift")
4010 (set_attr "mode" "<MODE>")])
4012 (define_insn "*<optab>si3_extend"
4013 [(set (match_operand:DI 0 "register_operand" "=d")
4015 (any_shift:SI (match_operand:SI 1 "register_operand" "d")
4016 (match_operand:SI 2 "arith_operand" "dI"))))]
4017 "TARGET_64BIT && !TARGET_MIPS16"
4019 if (GET_CODE (operands[2]) == CONST_INT)
4020 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
4022 return "<insn>\t%0,%1,%2";
4024 [(set_attr "type" "shift")
4025 (set_attr "mode" "SI")])
4027 (define_insn "*<optab>si3_mips16"
4028 [(set (match_operand:SI 0 "register_operand" "=d,d")
4029 (any_shift:SI (match_operand:SI 1 "register_operand" "0,d")
4030 (match_operand:SI 2 "arith_operand" "d,I")))]
4033 if (which_alternative == 0)
4034 return "<insn>\t%0,%2";
4036 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
4037 return "<insn>\t%0,%1,%2";
4039 [(set_attr "type" "shift")
4040 (set_attr "mode" "SI")
4041 (set_attr_alternative "length"
4043 (if_then_else (match_operand 2 "m16_uimm3_b")
4047 ;; We need separate DImode MIPS16 patterns because of the irregularity
4049 (define_insn "*ashldi3_mips16"
4050 [(set (match_operand:DI 0 "register_operand" "=d,d")
4051 (ashift:DI (match_operand:DI 1 "register_operand" "0,d")
4052 (match_operand:SI 2 "arith_operand" "d,I")))]
4053 "TARGET_64BIT && TARGET_MIPS16"
4055 if (which_alternative == 0)
4056 return "dsll\t%0,%2";
4058 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
4059 return "dsll\t%0,%1,%2";
4061 [(set_attr "type" "shift")
4062 (set_attr "mode" "DI")
4063 (set_attr_alternative "length"
4065 (if_then_else (match_operand 2 "m16_uimm3_b")
4069 (define_insn "*ashrdi3_mips16"
4070 [(set (match_operand:DI 0 "register_operand" "=d,d")
4071 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0,0")
4072 (match_operand:SI 2 "arith_operand" "d,I")))]
4073 "TARGET_64BIT && TARGET_MIPS16"
4075 if (GET_CODE (operands[2]) == CONST_INT)
4076 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
4078 return "dsra\t%0,%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 "*lshrdi3_mips16"
4089 [(set (match_operand:DI 0 "register_operand" "=d,d")
4090 (lshiftrt: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 "dsrl\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 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
4110 [(set (match_operand:GPR 0 "register_operand")
4111 (any_shift:GPR (match_operand:GPR 1 "register_operand")
4112 (match_operand:GPR 2 "const_int_operand")))]
4113 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
4114 && GET_CODE (operands[2]) == CONST_INT
4115 && INTVAL (operands[2]) > 8
4116 && INTVAL (operands[2]) <= 16"
4117 [(set (match_dup 0) (any_shift:GPR (match_dup 1) (const_int 8)))
4118 (set (match_dup 0) (any_shift:GPR (match_dup 0) (match_dup 2)))]
4119 { operands[2] = GEN_INT (INTVAL (operands[2]) - 8); })
4121 ;; If we load a byte on the mips16 as a bitfield, the resulting
4122 ;; sequence of instructions is too complicated for combine, because it
4123 ;; involves four instructions: a load, a shift, a constant load into a
4124 ;; register, and an and (the key problem here is that the mips16 does
4125 ;; not have and immediate). We recognize a shift of a load in order
4126 ;; to make it simple enough for combine to understand.
4128 ;; The length here is the worst case: the length of the split version
4129 ;; will be more accurate.
4130 (define_insn_and_split ""
4131 [(set (match_operand:SI 0 "register_operand" "=d")
4132 (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
4133 (match_operand:SI 2 "immediate_operand" "I")))]
4137 [(set (match_dup 0) (match_dup 1))
4138 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
4140 [(set_attr "type" "load")
4141 (set_attr "mode" "SI")
4142 (set_attr "length" "16")])
4144 (define_insn "rotr<mode>3"
4145 [(set (match_operand:GPR 0 "register_operand" "=d")
4146 (rotatert:GPR (match_operand:GPR 1 "register_operand" "d")
4147 (match_operand:SI 2 "arith_operand" "dI")))]
4148 "ISA_HAS_ROTR_<MODE>"
4150 if (GET_CODE (operands[2]) == CONST_INT)
4151 gcc_assert (INTVAL (operands[2]) >= 0
4152 && INTVAL (operands[2]) < GET_MODE_BITSIZE (<MODE>mode));
4154 return "<d>ror\t%0,%1,%2";
4156 [(set_attr "type" "shift")
4157 (set_attr "mode" "<MODE>")])
4160 ;; ....................
4164 ;; ....................
4166 ;; Flow here is rather complex:
4168 ;; 1) The cmp{si,di,sf,df} routine is called. It deposits the arguments
4169 ;; into cmp_operands[] but generates no RTL.
4171 ;; 2) The appropriate branch define_expand is called, which then
4172 ;; creates the appropriate RTL for the comparison and branch.
4173 ;; Different CC modes are used, based on what type of branch is
4174 ;; done, so that we can constrain things appropriately. There
4175 ;; are assumptions in the rest of GCC that break if we fold the
4176 ;; operands into the branches for integer operations, and use cc0
4177 ;; for floating point, so we use the fp status register instead.
4178 ;; If needed, an appropriate temporary is created to hold the
4179 ;; of the integer compare.
4181 (define_expand "cmp<mode>"
4183 (compare:CC (match_operand:GPR 0 "register_operand")
4184 (match_operand:GPR 1 "nonmemory_operand")))]
4187 cmp_operands[0] = operands[0];
4188 cmp_operands[1] = operands[1];
4192 (define_expand "cmp<mode>"
4194 (compare:CC (match_operand:SCALARF 0 "register_operand")
4195 (match_operand:SCALARF 1 "register_operand")))]
4198 cmp_operands[0] = operands[0];
4199 cmp_operands[1] = operands[1];
4204 ;; ....................
4206 ;; CONDITIONAL BRANCHES
4208 ;; ....................
4210 ;; Conditional branches on floating-point equality tests.
4212 (define_insn "branch_fp"
4215 (match_operator:CC 0 "comparison_operator"
4216 [(match_operand:CC 2 "register_operand" "z")
4218 (label_ref (match_operand 1 "" ""))
4222 return mips_output_conditional_branch (insn,
4224 /*two_operands_p=*/0,
4227 get_attr_length (insn));
4229 [(set_attr "type" "branch")
4230 (set_attr "mode" "none")])
4232 (define_insn "branch_fp_inverted"
4235 (match_operator:CC 0 "comparison_operator"
4236 [(match_operand:CC 2 "register_operand" "z")
4239 (label_ref (match_operand 1 "" ""))))]
4242 return mips_output_conditional_branch (insn,
4244 /*two_operands_p=*/0,
4247 get_attr_length (insn));
4249 [(set_attr "type" "branch")
4250 (set_attr "mode" "none")])
4252 ;; Conditional branches on comparisons with zero.
4254 (define_insn "*branch_zero<mode>"
4257 (match_operator:GPR 0 "comparison_operator"
4258 [(match_operand:GPR 2 "register_operand" "d")
4260 (label_ref (match_operand 1 "" ""))
4264 return mips_output_conditional_branch (insn,
4266 /*two_operands_p=*/0,
4269 get_attr_length (insn));
4271 [(set_attr "type" "branch")
4272 (set_attr "mode" "none")])
4274 (define_insn "*branch_zero<mode>_inverted"
4277 (match_operator:GPR 0 "comparison_operator"
4278 [(match_operand:GPR 2 "register_operand" "d")
4281 (label_ref (match_operand 1 "" ""))))]
4284 return mips_output_conditional_branch (insn,
4286 /*two_operands_p=*/0,
4289 get_attr_length (insn));
4291 [(set_attr "type" "branch")
4292 (set_attr "mode" "none")])
4294 ;; Conditional branch on equality comparison.
4296 (define_insn "*branch_equality<mode>"
4299 (match_operator:GPR 0 "equality_operator"
4300 [(match_operand:GPR 2 "register_operand" "d")
4301 (match_operand:GPR 3 "register_operand" "d")])
4302 (label_ref (match_operand 1 "" ""))
4306 return mips_output_conditional_branch (insn,
4308 /*two_operands_p=*/1,
4311 get_attr_length (insn));
4313 [(set_attr "type" "branch")
4314 (set_attr "mode" "none")])
4316 (define_insn "*branch_equality<mode>_inverted"
4319 (match_operator:GPR 0 "equality_operator"
4320 [(match_operand:GPR 2 "register_operand" "d")
4321 (match_operand:GPR 3 "register_operand" "d")])
4323 (label_ref (match_operand 1 "" ""))))]
4326 return mips_output_conditional_branch (insn,
4328 /*two_operands_p=*/1,
4331 get_attr_length (insn));
4333 [(set_attr "type" "branch")
4334 (set_attr "mode" "none")])
4338 (define_insn "*branch_equality<mode>_mips16"
4341 (match_operator:GPR 0 "equality_operator"
4342 [(match_operand:GPR 1 "register_operand" "d,t")
4344 (match_operand 2 "pc_or_label_operand" "")
4345 (match_operand 3 "pc_or_label_operand" "")))]
4348 if (operands[2] != pc_rtx)
4350 if (which_alternative == 0)
4351 return "b%C0z\t%1,%2";
4353 return "bt%C0z\t%2";
4357 if (which_alternative == 0)
4358 return "b%N0z\t%1,%3";
4360 return "bt%N0z\t%3";
4363 [(set_attr "type" "branch")
4364 (set_attr "mode" "none")
4365 (set_attr "length" "8")])
4367 (define_expand "b<code>"
4369 (if_then_else (any_cond:CC (cc0)
4371 (label_ref (match_operand 0 ""))
4375 gen_conditional_branch (operands, <CODE>);
4380 ;; ....................
4382 ;; SETTING A REGISTER FROM A COMPARISON
4384 ;; ....................
4386 (define_expand "seq"
4387 [(set (match_operand:SI 0 "register_operand")
4388 (eq:SI (match_dup 1)
4391 { if (mips_emit_scc (EQ, operands[0])) DONE; else FAIL; })
4393 (define_insn "*seq_<mode>"
4394 [(set (match_operand:GPR 0 "register_operand" "=d")
4395 (eq:GPR (match_operand:GPR 1 "register_operand" "d")
4399 [(set_attr "type" "slt")
4400 (set_attr "mode" "<MODE>")])
4402 (define_insn "*seq_<mode>_mips16"
4403 [(set (match_operand:GPR 0 "register_operand" "=t")
4404 (eq:GPR (match_operand:GPR 1 "register_operand" "d")
4408 [(set_attr "type" "slt")
4409 (set_attr "mode" "<MODE>")])
4411 ;; "sne" uses sltu instructions in which the first operand is $0.
4412 ;; This isn't possible in mips16 code.
4414 (define_expand "sne"
4415 [(set (match_operand:SI 0 "register_operand")
4416 (ne:SI (match_dup 1)
4419 { if (mips_emit_scc (NE, operands[0])) DONE; else FAIL; })
4421 (define_insn "*sne_<mode>"
4422 [(set (match_operand:GPR 0 "register_operand" "=d")
4423 (ne:GPR (match_operand:GPR 1 "register_operand" "d")
4427 [(set_attr "type" "slt")
4428 (set_attr "mode" "<MODE>")])
4430 (define_expand "sgt"
4431 [(set (match_operand:SI 0 "register_operand")
4432 (gt:SI (match_dup 1)
4435 { if (mips_emit_scc (GT, operands[0])) DONE; else FAIL; })
4437 (define_insn "*sgt_<mode>"
4438 [(set (match_operand:GPR 0 "register_operand" "=d")
4439 (gt:GPR (match_operand:GPR 1 "register_operand" "d")
4440 (match_operand:GPR 2 "reg_or_0_operand" "dJ")))]
4443 [(set_attr "type" "slt")
4444 (set_attr "mode" "<MODE>")])
4446 (define_insn "*sgt_<mode>_mips16"
4447 [(set (match_operand:GPR 0 "register_operand" "=t")
4448 (gt:GPR (match_operand:GPR 1 "register_operand" "d")
4449 (match_operand:GPR 2 "register_operand" "d")))]
4452 [(set_attr "type" "slt")
4453 (set_attr "mode" "<MODE>")])
4455 (define_expand "sge"
4456 [(set (match_operand:SI 0 "register_operand")
4457 (ge:SI (match_dup 1)
4460 { if (mips_emit_scc (GE, operands[0])) DONE; else FAIL; })
4462 (define_insn "*sge_<mode>"
4463 [(set (match_operand:GPR 0 "register_operand" "=d")
4464 (ge:GPR (match_operand:GPR 1 "register_operand" "d")
4468 [(set_attr "type" "slt")
4469 (set_attr "mode" "<MODE>")])
4471 (define_expand "slt"
4472 [(set (match_operand:SI 0 "register_operand")
4473 (lt:SI (match_dup 1)
4476 { if (mips_emit_scc (LT, operands[0])) DONE; else FAIL; })
4478 (define_insn "*slt_<mode>"
4479 [(set (match_operand:GPR 0 "register_operand" "=d")
4480 (lt:GPR (match_operand:GPR 1 "register_operand" "d")
4481 (match_operand:GPR 2 "arith_operand" "dI")))]
4484 [(set_attr "type" "slt")
4485 (set_attr "mode" "<MODE>")])
4487 (define_insn "*slt_<mode>_mips16"
4488 [(set (match_operand:GPR 0 "register_operand" "=t,t")
4489 (lt:GPR (match_operand:GPR 1 "register_operand" "d,d")
4490 (match_operand:GPR 2 "arith_operand" "d,I")))]
4493 [(set_attr "type" "slt")
4494 (set_attr "mode" "<MODE>")
4495 (set_attr_alternative "length"
4497 (if_then_else (match_operand 2 "m16_uimm8_1")
4501 (define_expand "sle"
4502 [(set (match_operand:SI 0 "register_operand")
4503 (le:SI (match_dup 1)
4506 { if (mips_emit_scc (LE, operands[0])) DONE; else FAIL; })
4508 (define_insn "*sle_<mode>"
4509 [(set (match_operand:GPR 0 "register_operand" "=d")
4510 (le:GPR (match_operand:GPR 1 "register_operand" "d")
4511 (match_operand:GPR 2 "sle_operand" "")))]
4514 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
4515 return "slt\t%0,%1,%2";
4517 [(set_attr "type" "slt")
4518 (set_attr "mode" "<MODE>")])
4520 (define_insn "*sle_<mode>_mips16"
4521 [(set (match_operand:GPR 0 "register_operand" "=t")
4522 (le:GPR (match_operand:GPR 1 "register_operand" "d")
4523 (match_operand:GPR 2 "sle_operand" "")))]
4526 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
4527 return "slt\t%1,%2";
4529 [(set_attr "type" "slt")
4530 (set_attr "mode" "<MODE>")
4531 (set (attr "length") (if_then_else (match_operand 2 "m16_uimm8_m1_1")
4535 (define_expand "sgtu"
4536 [(set (match_operand:SI 0 "register_operand")
4537 (gtu:SI (match_dup 1)
4540 { if (mips_emit_scc (GTU, operands[0])) DONE; else FAIL; })
4542 (define_insn "*sgtu_<mode>"
4543 [(set (match_operand:GPR 0 "register_operand" "=d")
4544 (gtu:GPR (match_operand:GPR 1 "register_operand" "d")
4545 (match_operand:GPR 2 "reg_or_0_operand" "dJ")))]
4548 [(set_attr "type" "slt")
4549 (set_attr "mode" "<MODE>")])
4551 (define_insn "*sgtu_<mode>_mips16"
4552 [(set (match_operand:GPR 0 "register_operand" "=t")
4553 (gtu:GPR (match_operand:GPR 1 "register_operand" "d")
4554 (match_operand:GPR 2 "register_operand" "d")))]
4557 [(set_attr "type" "slt")
4558 (set_attr "mode" "<MODE>")])
4560 (define_expand "sgeu"
4561 [(set (match_operand:SI 0 "register_operand")
4562 (geu:SI (match_dup 1)
4565 { if (mips_emit_scc (GEU, operands[0])) DONE; else FAIL; })
4567 (define_insn "*sge_<mode>"
4568 [(set (match_operand:GPR 0 "register_operand" "=d")
4569 (geu:GPR (match_operand:GPR 1 "register_operand" "d")
4573 [(set_attr "type" "slt")
4574 (set_attr "mode" "<MODE>")])
4576 (define_expand "sltu"
4577 [(set (match_operand:SI 0 "register_operand")
4578 (ltu:SI (match_dup 1)
4581 { if (mips_emit_scc (LTU, operands[0])) DONE; else FAIL; })
4583 (define_insn "*sltu_<mode>"
4584 [(set (match_operand:GPR 0 "register_operand" "=d")
4585 (ltu:GPR (match_operand:GPR 1 "register_operand" "d")
4586 (match_operand:GPR 2 "arith_operand" "dI")))]
4589 [(set_attr "type" "slt")
4590 (set_attr "mode" "<MODE>")])
4592 (define_insn "*sltu_<mode>_mips16"
4593 [(set (match_operand:GPR 0 "register_operand" "=t,t")
4594 (ltu:GPR (match_operand:GPR 1 "register_operand" "d,d")
4595 (match_operand:GPR 2 "arith_operand" "d,I")))]
4598 [(set_attr "type" "slt")
4599 (set_attr "mode" "<MODE>")
4600 (set_attr_alternative "length"
4602 (if_then_else (match_operand 2 "m16_uimm8_1")
4606 (define_expand "sleu"
4607 [(set (match_operand:SI 0 "register_operand")
4608 (leu:SI (match_dup 1)
4611 { if (mips_emit_scc (LEU, operands[0])) DONE; else FAIL; })
4613 (define_insn "*sleu_<mode>"
4614 [(set (match_operand:GPR 0 "register_operand" "=d")
4615 (leu:GPR (match_operand:GPR 1 "register_operand" "d")
4616 (match_operand:GPR 2 "sleu_operand" "")))]
4619 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
4620 return "sltu\t%0,%1,%2";
4622 [(set_attr "type" "slt")
4623 (set_attr "mode" "<MODE>")])
4625 (define_insn "*sleu_<mode>_mips16"
4626 [(set (match_operand:GPR 0 "register_operand" "=t")
4627 (leu:GPR (match_operand:GPR 1 "register_operand" "d")
4628 (match_operand:GPR 2 "sleu_operand" "")))]
4631 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
4632 return "sltu\t%1,%2";
4634 [(set_attr "type" "slt")
4635 (set_attr "mode" "<MODE>")
4636 (set (attr "length") (if_then_else (match_operand 2 "m16_uimm8_m1_1")
4641 ;; ....................
4643 ;; FLOATING POINT COMPARISONS
4645 ;; ....................
4647 (define_insn "s<code>_<mode>"
4648 [(set (match_operand:CC 0 "register_operand" "=z")
4649 (fcond:CC (match_operand:SCALARF 1 "register_operand" "f")
4650 (match_operand:SCALARF 2 "register_operand" "f")))]
4652 "c.<fcond>.<fmt>\t%Z0%1,%2"
4653 [(set_attr "type" "fcmp")
4654 (set_attr "mode" "FPSW")])
4656 (define_insn "s<code>_<mode>"
4657 [(set (match_operand:CC 0 "register_operand" "=z")
4658 (swapped_fcond:CC (match_operand:SCALARF 1 "register_operand" "f")
4659 (match_operand:SCALARF 2 "register_operand" "f")))]
4661 "c.<swapped_fcond>.<fmt>\t%Z0%2,%1"
4662 [(set_attr "type" "fcmp")
4663 (set_attr "mode" "FPSW")])
4666 ;; ....................
4668 ;; UNCONDITIONAL BRANCHES
4670 ;; ....................
4672 ;; Unconditional branches.
4676 (label_ref (match_operand 0 "" "")))]
4681 if (get_attr_length (insn) <= 8)
4682 return "%*b\t%l0%/";
4685 output_asm_insn (mips_output_load_label (), operands);
4686 return "%*jr\t%@%/%]";
4690 return "%*j\t%l0%/";
4692 [(set_attr "type" "jump")
4693 (set_attr "mode" "none")
4694 (set (attr "length")
4695 ;; We can't use `j' when emitting PIC. Emit a branch if it's
4696 ;; in range, otherwise load the address of the branch target into
4697 ;; $at and then jump to it.
4699 (ior (eq (symbol_ref "flag_pic") (const_int 0))
4700 (lt (abs (minus (match_dup 0)
4701 (plus (pc) (const_int 4))))
4702 (const_int 131072)))
4703 (const_int 4) (const_int 16)))])
4705 ;; We need a different insn for the mips16, because a mips16 branch
4706 ;; does not have a delay slot.
4710 (label_ref (match_operand 0 "" "")))]
4713 [(set_attr "type" "branch")
4714 (set_attr "mode" "none")
4715 (set_attr "length" "8")])
4717 (define_expand "indirect_jump"
4718 [(set (pc) (match_operand 0 "register_operand"))]
4721 operands[0] = force_reg (Pmode, operands[0]);
4722 if (Pmode == SImode)
4723 emit_jump_insn (gen_indirect_jumpsi (operands[0]));
4725 emit_jump_insn (gen_indirect_jumpdi (operands[0]));
4729 (define_insn "indirect_jump<mode>"
4730 [(set (pc) (match_operand:P 0 "register_operand" "d"))]
4733 [(set_attr "type" "jump")
4734 (set_attr "mode" "none")])
4736 (define_expand "tablejump"
4738 (match_operand 0 "register_operand"))
4739 (use (label_ref (match_operand 1 "")))]
4743 operands[0] = expand_binop (Pmode, add_optab,
4744 convert_to_mode (Pmode, operands[0], false),
4745 gen_rtx_LABEL_REF (Pmode, operands[1]),
4747 else if (TARGET_GPWORD)
4748 operands[0] = expand_binop (Pmode, add_optab, operands[0],
4749 pic_offset_table_rtx, 0, 0, OPTAB_WIDEN);
4751 if (Pmode == SImode)
4752 emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
4754 emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
4758 (define_insn "tablejump<mode>"
4760 (match_operand:P 0 "register_operand" "d"))
4761 (use (label_ref (match_operand 1 "" "")))]
4764 [(set_attr "type" "jump")
4765 (set_attr "mode" "none")])
4767 ;; For TARGET_ABICALLS, we save the gp in the jmp_buf as well.
4768 ;; While it is possible to either pull it off the stack (in the
4769 ;; o32 case) or recalculate it given t9 and our target label,
4770 ;; it takes 3 or 4 insns to do so.
4772 (define_expand "builtin_setjmp_setup"
4773 [(use (match_operand 0 "register_operand"))]
4778 addr = plus_constant (operands[0], GET_MODE_SIZE (Pmode) * 3);
4779 emit_move_insn (gen_rtx_MEM (Pmode, addr), pic_offset_table_rtx);
4783 ;; Restore the gp that we saved above. Despite the earlier comment, it seems
4784 ;; that older code did recalculate the gp from $25. Continue to jump through
4785 ;; $25 for compatibility (we lose nothing by doing so).
4787 (define_expand "builtin_longjmp"
4788 [(use (match_operand 0 "register_operand"))]
4791 /* The elements of the buffer are, in order: */
4792 int W = GET_MODE_SIZE (Pmode);
4793 rtx fp = gen_rtx_MEM (Pmode, operands[0]);
4794 rtx lab = gen_rtx_MEM (Pmode, plus_constant (operands[0], 1*W));
4795 rtx stack = gen_rtx_MEM (Pmode, plus_constant (operands[0], 2*W));
4796 rtx gpv = gen_rtx_MEM (Pmode, plus_constant (operands[0], 3*W));
4797 rtx pv = gen_rtx_REG (Pmode, PIC_FUNCTION_ADDR_REGNUM);
4798 /* Use gen_raw_REG to avoid being given pic_offset_table_rtx.
4799 The target is bound to be using $28 as the global pointer
4800 but the current function might not be. */
4801 rtx gp = gen_raw_REG (Pmode, GLOBAL_POINTER_REGNUM);
4803 /* This bit is similar to expand_builtin_longjmp except that it
4804 restores $gp as well. */
4805 emit_move_insn (hard_frame_pointer_rtx, fp);
4806 emit_move_insn (pv, lab);
4807 emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
4808 emit_move_insn (gp, gpv);
4809 emit_insn (gen_rtx_USE (VOIDmode, hard_frame_pointer_rtx));
4810 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
4811 emit_insn (gen_rtx_USE (VOIDmode, gp));
4812 emit_indirect_jump (pv);
4817 ;; ....................
4819 ;; Function prologue/epilogue
4821 ;; ....................
4824 (define_expand "prologue"
4828 mips_expand_prologue ();
4832 ;; Block any insns from being moved before this point, since the
4833 ;; profiling call to mcount can use various registers that aren't
4834 ;; saved or used to pass arguments.
4836 (define_insn "blockage"
4837 [(unspec_volatile [(const_int 0)] UNSPEC_BLOCKAGE)]
4840 [(set_attr "type" "unknown")
4841 (set_attr "mode" "none")
4842 (set_attr "length" "0")])
4844 (define_expand "epilogue"
4848 mips_expand_epilogue (false);
4852 (define_expand "sibcall_epilogue"
4856 mips_expand_epilogue (true);
4860 ;; Trivial return. Make it look like a normal return insn as that
4861 ;; allows jump optimizations to work better.
4863 (define_insn "return"
4865 "mips_can_use_return_insn ()"
4867 [(set_attr "type" "jump")
4868 (set_attr "mode" "none")])
4872 (define_insn "return_internal"
4874 (use (match_operand 0 "pmode_register_operand" ""))]
4877 [(set_attr "type" "jump")
4878 (set_attr "mode" "none")])
4880 ;; This is used in compiling the unwind routines.
4881 (define_expand "eh_return"
4882 [(use (match_operand 0 "general_operand"))]
4885 enum machine_mode gpr_mode = TARGET_64BIT ? DImode : SImode;
4887 if (GET_MODE (operands[0]) != gpr_mode)
4888 operands[0] = convert_to_mode (gpr_mode, operands[0], 0);
4890 emit_insn (gen_eh_set_lr_di (operands[0]));
4892 emit_insn (gen_eh_set_lr_si (operands[0]));
4897 ;; Clobber the return address on the stack. We can't expand this
4898 ;; until we know where it will be put in the stack frame.
4900 (define_insn "eh_set_lr_si"
4901 [(unspec [(match_operand:SI 0 "register_operand" "d")] UNSPEC_EH_RETURN)
4902 (clobber (match_scratch:SI 1 "=&d"))]
4906 (define_insn "eh_set_lr_di"
4907 [(unspec [(match_operand:DI 0 "register_operand" "d")] UNSPEC_EH_RETURN)
4908 (clobber (match_scratch:DI 1 "=&d"))]
4913 [(unspec [(match_operand 0 "register_operand")] UNSPEC_EH_RETURN)
4914 (clobber (match_scratch 1))]
4915 "reload_completed && !TARGET_DEBUG_D_MODE"
4918 mips_set_return_address (operands[0], operands[1]);
4922 (define_insn_and_split "exception_receiver"
4924 (unspec_volatile:SI [(const_int 0)] UNSPEC_EH_RECEIVER))]
4925 "TARGET_ABICALLS && TARGET_OLDABI"
4927 "&& reload_completed"
4933 [(set_attr "type" "load")
4934 (set_attr "length" "12")])
4937 ;; ....................
4941 ;; ....................
4943 ;; Instructions to load a call address from the GOT. The address might
4944 ;; point to a function or to a lazy binding stub. In the latter case,
4945 ;; the stub will use the dynamic linker to resolve the function, which
4946 ;; in turn will change the GOT entry to point to the function's real
4949 ;; This means that every call, even pure and constant ones, can
4950 ;; potentially modify the GOT entry. And once a stub has been called,
4951 ;; we must not call it again.
4953 ;; We represent this restriction using an imaginary fixed register that
4954 ;; acts like a GOT version number. By making the register call-clobbered,
4955 ;; we tell the target-independent code that the address could be changed
4956 ;; by any call insn.
4957 (define_insn "load_call<mode>"
4958 [(set (match_operand:P 0 "register_operand" "=c")
4959 (unspec:P [(match_operand:P 1 "register_operand" "r")
4960 (match_operand:P 2 "immediate_operand" "")
4961 (reg:P FAKE_CALL_REGNO)]
4964 "<load>\t%0,%R2(%1)"
4965 [(set_attr "type" "load")
4966 (set_attr "mode" "<MODE>")
4967 (set_attr "length" "4")])
4969 ;; Sibling calls. All these patterns use jump instructions.
4971 ;; If TARGET_SIBCALLS, call_insn_operand will only accept constant
4972 ;; addresses if a direct jump is acceptable. Since the 'S' constraint
4973 ;; is defined in terms of call_insn_operand, the same is true of the
4976 ;; When we use an indirect jump, we need a register that will be
4977 ;; preserved by the epilogue. Since TARGET_ABICALLS forces us to
4978 ;; use $25 for this purpose -- and $25 is never clobbered by the
4979 ;; epilogue -- we might as well use it for !TARGET_ABICALLS as well.
4981 (define_expand "sibcall"
4982 [(parallel [(call (match_operand 0 "")
4983 (match_operand 1 ""))
4984 (use (match_operand 2 "")) ;; next_arg_reg
4985 (use (match_operand 3 ""))])] ;; struct_value_size_rtx
4988 mips_expand_call (0, XEXP (operands[0], 0), operands[1], operands[2], true);
4992 (define_insn "sibcall_internal"
4993 [(call (mem:SI (match_operand 0 "call_insn_operand" "j,S"))
4994 (match_operand 1 "" ""))]
4995 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
4999 [(set_attr "type" "call")])
5001 (define_expand "sibcall_value"
5002 [(parallel [(set (match_operand 0 "")
5003 (call (match_operand 1 "")
5004 (match_operand 2 "")))
5005 (use (match_operand 3 ""))])] ;; next_arg_reg
5008 mips_expand_call (operands[0], XEXP (operands[1], 0),
5009 operands[2], operands[3], true);
5013 (define_insn "sibcall_value_internal"
5014 [(set (match_operand 0 "register_operand" "=df,df")
5015 (call (mem:SI (match_operand 1 "call_insn_operand" "j,S"))
5016 (match_operand 2 "" "")))]
5017 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
5021 [(set_attr "type" "call")])
5023 (define_insn "sibcall_value_multiple_internal"
5024 [(set (match_operand 0 "register_operand" "=df,df")
5025 (call (mem:SI (match_operand 1 "call_insn_operand" "j,S"))
5026 (match_operand 2 "" "")))
5027 (set (match_operand 3 "register_operand" "=df,df")
5028 (call (mem:SI (match_dup 1))
5030 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
5034 [(set_attr "type" "call")])
5036 (define_expand "call"
5037 [(parallel [(call (match_operand 0 "")
5038 (match_operand 1 ""))
5039 (use (match_operand 2 "")) ;; next_arg_reg
5040 (use (match_operand 3 ""))])] ;; struct_value_size_rtx
5043 mips_expand_call (0, XEXP (operands[0], 0), operands[1], operands[2], false);
5047 ;; This instruction directly corresponds to an assembly-language "jal".
5048 ;; There are four cases:
5051 ;; Both symbolic and register destinations are OK. The pattern
5052 ;; always expands to a single mips instruction.
5054 ;; - -mabicalls/-mno-explicit-relocs:
5055 ;; Again, both symbolic and register destinations are OK.
5056 ;; The call is treated as a multi-instruction black box.
5058 ;; - -mabicalls/-mexplicit-relocs with n32 or n64:
5059 ;; Only "jal $25" is allowed. This expands to a single "jalr $25"
5062 ;; - -mabicalls/-mexplicit-relocs with o32 or o64:
5063 ;; Only "jal $25" is allowed. The call is actually two instructions:
5064 ;; "jalr $25" followed by an insn to reload $gp.
5066 ;; In the last case, we can generate the individual instructions with
5067 ;; a define_split. There are several things to be wary of:
5069 ;; - We can't expose the load of $gp before reload. If we did,
5070 ;; it might get removed as dead, but reload can introduce new
5071 ;; uses of $gp by rematerializing constants.
5073 ;; - We shouldn't restore $gp after calls that never return.
5074 ;; It isn't valid to insert instructions between a noreturn
5075 ;; call and the following barrier.
5077 ;; - The splitter deliberately changes the liveness of $gp. The unsplit
5078 ;; instruction preserves $gp and so have no effect on its liveness.
5079 ;; But once we generate the separate insns, it becomes obvious that
5080 ;; $gp is not live on entry to the call.
5082 ;; ??? The operands[2] = insn check is a hack to make the original insn
5083 ;; available to the splitter.
5084 (define_insn_and_split "call_internal"
5085 [(call (mem:SI (match_operand 0 "call_insn_operand" "c,S"))
5086 (match_operand 1 "" ""))
5087 (clobber (reg:SI 31))]
5089 { return TARGET_SPLIT_CALLS ? "#" : "%*jal\t%0%/"; }
5090 "reload_completed && TARGET_SPLIT_CALLS && (operands[2] = insn)"
5093 emit_call_insn (gen_call_split (operands[0], operands[1]));
5094 if (!find_reg_note (operands[2], REG_NORETURN, 0))
5098 [(set_attr "jal" "indirect,direct")
5099 (set_attr "extended_mips16" "no,yes")])
5101 (define_insn "call_split"
5102 [(call (mem:SI (match_operand 0 "call_insn_operand" "c"))
5103 (match_operand 1 "" ""))
5104 (clobber (reg:SI 31))
5105 (clobber (reg:SI 28))]
5106 "TARGET_SPLIT_CALLS"
5108 [(set_attr "type" "call")])
5110 (define_expand "call_value"
5111 [(parallel [(set (match_operand 0 "")
5112 (call (match_operand 1 "")
5113 (match_operand 2 "")))
5114 (use (match_operand 3 ""))])] ;; next_arg_reg
5117 mips_expand_call (operands[0], XEXP (operands[1], 0),
5118 operands[2], operands[3], false);
5122 ;; See comment for call_internal.
5123 (define_insn_and_split "call_value_internal"
5124 [(set (match_operand 0 "register_operand" "=df,df")
5125 (call (mem:SI (match_operand 1 "call_insn_operand" "c,S"))
5126 (match_operand 2 "" "")))
5127 (clobber (reg:SI 31))]
5129 { return TARGET_SPLIT_CALLS ? "#" : "%*jal\t%1%/"; }
5130 "reload_completed && TARGET_SPLIT_CALLS && (operands[3] = insn)"
5133 emit_call_insn (gen_call_value_split (operands[0], operands[1],
5135 if (!find_reg_note (operands[3], REG_NORETURN, 0))
5139 [(set_attr "jal" "indirect,direct")
5140 (set_attr "extended_mips16" "no,yes")])
5142 (define_insn "call_value_split"
5143 [(set (match_operand 0 "register_operand" "=df")
5144 (call (mem:SI (match_operand 1 "call_insn_operand" "c"))
5145 (match_operand 2 "" "")))
5146 (clobber (reg:SI 31))
5147 (clobber (reg:SI 28))]
5148 "TARGET_SPLIT_CALLS"
5150 [(set_attr "type" "call")])
5152 ;; See comment for call_internal.
5153 (define_insn_and_split "call_value_multiple_internal"
5154 [(set (match_operand 0 "register_operand" "=df,df")
5155 (call (mem:SI (match_operand 1 "call_insn_operand" "c,S"))
5156 (match_operand 2 "" "")))
5157 (set (match_operand 3 "register_operand" "=df,df")
5158 (call (mem:SI (match_dup 1))
5160 (clobber (reg:SI 31))]
5162 { return TARGET_SPLIT_CALLS ? "#" : "%*jal\t%1%/"; }
5163 "reload_completed && TARGET_SPLIT_CALLS && (operands[4] = insn)"
5166 emit_call_insn (gen_call_value_multiple_split (operands[0], operands[1],
5167 operands[2], operands[3]));
5168 if (!find_reg_note (operands[4], REG_NORETURN, 0))
5172 [(set_attr "jal" "indirect,direct")
5173 (set_attr "extended_mips16" "no,yes")])
5175 (define_insn "call_value_multiple_split"
5176 [(set (match_operand 0 "register_operand" "=df")
5177 (call (mem:SI (match_operand 1 "call_insn_operand" "c"))
5178 (match_operand 2 "" "")))
5179 (set (match_operand 3 "register_operand" "=df")
5180 (call (mem:SI (match_dup 1))
5182 (clobber (reg:SI 31))
5183 (clobber (reg:SI 28))]
5184 "TARGET_SPLIT_CALLS"
5186 [(set_attr "type" "call")])
5188 ;; Call subroutine returning any type.
5190 (define_expand "untyped_call"
5191 [(parallel [(call (match_operand 0 "")
5193 (match_operand 1 "")
5194 (match_operand 2 "")])]
5199 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
5201 for (i = 0; i < XVECLEN (operands[2], 0); i++)
5203 rtx set = XVECEXP (operands[2], 0, i);
5204 emit_move_insn (SET_DEST (set), SET_SRC (set));
5207 emit_insn (gen_blockage ());
5212 ;; ....................
5216 ;; ....................
5220 (define_insn "prefetch"
5221 [(prefetch (match_operand:QI 0 "address_operand" "p")
5222 (match_operand 1 "const_int_operand" "n")
5223 (match_operand 2 "const_int_operand" "n"))]
5224 "ISA_HAS_PREFETCH && TARGET_EXPLICIT_RELOCS"
5226 operands[1] = mips_prefetch_cookie (operands[1], operands[2]);
5227 return "pref\t%1,%a0";
5229 [(set_attr "type" "prefetch")])
5231 (define_insn "*prefetch_indexed_<mode>"
5232 [(prefetch (plus:P (match_operand:P 0 "register_operand" "d")
5233 (match_operand:P 1 "register_operand" "d"))
5234 (match_operand 2 "const_int_operand" "n")
5235 (match_operand 3 "const_int_operand" "n"))]
5236 "ISA_HAS_PREFETCHX && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
5238 operands[2] = mips_prefetch_cookie (operands[2], operands[3]);
5239 return "prefx\t%2,%1(%0)";
5241 [(set_attr "type" "prefetchx")])
5247 [(set_attr "type" "nop")
5248 (set_attr "mode" "none")])
5250 ;; Like nop, but commented out when outside a .set noreorder block.
5251 (define_insn "hazard_nop"
5260 [(set_attr "type" "nop")])
5262 ;; MIPS4 Conditional move instructions.
5264 (define_insn "*mov<GPR:mode>_on_<MOVECC:mode>"
5265 [(set (match_operand:GPR 0 "register_operand" "=d,d")
5267 (match_operator:MOVECC 4 "equality_operator"
5268 [(match_operand:MOVECC 1 "register_operand" "<MOVECC:reg>,<MOVECC:reg>")
5270 (match_operand:GPR 2 "reg_or_0_operand" "dJ,0")
5271 (match_operand:GPR 3 "reg_or_0_operand" "0,dJ")))]
5276 [(set_attr "type" "condmove")
5277 (set_attr "mode" "<GPR:MODE>")])
5279 (define_insn "*mov<SCALARF:mode>_on_<MOVECC:mode>"
5280 [(set (match_operand:SCALARF 0 "register_operand" "=f,f")
5281 (if_then_else:SCALARF
5282 (match_operator:MOVECC 4 "equality_operator"
5283 [(match_operand:MOVECC 1 "register_operand" "<MOVECC:reg>,<MOVECC:reg>")
5285 (match_operand:SCALARF 2 "register_operand" "f,0")
5286 (match_operand:SCALARF 3 "register_operand" "0,f")))]
5289 mov%T4.<fmt>\t%0,%2,%1
5290 mov%t4.<fmt>\t%0,%3,%1"
5291 [(set_attr "type" "condmove")
5292 (set_attr "mode" "<SCALARF:MODE>")])
5294 ;; These are the main define_expand's used to make conditional moves.
5296 (define_expand "mov<mode>cc"
5297 [(set (match_dup 4) (match_operand 1 "comparison_operator"))
5298 (set (match_operand:GPR 0 "register_operand")
5299 (if_then_else:GPR (match_dup 5)
5300 (match_operand:GPR 2 "reg_or_0_operand")
5301 (match_operand:GPR 3 "reg_or_0_operand")))]
5304 gen_conditional_move (operands);
5308 (define_expand "mov<mode>cc"
5309 [(set (match_dup 4) (match_operand 1 "comparison_operator"))
5310 (set (match_operand:SCALARF 0 "register_operand")
5311 (if_then_else:SCALARF (match_dup 5)
5312 (match_operand:SCALARF 2 "register_operand")
5313 (match_operand:SCALARF 3 "register_operand")))]
5316 gen_conditional_move (operands);
5321 ;; ....................
5323 ;; mips16 inline constant tables
5325 ;; ....................
5328 (define_insn "consttable_int"
5329 [(unspec_volatile [(match_operand 0 "consttable_operand" "")
5330 (match_operand 1 "const_int_operand" "")]
5331 UNSPEC_CONSTTABLE_INT)]
5334 assemble_integer (operands[0], INTVAL (operands[1]),
5335 BITS_PER_UNIT * INTVAL (operands[1]), 1);
5338 [(set (attr "length") (symbol_ref "INTVAL (operands[1])"))])
5340 (define_insn "consttable_float"
5341 [(unspec_volatile [(match_operand 0 "consttable_operand" "")]
5342 UNSPEC_CONSTTABLE_FLOAT)]
5347 gcc_assert (GET_CODE (operands[0]) == CONST_DOUBLE);
5348 REAL_VALUE_FROM_CONST_DOUBLE (d, operands[0]);
5349 assemble_real (d, GET_MODE (operands[0]),
5350 GET_MODE_BITSIZE (GET_MODE (operands[0])));
5353 [(set (attr "length")
5354 (symbol_ref "GET_MODE_SIZE (GET_MODE (operands[0]))"))])
5356 (define_insn "align"
5357 [(unspec_volatile [(match_operand 0 "const_int_operand" "")] UNSPEC_ALIGN)]
5360 [(set (attr "length") (symbol_ref "(1 << INTVAL (operands[0])) - 1"))])
5363 [(match_operand 0 "small_data_pattern")]
5366 { operands[0] = mips_rewrite_small_data (operands[0]); })
5368 ; Thread-Local Storage
5370 ; The TLS base pointer is accessed via "rdhwr $v1, $29". No current
5371 ; MIPS architecture defines this register, and no current
5372 ; implementation provides it; instead, any OS which supports TLS is
5373 ; expected to trap and emulate this instruction. rdhwr is part of the
5374 ; MIPS 32r2 specification, but we use it on any architecture because
5375 ; we expect it to be emulated. Use .set to force the assembler to
5378 (define_insn "tls_get_tp_<mode>"
5379 [(set (match_operand:P 0 "register_operand" "=v")
5380 (unspec:P [(const_int 0)]
5381 UNSPEC_TLS_GET_TP))]
5382 "HAVE_AS_TLS && !TARGET_MIPS16"
5383 ".set\tpush\;.set\tmips32r2\t\;rdhwr\t%0,$29\;.set\tpop"
5384 [(set_attr "type" "unknown")
5385 (set_attr "mode" "<MODE>")])
5387 ; The MIPS Paired-Single Floating Point and MIPS-3D Instructions.
5389 (include "mips-ps-3d.md")