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 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.
26 ;; ??? Currently does not have define_function_unit support for the R8000.
27 ;; Must include new entries for fmadd in addition to existing entries.
30 [(UNSPEC_LOAD_DF_LOW 0)
31 (UNSPEC_LOAD_DF_HIGH 1)
32 (UNSPEC_STORE_DF_HIGH 2)
36 (UNSPEC_EH_RECEIVER 6)
38 (UNSPEC_CONSTTABLE_QI 8)
39 (UNSPEC_CONSTTABLE_HI 9)
40 (UNSPEC_CONSTTABLE_SI 10)
41 (UNSPEC_CONSTTABLE_DI 11)
42 (UNSPEC_CONSTTABLE_SF 12)
43 (UNSPEC_CONSTTABLE_DF 13)
60 (UNSPEC_ADDRESS_FIRST 100)
62 (FAKE_CALL_REGNO 79)])
64 ;; ....................
68 ;; ....................
70 (define_attr "got" "unset,xgot_high,load"
71 (const_string "unset"))
73 ;; For jal instructions, this attribute is DIRECT when the target address
74 ;; is symbolic and INDIRECT when it is a register.
75 (define_attr "jal" "unset,direct,indirect"
76 (const_string "unset"))
78 ;; This attribute is YES if the instruction is a jal macro (not a
79 ;; real jal instruction).
81 ;; jal is always a macro in SVR4 PIC since it includes an instruction to
82 ;; restore $gp. Direct jals are also macros in NewABI PIC since they
83 ;; load the target address into $25.
84 (define_attr "jal_macro" "no,yes"
85 (cond [(eq_attr "jal" "direct")
86 (symbol_ref "TARGET_ABICALLS != 0")
87 (eq_attr "jal" "indirect")
88 (symbol_ref "(TARGET_ABICALLS && !TARGET_NEWABI) != 0")]
91 ;; Classification of each insn.
92 ;; branch conditional branch
93 ;; jump unconditional jump
94 ;; call unconditional call
95 ;; load load instruction(s)
96 ;; store store instruction(s)
97 ;; prefetch memory prefetch (register + offset)
98 ;; prefetchx memory indexed prefetch (register + register)
99 ;; move data movement within same register set
100 ;; condmove conditional moves
101 ;; xfer transfer to/from coprocessor
102 ;; hilo transfer of hi/lo registers
103 ;; arith integer arithmetic instruction
104 ;; darith double precision integer arithmetic instructions
105 ;; const load constant
106 ;; imul integer multiply
107 ;; imadd integer multiply-add
108 ;; idiv integer divide
109 ;; icmp integer compare
110 ;; fadd floating point add/subtract
111 ;; fmul floating point multiply
112 ;; fmadd floating point multiply-add
113 ;; fdiv floating point divide
114 ;; fabs floating point absolute value
115 ;; fneg floating point negation
116 ;; fcmp floating point compare
117 ;; fcvt floating point convert
118 ;; fsqrt floating point square root
119 ;; frsqrt floating point reciprocal square root
120 ;; multi multiword sequence (or user asm statements)
123 "unknown,branch,jump,call,load,store,prefetch,prefetchx,move,condmove,xfer,hilo,const,arith,darith,imul,imadd,idiv,icmp,fadd,fmul,fmadd,fdiv,fabs,fneg,fcmp,fcvt,fsqrt,frsqrt,multi,nop"
124 (cond [(eq_attr "jal" "!unset") (const_string "call")
125 (eq_attr "got" "load") (const_string "load")]
126 (const_string "unknown")))
128 ;; Main data type used by the insn
129 (define_attr "mode" "unknown,none,QI,HI,SI,DI,SF,DF,FPSW"
130 (const_string "unknown"))
132 ;; Is this an extended instruction in mips16 mode?
133 (define_attr "extended_mips16" "no,yes"
136 ;; Length of instruction in bytes.
137 (define_attr "length" ""
138 (cond [;; Direct branch instructions have a range of [-0x40000,0x3fffc].
139 ;; If a branch is outside this range, we have a choice of two
140 ;; sequences. For PIC, an out-of-range branch like:
145 ;; becomes the equivalent of:
154 ;; where the load address can be up to three instructions long
157 ;; The non-PIC case is similar except that we use a direct
158 ;; jump instead of an la/jr pair. Since the target of this
159 ;; jump is an absolute 28-bit bit address (the other bits
160 ;; coming from the address of the delay slot) this form cannot
161 ;; cross a 256MB boundary. We could provide the option of
162 ;; using la/jr in this case too, but we do not do so at
165 ;; Note that this value does not account for the delay slot
166 ;; instruction, whose length is added separately. If the RTL
167 ;; pattern has no explicit delay slot, mips_adjust_insn_length
168 ;; will add the length of the implicit nop.
169 (eq_attr "type" "branch")
170 (cond [(lt (abs (minus (match_dup 1) (plus (pc) (const_int 4))))
173 (ne (symbol_ref "flag_pic && ! TARGET_EMBEDDED_PIC")
178 (eq_attr "got" "load")
180 (eq_attr "got" "xgot_high")
183 (eq_attr "type" "const")
184 (symbol_ref "mips_const_insns (operands[1]) * 4")
185 (eq_attr "type" "load")
186 (symbol_ref "mips_fetch_insns (operands[1]) * 4")
187 (eq_attr "type" "store")
188 (symbol_ref "mips_fetch_insns (operands[0]) * 4")
190 ;; In the worst case, a call macro will take 8 instructions:
192 ;; lui $25,%call_hi(FOO)
194 ;; lw $25,%call_lo(FOO)($25)
200 (eq_attr "jal_macro" "yes")
203 (and (eq_attr "extended_mips16" "yes")
204 (ne (symbol_ref "TARGET_MIPS16") (const_int 0)))
207 (eq_attr "type" "idiv")
208 (symbol_ref "mips_idiv_insns () * 4")
211 ;; Attribute describing the processor. This attribute must match exactly
212 ;; with the processor_type enumeration in mips.h.
214 "default,4kc,5kc,20kc,m4k,r3000,r3900,r6000,r4000,r4100,r4111,r4120,r4300,r4600,r4650,r5000,r5400,r5500,r7000,r8000,r9000,sb1,sr71000"
215 (const (symbol_ref "mips_tune")))
217 ;; The type of hardware hazard associated with this instruction.
218 ;; DELAY means that the next instruction cannot read the result
219 ;; of this one. HILO means that the next two instructions cannot
220 ;; write to HI or LO.
221 (define_attr "hazard" "none,delay,hilo"
222 (cond [(and (eq_attr "type" "load")
223 (ne (symbol_ref "ISA_HAS_LOAD_DELAY") (const_int 0)))
224 (const_string "delay")
226 (and (eq_attr "type" "xfer")
227 (ne (symbol_ref "ISA_HAS_XFER_DELAY") (const_int 0)))
228 (const_string "delay")
230 (and (eq_attr "type" "fcmp")
231 (ne (symbol_ref "ISA_HAS_FCMP_DELAY") (const_int 0)))
232 (const_string "delay")
234 ;; The r4000 multiplication patterns include an mflo instruction.
235 (and (eq_attr "type" "imul")
236 (ne (symbol_ref "TARGET_FIX_R4000") (const_int 0)))
237 (const_string "hilo")
239 (and (eq_attr "type" "hilo")
240 (and (eq (symbol_ref "ISA_HAS_HILO_INTERLOCKS") (const_int 0))
241 (match_operand 1 "hilo_operand" "")))
242 (const_string "hilo")]
243 (const_string "none")))
245 ;; Is it a single instruction?
246 (define_attr "single_insn" "no,yes"
247 (symbol_ref "get_attr_length (insn) == (TARGET_MIPS16 ? 2 : 4)"))
249 ;; Can the instruction be put into a delay slot?
250 (define_attr "can_delay" "no,yes"
251 (if_then_else (and (eq_attr "type" "!branch,call,jump")
252 (and (eq_attr "hazard" "none")
253 (eq_attr "single_insn" "yes")))
255 (const_string "no")))
257 ;; Attribute defining whether or not we can use the branch-likely instructions
258 (define_attr "branch_likely" "no,yes"
260 (if_then_else (ne (symbol_ref "GENERATE_BRANCHLIKELY") (const_int 0))
262 (const_string "no"))))
264 ;; Describe a user's asm statement.
265 (define_asm_attributes
266 [(set_attr "type" "multi")])
268 ;; .........................
270 ;; Branch, call and jump delay slots
272 ;; .........................
274 (define_delay (and (eq_attr "type" "branch")
275 (eq (symbol_ref "TARGET_MIPS16") (const_int 0)))
276 [(eq_attr "can_delay" "yes")
278 (and (eq_attr "branch_likely" "yes")
279 (eq_attr "can_delay" "yes"))])
281 (define_delay (eq_attr "type" "jump")
282 [(eq_attr "can_delay" "yes")
286 (define_delay (and (eq_attr "type" "call")
287 (eq_attr "jal_macro" "no"))
288 [(eq_attr "can_delay" "yes")
292 ;; .........................
296 ;; .........................
298 ; (define_function_unit NAME MULTIPLICITY SIMULTANEITY
299 ; TEST READY-DELAY ISSUE-DELAY [CONFLICT-LIST])
301 ;; Make the default case (PROCESSOR_DEFAULT) handle the worst case
303 (define_function_unit "memory" 1 0
304 (and (eq_attr "type" "load")
305 (eq_attr "cpu" "!r3000,r3900,r4600,r4650,r4100,r4120,r4300,r5000"))
308 (define_function_unit "memory" 1 0
309 (and (eq_attr "type" "load")
310 (eq_attr "cpu" "r3000,r3900,r4600,r4650,r4100,r4120,r4300,r5000"))
313 (define_function_unit "memory" 1 0 (eq_attr "type" "store") 1 0)
315 (define_function_unit "memory" 1 0 (eq_attr "type" "xfer") 2 0)
317 (define_function_unit "imuldiv" 1 0
318 (eq_attr "type" "hilo")
321 (define_function_unit "imuldiv" 1 0
322 (and (eq_attr "type" "imul,imadd")
323 (eq_attr "cpu" "!r3000,r3900,r4000,r4600,r4650,r4100,r4120,r4300,r5000"))
326 ;; On them mips16, we want to stronly discourage a mult from appearing
327 ;; after an mflo, since that requires explicit nop instructions. We
328 ;; do this by pretending that mflo ties up the function unit for long
329 ;; enough that the scheduler will ignore load stalls and the like when
330 ;; selecting instructions to between the two instructions.
332 (define_function_unit "imuldiv" 1 0
333 (and (eq_attr "type" "hilo") (ne (symbol_ref "TARGET_MIPS16") (const_int 0)))
336 (define_function_unit "imuldiv" 1 0
337 (and (eq_attr "type" "imul,imadd") (eq_attr "cpu" "r3000,r3900"))
340 (define_function_unit "imuldiv" 1 0
341 (and (eq_attr "type" "imul,imadd") (eq_attr "cpu" "r4000,r4600"))
344 (define_function_unit "imuldiv" 1 0
345 (and (eq_attr "type" "imul,imadd") (eq_attr "cpu" "r4650"))
348 (define_function_unit "imuldiv" 1 0
349 (and (eq_attr "type" "imul,imadd")
350 (and (eq_attr "mode" "SI") (eq_attr "cpu" "r4100,r4120")))
353 (define_function_unit "imuldiv" 1 0
354 (and (eq_attr "type" "imul,imadd")
355 (and (eq_attr "mode" "DI") (eq_attr "cpu" "r4100,r4120")))
358 (define_function_unit "imuldiv" 1 0
359 (and (eq_attr "type" "imul,imadd")
360 (and (eq_attr "mode" "SI") (eq_attr "cpu" "r4300,r5000")))
363 (define_function_unit "imuldiv" 1 0
364 (and (eq_attr "type" "imul,imadd")
365 (and (eq_attr "mode" "DI") (eq_attr "cpu" "r4300")))
368 (define_function_unit "imuldiv" 1 0
369 (and (eq_attr "type" "imul,imadd")
370 (and (eq_attr "mode" "DI") (eq_attr "cpu" "r5000")))
373 (define_function_unit "imuldiv" 1 0
374 (and (eq_attr "type" "idiv")
375 (eq_attr "cpu" "!r3000,r3900,r4000,r4600,r4650,r4100,r4120,r4300,r5000"))
378 (define_function_unit "imuldiv" 1 0
379 (and (eq_attr "type" "idiv") (eq_attr "cpu" "r3000,r3900"))
382 (define_function_unit "imuldiv" 1 0
383 (and (eq_attr "type" "idiv") (eq_attr "cpu" "r4600"))
386 (define_function_unit "imuldiv" 1 0
387 (and (eq_attr "type" "idiv") (eq_attr "cpu" "r4650"))
390 (define_function_unit "imuldiv" 1 0
391 (and (eq_attr "type" "idiv") (eq_attr "cpu" "r4000"))
394 (define_function_unit "imuldiv" 1 0
395 (and (eq_attr "type" "idiv")
396 (and (eq_attr "mode" "SI") (eq_attr "cpu" "r4100,r4120")))
399 (define_function_unit "imuldiv" 1 0
400 (and (eq_attr "type" "idiv")
401 (and (eq_attr "mode" "DI") (eq_attr "cpu" "r4100,r4120")))
404 (define_function_unit "imuldiv" 1 0
405 (and (eq_attr "type" "idiv")
406 (and (eq_attr "mode" "SI") (eq_attr "cpu" "r4300")))
409 (define_function_unit "imuldiv" 1 0
410 (and (eq_attr "type" "idiv")
411 (and (eq_attr "mode" "DI") (eq_attr "cpu" "r4300")))
414 (define_function_unit "imuldiv" 1 0
415 (and (eq_attr "type" "idiv")
416 (and (eq_attr "mode" "SI") (eq_attr "cpu" "r5000")))
419 (define_function_unit "imuldiv" 1 0
420 (and (eq_attr "type" "idiv")
421 (and (eq_attr "mode" "DI") (eq_attr "cpu" "r5000")))
424 ;; The R4300 does *NOT* have a separate Floating Point Unit, instead
425 ;; the FP hardware is part of the normal ALU circuitry. This means FP
426 ;; instructions affect the pipe-line, and no functional unit
427 ;; parallelism can occur on R4300 processors. To force GCC into coding
428 ;; for only a single functional unit, we force the R4300 FP
429 ;; instructions to be processed in the "imuldiv" unit.
431 (define_function_unit "adder" 1 1
432 (and (eq_attr "type" "fcmp") (eq_attr "cpu" "!r3000,r3900,r6000,r4300,r5000"))
435 (define_function_unit "adder" 1 1
436 (and (eq_attr "type" "fcmp") (eq_attr "cpu" "r3000,r3900,r6000"))
439 (define_function_unit "adder" 1 1
440 (and (eq_attr "type" "fcmp") (eq_attr "cpu" "r5000"))
443 (define_function_unit "adder" 1 1
444 (and (eq_attr "type" "fadd") (eq_attr "cpu" "!r3000,r3900,r6000,r4300"))
447 (define_function_unit "adder" 1 1
448 (and (eq_attr "type" "fadd") (eq_attr "cpu" "r3000,r3900"))
451 (define_function_unit "adder" 1 1
452 (and (eq_attr "type" "fadd") (eq_attr "cpu" "r6000"))
455 (define_function_unit "adder" 1 1
456 (and (eq_attr "type" "fabs,fneg")
457 (eq_attr "cpu" "!r3000,r3900,r4600,r4650,r4300,r5000"))
460 (define_function_unit "adder" 1 1
461 (and (eq_attr "type" "fabs,fneg") (eq_attr "cpu" "r3000,r3900,r4600,r4650,r5000"))
464 (define_function_unit "mult" 1 1
465 (and (eq_attr "type" "fmul")
466 (and (eq_attr "mode" "SF")
467 (eq_attr "cpu" "!r3000,r3900,r6000,r4600,r4650,r4300,r5000")))
470 (define_function_unit "mult" 1 1
471 (and (eq_attr "type" "fmul")
472 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r3000,r3900,r5000")))
475 (define_function_unit "mult" 1 1
476 (and (eq_attr "type" "fmul")
477 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r6000")))
480 (define_function_unit "mult" 1 1
481 (and (eq_attr "type" "fmul")
482 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r4600,r4650")))
485 (define_function_unit "mult" 1 1
486 (and (eq_attr "type" "fmul")
487 (and (eq_attr "mode" "DF") (eq_attr "cpu" "!r3000,r3900,r6000,r4300,r5000")))
490 (define_function_unit "mult" 1 1
491 (and (eq_attr "type" "fmul")
492 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r3000,r3900,r5000")))
495 (define_function_unit "mult" 1 1
496 (and (eq_attr "type" "fmul")
497 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r6000")))
500 (define_function_unit "divide" 1 1
501 (and (eq_attr "type" "fdiv")
502 (and (eq_attr "mode" "SF")
503 (eq_attr "cpu" "!r3000,r3900,r6000,r4600,r4650,r4300,r5000")))
506 (define_function_unit "divide" 1 1
507 (and (eq_attr "type" "fdiv")
508 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r3000,r3900")))
511 (define_function_unit "divide" 1 1
512 (and (eq_attr "type" "fdiv")
513 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r6000")))
516 (define_function_unit "divide" 1 1
517 (and (eq_attr "type" "fdiv")
518 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r4600,r4650")))
521 (define_function_unit "divide" 1 1
522 (and (eq_attr "type" "fdiv")
523 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r5000")))
526 (define_function_unit "divide" 1 1
527 (and (eq_attr "type" "fdiv")
528 (and (eq_attr "mode" "DF")
529 (eq_attr "cpu" "!r3000,r3900,r6000,r4600,r4650,r4300")))
532 (define_function_unit "divide" 1 1
533 (and (eq_attr "type" "fdiv")
534 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r3000,r3900")))
537 (define_function_unit "divide" 1 1
538 (and (eq_attr "type" "fdiv")
539 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r6000")))
542 (define_function_unit "divide" 1 1
543 (and (eq_attr "type" "fdiv")
544 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r4600,r4650")))
547 ;;; ??? Is this number right?
548 (define_function_unit "divide" 1 1
549 (and (eq_attr "type" "fsqrt,frsqrt")
550 (and (eq_attr "mode" "SF") (eq_attr "cpu" "!r4600,r4650,r4300,r5000")))
553 (define_function_unit "divide" 1 1
554 (and (eq_attr "type" "fsqrt,frsqrt")
555 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r4600,r4650")))
558 (define_function_unit "divide" 1 1
559 (and (eq_attr "type" "fsqrt,frsqrt")
560 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r5000")))
563 ;;; ??? Is this number right?
564 (define_function_unit "divide" 1 1
565 (and (eq_attr "type" "fsqrt,frsqrt")
566 (and (eq_attr "mode" "DF") (eq_attr "cpu" "!r4600,r4650,r4300,r5000")))
569 (define_function_unit "divide" 1 1
570 (and (eq_attr "type" "fsqrt,frsqrt")
571 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r4600,r4650")))
574 (define_function_unit "divide" 1 1
575 (and (eq_attr "type" "fsqrt,frsqrt")
576 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r5000")))
579 ;; R4300 FP instruction classes treated as part of the "imuldiv"
582 (define_function_unit "imuldiv" 1 0
583 (and (eq_attr "type" "fadd") (eq_attr "cpu" "r4300"))
586 (define_function_unit "imuldiv" 1 0
587 (and (eq_attr "type" "fcmp,fabs,fneg") (eq_attr "cpu" "r4300"))
590 (define_function_unit "imuldiv" 1 0
591 (and (eq_attr "type" "fmul") (and (eq_attr "mode" "SF") (eq_attr "cpu" "r4300")))
593 (define_function_unit "imuldiv" 1 0
594 (and (eq_attr "type" "fmul") (and (eq_attr "mode" "DF") (eq_attr "cpu" "r4300")))
597 (define_function_unit "imuldiv" 1 0
598 (and (and (eq_attr "type" "fdiv") (eq_attr "type" "fsqrt,frsqrt"))
599 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r4300")))
601 (define_function_unit "imuldiv" 1 0
602 (and (and (eq_attr "type" "fdiv") (eq_attr "type" "fsqrt,frsqrt"))
603 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r4300")))
606 ;; Include scheduling descriptions.
615 ;; ....................
619 ;; ....................
623 [(trap_if (const_int 1) (const_int 0))]
626 if (ISA_HAS_COND_TRAP)
628 /* The IRIX 6 O32 assembler requires the first break operand. */
629 else if (TARGET_MIPS16 || !TARGET_GAS)
635 (define_expand "conditional_trap"
636 [(trap_if (match_operator 0 "cmp_op"
637 [(match_dup 2) (match_dup 3)])
638 (match_operand 1 "const_int_operand" ""))]
641 if (operands[1] == const0_rtx)
643 mips_gen_conditional_trap (operands);
651 [(trap_if (match_operator 0 "trap_cmp_op"
652 [(match_operand:SI 1 "reg_or_0_operand" "dJ")
653 (match_operand:SI 2 "arith_operand" "dI")])
659 [(trap_if (match_operator 0 "trap_cmp_op"
660 [(match_operand:DI 1 "reg_or_0_operand" "dJ")
661 (match_operand:DI 2 "arith_operand" "dI")])
663 "TARGET_64BIT && ISA_HAS_COND_TRAP"
667 ;; ....................
671 ;; ....................
674 (define_insn "adddf3"
675 [(set (match_operand:DF 0 "register_operand" "=f")
676 (plus:DF (match_operand:DF 1 "register_operand" "f")
677 (match_operand:DF 2 "register_operand" "f")))]
678 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
680 [(set_attr "type" "fadd")
681 (set_attr "mode" "DF")])
683 (define_insn "addsf3"
684 [(set (match_operand:SF 0 "register_operand" "=f")
685 (plus:SF (match_operand:SF 1 "register_operand" "f")
686 (match_operand:SF 2 "register_operand" "f")))]
689 [(set_attr "type" "fadd")
690 (set_attr "mode" "SF")])
692 (define_expand "addsi3"
693 [(set (match_operand:SI 0 "register_operand" "")
694 (plus:SI (match_operand:SI 1 "reg_or_0_operand" "")
695 (match_operand:SI 2 "arith_operand" "")))]
698 /* If a large stack adjustment was forced into a register, we may be
699 asked to generate rtx such as:
701 (set (reg:SI sp) (plus:SI (reg:SI sp) (reg:SI pseudo)))
703 but no such instruction is available in mips16. Handle it by
704 using a temporary. */
706 && REGNO (operands[0]) == STACK_POINTER_REGNUM
707 && ((GET_CODE (operands[1]) == REG
708 && REGNO (operands[1]) != STACK_POINTER_REGNUM)
709 || GET_CODE (operands[2]) != CONST_INT))
711 rtx tmp = gen_reg_rtx (SImode);
713 emit_move_insn (tmp, operands[1]);
714 emit_insn (gen_addsi3 (tmp, tmp, operands[2]));
715 emit_move_insn (operands[0], tmp);
720 (define_insn "addsi3_internal"
721 [(set (match_operand:SI 0 "register_operand" "=d,d")
722 (plus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ,dJ")
723 (match_operand:SI 2 "arith_operand" "d,Q")))]
728 [(set_attr "type" "arith")
729 (set_attr "mode" "SI")])
731 ;; For the mips16, we need to recognize stack pointer additions
732 ;; explicitly, since we don't have a constraint for $sp. These insns
733 ;; will be generated by the save_restore_insns functions.
738 (match_operand:SI 0 "small_int" "I")))]
741 [(set_attr "type" "arith")
742 (set_attr "mode" "SI")
743 (set (attr "length") (if_then_else (match_operand:VOID 0 "m16_simm8_8" "")
748 [(set (match_operand:SI 0 "register_operand" "=d")
750 (match_operand:SI 1 "small_int" "I")))]
753 [(set_attr "type" "arith")
754 (set_attr "mode" "SI")
755 (set (attr "length") (if_then_else (match_operand:VOID 1 "m16_uimm8_4" "")
760 [(set (match_operand:SI 0 "register_operand" "=d,d,d")
761 (plus:SI (match_operand:SI 1 "register_operand" "0,d,d")
762 (match_operand:SI 2 "arith_operand" "Q,O,d")))]
764 && (GET_CODE (operands[1]) != REG
765 || REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER
766 || M16_REG_P (REGNO (operands[1]))
767 || REGNO (operands[1]) == ARG_POINTER_REGNUM
768 || REGNO (operands[1]) == FRAME_POINTER_REGNUM
769 || REGNO (operands[1]) == STACK_POINTER_REGNUM)
770 && (GET_CODE (operands[2]) != REG
771 || REGNO (operands[2]) >= FIRST_PSEUDO_REGISTER
772 || M16_REG_P (REGNO (operands[2]))
773 || REGNO (operands[2]) == ARG_POINTER_REGNUM
774 || REGNO (operands[2]) == FRAME_POINTER_REGNUM
775 || REGNO (operands[2]) == STACK_POINTER_REGNUM)"
777 if (REGNO (operands[0]) == REGNO (operands[1]))
778 return "addu\t%0,%2";
780 return "addu\t%0,%1,%2";
782 [(set_attr "type" "arith")
783 (set_attr "mode" "SI")
784 (set_attr_alternative "length"
785 [(if_then_else (match_operand:VOID 2 "m16_simm8_1" "")
788 (if_then_else (match_operand:VOID 2 "m16_simm4_1" "")
794 ;; On the mips16, we can sometimes split an add of a constant which is
795 ;; a 4 byte instruction into two adds which are both 2 byte
796 ;; instructions. There are two cases: one where we are adding a
797 ;; constant plus a register to another register, and one where we are
798 ;; simply adding a constant to a register.
801 [(set (match_operand:SI 0 "register_operand" "")
802 (plus:SI (match_dup 0)
803 (match_operand:SI 1 "const_int_operand" "")))]
804 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
805 && GET_CODE (operands[0]) == REG
806 && M16_REG_P (REGNO (operands[0]))
807 && GET_CODE (operands[1]) == CONST_INT
808 && ((INTVAL (operands[1]) > 0x7f
809 && INTVAL (operands[1]) <= 0x7f + 0x7f)
810 || (INTVAL (operands[1]) < - 0x80
811 && INTVAL (operands[1]) >= - 0x80 - 0x80))"
812 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
813 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]
815 HOST_WIDE_INT val = INTVAL (operands[1]);
819 operands[1] = GEN_INT (0x7f);
820 operands[2] = GEN_INT (val - 0x7f);
824 operands[1] = GEN_INT (- 0x80);
825 operands[2] = GEN_INT (val + 0x80);
830 [(set (match_operand:SI 0 "register_operand" "")
831 (plus:SI (match_operand:SI 1 "register_operand" "")
832 (match_operand:SI 2 "const_int_operand" "")))]
833 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
834 && GET_CODE (operands[0]) == REG
835 && M16_REG_P (REGNO (operands[0]))
836 && GET_CODE (operands[1]) == REG
837 && M16_REG_P (REGNO (operands[1]))
838 && REGNO (operands[0]) != REGNO (operands[1])
839 && GET_CODE (operands[2]) == CONST_INT
840 && ((INTVAL (operands[2]) > 0x7
841 && INTVAL (operands[2]) <= 0x7 + 0x7f)
842 || (INTVAL (operands[2]) < - 0x8
843 && INTVAL (operands[2]) >= - 0x8 - 0x80))"
844 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))
845 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 3)))]
847 HOST_WIDE_INT val = INTVAL (operands[2]);
851 operands[2] = GEN_INT (0x7);
852 operands[3] = GEN_INT (val - 0x7);
856 operands[2] = GEN_INT (- 0x8);
857 operands[3] = GEN_INT (val + 0x8);
861 (define_expand "adddi3"
862 [(parallel [(set (match_operand:DI 0 "register_operand" "")
863 (plus:DI (match_operand:DI 1 "register_operand" "")
864 (match_operand:DI 2 "arith_operand" "")))
865 (clobber (match_dup 3))])]
866 "TARGET_64BIT || (!TARGET_DEBUG_G_MODE && !TARGET_MIPS16)"
868 /* If a large stack adjustment was forced into a register, we may be
869 asked to generate rtx such as:
871 (set (reg:DI sp) (plus:DI (reg:DI sp) (reg:DI pseudo)))
873 but no such instruction is available in mips16. Handle it by
874 using a temporary. */
876 && REGNO (operands[0]) == STACK_POINTER_REGNUM
877 && ((GET_CODE (operands[1]) == REG
878 && REGNO (operands[1]) != STACK_POINTER_REGNUM)
879 || GET_CODE (operands[2]) != CONST_INT))
881 rtx tmp = gen_reg_rtx (DImode);
883 emit_move_insn (tmp, operands[1]);
884 emit_insn (gen_adddi3 (tmp, tmp, operands[2]));
885 emit_move_insn (operands[0], tmp);
891 emit_insn (gen_adddi3_internal_3 (operands[0], operands[1],
896 operands[3] = gen_reg_rtx (SImode);
899 (define_insn "adddi3_internal_1"
900 [(set (match_operand:DI 0 "register_operand" "=d,&d")
901 (plus:DI (match_operand:DI 1 "register_operand" "0,d")
902 (match_operand:DI 2 "register_operand" "d,d")))
903 (clobber (match_operand:SI 3 "register_operand" "=d,d"))]
904 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16"
906 return (REGNO (operands[0]) == REGNO (operands[1])
907 && REGNO (operands[0]) == REGNO (operands[2]))
908 ? "srl\t%3,%L0,31\;sll\t%M0,%M0,1\;sll\t%L0,%L1,1\;addu\t%M0,%M0,%3"
909 : "addu\t%L0,%L1,%L2\;sltu\t%3,%L0,%L2\;addu\t%M0,%M1,%M2\;addu\t%M0,%M0,%3";
911 [(set_attr "type" "darith")
912 (set_attr "mode" "DI")
913 (set_attr "length" "16")])
916 [(set (match_operand:DI 0 "register_operand" "")
917 (plus:DI (match_operand:DI 1 "register_operand" "")
918 (match_operand:DI 2 "register_operand" "")))
919 (clobber (match_operand:SI 3 "register_operand" ""))]
920 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
921 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
922 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
923 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
924 && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))
925 && (REGNO (operands[0]) != REGNO (operands[1])
926 || REGNO (operands[0]) != REGNO (operands[2]))"
928 [(set (subreg:SI (match_dup 0) 0)
929 (plus:SI (subreg:SI (match_dup 1) 0)
930 (subreg:SI (match_dup 2) 0)))
933 (ltu:SI (subreg:SI (match_dup 0) 0)
934 (subreg:SI (match_dup 2) 0)))
936 (set (subreg:SI (match_dup 0) 4)
937 (plus:SI (subreg:SI (match_dup 1) 4)
938 (subreg:SI (match_dup 2) 4)))
940 (set (subreg:SI (match_dup 0) 4)
941 (plus:SI (subreg:SI (match_dup 0) 4)
946 [(set (match_operand:DI 0 "register_operand" "")
947 (plus:DI (match_operand:DI 1 "register_operand" "")
948 (match_operand:DI 2 "register_operand" "")))
949 (clobber (match_operand:SI 3 "register_operand" ""))]
950 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
951 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
952 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
953 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
954 && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))
955 && (REGNO (operands[0]) != REGNO (operands[1])
956 || REGNO (operands[0]) != REGNO (operands[2]))"
958 [(set (subreg:SI (match_dup 0) 4)
959 (plus:SI (subreg:SI (match_dup 1) 4)
960 (subreg:SI (match_dup 2) 4)))
963 (ltu:SI (subreg:SI (match_dup 0) 4)
964 (subreg:SI (match_dup 2) 4)))
966 (set (subreg:SI (match_dup 0) 0)
967 (plus:SI (subreg:SI (match_dup 1) 0)
968 (subreg:SI (match_dup 2) 0)))
970 (set (subreg:SI (match_dup 0) 0)
971 (plus:SI (subreg:SI (match_dup 0) 0)
975 (define_insn "adddi3_internal_2"
976 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
977 (plus:DI (match_operand:DI 1 "register_operand" "%d,d,d")
978 (match_operand:DI 2 "small_int" "P,J,N")))
979 (clobber (match_operand:SI 3 "register_operand" "=d,d,d"))]
980 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16"
982 addu\t%L0,%L1,%2\;sltu\t%3,%L0,%2\;addu\t%M0,%M1,%3
983 move\t%L0,%L1\;move\t%M0,%M1
984 subu\t%L0,%L1,%n2\;sltu\t%3,%L0,%2\;subu\t%M0,%M1,1\;addu\t%M0,%M0,%3"
985 [(set_attr "type" "darith")
986 (set_attr "mode" "DI")
987 (set_attr "length" "12,8,16")])
990 [(set (match_operand:DI 0 "register_operand" "")
991 (plus:DI (match_operand:DI 1 "register_operand" "")
992 (match_operand:DI 2 "small_int" "")))
993 (clobber (match_operand:SI 3 "register_operand" ""))]
994 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
995 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
996 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
997 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
998 && INTVAL (operands[2]) > 0"
1000 [(set (subreg:SI (match_dup 0) 0)
1001 (plus:SI (subreg:SI (match_dup 1) 0)
1005 (ltu:SI (subreg:SI (match_dup 0) 0)
1008 (set (subreg:SI (match_dup 0) 4)
1009 (plus:SI (subreg:SI (match_dup 1) 4)
1014 [(set (match_operand:DI 0 "register_operand" "")
1015 (plus:DI (match_operand:DI 1 "register_operand" "")
1016 (match_operand:DI 2 "small_int" "")))
1017 (clobber (match_operand:SI 3 "register_operand" ""))]
1018 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
1019 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
1020 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1021 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1022 && INTVAL (operands[2]) > 0"
1024 [(set (subreg:SI (match_dup 0) 4)
1025 (plus:SI (subreg:SI (match_dup 1) 4)
1029 (ltu:SI (subreg:SI (match_dup 0) 4)
1032 (set (subreg:SI (match_dup 0) 0)
1033 (plus:SI (subreg:SI (match_dup 1) 0)
1037 (define_insn "adddi3_internal_3"
1038 [(set (match_operand:DI 0 "register_operand" "=d,d")
1039 (plus:DI (match_operand:DI 1 "reg_or_0_operand" "dJ,dJ")
1040 (match_operand:DI 2 "arith_operand" "d,Q")))]
1041 "TARGET_64BIT && !TARGET_MIPS16"
1045 [(set_attr "type" "darith")
1046 (set_attr "mode" "DI")])
1048 ;; For the mips16, we need to recognize stack pointer additions
1049 ;; explicitly, since we don't have a constraint for $sp. These insns
1050 ;; will be generated by the save_restore_insns functions.
1054 (plus:DI (reg:DI 29)
1055 (match_operand:DI 0 "small_int" "I")))]
1056 "TARGET_MIPS16 && TARGET_64BIT"
1058 [(set_attr "type" "arith")
1059 (set_attr "mode" "DI")
1060 (set (attr "length") (if_then_else (match_operand:VOID 0 "m16_simm8_8" "")
1065 [(set (match_operand:DI 0 "register_operand" "=d")
1066 (plus:DI (reg:DI 29)
1067 (match_operand:DI 1 "small_int" "I")))]
1068 "TARGET_MIPS16 && TARGET_64BIT"
1070 [(set_attr "type" "arith")
1071 (set_attr "mode" "DI")
1072 (set (attr "length") (if_then_else (match_operand:VOID 0 "m16_uimm5_4" "")
1077 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1078 (plus:DI (match_operand:DI 1 "register_operand" "0,d,d")
1079 (match_operand:DI 2 "arith_operand" "Q,O,d")))]
1080 "TARGET_MIPS16 && TARGET_64BIT
1081 && (GET_CODE (operands[1]) != REG
1082 || REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER
1083 || M16_REG_P (REGNO (operands[1]))
1084 || REGNO (operands[1]) == ARG_POINTER_REGNUM
1085 || REGNO (operands[1]) == FRAME_POINTER_REGNUM
1086 || REGNO (operands[1]) == STACK_POINTER_REGNUM)
1087 && (GET_CODE (operands[2]) != REG
1088 || REGNO (operands[2]) >= FIRST_PSEUDO_REGISTER
1089 || M16_REG_P (REGNO (operands[2]))
1090 || REGNO (operands[2]) == ARG_POINTER_REGNUM
1091 || REGNO (operands[2]) == FRAME_POINTER_REGNUM
1092 || REGNO (operands[2]) == STACK_POINTER_REGNUM)"
1094 if (REGNO (operands[0]) == REGNO (operands[1]))
1095 return "daddu\t%0,%2";
1097 return "daddu\t%0,%1,%2";
1099 [(set_attr "type" "arith")
1100 (set_attr "mode" "DI")
1101 (set_attr_alternative "length"
1102 [(if_then_else (match_operand:VOID 2 "m16_simm5_1" "")
1105 (if_then_else (match_operand:VOID 2 "m16_simm4_1" "")
1111 ;; On the mips16, we can sometimes split an add of a constant which is
1112 ;; a 4 byte instruction into two adds which are both 2 byte
1113 ;; instructions. There are two cases: one where we are adding a
1114 ;; constant plus a register to another register, and one where we are
1115 ;; simply adding a constant to a register.
1118 [(set (match_operand:DI 0 "register_operand" "")
1119 (plus:DI (match_dup 0)
1120 (match_operand:DI 1 "const_int_operand" "")))]
1121 "TARGET_MIPS16 && TARGET_64BIT && reload_completed && !TARGET_DEBUG_D_MODE
1122 && GET_CODE (operands[0]) == REG
1123 && M16_REG_P (REGNO (operands[0]))
1124 && GET_CODE (operands[1]) == CONST_INT
1125 && ((INTVAL (operands[1]) > 0xf
1126 && INTVAL (operands[1]) <= 0xf + 0xf)
1127 || (INTVAL (operands[1]) < - 0x10
1128 && INTVAL (operands[1]) >= - 0x10 - 0x10))"
1129 [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1)))
1130 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))]
1132 HOST_WIDE_INT val = INTVAL (operands[1]);
1136 operands[1] = GEN_INT (0xf);
1137 operands[2] = GEN_INT (val - 0xf);
1141 operands[1] = GEN_INT (- 0x10);
1142 operands[2] = GEN_INT (val + 0x10);
1147 [(set (match_operand:DI 0 "register_operand" "")
1148 (plus:DI (match_operand:DI 1 "register_operand" "")
1149 (match_operand:DI 2 "const_int_operand" "")))]
1150 "TARGET_MIPS16 && TARGET_64BIT && reload_completed && !TARGET_DEBUG_D_MODE
1151 && GET_CODE (operands[0]) == REG
1152 && M16_REG_P (REGNO (operands[0]))
1153 && GET_CODE (operands[1]) == REG
1154 && M16_REG_P (REGNO (operands[1]))
1155 && REGNO (operands[0]) != REGNO (operands[1])
1156 && GET_CODE (operands[2]) == CONST_INT
1157 && ((INTVAL (operands[2]) > 0x7
1158 && INTVAL (operands[2]) <= 0x7 + 0xf)
1159 || (INTVAL (operands[2]) < - 0x8
1160 && INTVAL (operands[2]) >= - 0x8 - 0x10))"
1161 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))
1162 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
1164 HOST_WIDE_INT val = INTVAL (operands[2]);
1168 operands[2] = GEN_INT (0x7);
1169 operands[3] = GEN_INT (val - 0x7);
1173 operands[2] = GEN_INT (- 0x8);
1174 operands[3] = GEN_INT (val + 0x8);
1178 (define_insn "addsi3_internal_2"
1179 [(set (match_operand:DI 0 "register_operand" "=d,d")
1180 (sign_extend:DI (plus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ,dJ")
1181 (match_operand:SI 2 "arith_operand" "d,Q"))))]
1182 "TARGET_64BIT && !TARGET_MIPS16"
1186 [(set_attr "type" "arith")
1187 (set_attr "mode" "SI")])
1190 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1191 (sign_extend:DI (plus:SI (match_operand:SI 1 "register_operand" "0,d,d")
1192 (match_operand:SI 2 "arith_operand" "Q,O,d"))))]
1193 "TARGET_MIPS16 && TARGET_64BIT"
1195 if (REGNO (operands[0]) == REGNO (operands[1]))
1196 return "addu\t%0,%2";
1198 return "addu\t%0,%1,%2";
1200 [(set_attr "type" "arith")
1201 (set_attr "mode" "SI")
1202 (set_attr_alternative "length"
1203 [(if_then_else (match_operand:VOID 2 "m16_simm8_1" "")
1206 (if_then_else (match_operand:VOID 2 "m16_simm4_1" "")
1212 ;; ....................
1216 ;; ....................
1219 (define_insn "subdf3"
1220 [(set (match_operand:DF 0 "register_operand" "=f")
1221 (minus:DF (match_operand:DF 1 "register_operand" "f")
1222 (match_operand:DF 2 "register_operand" "f")))]
1223 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
1225 [(set_attr "type" "fadd")
1226 (set_attr "mode" "DF")])
1228 (define_insn "subsf3"
1229 [(set (match_operand:SF 0 "register_operand" "=f")
1230 (minus:SF (match_operand:SF 1 "register_operand" "f")
1231 (match_operand:SF 2 "register_operand" "f")))]
1234 [(set_attr "type" "fadd")
1235 (set_attr "mode" "SF")])
1237 (define_expand "subsi3"
1238 [(set (match_operand:SI 0 "register_operand" "")
1239 (minus:SI (match_operand:SI 1 "register_operand" "")
1240 (match_operand:SI 2 "register_operand" "")))]
1244 (define_insn "subsi3_internal"
1245 [(set (match_operand:SI 0 "register_operand" "=d")
1246 (minus:SI (match_operand:SI 1 "register_operand" "d")
1247 (match_operand:SI 2 "register_operand" "d")))]
1250 [(set_attr "type" "arith")
1251 (set_attr "mode" "SI")])
1253 (define_expand "subdi3"
1254 [(parallel [(set (match_operand:DI 0 "register_operand" "=d")
1255 (minus:DI (match_operand:DI 1 "register_operand" "d")
1256 (match_operand:DI 2 "register_operand" "d")))
1257 (clobber (match_dup 3))])]
1258 "TARGET_64BIT || (!TARGET_DEBUG_G_MODE && !TARGET_MIPS16)"
1262 emit_insn (gen_subdi3_internal_3 (operands[0], operands[1],
1267 operands[3] = gen_reg_rtx (SImode);
1270 (define_insn "subdi3_internal"
1271 [(set (match_operand:DI 0 "register_operand" "=d")
1272 (minus:DI (match_operand:DI 1 "register_operand" "d")
1273 (match_operand:DI 2 "register_operand" "d")))
1274 (clobber (match_operand:SI 3 "register_operand" "=d"))]
1275 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16"
1276 "sltu\t%3,%L1,%L2\;subu\t%L0,%L1,%L2\;subu\t%M0,%M1,%M2\;subu\t%M0,%M0,%3"
1277 [(set_attr "type" "darith")
1278 (set_attr "mode" "DI")
1279 (set_attr "length" "16")])
1282 [(set (match_operand:DI 0 "register_operand" "")
1283 (minus:DI (match_operand:DI 1 "register_operand" "")
1284 (match_operand:DI 2 "register_operand" "")))
1285 (clobber (match_operand:SI 3 "register_operand" ""))]
1286 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
1287 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
1288 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1289 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1290 && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))"
1293 (ltu:SI (subreg:SI (match_dup 1) 0)
1294 (subreg:SI (match_dup 2) 0)))
1296 (set (subreg:SI (match_dup 0) 0)
1297 (minus:SI (subreg:SI (match_dup 1) 0)
1298 (subreg:SI (match_dup 2) 0)))
1300 (set (subreg:SI (match_dup 0) 4)
1301 (minus:SI (subreg:SI (match_dup 1) 4)
1302 (subreg:SI (match_dup 2) 4)))
1304 (set (subreg:SI (match_dup 0) 4)
1305 (minus:SI (subreg:SI (match_dup 0) 4)
1310 [(set (match_operand:DI 0 "register_operand" "")
1311 (minus:DI (match_operand:DI 1 "register_operand" "")
1312 (match_operand:DI 2 "register_operand" "")))
1313 (clobber (match_operand:SI 3 "register_operand" ""))]
1314 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
1315 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
1316 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1317 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1318 && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))"
1321 (ltu:SI (subreg:SI (match_dup 1) 4)
1322 (subreg:SI (match_dup 2) 4)))
1324 (set (subreg:SI (match_dup 0) 4)
1325 (minus:SI (subreg:SI (match_dup 1) 4)
1326 (subreg:SI (match_dup 2) 4)))
1328 (set (subreg:SI (match_dup 0) 0)
1329 (minus:SI (subreg:SI (match_dup 1) 0)
1330 (subreg:SI (match_dup 2) 0)))
1332 (set (subreg:SI (match_dup 0) 0)
1333 (minus:SI (subreg:SI (match_dup 0) 0)
1337 (define_insn "subdi3_internal_3"
1338 [(set (match_operand:DI 0 "register_operand" "=d")
1339 (minus:DI (match_operand:DI 1 "register_operand" "d")
1340 (match_operand:DI 2 "register_operand" "d")))]
1343 [(set_attr "type" "darith")
1344 (set_attr "mode" "DI")])
1346 (define_insn "subsi3_internal_2"
1347 [(set (match_operand:DI 0 "register_operand" "=d")
1349 (minus:SI (match_operand:SI 1 "register_operand" "d")
1350 (match_operand:SI 2 "register_operand" "d"))))]
1353 [(set_attr "type" "arith")
1354 (set_attr "mode" "DI")])
1357 ;; ....................
1361 ;; ....................
1364 (define_expand "muldf3"
1365 [(set (match_operand:DF 0 "register_operand" "=f")
1366 (mult:DF (match_operand:DF 1 "register_operand" "f")
1367 (match_operand:DF 2 "register_operand" "f")))]
1368 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
1371 (define_insn "muldf3_internal"
1372 [(set (match_operand:DF 0 "register_operand" "=f")
1373 (mult:DF (match_operand:DF 1 "register_operand" "f")
1374 (match_operand:DF 2 "register_operand" "f")))]
1375 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_4300_MUL_FIX"
1377 [(set_attr "type" "fmul")
1378 (set_attr "mode" "DF")])
1380 ;; Early VR4300 silicon has a CPU bug where multiplies with certain
1381 ;; operands may corrupt immediately following multiplies. This is a
1382 ;; simple fix to insert NOPs.
1384 (define_insn "muldf3_r4300"
1385 [(set (match_operand:DF 0 "register_operand" "=f")
1386 (mult:DF (match_operand:DF 1 "register_operand" "f")
1387 (match_operand:DF 2 "register_operand" "f")))]
1388 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_4300_MUL_FIX"
1389 "mul.d\t%0,%1,%2\;nop"
1390 [(set_attr "type" "fmul")
1391 (set_attr "mode" "DF")
1392 (set_attr "length" "8")])
1394 (define_expand "mulsf3"
1395 [(set (match_operand:SF 0 "register_operand" "=f")
1396 (mult:SF (match_operand:SF 1 "register_operand" "f")
1397 (match_operand:SF 2 "register_operand" "f")))]
1401 (define_insn "mulsf3_internal"
1402 [(set (match_operand:SF 0 "register_operand" "=f")
1403 (mult:SF (match_operand:SF 1 "register_operand" "f")
1404 (match_operand:SF 2 "register_operand" "f")))]
1405 "TARGET_HARD_FLOAT && !TARGET_4300_MUL_FIX"
1407 [(set_attr "type" "fmul")
1408 (set_attr "mode" "SF")])
1410 ;; See muldf3_r4300.
1412 (define_insn "mulsf3_r4300"
1413 [(set (match_operand:SF 0 "register_operand" "=f")
1414 (mult:SF (match_operand:SF 1 "register_operand" "f")
1415 (match_operand:SF 2 "register_operand" "f")))]
1416 "TARGET_HARD_FLOAT && TARGET_4300_MUL_FIX"
1417 "mul.s\t%0,%1,%2\;nop"
1418 [(set_attr "type" "fmul")
1419 (set_attr "mode" "SF")
1420 (set_attr "length" "8")])
1423 ;; The original R4000 has a cpu bug. If a double-word or a variable
1424 ;; shift executes while an integer multiplication is in progress, the
1425 ;; shift may give an incorrect result. Avoid this by keeping the mflo
1426 ;; with the mult on the R4000.
1428 ;; From "MIPS R4000PC/SC Errata, Processor Revision 2.2 and 3.0"
1429 ;; (also valid for MIPS R4000MC processors):
1431 ;; "16. R4000PC, R4000SC: Please refer to errata 28 for an update to
1432 ;; this errata description.
1433 ;; The following code sequence causes the R4000 to incorrectly
1434 ;; execute the Double Shift Right Arithmetic 32 (dsra32)
1435 ;; instruction. If the dsra32 instruction is executed during an
1436 ;; integer multiply, the dsra32 will only shift by the amount in
1437 ;; specified in the instruction rather than the amount plus 32
1439 ;; instruction 1: mult rs,rt integer multiply
1440 ;; instruction 2-12: dsra32 rd,rt,rs doubleword shift
1441 ;; right arithmetic + 32
1442 ;; Workaround: A dsra32 instruction placed after an integer
1443 ;; multiply should not be one of the 11 instructions after the
1444 ;; multiply instruction."
1448 ;; "28. R4000PC, R4000SC: The text from errata 16 should be replaced by
1449 ;; the following description.
1450 ;; All extended shifts (shift by n+32) and variable shifts (32 and
1451 ;; 64-bit versions) may produce incorrect results under the
1452 ;; following conditions:
1453 ;; 1) An integer multiply is currently executing
1454 ;; 2) These types of shift instructions are executed immediately
1455 ;; following an integer divide instruction.
1457 ;; 1) Make sure no integer multiply is running wihen these
1458 ;; instruction are executed. If this cannot be predicted at
1459 ;; compile time, then insert a "mfhi" to R0 instruction
1460 ;; immediately after the integer multiply instruction. This
1461 ;; will cause the integer multiply to complete before the shift
1463 ;; 2) Separate integer divide and these two classes of shift
1464 ;; instructions by another instruction or a noop."
1466 ;; These processors have PRId values of 0x00004220 and 0x00004300,
1469 (define_expand "mulsi3"
1470 [(set (match_operand:SI 0 "register_operand" "")
1471 (mult:SI (match_operand:SI 1 "register_operand" "")
1472 (match_operand:SI 2 "register_operand" "")))]
1475 if (GENERATE_MULT3_SI || TARGET_MAD)
1476 emit_insn (gen_mulsi3_mult3 (operands[0], operands[1], operands[2]));
1477 else if (!TARGET_FIX_R4000)
1478 emit_insn (gen_mulsi3_internal (operands[0], operands[1], operands[2]));
1480 emit_insn (gen_mulsi3_r4000 (operands[0], operands[1], operands[2]));
1484 (define_insn "mulsi3_mult3"
1485 [(set (match_operand:SI 0 "register_operand" "=d,l")
1486 (mult:SI (match_operand:SI 1 "register_operand" "d,d")
1487 (match_operand:SI 2 "register_operand" "d,d")))
1488 (clobber (match_scratch:SI 3 "=h,h"))
1489 (clobber (match_scratch:SI 4 "=l,X"))]
1493 if (which_alternative == 1)
1494 return "mult\t%1,%2";
1503 return "mul\t%0,%1,%2";
1504 return "mult\t%0,%1,%2";
1506 [(set_attr "type" "imul")
1507 (set_attr "mode" "SI")])
1509 ;; If a register gets allocated to LO, and we spill to memory, the reload
1510 ;; will include a move from LO to a GPR. Merge it into the multiplication
1511 ;; if it can set the GPR directly.
1514 ;; Operand 1: GPR (1st multiplication operand)
1515 ;; Operand 2: GPR (2nd multiplication operand)
1517 ;; Operand 4: GPR (destination)
1520 [(set (match_operand:SI 0 "register_operand" "")
1521 (mult:SI (match_operand:SI 1 "register_operand" "")
1522 (match_operand:SI 2 "register_operand" "")))
1523 (clobber (match_operand:SI 3 "register_operand" ""))
1524 (clobber (scratch:SI))])
1525 (set (match_operand:SI 4 "register_operand" "")
1528 && true_regnum (operands[0]) == LO_REGNUM
1529 && GP_REG_P (true_regnum (operands[4]))
1530 && peep2_reg_dead_p (2, operands[0])"
1533 (mult:SI (match_dup 1)
1535 (clobber (match_dup 3))
1536 (clobber (match_dup 0))])])
1538 (define_insn "mulsi3_internal"
1539 [(set (match_operand:SI 0 "register_operand" "=l")
1540 (mult:SI (match_operand:SI 1 "register_operand" "d")
1541 (match_operand:SI 2 "register_operand" "d")))
1542 (clobber (match_scratch:SI 3 "=h"))]
1545 [(set_attr "type" "imul")
1546 (set_attr "mode" "SI")])
1548 (define_insn "mulsi3_r4000"
1549 [(set (match_operand:SI 0 "register_operand" "=d")
1550 (mult:SI (match_operand:SI 1 "register_operand" "d")
1551 (match_operand:SI 2 "register_operand" "d")))
1552 (clobber (match_scratch:SI 3 "=h"))
1553 (clobber (match_scratch:SI 4 "=l"))]
1555 "mult\t%1,%2\;mflo\t%0"
1556 [(set_attr "type" "imul")
1557 (set_attr "mode" "SI")
1558 (set_attr "length" "8")])
1560 ;; Multiply-accumulate patterns
1562 ;; For processors that can copy the output to a general register:
1564 ;; The all-d alternative is needed because the combiner will find this
1565 ;; pattern and then register alloc/reload will move registers around to
1566 ;; make them fit, and we don't want to trigger unnecessary loads to LO.
1568 ;; The last alternative should be made slightly less desirable, but adding
1569 ;; "?" to the constraint is too strong, and causes values to be loaded into
1570 ;; LO even when that's more costly. For now, using "*d" mostly does the
1572 (define_insn "*mul_acc_si"
1573 [(set (match_operand:SI 0 "register_operand" "=l,*d,*d")
1574 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d,d")
1575 (match_operand:SI 2 "register_operand" "d,d,d"))
1576 (match_operand:SI 3 "register_operand" "0,l,*d")))
1577 (clobber (match_scratch:SI 4 "=h,h,h"))
1578 (clobber (match_scratch:SI 5 "=X,3,l"))
1579 (clobber (match_scratch:SI 6 "=X,X,&d"))]
1581 || ISA_HAS_MADD_MSUB)
1584 static const char *const madd[] = { "madd\t%1,%2", "madd\t%0,%1,%2" };
1585 if (which_alternative == 2)
1587 if (ISA_HAS_MADD_MSUB && which_alternative != 0)
1589 return madd[which_alternative];
1591 [(set_attr "type" "imadd,imadd,multi")
1592 (set_attr "mode" "SI")
1593 (set_attr "length" "4,4,8")])
1595 ;; Split the above insn if we failed to get LO allocated.
1597 [(set (match_operand:SI 0 "register_operand" "")
1598 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
1599 (match_operand:SI 2 "register_operand" ""))
1600 (match_operand:SI 3 "register_operand" "")))
1601 (clobber (match_scratch:SI 4 ""))
1602 (clobber (match_scratch:SI 5 ""))
1603 (clobber (match_scratch:SI 6 ""))]
1604 "reload_completed && !TARGET_DEBUG_D_MODE
1605 && GP_REG_P (true_regnum (operands[0]))
1606 && GP_REG_P (true_regnum (operands[3]))"
1607 [(parallel [(set (match_dup 6)
1608 (mult:SI (match_dup 1) (match_dup 2)))
1609 (clobber (match_dup 4))
1610 (clobber (match_dup 5))])
1611 (set (match_dup 0) (plus:SI (match_dup 6) (match_dup 3)))]
1614 ;; Splitter to copy result of MADD to a general register
1616 [(set (match_operand:SI 0 "register_operand" "")
1617 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
1618 (match_operand:SI 2 "register_operand" ""))
1619 (match_operand:SI 3 "register_operand" "")))
1620 (clobber (match_scratch:SI 4 ""))
1621 (clobber (match_scratch:SI 5 ""))
1622 (clobber (match_scratch:SI 6 ""))]
1623 "reload_completed && !TARGET_DEBUG_D_MODE
1624 && GP_REG_P (true_regnum (operands[0]))
1625 && true_regnum (operands[3]) == LO_REGNUM"
1626 [(parallel [(set (match_dup 3)
1627 (plus:SI (mult:SI (match_dup 1) (match_dup 2))
1629 (clobber (match_dup 4))
1630 (clobber (match_dup 5))
1631 (clobber (match_dup 6))])
1632 (set (match_dup 0) (match_dup 3))]
1635 (define_insn "*macc"
1636 [(set (match_operand:SI 0 "register_operand" "=l,d")
1637 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d")
1638 (match_operand:SI 2 "register_operand" "d,d"))
1639 (match_operand:SI 3 "register_operand" "0,l")))
1640 (clobber (match_scratch:SI 4 "=h,h"))
1641 (clobber (match_scratch:SI 5 "=X,3"))]
1644 if (which_alternative == 1)
1645 return "macc\t%0,%1,%2";
1646 else if (TARGET_MIPS5500)
1647 return "madd\t%1,%2";
1649 return "macc\t%.,%1,%2";
1651 [(set_attr "type" "imadd")
1652 (set_attr "mode" "SI")])
1654 ;; Pattern generated by define_peephole2 below
1655 (define_insn "*macc2"
1656 [(set (match_operand:SI 0 "register_operand" "=l")
1657 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d")
1658 (match_operand:SI 2 "register_operand" "d"))
1660 (set (match_operand:SI 3 "register_operand" "=d")
1661 (plus:SI (mult:SI (match_dup 1)
1664 (clobber (match_scratch:SI 4 "=h"))]
1665 "ISA_HAS_MACC && reload_completed"
1667 [(set_attr "type" "imadd")
1668 (set_attr "mode" "SI")])
1670 ;; Convert macc $0,<r1>,<r2> & mflo <r3> into macc <r3>,<r1>,<r2>
1673 ;; Operand 1: GPR (1st multiplication operand)
1674 ;; Operand 2: GPR (2nd multiplication operand)
1676 ;; Operand 4: GPR (destination)
1679 [(set (match_operand:SI 0 "register_operand" "")
1680 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
1681 (match_operand:SI 2 "register_operand" ""))
1683 (clobber (match_operand:SI 3 "register_operand" ""))
1684 (clobber (scratch:SI))])
1685 (set (match_operand:SI 4 "register_operand" "")
1688 && true_regnum (operands[0]) == LO_REGNUM
1689 && GP_REG_P (true_regnum (operands[4]))"
1690 [(parallel [(set (match_dup 0)
1691 (plus:SI (mult:SI (match_dup 1)
1695 (plus:SI (mult:SI (match_dup 1)
1698 (clobber (match_dup 3))])]
1701 ;; When we have a three-address multiplication instruction, it should
1702 ;; be faster to do a separate multiply and add, rather than moving
1703 ;; something into LO in order to use a macc instruction.
1705 ;; This peephole needs a scratch register to cater for the case when one
1706 ;; of the multiplication operands is the same as the destination.
1708 ;; Operand 0: GPR (scratch)
1710 ;; Operand 2: GPR (addend)
1711 ;; Operand 3: GPR (destination)
1712 ;; Operand 4: GPR (1st multiplication operand)
1713 ;; Operand 5: GPR (2nd multiplication operand)
1716 [(match_scratch:SI 0 "d")
1717 (set (match_operand:SI 1 "register_operand" "")
1718 (match_operand:SI 2 "register_operand" ""))
1721 [(set (match_operand:SI 3 "register_operand" "")
1722 (plus:SI (mult:SI (match_operand:SI 4 "register_operand" "")
1723 (match_operand:SI 5 "register_operand" ""))
1725 (clobber (match_operand:SI 6 "register_operand" ""))
1726 (clobber (match_dup 1))])]
1727 "ISA_HAS_MACC && GENERATE_MULT3_SI
1728 && true_regnum (operands[1]) == LO_REGNUM
1729 && peep2_reg_dead_p (2, operands[1])
1730 && GP_REG_P (true_regnum (operands[3]))"
1731 [(parallel [(set (match_dup 0)
1732 (mult:SI (match_dup 4)
1734 (clobber (match_dup 6))
1735 (clobber (match_dup 1))])
1737 (plus:SI (match_dup 0)
1741 ;; Same as above, except LO is the initial target of the macc.
1743 ;; Operand 0: GPR (scratch)
1745 ;; Operand 2: GPR (addend)
1746 ;; Operand 3: GPR (1st multiplication operand)
1747 ;; Operand 4: GPR (2nd multiplication operand)
1749 ;; Operand 6: GPR (destination)
1751 [(match_scratch:SI 0 "d")
1752 (set (match_operand:SI 1 "register_operand" "")
1753 (match_operand:SI 2 "register_operand" ""))
1757 (plus:SI (mult:SI (match_operand:SI 3 "register_operand" "")
1758 (match_operand:SI 4 "register_operand" ""))
1760 (clobber (match_operand:SI 5 "register_operand" ""))
1761 (clobber (scratch:SI))])
1763 (set (match_operand:SI 6 "register_operand" "")
1765 "ISA_HAS_MACC && GENERATE_MULT3_SI
1766 && true_regnum (operands[1]) == LO_REGNUM
1767 && peep2_reg_dead_p (3, operands[1])
1768 && GP_REG_P (true_regnum (operands[6]))"
1769 [(parallel [(set (match_dup 0)
1770 (mult:SI (match_dup 3)
1772 (clobber (match_dup 5))
1773 (clobber (match_dup 1))])
1775 (plus:SI (match_dup 0)
1779 (define_insn "*mul_sub_si"
1780 [(set (match_operand:SI 0 "register_operand" "=l,*d,*d")
1781 (minus:SI (match_operand:SI 1 "register_operand" "0,l,*d")
1782 (mult:SI (match_operand:SI 2 "register_operand" "d,d,d")
1783 (match_operand:SI 3 "register_operand" "d,d,d"))))
1784 (clobber (match_scratch:SI 4 "=h,h,h"))
1785 (clobber (match_scratch:SI 5 "=X,1,l"))
1786 (clobber (match_scratch:SI 6 "=X,X,&d"))]
1792 [(set_attr "type" "imadd,multi,multi")
1793 (set_attr "mode" "SI")
1794 (set_attr "length" "4,8,8")])
1796 ;; Split the above insn if we failed to get LO allocated.
1798 [(set (match_operand:SI 0 "register_operand" "")
1799 (minus:SI (match_operand:SI 1 "register_operand" "")
1800 (mult:SI (match_operand:SI 2 "register_operand" "")
1801 (match_operand:SI 3 "register_operand" ""))))
1802 (clobber (match_scratch:SI 4 ""))
1803 (clobber (match_scratch:SI 5 ""))
1804 (clobber (match_scratch:SI 6 ""))]
1805 "reload_completed && !TARGET_DEBUG_D_MODE
1806 && GP_REG_P (true_regnum (operands[0]))
1807 && GP_REG_P (true_regnum (operands[1]))"
1808 [(parallel [(set (match_dup 6)
1809 (mult:SI (match_dup 2) (match_dup 3)))
1810 (clobber (match_dup 4))
1811 (clobber (match_dup 5))])
1812 (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 6)))]
1815 ;; Splitter to copy result of MSUB to a general register
1817 [(set (match_operand:SI 0 "register_operand" "")
1818 (minus:SI (match_operand:SI 1 "register_operand" "")
1819 (mult:SI (match_operand:SI 2 "register_operand" "")
1820 (match_operand:SI 3 "register_operand" ""))))
1821 (clobber (match_scratch:SI 4 ""))
1822 (clobber (match_scratch:SI 5 ""))
1823 (clobber (match_scratch:SI 6 ""))]
1824 "reload_completed && !TARGET_DEBUG_D_MODE
1825 && GP_REG_P (true_regnum (operands[0]))
1826 && true_regnum (operands[1]) == LO_REGNUM"
1827 [(parallel [(set (match_dup 1)
1828 (minus:SI (match_dup 1)
1829 (mult:SI (match_dup 2) (match_dup 3))))
1830 (clobber (match_dup 4))
1831 (clobber (match_dup 5))
1832 (clobber (match_dup 6))])
1833 (set (match_dup 0) (match_dup 1))]
1836 (define_insn "*muls"
1837 [(set (match_operand:SI 0 "register_operand" "=l,d")
1838 (neg:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d")
1839 (match_operand:SI 2 "register_operand" "d,d"))))
1840 (clobber (match_scratch:SI 3 "=h,h"))
1841 (clobber (match_scratch:SI 4 "=X,l"))]
1846 [(set_attr "type" "imul")
1847 (set_attr "mode" "SI")])
1849 (define_insn "*msac"
1850 [(set (match_operand:SI 0 "register_operand" "=l,d")
1851 (minus:SI (match_operand:SI 1 "register_operand" "0,l")
1852 (mult:SI (match_operand:SI 2 "register_operand" "d,d")
1853 (match_operand:SI 3 "register_operand" "d,d"))))
1854 (clobber (match_scratch:SI 4 "=h,h"))
1855 (clobber (match_scratch:SI 5 "=X,1"))]
1858 if (which_alternative == 1)
1859 return "msac\t%0,%2,%3";
1860 else if (TARGET_MIPS5500)
1861 return "msub\t%2,%3";
1863 return "msac\t$0,%2,%3";
1865 [(set_attr "type" "imadd")
1866 (set_attr "mode" "SI")])
1868 (define_expand "muldi3"
1869 [(set (match_operand:DI 0 "register_operand" "")
1870 (mult:DI (match_operand:DI 1 "register_operand" "")
1871 (match_operand:DI 2 "register_operand" "")))]
1874 if (GENERATE_MULT3_DI)
1875 emit_insn (gen_muldi3_mult3 (operands[0], operands[1], operands[2]));
1876 else if (!TARGET_FIX_R4000)
1877 emit_insn (gen_muldi3_internal (operands[0], operands[1], operands[2]));
1879 emit_insn (gen_muldi3_r4000 (operands[0], operands[1], operands[2]));
1883 (define_insn "muldi3_mult3"
1884 [(set (match_operand:DI 0 "register_operand" "=d")
1885 (mult:DI (match_operand:DI 1 "register_operand" "d")
1886 (match_operand:DI 2 "register_operand" "d")))
1887 (clobber (match_scratch:DI 3 "=h"))
1888 (clobber (match_scratch:DI 4 "=l"))]
1889 "TARGET_64BIT && GENERATE_MULT3_DI"
1891 [(set_attr "type" "imul")
1892 (set_attr "mode" "DI")])
1894 (define_insn "muldi3_internal"
1895 [(set (match_operand:DI 0 "register_operand" "=l")
1896 (mult:DI (match_operand:DI 1 "register_operand" "d")
1897 (match_operand:DI 2 "register_operand" "d")))
1898 (clobber (match_scratch:DI 3 "=h"))]
1899 "TARGET_64BIT && !TARGET_FIX_R4000"
1901 [(set_attr "type" "imul")
1902 (set_attr "mode" "DI")])
1904 (define_insn "muldi3_r4000"
1905 [(set (match_operand:DI 0 "register_operand" "=d")
1906 (mult:DI (match_operand:DI 1 "register_operand" "d")
1907 (match_operand:DI 2 "register_operand" "d")))
1908 (clobber (match_scratch:DI 3 "=h"))
1909 (clobber (match_scratch:DI 4 "=l"))]
1910 "TARGET_64BIT && TARGET_FIX_R4000"
1911 "dmult\t%1,%2\;mflo\t%0"
1912 [(set_attr "type" "imul")
1913 (set_attr "mode" "DI")
1914 (set_attr "length" "8")])
1916 ;; ??? We could define a mulditi3 pattern when TARGET_64BIT.
1918 (define_expand "mulsidi3"
1920 [(set (match_operand:DI 0 "register_operand" "")
1922 (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
1923 (sign_extend:DI (match_operand:SI 2 "register_operand" ""))))
1924 (clobber (scratch:DI))
1925 (clobber (scratch:DI))
1926 (clobber (scratch:DI))])]
1927 "!TARGET_64BIT || !TARGET_FIX_R4000"
1931 if (!TARGET_FIX_R4000)
1932 emit_insn (gen_mulsidi3_32bit_internal (operands[0], operands[1],
1935 emit_insn (gen_mulsidi3_32bit_r4000 (operands[0], operands[1],
1941 (define_insn "mulsidi3_32bit_internal"
1942 [(set (match_operand:DI 0 "register_operand" "=x")
1944 (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
1945 (sign_extend:DI (match_operand:SI 2 "register_operand" "d"))))]
1946 "!TARGET_64BIT && !TARGET_FIX_R4000"
1948 [(set_attr "type" "imul")
1949 (set_attr "mode" "SI")])
1951 (define_insn "mulsidi3_32bit_r4000"
1952 [(set (match_operand:DI 0 "register_operand" "=d")
1954 (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
1955 (sign_extend:DI (match_operand:SI 2 "register_operand" "d"))))
1956 (clobber (match_scratch:DI 3 "=l"))
1957 (clobber (match_scratch:DI 4 "=h"))]
1958 "!TARGET_64BIT && TARGET_FIX_R4000"
1959 "mult\t%1,%2\;mflo\t%L0;mfhi\t%M0"
1960 [(set_attr "type" "imul")
1961 (set_attr "mode" "SI")
1962 (set_attr "length" "12")])
1964 (define_insn_and_split "*mulsidi3_64bit"
1965 [(set (match_operand:DI 0 "register_operand" "=d")
1966 (mult:DI (match_operator:DI 1 "extend_operator"
1967 [(match_operand:SI 3 "register_operand" "d")])
1968 (match_operator:DI 2 "extend_operator"
1969 [(match_operand:SI 4 "register_operand" "d")])))
1970 (clobber (match_scratch:DI 5 "=l"))
1971 (clobber (match_scratch:DI 6 "=h"))
1972 (clobber (match_scratch:DI 7 "=d"))]
1973 "TARGET_64BIT && !TARGET_FIX_R4000
1974 && GET_CODE (operands[1]) == GET_CODE (operands[2])"
1976 "&& reload_completed"
1980 (mult:SI (match_dup 3)
1984 (mult:DI (match_dup 1)
1988 ;; OP7 <- LO, OP0 <- HI
1989 (set (match_dup 7) (match_dup 5))
1990 (set (match_dup 0) (match_dup 6))
1994 (ashift:DI (match_dup 7)
1997 (lshiftrt:DI (match_dup 7)
2000 ;; Shift OP0 into place.
2002 (ashift:DI (match_dup 0)
2005 ;; OR the two halves together
2007 (ior:DI (match_dup 0)
2010 [(set_attr "type" "imul")
2011 (set_attr "mode" "SI")
2012 (set_attr "length" "24")])
2014 (define_insn "*mulsidi3_64bit_parts"
2015 [(set (match_operand:DI 0 "register_operand" "=l")
2017 (mult:SI (match_operand:SI 2 "register_operand" "d")
2018 (match_operand:SI 3 "register_operand" "d"))))
2019 (set (match_operand:DI 1 "register_operand" "=h")
2022 (match_operator:DI 4 "extend_operator" [(match_dup 2)])
2023 (match_operator:DI 5 "extend_operator" [(match_dup 3)]))
2025 "TARGET_64BIT && !TARGET_FIX_R4000
2026 && GET_CODE (operands[4]) == GET_CODE (operands[5])"
2028 if (GET_CODE (operands[4]) == SIGN_EXTEND)
2029 return "mult\t%2,%3";
2031 return "multu\t%2,%3";
2033 [(set_attr "type" "imul")
2034 (set_attr "mode" "SI")])
2036 (define_expand "umulsidi3"
2038 [(set (match_operand:DI 0 "register_operand" "")
2040 (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
2041 (zero_extend:DI (match_operand:SI 2 "register_operand" ""))))
2042 (clobber (scratch:DI))
2043 (clobber (scratch:DI))
2044 (clobber (scratch:DI))])]
2045 "!TARGET_64BIT || !TARGET_FIX_R4000"
2049 if (!TARGET_FIX_R4000)
2050 emit_insn (gen_umulsidi3_32bit_internal (operands[0], operands[1],
2053 emit_insn (gen_umulsidi3_32bit_r4000 (operands[0], operands[1],
2059 (define_insn "umulsidi3_32bit_internal"
2060 [(set (match_operand:DI 0 "register_operand" "=x")
2062 (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
2063 (zero_extend:DI (match_operand:SI 2 "register_operand" "d"))))]
2064 "!TARGET_64BIT && !TARGET_FIX_R4000"
2066 [(set_attr "type" "imul")
2067 (set_attr "mode" "SI")])
2069 (define_insn "umulsidi3_32bit_r4000"
2070 [(set (match_operand:DI 0 "register_operand" "=d")
2072 (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
2073 (zero_extend:DI (match_operand:SI 2 "register_operand" "d"))))
2074 (clobber (match_scratch:DI 3 "=l"))
2075 (clobber (match_scratch:DI 4 "=h"))]
2076 "!TARGET_64BIT && TARGET_FIX_R4000"
2077 "multu\t%1,%2\;mflo\t%L0;mfhi\t%M0"
2078 [(set_attr "type" "imul")
2079 (set_attr "mode" "SI")
2080 (set_attr "length" "12")])
2082 ;; Widening multiply with negation.
2083 (define_insn "*muls_di"
2084 [(set (match_operand:DI 0 "register_operand" "=x")
2087 (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
2088 (sign_extend:DI (match_operand:SI 2 "register_operand" "d")))))]
2089 "!TARGET_64BIT && ISA_HAS_MULS"
2091 [(set_attr "type" "imul")
2092 (set_attr "length" "4")
2093 (set_attr "mode" "SI")])
2095 (define_insn "*umuls_di"
2096 [(set (match_operand:DI 0 "register_operand" "=x")
2099 (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
2100 (zero_extend:DI (match_operand:SI 2 "register_operand" "d")))))]
2101 "!TARGET_64BIT && ISA_HAS_MULS"
2103 [(set_attr "type" "imul")
2104 (set_attr "length" "4")
2105 (set_attr "mode" "SI")])
2107 (define_insn "*smsac_di"
2108 [(set (match_operand:DI 0 "register_operand" "=x")
2110 (match_operand:DI 3 "register_operand" "0")
2112 (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
2113 (sign_extend:DI (match_operand:SI 2 "register_operand" "d")))))]
2114 "!TARGET_64BIT && ISA_HAS_MSAC"
2116 if (TARGET_MIPS5500)
2117 return "msub\t%1,%2";
2119 return "msac\t$0,%1,%2";
2121 [(set_attr "type" "imadd")
2122 (set_attr "length" "4")
2123 (set_attr "mode" "SI")])
2125 (define_insn "*umsac_di"
2126 [(set (match_operand:DI 0 "register_operand" "=x")
2128 (match_operand:DI 3 "register_operand" "0")
2130 (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
2131 (zero_extend:DI (match_operand:SI 2 "register_operand" "d")))))]
2132 "!TARGET_64BIT && ISA_HAS_MSAC"
2134 if (TARGET_MIPS5500)
2135 return "msubu\t%1,%2";
2137 return "msacu\t$0,%1,%2";
2139 [(set_attr "type" "imadd")
2140 (set_attr "length" "4")
2141 (set_attr "mode" "SI")])
2143 ;; _highpart patterns
2144 (define_expand "umulsi3_highpart"
2145 [(set (match_operand:SI 0 "register_operand" "")
2148 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
2149 (zero_extend:DI (match_operand:SI 2 "register_operand" "")))
2151 "ISA_HAS_MULHI || !TARGET_FIX_R4000"
2154 emit_insn (gen_umulsi3_highpart_mulhi_internal (operands[0], operands[1],
2157 emit_insn (gen_umulsi3_highpart_internal (operands[0], operands[1],
2162 (define_insn "umulsi3_highpart_internal"
2163 [(set (match_operand:SI 0 "register_operand" "=h")
2166 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
2167 (zero_extend:DI (match_operand:SI 2 "register_operand" "d")))
2169 (clobber (match_scratch:SI 3 "=l"))]
2170 "!ISA_HAS_MULHI && !TARGET_FIX_R4000"
2172 [(set_attr "type" "imul")
2173 (set_attr "mode" "SI")
2174 (set_attr "length" "4")])
2176 (define_insn "umulsi3_highpart_mulhi_internal"
2177 [(set (match_operand:SI 0 "register_operand" "=h,d")
2180 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "d,d"))
2181 (zero_extend:DI (match_operand:SI 2 "register_operand" "d,d")))
2183 (clobber (match_scratch:SI 3 "=l,l"))
2184 (clobber (match_scratch:SI 4 "=X,h"))]
2189 [(set_attr "type" "imul")
2190 (set_attr "mode" "SI")
2191 (set_attr "length" "4")])
2193 (define_insn "umulsi3_highpart_neg_mulhi_internal"
2194 [(set (match_operand:SI 0 "register_operand" "=h,d")
2198 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "d,d"))
2199 (zero_extend:DI (match_operand:SI 2 "register_operand" "d,d"))))
2201 (clobber (match_scratch:SI 3 "=l,l"))
2202 (clobber (match_scratch:SI 4 "=X,h"))]
2207 [(set_attr "type" "imul")
2208 (set_attr "mode" "SI")
2209 (set_attr "length" "4")])
2211 (define_expand "smulsi3_highpart"
2212 [(set (match_operand:SI 0 "register_operand" "")
2215 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
2216 (sign_extend:DI (match_operand:SI 2 "register_operand" "")))
2218 "ISA_HAS_MULHI || !TARGET_FIX_R4000"
2221 emit_insn (gen_smulsi3_highpart_mulhi_internal (operands[0], operands[1],
2224 emit_insn (gen_smulsi3_highpart_internal (operands[0], operands[1],
2229 (define_insn "smulsi3_highpart_internal"
2230 [(set (match_operand:SI 0 "register_operand" "=h")
2233 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
2234 (sign_extend:DI (match_operand:SI 2 "register_operand" "d")))
2236 (clobber (match_scratch:SI 3 "=l"))]
2237 "!ISA_HAS_MULHI && !TARGET_FIX_R4000"
2239 [(set_attr "type" "imul")
2240 (set_attr "mode" "SI")
2241 (set_attr "length" "4")])
2243 (define_insn "smulsi3_highpart_mulhi_internal"
2244 [(set (match_operand:SI 0 "register_operand" "=h,d")
2247 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d,d"))
2248 (sign_extend:DI (match_operand:SI 2 "register_operand" "d,d")))
2250 (clobber (match_scratch:SI 3 "=l,l"))
2251 (clobber (match_scratch:SI 4 "=X,h"))]
2256 [(set_attr "type" "imul")
2257 (set_attr "mode" "SI")
2258 (set_attr "length" "4")])
2260 (define_insn "smulsi3_highpart_neg_mulhi_internal"
2261 [(set (match_operand:SI 0 "register_operand" "=h,d")
2265 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d,d"))
2266 (sign_extend:DI (match_operand:SI 2 "register_operand" "d,d"))))
2268 (clobber (match_scratch:SI 3 "=l,l"))
2269 (clobber (match_scratch:SI 4 "=X,h"))]
2274 [(set_attr "type" "imul")
2275 (set_attr "mode" "SI")])
2277 (define_insn "smuldi3_highpart"
2278 [(set (match_operand:DI 0 "register_operand" "=h")
2282 (sign_extend:TI (match_operand:DI 1 "register_operand" "d"))
2283 (sign_extend:TI (match_operand:DI 2 "register_operand" "d")))
2285 (clobber (match_scratch:DI 3 "=l"))]
2286 "TARGET_64BIT && !TARGET_FIX_R4000"
2288 [(set_attr "type" "imul")
2289 (set_attr "mode" "DI")])
2291 (define_insn "umuldi3_highpart"
2292 [(set (match_operand:DI 0 "register_operand" "=h")
2296 (zero_extend:TI (match_operand:DI 1 "register_operand" "d"))
2297 (zero_extend:TI (match_operand:DI 2 "register_operand" "d")))
2299 (clobber (match_scratch:DI 3 "=l"))]
2300 "TARGET_64BIT && !TARGET_FIX_R4000"
2302 [(set_attr "type" "imul")
2303 (set_attr "mode" "DI")])
2306 ;; The R4650 supports a 32 bit multiply/ 64 bit accumulate
2307 ;; instruction. The HI/LO registers are used as a 64 bit accumulator.
2309 (define_insn "madsi"
2310 [(set (match_operand:SI 0 "register_operand" "+l")
2311 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d")
2312 (match_operand:SI 2 "register_operand" "d"))
2314 (clobber (match_scratch:SI 3 "=h"))]
2317 [(set_attr "type" "imadd")
2318 (set_attr "mode" "SI")])
2320 (define_insn "*umul_acc_di"
2321 [(set (match_operand:DI 0 "register_operand" "=x")
2323 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
2324 (zero_extend:DI (match_operand:SI 2 "register_operand" "d")))
2325 (match_operand:DI 3 "register_operand" "0")))]
2326 "(TARGET_MAD || ISA_HAS_MACC)
2330 return "madu\t%1,%2";
2331 else if (TARGET_MIPS5500)
2332 return "maddu\t%1,%2";
2334 return "maccu\t%.,%1,%2";
2336 [(set_attr "type" "imadd")
2337 (set_attr "mode" "SI")])
2340 (define_insn "*smul_acc_di"
2341 [(set (match_operand:DI 0 "register_operand" "=x")
2343 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
2344 (sign_extend:DI (match_operand:SI 2 "register_operand" "d")))
2345 (match_operand:DI 3 "register_operand" "0")))]
2346 "(TARGET_MAD || ISA_HAS_MACC)
2350 return "mad\t%1,%2";
2351 else if (TARGET_MIPS5500)
2352 return "madd\t%1,%2";
2354 return "macc\t%.,%1,%2";
2356 [(set_attr "type" "imadd")
2357 (set_attr "mode" "SI")])
2359 ;; Floating point multiply accumulate instructions.
2362 [(set (match_operand:DF 0 "register_operand" "=f")
2363 (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
2364 (match_operand:DF 2 "register_operand" "f"))
2365 (match_operand:DF 3 "register_operand" "f")))]
2366 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FUSED_MADD"
2367 "madd.d\t%0,%3,%1,%2"
2368 [(set_attr "type" "fmadd")
2369 (set_attr "mode" "DF")])
2372 [(set (match_operand:SF 0 "register_operand" "=f")
2373 (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
2374 (match_operand:SF 2 "register_operand" "f"))
2375 (match_operand:SF 3 "register_operand" "f")))]
2376 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
2377 "madd.s\t%0,%3,%1,%2"
2378 [(set_attr "type" "fmadd")
2379 (set_attr "mode" "SF")])
2382 [(set (match_operand:DF 0 "register_operand" "=f")
2383 (minus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
2384 (match_operand:DF 2 "register_operand" "f"))
2385 (match_operand:DF 3 "register_operand" "f")))]
2386 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FUSED_MADD"
2387 "msub.d\t%0,%3,%1,%2"
2388 [(set_attr "type" "fmadd")
2389 (set_attr "mode" "DF")])
2392 [(set (match_operand:SF 0 "register_operand" "=f")
2393 (minus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
2394 (match_operand:SF 2 "register_operand" "f"))
2395 (match_operand:SF 3 "register_operand" "f")))]
2397 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
2398 "msub.s\t%0,%3,%1,%2"
2399 [(set_attr "type" "fmadd")
2400 (set_attr "mode" "SF")])
2403 [(set (match_operand:DF 0 "register_operand" "=f")
2404 (neg:DF (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
2405 (match_operand:DF 2 "register_operand" "f"))
2406 (match_operand:DF 3 "register_operand" "f"))))]
2407 "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FUSED_MADD"
2408 "nmadd.d\t%0,%3,%1,%2"
2409 [(set_attr "type" "fmadd")
2410 (set_attr "mode" "DF")])
2413 [(set (match_operand:SF 0 "register_operand" "=f")
2414 (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
2415 (match_operand:SF 2 "register_operand" "f"))
2416 (match_operand:SF 3 "register_operand" "f"))))]
2417 "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
2418 "nmadd.s\t%0,%3,%1,%2"
2419 [(set_attr "type" "fmadd")
2420 (set_attr "mode" "SF")])
2423 [(set (match_operand:DF 0 "register_operand" "=f")
2424 (minus:DF (match_operand:DF 1 "register_operand" "f")
2425 (mult:DF (match_operand:DF 2 "register_operand" "f")
2426 (match_operand:DF 3 "register_operand" "f"))))]
2427 "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FUSED_MADD"
2428 "nmsub.d\t%0,%1,%2,%3"
2429 [(set_attr "type" "fmadd")
2430 (set_attr "mode" "DF")])
2433 [(set (match_operand:SF 0 "register_operand" "=f")
2434 (minus:SF (match_operand:SF 1 "register_operand" "f")
2435 (mult:SF (match_operand:SF 2 "register_operand" "f")
2436 (match_operand:SF 3 "register_operand" "f"))))]
2437 "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
2438 "nmsub.s\t%0,%1,%2,%3"
2439 [(set_attr "type" "fmadd")
2440 (set_attr "mode" "SF")])
2443 ;; ....................
2445 ;; DIVISION and REMAINDER
2447 ;; ....................
2450 (define_expand "divdf3"
2451 [(set (match_operand:DF 0 "register_operand" "")
2452 (div:DF (match_operand:DF 1 "reg_or_const_float_1_operand" "")
2453 (match_operand:DF 2 "register_operand" "")))]
2454 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2456 if (const_float_1_operand (operands[1], DFmode))
2457 if (!(ISA_HAS_FP4 && flag_unsafe_math_optimizations))
2461 ;; This pattern works around the early SB-1 rev2 core "F1" erratum:
2463 ;; If an mfc1 or dmfc1 happens to access the floating point register
2464 ;; file at the same time a long latency operation (div, sqrt, recip,
2465 ;; sqrt) iterates an intermediate result back through the floating
2466 ;; point register file bypass, then instead returning the correct
2467 ;; register value the mfc1 or dmfc1 operation returns the intermediate
2468 ;; result of the long latency operation.
2470 ;; The workaround is to insert an unconditional 'mov' from/to the
2471 ;; long latency op destination register.
2473 (define_insn "*divdf3"
2474 [(set (match_operand:DF 0 "register_operand" "=f")
2475 (div:DF (match_operand:DF 1 "register_operand" "f")
2476 (match_operand:DF 2 "register_operand" "f")))]
2477 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2480 return "div.d\t%0,%1,%2\;mov.d\t%0,%0";
2482 return "div.d\t%0,%1,%2";
2484 [(set_attr "type" "fdiv")
2485 (set_attr "mode" "DF")
2486 (set (attr "length")
2487 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
2492 ;; This pattern works around the early SB-1 rev2 core "F2" erratum:
2494 ;; In certain cases, div.s and div.ps may have a rounding error
2495 ;; and/or wrong inexact flag.
2497 ;; Therefore, we only allow div.s if not working around SB-1 rev2
2498 ;; errata, or if working around those errata and a slight loss of
2499 ;; precision is OK (i.e., flag_unsafe_math_optimizations is set).
2500 (define_expand "divsf3"
2501 [(set (match_operand:SF 0 "register_operand" "")
2502 (div:SF (match_operand:SF 1 "reg_or_const_float_1_operand" "")
2503 (match_operand:SF 2 "register_operand" "")))]
2504 "TARGET_HARD_FLOAT && (!TARGET_FIX_SB1 || flag_unsafe_math_optimizations)"
2506 if (const_float_1_operand (operands[1], SFmode))
2507 if (!(ISA_HAS_FP4 && flag_unsafe_math_optimizations))
2511 ;; This pattern works around the early SB-1 rev2 core "F1" erratum (see
2512 ;; "divdf3" comment for details).
2514 ;; This pattern works around the early SB-1 rev2 core "F2" erratum (see
2515 ;; "divsf3" comment for details).
2516 (define_insn "*divsf3"
2517 [(set (match_operand:SF 0 "register_operand" "=f")
2518 (div:SF (match_operand:SF 1 "register_operand" "f")
2519 (match_operand:SF 2 "register_operand" "f")))]
2520 "TARGET_HARD_FLOAT && (!TARGET_FIX_SB1 || flag_unsafe_math_optimizations)"
2523 return "div.s\t%0,%1,%2\;mov.s\t%0,%0";
2525 return "div.s\t%0,%1,%2";
2527 [(set_attr "type" "fdiv")
2528 (set_attr "mode" "SF")
2529 (set (attr "length")
2530 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
2534 ;; This pattern works around the early SB-1 rev2 core "F1" erratum (see
2535 ;; "divdf3" comment for details).
2537 [(set (match_operand:DF 0 "register_operand" "=f")
2538 (div:DF (match_operand:DF 1 "const_float_1_operand" "")
2539 (match_operand:DF 2 "register_operand" "f")))]
2540 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && flag_unsafe_math_optimizations"
2543 return "recip.d\t%0,%2\;mov.d\t%0,%0";
2545 return "recip.d\t%0,%2";
2547 [(set_attr "type" "fdiv")
2548 (set_attr "mode" "DF")
2549 (set (attr "length")
2550 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
2554 ;; This pattern works around the early SB-1 rev2 core "F1" erratum (see
2555 ;; "divdf3" comment for details).
2557 [(set (match_operand:SF 0 "register_operand" "=f")
2558 (div:SF (match_operand:SF 1 "const_float_1_operand" "")
2559 (match_operand:SF 2 "register_operand" "f")))]
2560 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && flag_unsafe_math_optimizations"
2563 return "recip.s\t%0,%2\;mov.s\t%0,%0";
2565 return "recip.s\t%0,%2";
2567 [(set_attr "type" "fdiv")
2568 (set_attr "mode" "SF")
2569 (set (attr "length")
2570 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
2574 (define_insn "divmodsi4"
2575 [(set (match_operand:SI 0 "register_operand" "=l")
2576 (div:SI (match_operand:SI 1 "register_operand" "d")
2577 (match_operand:SI 2 "register_operand" "d")))
2578 (set (match_operand:SI 3 "register_operand" "=h")
2579 (mod:SI (match_dup 1)
2582 { return mips_output_division ("div\t$0,%1,%2", operands); }
2583 [(set_attr "type" "idiv")
2584 (set_attr "mode" "SI")])
2586 (define_insn "divmoddi4"
2587 [(set (match_operand:DI 0 "register_operand" "=l")
2588 (div:DI (match_operand:DI 1 "register_operand" "d")
2589 (match_operand:DI 2 "register_operand" "d")))
2590 (set (match_operand:DI 3 "register_operand" "=h")
2591 (mod:DI (match_dup 1)
2594 { return mips_output_division ("ddiv\t$0,%1,%2", operands); }
2595 [(set_attr "type" "idiv")
2596 (set_attr "mode" "DI")])
2598 (define_insn "udivmodsi4"
2599 [(set (match_operand:SI 0 "register_operand" "=l")
2600 (udiv:SI (match_operand:SI 1 "register_operand" "d")
2601 (match_operand:SI 2 "register_operand" "d")))
2602 (set (match_operand:SI 3 "register_operand" "=h")
2603 (umod:SI (match_dup 1)
2606 { return mips_output_division ("divu\t$0,%1,%2", operands); }
2607 [(set_attr "type" "idiv")
2608 (set_attr "mode" "SI")])
2610 (define_insn "udivmoddi4"
2611 [(set (match_operand:DI 0 "register_operand" "=l")
2612 (udiv:DI (match_operand:DI 1 "register_operand" "d")
2613 (match_operand:DI 2 "register_operand" "d")))
2614 (set (match_operand:DI 3 "register_operand" "=h")
2615 (umod:DI (match_dup 1)
2618 { return mips_output_division ("ddivu\t$0,%1,%2", operands); }
2619 [(set_attr "type" "idiv")
2620 (set_attr "mode" "DI")])
2623 ;; ....................
2627 ;; ....................
2629 ;; This pattern works around the early SB-1 rev2 core "F1" erratum (see
2630 ;; "divdf3" comment for details).
2631 (define_insn "sqrtdf2"
2632 [(set (match_operand:DF 0 "register_operand" "=f")
2633 (sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
2634 "TARGET_HARD_FLOAT && HAVE_SQRT_P() && TARGET_DOUBLE_FLOAT"
2637 return "sqrt.d\t%0,%1\;mov.d\t%0,%0";
2639 return "sqrt.d\t%0,%1";
2641 [(set_attr "type" "fsqrt")
2642 (set_attr "mode" "DF")
2643 (set (attr "length")
2644 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
2648 ;; This pattern works around the early SB-1 rev2 core "F1" erratum (see
2649 ;; "divdf3" comment for details).
2650 (define_insn "sqrtsf2"
2651 [(set (match_operand:SF 0 "register_operand" "=f")
2652 (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
2653 "TARGET_HARD_FLOAT && HAVE_SQRT_P()"
2656 return "sqrt.s\t%0,%1\;mov.s\t%0,%0";
2658 return "sqrt.s\t%0,%1";
2660 [(set_attr "type" "fsqrt")
2661 (set_attr "mode" "SF")
2662 (set (attr "length")
2663 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
2667 ;; This pattern works around the early SB-1 rev2 core "F1" erratum (see
2668 ;; "divdf3" comment for details).
2670 [(set (match_operand:DF 0 "register_operand" "=f")
2671 (div:DF (match_operand:DF 1 "const_float_1_operand" "")
2672 (sqrt:DF (match_operand:DF 2 "register_operand" "f"))))]
2673 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && flag_unsafe_math_optimizations"
2676 return "rsqrt.d\t%0,%2\;mov.d\t%0,%0";
2678 return "rsqrt.d\t%0,%2";
2680 [(set_attr "type" "frsqrt")
2681 (set_attr "mode" "DF")
2682 (set (attr "length")
2683 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
2687 ;; This pattern works around the early SB-1 rev2 core "F1" erratum (see
2688 ;; "divdf3" comment for details).
2690 [(set (match_operand:SF 0 "register_operand" "=f")
2691 (div:SF (match_operand:SF 1 "const_float_1_operand" "")
2692 (sqrt:SF (match_operand:SF 2 "register_operand" "f"))))]
2693 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && flag_unsafe_math_optimizations"
2696 return "rsqrt.s\t%0,%2\;mov.s\t%0,%0";
2698 return "rsqrt.s\t%0,%2";
2700 [(set_attr "type" "frsqrt")
2701 (set_attr "mode" "SF")
2702 (set (attr "length")
2703 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
2708 ;; ....................
2712 ;; ....................
2714 ;; Do not use the integer abs macro instruction, since that signals an
2715 ;; exception on -2147483648 (sigh).
2717 (define_insn "abssi2"
2718 [(set (match_operand:SI 0 "register_operand" "=d")
2719 (abs:SI (match_operand:SI 1 "register_operand" "d")))]
2722 operands[2] = const0_rtx;
2724 if (REGNO (operands[0]) == REGNO (operands[1]))
2726 if (GENERATE_BRANCHLIKELY)
2727 return "%(bltzl\t%1,1f\;subu\t%0,%z2,%0\n%~1:%)";
2729 return "bgez\t%1,1f%#\;subu\t%0,%z2,%0\n%~1:";
2732 return "%(bgez\t%1,1f\;move\t%0,%1\;subu\t%0,%z2,%0\n%~1:%)";
2734 [(set_attr "type" "multi")
2735 (set_attr "mode" "SI")
2736 (set_attr "length" "12")])
2738 (define_insn "absdi2"
2739 [(set (match_operand:DI 0 "register_operand" "=d")
2740 (abs:DI (match_operand:DI 1 "register_operand" "d")))]
2741 "TARGET_64BIT && !TARGET_MIPS16"
2743 unsigned int regno1;
2744 operands[2] = const0_rtx;
2746 if (GET_CODE (operands[1]) == REG)
2747 regno1 = REGNO (operands[1]);
2749 regno1 = REGNO (XEXP (operands[1], 0));
2751 if (REGNO (operands[0]) == regno1)
2752 return "%(bltzl\t%1,1f\;dsubu\t%0,%z2,%0\n%~1:%)";
2754 return "%(bgez\t%1,1f\;move\t%0,%1\;dsubu\t%0,%z2,%0\n%~1:%)";
2756 [(set_attr "type" "multi")
2757 (set_attr "mode" "DI")
2758 (set_attr "length" "12")])
2760 (define_insn "absdf2"
2761 [(set (match_operand:DF 0 "register_operand" "=f")
2762 (abs:DF (match_operand:DF 1 "register_operand" "f")))]
2763 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2765 [(set_attr "type" "fabs")
2766 (set_attr "mode" "DF")])
2768 (define_insn "abssf2"
2769 [(set (match_operand:SF 0 "register_operand" "=f")
2770 (abs:SF (match_operand:SF 1 "register_operand" "f")))]
2773 [(set_attr "type" "fabs")
2774 (set_attr "mode" "SF")])
2777 ;; ....................
2779 ;; FIND FIRST BIT INSTRUCTION
2781 ;; ....................
2784 (define_insn "ffssi2"
2785 [(set (match_operand:SI 0 "register_operand" "=&d")
2786 (ffs:SI (match_operand:SI 1 "register_operand" "d")))
2787 (clobber (match_scratch:SI 2 "=&d"))
2788 (clobber (match_scratch:SI 3 "=&d"))]
2791 if (optimize && find_reg_note (insn, REG_DEAD, operands[1]))
2795 %~1:\tand\t%2,%1,0x0001\;\
2805 %~1:\tand\t%2,%3,0x0001\;\
2811 [(set_attr "type" "multi")
2812 (set_attr "mode" "SI")
2813 (set_attr "length" "28")])
2815 (define_insn "ffsdi2"
2816 [(set (match_operand:DI 0 "register_operand" "=&d")
2817 (ffs:DI (match_operand:DI 1 "register_operand" "d")))
2818 (clobber (match_scratch:DI 2 "=&d"))
2819 (clobber (match_scratch:DI 3 "=&d"))]
2820 "TARGET_64BIT && !TARGET_MIPS16"
2822 if (optimize && find_reg_note (insn, REG_DEAD, operands[1]))
2826 %~1:\tand\t%2,%1,0x0001\;\
2836 %~1:\tand\t%2,%3,0x0001\;\
2842 [(set_attr "type" "multi")
2843 (set_attr "mode" "DI")
2844 (set_attr "length" "28")])
2847 ;; ...................
2849 ;; Count leading zeroes.
2851 ;; ...................
2854 (define_insn "clzsi2"
2855 [(set (match_operand:SI 0 "register_operand" "=d")
2856 (clz:SI (match_operand:SI 1 "register_operand" "d")))]
2859 [(set_attr "type" "arith")
2860 (set_attr "mode" "SI")])
2862 (define_insn "clzdi2"
2863 [(set (match_operand:DI 0 "register_operand" "=d")
2864 (clz:DI (match_operand:DI 1 "register_operand" "d")))]
2867 [(set_attr "type" "arith")
2868 (set_attr "mode" "DI")])
2871 ;; ....................
2873 ;; NEGATION and ONE'S COMPLEMENT
2875 ;; ....................
2877 (define_insn "negsi2"
2878 [(set (match_operand:SI 0 "register_operand" "=d")
2879 (neg:SI (match_operand:SI 1 "register_operand" "d")))]
2883 return "neg\t%0,%1";
2885 return "subu\t%0,%.,%1";
2887 [(set_attr "type" "arith")
2888 (set_attr "mode" "SI")])
2890 (define_expand "negdi2"
2891 [(parallel [(set (match_operand:DI 0 "register_operand" "=d")
2892 (neg:DI (match_operand:DI 1 "register_operand" "d")))
2893 (clobber (match_dup 2))])]
2894 "(TARGET_64BIT || !TARGET_DEBUG_G_MODE) && !TARGET_MIPS16"
2898 emit_insn (gen_negdi2_internal_2 (operands[0], operands[1]));
2902 operands[2] = gen_reg_rtx (SImode);
2905 (define_insn "negdi2_internal"
2906 [(set (match_operand:DI 0 "register_operand" "=d")
2907 (neg:DI (match_operand:DI 1 "register_operand" "d")))
2908 (clobber (match_operand:SI 2 "register_operand" "=d"))]
2909 "! TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16"
2910 "subu\t%L0,%.,%L1\;subu\t%M0,%.,%M1\;sltu\t%2,%.,%L0\;subu\t%M0,%M0,%2"
2911 [(set_attr "type" "darith")
2912 (set_attr "mode" "DI")
2913 (set_attr "length" "16")])
2915 (define_insn "negdi2_internal_2"
2916 [(set (match_operand:DI 0 "register_operand" "=d")
2917 (neg:DI (match_operand:DI 1 "register_operand" "d")))]
2918 "TARGET_64BIT && !TARGET_MIPS16"
2920 [(set_attr "type" "arith")
2921 (set_attr "mode" "DI")])
2923 (define_insn "negdf2"
2924 [(set (match_operand:DF 0 "register_operand" "=f")
2925 (neg:DF (match_operand:DF 1 "register_operand" "f")))]
2926 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2928 [(set_attr "type" "fneg")
2929 (set_attr "mode" "DF")])
2931 (define_insn "negsf2"
2932 [(set (match_operand:SF 0 "register_operand" "=f")
2933 (neg:SF (match_operand:SF 1 "register_operand" "f")))]
2936 [(set_attr "type" "fneg")
2937 (set_attr "mode" "SF")])
2939 (define_insn "one_cmplsi2"
2940 [(set (match_operand:SI 0 "register_operand" "=d")
2941 (not:SI (match_operand:SI 1 "register_operand" "d")))]
2945 return "not\t%0,%1";
2947 return "nor\t%0,%.,%1";
2949 [(set_attr "type" "arith")
2950 (set_attr "mode" "SI")])
2952 (define_insn "one_cmpldi2"
2953 [(set (match_operand:DI 0 "register_operand" "=d")
2954 (not:DI (match_operand:DI 1 "register_operand" "d")))]
2958 return "not\t%0,%1";
2960 return "nor\t%0,%.,%1";
2962 [(set_attr "type" "darith")
2963 (set_attr "mode" "DI")])
2966 ;; ....................
2970 ;; ....................
2973 ;; Many of these instructions use trivial define_expands, because we
2974 ;; want to use a different set of constraints when TARGET_MIPS16.
2976 (define_expand "andsi3"
2977 [(set (match_operand:SI 0 "register_operand" "=d,d")
2978 (and:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
2979 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
2984 operands[1] = force_reg (SImode, operands[1]);
2985 operands[2] = force_reg (SImode, operands[2]);
2990 [(set (match_operand:SI 0 "register_operand" "=d,d")
2991 (and:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
2992 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
2997 [(set_attr "type" "arith")
2998 (set_attr "mode" "SI")])
3001 [(set (match_operand:SI 0 "register_operand" "=d")
3002 (and:SI (match_operand:SI 1 "register_operand" "%0")
3003 (match_operand:SI 2 "register_operand" "d")))]
3006 [(set_attr "type" "arith")
3007 (set_attr "mode" "SI")])
3009 (define_expand "anddi3"
3010 [(set (match_operand:DI 0 "register_operand" "")
3011 (and:DI (match_operand:DI 1 "register_operand" "")
3012 (match_operand:DI 2 "uns_arith_operand" "")))]
3017 operands[1] = force_reg (DImode, operands[1]);
3018 operands[2] = force_reg (DImode, operands[2]);
3023 [(set (match_operand:DI 0 "register_operand" "=d,d")
3024 (and:DI (match_operand:DI 1 "register_operand" "d,d")
3025 (match_operand:DI 2 "uns_arith_operand" "d,K")))]
3026 "TARGET_64BIT && !TARGET_MIPS16"
3030 [(set_attr "type" "darith")
3031 (set_attr "mode" "DI")])
3034 [(set (match_operand:DI 0 "register_operand" "=d")
3035 (and:DI (match_operand:DI 1 "register_operand" "0")
3036 (match_operand:DI 2 "register_operand" "d")))]
3037 "TARGET_64BIT && TARGET_MIPS16"
3039 [(set_attr "type" "darith")
3040 (set_attr "mode" "DI")])
3042 (define_expand "iorsi3"
3043 [(set (match_operand:SI 0 "register_operand" "=d,d")
3044 (ior:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
3045 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
3050 operands[1] = force_reg (SImode, operands[1]);
3051 operands[2] = force_reg (SImode, operands[2]);
3056 [(set (match_operand:SI 0 "register_operand" "=d,d")
3057 (ior:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
3058 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
3063 [(set_attr "type" "arith")
3064 (set_attr "mode" "SI")])
3067 [(set (match_operand:SI 0 "register_operand" "=d")
3068 (ior:SI (match_operand:SI 1 "register_operand" "%0")
3069 (match_operand:SI 2 "register_operand" "d")))]
3072 [(set_attr "type" "arith")
3073 (set_attr "mode" "SI")])
3075 (define_expand "iordi3"
3076 [(set (match_operand:DI 0 "register_operand" "")
3077 (ior:DI (match_operand:DI 1 "register_operand" "")
3078 (match_operand:DI 2 "uns_arith_operand" "")))]
3083 operands[1] = force_reg (DImode, operands[1]);
3084 operands[2] = force_reg (DImode, operands[2]);
3089 [(set (match_operand:DI 0 "register_operand" "=d,d")
3090 (ior:DI (match_operand:DI 1 "register_operand" "d,d")
3091 (match_operand:DI 2 "uns_arith_operand" "d,K")))]
3092 "TARGET_64BIT && !TARGET_MIPS16"
3096 [(set_attr "type" "darith")
3097 (set_attr "mode" "DI")])
3100 [(set (match_operand:DI 0 "register_operand" "=d")
3101 (ior:DI (match_operand:DI 1 "register_operand" "0")
3102 (match_operand:DI 2 "register_operand" "d")))]
3103 "TARGET_64BIT && TARGET_MIPS16"
3105 [(set_attr "type" "darith")
3106 (set_attr "mode" "DI")])
3108 (define_expand "xorsi3"
3109 [(set (match_operand:SI 0 "register_operand" "=d,d")
3110 (xor:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
3111 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
3116 [(set (match_operand:SI 0 "register_operand" "=d,d")
3117 (xor:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
3118 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
3123 [(set_attr "type" "arith")
3124 (set_attr "mode" "SI")])
3127 [(set (match_operand:SI 0 "register_operand" "=d,t,t")
3128 (xor:SI (match_operand:SI 1 "uns_arith_operand" "%0,d,d")
3129 (match_operand:SI 2 "uns_arith_operand" "d,K,d")))]
3135 [(set_attr "type" "arith")
3136 (set_attr "mode" "SI")
3137 (set_attr_alternative "length"
3139 (if_then_else (match_operand:VOID 2 "m16_uimm8_1" "")
3144 (define_expand "xordi3"
3145 [(set (match_operand:DI 0 "register_operand" "")
3146 (xor:DI (match_operand:DI 1 "register_operand" "")
3147 (match_operand:DI 2 "uns_arith_operand" "")))]
3152 operands[1] = force_reg (DImode, operands[1]);
3153 operands[2] = force_reg (DImode, operands[2]);
3158 [(set (match_operand:DI 0 "register_operand" "=d,d")
3159 (xor:DI (match_operand:DI 1 "register_operand" "d,d")
3160 (match_operand:DI 2 "uns_arith_operand" "d,K")))]
3161 "TARGET_64BIT && !TARGET_MIPS16"
3165 [(set_attr "type" "darith")
3166 (set_attr "mode" "DI")])
3169 [(set (match_operand:DI 0 "register_operand" "=d,t,t")
3170 (xor:DI (match_operand:DI 1 "register_operand" "%0,d,d")
3171 (match_operand:DI 2 "uns_arith_operand" "d,K,d")))]
3172 "TARGET_64BIT && TARGET_MIPS16"
3177 [(set_attr "type" "arith")
3178 (set_attr "mode" "DI")
3179 (set_attr_alternative "length"
3181 (if_then_else (match_operand:VOID 2 "m16_uimm8_1" "")
3186 (define_insn "*norsi3"
3187 [(set (match_operand:SI 0 "register_operand" "=d")
3188 (and:SI (not:SI (match_operand:SI 1 "register_operand" "d"))
3189 (not:SI (match_operand:SI 2 "register_operand" "d"))))]
3192 [(set_attr "type" "arith")
3193 (set_attr "mode" "SI")])
3195 (define_insn "*nordi3"
3196 [(set (match_operand:DI 0 "register_operand" "=d")
3197 (and:DI (not:DI (match_operand:DI 1 "register_operand" "d"))
3198 (not:DI (match_operand:DI 2 "register_operand" "d"))))]
3199 "TARGET_64BIT && !TARGET_MIPS16"
3201 [(set_attr "type" "darith")
3202 (set_attr "mode" "DI")])
3205 ;; ....................
3209 ;; ....................
3213 (define_insn "truncdfsf2"
3214 [(set (match_operand:SF 0 "register_operand" "=f")
3215 (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
3216 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
3218 [(set_attr "type" "fcvt")
3219 (set_attr "mode" "SF")])
3221 ;; Integer truncation patterns. Truncating SImode values to smaller
3222 ;; modes is a no-op, as it is for most other GCC ports. Truncating
3223 ;; DImode values to SImode is not a no-op for TARGET_64BIT since we
3224 ;; need to make sure that the lower 32 bits are properly sign-extended
3225 ;; (see TRULY_NOOP_TRUNCATION). Truncating DImode values into modes
3226 ;; smaller than SImode is equivalent to two separate truncations:
3229 ;; DI ---> HI == DI ---> SI ---> HI
3230 ;; DI ---> QI == DI ---> SI ---> QI
3232 ;; Step A needs a real instruction but step B does not.
3234 (define_insn "truncdisi2"
3235 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,m")
3236 (truncate:SI (match_operand:DI 1 "register_operand" "d,d")))]
3241 [(set_attr "type" "darith,store")
3242 (set_attr "mode" "SI")
3243 (set_attr "extended_mips16" "yes,*")])
3245 (define_insn "truncdihi2"
3246 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,m")
3247 (truncate:HI (match_operand:DI 1 "register_operand" "d,d")))]
3252 [(set_attr "type" "darith,store")
3253 (set_attr "mode" "SI")
3254 (set_attr "extended_mips16" "yes,*")])
3256 (define_insn "truncdiqi2"
3257 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,m")
3258 (truncate:QI (match_operand:DI 1 "register_operand" "d,d")))]
3263 [(set_attr "type" "darith,store")
3264 (set_attr "mode" "SI")
3265 (set_attr "extended_mips16" "yes,*")])
3267 ;; Combiner patterns to optimize shift/truncate combinations.
3270 [(set (match_operand:SI 0 "register_operand" "=d")
3271 (truncate:SI (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
3272 (match_operand:DI 2 "small_int" "I"))))]
3273 "TARGET_64BIT && !TARGET_MIPS16 && INTVAL (operands[2]) >= 32"
3275 [(set_attr "type" "darith")
3276 (set_attr "mode" "SI")])
3279 [(set (match_operand:SI 0 "register_operand" "=d")
3280 (truncate:SI (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
3282 "TARGET_64BIT && !TARGET_MIPS16"
3284 [(set_attr "type" "darith")
3285 (set_attr "mode" "SI")])
3288 ;; Combiner patterns for truncate/sign_extend combinations. They use
3289 ;; the shift/truncate patterns above.
3291 (define_insn_and_split ""
3292 [(set (match_operand:SI 0 "register_operand" "=d")
3294 (truncate:HI (match_operand:DI 1 "register_operand" "d"))))]
3295 "TARGET_64BIT && !TARGET_MIPS16"
3297 "&& reload_completed"
3299 (ashift:DI (match_dup 1)
3302 (truncate:SI (ashiftrt:DI (match_dup 2)
3304 { operands[2] = gen_lowpart (DImode, operands[0]); })
3306 (define_insn_and_split ""
3307 [(set (match_operand:SI 0 "register_operand" "=d")
3309 (truncate:QI (match_operand:DI 1 "register_operand" "d"))))]
3310 "TARGET_64BIT && !TARGET_MIPS16"
3312 "&& reload_completed"
3314 (ashift:DI (match_dup 1)
3317 (truncate:SI (ashiftrt:DI (match_dup 2)
3319 { operands[2] = gen_lowpart (DImode, operands[0]); })
3322 ;; Combiner patterns to optimize truncate/zero_extend combinations.
3325 [(set (match_operand:SI 0 "register_operand" "=d")
3326 (zero_extend:SI (truncate:HI
3327 (match_operand:DI 1 "register_operand" "d"))))]
3328 "TARGET_64BIT && !TARGET_MIPS16"
3329 "andi\t%0,%1,0xffff"
3330 [(set_attr "type" "darith")
3331 (set_attr "mode" "SI")])
3334 [(set (match_operand:SI 0 "register_operand" "=d")
3335 (zero_extend:SI (truncate:QI
3336 (match_operand:DI 1 "register_operand" "d"))))]
3337 "TARGET_64BIT && !TARGET_MIPS16"
3339 [(set_attr "type" "darith")
3340 (set_attr "mode" "SI")])
3343 [(set (match_operand:HI 0 "register_operand" "=d")
3344 (zero_extend:HI (truncate:QI
3345 (match_operand:DI 1 "register_operand" "d"))))]
3346 "TARGET_64BIT && !TARGET_MIPS16"
3348 [(set_attr "type" "darith")
3349 (set_attr "mode" "HI")])
3352 ;; ....................
3356 ;; ....................
3359 ;; Those for integer source operand are ordered widest source type first.
3361 (define_insn_and_split "zero_extendsidi2"
3362 [(set (match_operand:DI 0 "register_operand" "=d")
3363 (zero_extend:DI (match_operand:SI 1 "register_operand" "d")))]
3366 "&& reload_completed"
3368 (ashift:DI (match_dup 1) (const_int 32)))
3370 (lshiftrt:DI (match_dup 0) (const_int 32)))]
3371 "operands[1] = gen_lowpart (DImode, operands[1]);"
3372 [(set_attr "type" "arith")
3373 (set_attr "mode" "DI")])
3375 (define_insn "*zero_extendsidi2_mem"
3376 [(set (match_operand:DI 0 "register_operand" "=d")
3377 (zero_extend:DI (match_operand:SI 1 "memory_operand" "W")))]
3380 [(set_attr "type" "load")
3381 (set_attr "mode" "DI")])
3383 (define_expand "zero_extendhisi2"
3384 [(set (match_operand:SI 0 "register_operand" "")
3385 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
3388 if (TARGET_MIPS16 && GET_CODE (operands[1]) != MEM)
3390 rtx op = gen_lowpart (SImode, operands[1]);
3391 rtx temp = force_reg (SImode, GEN_INT (0xffff));
3393 emit_insn (gen_andsi3 (operands[0], op, temp));
3399 [(set (match_operand:SI 0 "register_operand" "=d,d")
3400 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "d,m")))]
3405 [(set_attr "type" "arith,load")
3406 (set_attr "mode" "SI")
3407 (set_attr "length" "4,*")])
3410 [(set (match_operand:SI 0 "register_operand" "=d")
3411 (zero_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
3414 [(set_attr "type" "load")
3415 (set_attr "mode" "SI")])
3417 (define_expand "zero_extendhidi2"
3418 [(set (match_operand:DI 0 "register_operand" "")
3419 (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "")))]
3422 if (TARGET_MIPS16 && GET_CODE (operands[1]) != MEM)
3424 rtx op = gen_lowpart (DImode, operands[1]);
3425 rtx temp = force_reg (DImode, GEN_INT (0xffff));
3427 emit_insn (gen_anddi3 (operands[0], op, temp));
3433 [(set (match_operand:DI 0 "register_operand" "=d,d")
3434 (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "d,m")))]
3435 "TARGET_64BIT && !TARGET_MIPS16"
3439 [(set_attr "type" "arith,load")
3440 (set_attr "mode" "DI")
3441 (set_attr "length" "4,*")])
3444 [(set (match_operand:DI 0 "register_operand" "=d")
3445 (zero_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
3446 "TARGET_64BIT && TARGET_MIPS16"
3448 [(set_attr "type" "load")
3449 (set_attr "mode" "DI")])
3451 (define_expand "zero_extendqihi2"
3452 [(set (match_operand:HI 0 "register_operand" "")
3453 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))]
3456 if (TARGET_MIPS16 && GET_CODE (operands[1]) != MEM)
3458 rtx op0 = gen_lowpart (SImode, operands[0]);
3459 rtx op1 = gen_lowpart (SImode, operands[1]);
3460 rtx temp = force_reg (SImode, GEN_INT (0xff));
3462 emit_insn (gen_andsi3 (op0, op1, temp));
3468 [(set (match_operand:HI 0 "register_operand" "=d,d")
3469 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
3474 [(set_attr "type" "arith,load")
3475 (set_attr "mode" "HI")
3476 (set_attr "length" "4,*")])
3479 [(set (match_operand:HI 0 "register_operand" "=d")
3480 (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
3483 [(set_attr "type" "load")
3484 (set_attr "mode" "HI")])
3486 (define_expand "zero_extendqisi2"
3487 [(set (match_operand:SI 0 "register_operand" "")
3488 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
3491 if (TARGET_MIPS16 && GET_CODE (operands[1]) != MEM)
3493 rtx op = gen_lowpart (SImode, operands[1]);
3494 rtx temp = force_reg (SImode, GEN_INT (0xff));
3496 emit_insn (gen_andsi3 (operands[0], op, temp));
3502 [(set (match_operand:SI 0 "register_operand" "=d,d")
3503 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
3508 [(set_attr "type" "arith,load")
3509 (set_attr "mode" "SI")
3510 (set_attr "length" "4,*")])
3513 [(set (match_operand:SI 0 "register_operand" "=d")
3514 (zero_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
3517 [(set_attr "type" "load")
3518 (set_attr "mode" "SI")])
3520 (define_expand "zero_extendqidi2"
3521 [(set (match_operand:DI 0 "register_operand" "")
3522 (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "")))]
3525 if (TARGET_MIPS16 && GET_CODE (operands[1]) != MEM)
3527 rtx op = gen_lowpart (DImode, operands[1]);
3528 rtx temp = force_reg (DImode, GEN_INT (0xff));
3530 emit_insn (gen_anddi3 (operands[0], op, temp));
3536 [(set (match_operand:DI 0 "register_operand" "=d,d")
3537 (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
3538 "TARGET_64BIT && !TARGET_MIPS16"
3542 [(set_attr "type" "arith,load")
3543 (set_attr "mode" "DI")
3544 (set_attr "length" "4,*")])
3547 [(set (match_operand:DI 0 "register_operand" "=d")
3548 (zero_extend:DI (match_operand:QI 1 "memory_operand" "m")))]
3549 "TARGET_64BIT && TARGET_MIPS16"
3551 [(set_attr "type" "load")
3552 (set_attr "mode" "DI")])
3555 ;; ....................
3559 ;; ....................
3562 ;; Those for integer source operand are ordered widest source type first.
3564 (define_insn "extendsidi2"
3565 [(set (match_operand:DI 0 "register_operand" "=d,d")
3566 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m")))]
3571 [(set_attr "type" "arith,load")
3572 (set_attr "mode" "DI")
3573 (set_attr "extended_mips16" "yes,*")])
3575 ;; These patterns originally accepted general_operands, however, slightly
3576 ;; better code is generated by only accepting register_operands, and then
3577 ;; letting combine generate the lh and lb insns.
3579 ;; These expanders originally put values in registers first. We split
3580 ;; all non-mem patterns after reload.
3582 (define_expand "extendhidi2"
3583 [(set (match_operand:DI 0 "register_operand" "")
3584 (sign_extend:DI (match_operand:HI 1 "nonimmediate_operand" "")))]
3588 (define_insn "*extendhidi2"
3589 [(set (match_operand:DI 0 "register_operand" "=d")
3590 (sign_extend:DI (match_operand:HI 1 "register_operand" "d")))]
3595 [(set (match_operand:DI 0 "register_operand" "")
3596 (sign_extend:DI (match_operand:HI 1 "register_operand" "")))]
3597 "TARGET_64BIT && reload_completed"
3599 (ashift:DI (match_dup 1) (const_int 48)))
3601 (ashiftrt:DI (match_dup 0) (const_int 48)))]
3602 "operands[1] = gen_lowpart (DImode, operands[1]);")
3604 (define_insn "*extendhidi2_mem"
3605 [(set (match_operand:DI 0 "register_operand" "=d")
3606 (sign_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
3609 [(set_attr "type" "load")
3610 (set_attr "mode" "DI")])
3612 (define_expand "extendhisi2"
3613 [(set (match_operand:SI 0 "register_operand" "")
3614 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
3617 if (ISA_HAS_SEB_SEH)
3619 emit_insn (gen_extendhisi2_hw (operands[0],
3620 force_reg (HImode, operands[1])));
3625 (define_insn "*extendhisi2"
3626 [(set (match_operand:SI 0 "register_operand" "=d")
3627 (sign_extend:SI (match_operand:HI 1 "register_operand" "d")))]
3632 [(set (match_operand:SI 0 "register_operand" "")
3633 (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
3636 (ashift:SI (match_dup 1) (const_int 16)))
3638 (ashiftrt:SI (match_dup 0) (const_int 16)))]
3639 "operands[1] = gen_lowpart (SImode, operands[1]);")
3641 (define_insn "extendhisi2_mem"
3642 [(set (match_operand:SI 0 "register_operand" "=d")
3643 (sign_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
3646 [(set_attr "type" "load")
3647 (set_attr "mode" "SI")])
3649 (define_insn "extendhisi2_hw"
3650 [(set (match_operand:SI 0 "register_operand" "=r")
3651 (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
3654 [(set_attr "type" "arith")
3655 (set_attr "mode" "SI")])
3657 (define_expand "extendqihi2"
3658 [(set (match_operand:HI 0 "register_operand" "")
3659 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))]
3663 (define_insn "*extendqihi2"
3664 [(set (match_operand:HI 0 "register_operand" "=d")
3665 (sign_extend:HI (match_operand:QI 1 "register_operand" "d")))]
3670 [(set (match_operand:HI 0 "register_operand" "")
3671 (sign_extend:HI (match_operand:QI 1 "register_operand" "")))]
3674 (ashift:SI (match_dup 1) (const_int 24)))
3676 (ashiftrt:SI (match_dup 0) (const_int 24)))]
3677 "operands[0] = gen_lowpart (SImode, operands[0]);
3678 operands[1] = gen_lowpart (SImode, operands[1]);")
3680 (define_insn "*extendqihi2_internal_mem"
3681 [(set (match_operand:HI 0 "register_operand" "=d")
3682 (sign_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
3685 [(set_attr "type" "load")
3686 (set_attr "mode" "SI")])
3689 (define_expand "extendqisi2"
3690 [(set (match_operand:SI 0 "register_operand" "")
3691 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
3694 if (ISA_HAS_SEB_SEH)
3696 emit_insn (gen_extendqisi2_hw (operands[0],
3697 force_reg (QImode, operands[1])));
3702 (define_insn "*extendqisi2"
3703 [(set (match_operand:SI 0 "register_operand" "=d")
3704 (sign_extend:SI (match_operand:QI 1 "register_operand" "d")))]
3709 [(set (match_operand:SI 0 "register_operand" "")
3710 (sign_extend:SI (match_operand:QI 1 "register_operand" "")))]
3713 (ashift:SI (match_dup 1) (const_int 24)))
3715 (ashiftrt:SI (match_dup 0) (const_int 24)))]
3716 "operands[1] = gen_lowpart (SImode, operands[1]);")
3718 (define_insn "*extendqisi2_mem"
3719 [(set (match_operand:SI 0 "register_operand" "=d")
3720 (sign_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
3723 [(set_attr "type" "load")
3724 (set_attr "mode" "SI")])
3726 (define_insn "extendqisi2_hw"
3727 [(set (match_operand:SI 0 "register_operand" "=r")
3728 (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
3731 [(set_attr "type" "arith")
3732 (set_attr "mode" "SI")])
3734 (define_expand "extendqidi2"
3735 [(set (match_operand:DI 0 "register_operand" "")
3736 (sign_extend:DI (match_operand:QI 1 "nonimmediate_operand" "")))]
3740 (define_insn "*extendqidi2"
3741 [(set (match_operand:DI 0 "register_operand" "=d")
3742 (sign_extend:DI (match_operand:QI 1 "register_operand" "d")))]
3747 [(set (match_operand:DI 0 "register_operand" "")
3748 (sign_extend:DI (match_operand:QI 1 "register_operand" "")))]
3749 "TARGET_64BIT && reload_completed"
3751 (ashift:DI (match_dup 1) (const_int 56)))
3753 (ashiftrt:DI (match_dup 0) (const_int 56)))]
3754 "operands[1] = gen_lowpart (DImode, operands[1]);")
3756 (define_insn "*extendqidi2_mem"
3757 [(set (match_operand:DI 0 "register_operand" "=d")
3758 (sign_extend:DI (match_operand:QI 1 "memory_operand" "m")))]
3761 [(set_attr "type" "load")
3762 (set_attr "mode" "DI")])
3764 (define_insn "extendsfdf2"
3765 [(set (match_operand:DF 0 "register_operand" "=f")
3766 (float_extend:DF (match_operand:SF 1 "register_operand" "f")))]
3767 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
3769 [(set_attr "type" "fcvt")
3770 (set_attr "mode" "DF")])
3773 ;; ....................
3777 ;; ....................
3779 (define_expand "fix_truncdfsi2"
3780 [(set (match_operand:SI 0 "register_operand" "=f")
3781 (fix:SI (match_operand:DF 1 "register_operand" "f")))]
3782 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
3784 if (!ISA_HAS_TRUNC_W)
3786 emit_insn (gen_fix_truncdfsi2_macro (operands[0], operands[1]));
3791 (define_insn "fix_truncdfsi2_insn"
3792 [(set (match_operand:SI 0 "register_operand" "=f")
3793 (fix:SI (match_operand:DF 1 "register_operand" "f")))]
3794 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && ISA_HAS_TRUNC_W"
3796 [(set_attr "type" "fcvt")
3797 (set_attr "mode" "DF")
3798 (set_attr "length" "4")])
3800 (define_insn "fix_truncdfsi2_macro"
3801 [(set (match_operand:SI 0 "register_operand" "=f")
3802 (fix:SI (match_operand:DF 1 "register_operand" "f")))
3803 (clobber (match_scratch:DF 2 "=d"))]
3804 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !ISA_HAS_TRUNC_W"
3807 return ".set\tmacro\;trunc.w.d %0,%1,%2\;.set\tnomacro";
3809 return "trunc.w.d %0,%1,%2";
3811 [(set_attr "type" "fcvt")
3812 (set_attr "mode" "DF")
3813 (set_attr "length" "36")])
3815 (define_expand "fix_truncsfsi2"
3816 [(set (match_operand:SI 0 "register_operand" "=f")
3817 (fix:SI (match_operand:SF 1 "register_operand" "f")))]
3820 if (!ISA_HAS_TRUNC_W)
3822 emit_insn (gen_fix_truncsfsi2_macro (operands[0], operands[1]));
3827 (define_insn "fix_truncsfsi2_insn"
3828 [(set (match_operand:SI 0 "register_operand" "=f")
3829 (fix:SI (match_operand:SF 1 "register_operand" "f")))]
3830 "TARGET_HARD_FLOAT && ISA_HAS_TRUNC_W"
3832 [(set_attr "type" "fcvt")
3833 (set_attr "mode" "DF")
3834 (set_attr "length" "4")])
3836 (define_insn "fix_truncsfsi2_macro"
3837 [(set (match_operand:SI 0 "register_operand" "=f")
3838 (fix:SI (match_operand:SF 1 "register_operand" "f")))
3839 (clobber (match_scratch:SF 2 "=d"))]
3840 "TARGET_HARD_FLOAT && !ISA_HAS_TRUNC_W"
3843 return ".set\tmacro\;trunc.w.s %0,%1,%2\;.set\tnomacro";
3845 return "trunc.w.s %0,%1,%2";
3847 [(set_attr "type" "fcvt")
3848 (set_attr "mode" "DF")
3849 (set_attr "length" "36")])
3852 (define_insn "fix_truncdfdi2"
3853 [(set (match_operand:DI 0 "register_operand" "=f")
3854 (fix:DI (match_operand:DF 1 "register_operand" "f")))]
3855 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
3857 [(set_attr "type" "fcvt")
3858 (set_attr "mode" "DF")
3859 (set_attr "length" "4")])
3862 (define_insn "fix_truncsfdi2"
3863 [(set (match_operand:DI 0 "register_operand" "=f")
3864 (fix:DI (match_operand:SF 1 "register_operand" "f")))]
3865 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
3867 [(set_attr "type" "fcvt")
3868 (set_attr "mode" "SF")
3869 (set_attr "length" "4")])
3872 (define_insn "floatsidf2"
3873 [(set (match_operand:DF 0 "register_operand" "=f")
3874 (float:DF (match_operand:SI 1 "register_operand" "f")))]
3875 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
3877 [(set_attr "type" "fcvt")
3878 (set_attr "mode" "DF")
3879 (set_attr "length" "4")])
3882 (define_insn "floatdidf2"
3883 [(set (match_operand:DF 0 "register_operand" "=f")
3884 (float:DF (match_operand:DI 1 "register_operand" "f")))]
3885 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
3887 [(set_attr "type" "fcvt")
3888 (set_attr "mode" "DF")
3889 (set_attr "length" "4")])
3892 (define_insn "floatsisf2"
3893 [(set (match_operand:SF 0 "register_operand" "=f")
3894 (float:SF (match_operand:SI 1 "register_operand" "f")))]
3897 [(set_attr "type" "fcvt")
3898 (set_attr "mode" "SF")
3899 (set_attr "length" "4")])
3902 (define_insn "floatdisf2"
3903 [(set (match_operand:SF 0 "register_operand" "=f")
3904 (float:SF (match_operand:DI 1 "register_operand" "f")))]
3905 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
3907 [(set_attr "type" "fcvt")
3908 (set_attr "mode" "SF")
3909 (set_attr "length" "4")])
3912 (define_expand "fixuns_truncdfsi2"
3913 [(set (match_operand:SI 0 "register_operand" "")
3914 (unsigned_fix:SI (match_operand:DF 1 "register_operand" "")))]
3915 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
3917 rtx reg1 = gen_reg_rtx (DFmode);
3918 rtx reg2 = gen_reg_rtx (DFmode);
3919 rtx reg3 = gen_reg_rtx (SImode);
3920 rtx label1 = gen_label_rtx ();
3921 rtx label2 = gen_label_rtx ();
3922 REAL_VALUE_TYPE offset;
3924 real_2expN (&offset, 31);
3926 if (reg1) /* Turn off complaints about unreached code. */
3928 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, DFmode));
3929 do_pending_stack_adjust ();
3931 emit_insn (gen_cmpdf (operands[1], reg1));
3932 emit_jump_insn (gen_bge (label1));
3934 emit_insn (gen_fix_truncdfsi2 (operands[0], operands[1]));
3935 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
3936 gen_rtx_LABEL_REF (VOIDmode, label2)));
3939 emit_label (label1);
3940 emit_move_insn (reg2, gen_rtx_MINUS (DFmode, operands[1], reg1));
3941 emit_move_insn (reg3, GEN_INT (trunc_int_for_mode
3942 (BITMASK_HIGH, SImode)));
3944 emit_insn (gen_fix_truncdfsi2 (operands[0], reg2));
3945 emit_insn (gen_iorsi3 (operands[0], operands[0], reg3));
3947 emit_label (label2);
3949 /* Allow REG_NOTES to be set on last insn (labels don't have enough
3950 fields, and can't be used for REG_NOTES anyway). */
3951 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
3957 (define_expand "fixuns_truncdfdi2"
3958 [(set (match_operand:DI 0 "register_operand" "")
3959 (unsigned_fix:DI (match_operand:DF 1 "register_operand" "")))]
3960 "TARGET_HARD_FLOAT && TARGET_64BIT && TARGET_DOUBLE_FLOAT"
3962 rtx reg1 = gen_reg_rtx (DFmode);
3963 rtx reg2 = gen_reg_rtx (DFmode);
3964 rtx reg3 = gen_reg_rtx (DImode);
3965 rtx label1 = gen_label_rtx ();
3966 rtx label2 = gen_label_rtx ();
3967 REAL_VALUE_TYPE offset;
3969 real_2expN (&offset, 63);
3971 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, DFmode));
3972 do_pending_stack_adjust ();
3974 emit_insn (gen_cmpdf (operands[1], reg1));
3975 emit_jump_insn (gen_bge (label1));
3977 emit_insn (gen_fix_truncdfdi2 (operands[0], operands[1]));
3978 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
3979 gen_rtx_LABEL_REF (VOIDmode, label2)));
3982 emit_label (label1);
3983 emit_move_insn (reg2, gen_rtx_MINUS (DFmode, operands[1], reg1));
3984 emit_move_insn (reg3, GEN_INT (BITMASK_HIGH));
3985 emit_insn (gen_ashldi3 (reg3, reg3, GEN_INT (32)));
3987 emit_insn (gen_fix_truncdfdi2 (operands[0], reg2));
3988 emit_insn (gen_iordi3 (operands[0], operands[0], reg3));
3990 emit_label (label2);
3992 /* Allow REG_NOTES to be set on last insn (labels don't have enough
3993 fields, and can't be used for REG_NOTES anyway). */
3994 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
3999 (define_expand "fixuns_truncsfsi2"
4000 [(set (match_operand:SI 0 "register_operand" "")
4001 (unsigned_fix:SI (match_operand:SF 1 "register_operand" "")))]
4004 rtx reg1 = gen_reg_rtx (SFmode);
4005 rtx reg2 = gen_reg_rtx (SFmode);
4006 rtx reg3 = gen_reg_rtx (SImode);
4007 rtx label1 = gen_label_rtx ();
4008 rtx label2 = gen_label_rtx ();
4009 REAL_VALUE_TYPE offset;
4011 real_2expN (&offset, 31);
4013 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, SFmode));
4014 do_pending_stack_adjust ();
4016 emit_insn (gen_cmpsf (operands[1], reg1));
4017 emit_jump_insn (gen_bge (label1));
4019 emit_insn (gen_fix_truncsfsi2 (operands[0], operands[1]));
4020 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
4021 gen_rtx_LABEL_REF (VOIDmode, label2)));
4024 emit_label (label1);
4025 emit_move_insn (reg2, gen_rtx_MINUS (SFmode, operands[1], reg1));
4026 emit_move_insn (reg3, GEN_INT (trunc_int_for_mode
4027 (BITMASK_HIGH, SImode)));
4029 emit_insn (gen_fix_truncsfsi2 (operands[0], reg2));
4030 emit_insn (gen_iorsi3 (operands[0], operands[0], reg3));
4032 emit_label (label2);
4034 /* Allow REG_NOTES to be set on last insn (labels don't have enough
4035 fields, and can't be used for REG_NOTES anyway). */
4036 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
4041 (define_expand "fixuns_truncsfdi2"
4042 [(set (match_operand:DI 0 "register_operand" "")
4043 (unsigned_fix:DI (match_operand:SF 1 "register_operand" "")))]
4044 "TARGET_HARD_FLOAT && TARGET_64BIT && TARGET_DOUBLE_FLOAT"
4046 rtx reg1 = gen_reg_rtx (SFmode);
4047 rtx reg2 = gen_reg_rtx (SFmode);
4048 rtx reg3 = gen_reg_rtx (DImode);
4049 rtx label1 = gen_label_rtx ();
4050 rtx label2 = gen_label_rtx ();
4051 REAL_VALUE_TYPE offset;
4053 real_2expN (&offset, 63);
4055 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, SFmode));
4056 do_pending_stack_adjust ();
4058 emit_insn (gen_cmpsf (operands[1], reg1));
4059 emit_jump_insn (gen_bge (label1));
4061 emit_insn (gen_fix_truncsfdi2 (operands[0], operands[1]));
4062 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
4063 gen_rtx_LABEL_REF (VOIDmode, label2)));
4066 emit_label (label1);
4067 emit_move_insn (reg2, gen_rtx_MINUS (SFmode, operands[1], reg1));
4068 emit_move_insn (reg3, GEN_INT (BITMASK_HIGH));
4069 emit_insn (gen_ashldi3 (reg3, reg3, GEN_INT (32)));
4071 emit_insn (gen_fix_truncsfdi2 (operands[0], reg2));
4072 emit_insn (gen_iordi3 (operands[0], operands[0], reg3));
4074 emit_label (label2);
4076 /* Allow REG_NOTES to be set on last insn (labels don't have enough
4077 fields, and can't be used for REG_NOTES anyway). */
4078 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
4083 ;; ....................
4087 ;; ....................
4089 ;; Bit field extract patterns which use lwl/lwr or ldl/ldr.
4091 (define_expand "extv"
4092 [(set (match_operand 0 "register_operand" "")
4093 (sign_extract (match_operand:QI 1 "memory_operand" "")
4094 (match_operand 2 "immediate_operand" "")
4095 (match_operand 3 "immediate_operand" "")))]
4098 if (mips_expand_unaligned_load (operands[0], operands[1],
4099 INTVAL (operands[2]),
4100 INTVAL (operands[3])))
4106 (define_expand "extzv"
4107 [(set (match_operand 0 "register_operand" "")
4108 (zero_extract (match_operand:QI 1 "memory_operand" "")
4109 (match_operand 2 "immediate_operand" "")
4110 (match_operand 3 "immediate_operand" "")))]
4113 if (mips_expand_unaligned_load (operands[0], operands[1],
4114 INTVAL (operands[2]),
4115 INTVAL (operands[3])))
4121 (define_expand "insv"
4122 [(set (zero_extract (match_operand:QI 0 "memory_operand" "")
4123 (match_operand 1 "immediate_operand" "")
4124 (match_operand 2 "immediate_operand" ""))
4125 (match_operand 3 "reg_or_0_operand" ""))]
4128 if (mips_expand_unaligned_store (operands[0], operands[3],
4129 INTVAL (operands[1]),
4130 INTVAL (operands[2])))
4136 ;; Unaligned word moves generated by the bit field patterns.
4138 ;; As far as the rtl is concerned, both the left-part and right-part
4139 ;; instructions can access the whole field. However, the real operand
4140 ;; refers to just the first or the last byte (depending on endianness).
4141 ;; We therefore use two memory operands to each instruction, one to
4142 ;; describe the rtl effect and one to use in the assembly output.
4144 ;; Operands 0 and 1 are the rtl-level target and source respectively.
4145 ;; This allows us to use the standard length calculations for the "load"
4146 ;; and "store" type attributes.
4148 (define_insn "mov_lwl"
4149 [(set (match_operand:SI 0 "register_operand" "=d")
4150 (unspec:SI [(match_operand:BLK 1 "memory_operand" "m")
4151 (match_operand:QI 2 "memory_operand" "m")]
4155 [(set_attr "type" "load")
4156 (set_attr "mode" "SI")
4157 (set_attr "hazard" "none")])
4159 (define_insn "mov_lwr"
4160 [(set (match_operand:SI 0 "register_operand" "=d")
4161 (unspec:SI [(match_operand:BLK 1 "memory_operand" "m")
4162 (match_operand:QI 2 "memory_operand" "m")
4163 (match_operand:SI 3 "register_operand" "0")]
4167 [(set_attr "type" "load")
4168 (set_attr "mode" "SI")])
4171 (define_insn "mov_swl"
4172 [(set (match_operand:BLK 0 "memory_operand" "=m")
4173 (unspec:BLK [(match_operand:SI 1 "reg_or_0_operand" "dJ")
4174 (match_operand:QI 2 "memory_operand" "m")]
4178 [(set_attr "type" "store")
4179 (set_attr "mode" "SI")])
4181 (define_insn "mov_swr"
4182 [(set (match_operand:BLK 0 "memory_operand" "+m")
4183 (unspec:BLK [(match_operand:SI 1 "reg_or_0_operand" "dJ")
4184 (match_operand:QI 2 "memory_operand" "m")
4189 [(set_attr "type" "store")
4190 (set_attr "mode" "SI")])
4193 (define_insn "mov_ldl"
4194 [(set (match_operand:DI 0 "register_operand" "=d")
4195 (unspec:DI [(match_operand:BLK 1 "memory_operand" "m")
4196 (match_operand:QI 2 "memory_operand" "m")]
4198 "TARGET_64BIT && !TARGET_MIPS16"
4200 [(set_attr "type" "load")
4201 (set_attr "mode" "DI")])
4203 (define_insn "mov_ldr"
4204 [(set (match_operand:DI 0 "register_operand" "=d")
4205 (unspec:DI [(match_operand:BLK 1 "memory_operand" "m")
4206 (match_operand:QI 2 "memory_operand" "m")
4207 (match_operand:DI 3 "register_operand" "0")]
4209 "TARGET_64BIT && !TARGET_MIPS16"
4211 [(set_attr "type" "load")
4212 (set_attr "mode" "DI")])
4215 (define_insn "mov_sdl"
4216 [(set (match_operand:BLK 0 "memory_operand" "=m")
4217 (unspec:BLK [(match_operand:DI 1 "reg_or_0_operand" "dJ")
4218 (match_operand:QI 2 "memory_operand" "m")]
4220 "TARGET_64BIT && !TARGET_MIPS16"
4222 [(set_attr "type" "store")
4223 (set_attr "mode" "DI")])
4225 (define_insn "mov_sdr"
4226 [(set (match_operand:BLK 0 "memory_operand" "+m")
4227 (unspec:BLK [(match_operand:DI 1 "reg_or_0_operand" "dJ")
4228 (match_operand:QI 2 "memory_operand" "m")
4231 "TARGET_64BIT && !TARGET_MIPS16"
4233 [(set_attr "type" "store")
4234 (set_attr "mode" "DI")])
4236 ;; An instruction to calculate the high part of a 64-bit SYMBOL_GENERAL.
4237 ;; The required value is:
4239 ;; (%highest(op1) << 48) + (%higher(op1) << 32) + (%hi(op1) << 16)
4241 ;; which translates to:
4243 ;; lui op0,%highest(op1)
4244 ;; daddiu op0,op0,%higher(op1)
4246 ;; daddiu op0,op0,%hi(op1)
4248 (define_insn_and_split "*lea_high64"
4249 [(set (match_operand:DI 0 "register_operand" "=d")
4250 (high:DI (match_operand:DI 1 "general_symbolic_operand" "")))]
4251 "TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS"
4253 "&& reload_completed"
4254 [(set (match_dup 0) (high:DI (match_dup 2)))
4255 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 2)))
4256 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 16)))
4257 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 3)))
4258 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 16)))]
4260 operands[2] = mips_unspec_address (operands[1], SYMBOL_64_HIGH);
4261 operands[3] = mips_unspec_address (operands[1], SYMBOL_64_MID);
4263 [(set_attr "length" "20")])
4265 ;; On most targets, the expansion of (lo_sum (high X) X) for a 64-bit
4266 ;; SYMBOL_GENERAL X will take 6 cycles. This next pattern allows combine
4267 ;; to merge the HIGH and LO_SUM parts of a move if the HIGH part is only
4268 ;; used once. We can then use the sequence:
4270 ;; lui op0,%highest(op1)
4272 ;; daddiu op0,op0,%higher(op1)
4273 ;; daddiu op2,op2,%lo(op1)
4275 ;; daddu op0,op0,op2
4277 ;; which takes 4 cycles on most superscalar targets.
4278 (define_insn_and_split "*lea64"
4279 [(set (match_operand:DI 0 "register_operand" "=d")
4280 (match_operand:DI 1 "general_symbolic_operand" ""))
4281 (clobber (match_scratch:DI 2 "=&d"))]
4282 "TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS && cse_not_expected"
4284 "&& reload_completed"
4285 [(set (match_dup 0) (high:DI (match_dup 3)))
4286 (set (match_dup 2) (high:DI (match_dup 4)))
4287 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 3)))
4288 (set (match_dup 2) (lo_sum:DI (match_dup 2) (match_dup 4)))
4289 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
4290 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))]
4292 operands[3] = mips_unspec_address (operands[1], SYMBOL_64_HIGH);
4293 operands[4] = mips_unspec_address (operands[1], SYMBOL_64_LOW);
4295 [(set_attr "length" "24")])
4297 ;; Insns to fetch a global symbol from a big GOT.
4299 (define_insn_and_split "*xgot_hisi"
4300 [(set (match_operand:SI 0 "register_operand" "=d")
4301 (high:SI (match_operand:SI 1 "global_got_operand" "")))]
4302 "TARGET_EXPLICIT_RELOCS && TARGET_XGOT"
4304 "&& reload_completed"
4305 [(set (match_dup 0) (high:SI (match_dup 2)))
4306 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 3)))]
4308 operands[2] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_GLOBAL);
4309 operands[3] = pic_offset_table_rtx;
4311 [(set_attr "got" "xgot_high")])
4313 (define_insn_and_split "*xgot_losi"
4314 [(set (match_operand:SI 0 "register_operand" "=d")
4315 (lo_sum:SI (match_operand:SI 1 "register_operand" "d")
4316 (match_operand:SI 2 "global_got_operand" "")))]
4317 "TARGET_EXPLICIT_RELOCS && TARGET_XGOT"
4319 "&& reload_completed"
4321 (unspec:SI [(match_dup 1) (match_dup 3)] UNSPEC_LOAD_GOT))]
4322 { operands[3] = mips_unspec_address (operands[2], SYMBOL_GOTOFF_GLOBAL); }
4323 [(set_attr "got" "load")])
4325 (define_insn_and_split "*xgot_hidi"
4326 [(set (match_operand:DI 0 "register_operand" "=d")
4327 (high:DI (match_operand:DI 1 "global_got_operand" "")))]
4328 "TARGET_EXPLICIT_RELOCS && TARGET_XGOT"
4330 "&& reload_completed"
4331 [(set (match_dup 0) (high:DI (match_dup 2)))
4332 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
4334 operands[2] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_GLOBAL);
4335 operands[3] = pic_offset_table_rtx;
4337 [(set_attr "got" "xgot_high")])
4339 (define_insn_and_split "*xgot_lodi"
4340 [(set (match_operand:DI 0 "register_operand" "=d")
4341 (lo_sum:DI (match_operand:DI 1 "register_operand" "d")
4342 (match_operand:DI 2 "global_got_operand" "")))]
4343 "TARGET_EXPLICIT_RELOCS && TARGET_XGOT"
4345 "&& reload_completed"
4347 (unspec:DI [(match_dup 1) (match_dup 3)] UNSPEC_LOAD_GOT))]
4348 { operands[3] = mips_unspec_address (operands[2], SYMBOL_GOTOFF_GLOBAL); }
4349 [(set_attr "got" "load")])
4351 ;; Insns to fetch a global symbol from a normal GOT.
4353 (define_insn_and_split "*got_dispsi"
4354 [(set (match_operand:SI 0 "register_operand" "=d")
4355 (match_operand:SI 1 "global_got_operand" ""))]
4356 "TARGET_EXPLICIT_RELOCS && !TARGET_XGOT"
4358 "&& reload_completed"
4360 (unspec:SI [(match_dup 2) (match_dup 3)] UNSPEC_LOAD_GOT))]
4362 operands[2] = pic_offset_table_rtx;
4363 operands[3] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_GLOBAL);
4365 [(set_attr "got" "load")])
4367 (define_insn_and_split "*got_dispdi"
4368 [(set (match_operand:DI 0 "register_operand" "=d")
4369 (match_operand:DI 1 "global_got_operand" ""))]
4370 "TARGET_EXPLICIT_RELOCS && !TARGET_XGOT"
4372 "&& reload_completed"
4374 (unspec:DI [(match_dup 2) (match_dup 3)] UNSPEC_LOAD_GOT))]
4376 operands[2] = pic_offset_table_rtx;
4377 operands[3] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_GLOBAL);
4379 [(set_attr "got" "load")])
4381 ;; Insns for loading the high part of a local symbol.
4383 (define_insn_and_split "*got_pagesi"
4384 [(set (match_operand:SI 0 "register_operand" "=d")
4385 (high:SI (match_operand:SI 1 "local_got_operand" "")))]
4386 "TARGET_EXPLICIT_RELOCS"
4388 "&& reload_completed"
4390 (unspec:SI [(match_dup 2) (match_dup 3)] UNSPEC_LOAD_GOT))]
4392 operands[2] = pic_offset_table_rtx;
4393 operands[3] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_PAGE);
4395 [(set_attr "got" "load")])
4397 (define_insn_and_split "*got_pagedi"
4398 [(set (match_operand:DI 0 "register_operand" "=d")
4399 (high:DI (match_operand:DI 1 "local_got_operand" "")))]
4400 "TARGET_EXPLICIT_RELOCS"
4402 "&& reload_completed"
4404 (unspec:DI [(match_dup 2) (match_dup 3)] UNSPEC_LOAD_GOT))]
4406 operands[2] = pic_offset_table_rtx;
4407 operands[3] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_PAGE);
4409 [(set_attr "got" "load")])
4411 ;; Lower-level instructions for loading an address from the GOT.
4412 ;; We could use MEMs, but an unspec gives more optimization
4415 (define_insn "*load_gotsi"
4416 [(set (match_operand:SI 0 "register_operand" "=d")
4417 (unspec:SI [(match_operand:SI 1 "register_operand" "d")
4418 (match_operand:SI 2 "immediate_operand" "")]
4422 [(set_attr "type" "load")
4423 (set_attr "length" "4")])
4425 (define_insn "*load_gotdi"
4426 [(set (match_operand:DI 0 "register_operand" "=d")
4427 (unspec:DI [(match_operand:DI 1 "register_operand" "d")
4428 (match_operand:DI 2 "immediate_operand" "")]
4432 [(set_attr "type" "load")
4433 (set_attr "length" "4")])
4435 ;; Instructions for adding the low 16 bits of an address to a register.
4436 ;; Operand 2 is the address: print_operand works out which relocation
4437 ;; should be applied.
4439 (define_insn "*lowsi"
4440 [(set (match_operand:SI 0 "register_operand" "=d")
4441 (lo_sum:SI (match_operand:SI 1 "register_operand" "d")
4442 (match_operand:SI 2 "immediate_operand" "")))]
4445 [(set_attr "type" "arith")
4446 (set_attr "mode" "SI")])
4448 (define_insn "*lowdi"
4449 [(set (match_operand:DI 0 "register_operand" "=d")
4450 (lo_sum:DI (match_operand:DI 1 "register_operand" "d")
4451 (match_operand:DI 2 "immediate_operand" "")))]
4452 "!TARGET_MIPS16 && TARGET_64BIT"
4454 [(set_attr "type" "arith")
4455 (set_attr "mode" "DI")])
4457 (define_insn "*lowsi_mips16"
4458 [(set (match_operand:SI 0 "register_operand" "=d")
4459 (lo_sum:SI (match_operand:SI 1 "register_operand" "0")
4460 (match_operand:SI 2 "immediate_operand" "")))]
4463 [(set_attr "type" "arith")
4464 (set_attr "mode" "SI")
4465 (set_attr "length" "8")])
4467 (define_insn "*lowdi_mips16"
4468 [(set (match_operand:DI 0 "register_operand" "=d")
4469 (lo_sum:DI (match_operand:DI 1 "register_operand" "0")
4470 (match_operand:DI 2 "immediate_operand" "")))]
4471 "TARGET_MIPS16 && TARGET_64BIT"
4473 [(set_attr "type" "arith")
4474 (set_attr "mode" "DI")
4475 (set_attr "length" "8")])
4477 ;; 64-bit integer moves
4479 ;; Unlike most other insns, the move insns can't be split with
4480 ;; different predicates, because register spilling and other parts of
4481 ;; the compiler, have memoized the insn number already.
4483 (define_expand "movdi"
4484 [(set (match_operand:DI 0 "" "")
4485 (match_operand:DI 1 "" ""))]
4488 if (mips_legitimize_move (DImode, operands[0], operands[1]))
4491 /* If we are generating embedded PIC code, and we are referring to a
4492 symbol in the .text section, we must use an offset from the start
4494 if (TARGET_EMBEDDED_PIC
4495 && (GET_CODE (operands[1]) == LABEL_REF
4496 || (GET_CODE (operands[1]) == SYMBOL_REF
4497 && ! SYMBOL_REF_FLAG (operands[1]))))
4501 temp = embedded_pic_offset (operands[1]);
4502 temp = gen_rtx_PLUS (Pmode, embedded_pic_fnaddr_reg (),
4503 force_reg (DImode, temp));
4504 emit_move_insn (operands[0], force_reg (DImode, temp));
4509 ;; For mips16, we need a special case to handle storing $31 into
4510 ;; memory, since we don't have a constraint to match $31. This
4511 ;; instruction can be generated by save_restore_insns.
4514 [(set (match_operand:DI 0 "stack_operand" "=m")
4516 "TARGET_MIPS16 && TARGET_64BIT"
4518 [(set_attr "type" "store")
4519 (set_attr "mode" "DI")])
4521 (define_insn "*movdi_32bit"
4522 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,m,*x,*d,*x,*B*C*D,*B*C*D,*d,*m")
4523 (match_operand:DI 1 "move_operand" "d,i,m,d,J,*x,*d,*d,*m,*B*C*D,*B*C*D"))]
4524 "!TARGET_64BIT && !TARGET_MIPS16
4525 && (register_operand (operands[0], DImode)
4526 || reg_or_0_operand (operands[1], DImode))"
4527 { return mips_output_move (operands[0], operands[1]); }
4528 [(set_attr "type" "move,arith,load,store,hilo,hilo,hilo,xfer,load,xfer,store")
4529 (set_attr "mode" "DI")
4530 (set_attr "length" "8,16,*,*,8,8,8,8,*,8,*")])
4532 (define_insn "*movdi_32bit_mips16"
4533 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m,*d")
4534 (match_operand:DI 1 "move_operand" "d,d,y,K,N,m,d,*x"))]
4535 "!TARGET_64BIT && TARGET_MIPS16
4536 && (register_operand (operands[0], DImode)
4537 || register_operand (operands[1], DImode))"
4538 { return mips_output_move (operands[0], operands[1]); }
4539 [(set_attr "type" "move,move,move,arith,arith,load,store,hilo")
4540 (set_attr "mode" "DI")
4541 (set_attr "length" "8,8,8,8,12,*,*,8")])
4543 (define_insn "*movdi_64bit"
4544 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,e,d,m,*f,*f,*f,*d,*m,*x,*d,*x,*B*C*D,*B*C*D,*d,*m")
4545 (match_operand:DI 1 "move_operand" "d,U,T,m,dJ,*f,*d*J,*m,*f,*f,*J,*x,*d,*d,*m,*B*C*D,*B*C*D"))]
4546 "TARGET_64BIT && !TARGET_MIPS16
4547 && (register_operand (operands[0], DImode)
4548 || reg_or_0_operand (operands[1], DImode))"
4549 { return mips_output_move (operands[0], operands[1]); }
4550 [(set_attr "type" "move,const,const,load,store,move,xfer,load,xfer,store,hilo,hilo,hilo,xfer,load,xfer,store")
4551 (set_attr "mode" "DI")
4552 (set_attr "length" "4,*,*,*,*,4,4,*,4,*,4,4,4,8,*,8,*")])
4554 (define_insn "*movdi_64bit_mips16"
4555 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,y,d,d,d,d,d,m,*d")
4556 (match_operand:DI 1 "move_operand" "d,d,y,K,N,U,m,d,*x"))]
4557 "TARGET_64BIT && TARGET_MIPS16
4558 && (register_operand (operands[0], DImode)
4559 || register_operand (operands[1], DImode))"
4560 { return mips_output_move (operands[0], operands[1]); }
4561 [(set_attr "type" "move,move,move,arith,arith,const,load,store,hilo")
4562 (set_attr "mode" "DI")
4563 (set_attr_alternative "length"
4567 (if_then_else (match_operand:VOID 1 "m16_uimm8_1" "")
4570 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1" "")
4579 ;; On the mips16, we can split ld $r,N($r) into an add and a load,
4580 ;; when the original load is a 4 byte instruction but the add and the
4581 ;; load are 2 2 byte instructions.
4584 [(set (match_operand:DI 0 "register_operand" "")
4585 (mem:DI (plus:DI (match_dup 0)
4586 (match_operand:DI 1 "const_int_operand" ""))))]
4587 "TARGET_64BIT && TARGET_MIPS16 && reload_completed
4588 && !TARGET_DEBUG_D_MODE
4589 && GET_CODE (operands[0]) == REG
4590 && M16_REG_P (REGNO (operands[0]))
4591 && GET_CODE (operands[1]) == CONST_INT
4592 && ((INTVAL (operands[1]) < 0
4593 && INTVAL (operands[1]) >= -0x10)
4594 || (INTVAL (operands[1]) >= 32 * 8
4595 && INTVAL (operands[1]) <= 31 * 8 + 0x8)
4596 || (INTVAL (operands[1]) >= 0
4597 && INTVAL (operands[1]) < 32 * 8
4598 && (INTVAL (operands[1]) & 7) != 0))"
4599 [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1)))
4600 (set (match_dup 0) (mem:DI (plus:DI (match_dup 0) (match_dup 2))))]
4602 HOST_WIDE_INT val = INTVAL (operands[1]);
4605 operands[2] = const0_rtx;
4606 else if (val >= 32 * 8)
4610 operands[1] = GEN_INT (0x8 + off);
4611 operands[2] = GEN_INT (val - off - 0x8);
4617 operands[1] = GEN_INT (off);
4618 operands[2] = GEN_INT (val - off);
4622 ;; 32-bit Integer moves
4624 ;; Unlike most other insns, the move insns can't be split with
4625 ;; different predicates, because register spilling and other parts of
4626 ;; the compiler, have memoized the insn number already.
4628 (define_expand "movsi"
4629 [(set (match_operand:SI 0 "" "")
4630 (match_operand:SI 1 "" ""))]
4633 if (mips_legitimize_move (SImode, operands[0], operands[1]))
4636 /* If we are generating embedded PIC code, and we are referring to a
4637 symbol in the .text section, we must use an offset from the start
4639 if (TARGET_EMBEDDED_PIC
4640 && (GET_CODE (operands[1]) == LABEL_REF
4641 || (GET_CODE (operands[1]) == SYMBOL_REF
4642 && ! SYMBOL_REF_FLAG (operands[1]))))
4646 temp = embedded_pic_offset (operands[1]);
4647 temp = gen_rtx_PLUS (Pmode, embedded_pic_fnaddr_reg (),
4648 force_reg (SImode, temp));
4649 emit_move_insn (operands[0], force_reg (SImode, temp));
4654 ;; We can only store $ra directly into a small sp offset.
4657 [(set (match_operand:SI 0 "stack_operand" "=m")
4661 [(set_attr "type" "store")
4662 (set_attr "mode" "SI")])
4664 ;; The difference between these two is whether or not ints are allowed
4665 ;; in FP registers (off by default, use -mdebugh to enable).
4667 (define_insn "*movsi_internal"
4668 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,e,d,m,*f,*f,*f,*d,*m,*d,*z,*x,*d,*x,*B*C*D,*B*C*D,*d,*m")
4669 (match_operand:SI 1 "move_operand" "d,U,T,m,dJ,*f,*d*J,*m,*f,*f,*z,*d,J,*x,*d,*d,*m,*B*C*D,*B*C*D"))]
4671 && (register_operand (operands[0], SImode)
4672 || reg_or_0_operand (operands[1], SImode))"
4673 { return mips_output_move (operands[0], operands[1]); }
4674 [(set_attr "type" "move,const,const,load,store,move,xfer,load,xfer,store,xfer,xfer,hilo,hilo,hilo,xfer,load,xfer,store")
4675 (set_attr "mode" "SI")
4676 (set_attr "length" "4,*,*,*,*,4,4,*,4,*,4,4,4,4,4,4,*,4,*")])
4678 (define_insn "*movsi_mips16"
4679 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,y,d,d,d,d,d,m,*d")
4680 (match_operand:SI 1 "move_operand" "d,d,y,K,N,U,m,d,*x"))]
4682 && (register_operand (operands[0], SImode)
4683 || register_operand (operands[1], SImode))"
4684 { return mips_output_move (operands[0], operands[1]); }
4685 [(set_attr "type" "move,move,move,arith,arith,const,load,store,hilo")
4686 (set_attr "mode" "SI")
4687 (set_attr_alternative "length"
4691 (if_then_else (match_operand:VOID 1 "m16_uimm8_1" "")
4694 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1" "")
4702 ;; On the mips16, we can split lw $r,N($r) into an add and a load,
4703 ;; when the original load is a 4 byte instruction but the add and the
4704 ;; load are 2 2 byte instructions.
4707 [(set (match_operand:SI 0 "register_operand" "")
4708 (mem:SI (plus:SI (match_dup 0)
4709 (match_operand:SI 1 "const_int_operand" ""))))]
4710 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
4711 && GET_CODE (operands[0]) == REG
4712 && M16_REG_P (REGNO (operands[0]))
4713 && GET_CODE (operands[1]) == CONST_INT
4714 && ((INTVAL (operands[1]) < 0
4715 && INTVAL (operands[1]) >= -0x80)
4716 || (INTVAL (operands[1]) >= 32 * 4
4717 && INTVAL (operands[1]) <= 31 * 4 + 0x7c)
4718 || (INTVAL (operands[1]) >= 0
4719 && INTVAL (operands[1]) < 32 * 4
4720 && (INTVAL (operands[1]) & 3) != 0))"
4721 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
4722 (set (match_dup 0) (mem:SI (plus:SI (match_dup 0) (match_dup 2))))]
4724 HOST_WIDE_INT val = INTVAL (operands[1]);
4727 operands[2] = const0_rtx;
4728 else if (val >= 32 * 4)
4732 operands[1] = GEN_INT (0x7c + off);
4733 operands[2] = GEN_INT (val - off - 0x7c);
4739 operands[1] = GEN_INT (off);
4740 operands[2] = GEN_INT (val - off);
4744 ;; On the mips16, we can split a load of certain constants into a load
4745 ;; and an add. This turns a 4 byte instruction into 2 2 byte
4749 [(set (match_operand:SI 0 "register_operand" "")
4750 (match_operand:SI 1 "const_int_operand" ""))]
4751 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
4752 && GET_CODE (operands[0]) == REG
4753 && M16_REG_P (REGNO (operands[0]))
4754 && GET_CODE (operands[1]) == CONST_INT
4755 && INTVAL (operands[1]) >= 0x100
4756 && INTVAL (operands[1]) <= 0xff + 0x7f"
4757 [(set (match_dup 0) (match_dup 1))
4758 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]
4760 int val = INTVAL (operands[1]);
4762 operands[1] = GEN_INT (0xff);
4763 operands[2] = GEN_INT (val - 0xff);
4766 ;; On the mips16, we can split a load of a negative constant into a
4767 ;; load and a neg. That's what mips_output_move will generate anyhow.
4770 [(set (match_operand:SI 0 "register_operand" "")
4771 (match_operand:SI 1 "const_int_operand" ""))]
4772 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
4773 && GET_CODE (operands[0]) == REG
4774 && M16_REG_P (REGNO (operands[0]))
4775 && GET_CODE (operands[1]) == CONST_INT
4776 && INTVAL (operands[1]) < 0
4777 && INTVAL (operands[1]) > - 0x8000"
4778 [(set (match_dup 0) (match_dup 1))
4779 (set (match_dup 0) (neg:SI (match_dup 0)))]
4780 { operands[1] = GEN_INT (- INTVAL (operands[1])); })
4782 ;; This insn handles moving CCmode values. It's really just a
4783 ;; slightly simplified copy of movsi_internal2, with additional cases
4784 ;; to move a condition register to a general register and to move
4785 ;; between the general registers and the floating point registers.
4787 (define_insn "movcc"
4788 [(set (match_operand:CC 0 "nonimmediate_operand" "=d,*d,*d,*m,*d,*f,*f,*f,*m")
4789 (match_operand:CC 1 "general_operand" "z,*d,*m,*d,*f,*d,*f,*m,*f"))]
4790 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
4791 { return mips_output_move (operands[0], operands[1]); }
4792 [(set_attr "type" "move,move,load,store,xfer,xfer,move,load,store")
4793 (set_attr "mode" "SI")
4794 (set_attr "length" "8,4,*,*,4,4,4,*,*")])
4796 ;; Reload condition code registers. reload_incc and reload_outcc
4797 ;; both handle moves from arbitrary operands into condition code
4798 ;; registers. reload_incc handles the more common case in which
4799 ;; a source operand is constrained to be in a condition-code
4800 ;; register, but has not been allocated to one.
4802 ;; Sometimes, such as in movcc, we have a CCmode destination whose
4803 ;; constraints do not include 'z'. reload_outcc handles the case
4804 ;; when such an operand is allocated to a condition-code register.
4806 ;; Note that reloads from a condition code register to some
4807 ;; other location can be done using ordinary moves. Moving
4808 ;; into a GPR takes a single movcc, moving elsewhere takes
4809 ;; two. We can leave these cases to the generic reload code.
4810 (define_expand "reload_incc"
4811 [(set (match_operand:CC 0 "fcc_register_operand" "=z")
4812 (match_operand:CC 1 "general_operand" ""))
4813 (clobber (match_operand:TF 2 "register_operand" "=&f"))]
4814 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
4816 mips_emit_fcc_reload (operands[0], operands[1], operands[2]);
4820 (define_expand "reload_outcc"
4821 [(set (match_operand:CC 0 "fcc_register_operand" "=z")
4822 (match_operand:CC 1 "register_operand" ""))
4823 (clobber (match_operand:TF 2 "register_operand" "=&f"))]
4824 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
4826 mips_emit_fcc_reload (operands[0], operands[1], operands[2]);
4830 ;; MIPS4 supports loading and storing a floating point register from
4831 ;; the sum of two general registers. We use two versions for each of
4832 ;; these four instructions: one where the two general registers are
4833 ;; SImode, and one where they are DImode. This is because general
4834 ;; registers will be in SImode when they hold 32 bit values, but,
4835 ;; since the 32 bit values are always sign extended, the [ls][wd]xc1
4836 ;; instructions will still work correctly.
4838 ;; ??? Perhaps it would be better to support these instructions by
4839 ;; modifying GO_IF_LEGITIMATE_ADDRESS and friends. However, since
4840 ;; these instructions can only be used to load and store floating
4841 ;; point registers, that would probably cause trouble in reload.
4844 [(set (match_operand:SF 0 "register_operand" "=f")
4845 (mem:SF (plus:SI (match_operand:SI 1 "register_operand" "d")
4846 (match_operand:SI 2 "register_operand" "d"))))]
4847 "ISA_HAS_FP4 && TARGET_HARD_FLOAT"
4849 [(set_attr "type" "load")
4850 (set_attr "mode" "SF")
4851 (set_attr "length" "4")])
4854 [(set (match_operand:SF 0 "register_operand" "=f")
4855 (mem:SF (plus:DI (match_operand:DI 1 "register_operand" "d")
4856 (match_operand:DI 2 "register_operand" "d"))))]
4857 "ISA_HAS_FP4 && TARGET_HARD_FLOAT"
4859 [(set_attr "type" "load")
4860 (set_attr "mode" "SF")
4861 (set_attr "length" "4")])
4864 [(set (match_operand:DF 0 "register_operand" "=f")
4865 (mem:DF (plus:SI (match_operand:SI 1 "register_operand" "d")
4866 (match_operand:SI 2 "register_operand" "d"))))]
4867 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
4869 [(set_attr "type" "load")
4870 (set_attr "mode" "DF")
4871 (set_attr "length" "4")])
4874 [(set (match_operand:DF 0 "register_operand" "=f")
4875 (mem:DF (plus:DI (match_operand:DI 1 "register_operand" "d")
4876 (match_operand:DI 2 "register_operand" "d"))))]
4877 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
4879 [(set_attr "type" "load")
4880 (set_attr "mode" "DF")
4881 (set_attr "length" "4")])
4884 [(set (mem:SF (plus:SI (match_operand:SI 1 "register_operand" "d")
4885 (match_operand:SI 2 "register_operand" "d")))
4886 (match_operand:SF 0 "register_operand" "f"))]
4887 "ISA_HAS_FP4 && TARGET_HARD_FLOAT"
4889 [(set_attr "type" "store")
4890 (set_attr "mode" "SF")
4891 (set_attr "length" "4")])
4894 [(set (mem:SF (plus:DI (match_operand:DI 1 "register_operand" "d")
4895 (match_operand:DI 2 "register_operand" "d")))
4896 (match_operand:SF 0 "register_operand" "f"))]
4897 "ISA_HAS_FP4 && TARGET_HARD_FLOAT"
4899 [(set_attr "type" "store")
4900 (set_attr "mode" "SF")
4901 (set_attr "length" "4")])
4904 [(set (mem:DF (plus:SI (match_operand:SI 1 "register_operand" "d")
4905 (match_operand:SI 2 "register_operand" "d")))
4906 (match_operand:DF 0 "register_operand" "f"))]
4907 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
4909 [(set_attr "type" "store")
4910 (set_attr "mode" "DF")
4911 (set_attr "length" "4")])
4914 [(set (mem:DF (plus:DI (match_operand:DI 1 "register_operand" "d")
4915 (match_operand:DI 2 "register_operand" "d")))
4916 (match_operand:DF 0 "register_operand" "f"))]
4917 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
4919 [(set_attr "type" "store")
4920 (set_attr "mode" "DF")
4921 (set_attr "length" "4")])
4923 ;; 16-bit Integer moves
4925 ;; Unlike most other insns, the move insns can't be split with
4926 ;; different predicates, because register spilling and other parts of
4927 ;; the compiler, have memoized the insn number already.
4928 ;; Unsigned loads are used because LOAD_EXTEND_OP returns ZERO_EXTEND.
4930 (define_expand "movhi"
4931 [(set (match_operand:HI 0 "" "")
4932 (match_operand:HI 1 "" ""))]
4935 if (mips_legitimize_move (HImode, operands[0], operands[1]))
4939 (define_insn "*movhi_internal"
4940 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,m,*d,*f,*f,*x,*d")
4941 (match_operand:HI 1 "move_operand" "d,I,m,dJ,*f,*d,*f,*d,*x"))]
4943 && (register_operand (operands[0], HImode)
4944 || reg_or_0_operand (operands[1], HImode))"
4955 [(set_attr "type" "move,arith,load,store,xfer,xfer,move,hilo,hilo")
4956 (set_attr "mode" "HI")
4957 (set_attr "length" "4,4,*,*,4,4,4,4,4")])
4959 (define_insn "*movhi_mips16"
4960 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m,*d")
4961 (match_operand:HI 1 "move_operand" "d,d,y,K,N,m,d,*x"))]
4963 && (register_operand (operands[0], HImode)
4964 || register_operand (operands[1], HImode))"
4974 [(set_attr "type" "move,move,move,arith,arith,load,store,hilo")
4975 (set_attr "mode" "HI")
4976 (set_attr_alternative "length"
4980 (if_then_else (match_operand:VOID 1 "m16_uimm8_1" "")
4983 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1" "")
4991 ;; On the mips16, we can split lh $r,N($r) into an add and a load,
4992 ;; when the original load is a 4 byte instruction but the add and the
4993 ;; load are 2 2 byte instructions.
4996 [(set (match_operand:HI 0 "register_operand" "")
4997 (mem:HI (plus:SI (match_dup 0)
4998 (match_operand:SI 1 "const_int_operand" ""))))]
4999 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
5000 && GET_CODE (operands[0]) == REG
5001 && M16_REG_P (REGNO (operands[0]))
5002 && GET_CODE (operands[1]) == CONST_INT
5003 && ((INTVAL (operands[1]) < 0
5004 && INTVAL (operands[1]) >= -0x80)
5005 || (INTVAL (operands[1]) >= 32 * 2
5006 && INTVAL (operands[1]) <= 31 * 2 + 0x7e)
5007 || (INTVAL (operands[1]) >= 0
5008 && INTVAL (operands[1]) < 32 * 2
5009 && (INTVAL (operands[1]) & 1) != 0))"
5010 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
5011 (set (match_dup 0) (mem:HI (plus:SI (match_dup 0) (match_dup 2))))]
5013 HOST_WIDE_INT val = INTVAL (operands[1]);
5016 operands[2] = const0_rtx;
5017 else if (val >= 32 * 2)
5021 operands[1] = GEN_INT (0x7e + off);
5022 operands[2] = GEN_INT (val - off - 0x7e);
5028 operands[1] = GEN_INT (off);
5029 operands[2] = GEN_INT (val - off);
5033 ;; 8-bit Integer moves
5035 ;; Unlike most other insns, the move insns can't be split with
5036 ;; different predicates, because register spilling and other parts of
5037 ;; the compiler, have memoized the insn number already.
5038 ;; Unsigned loads are used because LOAD_EXTEND_OP returns ZERO_EXTEND.
5040 (define_expand "movqi"
5041 [(set (match_operand:QI 0 "" "")
5042 (match_operand:QI 1 "" ""))]
5045 if (mips_legitimize_move (QImode, operands[0], operands[1]))
5049 (define_insn "*movqi_internal"
5050 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,m,*d,*f,*f,*x,*d")
5051 (match_operand:QI 1 "move_operand" "d,I,m,dJ,*f,*d,*f,*d,*x"))]
5053 && (register_operand (operands[0], QImode)
5054 || reg_or_0_operand (operands[1], QImode))"
5065 [(set_attr "type" "move,arith,load,store,xfer,xfer,move,hilo,hilo")
5066 (set_attr "mode" "QI")
5067 (set_attr "length" "4,4,*,*,4,4,4,4,4")])
5069 (define_insn "*movqi_mips16"
5070 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m,*d")
5071 (match_operand:QI 1 "move_operand" "d,d,y,K,N,m,d,*x"))]
5073 && (register_operand (operands[0], QImode)
5074 || register_operand (operands[1], QImode))"
5084 [(set_attr "type" "move,move,move,arith,arith,load,store,hilo")
5085 (set_attr "mode" "QI")
5086 (set_attr "length" "4,4,4,4,8,*,*,4")])
5088 ;; On the mips16, we can split lb $r,N($r) into an add and a load,
5089 ;; when the original load is a 4 byte instruction but the add and the
5090 ;; load are 2 2 byte instructions.
5093 [(set (match_operand:QI 0 "register_operand" "")
5094 (mem:QI (plus:SI (match_dup 0)
5095 (match_operand:SI 1 "const_int_operand" ""))))]
5096 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
5097 && GET_CODE (operands[0]) == REG
5098 && M16_REG_P (REGNO (operands[0]))
5099 && GET_CODE (operands[1]) == CONST_INT
5100 && ((INTVAL (operands[1]) < 0
5101 && INTVAL (operands[1]) >= -0x80)
5102 || (INTVAL (operands[1]) >= 32
5103 && INTVAL (operands[1]) <= 31 + 0x7f))"
5104 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
5105 (set (match_dup 0) (mem:QI (plus:SI (match_dup 0) (match_dup 2))))]
5107 HOST_WIDE_INT val = INTVAL (operands[1]);
5110 operands[2] = const0_rtx;
5113 operands[1] = GEN_INT (0x7f);
5114 operands[2] = GEN_INT (val - 0x7f);
5118 ;; 32-bit floating point moves
5120 (define_expand "movsf"
5121 [(set (match_operand:SF 0 "" "")
5122 (match_operand:SF 1 "" ""))]
5125 if (mips_legitimize_move (SFmode, operands[0], operands[1]))
5129 (define_insn "*movsf_hardfloat"
5130 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,f,m,*f,*d,*d,*d,*m")
5131 (match_operand:SF 1 "move_operand" "f,G,m,fG,*d,*f,*G*d,*m,*d"))]
5133 && (register_operand (operands[0], SFmode)
5134 || reg_or_0_operand (operands[1], SFmode))"
5135 { return mips_output_move (operands[0], operands[1]); }
5136 [(set_attr "type" "move,xfer,load,store,xfer,xfer,move,load,store")
5137 (set_attr "mode" "SF")
5138 (set_attr "length" "4,4,*,*,4,4,4,*,*")])
5140 (define_insn "*movsf_softfloat"
5141 [(set (match_operand:SF 0 "nonimmediate_operand" "=d,d,m")
5142 (match_operand:SF 1 "move_operand" "Gd,m,d"))]
5143 "TARGET_SOFT_FLOAT && !TARGET_MIPS16
5144 && (register_operand (operands[0], SFmode)
5145 || reg_or_0_operand (operands[1], SFmode))"
5146 { return mips_output_move (operands[0], operands[1]); }
5147 [(set_attr "type" "move,load,store")
5148 (set_attr "mode" "SF")
5149 (set_attr "length" "4,*,*")])
5151 (define_insn "*movsf_mips16"
5152 [(set (match_operand:SF 0 "nonimmediate_operand" "=d,y,d,d,m")
5153 (match_operand:SF 1 "move_operand" "d,d,y,m,d"))]
5155 && (register_operand (operands[0], SFmode)
5156 || register_operand (operands[1], SFmode))"
5157 { return mips_output_move (operands[0], operands[1]); }
5158 [(set_attr "type" "move,move,move,load,store")
5159 (set_attr "mode" "SF")
5160 (set_attr "length" "4,4,4,*,*")])
5163 ;; 64-bit floating point moves
5165 (define_expand "movdf"
5166 [(set (match_operand:DF 0 "" "")
5167 (match_operand:DF 1 "" ""))]
5170 if (mips_legitimize_move (DFmode, operands[0], operands[1]))
5174 (define_insn "*movdf_hardfloat_64bit"
5175 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,m,*f,*d,*d,*d,*m")
5176 (match_operand:DF 1 "move_operand" "f,G,m,fG,*d,*f,*d*G,*m,*d"))]
5177 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_64BIT
5178 && (register_operand (operands[0], DFmode)
5179 || reg_or_0_operand (operands[1], DFmode))"
5180 { return mips_output_move (operands[0], operands[1]); }
5181 [(set_attr "type" "move,xfer,load,store,xfer,xfer,move,load,store")
5182 (set_attr "mode" "DF")
5183 (set_attr "length" "4,4,*,*,4,4,4,*,*")])
5185 (define_insn "*movdf_hardfloat_32bit"
5186 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,m,*f,*d,*d,*d,*m")
5187 (match_operand:DF 1 "move_operand" "f,G,m,fG,*d,*f,*d*G,*m,*d"))]
5188 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT
5189 && (register_operand (operands[0], DFmode)
5190 || reg_or_0_operand (operands[1], DFmode))"
5191 { return mips_output_move (operands[0], operands[1]); }
5192 [(set_attr "type" "move,xfer,load,store,xfer,xfer,move,load,store")
5193 (set_attr "mode" "DF")
5194 (set_attr "length" "4,8,*,*,8,8,8,*,*")])
5196 (define_insn "*movdf_softfloat"
5197 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,m,d,f,f")
5198 (match_operand:DF 1 "move_operand" "dG,m,dG,f,d,f"))]
5199 "(TARGET_SOFT_FLOAT || TARGET_SINGLE_FLOAT) && !TARGET_MIPS16
5200 && (register_operand (operands[0], DFmode)
5201 || reg_or_0_operand (operands[1], DFmode))"
5202 { return mips_output_move (operands[0], operands[1]); }
5203 [(set_attr "type" "move,load,store,xfer,xfer,move")
5204 (set_attr "mode" "DF")
5205 (set_attr "length" "8,*,*,4,4,4")])
5207 (define_insn "*movdf_mips16"
5208 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,y,d,d,m")
5209 (match_operand:DF 1 "move_operand" "d,d,y,m,d"))]
5211 && (register_operand (operands[0], DFmode)
5212 || register_operand (operands[1], DFmode))"
5213 { return mips_output_move (operands[0], operands[1]); }
5214 [(set_attr "type" "move,move,move,load,store")
5215 (set_attr "mode" "DF")
5216 (set_attr "length" "8,8,8,*,*")])
5219 [(set (match_operand:DI 0 "nonimmediate_operand" "")
5220 (match_operand:DI 1 "move_operand" ""))]
5221 "reload_completed && !TARGET_64BIT
5222 && mips_split_64bit_move_p (operands[0], operands[1])"
5225 mips_split_64bit_move (operands[0], operands[1]);
5230 [(set (match_operand:DF 0 "nonimmediate_operand" "")
5231 (match_operand:DF 1 "move_operand" ""))]
5232 "reload_completed && !TARGET_64BIT
5233 && mips_split_64bit_move_p (operands[0], operands[1])"
5236 mips_split_64bit_move (operands[0], operands[1]);
5240 ;; Patterns for loading or storing part of a paired floating point
5241 ;; register. We need them because odd-numbered floating-point registers
5242 ;; are not fully independent: see mips_split_64bit_move.
5244 ;; Load the low word of operand 0 with operand 1.
5245 (define_insn "load_df_low"
5246 [(set (match_operand:DF 0 "register_operand" "=f,f")
5247 (unspec:DF [(match_operand:SI 1 "general_operand" "dJ,m")]
5248 UNSPEC_LOAD_DF_LOW))]
5249 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT"
5251 operands[0] = mips_subword (operands[0], 0);
5252 return mips_output_move (operands[0], operands[1]);
5254 [(set_attr "type" "xfer,load")
5255 (set_attr "mode" "SF")
5256 (set_attr "length" "4")])
5258 ;; Load the high word of operand 0 from operand 1, preserving the value
5260 (define_insn "load_df_high"
5261 [(set (match_operand:DF 0 "register_operand" "=f,f")
5262 (unspec:DF [(match_operand:SI 1 "general_operand" "dJ,m")
5263 (match_operand:DF 2 "register_operand" "0,0")]
5264 UNSPEC_LOAD_DF_HIGH))]
5265 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT"
5267 operands[0] = mips_subword (operands[0], 1);
5268 return mips_output_move (operands[0], operands[1]);
5270 [(set_attr "type" "xfer,load")
5271 (set_attr "mode" "SF")
5272 (set_attr "length" "4")])
5274 ;; Store the high word of operand 1 in operand 0. The corresponding
5275 ;; low-word move is done in the normal way.
5276 (define_insn "store_df_high"
5277 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,m")
5278 (unspec:SI [(match_operand:DF 1 "register_operand" "f,f")]
5279 UNSPEC_STORE_DF_HIGH))]
5280 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT"
5282 operands[1] = mips_subword (operands[1], 1);
5283 return mips_output_move (operands[0], operands[1]);
5285 [(set_attr "type" "xfer,store")
5286 (set_attr "mode" "SF")
5287 (set_attr "length" "4")])
5289 ;; Insn to initialize $gp for n32/n64 abicalls. Operand 0 is the offset
5290 ;; of _gp from the start of this function. Operand 1 is the incoming
5291 ;; function address.
5292 (define_insn_and_split "loadgp"
5293 [(unspec_volatile [(match_operand 0 "" "")
5294 (match_operand 1 "register_operand" "")] UNSPEC_LOADGP)]
5295 "TARGET_ABICALLS && TARGET_NEWABI"
5298 [(set (match_dup 2) (match_dup 3))
5299 (set (match_dup 2) (match_dup 4))
5300 (set (match_dup 2) (match_dup 5))]
5302 operands[2] = pic_offset_table_rtx;
5303 operands[3] = gen_rtx_HIGH (Pmode, operands[0]);
5304 operands[4] = gen_rtx_PLUS (Pmode, operands[2], operands[1]);
5305 operands[5] = gen_rtx_LO_SUM (Pmode, operands[2], operands[0]);
5307 [(set_attr "length" "12")])
5309 ;; The use of gp is hidden when not using explicit relocations.
5310 ;; This blockage instruction prevents the gp load from being
5311 ;; scheduled after an implicit use of gp. It also prevents
5312 ;; the load from being deleted as dead.
5313 (define_insn "loadgp_blockage"
5314 [(unspec_volatile [(reg:DI 28)] UNSPEC_BLOCKAGE)]
5317 [(set_attr "type" "unknown")
5318 (set_attr "mode" "none")
5319 (set_attr "length" "0")])
5321 ;; Emit a .cprestore directive, which expands to a single store instruction.
5322 ;; Note that we continue to use .cprestore for explicit reloc code so that
5323 ;; jals inside inlines asms will work correctly.
5324 (define_insn "cprestore"
5325 [(unspec_volatile [(match_operand 0 "const_int_operand" "")]
5329 [(set_attr "type" "store")
5330 (set_attr "length" "4")])
5332 ;; Block moves, see mips.c for more details.
5333 ;; Argument 0 is the destination
5334 ;; Argument 1 is the source
5335 ;; Argument 2 is the length
5336 ;; Argument 3 is the alignment
5338 (define_expand "movstrsi"
5339 [(parallel [(set (match_operand:BLK 0 "general_operand" "")
5340 (match_operand:BLK 1 "general_operand" ""))
5341 (use (match_operand:SI 2 "" ""))
5342 (use (match_operand:SI 3 "const_int_operand" ""))])]
5343 "!TARGET_MIPS16 && !TARGET_MEMCPY"
5345 if (mips_expand_block_move (operands[0], operands[1], operands[2]))
5352 ;; ....................
5356 ;; ....................
5358 ;; Many of these instructions use trivial define_expands, because we
5359 ;; want to use a different set of constraints when TARGET_MIPS16.
5361 (define_expand "ashlsi3"
5362 [(set (match_operand:SI 0 "register_operand" "=d")
5363 (ashift:SI (match_operand:SI 1 "register_operand" "d")
5364 (match_operand:SI 2 "arith_operand" "dI")))]
5367 /* On the mips16, a shift of more than 8 is a four byte instruction,
5368 so, for a shift between 8 and 16, it is just as fast to do two
5369 shifts of 8 or less. If there is a lot of shifting going on, we
5370 may win in CSE. Otherwise combine will put the shifts back
5371 together again. This can be called by function_arg, so we must
5372 be careful not to allocate a new register if we've reached the
5376 && GET_CODE (operands[2]) == CONST_INT
5377 && INTVAL (operands[2]) > 8
5378 && INTVAL (operands[2]) <= 16
5379 && ! reload_in_progress
5380 && ! reload_completed)
5382 rtx temp = gen_reg_rtx (SImode);
5384 emit_insn (gen_ashlsi3_internal2 (temp, operands[1], GEN_INT (8)));
5385 emit_insn (gen_ashlsi3_internal2 (operands[0], temp,
5386 GEN_INT (INTVAL (operands[2]) - 8)));
5391 (define_insn "ashlsi3_internal1"
5392 [(set (match_operand:SI 0 "register_operand" "=d")
5393 (ashift:SI (match_operand:SI 1 "register_operand" "d")
5394 (match_operand:SI 2 "arith_operand" "dI")))]
5397 if (GET_CODE (operands[2]) == CONST_INT)
5398 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
5400 return "sll\t%0,%1,%2";
5402 [(set_attr "type" "arith")
5403 (set_attr "mode" "SI")])
5405 (define_insn "ashlsi3_internal1_extend"
5406 [(set (match_operand:DI 0 "register_operand" "=d")
5407 (sign_extend:DI (ashift:SI (match_operand:SI 1 "register_operand" "d")
5408 (match_operand:SI 2 "arith_operand" "dI"))))]
5409 "TARGET_64BIT && !TARGET_MIPS16"
5411 if (GET_CODE (operands[2]) == CONST_INT)
5412 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
5414 return "sll\t%0,%1,%2";
5416 [(set_attr "type" "arith")
5417 (set_attr "mode" "DI")])
5420 (define_insn "ashlsi3_internal2"
5421 [(set (match_operand:SI 0 "register_operand" "=d,d")
5422 (ashift:SI (match_operand:SI 1 "register_operand" "0,d")
5423 (match_operand:SI 2 "arith_operand" "d,I")))]
5426 if (which_alternative == 0)
5427 return "sll\t%0,%2";
5429 if (GET_CODE (operands[2]) == CONST_INT)
5430 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
5432 return "sll\t%0,%1,%2";
5434 [(set_attr "type" "arith")
5435 (set_attr "mode" "SI")
5436 (set_attr_alternative "length"
5438 (if_then_else (match_operand:VOID 2 "m16_uimm3_b" "")
5442 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
5445 [(set (match_operand:SI 0 "register_operand" "")
5446 (ashift:SI (match_operand:SI 1 "register_operand" "")
5447 (match_operand:SI 2 "const_int_operand" "")))]
5448 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
5449 && GET_CODE (operands[2]) == CONST_INT
5450 && INTVAL (operands[2]) > 8
5451 && INTVAL (operands[2]) <= 16"
5452 [(set (match_dup 0) (ashift:SI (match_dup 1) (const_int 8)))
5453 (set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2)))]
5454 { operands[2] = GEN_INT (INTVAL (operands[2]) - 8); })
5456 (define_expand "ashldi3"
5457 [(parallel [(set (match_operand:DI 0 "register_operand" "")
5458 (ashift:DI (match_operand:DI 1 "register_operand" "")
5459 (match_operand:SI 2 "arith_operand" "")))
5460 (clobber (match_dup 3))])]
5461 "TARGET_64BIT || (!TARGET_DEBUG_G_MODE && !TARGET_MIPS16)"
5465 /* On the mips16, a shift of more than 8 is a four byte
5466 instruction, so, for a shift between 8 and 16, it is just as
5467 fast to do two shifts of 8 or less. If there is a lot of
5468 shifting going on, we may win in CSE. Otherwise combine will
5469 put the shifts back together again. This can be called by
5470 function_arg, so we must be careful not to allocate a new
5471 register if we've reached the reload pass. */
5474 && GET_CODE (operands[2]) == CONST_INT
5475 && INTVAL (operands[2]) > 8
5476 && INTVAL (operands[2]) <= 16
5477 && ! reload_in_progress
5478 && ! reload_completed)
5480 rtx temp = gen_reg_rtx (DImode);
5482 emit_insn (gen_ashldi3_internal4 (temp, operands[1], GEN_INT (8)));
5483 emit_insn (gen_ashldi3_internal4 (operands[0], temp,
5484 GEN_INT (INTVAL (operands[2]) - 8)));
5488 emit_insn (gen_ashldi3_internal4 (operands[0], operands[1],
5493 operands[3] = gen_reg_rtx (SImode);
5497 (define_insn "ashldi3_internal"
5498 [(set (match_operand:DI 0 "register_operand" "=&d")
5499 (ashift:DI (match_operand:DI 1 "register_operand" "d")
5500 (match_operand:SI 2 "register_operand" "d")))
5501 (clobber (match_operand:SI 3 "register_operand" "=d"))]
5502 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16"
5519 [(set_attr "type" "darith")
5520 (set_attr "mode" "SI")
5521 (set_attr "length" "48")])
5524 (define_insn "ashldi3_internal2"
5525 [(set (match_operand:DI 0 "register_operand" "=d")
5526 (ashift:DI (match_operand:DI 1 "register_operand" "d")
5527 (match_operand:SI 2 "small_int" "IJK")))
5528 (clobber (match_operand:SI 3 "register_operand" "=d"))]
5529 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
5530 && (INTVAL (operands[2]) & 32) != 0"
5532 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
5533 return "sll\t%M0,%L1,%2\;move\t%L0,%.";
5535 [(set_attr "type" "darith")
5536 (set_attr "mode" "DI")
5537 (set_attr "length" "8")])
5541 [(set (match_operand:DI 0 "register_operand" "")
5542 (ashift:DI (match_operand:DI 1 "register_operand" "")
5543 (match_operand:SI 2 "small_int" "")))
5544 (clobber (match_operand:SI 3 "register_operand" ""))]
5545 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
5546 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
5547 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
5548 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
5549 && (INTVAL (operands[2]) & 32) != 0"
5551 [(set (subreg:SI (match_dup 0) 4) (ashift:SI (subreg:SI (match_dup 1) 0) (match_dup 2)))
5552 (set (subreg:SI (match_dup 0) 0) (const_int 0))]
5554 "operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);")
5558 [(set (match_operand:DI 0 "register_operand" "")
5559 (ashift:DI (match_operand:DI 1 "register_operand" "")
5560 (match_operand:SI 2 "small_int" "")))
5561 (clobber (match_operand:SI 3 "register_operand" ""))]
5562 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
5563 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
5564 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
5565 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
5566 && (INTVAL (operands[2]) & 32) != 0"
5568 [(set (subreg:SI (match_dup 0) 0) (ashift:SI (subreg:SI (match_dup 1) 4) (match_dup 2)))
5569 (set (subreg:SI (match_dup 0) 4) (const_int 0))]
5571 "operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);")
5574 (define_insn "ashldi3_internal3"
5575 [(set (match_operand:DI 0 "register_operand" "=d")
5576 (ashift:DI (match_operand:DI 1 "register_operand" "d")
5577 (match_operand:SI 2 "small_int" "IJK")))
5578 (clobber (match_operand:SI 3 "register_operand" "=d"))]
5579 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
5580 && (INTVAL (operands[2]) & 63) < 32
5581 && (INTVAL (operands[2]) & 63) != 0"
5583 int amount = INTVAL (operands[2]);
5585 operands[2] = GEN_INT (amount & 31);
5586 operands[4] = GEN_INT ((-amount) & 31);
5588 return "sll\t%M0,%M1,%2\;srl\t%3,%L1,%4\;or\t%M0,%M0,%3\;sll\t%L0,%L1,%2";
5590 [(set_attr "type" "darith")
5591 (set_attr "mode" "DI")
5592 (set_attr "length" "16")])
5596 [(set (match_operand:DI 0 "register_operand" "")
5597 (ashift:DI (match_operand:DI 1 "register_operand" "")
5598 (match_operand:SI 2 "small_int" "")))
5599 (clobber (match_operand:SI 3 "register_operand" ""))]
5600 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
5601 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
5602 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
5603 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
5604 && (INTVAL (operands[2]) & 63) < 32
5605 && (INTVAL (operands[2]) & 63) != 0"
5607 [(set (subreg:SI (match_dup 0) 4)
5608 (ashift:SI (subreg:SI (match_dup 1) 4)
5612 (lshiftrt:SI (subreg:SI (match_dup 1) 0)
5615 (set (subreg:SI (match_dup 0) 4)
5616 (ior:SI (subreg:SI (match_dup 0) 4)
5619 (set (subreg:SI (match_dup 0) 0)
5620 (ashift:SI (subreg:SI (match_dup 1) 0)
5623 int amount = INTVAL (operands[2]);
5624 operands[2] = GEN_INT (amount & 31);
5625 operands[4] = GEN_INT ((-amount) & 31);
5630 [(set (match_operand:DI 0 "register_operand" "")
5631 (ashift:DI (match_operand:DI 1 "register_operand" "")
5632 (match_operand:SI 2 "small_int" "")))
5633 (clobber (match_operand:SI 3 "register_operand" ""))]
5634 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
5635 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
5636 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
5637 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
5638 && (INTVAL (operands[2]) & 63) < 32
5639 && (INTVAL (operands[2]) & 63) != 0"
5641 [(set (subreg:SI (match_dup 0) 0)
5642 (ashift:SI (subreg:SI (match_dup 1) 0)
5646 (lshiftrt:SI (subreg:SI (match_dup 1) 4)
5649 (set (subreg:SI (match_dup 0) 0)
5650 (ior:SI (subreg:SI (match_dup 0) 0)
5653 (set (subreg:SI (match_dup 0) 4)
5654 (ashift:SI (subreg:SI (match_dup 1) 4)
5657 int amount = INTVAL (operands[2]);
5658 operands[2] = GEN_INT (amount & 31);
5659 operands[4] = GEN_INT ((-amount) & 31);
5663 (define_insn "ashldi3_internal4"
5664 [(set (match_operand:DI 0 "register_operand" "=d")
5665 (ashift:DI (match_operand:DI 1 "register_operand" "d")
5666 (match_operand:SI 2 "arith_operand" "dI")))]
5667 "TARGET_64BIT && !TARGET_MIPS16"
5669 if (GET_CODE (operands[2]) == CONST_INT)
5670 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
5672 return "dsll\t%0,%1,%2";
5674 [(set_attr "type" "arith")
5675 (set_attr "mode" "DI")])
5678 [(set (match_operand:DI 0 "register_operand" "=d,d")
5679 (ashift:DI (match_operand:DI 1 "register_operand" "0,d")
5680 (match_operand:SI 2 "arith_operand" "d,I")))]
5681 "TARGET_64BIT && TARGET_MIPS16"
5683 if (which_alternative == 0)
5684 return "dsll\t%0,%2";
5686 if (GET_CODE (operands[2]) == CONST_INT)
5687 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
5689 return "dsll\t%0,%1,%2";
5691 [(set_attr "type" "arith")
5692 (set_attr "mode" "DI")
5693 (set_attr_alternative "length"
5695 (if_then_else (match_operand:VOID 2 "m16_uimm3_b" "")
5700 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
5703 [(set (match_operand:DI 0 "register_operand" "")
5704 (ashift:DI (match_operand:DI 1 "register_operand" "")
5705 (match_operand:SI 2 "const_int_operand" "")))]
5706 "TARGET_MIPS16 && TARGET_64BIT && !TARGET_DEBUG_D_MODE
5708 && GET_CODE (operands[2]) == CONST_INT
5709 && INTVAL (operands[2]) > 8
5710 && INTVAL (operands[2]) <= 16"
5711 [(set (match_dup 0) (ashift:DI (match_dup 1) (const_int 8)))
5712 (set (match_dup 0) (ashift:DI (match_dup 0) (match_dup 2)))]
5713 { operands[2] = GEN_INT (INTVAL (operands[2]) - 8); })
5715 (define_expand "ashrsi3"
5716 [(set (match_operand:SI 0 "register_operand" "=d")
5717 (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
5718 (match_operand:SI 2 "arith_operand" "dI")))]
5721 /* On the mips16, a shift of more than 8 is a four byte instruction,
5722 so, for a shift between 8 and 16, it is just as fast to do two
5723 shifts of 8 or less. If there is a lot of shifting going on, we
5724 may win in CSE. Otherwise combine will put the shifts back
5728 && GET_CODE (operands[2]) == CONST_INT
5729 && INTVAL (operands[2]) > 8
5730 && INTVAL (operands[2]) <= 16)
5732 rtx temp = gen_reg_rtx (SImode);
5734 emit_insn (gen_ashrsi3_internal2 (temp, operands[1], GEN_INT (8)));
5735 emit_insn (gen_ashrsi3_internal2 (operands[0], temp,
5736 GEN_INT (INTVAL (operands[2]) - 8)));
5741 (define_insn "ashrsi3_internal1"
5742 [(set (match_operand:SI 0 "register_operand" "=d")
5743 (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
5744 (match_operand:SI 2 "arith_operand" "dI")))]
5747 if (GET_CODE (operands[2]) == CONST_INT)
5748 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
5750 return "sra\t%0,%1,%2";
5752 [(set_attr "type" "arith")
5753 (set_attr "mode" "SI")])
5755 (define_insn "ashrsi3_internal2"
5756 [(set (match_operand:SI 0 "register_operand" "=d,d")
5757 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0,d")
5758 (match_operand:SI 2 "arith_operand" "d,I")))]
5761 if (which_alternative == 0)
5762 return "sra\t%0,%2";
5764 if (GET_CODE (operands[2]) == CONST_INT)
5765 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
5767 return "sra\t%0,%1,%2";
5769 [(set_attr "type" "arith")
5770 (set_attr "mode" "SI")
5771 (set_attr_alternative "length"
5773 (if_then_else (match_operand:VOID 2 "m16_uimm3_b" "")
5778 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
5781 [(set (match_operand:SI 0 "register_operand" "")
5782 (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
5783 (match_operand:SI 2 "const_int_operand" "")))]
5784 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
5785 && GET_CODE (operands[2]) == CONST_INT
5786 && INTVAL (operands[2]) > 8
5787 && INTVAL (operands[2]) <= 16"
5788 [(set (match_dup 0) (ashiftrt:SI (match_dup 1) (const_int 8)))
5789 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (match_dup 2)))]
5790 { operands[2] = GEN_INT (INTVAL (operands[2]) - 8); })
5792 (define_expand "ashrdi3"
5793 [(parallel [(set (match_operand:DI 0 "register_operand" "")
5794 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
5795 (match_operand:SI 2 "arith_operand" "")))
5796 (clobber (match_dup 3))])]
5797 "TARGET_64BIT || (!TARGET_DEBUG_G_MODE && !TARGET_MIPS16)"
5801 /* On the mips16, a shift of more than 8 is a four byte
5802 instruction, so, for a shift between 8 and 16, it is just as
5803 fast to do two shifts of 8 or less. If there is a lot of
5804 shifting going on, we may win in CSE. Otherwise combine will
5805 put the shifts back together again. */
5808 && GET_CODE (operands[2]) == CONST_INT
5809 && INTVAL (operands[2]) > 8
5810 && INTVAL (operands[2]) <= 16)
5812 rtx temp = gen_reg_rtx (DImode);
5814 emit_insn (gen_ashrdi3_internal4 (temp, operands[1], GEN_INT (8)));
5815 emit_insn (gen_ashrdi3_internal4 (operands[0], temp,
5816 GEN_INT (INTVAL (operands[2]) - 8)));
5820 emit_insn (gen_ashrdi3_internal4 (operands[0], operands[1],
5825 operands[3] = gen_reg_rtx (SImode);
5829 (define_insn "ashrdi3_internal"
5830 [(set (match_operand:DI 0 "register_operand" "=&d")
5831 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
5832 (match_operand:SI 2 "register_operand" "d")))
5833 (clobber (match_operand:SI 3 "register_operand" "=d"))]
5834 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16"
5851 [(set_attr "type" "darith")
5852 (set_attr "mode" "DI")
5853 (set_attr "length" "48")])
5856 (define_insn "ashrdi3_internal2"
5857 [(set (match_operand:DI 0 "register_operand" "=d")
5858 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
5859 (match_operand:SI 2 "small_int" "IJK")))
5860 (clobber (match_operand:SI 3 "register_operand" "=d"))]
5861 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && (INTVAL (operands[2]) & 32) != 0"
5863 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
5864 return "sra\t%L0,%M1,%2\;sra\t%M0,%M1,31";
5866 [(set_attr "type" "darith")
5867 (set_attr "mode" "DI")
5868 (set_attr "length" "8")])
5872 [(set (match_operand:DI 0 "register_operand" "")
5873 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
5874 (match_operand:SI 2 "small_int" "")))
5875 (clobber (match_operand:SI 3 "register_operand" ""))]
5876 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
5877 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
5878 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
5879 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
5880 && (INTVAL (operands[2]) & 32) != 0"
5882 [(set (subreg:SI (match_dup 0) 0) (ashiftrt:SI (subreg:SI (match_dup 1) 4) (match_dup 2)))
5883 (set (subreg:SI (match_dup 0) 4) (ashiftrt:SI (subreg:SI (match_dup 1) 4) (const_int 31)))]
5885 "operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);")
5889 [(set (match_operand:DI 0 "register_operand" "")
5890 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
5891 (match_operand:SI 2 "small_int" "")))
5892 (clobber (match_operand:SI 3 "register_operand" ""))]
5893 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
5894 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
5895 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
5896 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
5897 && (INTVAL (operands[2]) & 32) != 0"
5899 [(set (subreg:SI (match_dup 0) 4) (ashiftrt:SI (subreg:SI (match_dup 1) 0) (match_dup 2)))
5900 (set (subreg:SI (match_dup 0) 0) (ashiftrt:SI (subreg:SI (match_dup 1) 0) (const_int 31)))]
5902 "operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);")
5905 (define_insn "ashrdi3_internal3"
5906 [(set (match_operand:DI 0 "register_operand" "=d")
5907 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
5908 (match_operand:SI 2 "small_int" "IJK")))
5909 (clobber (match_operand:SI 3 "register_operand" "=d"))]
5910 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
5911 && (INTVAL (operands[2]) & 63) < 32
5912 && (INTVAL (operands[2]) & 63) != 0"
5914 int amount = INTVAL (operands[2]);
5916 operands[2] = GEN_INT (amount & 31);
5917 operands[4] = GEN_INT ((-amount) & 31);
5919 return "srl\t%L0,%L1,%2\;sll\t%3,%M1,%4\;or\t%L0,%L0,%3\;sra\t%M0,%M1,%2";
5921 [(set_attr "type" "darith")
5922 (set_attr "mode" "DI")
5923 (set_attr "length" "16")])
5927 [(set (match_operand:DI 0 "register_operand" "")
5928 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
5929 (match_operand:SI 2 "small_int" "")))
5930 (clobber (match_operand:SI 3 "register_operand" ""))]
5931 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
5932 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
5933 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
5934 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
5935 && (INTVAL (operands[2]) & 63) < 32
5936 && (INTVAL (operands[2]) & 63) != 0"
5938 [(set (subreg:SI (match_dup 0) 0)
5939 (lshiftrt:SI (subreg:SI (match_dup 1) 0)
5943 (ashift:SI (subreg:SI (match_dup 1) 4)
5946 (set (subreg:SI (match_dup 0) 0)
5947 (ior:SI (subreg:SI (match_dup 0) 0)
5950 (set (subreg:SI (match_dup 0) 4)
5951 (ashiftrt:SI (subreg:SI (match_dup 1) 4)
5954 int amount = INTVAL (operands[2]);
5955 operands[2] = GEN_INT (amount & 31);
5956 operands[4] = GEN_INT ((-amount) & 31);
5961 [(set (match_operand:DI 0 "register_operand" "")
5962 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
5963 (match_operand:SI 2 "small_int" "")))
5964 (clobber (match_operand:SI 3 "register_operand" ""))]
5965 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
5966 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
5967 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
5968 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
5969 && (INTVAL (operands[2]) & 63) < 32
5970 && (INTVAL (operands[2]) & 63) != 0"
5972 [(set (subreg:SI (match_dup 0) 4)
5973 (lshiftrt:SI (subreg:SI (match_dup 1) 4)
5977 (ashift:SI (subreg:SI (match_dup 1) 0)
5980 (set (subreg:SI (match_dup 0) 4)
5981 (ior:SI (subreg:SI (match_dup 0) 4)
5984 (set (subreg:SI (match_dup 0) 0)
5985 (ashiftrt:SI (subreg:SI (match_dup 1) 0)
5988 int amount = INTVAL (operands[2]);
5989 operands[2] = GEN_INT (amount & 31);
5990 operands[4] = GEN_INT ((-amount) & 31);
5994 (define_insn "ashrdi3_internal4"
5995 [(set (match_operand:DI 0 "register_operand" "=d")
5996 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
5997 (match_operand:SI 2 "arith_operand" "dI")))]
5998 "TARGET_64BIT && !TARGET_MIPS16"
6000 if (GET_CODE (operands[2]) == CONST_INT)
6001 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
6003 return "dsra\t%0,%1,%2";
6005 [(set_attr "type" "arith")
6006 (set_attr "mode" "DI")])
6009 [(set (match_operand:DI 0 "register_operand" "=d,d")
6010 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0,0")
6011 (match_operand:SI 2 "arith_operand" "d,I")))]
6012 "TARGET_64BIT && TARGET_MIPS16"
6014 if (GET_CODE (operands[2]) == CONST_INT)
6015 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
6017 return "dsra\t%0,%2";
6019 [(set_attr "type" "arith")
6020 (set_attr "mode" "DI")
6021 (set_attr_alternative "length"
6023 (if_then_else (match_operand:VOID 2 "m16_uimm3_b" "")
6027 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
6030 [(set (match_operand:DI 0 "register_operand" "")
6031 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
6032 (match_operand:SI 2 "const_int_operand" "")))]
6033 "TARGET_MIPS16 && TARGET_64BIT && !TARGET_DEBUG_D_MODE
6035 && GET_CODE (operands[2]) == CONST_INT
6036 && INTVAL (operands[2]) > 8
6037 && INTVAL (operands[2]) <= 16"
6038 [(set (match_dup 0) (ashiftrt:DI (match_dup 1) (const_int 8)))
6039 (set (match_dup 0) (ashiftrt:DI (match_dup 0) (match_dup 2)))]
6040 { operands[2] = GEN_INT (INTVAL (operands[2]) - 8); })
6042 (define_expand "lshrsi3"
6043 [(set (match_operand:SI 0 "register_operand" "=d")
6044 (lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
6045 (match_operand:SI 2 "arith_operand" "dI")))]
6048 /* On the mips16, a shift of more than 8 is a four byte instruction,
6049 so, for a shift between 8 and 16, it is just as fast to do two
6050 shifts of 8 or less. If there is a lot of shifting going on, we
6051 may win in CSE. Otherwise combine will put the shifts back
6055 && GET_CODE (operands[2]) == CONST_INT
6056 && INTVAL (operands[2]) > 8
6057 && INTVAL (operands[2]) <= 16)
6059 rtx temp = gen_reg_rtx (SImode);
6061 emit_insn (gen_lshrsi3_internal2 (temp, operands[1], GEN_INT (8)));
6062 emit_insn (gen_lshrsi3_internal2 (operands[0], temp,
6063 GEN_INT (INTVAL (operands[2]) - 8)));
6068 (define_insn "lshrsi3_internal1"
6069 [(set (match_operand:SI 0 "register_operand" "=d")
6070 (lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
6071 (match_operand:SI 2 "arith_operand" "dI")))]
6074 if (GET_CODE (operands[2]) == CONST_INT)
6075 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
6077 return "srl\t%0,%1,%2";
6079 [(set_attr "type" "arith")
6080 (set_attr "mode" "SI")])
6082 (define_insn "lshrsi3_internal2"
6083 [(set (match_operand:SI 0 "register_operand" "=d,d")
6084 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0,d")
6085 (match_operand:SI 2 "arith_operand" "d,I")))]
6088 if (which_alternative == 0)
6089 return "srl\t%0,%2";
6091 if (GET_CODE (operands[2]) == CONST_INT)
6092 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
6094 return "srl\t%0,%1,%2";
6096 [(set_attr "type" "arith")
6097 (set_attr "mode" "SI")
6098 (set_attr_alternative "length"
6100 (if_then_else (match_operand:VOID 2 "m16_uimm3_b" "")
6105 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
6108 [(set (match_operand:SI 0 "register_operand" "")
6109 (lshiftrt:SI (match_operand:SI 1 "register_operand" "")
6110 (match_operand:SI 2 "const_int_operand" "")))]
6111 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
6112 && GET_CODE (operands[2]) == CONST_INT
6113 && INTVAL (operands[2]) > 8
6114 && INTVAL (operands[2]) <= 16"
6115 [(set (match_dup 0) (lshiftrt:SI (match_dup 1) (const_int 8)))
6116 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
6117 { operands[2] = GEN_INT (INTVAL (operands[2]) - 8); })
6119 ;; If we load a byte on the mips16 as a bitfield, the resulting
6120 ;; sequence of instructions is too complicated for combine, because it
6121 ;; involves four instructions: a load, a shift, a constant load into a
6122 ;; register, and an and (the key problem here is that the mips16 does
6123 ;; not have and immediate). We recognize a shift of a load in order
6124 ;; to make it simple enough for combine to understand.
6126 ;; The length here is the worst case: the length of the split version
6127 ;; will be more accurate.
6128 (define_insn_and_split ""
6129 [(set (match_operand:SI 0 "register_operand" "=d")
6130 (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6131 (match_operand:SI 2 "immediate_operand" "I")))]
6135 [(set (match_dup 0) (match_dup 1))
6136 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
6138 [(set_attr "type" "load")
6139 (set_attr "mode" "SI")
6140 (set_attr "length" "16")])
6142 (define_expand "lshrdi3"
6143 [(parallel [(set (match_operand:DI 0 "register_operand" "")
6144 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
6145 (match_operand:SI 2 "arith_operand" "")))
6146 (clobber (match_dup 3))])]
6147 "TARGET_64BIT || (!TARGET_DEBUG_G_MODE && !TARGET_MIPS16)"
6151 /* On the mips16, a shift of more than 8 is a four byte
6152 instruction, so, for a shift between 8 and 16, it is just as
6153 fast to do two shifts of 8 or less. If there is a lot of
6154 shifting going on, we may win in CSE. Otherwise combine will
6155 put the shifts back together again. */
6158 && GET_CODE (operands[2]) == CONST_INT
6159 && INTVAL (operands[2]) > 8
6160 && INTVAL (operands[2]) <= 16)
6162 rtx temp = gen_reg_rtx (DImode);
6164 emit_insn (gen_lshrdi3_internal4 (temp, operands[1], GEN_INT (8)));
6165 emit_insn (gen_lshrdi3_internal4 (operands[0], temp,
6166 GEN_INT (INTVAL (operands[2]) - 8)));
6170 emit_insn (gen_lshrdi3_internal4 (operands[0], operands[1],
6175 operands[3] = gen_reg_rtx (SImode);
6179 (define_insn "lshrdi3_internal"
6180 [(set (match_operand:DI 0 "register_operand" "=&d")
6181 (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
6182 (match_operand:SI 2 "register_operand" "d")))
6183 (clobber (match_operand:SI 3 "register_operand" "=d"))]
6184 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16"
6201 [(set_attr "type" "darith")
6202 (set_attr "mode" "DI")
6203 (set_attr "length" "48")])
6206 (define_insn "lshrdi3_internal2"
6207 [(set (match_operand:DI 0 "register_operand" "=d")
6208 (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
6209 (match_operand:SI 2 "small_int" "IJK")))
6210 (clobber (match_operand:SI 3 "register_operand" "=d"))]
6211 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
6212 && (INTVAL (operands[2]) & 32) != 0"
6214 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
6215 return "srl\t%L0,%M1,%2\;move\t%M0,%.";
6217 [(set_attr "type" "darith")
6218 (set_attr "mode" "DI")
6219 (set_attr "length" "8")])
6223 [(set (match_operand:DI 0 "register_operand" "")
6224 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
6225 (match_operand:SI 2 "small_int" "")))
6226 (clobber (match_operand:SI 3 "register_operand" ""))]
6227 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
6228 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
6229 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
6230 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
6231 && (INTVAL (operands[2]) & 32) != 0"
6233 [(set (subreg:SI (match_dup 0) 0) (lshiftrt:SI (subreg:SI (match_dup 1) 4) (match_dup 2)))
6234 (set (subreg:SI (match_dup 0) 4) (const_int 0))]
6236 "operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);")
6240 [(set (match_operand:DI 0 "register_operand" "")
6241 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
6242 (match_operand:SI 2 "small_int" "")))
6243 (clobber (match_operand:SI 3 "register_operand" ""))]
6244 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
6245 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
6246 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
6247 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
6248 && (INTVAL (operands[2]) & 32) != 0"
6250 [(set (subreg:SI (match_dup 0) 4) (lshiftrt:SI (subreg:SI (match_dup 1) 0) (match_dup 2)))
6251 (set (subreg:SI (match_dup 0) 0) (const_int 0))]
6253 "operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);")
6256 (define_insn "lshrdi3_internal3"
6257 [(set (match_operand:DI 0 "register_operand" "=d")
6258 (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
6259 (match_operand:SI 2 "small_int" "IJK")))
6260 (clobber (match_operand:SI 3 "register_operand" "=d"))]
6261 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
6262 && (INTVAL (operands[2]) & 63) < 32
6263 && (INTVAL (operands[2]) & 63) != 0"
6265 int amount = INTVAL (operands[2]);
6267 operands[2] = GEN_INT (amount & 31);
6268 operands[4] = GEN_INT ((-amount) & 31);
6270 return "srl\t%L0,%L1,%2\;sll\t%3,%M1,%4\;or\t%L0,%L0,%3\;srl\t%M0,%M1,%2";
6272 [(set_attr "type" "darith")
6273 (set_attr "mode" "DI")
6274 (set_attr "length" "16")])
6278 [(set (match_operand:DI 0 "register_operand" "")
6279 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
6280 (match_operand:SI 2 "small_int" "")))
6281 (clobber (match_operand:SI 3 "register_operand" ""))]
6282 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
6283 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
6284 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
6285 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
6286 && (INTVAL (operands[2]) & 63) < 32
6287 && (INTVAL (operands[2]) & 63) != 0"
6289 [(set (subreg:SI (match_dup 0) 0)
6290 (lshiftrt:SI (subreg:SI (match_dup 1) 0)
6294 (ashift:SI (subreg:SI (match_dup 1) 4)
6297 (set (subreg:SI (match_dup 0) 0)
6298 (ior:SI (subreg:SI (match_dup 0) 0)
6301 (set (subreg:SI (match_dup 0) 4)
6302 (lshiftrt:SI (subreg:SI (match_dup 1) 4)
6305 int amount = INTVAL (operands[2]);
6306 operands[2] = GEN_INT (amount & 31);
6307 operands[4] = GEN_INT ((-amount) & 31);
6312 [(set (match_operand:DI 0 "register_operand" "")
6313 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
6314 (match_operand:SI 2 "small_int" "")))
6315 (clobber (match_operand:SI 3 "register_operand" ""))]
6316 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
6317 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
6318 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
6319 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
6320 && (INTVAL (operands[2]) & 63) < 32
6321 && (INTVAL (operands[2]) & 63) != 0"
6323 [(set (subreg:SI (match_dup 0) 4)
6324 (lshiftrt:SI (subreg:SI (match_dup 1) 4)
6328 (ashift:SI (subreg:SI (match_dup 1) 0)
6331 (set (subreg:SI (match_dup 0) 4)
6332 (ior:SI (subreg:SI (match_dup 0) 4)
6335 (set (subreg:SI (match_dup 0) 0)
6336 (lshiftrt:SI (subreg:SI (match_dup 1) 0)
6339 int amount = INTVAL (operands[2]);
6340 operands[2] = GEN_INT (amount & 31);
6341 operands[4] = GEN_INT ((-amount) & 31);
6345 (define_insn "lshrdi3_internal4"
6346 [(set (match_operand:DI 0 "register_operand" "=d")
6347 (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
6348 (match_operand:SI 2 "arith_operand" "dI")))]
6349 "TARGET_64BIT && !TARGET_MIPS16"
6351 if (GET_CODE (operands[2]) == CONST_INT)
6352 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
6354 return "dsrl\t%0,%1,%2";
6356 [(set_attr "type" "arith")
6357 (set_attr "mode" "DI")])
6360 [(set (match_operand:DI 0 "register_operand" "=d,d")
6361 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0,0")
6362 (match_operand:SI 2 "arith_operand" "d,I")))]
6363 "TARGET_64BIT && TARGET_MIPS16"
6365 if (GET_CODE (operands[2]) == CONST_INT)
6366 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
6368 return "dsrl\t%0,%2";
6370 [(set_attr "type" "arith")
6371 (set_attr "mode" "DI")
6372 (set_attr_alternative "length"
6374 (if_then_else (match_operand:VOID 2 "m16_uimm3_b" "")
6378 (define_insn "rotrsi3"
6379 [(set (match_operand:SI 0 "register_operand" "=d")
6380 (rotatert:SI (match_operand:SI 1 "register_operand" "d")
6381 (match_operand:SI 2 "arith_operand" "dn")))]
6384 if (TARGET_SR71K && GET_CODE (operands[2]) != CONST_INT)
6385 return "rorv\t%0,%1,%2";
6387 if ((GET_CODE (operands[2]) == CONST_INT)
6388 && (INTVAL (operands[2]) < 0 || INTVAL (operands[2]) >= 32))
6391 return "ror\t%0,%1,%2";
6393 [(set_attr "type" "arith")
6394 (set_attr "mode" "SI")])
6396 (define_insn "rotrdi3"
6397 [(set (match_operand:DI 0 "register_operand" "=d")
6398 (rotatert:DI (match_operand:DI 1 "register_operand" "d")
6399 (match_operand:DI 2 "arith_operand" "dn")))]
6404 if (GET_CODE (operands[2]) != CONST_INT)
6405 return "drorv\t%0,%1,%2";
6407 if (INTVAL (operands[2]) >= 32 && INTVAL (operands[2]) <= 63)
6408 return "dror32\t%0,%1,%2";
6411 if ((GET_CODE (operands[2]) == CONST_INT)
6412 && (INTVAL (operands[2]) < 0 || INTVAL (operands[2]) >= 64))
6415 return "dror\t%0,%1,%2";
6417 [(set_attr "type" "arith")
6418 (set_attr "mode" "DI")])
6421 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
6424 [(set (match_operand:DI 0 "register_operand" "")
6425 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
6426 (match_operand:SI 2 "const_int_operand" "")))]
6427 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
6428 && GET_CODE (operands[2]) == CONST_INT
6429 && INTVAL (operands[2]) > 8
6430 && INTVAL (operands[2]) <= 16"
6431 [(set (match_dup 0) (lshiftrt:DI (match_dup 1) (const_int 8)))
6432 (set (match_dup 0) (lshiftrt:DI (match_dup 0) (match_dup 2)))]
6433 { operands[2] = GEN_INT (INTVAL (operands[2]) - 8); })
6436 ;; ....................
6440 ;; ....................
6442 ;; Flow here is rather complex:
6444 ;; 1) The cmp{si,di,sf,df} routine is called. It deposits the
6445 ;; arguments into the branch_cmp array, and the type into
6446 ;; branch_type. No RTL is generated.
6448 ;; 2) The appropriate branch define_expand is called, which then
6449 ;; creates the appropriate RTL for the comparison and branch.
6450 ;; Different CC modes are used, based on what type of branch is
6451 ;; done, so that we can constrain things appropriately. There
6452 ;; are assumptions in the rest of GCC that break if we fold the
6453 ;; operands into the branches for integer operations, and use cc0
6454 ;; for floating point, so we use the fp status register instead.
6455 ;; If needed, an appropriate temporary is created to hold the
6456 ;; of the integer compare.
6458 (define_expand "cmpsi"
6460 (compare:CC (match_operand:SI 0 "register_operand" "")
6461 (match_operand:SI 1 "arith_operand" "")))]
6464 branch_cmp[0] = operands[0];
6465 branch_cmp[1] = operands[1];
6466 branch_type = CMP_SI;
6470 (define_expand "cmpdi"
6472 (compare:CC (match_operand:DI 0 "register_operand" "")
6473 (match_operand:DI 1 "arith_operand" "")))]
6476 branch_cmp[0] = operands[0];
6477 branch_cmp[1] = operands[1];
6478 branch_type = CMP_DI;
6482 (define_expand "cmpdf"
6484 (compare:CC (match_operand:DF 0 "register_operand" "")
6485 (match_operand:DF 1 "register_operand" "")))]
6486 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
6488 branch_cmp[0] = operands[0];
6489 branch_cmp[1] = operands[1];
6490 branch_type = CMP_DF;
6494 (define_expand "cmpsf"
6496 (compare:CC (match_operand:SF 0 "register_operand" "")
6497 (match_operand:SF 1 "register_operand" "")))]
6500 branch_cmp[0] = operands[0];
6501 branch_cmp[1] = operands[1];
6502 branch_type = CMP_SF;
6507 ;; ....................
6509 ;; CONDITIONAL BRANCHES
6511 ;; ....................
6513 ;; Conditional branches on floating-point equality tests.
6515 (define_insn "branch_fp"
6518 (match_operator:CC 0 "cmp_op"
6519 [(match_operand:CC 2 "register_operand" "z")
6521 (label_ref (match_operand 1 "" ""))
6525 return mips_output_conditional_branch (insn,
6527 /*two_operands_p=*/0,
6530 get_attr_length (insn));
6532 [(set_attr "type" "branch")
6533 (set_attr "mode" "none")])
6535 (define_insn "branch_fp_inverted"
6538 (match_operator:CC 0 "cmp_op"
6539 [(match_operand:CC 2 "register_operand" "z")
6542 (label_ref (match_operand 1 "" ""))))]
6545 return mips_output_conditional_branch (insn,
6547 /*two_operands_p=*/0,
6550 get_attr_length (insn));
6552 [(set_attr "type" "branch")
6553 (set_attr "mode" "none")])
6555 ;; Conditional branches on comparisons with zero.
6557 (define_insn "branch_zero"
6560 (match_operator:SI 0 "cmp_op"
6561 [(match_operand:SI 2 "register_operand" "d")
6563 (label_ref (match_operand 1 "" ""))
6567 return mips_output_conditional_branch (insn,
6569 /*two_operands_p=*/0,
6572 get_attr_length (insn));
6574 [(set_attr "type" "branch")
6575 (set_attr "mode" "none")])
6577 (define_insn "branch_zero_inverted"
6580 (match_operator:SI 0 "cmp_op"
6581 [(match_operand:SI 2 "register_operand" "d")
6584 (label_ref (match_operand 1 "" ""))))]
6587 return mips_output_conditional_branch (insn,
6589 /*two_operands_p=*/0,
6592 get_attr_length (insn));
6594 [(set_attr "type" "branch")
6595 (set_attr "mode" "none")])
6597 (define_insn "branch_zero_di"
6600 (match_operator:DI 0 "cmp_op"
6601 [(match_operand:DI 2 "register_operand" "d")
6603 (label_ref (match_operand 1 "" ""))
6607 return mips_output_conditional_branch (insn,
6609 /*two_operands_p=*/0,
6612 get_attr_length (insn));
6614 [(set_attr "type" "branch")
6615 (set_attr "mode" "none")])
6617 (define_insn "branch_zero_di_inverted"
6620 (match_operator:DI 0 "cmp_op"
6621 [(match_operand:DI 2 "register_operand" "d")
6624 (label_ref (match_operand 1 "" ""))))]
6627 return mips_output_conditional_branch (insn,
6629 /*two_operands_p=*/0,
6632 get_attr_length (insn));
6634 [(set_attr "type" "branch")
6635 (set_attr "mode" "none")])
6637 ;; Conditional branch on equality comparison.
6639 (define_insn "branch_equality"
6642 (match_operator:SI 0 "equality_op"
6643 [(match_operand:SI 2 "register_operand" "d")
6644 (match_operand:SI 3 "register_operand" "d")])
6645 (label_ref (match_operand 1 "" ""))
6649 return mips_output_conditional_branch (insn,
6651 /*two_operands_p=*/1,
6654 get_attr_length (insn));
6656 [(set_attr "type" "branch")
6657 (set_attr "mode" "none")])
6659 (define_insn "branch_equality_di"
6662 (match_operator:DI 0 "equality_op"
6663 [(match_operand:DI 2 "register_operand" "d")
6664 (match_operand:DI 3 "register_operand" "d")])
6665 (label_ref (match_operand 1 "" ""))
6669 return mips_output_conditional_branch (insn,
6671 /*two_operands_p=*/1,
6674 get_attr_length (insn));
6676 [(set_attr "type" "branch")
6677 (set_attr "mode" "none")])
6679 (define_insn "branch_equality_inverted"
6682 (match_operator:SI 0 "equality_op"
6683 [(match_operand:SI 2 "register_operand" "d")
6684 (match_operand:SI 3 "register_operand" "d")])
6686 (label_ref (match_operand 1 "" ""))))]
6689 return mips_output_conditional_branch (insn,
6691 /*two_operands_p=*/1,
6694 get_attr_length (insn));
6696 [(set_attr "type" "branch")
6697 (set_attr "mode" "none")])
6699 (define_insn "branch_equality_di_inverted"
6702 (match_operator:DI 0 "equality_op"
6703 [(match_operand:DI 2 "register_operand" "d")
6704 (match_operand:DI 3 "register_operand" "d")])
6706 (label_ref (match_operand 1 "" ""))))]
6709 return mips_output_conditional_branch (insn,
6711 /*two_operands_p=*/1,
6714 get_attr_length (insn));
6716 [(set_attr "type" "branch")
6717 (set_attr "mode" "none")])
6723 (if_then_else (match_operator:SI 0 "equality_op"
6724 [(match_operand:SI 1 "register_operand" "d,t")
6726 (match_operand 2 "pc_or_label_operand" "")
6727 (match_operand 3 "pc_or_label_operand" "")))]
6730 if (operands[2] != pc_rtx)
6732 if (which_alternative == 0)
6733 return "b%C0z\t%1,%2";
6735 return "bt%C0z\t%2";
6739 if (which_alternative == 0)
6740 return "b%N0z\t%1,%3";
6742 return "bt%N0z\t%3";
6745 [(set_attr "type" "branch")
6746 (set_attr "mode" "none")
6747 (set_attr "length" "8")])
6751 (if_then_else (match_operator:DI 0 "equality_op"
6752 [(match_operand:DI 1 "register_operand" "d,t")
6754 (match_operand 2 "pc_or_label_operand" "")
6755 (match_operand 3 "pc_or_label_operand" "")))]
6758 if (operands[2] != pc_rtx)
6760 if (which_alternative == 0)
6761 return "b%C0z\t%1,%2";
6763 return "bt%C0z\t%2";
6767 if (which_alternative == 0)
6768 return "b%N0z\t%1,%3";
6770 return "bt%N0z\t%3";
6773 [(set_attr "type" "branch")
6774 (set_attr "mode" "none")
6775 (set_attr "length" "8")])
6777 (define_expand "bunordered"
6779 (if_then_else (unordered:CC (cc0)
6781 (label_ref (match_operand 0 "" ""))
6785 gen_conditional_branch (operands, UNORDERED);
6789 (define_expand "bordered"
6791 (if_then_else (ordered:CC (cc0)
6793 (label_ref (match_operand 0 "" ""))
6797 gen_conditional_branch (operands, ORDERED);
6801 (define_expand "bunlt"
6803 (if_then_else (unlt:CC (cc0)
6805 (label_ref (match_operand 0 "" ""))
6809 gen_conditional_branch (operands, UNLT);
6813 (define_expand "bunge"
6815 (if_then_else (unge:CC (cc0)
6817 (label_ref (match_operand 0 "" ""))
6821 gen_conditional_branch (operands, UNGE);
6825 (define_expand "buneq"
6827 (if_then_else (uneq:CC (cc0)
6829 (label_ref (match_operand 0 "" ""))
6833 gen_conditional_branch (operands, UNEQ);
6837 (define_expand "bltgt"
6839 (if_then_else (ltgt:CC (cc0)
6841 (label_ref (match_operand 0 "" ""))
6845 gen_conditional_branch (operands, LTGT);
6849 (define_expand "bunle"
6851 (if_then_else (unle:CC (cc0)
6853 (label_ref (match_operand 0 "" ""))
6857 gen_conditional_branch (operands, UNLE);
6861 (define_expand "bungt"
6863 (if_then_else (ungt:CC (cc0)
6865 (label_ref (match_operand 0 "" ""))
6869 gen_conditional_branch (operands, UNGT);
6873 (define_expand "beq"
6875 (if_then_else (eq:CC (cc0)
6877 (label_ref (match_operand 0 "" ""))
6881 gen_conditional_branch (operands, EQ);
6885 (define_expand "bne"
6887 (if_then_else (ne:CC (cc0)
6889 (label_ref (match_operand 0 "" ""))
6893 gen_conditional_branch (operands, NE);
6897 (define_expand "bgt"
6899 (if_then_else (gt:CC (cc0)
6901 (label_ref (match_operand 0 "" ""))
6905 gen_conditional_branch (operands, GT);
6909 (define_expand "bge"
6911 (if_then_else (ge:CC (cc0)
6913 (label_ref (match_operand 0 "" ""))
6917 gen_conditional_branch (operands, GE);
6921 (define_expand "blt"
6923 (if_then_else (lt:CC (cc0)
6925 (label_ref (match_operand 0 "" ""))
6929 gen_conditional_branch (operands, LT);
6933 (define_expand "ble"
6935 (if_then_else (le:CC (cc0)
6937 (label_ref (match_operand 0 "" ""))
6941 gen_conditional_branch (operands, LE);
6945 (define_expand "bgtu"
6947 (if_then_else (gtu:CC (cc0)
6949 (label_ref (match_operand 0 "" ""))
6953 gen_conditional_branch (operands, GTU);
6957 (define_expand "bgeu"
6959 (if_then_else (geu:CC (cc0)
6961 (label_ref (match_operand 0 "" ""))
6965 gen_conditional_branch (operands, GEU);
6969 (define_expand "bltu"
6971 (if_then_else (ltu:CC (cc0)
6973 (label_ref (match_operand 0 "" ""))
6977 gen_conditional_branch (operands, LTU);
6981 (define_expand "bleu"
6983 (if_then_else (leu:CC (cc0)
6985 (label_ref (match_operand 0 "" ""))
6989 gen_conditional_branch (operands, LEU);
6994 ;; ....................
6996 ;; SETTING A REGISTER FROM A COMPARISON
6998 ;; ....................
7000 (define_expand "seq"
7001 [(set (match_operand:SI 0 "register_operand" "=d")
7002 (eq:SI (match_dup 1)
7006 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
7009 /* Set up operands from compare. */
7010 operands[1] = branch_cmp[0];
7011 operands[2] = branch_cmp[1];
7013 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
7015 gen_int_relational (EQ, operands[0], operands[1], operands[2], (int *)0);
7019 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
7020 operands[2] = force_reg (SImode, operands[2]);
7022 /* Fall through and generate default code. */
7026 (define_insn "seq_si_zero"
7027 [(set (match_operand:SI 0 "register_operand" "=d")
7028 (eq:SI (match_operand:SI 1 "register_operand" "d")
7032 [(set_attr "type" "arith")
7033 (set_attr "mode" "SI")])
7036 [(set (match_operand:SI 0 "register_operand" "=t")
7037 (eq:SI (match_operand:SI 1 "register_operand" "d")
7041 [(set_attr "type" "arith")
7042 (set_attr "mode" "SI")])
7044 (define_insn "seq_di_zero"
7045 [(set (match_operand:DI 0 "register_operand" "=d")
7046 (eq:DI (match_operand:DI 1 "register_operand" "d")
7048 "TARGET_64BIT && !TARGET_MIPS16"
7050 [(set_attr "type" "arith")
7051 (set_attr "mode" "DI")])
7054 [(set (match_operand:DI 0 "register_operand" "=t")
7055 (eq:DI (match_operand:DI 1 "register_operand" "d")
7057 "TARGET_64BIT && TARGET_MIPS16"
7059 [(set_attr "type" "arith")
7060 (set_attr "mode" "DI")])
7062 (define_insn "seq_si"
7063 [(set (match_operand:SI 0 "register_operand" "=d,d")
7064 (eq:SI (match_operand:SI 1 "register_operand" "%d,d")
7065 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
7066 "TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7068 xor\t%0,%1,%2\;sltu\t%0,%0,1
7069 xori\t%0,%1,%2\;sltu\t%0,%0,1"
7070 [(set_attr "type" "arith")
7071 (set_attr "mode" "SI")
7072 (set_attr "length" "8")])
7075 [(set (match_operand:SI 0 "register_operand" "")
7076 (eq:SI (match_operand:SI 1 "register_operand" "")
7077 (match_operand:SI 2 "uns_arith_operand" "")))]
7078 "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE && !TARGET_MIPS16
7079 && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)"
7081 (xor:SI (match_dup 1)
7084 (ltu:SI (match_dup 0)
7088 (define_insn "seq_di"
7089 [(set (match_operand:DI 0 "register_operand" "=d,d")
7090 (eq:DI (match_operand:DI 1 "register_operand" "%d,d")
7091 (match_operand:DI 2 "uns_arith_operand" "d,K")))]
7092 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7094 xor\t%0,%1,%2\;sltu\t%0,%0,1
7095 xori\t%0,%1,%2\;sltu\t%0,%0,1"
7096 [(set_attr "type" "arith")
7097 (set_attr "mode" "DI")
7098 (set_attr "length" "8")])
7101 [(set (match_operand:DI 0 "register_operand" "")
7102 (eq:DI (match_operand:DI 1 "register_operand" "")
7103 (match_operand:DI 2 "uns_arith_operand" "")))]
7104 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
7106 && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)"
7108 (xor:DI (match_dup 1)
7111 (ltu:DI (match_dup 0)
7115 ;; On the mips16 the default code is better than using sltu.
7117 (define_expand "sne"
7118 [(set (match_operand:SI 0 "register_operand" "=d")
7119 (ne:SI (match_dup 1)
7123 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
7126 /* Set up operands from compare. */
7127 operands[1] = branch_cmp[0];
7128 operands[2] = branch_cmp[1];
7130 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE)
7132 gen_int_relational (NE, operands[0], operands[1], operands[2], (int *)0);
7136 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
7137 operands[2] = force_reg (SImode, operands[2]);
7139 /* Fall through and generate default code. */
7142 (define_insn "sne_si_zero"
7143 [(set (match_operand:SI 0 "register_operand" "=d")
7144 (ne:SI (match_operand:SI 1 "register_operand" "d")
7148 [(set_attr "type" "arith")
7149 (set_attr "mode" "SI")])
7151 (define_insn "sne_di_zero"
7152 [(set (match_operand:DI 0 "register_operand" "=d")
7153 (ne:DI (match_operand:DI 1 "register_operand" "d")
7155 "TARGET_64BIT && !TARGET_MIPS16"
7157 [(set_attr "type" "arith")
7158 (set_attr "mode" "DI")])
7160 (define_insn "sne_si"
7161 [(set (match_operand:SI 0 "register_operand" "=d,d")
7162 (ne:SI (match_operand:SI 1 "register_operand" "%d,d")
7163 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
7164 "TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7166 xor\t%0,%1,%2\;sltu\t%0,%.,%0
7167 xori\t%0,%1,%x2\;sltu\t%0,%.,%0"
7168 [(set_attr "type" "arith")
7169 (set_attr "mode" "SI")
7170 (set_attr "length" "8")])
7173 [(set (match_operand:SI 0 "register_operand" "")
7174 (ne:SI (match_operand:SI 1 "register_operand" "")
7175 (match_operand:SI 2 "uns_arith_operand" "")))]
7176 "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE && !TARGET_MIPS16
7177 && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)"
7179 (xor:SI (match_dup 1)
7182 (gtu:SI (match_dup 0)
7186 (define_insn "sne_di"
7187 [(set (match_operand:DI 0 "register_operand" "=d,d")
7188 (ne:DI (match_operand:DI 1 "register_operand" "%d,d")
7189 (match_operand:DI 2 "uns_arith_operand" "d,K")))]
7190 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7192 xor\t%0,%1,%2\;sltu\t%0,%.,%0
7193 xori\t%0,%1,%x2\;sltu\t%0,%.,%0"
7194 [(set_attr "type" "arith")
7195 (set_attr "mode" "DI")
7196 (set_attr "length" "8")])
7199 [(set (match_operand:DI 0 "register_operand" "")
7200 (ne:DI (match_operand:DI 1 "register_operand" "")
7201 (match_operand:DI 2 "uns_arith_operand" "")))]
7202 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
7204 && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)"
7206 (xor:DI (match_dup 1)
7209 (gtu:DI (match_dup 0)
7213 (define_expand "sgt"
7214 [(set (match_operand:SI 0 "register_operand" "=d")
7215 (gt:SI (match_dup 1)
7219 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
7222 /* Set up operands from compare. */
7223 operands[1] = branch_cmp[0];
7224 operands[2] = branch_cmp[1];
7226 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
7228 gen_int_relational (GT, operands[0], operands[1], operands[2], (int *)0);
7232 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) != 0)
7233 operands[2] = force_reg (SImode, operands[2]);
7235 /* Fall through and generate default code. */
7238 (define_insn "sgt_si"
7239 [(set (match_operand:SI 0 "register_operand" "=d")
7240 (gt:SI (match_operand:SI 1 "register_operand" "d")
7241 (match_operand:SI 2 "reg_or_0_operand" "dJ")))]
7244 [(set_attr "type" "arith")
7245 (set_attr "mode" "SI")])
7248 [(set (match_operand:SI 0 "register_operand" "=t")
7249 (gt:SI (match_operand:SI 1 "register_operand" "d")
7250 (match_operand:SI 2 "register_operand" "d")))]
7253 [(set_attr "type" "arith")
7254 (set_attr "mode" "SI")])
7256 (define_insn "sgt_di"
7257 [(set (match_operand:DI 0 "register_operand" "=d")
7258 (gt:DI (match_operand:DI 1 "register_operand" "d")
7259 (match_operand:DI 2 "reg_or_0_operand" "dJ")))]
7260 "TARGET_64BIT && !TARGET_MIPS16"
7262 [(set_attr "type" "arith")
7263 (set_attr "mode" "DI")])
7266 [(set (match_operand:DI 0 "register_operand" "=d")
7267 (gt:DI (match_operand:DI 1 "register_operand" "d")
7268 (match_operand:DI 2 "register_operand" "d")))]
7269 "TARGET_64BIT && TARGET_MIPS16"
7271 [(set_attr "type" "arith")
7272 (set_attr "mode" "DI")])
7274 (define_expand "sge"
7275 [(set (match_operand:SI 0 "register_operand" "=d")
7276 (ge:SI (match_dup 1)
7280 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
7283 /* Set up operands from compare. */
7284 operands[1] = branch_cmp[0];
7285 operands[2] = branch_cmp[1];
7287 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
7289 gen_int_relational (GE, operands[0], operands[1], operands[2], (int *)0);
7293 /* Fall through and generate default code. */
7296 (define_insn "sge_si"
7297 [(set (match_operand:SI 0 "register_operand" "=d")
7298 (ge:SI (match_operand:SI 1 "register_operand" "d")
7299 (match_operand:SI 2 "arith_operand" "dI")))]
7300 "TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7301 "slt\t%0,%1,%2\;xori\t%0,%0,0x0001"
7302 [(set_attr "type" "arith")
7303 (set_attr "mode" "SI")
7304 (set_attr "length" "8")])
7307 [(set (match_operand:SI 0 "register_operand" "")
7308 (ge:SI (match_operand:SI 1 "register_operand" "")
7309 (match_operand:SI 2 "arith_operand" "")))]
7310 "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE && !TARGET_MIPS16"
7312 (lt:SI (match_dup 1)
7315 (xor:SI (match_dup 0)
7319 (define_insn "sge_di"
7320 [(set (match_operand:DI 0 "register_operand" "=d")
7321 (ge:DI (match_operand:DI 1 "register_operand" "d")
7322 (match_operand:DI 2 "arith_operand" "dI")))]
7323 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7324 "slt\t%0,%1,%2\;xori\t%0,%0,0x0001"
7325 [(set_attr "type" "arith")
7326 (set_attr "mode" "DI")
7327 (set_attr "length" "8")])
7330 [(set (match_operand:DI 0 "register_operand" "")
7331 (ge:DI (match_operand:DI 1 "register_operand" "")
7332 (match_operand:DI 2 "arith_operand" "")))]
7333 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
7336 (lt:DI (match_dup 1)
7339 (xor:DI (match_dup 0)
7343 (define_expand "slt"
7344 [(set (match_operand:SI 0 "register_operand" "=d")
7345 (lt:SI (match_dup 1)
7349 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
7352 /* Set up operands from compare. */
7353 operands[1] = branch_cmp[0];
7354 operands[2] = branch_cmp[1];
7356 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
7358 gen_int_relational (LT, operands[0], operands[1], operands[2], (int *)0);
7362 /* Fall through and generate default code. */
7365 (define_insn "slt_si"
7366 [(set (match_operand:SI 0 "register_operand" "=d")
7367 (lt:SI (match_operand:SI 1 "register_operand" "d")
7368 (match_operand:SI 2 "arith_operand" "dI")))]
7371 [(set_attr "type" "arith")
7372 (set_attr "mode" "SI")])
7375 [(set (match_operand:SI 0 "register_operand" "=t,t")
7376 (lt:SI (match_operand:SI 1 "register_operand" "d,d")
7377 (match_operand:SI 2 "arith_operand" "d,I")))]
7380 [(set_attr "type" "arith")
7381 (set_attr "mode" "SI")
7382 (set_attr_alternative "length"
7384 (if_then_else (match_operand:VOID 2 "m16_uimm8_1" "")
7388 (define_insn "slt_di"
7389 [(set (match_operand:DI 0 "register_operand" "=d")
7390 (lt:DI (match_operand:DI 1 "register_operand" "d")
7391 (match_operand:DI 2 "arith_operand" "dI")))]
7392 "TARGET_64BIT && !TARGET_MIPS16"
7394 [(set_attr "type" "arith")
7395 (set_attr "mode" "DI")])
7398 [(set (match_operand:DI 0 "register_operand" "=t,t")
7399 (lt:DI (match_operand:DI 1 "register_operand" "d,d")
7400 (match_operand:DI 2 "arith_operand" "d,I")))]
7401 "TARGET_64BIT && TARGET_MIPS16"
7403 [(set_attr "type" "arith")
7404 (set_attr "mode" "DI")
7405 (set_attr_alternative "length"
7407 (if_then_else (match_operand:VOID 2 "m16_uimm8_1" "")
7411 (define_expand "sle"
7412 [(set (match_operand:SI 0 "register_operand" "=d")
7413 (le:SI (match_dup 1)
7417 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
7420 /* Set up operands from compare. */
7421 operands[1] = branch_cmp[0];
7422 operands[2] = branch_cmp[1];
7424 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
7426 gen_int_relational (LE, operands[0], operands[1], operands[2], (int *)0);
7430 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 32767)
7431 operands[2] = force_reg (SImode, operands[2]);
7433 /* Fall through and generate default code. */
7436 (define_insn "sle_si_const"
7437 [(set (match_operand:SI 0 "register_operand" "=d")
7438 (le:SI (match_operand:SI 1 "register_operand" "d")
7439 (match_operand:SI 2 "small_int" "I")))]
7440 "!TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
7442 operands[2] = GEN_INT (INTVAL (operands[2])+1);
7443 return "slt\t%0,%1,%2";
7445 [(set_attr "type" "arith")
7446 (set_attr "mode" "SI")])
7449 [(set (match_operand:SI 0 "register_operand" "=t")
7450 (le:SI (match_operand:SI 1 "register_operand" "d")
7451 (match_operand:SI 2 "small_int" "I")))]
7452 "TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
7454 operands[2] = GEN_INT (INTVAL (operands[2])+1);
7455 return "slt\t%1,%2";
7457 [(set_attr "type" "arith")
7458 (set_attr "mode" "SI")
7459 (set (attr "length") (if_then_else (match_operand:VOID 2 "m16_uimm8_m1_1" "")
7463 (define_insn "sle_di_const"
7464 [(set (match_operand:DI 0 "register_operand" "=d")
7465 (le:DI (match_operand:DI 1 "register_operand" "d")
7466 (match_operand:DI 2 "small_int" "I")))]
7467 "TARGET_64BIT && !TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
7469 operands[2] = GEN_INT (INTVAL (operands[2])+1);
7470 return "slt\t%0,%1,%2";
7472 [(set_attr "type" "arith")
7473 (set_attr "mode" "DI")])
7476 [(set (match_operand:DI 0 "register_operand" "=t")
7477 (le:DI (match_operand:DI 1 "register_operand" "d")
7478 (match_operand:DI 2 "small_int" "I")))]
7479 "TARGET_64BIT && TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
7481 operands[2] = GEN_INT (INTVAL (operands[2])+1);
7482 return "slt\t%1,%2";
7484 [(set_attr "type" "arith")
7485 (set_attr "mode" "DI")
7486 (set (attr "length") (if_then_else (match_operand:VOID 2 "m16_uimm8_m1_1" "")
7490 (define_insn "sle_si_reg"
7491 [(set (match_operand:SI 0 "register_operand" "=d")
7492 (le:SI (match_operand:SI 1 "register_operand" "d")
7493 (match_operand:SI 2 "register_operand" "d")))]
7494 "TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7495 "slt\t%0,%z2,%1\;xori\t%0,%0,0x0001"
7496 [(set_attr "type" "arith")
7497 (set_attr "mode" "SI")
7498 (set_attr "length" "8")])
7501 [(set (match_operand:SI 0 "register_operand" "")
7502 (le:SI (match_operand:SI 1 "register_operand" "")
7503 (match_operand:SI 2 "register_operand" "")))]
7504 "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE && !TARGET_MIPS16"
7506 (lt:SI (match_dup 2)
7509 (xor:SI (match_dup 0)
7513 (define_insn "sle_di_reg"
7514 [(set (match_operand:DI 0 "register_operand" "=d")
7515 (le:DI (match_operand:DI 1 "register_operand" "d")
7516 (match_operand:DI 2 "register_operand" "d")))]
7517 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7518 "slt\t%0,%z2,%1\;xori\t%0,%0,0x0001"
7519 [(set_attr "type" "arith")
7520 (set_attr "mode" "DI")
7521 (set_attr "length" "8")])
7524 [(set (match_operand:DI 0 "register_operand" "")
7525 (le:DI (match_operand:DI 1 "register_operand" "")
7526 (match_operand:DI 2 "register_operand" "")))]
7527 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
7530 (lt:DI (match_dup 2)
7533 (xor:DI (match_dup 0)
7537 (define_expand "sgtu"
7538 [(set (match_operand:SI 0 "register_operand" "=d")
7539 (gtu:SI (match_dup 1)
7543 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
7546 /* Set up operands from compare. */
7547 operands[1] = branch_cmp[0];
7548 operands[2] = branch_cmp[1];
7550 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
7552 gen_int_relational (GTU, operands[0], operands[1], operands[2], (int *)0);
7556 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) != 0)
7557 operands[2] = force_reg (SImode, operands[2]);
7559 /* Fall through and generate default code. */
7562 (define_insn "sgtu_si"
7563 [(set (match_operand:SI 0 "register_operand" "=d")
7564 (gtu:SI (match_operand:SI 1 "register_operand" "d")
7565 (match_operand:SI 2 "reg_or_0_operand" "dJ")))]
7568 [(set_attr "type" "arith")
7569 (set_attr "mode" "SI")])
7572 [(set (match_operand:SI 0 "register_operand" "=t")
7573 (gtu:SI (match_operand:SI 1 "register_operand" "d")
7574 (match_operand:SI 2 "register_operand" "d")))]
7577 [(set_attr "type" "arith")
7578 (set_attr "mode" "SI")])
7580 (define_insn "sgtu_di"
7581 [(set (match_operand:DI 0 "register_operand" "=d")
7582 (gtu:DI (match_operand:DI 1 "register_operand" "d")
7583 (match_operand:DI 2 "reg_or_0_operand" "dJ")))]
7584 "TARGET_64BIT && !TARGET_MIPS16"
7586 [(set_attr "type" "arith")
7587 (set_attr "mode" "DI")])
7590 [(set (match_operand:DI 0 "register_operand" "=t")
7591 (gtu:DI (match_operand:DI 1 "register_operand" "d")
7592 (match_operand:DI 2 "register_operand" "d")))]
7593 "TARGET_64BIT && TARGET_MIPS16"
7595 [(set_attr "type" "arith")
7596 (set_attr "mode" "DI")])
7598 (define_expand "sgeu"
7599 [(set (match_operand:SI 0 "register_operand" "=d")
7600 (geu:SI (match_dup 1)
7604 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
7607 /* Set up operands from compare. */
7608 operands[1] = branch_cmp[0];
7609 operands[2] = branch_cmp[1];
7611 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
7613 gen_int_relational (GEU, operands[0], operands[1], operands[2], (int *)0);
7617 /* Fall through and generate default code. */
7620 (define_insn "sgeu_si"
7621 [(set (match_operand:SI 0 "register_operand" "=d")
7622 (geu:SI (match_operand:SI 1 "register_operand" "d")
7623 (match_operand:SI 2 "arith_operand" "dI")))]
7624 "TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7625 "sltu\t%0,%1,%2\;xori\t%0,%0,0x0001"
7626 [(set_attr "type" "arith")
7627 (set_attr "mode" "SI")
7628 (set_attr "length" "8")])
7631 [(set (match_operand:SI 0 "register_operand" "")
7632 (geu:SI (match_operand:SI 1 "register_operand" "")
7633 (match_operand:SI 2 "arith_operand" "")))]
7634 "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE && !TARGET_MIPS16"
7636 (ltu:SI (match_dup 1)
7639 (xor:SI (match_dup 0)
7643 (define_insn "sgeu_di"
7644 [(set (match_operand:DI 0 "register_operand" "=d")
7645 (geu:DI (match_operand:DI 1 "register_operand" "d")
7646 (match_operand:DI 2 "arith_operand" "dI")))]
7647 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7648 "sltu\t%0,%1,%2\;xori\t%0,%0,0x0001"
7649 [(set_attr "type" "arith")
7650 (set_attr "mode" "DI")
7651 (set_attr "length" "8")])
7654 [(set (match_operand:DI 0 "register_operand" "")
7655 (geu:DI (match_operand:DI 1 "register_operand" "")
7656 (match_operand:DI 2 "arith_operand" "")))]
7657 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
7660 (ltu:DI (match_dup 1)
7663 (xor:DI (match_dup 0)
7667 (define_expand "sltu"
7668 [(set (match_operand:SI 0 "register_operand" "=d")
7669 (ltu:SI (match_dup 1)
7673 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
7676 /* Set up operands from compare. */
7677 operands[1] = branch_cmp[0];
7678 operands[2] = branch_cmp[1];
7680 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
7682 gen_int_relational (LTU, operands[0], operands[1], operands[2], (int *)0);
7686 /* Fall through and generate default code. */
7689 (define_insn "sltu_si"
7690 [(set (match_operand:SI 0 "register_operand" "=d")
7691 (ltu:SI (match_operand:SI 1 "register_operand" "d")
7692 (match_operand:SI 2 "arith_operand" "dI")))]
7695 [(set_attr "type" "arith")
7696 (set_attr "mode" "SI")])
7699 [(set (match_operand:SI 0 "register_operand" "=t,t")
7700 (ltu:SI (match_operand:SI 1 "register_operand" "d,d")
7701 (match_operand:SI 2 "arith_operand" "d,I")))]
7704 [(set_attr "type" "arith")
7705 (set_attr "mode" "SI")
7706 (set_attr_alternative "length"
7708 (if_then_else (match_operand:VOID 2 "m16_uimm8_1" "")
7712 (define_insn "sltu_di"
7713 [(set (match_operand:DI 0 "register_operand" "=d")
7714 (ltu:DI (match_operand:DI 1 "register_operand" "d")
7715 (match_operand:DI 2 "arith_operand" "dI")))]
7716 "TARGET_64BIT && !TARGET_MIPS16"
7718 [(set_attr "type" "arith")
7719 (set_attr "mode" "DI")])
7722 [(set (match_operand:DI 0 "register_operand" "=t,t")
7723 (ltu:DI (match_operand:DI 1 "register_operand" "d,d")
7724 (match_operand:DI 2 "arith_operand" "d,I")))]
7725 "TARGET_64BIT && TARGET_MIPS16"
7727 [(set_attr "type" "arith")
7728 (set_attr "mode" "DI")
7729 (set_attr_alternative "length"
7731 (if_then_else (match_operand:VOID 2 "m16_uimm8_1" "")
7735 (define_expand "sleu"
7736 [(set (match_operand:SI 0 "register_operand" "=d")
7737 (leu:SI (match_dup 1)
7741 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
7744 /* Set up operands from compare. */
7745 operands[1] = branch_cmp[0];
7746 operands[2] = branch_cmp[1];
7748 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
7750 gen_int_relational (LEU, operands[0], operands[1], operands[2], (int *)0);
7754 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 32767)
7755 operands[2] = force_reg (SImode, operands[2]);
7757 /* Fall through and generate default code. */
7760 (define_insn "sleu_si_const"
7761 [(set (match_operand:SI 0 "register_operand" "=d")
7762 (leu:SI (match_operand:SI 1 "register_operand" "d")
7763 (match_operand:SI 2 "small_int" "I")))]
7764 "!TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
7766 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
7767 return "sltu\t%0,%1,%2";
7769 [(set_attr "type" "arith")
7770 (set_attr "mode" "SI")])
7773 [(set (match_operand:SI 0 "register_operand" "=t")
7774 (leu:SI (match_operand:SI 1 "register_operand" "d")
7775 (match_operand:SI 2 "small_int" "I")))]
7776 "TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
7778 operands[2] = GEN_INT (INTVAL (operands[2])+1);
7779 return "sltu\t%1,%2";
7781 [(set_attr "type" "arith")
7782 (set_attr "mode" "SI")
7783 (set (attr "length") (if_then_else (match_operand:VOID 2 "m16_uimm8_m1_1" "")
7787 (define_insn "sleu_di_const"
7788 [(set (match_operand:DI 0 "register_operand" "=d")
7789 (leu:DI (match_operand:DI 1 "register_operand" "d")
7790 (match_operand:DI 2 "small_int" "I")))]
7791 "TARGET_64BIT && !TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
7793 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
7794 return "sltu\t%0,%1,%2";
7796 [(set_attr "type" "arith")
7797 (set_attr "mode" "DI")])
7800 [(set (match_operand:DI 0 "register_operand" "=t")
7801 (leu:DI (match_operand:DI 1 "register_operand" "d")
7802 (match_operand:DI 2 "small_int" "I")))]
7803 "TARGET_64BIT && TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
7805 operands[2] = GEN_INT (INTVAL (operands[2])+1);
7806 return "sltu\t%1,%2";
7808 [(set_attr "type" "arith")
7809 (set_attr "mode" "DI")
7810 (set (attr "length") (if_then_else (match_operand:VOID 2 "m16_uimm8_m1_1" "")
7814 (define_insn "sleu_si_reg"
7815 [(set (match_operand:SI 0 "register_operand" "=d")
7816 (leu:SI (match_operand:SI 1 "register_operand" "d")
7817 (match_operand:SI 2 "register_operand" "d")))]
7818 "TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7819 "sltu\t%0,%z2,%1\;xori\t%0,%0,0x0001"
7820 [(set_attr "type" "arith")
7821 (set_attr "mode" "SI")
7822 (set_attr "length" "8")])
7825 [(set (match_operand:SI 0 "register_operand" "")
7826 (leu:SI (match_operand:SI 1 "register_operand" "")
7827 (match_operand:SI 2 "register_operand" "")))]
7828 "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE && !TARGET_MIPS16"
7830 (ltu:SI (match_dup 2)
7833 (xor:SI (match_dup 0)
7837 (define_insn "sleu_di_reg"
7838 [(set (match_operand:DI 0 "register_operand" "=d")
7839 (leu:DI (match_operand:DI 1 "register_operand" "d")
7840 (match_operand:DI 2 "register_operand" "d")))]
7841 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7842 "sltu\t%0,%z2,%1\;xori\t%0,%0,0x0001"
7843 [(set_attr "type" "arith")
7844 (set_attr "mode" "DI")
7845 (set_attr "length" "8")])
7848 [(set (match_operand:DI 0 "register_operand" "")
7849 (leu:DI (match_operand:DI 1 "register_operand" "")
7850 (match_operand:DI 2 "register_operand" "")))]
7851 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
7854 (ltu:DI (match_dup 2)
7857 (xor:DI (match_dup 0)
7862 ;; ....................
7864 ;; FLOATING POINT COMPARISONS
7866 ;; ....................
7868 (define_insn "sunordered_df"
7869 [(set (match_operand:CC 0 "register_operand" "=z")
7870 (unordered:CC (match_operand:DF 1 "register_operand" "f")
7871 (match_operand:DF 2 "register_operand" "f")))]
7872 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
7874 [(set_attr "type" "fcmp")
7875 (set_attr "mode" "FPSW")])
7877 (define_insn "sunlt_df"
7878 [(set (match_operand:CC 0 "register_operand" "=z")
7879 (unlt:CC (match_operand:DF 1 "register_operand" "f")
7880 (match_operand:DF 2 "register_operand" "f")))]
7881 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
7883 [(set_attr "type" "fcmp")
7884 (set_attr "mode" "FPSW")])
7886 (define_insn "suneq_df"
7887 [(set (match_operand:CC 0 "register_operand" "=z")
7888 (uneq:CC (match_operand:DF 1 "register_operand" "f")
7889 (match_operand:DF 2 "register_operand" "f")))]
7890 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
7892 [(set_attr "type" "fcmp")
7893 (set_attr "mode" "FPSW")])
7895 (define_insn "sunle_df"
7896 [(set (match_operand:CC 0 "register_operand" "=z")
7897 (unle:CC (match_operand:DF 1 "register_operand" "f")
7898 (match_operand:DF 2 "register_operand" "f")))]
7899 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
7901 [(set_attr "type" "fcmp")
7902 (set_attr "mode" "FPSW")])
7904 (define_insn "seq_df"
7905 [(set (match_operand:CC 0 "register_operand" "=z")
7906 (eq:CC (match_operand:DF 1 "register_operand" "f")
7907 (match_operand:DF 2 "register_operand" "f")))]
7908 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
7910 [(set_attr "type" "fcmp")
7911 (set_attr "mode" "FPSW")])
7913 (define_insn "slt_df"
7914 [(set (match_operand:CC 0 "register_operand" "=z")
7915 (lt:CC (match_operand:DF 1 "register_operand" "f")
7916 (match_operand:DF 2 "register_operand" "f")))]
7917 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
7919 [(set_attr "type" "fcmp")
7920 (set_attr "mode" "FPSW")])
7922 (define_insn "sle_df"
7923 [(set (match_operand:CC 0 "register_operand" "=z")
7924 (le:CC (match_operand:DF 1 "register_operand" "f")
7925 (match_operand:DF 2 "register_operand" "f")))]
7926 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
7928 [(set_attr "type" "fcmp")
7929 (set_attr "mode" "FPSW")])
7931 (define_insn "sgt_df"
7932 [(set (match_operand:CC 0 "register_operand" "=z")
7933 (gt:CC (match_operand:DF 1 "register_operand" "f")
7934 (match_operand:DF 2 "register_operand" "f")))]
7935 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
7937 [(set_attr "type" "fcmp")
7938 (set_attr "mode" "FPSW")])
7940 (define_insn "sge_df"
7941 [(set (match_operand:CC 0 "register_operand" "=z")
7942 (ge:CC (match_operand:DF 1 "register_operand" "f")
7943 (match_operand:DF 2 "register_operand" "f")))]
7944 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
7946 [(set_attr "type" "fcmp")
7947 (set_attr "mode" "FPSW")])
7949 (define_insn "sunordered_sf"
7950 [(set (match_operand:CC 0 "register_operand" "=z")
7951 (unordered:CC (match_operand:SF 1 "register_operand" "f")
7952 (match_operand:SF 2 "register_operand" "f")))]
7955 [(set_attr "type" "fcmp")
7956 (set_attr "mode" "FPSW")])
7958 (define_insn "sunlt_sf"
7959 [(set (match_operand:CC 0 "register_operand" "=z")
7960 (unlt:CC (match_operand:SF 1 "register_operand" "f")
7961 (match_operand:SF 2 "register_operand" "f")))]
7964 [(set_attr "type" "fcmp")
7965 (set_attr "mode" "FPSW")])
7967 (define_insn "suneq_sf"
7968 [(set (match_operand:CC 0 "register_operand" "=z")
7969 (uneq:CC (match_operand:SF 1 "register_operand" "f")
7970 (match_operand:SF 2 "register_operand" "f")))]
7973 [(set_attr "type" "fcmp")
7974 (set_attr "mode" "FPSW")])
7976 (define_insn "sunle_sf"
7977 [(set (match_operand:CC 0 "register_operand" "=z")
7978 (unle:CC (match_operand:SF 1 "register_operand" "f")
7979 (match_operand:SF 2 "register_operand" "f")))]
7982 [(set_attr "type" "fcmp")
7983 (set_attr "mode" "FPSW")])
7985 (define_insn "seq_sf"
7986 [(set (match_operand:CC 0 "register_operand" "=z")
7987 (eq:CC (match_operand:SF 1 "register_operand" "f")
7988 (match_operand:SF 2 "register_operand" "f")))]
7991 [(set_attr "type" "fcmp")
7992 (set_attr "mode" "FPSW")])
7994 (define_insn "slt_sf"
7995 [(set (match_operand:CC 0 "register_operand" "=z")
7996 (lt:CC (match_operand:SF 1 "register_operand" "f")
7997 (match_operand:SF 2 "register_operand" "f")))]
8000 [(set_attr "type" "fcmp")
8001 (set_attr "mode" "FPSW")])
8003 (define_insn "sle_sf"
8004 [(set (match_operand:CC 0 "register_operand" "=z")
8005 (le:CC (match_operand:SF 1 "register_operand" "f")
8006 (match_operand:SF 2 "register_operand" "f")))]
8009 [(set_attr "type" "fcmp")
8010 (set_attr "mode" "FPSW")])
8012 (define_insn "sgt_sf"
8013 [(set (match_operand:CC 0 "register_operand" "=z")
8014 (gt:CC (match_operand:SF 1 "register_operand" "f")
8015 (match_operand:SF 2 "register_operand" "f")))]
8018 [(set_attr "type" "fcmp")
8019 (set_attr "mode" "FPSW")])
8021 (define_insn "sge_sf"
8022 [(set (match_operand:CC 0 "register_operand" "=z")
8023 (ge:CC (match_operand:SF 1 "register_operand" "f")
8024 (match_operand:SF 2 "register_operand" "f")))]
8027 [(set_attr "type" "fcmp")
8028 (set_attr "mode" "FPSW")])
8031 ;; ....................
8033 ;; UNCONDITIONAL BRANCHES
8035 ;; ....................
8037 ;; Unconditional branches.
8041 (label_ref (match_operand 0 "" "")))]
8044 if (flag_pic && ! TARGET_EMBEDDED_PIC)
8046 if (get_attr_length (insn) <= 8)
8047 return "%*b\t%l0%/";
8050 output_asm_insn (mips_output_load_label (), operands);
8051 return "%*jr\t%@%/%]";
8055 return "%*j\t%l0%/";
8057 [(set_attr "type" "jump")
8058 (set_attr "mode" "none")
8059 (set (attr "length")
8060 ;; we can't use `j' when emitting non-embedded PIC, so we emit
8061 ;; branch, if it's in range, or load the address of the branch
8062 ;; target into $at in a PIC-compatible way and then jump to it.
8064 (ior (eq (symbol_ref "flag_pic && ! TARGET_EMBEDDED_PIC")
8066 (lt (abs (minus (match_dup 0)
8067 (plus (pc) (const_int 4))))
8068 (const_int 131072)))
8069 (const_int 4) (const_int 16)))])
8071 ;; We need a different insn for the mips16, because a mips16 branch
8072 ;; does not have a delay slot.
8076 (label_ref (match_operand 0 "" "")))]
8079 [(set_attr "type" "branch")
8080 (set_attr "mode" "none")
8081 (set_attr "length" "8")])
8083 (define_expand "indirect_jump"
8084 [(set (pc) (match_operand 0 "register_operand" "d"))]
8090 if (GET_CODE (dest) != REG || GET_MODE (dest) != Pmode)
8091 operands[0] = copy_to_mode_reg (Pmode, dest);
8093 if (!(Pmode == DImode))
8094 emit_jump_insn (gen_indirect_jump_internal1 (operands[0]));
8096 emit_jump_insn (gen_indirect_jump_internal2 (operands[0]));
8101 (define_insn "indirect_jump_internal1"
8102 [(set (pc) (match_operand:SI 0 "register_operand" "d"))]
8103 "!(Pmode == DImode)"
8105 [(set_attr "type" "jump")
8106 (set_attr "mode" "none")])
8108 (define_insn "indirect_jump_internal2"
8109 [(set (pc) (match_operand:DI 0 "register_operand" "d"))]
8112 [(set_attr "type" "jump")
8113 (set_attr "mode" "none")])
8115 (define_expand "tablejump"
8117 (match_operand 0 "register_operand" "d"))
8118 (use (label_ref (match_operand 1 "" "")))]
8123 if (GET_MODE (operands[0]) != HImode)
8125 if (!(Pmode == DImode))
8126 emit_insn (gen_tablejump_mips161 (operands[0], operands[1]));
8128 emit_insn (gen_tablejump_mips162 (operands[0], operands[1]));
8132 if (GET_MODE (operands[0]) != ptr_mode)
8136 operands[0] = expand_binop (ptr_mode, add_optab, operands[0],
8137 pic_offset_table_rtx, 0, 0, OPTAB_WIDEN);
8139 if (Pmode == SImode)
8140 emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
8142 emit_jump_insn (gen_tablejump_internal2 (operands[0], operands[1]));
8146 (define_insn "tablejump_internal1"
8148 (match_operand:SI 0 "register_operand" "d"))
8149 (use (label_ref (match_operand 1 "" "")))]
8152 [(set_attr "type" "jump")
8153 (set_attr "mode" "none")])
8155 (define_insn "tablejump_internal2"
8157 (match_operand:DI 0 "register_operand" "d"))
8158 (use (label_ref (match_operand 1 "" "")))]
8161 [(set_attr "type" "jump")
8162 (set_attr "mode" "none")])
8164 (define_expand "tablejump_mips161"
8165 [(set (pc) (plus:SI (sign_extend:SI
8166 (match_operand:HI 0 "register_operand" "d"))
8167 (label_ref:SI (match_operand 1 "" ""))))]
8168 "TARGET_MIPS16 && !(Pmode == DImode)"
8172 t1 = gen_reg_rtx (SImode);
8173 t2 = gen_reg_rtx (SImode);
8174 t3 = gen_reg_rtx (SImode);
8175 emit_insn (gen_extendhisi2 (t1, operands[0]));
8176 emit_move_insn (t2, gen_rtx_LABEL_REF (SImode, operands[1]));
8177 emit_insn (gen_addsi3 (t3, t1, t2));
8178 emit_jump_insn (gen_tablejump_internal1 (t3, operands[1]));
8182 (define_expand "tablejump_mips162"
8183 [(set (pc) (plus:DI (sign_extend:DI
8184 (match_operand:HI 0 "register_operand" "d"))
8185 (label_ref:DI (match_operand 1 "" ""))))]
8186 "TARGET_MIPS16 && Pmode == DImode"
8190 t1 = gen_reg_rtx (DImode);
8191 t2 = gen_reg_rtx (DImode);
8192 t3 = gen_reg_rtx (DImode);
8193 emit_insn (gen_extendhidi2 (t1, operands[0]));
8194 emit_move_insn (t2, gen_rtx_LABEL_REF (DImode, operands[1]));
8195 emit_insn (gen_adddi3 (t3, t1, t2));
8196 emit_jump_insn (gen_tablejump_internal2 (t3, operands[1]));
8200 ;; Implement a switch statement when generating embedded PIC code.
8201 ;; Switches are implemented by `tablejump' when not using -membedded-pic.
8203 (define_expand "casesi"
8205 (minus:SI (match_operand:SI 0 "register_operand" "")
8206 (match_operand:SI 1 "const_int_operand" "")))
8208 (compare:CC (match_dup 5)
8209 (match_operand:SI 2 "arith_operand" "")))
8211 (if_then_else (gtu (cc0)
8213 (label_ref (match_operand 4 "" ""))
8217 (mem:SI (plus:SI (mult:SI (match_dup 5)
8219 (label_ref (match_operand 3 "" "")))))
8220 (clobber (match_scratch:SI 6 ""))
8221 (clobber (reg:SI 31))])]
8222 "TARGET_EMBEDDED_PIC"
8226 /* If the index is too large, go to the default label. */
8227 index = expand_binop (SImode, sub_optab, operands[0],
8228 operands[1], 0, 0, OPTAB_WIDEN);
8229 emit_insn (gen_cmpsi (index, operands[2]));
8230 emit_insn (gen_bgtu (operands[4]));
8232 /* Do the PIC jump. */
8233 if (Pmode != DImode)
8234 emit_jump_insn (gen_casesi_internal (index, operands[3],
8235 gen_reg_rtx (SImode)));
8237 emit_jump_insn (gen_casesi_internal_di (index, operands[3],
8238 gen_reg_rtx (DImode)));
8243 ;; An embedded PIC switch statement looks like this:
8245 ;; sll $reg,$index,2
8247 ;; addu $reg,$reg,$31
8248 ;; lw $reg,$L1-$LS1($reg)
8249 ;; addu $reg,$reg,$31
8256 (define_insn "casesi_internal"
8258 (mem:SI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "d")
8260 (label_ref (match_operand 1 "" "")))))
8261 (clobber (match_operand:SI 2 "register_operand" "=d"))
8262 (clobber (reg:SI 31))]
8263 "TARGET_EMBEDDED_PIC"
8266 return "%(bal\\t%S1\;sll\\t%2,%0,2\\n%~%S1:\;addu\\t%2,%2,$31%)\;\\
8267 .set macro\;lw\\t%2,%1-%S1(%2)\;.set nomacro\;addu\\t%2,%2,$31\\n\\t%*j\\t%2%/";
8269 "%(bal\\t%S1\;sll\\t%2,%0,2\\n%~%S1:\;addu\\t%2,%2,$31%)\;\\
8270 lw\\t%2,%1-%S1(%2)\;addu\\t%2,%2,$31\\n\\t%*j\\t%2%/"
8273 [(set_attr "type" "jump")
8274 (set_attr "mode" "none")
8275 (set_attr "length" "24")])
8277 ;; This code assumes that the table index will never be >= 29 bits wide,
8278 ;; which allows the 'sign extend' from SI to DI be a no-op.
8279 (define_insn "casesi_internal_di"
8281 (mem:DI (plus:DI (sign_extend:DI
8282 (mult:SI (match_operand:SI 0 "register_operand" "d")
8284 (label_ref (match_operand 1 "" "")))))
8285 (clobber (match_operand:DI 2 "register_operand" "=d"))
8286 (clobber (reg:DI 31))]
8287 "TARGET_EMBEDDED_PIC"
8290 return "%(bal\\t%S1\;sll\\t%2,%0,3\\n%~%S1:\;daddu\\t%2,%2,$31%)\;\\
8291 .set macro\;ld\\t%2,%1-%S1(%2)\;.set nomacro\;daddu\\t%2,%2,$31\\n\\t%*j\\t%2%/";
8293 "%(bal\\t%S1\;sll\\t%2,%0,3\\n%~%S1:\;daddu\\t%2,%2,$31%)\;\\
8294 ld\\t%2,%1-%S1(%2)\;daddu\\t%2,%2,$31\\n\\t%*j\\t%2%/"
8297 [(set_attr "type" "jump")
8298 (set_attr "mode" "none")
8299 (set_attr "length" "24")])
8301 ;; For TARGET_ABICALLS, we save the gp in the jmp_buf as well.
8302 ;; While it is possible to either pull it off the stack (in the
8303 ;; o32 case) or recalculate it given t9 and our target label,
8304 ;; it takes 3 or 4 insns to do so.
8306 (define_expand "builtin_setjmp_setup"
8307 [(use (match_operand 0 "register_operand" ""))]
8312 addr = plus_constant (operands[0], GET_MODE_SIZE (Pmode) * 3);
8313 emit_move_insn (gen_rtx_MEM (Pmode, addr), pic_offset_table_rtx);
8317 ;; Restore the gp that we saved above. Despite the earlier comment, it seems
8318 ;; that older code did recalculate the gp from $25. Continue to jump through
8319 ;; $25 for compatibility (we lose nothing by doing so).
8321 (define_expand "builtin_longjmp"
8322 [(use (match_operand 0 "register_operand" "r"))]
8325 /* The elements of the buffer are, in order: */
8326 int W = GET_MODE_SIZE (Pmode);
8327 rtx fp = gen_rtx_MEM (Pmode, operands[0]);
8328 rtx lab = gen_rtx_MEM (Pmode, plus_constant (operands[0], 1*W));
8329 rtx stack = gen_rtx_MEM (Pmode, plus_constant (operands[0], 2*W));
8330 rtx gpv = gen_rtx_MEM (Pmode, plus_constant (operands[0], 3*W));
8331 rtx pv = gen_rtx_REG (Pmode, PIC_FUNCTION_ADDR_REGNUM);
8332 /* Use gen_raw_REG to avoid being given pic_offset_table_rtx.
8333 The target is bound to be using $28 as the global pointer
8334 but the current function might not be. */
8335 rtx gp = gen_raw_REG (Pmode, GLOBAL_POINTER_REGNUM);
8337 /* This bit is similar to expand_builtin_longjmp except that it
8338 restores $gp as well. */
8339 emit_move_insn (hard_frame_pointer_rtx, fp);
8340 emit_move_insn (pv, lab);
8341 emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
8342 emit_move_insn (gp, gpv);
8343 emit_insn (gen_rtx_USE (VOIDmode, hard_frame_pointer_rtx));
8344 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
8345 emit_insn (gen_rtx_USE (VOIDmode, gp));
8346 emit_indirect_jump (pv);
8351 ;; ....................
8353 ;; Function prologue/epilogue
8355 ;; ....................
8358 (define_expand "prologue"
8362 mips_expand_prologue ();
8366 ;; Block any insns from being moved before this point, since the
8367 ;; profiling call to mcount can use various registers that aren't
8368 ;; saved or used to pass arguments.
8370 (define_insn "blockage"
8371 [(unspec_volatile [(const_int 0)] UNSPEC_BLOCKAGE)]
8374 [(set_attr "type" "unknown")
8375 (set_attr "mode" "none")
8376 (set_attr "length" "0")])
8378 (define_expand "epilogue"
8382 mips_expand_epilogue (false);
8386 (define_expand "sibcall_epilogue"
8390 mips_expand_epilogue (true);
8394 ;; Trivial return. Make it look like a normal return insn as that
8395 ;; allows jump optimizations to work better.
8397 (define_insn "return"
8399 "mips_can_use_return_insn ()"
8401 [(set_attr "type" "jump")
8402 (set_attr "mode" "none")])
8406 (define_insn "return_internal"
8408 (use (match_operand 0 "pmode_register_operand" ""))]
8411 [(set_attr "type" "jump")
8412 (set_attr "mode" "none")])
8414 ;; When generating embedded PIC code we need to get the address of the
8415 ;; current function. This specialized instruction does just that.
8417 (define_insn "get_fnaddr"
8418 [(set (match_operand 0 "register_operand" "=d")
8419 (unspec [(match_operand 1 "" "")] UNSPEC_GET_FNADDR))
8420 (clobber (reg:SI 31))]
8421 "TARGET_EMBEDDED_PIC
8422 && GET_CODE (operands[1]) == SYMBOL_REF"
8423 "%($LF%= = . + 8\;bal\t$LF%=\;nop;la\t%0,%1-$LF%=%)\;addu\t%0,%0,$31"
8424 [(set_attr "type" "call")
8425 (set_attr "mode" "none")
8426 (set_attr "length" "20")])
8428 ;; This is used in compiling the unwind routines.
8429 (define_expand "eh_return"
8430 [(use (match_operand 0 "general_operand" ""))]
8433 enum machine_mode gpr_mode = TARGET_64BIT ? DImode : SImode;
8435 if (GET_MODE (operands[0]) != gpr_mode)
8436 operands[0] = convert_to_mode (gpr_mode, operands[0], 0);
8438 emit_insn (gen_eh_set_lr_di (operands[0]));
8440 emit_insn (gen_eh_set_lr_si (operands[0]));
8445 ;; Clobber the return address on the stack. We can't expand this
8446 ;; until we know where it will be put in the stack frame.
8448 (define_insn "eh_set_lr_si"
8449 [(unspec [(match_operand:SI 0 "register_operand" "d")] UNSPEC_EH_RETURN)
8450 (clobber (match_scratch:SI 1 "=&d"))]
8454 (define_insn "eh_set_lr_di"
8455 [(unspec [(match_operand:DI 0 "register_operand" "d")] UNSPEC_EH_RETURN)
8456 (clobber (match_scratch:DI 1 "=&d"))]
8461 [(unspec [(match_operand 0 "register_operand" "")] UNSPEC_EH_RETURN)
8462 (clobber (match_scratch 1 ""))]
8463 "reload_completed && !TARGET_DEBUG_D_MODE"
8466 mips_set_return_address (operands[0], operands[1]);
8470 (define_insn "exception_receiver"
8472 (unspec_volatile:SI [(const_int 0)] UNSPEC_EH_RECEIVER))]
8473 "TARGET_ABICALLS && TARGET_OLDABI"
8475 operands[0] = pic_offset_table_rtx;
8476 operands[1] = mips_gp_save_slot ();
8477 return mips_output_move (operands[0], operands[1]);
8479 [(set_attr "type" "load")
8480 (set_attr "length" "8")])
8483 ;; ....................
8487 ;; ....................
8489 ;; Instructions to load a call address from the GOT. The address might
8490 ;; point to a function or to a lazy binding stub. In the latter case,
8491 ;; the stub will use the dynamic linker to resolve the function, which
8492 ;; in turn will change the GOT entry to point to the function's real
8495 ;; This means that every call, even pure and constant ones, can
8496 ;; potentially modify the GOT entry. And once a stub has been called,
8497 ;; we must not call it again.
8499 ;; We represent this restriction using an imaginary fixed register that
8500 ;; acts like a GOT version number. By making the register call-clobbered,
8501 ;; we tell the target-independent code that the address could be changed
8502 ;; by any call insn.
8503 (define_insn "load_callsi"
8504 [(set (match_operand:SI 0 "register_operand" "=c")
8505 (unspec:SI [(match_operand:SI 1 "register_operand" "r")
8506 (match_operand:SI 2 "immediate_operand" "")
8507 (reg:SI FAKE_CALL_REGNO)]
8511 [(set_attr "type" "load")
8512 (set_attr "length" "4")])
8514 (define_insn "load_calldi"
8515 [(set (match_operand:DI 0 "register_operand" "=c")
8516 (unspec:DI [(match_operand:DI 1 "register_operand" "r")
8517 (match_operand:DI 2 "immediate_operand" "")
8518 (reg:DI FAKE_CALL_REGNO)]
8522 [(set_attr "type" "load")
8523 (set_attr "length" "4")])
8525 ;; Sibling calls. All these patterns use jump instructions.
8527 ;; If TARGET_SIBCALLS, call_insn_operand will only accept constant
8528 ;; addresses if a direct jump is acceptable. Since the 'S' constraint
8529 ;; is defined in terms of call_insn_operand, the same is true of the
8532 ;; When we use an indirect jump, we need a register that will be
8533 ;; preserved by the epilogue. Since TARGET_ABICALLS forces us to
8534 ;; use $25 for this purpose -- and $25 is never clobbered by the
8535 ;; epilogue -- we might as well use it for !TARGET_ABICALLS as well.
8537 (define_expand "sibcall"
8538 [(parallel [(call (match_operand 0 "" "")
8539 (match_operand 1 "" ""))
8540 (use (match_operand 2 "" "")) ;; next_arg_reg
8541 (use (match_operand 3 "" ""))])] ;; struct_value_size_rtx
8544 mips_expand_call (0, XEXP (operands[0], 0), operands[1], operands[2], true);
8548 (define_insn "sibcall_internal"
8549 [(call (mem:SI (match_operand 0 "call_insn_operand" "j,S"))
8550 (match_operand 1 "" ""))]
8551 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
8555 [(set_attr "type" "call")])
8557 (define_expand "sibcall_value"
8558 [(parallel [(set (match_operand 0 "" "")
8559 (call (match_operand 1 "" "")
8560 (match_operand 2 "" "")))
8561 (use (match_operand 3 "" ""))])] ;; next_arg_reg
8564 mips_expand_call (operands[0], XEXP (operands[1], 0),
8565 operands[2], operands[3], true);
8569 (define_insn "sibcall_value_internal"
8570 [(set (match_operand 0 "register_operand" "=df,df")
8571 (call (mem:SI (match_operand 1 "call_insn_operand" "j,S"))
8572 (match_operand 2 "" "")))]
8573 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
8577 [(set_attr "type" "call")])
8579 (define_insn "sibcall_value_multiple_internal"
8580 [(set (match_operand 0 "register_operand" "=df,df")
8581 (call (mem:SI (match_operand 1 "call_insn_operand" "j,S"))
8582 (match_operand 2 "" "")))
8583 (set (match_operand 3 "register_operand" "=df,df")
8584 (call (mem:SI (match_dup 1))
8586 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
8590 [(set_attr "type" "call")])
8592 (define_expand "call"
8593 [(parallel [(call (match_operand 0 "" "")
8594 (match_operand 1 "" ""))
8595 (use (match_operand 2 "" "")) ;; next_arg_reg
8596 (use (match_operand 3 "" ""))])] ;; struct_value_size_rtx
8599 mips_expand_call (0, XEXP (operands[0], 0), operands[1], operands[2], false);
8603 ;; This instruction directly corresponds to an assembly-language "jal".
8604 ;; There are four cases:
8607 ;; Both symbolic and register destinations are OK. The pattern
8608 ;; always expands to a single mips instruction.
8610 ;; - -mabicalls/-mno-explicit-relocs:
8611 ;; Again, both symbolic and register destinations are OK.
8612 ;; The call is treated as a multi-instruction black box.
8614 ;; - -mabicalls/-mexplicit-relocs with n32 or n64:
8615 ;; Only "jal $25" is allowed. This expands to a single "jalr $25"
8618 ;; - -mabicalls/-mexplicit-relocs with o32 or o64:
8619 ;; Only "jal $25" is allowed. The call is actually two instructions:
8620 ;; "jalr $25" followed by an insn to reload $gp.
8622 ;; In the last case, we can generate the individual instructions with
8623 ;; a define_split. There are several things to be wary of:
8625 ;; - We can't expose the load of $gp before reload. If we did,
8626 ;; it might get removed as dead, but reload can introduce new
8627 ;; uses of $gp by rematerializing constants.
8629 ;; - We shouldn't restore $gp after calls that never return.
8630 ;; It isn't valid to insert instructions between a noreturn
8631 ;; call and the following barrier.
8633 ;; - The splitter deliberately changes the liveness of $gp. The unsplit
8634 ;; instruction preserves $gp and so have no effect on its liveness.
8635 ;; But once we generate the separate insns, it becomes obvious that
8636 ;; $gp is not live on entry to the call.
8638 ;; ??? The operands[2] = insn check is a hack to make the original insn
8639 ;; available to the splitter.
8640 (define_insn_and_split "call_internal"
8641 [(call (mem:SI (match_operand 0 "call_insn_operand" "c,S"))
8642 (match_operand 1 "" ""))
8643 (clobber (reg:SI 31))]
8645 { return TARGET_SPLIT_CALLS ? "#" : "%*jal\t%0%/"; }
8646 "reload_completed && TARGET_SPLIT_CALLS && (operands[2] = insn)"
8649 emit_call_insn (gen_call_split (operands[0], operands[1]));
8650 if (!find_reg_note (operands[2], REG_NORETURN, 0))
8651 emit_move_insn (pic_offset_table_rtx, mips_gp_save_slot ());
8654 [(set_attr "jal" "indirect,direct")
8655 (set_attr "extended_mips16" "no,yes")])
8657 (define_insn "call_split"
8658 [(call (mem:SI (match_operand 0 "call_insn_operand" "c"))
8659 (match_operand 1 "" ""))
8660 (clobber (reg:SI 31))
8661 (clobber (reg:SI 28))]
8662 "TARGET_SPLIT_CALLS"
8664 [(set_attr "type" "call")])
8666 (define_expand "call_value"
8667 [(parallel [(set (match_operand 0 "" "")
8668 (call (match_operand 1 "" "")
8669 (match_operand 2 "" "")))
8670 (use (match_operand 3 "" ""))])] ;; next_arg_reg
8673 mips_expand_call (operands[0], XEXP (operands[1], 0),
8674 operands[2], operands[3], false);
8678 ;; See comment for call_internal.
8679 (define_insn_and_split "call_value_internal"
8680 [(set (match_operand 0 "register_operand" "=df,df")
8681 (call (mem:SI (match_operand 1 "call_insn_operand" "c,S"))
8682 (match_operand 2 "" "")))
8683 (clobber (reg:SI 31))]
8685 { return TARGET_SPLIT_CALLS ? "#" : "%*jal\t%1%/"; }
8686 "reload_completed && TARGET_SPLIT_CALLS && (operands[3] = insn)"
8689 emit_call_insn (gen_call_value_split (operands[0], operands[1],
8691 if (!find_reg_note (operands[3], REG_NORETURN, 0))
8692 emit_move_insn (pic_offset_table_rtx, mips_gp_save_slot ());
8695 [(set_attr "jal" "indirect,direct")
8696 (set_attr "extended_mips16" "no,yes")])
8698 (define_insn "call_value_split"
8699 [(set (match_operand 0 "register_operand" "=df")
8700 (call (mem:SI (match_operand 1 "call_insn_operand" "c"))
8701 (match_operand 2 "" "")))
8702 (clobber (reg:SI 31))
8703 (clobber (reg:SI 28))]
8704 "TARGET_SPLIT_CALLS"
8706 [(set_attr "type" "call")])
8708 ;; See comment for call_internal.
8709 (define_insn_and_split "call_value_multiple_internal"
8710 [(set (match_operand 0 "register_operand" "=df,df")
8711 (call (mem:SI (match_operand 1 "call_insn_operand" "c,S"))
8712 (match_operand 2 "" "")))
8713 (set (match_operand 3 "register_operand" "=df,df")
8714 (call (mem:SI (match_dup 1))
8716 (clobber (reg:SI 31))]
8718 { return TARGET_SPLIT_CALLS ? "#" : "%*jal\t%1%/"; }
8719 "reload_completed && TARGET_SPLIT_CALLS && (operands[4] = insn)"
8722 emit_call_insn (gen_call_value_multiple_split (operands[0], operands[1],
8723 operands[2], operands[3]));
8724 if (!find_reg_note (operands[4], REG_NORETURN, 0))
8725 emit_move_insn (pic_offset_table_rtx, mips_gp_save_slot ());
8728 [(set_attr "jal" "indirect,direct")
8729 (set_attr "extended_mips16" "no,yes")])
8731 (define_insn "call_value_multiple_split"
8732 [(set (match_operand 0 "register_operand" "=df")
8733 (call (mem:SI (match_operand 1 "call_insn_operand" "c"))
8734 (match_operand 2 "" "")))
8735 (set (match_operand 3 "register_operand" "=df")
8736 (call (mem:SI (match_dup 1))
8738 (clobber (reg:SI 31))
8739 (clobber (reg:SI 28))]
8740 "TARGET_SPLIT_CALLS"
8742 [(set_attr "type" "call")])
8744 ;; Call subroutine returning any type.
8746 (define_expand "untyped_call"
8747 [(parallel [(call (match_operand 0 "" "")
8749 (match_operand 1 "" "")
8750 (match_operand 2 "" "")])]
8755 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
8757 for (i = 0; i < XVECLEN (operands[2], 0); i++)
8759 rtx set = XVECEXP (operands[2], 0, i);
8760 emit_move_insn (SET_DEST (set), SET_SRC (set));
8763 emit_insn (gen_blockage ());
8768 ;; ....................
8772 ;; ....................
8776 (define_expand "prefetch"
8777 [(prefetch (match_operand 0 "address_operand" "")
8778 (match_operand 1 "const_int_operand" "")
8779 (match_operand 2 "const_int_operand" ""))]
8782 if (symbolic_operand (operands[0], GET_MODE (operands[0])))
8783 operands[0] = force_reg (GET_MODE (operands[0]), operands[0]);
8786 (define_insn "prefetch_si_address"
8787 [(prefetch (plus:SI (match_operand:SI 0 "register_operand" "r")
8788 (match_operand:SI 3 "const_int_operand" "I"))
8789 (match_operand:SI 1 "const_int_operand" "n")
8790 (match_operand:SI 2 "const_int_operand" "n"))]
8791 "ISA_HAS_PREFETCH && Pmode == SImode"
8792 { return mips_emit_prefetch (operands); }
8793 [(set_attr "type" "prefetch")])
8795 (define_insn "prefetch_indexed_si"
8796 [(prefetch (plus:SI (match_operand:SI 0 "register_operand" "r")
8797 (match_operand:SI 3 "register_operand" "r"))
8798 (match_operand:SI 1 "const_int_operand" "n")
8799 (match_operand:SI 2 "const_int_operand" "n"))]
8800 "ISA_HAS_PREFETCHX && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && Pmode == SImode"
8801 { return mips_emit_prefetch (operands); }
8802 [(set_attr "type" "prefetchx")])
8804 (define_insn "prefetch_si"
8805 [(prefetch (match_operand:SI 0 "register_operand" "r")
8806 (match_operand:SI 1 "const_int_operand" "n")
8807 (match_operand:SI 2 "const_int_operand" "n"))]
8808 "ISA_HAS_PREFETCH && Pmode == SImode"
8810 operands[3] = const0_rtx;
8811 return mips_emit_prefetch (operands);
8813 [(set_attr "type" "prefetch")])
8815 (define_insn "prefetch_di_address"
8816 [(prefetch (plus:DI (match_operand:DI 0 "register_operand" "r")
8817 (match_operand:DI 3 "const_int_operand" "I"))
8818 (match_operand:DI 1 "const_int_operand" "n")
8819 (match_operand:DI 2 "const_int_operand" "n"))]
8820 "ISA_HAS_PREFETCH && Pmode == DImode"
8821 { return mips_emit_prefetch (operands); }
8822 [(set_attr "type" "prefetch")])
8824 (define_insn "prefetch_indexed_di"
8825 [(prefetch (plus:DI (match_operand:DI 0 "register_operand" "r")
8826 (match_operand:DI 3 "register_operand" "r"))
8827 (match_operand:DI 1 "const_int_operand" "n")
8828 (match_operand:DI 2 "const_int_operand" "n"))]
8829 "ISA_HAS_PREFETCHX && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && Pmode == DImode"
8830 { return mips_emit_prefetch (operands); }
8831 [(set_attr "type" "prefetchx")])
8833 (define_insn "prefetch_di"
8834 [(prefetch (match_operand:DI 0 "register_operand" "r")
8835 (match_operand:DI 1 "const_int_operand" "n")
8836 (match_operand:DI 2 "const_int_operand" "n"))]
8837 "ISA_HAS_PREFETCH && Pmode == DImode"
8839 operands[3] = const0_rtx;
8840 return mips_emit_prefetch (operands);
8842 [(set_attr "type" "prefetch")])
8848 [(set_attr "type" "nop")
8849 (set_attr "mode" "none")])
8851 ;; Like nop, but commented out when outside a .set noreorder block.
8852 (define_insn "hazard_nop"
8861 [(set_attr "type" "arith")])
8863 ;; MIPS4 Conditional move instructions.
8866 [(set (match_operand:SI 0 "register_operand" "=d,d")
8868 (match_operator 4 "equality_op"
8869 [(match_operand:SI 1 "register_operand" "d,d")
8871 (match_operand:SI 2 "reg_or_0_operand" "dJ,0")
8872 (match_operand:SI 3 "reg_or_0_operand" "0,dJ")))]
8873 "ISA_HAS_CONDMOVE || ISA_HAS_INT_CONDMOVE"
8877 [(set_attr "type" "condmove")
8878 (set_attr "mode" "SI")])
8881 [(set (match_operand:SI 0 "register_operand" "=d,d")
8883 (match_operator 4 "equality_op"
8884 [(match_operand:DI 1 "register_operand" "d,d")
8886 (match_operand:SI 2 "reg_or_0_operand" "dJ,0")
8887 (match_operand:SI 3 "reg_or_0_operand" "0,dJ")))]
8888 "ISA_HAS_CONDMOVE || ISA_HAS_INT_CONDMOVE"
8892 [(set_attr "type" "condmove")
8893 (set_attr "mode" "SI")])
8896 [(set (match_operand:SI 0 "register_operand" "=d,d")
8898 (match_operator 3 "equality_op" [(match_operand:CC 4
8902 (match_operand:SI 1 "reg_or_0_operand" "dJ,0")
8903 (match_operand:SI 2 "reg_or_0_operand" "0,dJ")))]
8904 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT"
8908 [(set_attr "type" "condmove")
8909 (set_attr "mode" "SI")])
8912 [(set (match_operand:DI 0 "register_operand" "=d,d")
8914 (match_operator 4 "equality_op"
8915 [(match_operand:SI 1 "register_operand" "d,d")
8917 (match_operand:DI 2 "reg_or_0_operand" "dJ,0")
8918 (match_operand:DI 3 "reg_or_0_operand" "0,dJ")))]
8919 "(ISA_HAS_CONDMOVE || ISA_HAS_INT_CONDMOVE) && TARGET_64BIT"
8923 [(set_attr "type" "condmove")
8924 (set_attr "mode" "DI")])
8927 [(set (match_operand:DI 0 "register_operand" "=d,d")
8929 (match_operator 4 "equality_op"
8930 [(match_operand:DI 1 "register_operand" "d,d")
8932 (match_operand:DI 2 "reg_or_0_operand" "dJ,0")
8933 (match_operand:DI 3 "reg_or_0_operand" "0,dJ")))]
8934 "(ISA_HAS_CONDMOVE || ISA_HAS_INT_CONDMOVE) && TARGET_64BIT"
8938 [(set_attr "type" "condmove")
8939 (set_attr "mode" "DI")])
8942 [(set (match_operand:DI 0 "register_operand" "=d,d")
8944 (match_operator 3 "equality_op" [(match_operand:CC 4
8948 (match_operand:DI 1 "reg_or_0_operand" "dJ,0")
8949 (match_operand:DI 2 "reg_or_0_operand" "0,dJ")))]
8950 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT && TARGET_64BIT"
8954 [(set_attr "type" "condmove")
8955 (set_attr "mode" "DI")])
8958 [(set (match_operand:SF 0 "register_operand" "=f,f")
8960 (match_operator 4 "equality_op"
8961 [(match_operand:SI 1 "register_operand" "d,d")
8963 (match_operand:SF 2 "register_operand" "f,0")
8964 (match_operand:SF 3 "register_operand" "0,f")))]
8965 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT"
8969 [(set_attr "type" "condmove")
8970 (set_attr "mode" "SF")])
8973 [(set (match_operand:SF 0 "register_operand" "=f,f")
8975 (match_operator 4 "equality_op"
8976 [(match_operand:DI 1 "register_operand" "d,d")
8978 (match_operand:SF 2 "register_operand" "f,0")
8979 (match_operand:SF 3 "register_operand" "0,f")))]
8980 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT"
8984 [(set_attr "type" "condmove")
8985 (set_attr "mode" "SF")])
8988 [(set (match_operand:SF 0 "register_operand" "=f,f")
8990 (match_operator 3 "equality_op" [(match_operand:CC 4
8994 (match_operand:SF 1 "register_operand" "f,0")
8995 (match_operand:SF 2 "register_operand" "0,f")))]
8996 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT"
9000 [(set_attr "type" "condmove")
9001 (set_attr "mode" "SF")])
9004 [(set (match_operand:DF 0 "register_operand" "=f,f")
9006 (match_operator 4 "equality_op"
9007 [(match_operand:SI 1 "register_operand" "d,d")
9009 (match_operand:DF 2 "register_operand" "f,0")
9010 (match_operand:DF 3 "register_operand" "0,f")))]
9011 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
9015 [(set_attr "type" "condmove")
9016 (set_attr "mode" "DF")])
9019 [(set (match_operand:DF 0 "register_operand" "=f,f")
9021 (match_operator 4 "equality_op"
9022 [(match_operand:DI 1 "register_operand" "d,d")
9024 (match_operand:DF 2 "register_operand" "f,0")
9025 (match_operand:DF 3 "register_operand" "0,f")))]
9026 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
9030 [(set_attr "type" "condmove")
9031 (set_attr "mode" "DF")])
9034 [(set (match_operand:DF 0 "register_operand" "=f,f")
9036 (match_operator 3 "equality_op" [(match_operand:CC 4
9040 (match_operand:DF 1 "register_operand" "f,0")
9041 (match_operand:DF 2 "register_operand" "0,f")))]
9042 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
9046 [(set_attr "type" "condmove")
9047 (set_attr "mode" "DF")])
9049 ;; These are the main define_expand's used to make conditional moves.
9051 (define_expand "movsicc"
9052 [(set (match_dup 4) (match_operand 1 "comparison_operator" ""))
9053 (set (match_operand:SI 0 "register_operand" "")
9054 (if_then_else:SI (match_dup 5)
9055 (match_operand:SI 2 "reg_or_0_operand" "")
9056 (match_operand:SI 3 "reg_or_0_operand" "")))]
9057 "ISA_HAS_CONDMOVE || ISA_HAS_INT_CONDMOVE"
9059 gen_conditional_move (operands);
9063 (define_expand "movdicc"
9064 [(set (match_dup 4) (match_operand 1 "comparison_operator" ""))
9065 (set (match_operand:DI 0 "register_operand" "")
9066 (if_then_else:DI (match_dup 5)
9067 (match_operand:DI 2 "reg_or_0_operand" "")
9068 (match_operand:DI 3 "reg_or_0_operand" "")))]
9069 "(ISA_HAS_CONDMOVE || ISA_HAS_INT_CONDMOVE) && TARGET_64BIT"
9071 gen_conditional_move (operands);
9075 (define_expand "movsfcc"
9076 [(set (match_dup 4) (match_operand 1 "comparison_operator" ""))
9077 (set (match_operand:SF 0 "register_operand" "")
9078 (if_then_else:SF (match_dup 5)
9079 (match_operand:SF 2 "register_operand" "")
9080 (match_operand:SF 3 "register_operand" "")))]
9081 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT"
9083 gen_conditional_move (operands);
9087 (define_expand "movdfcc"
9088 [(set (match_dup 4) (match_operand 1 "comparison_operator" ""))
9089 (set (match_operand:DF 0 "register_operand" "")
9090 (if_then_else:DF (match_dup 5)
9091 (match_operand:DF 2 "register_operand" "")
9092 (match_operand:DF 3 "register_operand" "")))]
9093 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
9095 gen_conditional_move (operands);
9100 ;; ....................
9102 ;; mips16 inline constant tables
9104 ;; ....................
9107 (define_insn "consttable_qi"
9108 [(unspec_volatile [(match_operand:QI 0 "consttable_operand" "=g")]
9109 UNSPEC_CONSTTABLE_QI)]
9112 assemble_integer (operands[0], 1, BITS_PER_UNIT, 1);
9115 [(set_attr "type" "unknown")
9116 (set_attr "mode" "QI")
9117 (set_attr "length" "8")])
9119 (define_insn "consttable_hi"
9120 [(unspec_volatile [(match_operand:HI 0 "consttable_operand" "=g")]
9121 UNSPEC_CONSTTABLE_HI)]
9124 assemble_integer (operands[0], 2, BITS_PER_UNIT * 2, 1);
9127 [(set_attr "type" "unknown")
9128 (set_attr "mode" "HI")
9129 (set_attr "length" "8")])
9131 (define_insn "consttable_si"
9132 [(unspec_volatile [(match_operand:SI 0 "consttable_operand" "=g")]
9133 UNSPEC_CONSTTABLE_SI)]
9136 assemble_integer (operands[0], 4, BITS_PER_UNIT * 4, 1);
9139 [(set_attr "type" "unknown")
9140 (set_attr "mode" "SI")
9141 (set_attr "length" "8")])
9143 (define_insn "consttable_di"
9144 [(unspec_volatile [(match_operand:DI 0 "consttable_operand" "=g")]
9145 UNSPEC_CONSTTABLE_DI)]
9148 assemble_integer (operands[0], 8, BITS_PER_UNIT * 8, 1);
9151 [(set_attr "type" "unknown")
9152 (set_attr "mode" "DI")
9153 (set_attr "length" "16")])
9155 (define_insn "consttable_sf"
9156 [(unspec_volatile [(match_operand:SF 0 "consttable_operand" "=g")]
9157 UNSPEC_CONSTTABLE_SF)]
9162 if (GET_CODE (operands[0]) != CONST_DOUBLE)
9164 REAL_VALUE_FROM_CONST_DOUBLE (d, operands[0]);
9165 assemble_real (d, SFmode, GET_MODE_ALIGNMENT (SFmode));
9168 [(set_attr "type" "unknown")
9169 (set_attr "mode" "SF")
9170 (set_attr "length" "8")])
9172 (define_insn "consttable_df"
9173 [(unspec_volatile [(match_operand:DF 0 "consttable_operand" "=g")]
9174 UNSPEC_CONSTTABLE_DF)]
9179 if (GET_CODE (operands[0]) != CONST_DOUBLE)
9181 REAL_VALUE_FROM_CONST_DOUBLE (d, operands[0]);
9182 assemble_real (d, DFmode, GET_MODE_ALIGNMENT (DFmode));
9185 [(set_attr "type" "unknown")
9186 (set_attr "mode" "DF")
9187 (set_attr "length" "16")])
9189 (define_insn "align_2"
9190 [(unspec_volatile [(const_int 0)] UNSPEC_ALIGN_2)]
9193 [(set_attr "type" "unknown")
9194 (set_attr "mode" "HI")
9195 (set_attr "length" "8")])
9197 (define_insn "align_4"
9198 [(unspec_volatile [(const_int 0)] UNSPEC_ALIGN_4)]
9201 [(set_attr "type" "unknown")
9202 (set_attr "mode" "SI")
9203 (set_attr "length" "8")])
9205 (define_insn "align_8"
9206 [(unspec_volatile [(const_int 0)] UNSPEC_ALIGN_8)]
9209 [(set_attr "type" "unknown")
9210 (set_attr "mode" "DI")
9211 (set_attr "length" "12")])
9214 ;; ....................
9218 ;; ....................
9221 ;; On the mips16, reload will sometimes decide that a pseudo register
9222 ;; should go into $24, and then later on have to reload that register.
9223 ;; When that happens, we get a load of a general register followed by
9224 ;; a move from the general register to $24 followed by a branch.
9225 ;; These peepholes catch the common case, and fix it to just use the
9226 ;; general register for the branch.
9229 [(set (match_operand:SI 0 "register_operand" "=t")
9230 (match_operand:SI 1 "register_operand" "d"))
9232 (if_then_else (match_operator:SI 2 "equality_op" [(match_dup 0)
9234 (match_operand 3 "pc_or_label_operand" "")
9235 (match_operand 4 "pc_or_label_operand" "")))]
9237 && GET_CODE (operands[0]) == REG
9238 && REGNO (operands[0]) == 24
9239 && dead_or_set_p (insn, operands[0])
9240 && GET_CODE (operands[1]) == REG
9241 && M16_REG_P (REGNO (operands[1]))"
9243 if (operands[3] != pc_rtx)
9244 return "b%C2z\t%1,%3";
9246 return "b%N2z\t%1,%4";
9248 [(set_attr "type" "branch")
9249 (set_attr "mode" "none")
9250 (set_attr "length" "8")])
9253 [(set (match_operand:DI 0 "register_operand" "=t")
9254 (match_operand:DI 1 "register_operand" "d"))
9256 (if_then_else (match_operator:DI 2 "equality_op" [(match_dup 0)
9258 (match_operand 3 "pc_or_label_operand" "")
9259 (match_operand 4 "pc_or_label_operand" "")))]
9260 "TARGET_MIPS16 && TARGET_64BIT
9261 && GET_CODE (operands[0]) == REG
9262 && REGNO (operands[0]) == 24
9263 && dead_or_set_p (insn, operands[0])
9264 && GET_CODE (operands[1]) == REG
9265 && M16_REG_P (REGNO (operands[1]))"
9267 if (operands[3] != pc_rtx)
9268 return "b%C2z\t%1,%3";
9270 return "b%N2z\t%1,%4";
9272 [(set_attr "type" "branch")
9273 (set_attr "mode" "none")
9274 (set_attr "length" "8")])
9276 ;; We can also have the reverse reload: reload will spill $24 into
9277 ;; another register, and then do a branch on that register when it
9278 ;; could have just stuck with $24.
9281 [(set (match_operand:SI 0 "register_operand" "=d")
9282 (match_operand:SI 1 "register_operand" "t"))
9284 (if_then_else (match_operator:SI 2 "equality_op" [(match_dup 0)
9286 (match_operand 3 "pc_or_label_operand" "")
9287 (match_operand 4 "pc_or_label_operand" "")))]
9289 && GET_CODE (operands[1]) == REG
9290 && REGNO (operands[1]) == 24
9291 && GET_CODE (operands[0]) == REG
9292 && M16_REG_P (REGNO (operands[0]))
9293 && dead_or_set_p (insn, operands[0])"
9295 if (operands[3] != pc_rtx)
9296 return "bt%C2z\t%3";
9298 return "bt%N2z\t%4";
9300 [(set_attr "type" "branch")
9301 (set_attr "mode" "none")
9302 (set_attr "length" "8")])
9305 [(set (match_operand:DI 0 "register_operand" "=d")
9306 (match_operand:DI 1 "register_operand" "t"))
9308 (if_then_else (match_operator:DI 2 "equality_op" [(match_dup 0)
9310 (match_operand 3 "pc_or_label_operand" "")
9311 (match_operand 4 "pc_or_label_operand" "")))]
9312 "TARGET_MIPS16 && TARGET_64BIT
9313 && GET_CODE (operands[1]) == REG
9314 && REGNO (operands[1]) == 24
9315 && GET_CODE (operands[0]) == REG
9316 && M16_REG_P (REGNO (operands[0]))
9317 && dead_or_set_p (insn, operands[0])"
9319 if (operands[3] != pc_rtx)
9320 return "bt%C2z\t%3";
9322 return "bt%N2z\t%4";
9324 [(set_attr "type" "branch")
9325 (set_attr "mode" "none")
9326 (set_attr "length" "8")])
9329 [(match_operand 0 "small_data_pattern" "")]
9332 { operands[0] = mips_rewrite_small_data (operands[0]); })