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_INT 8)
39 (UNSPEC_CONSTTABLE_FLOAT 9)
56 (UNSPEC_ADDRESS_FIRST 100)
58 (FAKE_CALL_REGNO 79)])
60 ;; ....................
64 ;; ....................
66 (define_attr "got" "unset,xgot_high,load"
67 (const_string "unset"))
69 ;; For jal instructions, this attribute is DIRECT when the target address
70 ;; is symbolic and INDIRECT when it is a register.
71 (define_attr "jal" "unset,direct,indirect"
72 (const_string "unset"))
74 ;; This attribute is YES if the instruction is a jal macro (not a
75 ;; real jal instruction).
77 ;; jal is always a macro in SVR4 PIC since it includes an instruction to
78 ;; restore $gp. Direct jals are also macros in NewABI PIC since they
79 ;; load the target address into $25.
80 (define_attr "jal_macro" "no,yes"
81 (cond [(eq_attr "jal" "direct")
82 (symbol_ref "TARGET_ABICALLS != 0")
83 (eq_attr "jal" "indirect")
84 (symbol_ref "(TARGET_ABICALLS && !TARGET_NEWABI) != 0")]
87 ;; Classification of each insn.
88 ;; branch conditional branch
89 ;; jump unconditional jump
90 ;; call unconditional call
91 ;; load load instruction(s)
92 ;; fpload floating point load
93 ;; fpidxload floating point indexed load
94 ;; store store instruction(s)
95 ;; fpstore floating point store
96 ;; fpidxstore floating point indexed store
97 ;; prefetch memory prefetch (register + offset)
98 ;; prefetchx memory indexed prefetch (register + register)
99 ;; condmove conditional moves
100 ;; xfer transfer to/from coprocessor
101 ;; mthilo transfer to hi/lo registers
102 ;; mfhilo transfer from hi/lo registers
103 ;; const load constant
104 ;; arith integer arithmetic and logical instructions
105 ;; shift integer shift instructions
106 ;; slt set less than instructions
107 ;; clz the clz and clo instructions
108 ;; trap trap if instructions
109 ;; imul integer multiply
110 ;; imadd integer multiply-add
111 ;; idiv integer divide
112 ;; fmove floating point register move
113 ;; fadd floating point add/subtract
114 ;; fmul floating point multiply
115 ;; fmadd floating point multiply-add
116 ;; fdiv floating point divide
117 ;; fabs floating point absolute value
118 ;; fneg floating point negation
119 ;; fcmp floating point compare
120 ;; fcvt floating point convert
121 ;; fsqrt floating point square root
122 ;; frsqrt floating point reciprocal square root
123 ;; multi multiword sequence (or user asm statements)
126 "unknown,branch,jump,call,load,fpload,fpidxload,store,fpstore,fpidxstore,prefetch,prefetchx,condmove,xfer,mthilo,mfhilo,const,arith,shift,slt,clz,trap,imul,imadd,idiv,fmove,fadd,fmul,fmadd,fdiv,fabs,fneg,fcmp,fcvt,fsqrt,frsqrt,multi,nop"
127 (cond [(eq_attr "jal" "!unset") (const_string "call")
128 (eq_attr "got" "load") (const_string "load")]
129 (const_string "unknown")))
131 ;; Main data type used by the insn
132 (define_attr "mode" "unknown,none,QI,HI,SI,DI,SF,DF,FPSW"
133 (const_string "unknown"))
135 ;; Is this an extended instruction in mips16 mode?
136 (define_attr "extended_mips16" "no,yes"
139 ;; Length of instruction in bytes.
140 (define_attr "length" ""
141 (cond [;; Direct branch instructions have a range of [-0x40000,0x3fffc].
142 ;; If a branch is outside this range, we have a choice of two
143 ;; sequences. For PIC, an out-of-range branch like:
148 ;; becomes the equivalent of:
157 ;; where the load address can be up to three instructions long
160 ;; The non-PIC case is similar except that we use a direct
161 ;; jump instead of an la/jr pair. Since the target of this
162 ;; jump is an absolute 28-bit bit address (the other bits
163 ;; coming from the address of the delay slot) this form cannot
164 ;; cross a 256MB boundary. We could provide the option of
165 ;; using la/jr in this case too, but we do not do so at
168 ;; Note that this value does not account for the delay slot
169 ;; instruction, whose length is added separately. If the RTL
170 ;; pattern has no explicit delay slot, mips_adjust_insn_length
171 ;; will add the length of the implicit nop. The values for
172 ;; forward and backward branches will be different as well.
173 (eq_attr "type" "branch")
174 (cond [(and (le (minus (match_dup 1) (pc)) (const_int 131064))
175 (le (minus (pc) (match_dup 1)) (const_int 131068)))
177 (ne (symbol_ref "flag_pic") (const_int 0))
181 (eq_attr "got" "load")
183 (eq_attr "got" "xgot_high")
186 (eq_attr "type" "const")
187 (symbol_ref "mips_const_insns (operands[1]) * 4")
188 (eq_attr "type" "load,fpload,fpidxload")
189 (symbol_ref "mips_fetch_insns (operands[1]) * 4")
190 (eq_attr "type" "store,fpstore,fpidxstore")
191 (symbol_ref "mips_fetch_insns (operands[0]) * 4")
193 ;; In the worst case, a call macro will take 8 instructions:
195 ;; lui $25,%call_hi(FOO)
197 ;; lw $25,%call_lo(FOO)($25)
203 (eq_attr "jal_macro" "yes")
206 (and (eq_attr "extended_mips16" "yes")
207 (ne (symbol_ref "TARGET_MIPS16") (const_int 0)))
210 ;; Various VR4120 errata require a nop to be inserted after a macc
211 ;; instruction. The assembler does this for us, so account for
212 ;; the worst-case length here.
213 (and (eq_attr "type" "imadd")
214 (ne (symbol_ref "TARGET_FIX_VR4120") (const_int 0)))
217 ;; VR4120 errata MD(4): if there are consecutive dmult instructions,
218 ;; the result of the second one is missed. The assembler should work
219 ;; around this by inserting a nop after the first dmult.
220 (and (eq_attr "type" "imul")
221 (and (eq_attr "mode" "DI")
222 (ne (symbol_ref "TARGET_FIX_VR4120") (const_int 0))))
225 (eq_attr "type" "idiv")
226 (symbol_ref "mips_idiv_insns () * 4")
229 ;; Attribute describing the processor. This attribute must match exactly
230 ;; with the processor_type enumeration in mips.h.
232 "default,4kc,5kc,20kc,m4k,r3000,r3900,r6000,r4000,r4100,r4111,r4120,r4130,r4300,r4600,r4650,r5000,r5400,r5500,r7000,r8000,r9000,sb1,sr71000"
233 (const (symbol_ref "mips_tune")))
235 ;; The type of hardware hazard associated with this instruction.
236 ;; DELAY means that the next instruction cannot read the result
237 ;; of this one. HILO means that the next two instructions cannot
238 ;; write to HI or LO.
239 (define_attr "hazard" "none,delay,hilo"
240 (cond [(and (eq_attr "type" "load,fpload,fpidxload")
241 (ne (symbol_ref "ISA_HAS_LOAD_DELAY") (const_int 0)))
242 (const_string "delay")
244 (and (eq_attr "type" "xfer")
245 (ne (symbol_ref "ISA_HAS_XFER_DELAY") (const_int 0)))
246 (const_string "delay")
248 (and (eq_attr "type" "fcmp")
249 (ne (symbol_ref "ISA_HAS_FCMP_DELAY") (const_int 0)))
250 (const_string "delay")
252 ;; The r4000 multiplication patterns include an mflo instruction.
253 (and (eq_attr "type" "imul")
254 (ne (symbol_ref "TARGET_FIX_R4000") (const_int 0)))
255 (const_string "hilo")
257 (and (eq_attr "type" "mfhilo")
258 (eq (symbol_ref "ISA_HAS_HILO_INTERLOCKS") (const_int 0)))
259 (const_string "hilo")]
260 (const_string "none")))
262 ;; Is it a single instruction?
263 (define_attr "single_insn" "no,yes"
264 (symbol_ref "get_attr_length (insn) == (TARGET_MIPS16 ? 2 : 4)"))
266 ;; Can the instruction be put into a delay slot?
267 (define_attr "can_delay" "no,yes"
268 (if_then_else (and (eq_attr "type" "!branch,call,jump")
269 (and (eq_attr "hazard" "none")
270 (eq_attr "single_insn" "yes")))
272 (const_string "no")))
274 ;; Attribute defining whether or not we can use the branch-likely instructions
275 (define_attr "branch_likely" "no,yes"
277 (if_then_else (ne (symbol_ref "GENERATE_BRANCHLIKELY") (const_int 0))
279 (const_string "no"))))
281 ;; True if an instruction might assign to hi or lo when reloaded.
282 ;; This is used by the TUNE_MACC_CHAINS code.
283 (define_attr "may_clobber_hilo" "no,yes"
284 (if_then_else (eq_attr "type" "imul,imadd,idiv,mthilo")
286 (const_string "no")))
288 ;; Describe a user's asm statement.
289 (define_asm_attributes
290 [(set_attr "type" "multi")])
292 ;; .........................
294 ;; Branch, call and jump delay slots
296 ;; .........................
298 (define_delay (and (eq_attr "type" "branch")
299 (eq (symbol_ref "TARGET_MIPS16") (const_int 0)))
300 [(eq_attr "can_delay" "yes")
302 (and (eq_attr "branch_likely" "yes")
303 (eq_attr "can_delay" "yes"))])
305 (define_delay (eq_attr "type" "jump")
306 [(eq_attr "can_delay" "yes")
310 (define_delay (and (eq_attr "type" "call")
311 (eq_attr "jal_macro" "no"))
312 [(eq_attr "can_delay" "yes")
316 ;; .........................
320 ;; .........................
322 ; (define_function_unit NAME MULTIPLICITY SIMULTANEITY
323 ; TEST READY-DELAY ISSUE-DELAY [CONFLICT-LIST])
325 ;; Make the default case (PROCESSOR_DEFAULT) handle the worst case
327 (define_function_unit "memory" 1 0
328 (and (eq_attr "type" "load,fpload,fpidxload")
329 (eq_attr "cpu" "!r3000,r3900,r4600,r4650,r4100,r4120,r4300,r5000"))
332 (define_function_unit "memory" 1 0
333 (and (eq_attr "type" "load,fpload,fpidxload")
334 (eq_attr "cpu" "r3000,r3900,r4600,r4650,r4100,r4120,r4300,r5000"))
337 (define_function_unit "memory" 1 0
338 (eq_attr "type" "store,fpstore,fpidxstore")
341 (define_function_unit "memory" 1 0 (eq_attr "type" "xfer") 2 0)
343 (define_function_unit "imuldiv" 1 0
344 (eq_attr "type" "mthilo,mfhilo")
347 (define_function_unit "imuldiv" 1 0
348 (and (eq_attr "type" "imul,imadd")
349 (eq_attr "cpu" "!r3000,r3900,r4000,r4600,r4650,r4100,r4120,r4300,r5000"))
352 ;; On them mips16, we want to stronly discourage a mult from appearing
353 ;; after an mflo, since that requires explicit nop instructions. We
354 ;; do this by pretending that mflo ties up the function unit for long
355 ;; enough that the scheduler will ignore load stalls and the like when
356 ;; selecting instructions to between the two instructions.
358 (define_function_unit "imuldiv" 1 0
359 (and (eq_attr "type" "mfhilo") (ne (symbol_ref "TARGET_MIPS16") (const_int 0)))
362 (define_function_unit "imuldiv" 1 0
363 (and (eq_attr "type" "imul,imadd") (eq_attr "cpu" "r3000,r3900"))
366 (define_function_unit "imuldiv" 1 0
367 (and (eq_attr "type" "imul,imadd") (eq_attr "cpu" "r4000,r4600"))
370 (define_function_unit "imuldiv" 1 0
371 (and (eq_attr "type" "imul,imadd") (eq_attr "cpu" "r4650"))
374 (define_function_unit "imuldiv" 1 0
375 (and (eq_attr "type" "imul,imadd")
376 (and (eq_attr "mode" "SI") (eq_attr "cpu" "r4100,r4120")))
379 (define_function_unit "imuldiv" 1 0
380 (and (eq_attr "type" "imul,imadd")
381 (and (eq_attr "mode" "DI") (eq_attr "cpu" "r4100,r4120")))
384 (define_function_unit "imuldiv" 1 0
385 (and (eq_attr "type" "imul,imadd")
386 (and (eq_attr "mode" "SI") (eq_attr "cpu" "r4300,r5000")))
389 (define_function_unit "imuldiv" 1 0
390 (and (eq_attr "type" "imul,imadd")
391 (and (eq_attr "mode" "DI") (eq_attr "cpu" "r4300")))
394 (define_function_unit "imuldiv" 1 0
395 (and (eq_attr "type" "imul,imadd")
396 (and (eq_attr "mode" "DI") (eq_attr "cpu" "r5000")))
399 (define_function_unit "imuldiv" 1 0
400 (and (eq_attr "type" "idiv")
401 (eq_attr "cpu" "!r3000,r3900,r4000,r4600,r4650,r4100,r4120,r4300,r5000"))
404 (define_function_unit "imuldiv" 1 0
405 (and (eq_attr "type" "idiv") (eq_attr "cpu" "r3000,r3900"))
408 (define_function_unit "imuldiv" 1 0
409 (and (eq_attr "type" "idiv") (eq_attr "cpu" "r4600"))
412 (define_function_unit "imuldiv" 1 0
413 (and (eq_attr "type" "idiv") (eq_attr "cpu" "r4650"))
416 (define_function_unit "imuldiv" 1 0
417 (and (eq_attr "type" "idiv") (eq_attr "cpu" "r4000"))
420 (define_function_unit "imuldiv" 1 0
421 (and (eq_attr "type" "idiv")
422 (and (eq_attr "mode" "SI") (eq_attr "cpu" "r4100,r4120")))
425 (define_function_unit "imuldiv" 1 0
426 (and (eq_attr "type" "idiv")
427 (and (eq_attr "mode" "DI") (eq_attr "cpu" "r4100,r4120")))
430 (define_function_unit "imuldiv" 1 0
431 (and (eq_attr "type" "idiv")
432 (and (eq_attr "mode" "SI") (eq_attr "cpu" "r4300")))
435 (define_function_unit "imuldiv" 1 0
436 (and (eq_attr "type" "idiv")
437 (and (eq_attr "mode" "DI") (eq_attr "cpu" "r4300")))
440 (define_function_unit "imuldiv" 1 0
441 (and (eq_attr "type" "idiv")
442 (and (eq_attr "mode" "SI") (eq_attr "cpu" "r5000")))
445 (define_function_unit "imuldiv" 1 0
446 (and (eq_attr "type" "idiv")
447 (and (eq_attr "mode" "DI") (eq_attr "cpu" "r5000")))
450 ;; The R4300 does *NOT* have a separate Floating Point Unit, instead
451 ;; the FP hardware is part of the normal ALU circuitry. This means FP
452 ;; instructions affect the pipe-line, and no functional unit
453 ;; parallelism can occur on R4300 processors. To force GCC into coding
454 ;; for only a single functional unit, we force the R4300 FP
455 ;; instructions to be processed in the "imuldiv" unit.
457 (define_function_unit "adder" 1 1
458 (and (eq_attr "type" "fcmp") (eq_attr "cpu" "!r3000,r3900,r6000,r4300,r5000"))
461 (define_function_unit "adder" 1 1
462 (and (eq_attr "type" "fcmp") (eq_attr "cpu" "r3000,r3900,r6000"))
465 (define_function_unit "adder" 1 1
466 (and (eq_attr "type" "fcmp") (eq_attr "cpu" "r5000"))
469 (define_function_unit "adder" 1 1
470 (and (eq_attr "type" "fadd") (eq_attr "cpu" "!r3000,r3900,r6000,r4300"))
473 (define_function_unit "adder" 1 1
474 (and (eq_attr "type" "fadd") (eq_attr "cpu" "r3000,r3900"))
477 (define_function_unit "adder" 1 1
478 (and (eq_attr "type" "fadd") (eq_attr "cpu" "r6000"))
481 (define_function_unit "adder" 1 1
482 (and (eq_attr "type" "fabs,fneg,fmove")
483 (eq_attr "cpu" "!r3000,r3900,r4600,r4650,r4300,r5000"))
486 (define_function_unit "adder" 1 1
487 (and (eq_attr "type" "fabs,fneg,fmove") (eq_attr "cpu" "r3000,r3900,r4600,r4650,r5000"))
490 (define_function_unit "mult" 1 1
491 (and (eq_attr "type" "fmul")
492 (and (eq_attr "mode" "SF")
493 (eq_attr "cpu" "!r3000,r3900,r6000,r4600,r4650,r4300,r5000")))
496 (define_function_unit "mult" 1 1
497 (and (eq_attr "type" "fmul")
498 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r3000,r3900,r5000")))
501 (define_function_unit "mult" 1 1
502 (and (eq_attr "type" "fmul")
503 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r6000")))
506 (define_function_unit "mult" 1 1
507 (and (eq_attr "type" "fmul")
508 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r4600,r4650")))
511 (define_function_unit "mult" 1 1
512 (and (eq_attr "type" "fmul")
513 (and (eq_attr "mode" "DF") (eq_attr "cpu" "!r3000,r3900,r6000,r4300,r5000")))
516 (define_function_unit "mult" 1 1
517 (and (eq_attr "type" "fmul")
518 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r3000,r3900,r5000")))
521 (define_function_unit "mult" 1 1
522 (and (eq_attr "type" "fmul")
523 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r6000")))
526 (define_function_unit "divide" 1 1
527 (and (eq_attr "type" "fdiv")
528 (and (eq_attr "mode" "SF")
529 (eq_attr "cpu" "!r3000,r3900,r6000,r4600,r4650,r4300,r5000")))
532 (define_function_unit "divide" 1 1
533 (and (eq_attr "type" "fdiv")
534 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r3000,r3900")))
537 (define_function_unit "divide" 1 1
538 (and (eq_attr "type" "fdiv")
539 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r6000")))
542 (define_function_unit "divide" 1 1
543 (and (eq_attr "type" "fdiv")
544 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r4600,r4650")))
547 (define_function_unit "divide" 1 1
548 (and (eq_attr "type" "fdiv")
549 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r5000")))
552 (define_function_unit "divide" 1 1
553 (and (eq_attr "type" "fdiv")
554 (and (eq_attr "mode" "DF")
555 (eq_attr "cpu" "!r3000,r3900,r6000,r4600,r4650,r4300")))
558 (define_function_unit "divide" 1 1
559 (and (eq_attr "type" "fdiv")
560 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r3000,r3900")))
563 (define_function_unit "divide" 1 1
564 (and (eq_attr "type" "fdiv")
565 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r6000")))
568 (define_function_unit "divide" 1 1
569 (and (eq_attr "type" "fdiv")
570 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r4600,r4650")))
573 ;;; ??? Is this number right?
574 (define_function_unit "divide" 1 1
575 (and (eq_attr "type" "fsqrt,frsqrt")
576 (and (eq_attr "mode" "SF") (eq_attr "cpu" "!r4600,r4650,r4300,r5000")))
579 (define_function_unit "divide" 1 1
580 (and (eq_attr "type" "fsqrt,frsqrt")
581 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r4600,r4650")))
584 (define_function_unit "divide" 1 1
585 (and (eq_attr "type" "fsqrt,frsqrt")
586 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r5000")))
589 ;;; ??? Is this number right?
590 (define_function_unit "divide" 1 1
591 (and (eq_attr "type" "fsqrt,frsqrt")
592 (and (eq_attr "mode" "DF") (eq_attr "cpu" "!r4600,r4650,r4300,r5000")))
595 (define_function_unit "divide" 1 1
596 (and (eq_attr "type" "fsqrt,frsqrt")
597 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r4600,r4650")))
600 (define_function_unit "divide" 1 1
601 (and (eq_attr "type" "fsqrt,frsqrt")
602 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r5000")))
605 ;; R4300 FP instruction classes treated as part of the "imuldiv"
608 (define_function_unit "imuldiv" 1 0
609 (and (eq_attr "type" "fadd") (eq_attr "cpu" "r4300"))
612 (define_function_unit "imuldiv" 1 0
613 (and (eq_attr "type" "fcmp,fabs,fneg,fmove") (eq_attr "cpu" "r4300"))
616 (define_function_unit "imuldiv" 1 0
617 (and (eq_attr "type" "fmul") (and (eq_attr "mode" "SF") (eq_attr "cpu" "r4300")))
619 (define_function_unit "imuldiv" 1 0
620 (and (eq_attr "type" "fmul") (and (eq_attr "mode" "DF") (eq_attr "cpu" "r4300")))
623 (define_function_unit "imuldiv" 1 0
624 (and (and (eq_attr "type" "fdiv") (eq_attr "type" "fsqrt,frsqrt"))
625 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r4300")))
627 (define_function_unit "imuldiv" 1 0
628 (and (and (eq_attr "type" "fdiv") (eq_attr "type" "fsqrt,frsqrt"))
629 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r4300")))
632 ;; Include scheduling descriptions.
643 ;; ....................
647 ;; ....................
651 [(trap_if (const_int 1) (const_int 0))]
654 if (ISA_HAS_COND_TRAP)
656 /* The IRIX 6 O32 assembler requires the first break operand. */
657 else if (TARGET_MIPS16 || !TARGET_GAS)
662 [(set_attr "type" "trap")])
664 (define_expand "conditional_trap"
665 [(trap_if (match_operator 0 "cmp_op"
666 [(match_dup 2) (match_dup 3)])
667 (match_operand 1 "const_int_operand"))]
670 if (operands[1] == const0_rtx)
672 mips_gen_conditional_trap (operands);
680 [(trap_if (match_operator 0 "trap_cmp_op"
681 [(match_operand:SI 1 "reg_or_0_operand" "dJ")
682 (match_operand:SI 2 "arith_operand" "dI")])
686 [(set_attr "type" "trap")])
689 [(trap_if (match_operator 0 "trap_cmp_op"
690 [(match_operand:DI 1 "reg_or_0_operand" "dJ")
691 (match_operand:DI 2 "arith_operand" "dI")])
693 "TARGET_64BIT && ISA_HAS_COND_TRAP"
695 [(set_attr "type" "trap")])
698 ;; ....................
702 ;; ....................
705 (define_insn "adddf3"
706 [(set (match_operand:DF 0 "register_operand" "=f")
707 (plus:DF (match_operand:DF 1 "register_operand" "f")
708 (match_operand:DF 2 "register_operand" "f")))]
709 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
711 [(set_attr "type" "fadd")
712 (set_attr "mode" "DF")])
714 (define_insn "addsf3"
715 [(set (match_operand:SF 0 "register_operand" "=f")
716 (plus:SF (match_operand:SF 1 "register_operand" "f")
717 (match_operand:SF 2 "register_operand" "f")))]
720 [(set_attr "type" "fadd")
721 (set_attr "mode" "SF")])
723 (define_expand "addsi3"
724 [(set (match_operand:SI 0 "register_operand")
725 (plus:SI (match_operand:SI 1 "reg_or_0_operand")
726 (match_operand:SI 2 "arith_operand")))]
729 /* If a large stack adjustment was forced into a register, we may be
730 asked to generate rtx such as:
732 (set (reg:SI sp) (plus:SI (reg:SI sp) (reg:SI pseudo)))
734 but no such instruction is available in mips16. Handle it by
735 using a temporary. */
737 && REGNO (operands[0]) == STACK_POINTER_REGNUM
738 && ((GET_CODE (operands[1]) == REG
739 && REGNO (operands[1]) != STACK_POINTER_REGNUM)
740 || GET_CODE (operands[2]) != CONST_INT))
742 rtx tmp = gen_reg_rtx (SImode);
744 emit_move_insn (tmp, operands[1]);
745 emit_insn (gen_addsi3 (tmp, tmp, operands[2]));
746 emit_move_insn (operands[0], tmp);
751 (define_insn "addsi3_internal"
752 [(set (match_operand:SI 0 "register_operand" "=d,d")
753 (plus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ,dJ")
754 (match_operand:SI 2 "arith_operand" "d,Q")))]
759 [(set_attr "type" "arith")
760 (set_attr "mode" "SI")])
762 ;; For the mips16, we need to recognize stack pointer additions
763 ;; explicitly, since we don't have a constraint for $sp. These insns
764 ;; will be generated by the save_restore_insns functions.
769 (match_operand:SI 0 "small_int" "I")))]
772 [(set_attr "type" "arith")
773 (set_attr "mode" "SI")
774 (set (attr "length") (if_then_else (match_operand:VOID 0 "m16_simm8_8")
779 [(set (match_operand:SI 0 "register_operand" "=d")
781 (match_operand:SI 1 "small_int" "I")))]
784 [(set_attr "type" "arith")
785 (set_attr "mode" "SI")
786 (set (attr "length") (if_then_else (match_operand:VOID 1 "m16_uimm8_4")
791 [(set (match_operand:SI 0 "register_operand" "=d,d,d")
792 (plus:SI (match_operand:SI 1 "register_operand" "0,d,d")
793 (match_operand:SI 2 "arith_operand" "Q,O,d")))]
795 && (GET_CODE (operands[1]) != REG
796 || REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER
797 || M16_REG_P (REGNO (operands[1]))
798 || REGNO (operands[1]) == ARG_POINTER_REGNUM
799 || REGNO (operands[1]) == FRAME_POINTER_REGNUM
800 || REGNO (operands[1]) == STACK_POINTER_REGNUM)
801 && (GET_CODE (operands[2]) != REG
802 || REGNO (operands[2]) >= FIRST_PSEUDO_REGISTER
803 || M16_REG_P (REGNO (operands[2]))
804 || REGNO (operands[2]) == ARG_POINTER_REGNUM
805 || REGNO (operands[2]) == FRAME_POINTER_REGNUM
806 || REGNO (operands[2]) == STACK_POINTER_REGNUM)"
808 if (REGNO (operands[0]) == REGNO (operands[1]))
809 return "addu\t%0,%2";
811 return "addu\t%0,%1,%2";
813 [(set_attr "type" "arith")
814 (set_attr "mode" "SI")
815 (set_attr_alternative "length"
816 [(if_then_else (match_operand:VOID 2 "m16_simm8_1")
819 (if_then_else (match_operand:VOID 2 "m16_simm4_1")
825 ;; On the mips16, we can sometimes split an add of a constant which is
826 ;; a 4 byte instruction into two adds which are both 2 byte
827 ;; instructions. There are two cases: one where we are adding a
828 ;; constant plus a register to another register, and one where we are
829 ;; simply adding a constant to a register.
832 [(set (match_operand:SI 0 "register_operand")
833 (plus:SI (match_dup 0)
834 (match_operand:SI 1 "const_int_operand")))]
835 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
836 && GET_CODE (operands[0]) == REG
837 && M16_REG_P (REGNO (operands[0]))
838 && GET_CODE (operands[1]) == CONST_INT
839 && ((INTVAL (operands[1]) > 0x7f
840 && INTVAL (operands[1]) <= 0x7f + 0x7f)
841 || (INTVAL (operands[1]) < - 0x80
842 && INTVAL (operands[1]) >= - 0x80 - 0x80))"
843 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
844 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]
846 HOST_WIDE_INT val = INTVAL (operands[1]);
850 operands[1] = GEN_INT (0x7f);
851 operands[2] = GEN_INT (val - 0x7f);
855 operands[1] = GEN_INT (- 0x80);
856 operands[2] = GEN_INT (val + 0x80);
861 [(set (match_operand:SI 0 "register_operand")
862 (plus:SI (match_operand:SI 1 "register_operand")
863 (match_operand:SI 2 "const_int_operand")))]
864 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
865 && GET_CODE (operands[0]) == REG
866 && M16_REG_P (REGNO (operands[0]))
867 && GET_CODE (operands[1]) == REG
868 && M16_REG_P (REGNO (operands[1]))
869 && REGNO (operands[0]) != REGNO (operands[1])
870 && GET_CODE (operands[2]) == CONST_INT
871 && ((INTVAL (operands[2]) > 0x7
872 && INTVAL (operands[2]) <= 0x7 + 0x7f)
873 || (INTVAL (operands[2]) < - 0x8
874 && INTVAL (operands[2]) >= - 0x8 - 0x80))"
875 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))
876 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 3)))]
878 HOST_WIDE_INT val = INTVAL (operands[2]);
882 operands[2] = GEN_INT (0x7);
883 operands[3] = GEN_INT (val - 0x7);
887 operands[2] = GEN_INT (- 0x8);
888 operands[3] = GEN_INT (val + 0x8);
892 (define_expand "adddi3"
893 [(parallel [(set (match_operand:DI 0 "register_operand")
894 (plus:DI (match_operand:DI 1 "register_operand")
895 (match_operand:DI 2 "arith_operand")))
896 (clobber (match_dup 3))])]
897 "TARGET_64BIT || (!TARGET_DEBUG_G_MODE && !TARGET_MIPS16)"
899 /* If a large stack adjustment was forced into a register, we may be
900 asked to generate rtx such as:
902 (set (reg:DI sp) (plus:DI (reg:DI sp) (reg:DI pseudo)))
904 but no such instruction is available in mips16. Handle it by
905 using a temporary. */
907 && REGNO (operands[0]) == STACK_POINTER_REGNUM
908 && ((GET_CODE (operands[1]) == REG
909 && REGNO (operands[1]) != STACK_POINTER_REGNUM)
910 || GET_CODE (operands[2]) != CONST_INT))
912 rtx tmp = gen_reg_rtx (DImode);
914 emit_move_insn (tmp, operands[1]);
915 emit_insn (gen_adddi3 (tmp, tmp, operands[2]));
916 emit_move_insn (operands[0], tmp);
922 emit_insn (gen_adddi3_internal_3 (operands[0], operands[1],
927 operands[3] = gen_reg_rtx (SImode);
930 (define_insn "adddi3_internal_1"
931 [(set (match_operand:DI 0 "register_operand" "=d,&d")
932 (plus:DI (match_operand:DI 1 "register_operand" "0,d")
933 (match_operand:DI 2 "register_operand" "d,d")))
934 (clobber (match_operand:SI 3 "register_operand" "=d,d"))]
935 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16"
937 return (REGNO (operands[0]) == REGNO (operands[1])
938 && REGNO (operands[0]) == REGNO (operands[2]))
939 ? "srl\t%3,%L0,31\;sll\t%M0,%M0,1\;sll\t%L0,%L1,1\;addu\t%M0,%M0,%3"
940 : "addu\t%L0,%L1,%L2\;sltu\t%3,%L0,%L2\;addu\t%M0,%M1,%M2\;addu\t%M0,%M0,%3";
942 [(set_attr "type" "multi")
943 (set_attr "mode" "DI")
944 (set_attr "length" "16")])
947 [(set (match_operand:DI 0 "register_operand")
948 (plus:DI (match_operand:DI 1 "register_operand")
949 (match_operand:DI 2 "register_operand")))
950 (clobber (match_operand:SI 3 "register_operand"))]
951 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
952 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
953 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
954 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
955 && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))
956 && (REGNO (operands[0]) != REGNO (operands[1])
957 || REGNO (operands[0]) != REGNO (operands[2]))"
959 [(set (subreg:SI (match_dup 0) 0)
960 (plus:SI (subreg:SI (match_dup 1) 0)
961 (subreg:SI (match_dup 2) 0)))
964 (ltu:SI (subreg:SI (match_dup 0) 0)
965 (subreg:SI (match_dup 2) 0)))
967 (set (subreg:SI (match_dup 0) 4)
968 (plus:SI (subreg:SI (match_dup 1) 4)
969 (subreg:SI (match_dup 2) 4)))
971 (set (subreg:SI (match_dup 0) 4)
972 (plus:SI (subreg:SI (match_dup 0) 4)
977 [(set (match_operand:DI 0 "register_operand")
978 (plus:DI (match_operand:DI 1 "register_operand")
979 (match_operand:DI 2 "register_operand")))
980 (clobber (match_operand:SI 3 "register_operand"))]
981 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
982 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
983 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
984 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
985 && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))
986 && (REGNO (operands[0]) != REGNO (operands[1])
987 || REGNO (operands[0]) != REGNO (operands[2]))"
989 [(set (subreg:SI (match_dup 0) 4)
990 (plus:SI (subreg:SI (match_dup 1) 4)
991 (subreg:SI (match_dup 2) 4)))
994 (ltu:SI (subreg:SI (match_dup 0) 4)
995 (subreg:SI (match_dup 2) 4)))
997 (set (subreg:SI (match_dup 0) 0)
998 (plus:SI (subreg:SI (match_dup 1) 0)
999 (subreg:SI (match_dup 2) 0)))
1001 (set (subreg:SI (match_dup 0) 0)
1002 (plus:SI (subreg:SI (match_dup 0) 0)
1006 (define_insn "adddi3_internal_2"
1007 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1008 (plus:DI (match_operand:DI 1 "register_operand" "%d,d,d")
1009 (match_operand:DI 2 "small_int" "P,J,N")))
1010 (clobber (match_operand:SI 3 "register_operand" "=d,d,d"))]
1011 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16"
1013 addu\t%L0,%L1,%2\;sltu\t%3,%L0,%2\;addu\t%M0,%M1,%3
1014 move\t%L0,%L1\;move\t%M0,%M1
1015 subu\t%L0,%L1,%n2\;sltu\t%3,%L0,%2\;subu\t%M0,%M1,1\;addu\t%M0,%M0,%3"
1016 [(set_attr "type" "multi")
1017 (set_attr "mode" "DI")
1018 (set_attr "length" "12,8,16")])
1021 [(set (match_operand:DI 0 "register_operand")
1022 (plus:DI (match_operand:DI 1 "register_operand")
1023 (match_operand:DI 2 "small_int")))
1024 (clobber (match_operand:SI 3 "register_operand"))]
1025 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
1026 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
1027 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1028 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1029 && INTVAL (operands[2]) > 0"
1031 [(set (subreg:SI (match_dup 0) 0)
1032 (plus:SI (subreg:SI (match_dup 1) 0)
1036 (ltu:SI (subreg:SI (match_dup 0) 0)
1039 (set (subreg:SI (match_dup 0) 4)
1040 (plus:SI (subreg:SI (match_dup 1) 4)
1045 [(set (match_operand:DI 0 "register_operand")
1046 (plus:DI (match_operand:DI 1 "register_operand")
1047 (match_operand:DI 2 "small_int")))
1048 (clobber (match_operand:SI 3 "register_operand"))]
1049 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
1050 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
1051 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1052 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1053 && INTVAL (operands[2]) > 0"
1055 [(set (subreg:SI (match_dup 0) 4)
1056 (plus:SI (subreg:SI (match_dup 1) 4)
1060 (ltu:SI (subreg:SI (match_dup 0) 4)
1063 (set (subreg:SI (match_dup 0) 0)
1064 (plus:SI (subreg:SI (match_dup 1) 0)
1068 (define_insn "adddi3_internal_3"
1069 [(set (match_operand:DI 0 "register_operand" "=d,d")
1070 (plus:DI (match_operand:DI 1 "reg_or_0_operand" "dJ,dJ")
1071 (match_operand:DI 2 "arith_operand" "d,Q")))]
1072 "TARGET_64BIT && !TARGET_MIPS16"
1076 [(set_attr "type" "arith")
1077 (set_attr "mode" "DI")])
1079 ;; For the mips16, we need to recognize stack pointer additions
1080 ;; explicitly, since we don't have a constraint for $sp. These insns
1081 ;; will be generated by the save_restore_insns functions.
1085 (plus:DI (reg:DI 29)
1086 (match_operand:DI 0 "small_int" "I")))]
1087 "TARGET_MIPS16 && TARGET_64BIT"
1089 [(set_attr "type" "arith")
1090 (set_attr "mode" "DI")
1091 (set (attr "length") (if_then_else (match_operand:VOID 0 "m16_simm8_8")
1096 [(set (match_operand:DI 0 "register_operand" "=d")
1097 (plus:DI (reg:DI 29)
1098 (match_operand:DI 1 "small_int" "I")))]
1099 "TARGET_MIPS16 && TARGET_64BIT"
1101 [(set_attr "type" "arith")
1102 (set_attr "mode" "DI")
1103 (set (attr "length") (if_then_else (match_operand:VOID 0 "m16_uimm5_4")
1108 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1109 (plus:DI (match_operand:DI 1 "register_operand" "0,d,d")
1110 (match_operand:DI 2 "arith_operand" "Q,O,d")))]
1111 "TARGET_MIPS16 && TARGET_64BIT
1112 && (GET_CODE (operands[1]) != REG
1113 || REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER
1114 || M16_REG_P (REGNO (operands[1]))
1115 || REGNO (operands[1]) == ARG_POINTER_REGNUM
1116 || REGNO (operands[1]) == FRAME_POINTER_REGNUM
1117 || REGNO (operands[1]) == STACK_POINTER_REGNUM)
1118 && (GET_CODE (operands[2]) != REG
1119 || REGNO (operands[2]) >= FIRST_PSEUDO_REGISTER
1120 || M16_REG_P (REGNO (operands[2]))
1121 || REGNO (operands[2]) == ARG_POINTER_REGNUM
1122 || REGNO (operands[2]) == FRAME_POINTER_REGNUM
1123 || REGNO (operands[2]) == STACK_POINTER_REGNUM)"
1125 if (REGNO (operands[0]) == REGNO (operands[1]))
1126 return "daddu\t%0,%2";
1128 return "daddu\t%0,%1,%2";
1130 [(set_attr "type" "arith")
1131 (set_attr "mode" "DI")
1132 (set_attr_alternative "length"
1133 [(if_then_else (match_operand:VOID 2 "m16_simm5_1")
1136 (if_then_else (match_operand:VOID 2 "m16_simm4_1")
1142 ;; On the mips16, we can sometimes split an add of a constant which is
1143 ;; a 4 byte instruction into two adds which are both 2 byte
1144 ;; instructions. There are two cases: one where we are adding a
1145 ;; constant plus a register to another register, and one where we are
1146 ;; simply adding a constant to a register.
1149 [(set (match_operand:DI 0 "register_operand")
1150 (plus:DI (match_dup 0)
1151 (match_operand:DI 1 "const_int_operand")))]
1152 "TARGET_MIPS16 && TARGET_64BIT && reload_completed && !TARGET_DEBUG_D_MODE
1153 && GET_CODE (operands[0]) == REG
1154 && M16_REG_P (REGNO (operands[0]))
1155 && GET_CODE (operands[1]) == CONST_INT
1156 && ((INTVAL (operands[1]) > 0xf
1157 && INTVAL (operands[1]) <= 0xf + 0xf)
1158 || (INTVAL (operands[1]) < - 0x10
1159 && INTVAL (operands[1]) >= - 0x10 - 0x10))"
1160 [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1)))
1161 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))]
1163 HOST_WIDE_INT val = INTVAL (operands[1]);
1167 operands[1] = GEN_INT (0xf);
1168 operands[2] = GEN_INT (val - 0xf);
1172 operands[1] = GEN_INT (- 0x10);
1173 operands[2] = GEN_INT (val + 0x10);
1178 [(set (match_operand:DI 0 "register_operand")
1179 (plus:DI (match_operand:DI 1 "register_operand")
1180 (match_operand:DI 2 "const_int_operand")))]
1181 "TARGET_MIPS16 && TARGET_64BIT && reload_completed && !TARGET_DEBUG_D_MODE
1182 && GET_CODE (operands[0]) == REG
1183 && M16_REG_P (REGNO (operands[0]))
1184 && GET_CODE (operands[1]) == REG
1185 && M16_REG_P (REGNO (operands[1]))
1186 && REGNO (operands[0]) != REGNO (operands[1])
1187 && GET_CODE (operands[2]) == CONST_INT
1188 && ((INTVAL (operands[2]) > 0x7
1189 && INTVAL (operands[2]) <= 0x7 + 0xf)
1190 || (INTVAL (operands[2]) < - 0x8
1191 && INTVAL (operands[2]) >= - 0x8 - 0x10))"
1192 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))
1193 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
1195 HOST_WIDE_INT val = INTVAL (operands[2]);
1199 operands[2] = GEN_INT (0x7);
1200 operands[3] = GEN_INT (val - 0x7);
1204 operands[2] = GEN_INT (- 0x8);
1205 operands[3] = GEN_INT (val + 0x8);
1209 (define_insn "addsi3_internal_2"
1210 [(set (match_operand:DI 0 "register_operand" "=d,d")
1211 (sign_extend:DI (plus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ,dJ")
1212 (match_operand:SI 2 "arith_operand" "d,Q"))))]
1213 "TARGET_64BIT && !TARGET_MIPS16"
1217 [(set_attr "type" "arith")
1218 (set_attr "mode" "SI")])
1221 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1222 (sign_extend:DI (plus:SI (match_operand:SI 1 "register_operand" "0,d,d")
1223 (match_operand:SI 2 "arith_operand" "Q,O,d"))))]
1224 "TARGET_MIPS16 && TARGET_64BIT"
1226 if (REGNO (operands[0]) == REGNO (operands[1]))
1227 return "addu\t%0,%2";
1229 return "addu\t%0,%1,%2";
1231 [(set_attr "type" "arith")
1232 (set_attr "mode" "SI")
1233 (set_attr_alternative "length"
1234 [(if_then_else (match_operand:VOID 2 "m16_simm8_1")
1237 (if_then_else (match_operand:VOID 2 "m16_simm4_1")
1243 ;; ....................
1247 ;; ....................
1250 (define_insn "subdf3"
1251 [(set (match_operand:DF 0 "register_operand" "=f")
1252 (minus:DF (match_operand:DF 1 "register_operand" "f")
1253 (match_operand:DF 2 "register_operand" "f")))]
1254 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
1256 [(set_attr "type" "fadd")
1257 (set_attr "mode" "DF")])
1259 (define_insn "subsf3"
1260 [(set (match_operand:SF 0 "register_operand" "=f")
1261 (minus:SF (match_operand:SF 1 "register_operand" "f")
1262 (match_operand:SF 2 "register_operand" "f")))]
1265 [(set_attr "type" "fadd")
1266 (set_attr "mode" "SF")])
1268 (define_expand "subsi3"
1269 [(set (match_operand:SI 0 "register_operand")
1270 (minus:SI (match_operand:SI 1 "register_operand")
1271 (match_operand:SI 2 "register_operand")))]
1275 (define_insn "subsi3_internal"
1276 [(set (match_operand:SI 0 "register_operand" "=d")
1277 (minus:SI (match_operand:SI 1 "register_operand" "d")
1278 (match_operand:SI 2 "register_operand" "d")))]
1281 [(set_attr "type" "arith")
1282 (set_attr "mode" "SI")])
1284 (define_expand "subdi3"
1285 [(parallel [(set (match_operand:DI 0 "register_operand")
1286 (minus:DI (match_operand:DI 1 "register_operand")
1287 (match_operand:DI 2 "register_operand")))
1288 (clobber (match_dup 3))])]
1289 "TARGET_64BIT || (!TARGET_DEBUG_G_MODE && !TARGET_MIPS16)"
1293 emit_insn (gen_subdi3_internal_3 (operands[0], operands[1],
1298 operands[3] = gen_reg_rtx (SImode);
1301 (define_insn "subdi3_internal"
1302 [(set (match_operand:DI 0 "register_operand" "=d")
1303 (minus:DI (match_operand:DI 1 "register_operand" "d")
1304 (match_operand:DI 2 "register_operand" "d")))
1305 (clobber (match_operand:SI 3 "register_operand" "=d"))]
1306 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16"
1307 "sltu\t%3,%L1,%L2\;subu\t%L0,%L1,%L2\;subu\t%M0,%M1,%M2\;subu\t%M0,%M0,%3"
1308 [(set_attr "type" "multi")
1309 (set_attr "mode" "DI")
1310 (set_attr "length" "16")])
1313 [(set (match_operand:DI 0 "register_operand")
1314 (minus:DI (match_operand:DI 1 "register_operand")
1315 (match_operand:DI 2 "register_operand")))
1316 (clobber (match_operand:SI 3 "register_operand"))]
1317 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
1318 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
1319 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1320 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1321 && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))"
1324 (ltu:SI (subreg:SI (match_dup 1) 0)
1325 (subreg:SI (match_dup 2) 0)))
1327 (set (subreg:SI (match_dup 0) 0)
1328 (minus:SI (subreg:SI (match_dup 1) 0)
1329 (subreg:SI (match_dup 2) 0)))
1331 (set (subreg:SI (match_dup 0) 4)
1332 (minus:SI (subreg:SI (match_dup 1) 4)
1333 (subreg:SI (match_dup 2) 4)))
1335 (set (subreg:SI (match_dup 0) 4)
1336 (minus:SI (subreg:SI (match_dup 0) 4)
1341 [(set (match_operand:DI 0 "register_operand")
1342 (minus:DI (match_operand:DI 1 "register_operand")
1343 (match_operand:DI 2 "register_operand")))
1344 (clobber (match_operand:SI 3 "register_operand"))]
1345 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
1346 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
1347 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1348 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1349 && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))"
1352 (ltu:SI (subreg:SI (match_dup 1) 4)
1353 (subreg:SI (match_dup 2) 4)))
1355 (set (subreg:SI (match_dup 0) 4)
1356 (minus:SI (subreg:SI (match_dup 1) 4)
1357 (subreg:SI (match_dup 2) 4)))
1359 (set (subreg:SI (match_dup 0) 0)
1360 (minus:SI (subreg:SI (match_dup 1) 0)
1361 (subreg:SI (match_dup 2) 0)))
1363 (set (subreg:SI (match_dup 0) 0)
1364 (minus:SI (subreg:SI (match_dup 0) 0)
1368 (define_insn "subdi3_internal_3"
1369 [(set (match_operand:DI 0 "register_operand" "=d")
1370 (minus:DI (match_operand:DI 1 "register_operand" "d")
1371 (match_operand:DI 2 "register_operand" "d")))]
1374 [(set_attr "type" "arith")
1375 (set_attr "mode" "DI")])
1377 (define_insn "subsi3_internal_2"
1378 [(set (match_operand:DI 0 "register_operand" "=d")
1380 (minus:SI (match_operand:SI 1 "register_operand" "d")
1381 (match_operand:SI 2 "register_operand" "d"))))]
1384 [(set_attr "type" "arith")
1385 (set_attr "mode" "DI")])
1388 ;; ....................
1392 ;; ....................
1395 (define_expand "muldf3"
1396 [(set (match_operand:DF 0 "register_operand")
1397 (mult:DF (match_operand:DF 1 "register_operand")
1398 (match_operand:DF 2 "register_operand")))]
1399 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
1402 (define_insn "muldf3_internal"
1403 [(set (match_operand:DF 0 "register_operand" "=f")
1404 (mult:DF (match_operand:DF 1 "register_operand" "f")
1405 (match_operand:DF 2 "register_operand" "f")))]
1406 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_4300_MUL_FIX"
1408 [(set_attr "type" "fmul")
1409 (set_attr "mode" "DF")])
1411 ;; Early VR4300 silicon has a CPU bug where multiplies with certain
1412 ;; operands may corrupt immediately following multiplies. This is a
1413 ;; simple fix to insert NOPs.
1415 (define_insn "muldf3_r4300"
1416 [(set (match_operand:DF 0 "register_operand" "=f")
1417 (mult:DF (match_operand:DF 1 "register_operand" "f")
1418 (match_operand:DF 2 "register_operand" "f")))]
1419 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_4300_MUL_FIX"
1420 "mul.d\t%0,%1,%2\;nop"
1421 [(set_attr "type" "fmul")
1422 (set_attr "mode" "DF")
1423 (set_attr "length" "8")])
1425 (define_expand "mulsf3"
1426 [(set (match_operand:SF 0 "register_operand")
1427 (mult:SF (match_operand:SF 1 "register_operand")
1428 (match_operand:SF 2 "register_operand")))]
1432 (define_insn "mulsf3_internal"
1433 [(set (match_operand:SF 0 "register_operand" "=f")
1434 (mult:SF (match_operand:SF 1 "register_operand" "f")
1435 (match_operand:SF 2 "register_operand" "f")))]
1436 "TARGET_HARD_FLOAT && !TARGET_4300_MUL_FIX"
1438 [(set_attr "type" "fmul")
1439 (set_attr "mode" "SF")])
1441 ;; See muldf3_r4300.
1443 (define_insn "mulsf3_r4300"
1444 [(set (match_operand:SF 0 "register_operand" "=f")
1445 (mult:SF (match_operand:SF 1 "register_operand" "f")
1446 (match_operand:SF 2 "register_operand" "f")))]
1447 "TARGET_HARD_FLOAT && TARGET_4300_MUL_FIX"
1448 "mul.s\t%0,%1,%2\;nop"
1449 [(set_attr "type" "fmul")
1450 (set_attr "mode" "SF")
1451 (set_attr "length" "8")])
1454 ;; The original R4000 has a cpu bug. If a double-word or a variable
1455 ;; shift executes while an integer multiplication is in progress, the
1456 ;; shift may give an incorrect result. Avoid this by keeping the mflo
1457 ;; with the mult on the R4000.
1459 ;; From "MIPS R4000PC/SC Errata, Processor Revision 2.2 and 3.0"
1460 ;; (also valid for MIPS R4000MC processors):
1462 ;; "16. R4000PC, R4000SC: Please refer to errata 28 for an update to
1463 ;; this errata description.
1464 ;; The following code sequence causes the R4000 to incorrectly
1465 ;; execute the Double Shift Right Arithmetic 32 (dsra32)
1466 ;; instruction. If the dsra32 instruction is executed during an
1467 ;; integer multiply, the dsra32 will only shift by the amount in
1468 ;; specified in the instruction rather than the amount plus 32
1470 ;; instruction 1: mult rs,rt integer multiply
1471 ;; instruction 2-12: dsra32 rd,rt,rs doubleword shift
1472 ;; right arithmetic + 32
1473 ;; Workaround: A dsra32 instruction placed after an integer
1474 ;; multiply should not be one of the 11 instructions after the
1475 ;; multiply instruction."
1479 ;; "28. R4000PC, R4000SC: The text from errata 16 should be replaced by
1480 ;; the following description.
1481 ;; All extended shifts (shift by n+32) and variable shifts (32 and
1482 ;; 64-bit versions) may produce incorrect results under the
1483 ;; following conditions:
1484 ;; 1) An integer multiply is currently executing
1485 ;; 2) These types of shift instructions are executed immediately
1486 ;; following an integer divide instruction.
1488 ;; 1) Make sure no integer multiply is running wihen these
1489 ;; instruction are executed. If this cannot be predicted at
1490 ;; compile time, then insert a "mfhi" to R0 instruction
1491 ;; immediately after the integer multiply instruction. This
1492 ;; will cause the integer multiply to complete before the shift
1494 ;; 2) Separate integer divide and these two classes of shift
1495 ;; instructions by another instruction or a noop."
1497 ;; These processors have PRId values of 0x00004220 and 0x00004300,
1500 (define_expand "mulsi3"
1501 [(set (match_operand:SI 0 "register_operand")
1502 (mult:SI (match_operand:SI 1 "register_operand")
1503 (match_operand:SI 2 "register_operand")))]
1506 if (GENERATE_MULT3_SI || TARGET_MAD)
1507 emit_insn (gen_mulsi3_mult3 (operands[0], operands[1], operands[2]));
1508 else if (!TARGET_FIX_R4000)
1509 emit_insn (gen_mulsi3_internal (operands[0], operands[1], operands[2]));
1511 emit_insn (gen_mulsi3_r4000 (operands[0], operands[1], operands[2]));
1515 (define_insn "mulsi3_mult3"
1516 [(set (match_operand:SI 0 "register_operand" "=d,l")
1517 (mult:SI (match_operand:SI 1 "register_operand" "d,d")
1518 (match_operand:SI 2 "register_operand" "d,d")))
1519 (clobber (match_scratch:SI 3 "=h,h"))
1520 (clobber (match_scratch:SI 4 "=l,X"))]
1524 if (which_alternative == 1)
1525 return "mult\t%1,%2";
1534 return "mul\t%0,%1,%2";
1535 return "mult\t%0,%1,%2";
1537 [(set_attr "type" "imul")
1538 (set_attr "mode" "SI")])
1540 ;; If a register gets allocated to LO, and we spill to memory, the reload
1541 ;; will include a move from LO to a GPR. Merge it into the multiplication
1542 ;; if it can set the GPR directly.
1545 ;; Operand 1: GPR (1st multiplication operand)
1546 ;; Operand 2: GPR (2nd multiplication operand)
1548 ;; Operand 4: GPR (destination)
1551 [(set (match_operand:SI 0 "register_operand")
1552 (mult:SI (match_operand:SI 1 "register_operand")
1553 (match_operand:SI 2 "register_operand")))
1554 (clobber (match_operand:SI 3 "register_operand"))
1555 (clobber (scratch:SI))])
1556 (set (match_operand:SI 4 "register_operand")
1557 (unspec [(match_dup 0) (match_dup 3)] UNSPEC_MFHILO))]
1558 "GENERATE_MULT3_SI && peep2_reg_dead_p (2, operands[0])"
1561 (mult:SI (match_dup 1)
1563 (clobber (match_dup 3))
1564 (clobber (match_dup 0))])])
1566 (define_insn "mulsi3_internal"
1567 [(set (match_operand:SI 0 "register_operand" "=l")
1568 (mult:SI (match_operand:SI 1 "register_operand" "d")
1569 (match_operand:SI 2 "register_operand" "d")))
1570 (clobber (match_scratch:SI 3 "=h"))]
1573 [(set_attr "type" "imul")
1574 (set_attr "mode" "SI")])
1576 (define_insn "mulsi3_r4000"
1577 [(set (match_operand:SI 0 "register_operand" "=d")
1578 (mult:SI (match_operand:SI 1 "register_operand" "d")
1579 (match_operand:SI 2 "register_operand" "d")))
1580 (clobber (match_scratch:SI 3 "=h"))
1581 (clobber (match_scratch:SI 4 "=l"))]
1583 "mult\t%1,%2\;mflo\t%0"
1584 [(set_attr "type" "imul")
1585 (set_attr "mode" "SI")
1586 (set_attr "length" "8")])
1588 ;; On the VR4120 and VR4130, it is better to use "mtlo $0; macc" instead
1589 ;; of "mult; mflo". They have the same latency, but the first form gives
1590 ;; us an extra cycle to compute the operands.
1593 ;; Operand 1: GPR (1st multiplication operand)
1594 ;; Operand 2: GPR (2nd multiplication operand)
1596 ;; Operand 4: GPR (destination)
1599 [(set (match_operand:SI 0 "register_operand")
1600 (mult:SI (match_operand:SI 1 "register_operand")
1601 (match_operand:SI 2 "register_operand")))
1602 (clobber (match_operand:SI 3 "register_operand"))])
1603 (set (match_operand:SI 4 "register_operand")
1604 (unspec:SI [(match_dup 0) (match_dup 3)] UNSPEC_MFHILO))]
1605 "ISA_HAS_MACC && !GENERATE_MULT3_SI"
1610 (plus:SI (mult:SI (match_dup 1)
1614 (plus:SI (mult:SI (match_dup 1)
1617 (clobber (match_dup 3))])])
1619 ;; Multiply-accumulate patterns
1621 ;; For processors that can copy the output to a general register:
1623 ;; The all-d alternative is needed because the combiner will find this
1624 ;; pattern and then register alloc/reload will move registers around to
1625 ;; make them fit, and we don't want to trigger unnecessary loads to LO.
1627 ;; The last alternative should be made slightly less desirable, but adding
1628 ;; "?" to the constraint is too strong, and causes values to be loaded into
1629 ;; LO even when that's more costly. For now, using "*d" mostly does the
1631 (define_insn "*mul_acc_si"
1632 [(set (match_operand:SI 0 "register_operand" "=l,*d,*d")
1633 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d,d")
1634 (match_operand:SI 2 "register_operand" "d,d,d"))
1635 (match_operand:SI 3 "register_operand" "0,l,*d")))
1636 (clobber (match_scratch:SI 4 "=h,h,h"))
1637 (clobber (match_scratch:SI 5 "=X,3,l"))
1638 (clobber (match_scratch:SI 6 "=X,X,&d"))]
1640 || ISA_HAS_MADD_MSUB)
1643 static const char *const madd[] = { "madd\t%1,%2", "madd\t%0,%1,%2" };
1644 if (which_alternative == 2)
1646 if (ISA_HAS_MADD_MSUB && which_alternative != 0)
1648 return madd[which_alternative];
1650 [(set_attr "type" "imadd,imadd,multi")
1651 (set_attr "mode" "SI")
1652 (set_attr "length" "4,4,8")])
1654 ;; Split the above insn if we failed to get LO allocated.
1656 [(set (match_operand:SI 0 "register_operand")
1657 (plus:SI (mult:SI (match_operand:SI 1 "register_operand")
1658 (match_operand:SI 2 "register_operand"))
1659 (match_operand:SI 3 "register_operand")))
1660 (clobber (match_scratch:SI 4))
1661 (clobber (match_scratch:SI 5))
1662 (clobber (match_scratch:SI 6))]
1663 "reload_completed && !TARGET_DEBUG_D_MODE
1664 && GP_REG_P (true_regnum (operands[0]))
1665 && GP_REG_P (true_regnum (operands[3]))"
1666 [(parallel [(set (match_dup 6)
1667 (mult:SI (match_dup 1) (match_dup 2)))
1668 (clobber (match_dup 4))
1669 (clobber (match_dup 5))])
1670 (set (match_dup 0) (plus:SI (match_dup 6) (match_dup 3)))]
1673 ;; Splitter to copy result of MADD to a general register
1675 [(set (match_operand:SI 0 "register_operand")
1676 (plus:SI (mult:SI (match_operand:SI 1 "register_operand")
1677 (match_operand:SI 2 "register_operand"))
1678 (match_operand:SI 3 "register_operand")))
1679 (clobber (match_scratch:SI 4))
1680 (clobber (match_scratch:SI 5))
1681 (clobber (match_scratch:SI 6))]
1682 "reload_completed && !TARGET_DEBUG_D_MODE
1683 && GP_REG_P (true_regnum (operands[0]))
1684 && true_regnum (operands[3]) == LO_REGNUM"
1685 [(parallel [(set (match_dup 3)
1686 (plus:SI (mult:SI (match_dup 1) (match_dup 2))
1688 (clobber (match_dup 4))
1689 (clobber (match_dup 5))
1690 (clobber (match_dup 6))])
1691 (set (match_dup 0) (unspec:SI [(match_dup 5) (match_dup 4)] UNSPEC_MFHILO))]
1694 (define_insn "*macc"
1695 [(set (match_operand:SI 0 "register_operand" "=l,d")
1696 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d")
1697 (match_operand:SI 2 "register_operand" "d,d"))
1698 (match_operand:SI 3 "register_operand" "0,l")))
1699 (clobber (match_scratch:SI 4 "=h,h"))
1700 (clobber (match_scratch:SI 5 "=X,3"))]
1703 if (which_alternative == 1)
1704 return "macc\t%0,%1,%2";
1705 else if (TARGET_MIPS5500)
1706 return "madd\t%1,%2";
1708 /* The VR4130 assumes that there is a two-cycle latency between a macc
1709 that "writes" to $0 and an instruction that reads from it. We avoid
1710 this by assigning to $1 instead. */
1711 return "%[macc\t%@,%1,%2%]";
1713 [(set_attr "type" "imadd")
1714 (set_attr "mode" "SI")])
1716 (define_insn "*msac"
1717 [(set (match_operand:SI 0 "register_operand" "=l,d")
1718 (minus:SI (match_operand:SI 1 "register_operand" "0,l")
1719 (mult:SI (match_operand:SI 2 "register_operand" "d,d")
1720 (match_operand:SI 3 "register_operand" "d,d"))))
1721 (clobber (match_scratch:SI 4 "=h,h"))
1722 (clobber (match_scratch:SI 5 "=X,1"))]
1725 if (which_alternative == 1)
1726 return "msac\t%0,%2,%3";
1727 else if (TARGET_MIPS5500)
1728 return "msub\t%2,%3";
1730 return "msac\t$0,%2,%3";
1732 [(set_attr "type" "imadd")
1733 (set_attr "mode" "SI")])
1735 ;; An msac-like instruction implemented using negation and a macc.
1736 (define_insn_and_split "*msac_using_macc"
1737 [(set (match_operand:SI 0 "register_operand" "=l,d")
1738 (minus:SI (match_operand:SI 1 "register_operand" "0,l")
1739 (mult:SI (match_operand:SI 2 "register_operand" "d,d")
1740 (match_operand:SI 3 "register_operand" "d,d"))))
1741 (clobber (match_scratch:SI 4 "=h,h"))
1742 (clobber (match_scratch:SI 5 "=X,1"))
1743 (clobber (match_scratch:SI 6 "=d,d"))]
1744 "ISA_HAS_MACC && !ISA_HAS_MSAC"
1746 "&& reload_completed"
1748 (neg:SI (match_dup 3)))
1751 (plus:SI (mult:SI (match_dup 2)
1754 (clobber (match_dup 4))
1755 (clobber (match_dup 5))])]
1757 [(set_attr "type" "imadd")
1758 (set_attr "length" "8")])
1760 ;; Patterns generated by the define_peephole2 below.
1762 (define_insn "*macc2"
1763 [(set (match_operand:SI 0 "register_operand" "=l")
1764 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d")
1765 (match_operand:SI 2 "register_operand" "d"))
1767 (set (match_operand:SI 3 "register_operand" "=d")
1768 (plus:SI (mult:SI (match_dup 1)
1771 (clobber (match_scratch:SI 4 "=h"))]
1772 "ISA_HAS_MACC && reload_completed"
1774 [(set_attr "type" "imadd")
1775 (set_attr "mode" "SI")])
1777 (define_insn "*msac2"
1778 [(set (match_operand:SI 0 "register_operand" "=l")
1779 (minus:SI (match_dup 0)
1780 (mult:SI (match_operand:SI 1 "register_operand" "d")
1781 (match_operand:SI 2 "register_operand" "d"))))
1782 (set (match_operand:SI 3 "register_operand" "=d")
1783 (minus:SI (match_dup 0)
1784 (mult:SI (match_dup 1)
1786 (clobber (match_scratch:SI 4 "=h"))]
1787 "ISA_HAS_MSAC && reload_completed"
1789 [(set_attr "type" "imadd")
1790 (set_attr "mode" "SI")])
1792 ;; Convert macc $0,<r1>,<r2> & mflo <r3> into macc <r3>,<r1>,<r2>
1796 ;; Operand 1: macc/msac
1798 ;; Operand 3: GPR (destination)
1801 [(set (match_operand:SI 0 "register_operand")
1802 (match_operand:SI 1 "macc_msac_operand"))
1803 (clobber (match_operand:SI 2 "register_operand"))
1804 (clobber (scratch:SI))])
1805 (set (match_operand:SI 3 "register_operand")
1806 (unspec:SI [(match_dup 0) (match_dup 2)] UNSPEC_MFHILO))]
1808 [(parallel [(set (match_dup 0)
1812 (clobber (match_dup 2))])]
1815 ;; When we have a three-address multiplication instruction, it should
1816 ;; be faster to do a separate multiply and add, rather than moving
1817 ;; something into LO in order to use a macc instruction.
1819 ;; This peephole needs a scratch register to cater for the case when one
1820 ;; of the multiplication operands is the same as the destination.
1822 ;; Operand 0: GPR (scratch)
1824 ;; Operand 2: GPR (addend)
1825 ;; Operand 3: GPR (destination)
1826 ;; Operand 4: macc/msac
1828 ;; Operand 6: new multiplication
1829 ;; Operand 7: new addition/subtraction
1831 [(match_scratch:SI 0 "d")
1832 (set (match_operand:SI 1 "register_operand")
1833 (match_operand:SI 2 "register_operand"))
1836 [(set (match_operand:SI 3 "register_operand")
1837 (match_operand:SI 4 "macc_msac_operand"))
1838 (clobber (match_operand:SI 5 "register_operand"))
1839 (clobber (match_dup 1))])]
1841 && true_regnum (operands[1]) == LO_REGNUM
1842 && peep2_reg_dead_p (2, operands[1])
1843 && GP_REG_P (true_regnum (operands[3]))"
1844 [(parallel [(set (match_dup 0)
1846 (clobber (match_dup 5))
1847 (clobber (match_dup 1))])
1851 operands[6] = XEXP (operands[4], GET_CODE (operands[4]) == PLUS ? 0 : 1);
1852 operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[4]), SImode,
1853 operands[2], operands[0]);
1856 ;; Same as above, except LO is the initial target of the macc.
1858 ;; Operand 0: GPR (scratch)
1860 ;; Operand 2: GPR (addend)
1861 ;; Operand 3: macc/msac
1863 ;; Operand 5: GPR (destination)
1864 ;; Operand 6: new multiplication
1865 ;; Operand 7: new addition/subtraction
1867 [(match_scratch:SI 0 "d")
1868 (set (match_operand:SI 1 "register_operand")
1869 (match_operand:SI 2 "register_operand"))
1873 (match_operand:SI 3 "macc_msac_operand"))
1874 (clobber (match_operand:SI 4 "register_operand"))
1875 (clobber (scratch:SI))])
1877 (set (match_operand:SI 5 "register_operand")
1878 (unspec:SI [(match_dup 1) (match_dup 4)] UNSPEC_MFHILO))]
1879 "GENERATE_MULT3_SI && peep2_reg_dead_p (3, operands[1])"
1880 [(parallel [(set (match_dup 0)
1882 (clobber (match_dup 4))
1883 (clobber (match_dup 1))])
1887 operands[6] = XEXP (operands[4], GET_CODE (operands[4]) == PLUS ? 0 : 1);
1888 operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[4]), SImode,
1889 operands[2], operands[0]);
1892 (define_insn "*mul_sub_si"
1893 [(set (match_operand:SI 0 "register_operand" "=l,*d,*d")
1894 (minus:SI (match_operand:SI 1 "register_operand" "0,l,*d")
1895 (mult:SI (match_operand:SI 2 "register_operand" "d,d,d")
1896 (match_operand:SI 3 "register_operand" "d,d,d"))))
1897 (clobber (match_scratch:SI 4 "=h,h,h"))
1898 (clobber (match_scratch:SI 5 "=X,1,l"))
1899 (clobber (match_scratch:SI 6 "=X,X,&d"))]
1905 [(set_attr "type" "imadd,multi,multi")
1906 (set_attr "mode" "SI")
1907 (set_attr "length" "4,8,8")])
1909 ;; Split the above insn if we failed to get LO allocated.
1911 [(set (match_operand:SI 0 "register_operand")
1912 (minus:SI (match_operand:SI 1 "register_operand")
1913 (mult:SI (match_operand:SI 2 "register_operand")
1914 (match_operand:SI 3 "register_operand"))))
1915 (clobber (match_scratch:SI 4))
1916 (clobber (match_scratch:SI 5))
1917 (clobber (match_scratch:SI 6))]
1918 "reload_completed && !TARGET_DEBUG_D_MODE
1919 && GP_REG_P (true_regnum (operands[0]))
1920 && GP_REG_P (true_regnum (operands[1]))"
1921 [(parallel [(set (match_dup 6)
1922 (mult:SI (match_dup 2) (match_dup 3)))
1923 (clobber (match_dup 4))
1924 (clobber (match_dup 5))])
1925 (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 6)))]
1928 ;; Splitter to copy result of MSUB to a general register
1930 [(set (match_operand:SI 0 "register_operand")
1931 (minus:SI (match_operand:SI 1 "register_operand")
1932 (mult:SI (match_operand:SI 2 "register_operand")
1933 (match_operand:SI 3 "register_operand"))))
1934 (clobber (match_scratch:SI 4))
1935 (clobber (match_scratch:SI 5))
1936 (clobber (match_scratch:SI 6))]
1937 "reload_completed && !TARGET_DEBUG_D_MODE
1938 && GP_REG_P (true_regnum (operands[0]))
1939 && true_regnum (operands[1]) == LO_REGNUM"
1940 [(parallel [(set (match_dup 1)
1941 (minus:SI (match_dup 1)
1942 (mult:SI (match_dup 2) (match_dup 3))))
1943 (clobber (match_dup 4))
1944 (clobber (match_dup 5))
1945 (clobber (match_dup 6))])
1946 (set (match_dup 0) (unspec:SI [(match_dup 5) (match_dup 4)] UNSPEC_MFHILO))]
1949 (define_insn "*muls"
1950 [(set (match_operand:SI 0 "register_operand" "=l,d")
1951 (neg:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d")
1952 (match_operand:SI 2 "register_operand" "d,d"))))
1953 (clobber (match_scratch:SI 3 "=h,h"))
1954 (clobber (match_scratch:SI 4 "=X,l"))]
1959 [(set_attr "type" "imul")
1960 (set_attr "mode" "SI")])
1962 (define_expand "muldi3"
1963 [(set (match_operand:DI 0 "register_operand")
1964 (mult:DI (match_operand:DI 1 "register_operand")
1965 (match_operand:DI 2 "register_operand")))]
1968 if (GENERATE_MULT3_DI)
1969 emit_insn (gen_muldi3_mult3 (operands[0], operands[1], operands[2]));
1970 else if (!TARGET_FIX_R4000)
1971 emit_insn (gen_muldi3_internal (operands[0], operands[1], operands[2]));
1973 emit_insn (gen_muldi3_r4000 (operands[0], operands[1], operands[2]));
1977 (define_insn "muldi3_mult3"
1978 [(set (match_operand:DI 0 "register_operand" "=d")
1979 (mult:DI (match_operand:DI 1 "register_operand" "d")
1980 (match_operand:DI 2 "register_operand" "d")))
1981 (clobber (match_scratch:DI 3 "=h"))
1982 (clobber (match_scratch:DI 4 "=l"))]
1983 "TARGET_64BIT && GENERATE_MULT3_DI"
1985 [(set_attr "type" "imul")
1986 (set_attr "mode" "DI")])
1988 (define_insn "muldi3_internal"
1989 [(set (match_operand:DI 0 "register_operand" "=l")
1990 (mult:DI (match_operand:DI 1 "register_operand" "d")
1991 (match_operand:DI 2 "register_operand" "d")))
1992 (clobber (match_scratch:DI 3 "=h"))]
1993 "TARGET_64BIT && !TARGET_FIX_R4000"
1995 [(set_attr "type" "imul")
1996 (set_attr "mode" "DI")])
1998 (define_insn "muldi3_r4000"
1999 [(set (match_operand:DI 0 "register_operand" "=d")
2000 (mult:DI (match_operand:DI 1 "register_operand" "d")
2001 (match_operand:DI 2 "register_operand" "d")))
2002 (clobber (match_scratch:DI 3 "=h"))
2003 (clobber (match_scratch:DI 4 "=l"))]
2004 "TARGET_64BIT && TARGET_FIX_R4000"
2005 "dmult\t%1,%2\;mflo\t%0"
2006 [(set_attr "type" "imul")
2007 (set_attr "mode" "DI")
2008 (set_attr "length" "8")])
2010 ;; ??? We could define a mulditi3 pattern when TARGET_64BIT.
2012 (define_expand "mulsidi3"
2014 [(set (match_operand:DI 0 "register_operand")
2016 (sign_extend:DI (match_operand:SI 1 "register_operand"))
2017 (sign_extend:DI (match_operand:SI 2 "register_operand"))))
2018 (clobber (scratch:DI))
2019 (clobber (scratch:DI))
2020 (clobber (scratch:DI))])]
2021 "!TARGET_64BIT || !TARGET_FIX_R4000"
2025 if (!TARGET_FIX_R4000)
2026 emit_insn (gen_mulsidi3_32bit_internal (operands[0], operands[1],
2029 emit_insn (gen_mulsidi3_32bit_r4000 (operands[0], operands[1],
2035 (define_insn "mulsidi3_32bit_internal"
2036 [(set (match_operand:DI 0 "register_operand" "=x")
2038 (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
2039 (sign_extend:DI (match_operand:SI 2 "register_operand" "d"))))]
2040 "!TARGET_64BIT && !TARGET_FIX_R4000"
2042 [(set_attr "type" "imul")
2043 (set_attr "mode" "SI")])
2045 (define_insn "mulsidi3_32bit_r4000"
2046 [(set (match_operand:DI 0 "register_operand" "=d")
2048 (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
2049 (sign_extend:DI (match_operand:SI 2 "register_operand" "d"))))
2050 (clobber (match_scratch:DI 3 "=l"))
2051 (clobber (match_scratch:DI 4 "=h"))]
2052 "!TARGET_64BIT && TARGET_FIX_R4000"
2053 "mult\t%1,%2\;mflo\t%L0;mfhi\t%M0"
2054 [(set_attr "type" "imul")
2055 (set_attr "mode" "SI")
2056 (set_attr "length" "12")])
2058 (define_insn_and_split "*mulsidi3_64bit"
2059 [(set (match_operand:DI 0 "register_operand" "=d")
2060 (mult:DI (match_operator:DI 1 "extend_operator"
2061 [(match_operand:SI 3 "register_operand" "d")])
2062 (match_operator:DI 2 "extend_operator"
2063 [(match_operand:SI 4 "register_operand" "d")])))
2064 (clobber (match_scratch:DI 5 "=l"))
2065 (clobber (match_scratch:DI 6 "=h"))
2066 (clobber (match_scratch:DI 7 "=d"))]
2067 "TARGET_64BIT && !TARGET_FIX_R4000
2068 && GET_CODE (operands[1]) == GET_CODE (operands[2])"
2070 "&& reload_completed"
2074 (mult:SI (match_dup 3)
2078 (mult:DI (match_dup 1)
2082 ;; OP7 <- LO, OP0 <- HI
2083 (set (match_dup 7) (unspec:DI [(match_dup 5) (match_dup 6)] UNSPEC_MFHILO))
2084 (set (match_dup 0) (unspec:DI [(match_dup 6) (match_dup 5)] UNSPEC_MFHILO))
2088 (ashift:DI (match_dup 7)
2091 (lshiftrt:DI (match_dup 7)
2094 ;; Shift OP0 into place.
2096 (ashift:DI (match_dup 0)
2099 ;; OR the two halves together
2101 (ior:DI (match_dup 0)
2104 [(set_attr "type" "imul")
2105 (set_attr "mode" "SI")
2106 (set_attr "length" "24")])
2108 (define_insn "*mulsidi3_64bit_parts"
2109 [(set (match_operand:DI 0 "register_operand" "=l")
2111 (mult:SI (match_operand:SI 2 "register_operand" "d")
2112 (match_operand:SI 3 "register_operand" "d"))))
2113 (set (match_operand:DI 1 "register_operand" "=h")
2116 (match_operator:DI 4 "extend_operator" [(match_dup 2)])
2117 (match_operator:DI 5 "extend_operator" [(match_dup 3)]))
2119 "TARGET_64BIT && !TARGET_FIX_R4000
2120 && GET_CODE (operands[4]) == GET_CODE (operands[5])"
2122 if (GET_CODE (operands[4]) == SIGN_EXTEND)
2123 return "mult\t%2,%3";
2125 return "multu\t%2,%3";
2127 [(set_attr "type" "imul")
2128 (set_attr "mode" "SI")])
2130 (define_expand "umulsidi3"
2132 [(set (match_operand:DI 0 "register_operand")
2134 (zero_extend:DI (match_operand:SI 1 "register_operand"))
2135 (zero_extend:DI (match_operand:SI 2 "register_operand"))))
2136 (clobber (scratch:DI))
2137 (clobber (scratch:DI))
2138 (clobber (scratch:DI))])]
2139 "!TARGET_64BIT || !TARGET_FIX_R4000"
2143 if (!TARGET_FIX_R4000)
2144 emit_insn (gen_umulsidi3_32bit_internal (operands[0], operands[1],
2147 emit_insn (gen_umulsidi3_32bit_r4000 (operands[0], operands[1],
2153 (define_insn "umulsidi3_32bit_internal"
2154 [(set (match_operand:DI 0 "register_operand" "=x")
2156 (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
2157 (zero_extend:DI (match_operand:SI 2 "register_operand" "d"))))]
2158 "!TARGET_64BIT && !TARGET_FIX_R4000"
2160 [(set_attr "type" "imul")
2161 (set_attr "mode" "SI")])
2163 (define_insn "umulsidi3_32bit_r4000"
2164 [(set (match_operand:DI 0 "register_operand" "=d")
2166 (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
2167 (zero_extend:DI (match_operand:SI 2 "register_operand" "d"))))
2168 (clobber (match_scratch:DI 3 "=l"))
2169 (clobber (match_scratch:DI 4 "=h"))]
2170 "!TARGET_64BIT && TARGET_FIX_R4000"
2171 "multu\t%1,%2\;mflo\t%L0;mfhi\t%M0"
2172 [(set_attr "type" "imul")
2173 (set_attr "mode" "SI")
2174 (set_attr "length" "12")])
2176 ;; Widening multiply with negation.
2177 (define_insn "*muls_di"
2178 [(set (match_operand:DI 0 "register_operand" "=x")
2181 (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
2182 (sign_extend:DI (match_operand:SI 2 "register_operand" "d")))))]
2183 "!TARGET_64BIT && ISA_HAS_MULS"
2185 [(set_attr "type" "imul")
2186 (set_attr "length" "4")
2187 (set_attr "mode" "SI")])
2189 (define_insn "*umuls_di"
2190 [(set (match_operand:DI 0 "register_operand" "=x")
2193 (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
2194 (zero_extend:DI (match_operand:SI 2 "register_operand" "d")))))]
2195 "!TARGET_64BIT && ISA_HAS_MULS"
2197 [(set_attr "type" "imul")
2198 (set_attr "length" "4")
2199 (set_attr "mode" "SI")])
2201 (define_insn "*smsac_di"
2202 [(set (match_operand:DI 0 "register_operand" "=x")
2204 (match_operand:DI 3 "register_operand" "0")
2206 (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
2207 (sign_extend:DI (match_operand:SI 2 "register_operand" "d")))))]
2208 "!TARGET_64BIT && ISA_HAS_MSAC"
2210 if (TARGET_MIPS5500)
2211 return "msub\t%1,%2";
2213 return "msac\t$0,%1,%2";
2215 [(set_attr "type" "imadd")
2216 (set_attr "length" "4")
2217 (set_attr "mode" "SI")])
2219 (define_insn "*umsac_di"
2220 [(set (match_operand:DI 0 "register_operand" "=x")
2222 (match_operand:DI 3 "register_operand" "0")
2224 (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
2225 (zero_extend:DI (match_operand:SI 2 "register_operand" "d")))))]
2226 "!TARGET_64BIT && ISA_HAS_MSAC"
2228 if (TARGET_MIPS5500)
2229 return "msubu\t%1,%2";
2231 return "msacu\t$0,%1,%2";
2233 [(set_attr "type" "imadd")
2234 (set_attr "length" "4")
2235 (set_attr "mode" "SI")])
2237 ;; _highpart patterns
2238 (define_expand "umulsi3_highpart"
2239 [(set (match_operand:SI 0 "register_operand")
2242 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand"))
2243 (zero_extend:DI (match_operand:SI 2 "register_operand")))
2245 "ISA_HAS_MULHI || !TARGET_FIX_R4000"
2248 emit_insn (gen_umulsi3_highpart_mulhi_internal (operands[0], operands[1],
2251 emit_insn (gen_umulsi3_highpart_internal (operands[0], operands[1],
2256 (define_insn "umulsi3_highpart_internal"
2257 [(set (match_operand:SI 0 "register_operand" "=h")
2260 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
2261 (zero_extend:DI (match_operand:SI 2 "register_operand" "d")))
2263 (clobber (match_scratch:SI 3 "=l"))]
2264 "!ISA_HAS_MULHI && !TARGET_FIX_R4000"
2266 [(set_attr "type" "imul")
2267 (set_attr "mode" "SI")
2268 (set_attr "length" "4")])
2270 (define_insn "umulsi3_highpart_mulhi_internal"
2271 [(set (match_operand:SI 0 "register_operand" "=h,d")
2274 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "d,d"))
2275 (zero_extend:DI (match_operand:SI 2 "register_operand" "d,d")))
2277 (clobber (match_scratch:SI 3 "=l,l"))
2278 (clobber (match_scratch:SI 4 "=X,h"))]
2283 [(set_attr "type" "imul")
2284 (set_attr "mode" "SI")
2285 (set_attr "length" "4")])
2287 (define_insn "umulsi3_highpart_neg_mulhi_internal"
2288 [(set (match_operand:SI 0 "register_operand" "=h,d")
2292 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "d,d"))
2293 (zero_extend:DI (match_operand:SI 2 "register_operand" "d,d"))))
2295 (clobber (match_scratch:SI 3 "=l,l"))
2296 (clobber (match_scratch:SI 4 "=X,h"))]
2301 [(set_attr "type" "imul")
2302 (set_attr "mode" "SI")
2303 (set_attr "length" "4")])
2305 (define_expand "smulsi3_highpart"
2306 [(set (match_operand:SI 0 "register_operand")
2309 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand"))
2310 (sign_extend:DI (match_operand:SI 2 "register_operand")))
2312 "ISA_HAS_MULHI || !TARGET_FIX_R4000"
2315 emit_insn (gen_smulsi3_highpart_mulhi_internal (operands[0], operands[1],
2318 emit_insn (gen_smulsi3_highpart_internal (operands[0], operands[1],
2323 (define_insn "smulsi3_highpart_internal"
2324 [(set (match_operand:SI 0 "register_operand" "=h")
2327 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
2328 (sign_extend:DI (match_operand:SI 2 "register_operand" "d")))
2330 (clobber (match_scratch:SI 3 "=l"))]
2331 "!ISA_HAS_MULHI && !TARGET_FIX_R4000"
2333 [(set_attr "type" "imul")
2334 (set_attr "mode" "SI")
2335 (set_attr "length" "4")])
2337 (define_insn "smulsi3_highpart_mulhi_internal"
2338 [(set (match_operand:SI 0 "register_operand" "=h,d")
2341 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d,d"))
2342 (sign_extend:DI (match_operand:SI 2 "register_operand" "d,d")))
2344 (clobber (match_scratch:SI 3 "=l,l"))
2345 (clobber (match_scratch:SI 4 "=X,h"))]
2350 [(set_attr "type" "imul")
2351 (set_attr "mode" "SI")
2352 (set_attr "length" "4")])
2354 (define_insn "smulsi3_highpart_neg_mulhi_internal"
2355 [(set (match_operand:SI 0 "register_operand" "=h,d")
2359 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d,d"))
2360 (sign_extend:DI (match_operand:SI 2 "register_operand" "d,d"))))
2362 (clobber (match_scratch:SI 3 "=l,l"))
2363 (clobber (match_scratch:SI 4 "=X,h"))]
2368 [(set_attr "type" "imul")
2369 (set_attr "mode" "SI")])
2371 (define_insn "smuldi3_highpart"
2372 [(set (match_operand:DI 0 "register_operand" "=h")
2376 (sign_extend:TI (match_operand:DI 1 "register_operand" "d"))
2377 (sign_extend:TI (match_operand:DI 2 "register_operand" "d")))
2379 (clobber (match_scratch:DI 3 "=l"))]
2380 "TARGET_64BIT && !TARGET_FIX_R4000"
2382 [(set_attr "type" "imul")
2383 (set_attr "mode" "DI")])
2385 ;; Disable this pattern for -mfix-vr4120. This is for VR4120 errata MD(0),
2386 ;; which says that dmultu does not always produce the correct result.
2387 (define_insn "umuldi3_highpart"
2388 [(set (match_operand:DI 0 "register_operand" "=h")
2392 (zero_extend:TI (match_operand:DI 1 "register_operand" "d"))
2393 (zero_extend:TI (match_operand:DI 2 "register_operand" "d")))
2395 (clobber (match_scratch:DI 3 "=l"))]
2396 "TARGET_64BIT && !TARGET_FIX_R4000 && !TARGET_FIX_VR4120"
2398 [(set_attr "type" "imul")
2399 (set_attr "mode" "DI")])
2402 ;; The R4650 supports a 32 bit multiply/ 64 bit accumulate
2403 ;; instruction. The HI/LO registers are used as a 64 bit accumulator.
2405 (define_insn "madsi"
2406 [(set (match_operand:SI 0 "register_operand" "+l")
2407 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d")
2408 (match_operand:SI 2 "register_operand" "d"))
2410 (clobber (match_scratch:SI 3 "=h"))]
2413 [(set_attr "type" "imadd")
2414 (set_attr "mode" "SI")])
2416 (define_insn "*umul_acc_di"
2417 [(set (match_operand:DI 0 "register_operand" "=x")
2419 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
2420 (zero_extend:DI (match_operand:SI 2 "register_operand" "d")))
2421 (match_operand:DI 3 "register_operand" "0")))]
2422 "(TARGET_MAD || ISA_HAS_MACC)
2426 return "madu\t%1,%2";
2427 else if (TARGET_MIPS5500)
2428 return "maddu\t%1,%2";
2430 /* See comment in *macc. */
2431 return "%[maccu\t%@,%1,%2%]";
2433 [(set_attr "type" "imadd")
2434 (set_attr "mode" "SI")])
2437 (define_insn "*smul_acc_di"
2438 [(set (match_operand:DI 0 "register_operand" "=x")
2440 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
2441 (sign_extend:DI (match_operand:SI 2 "register_operand" "d")))
2442 (match_operand:DI 3 "register_operand" "0")))]
2443 "(TARGET_MAD || ISA_HAS_MACC)
2447 return "mad\t%1,%2";
2448 else if (TARGET_MIPS5500)
2449 return "madd\t%1,%2";
2451 /* See comment in *macc. */
2452 return "%[macc\t%@,%1,%2%]";
2454 [(set_attr "type" "imadd")
2455 (set_attr "mode" "SI")])
2457 ;; Floating point multiply accumulate instructions.
2460 [(set (match_operand:DF 0 "register_operand" "=f")
2461 (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
2462 (match_operand:DF 2 "register_operand" "f"))
2463 (match_operand:DF 3 "register_operand" "f")))]
2464 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FUSED_MADD"
2465 "madd.d\t%0,%3,%1,%2"
2466 [(set_attr "type" "fmadd")
2467 (set_attr "mode" "DF")])
2470 [(set (match_operand:SF 0 "register_operand" "=f")
2471 (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
2472 (match_operand:SF 2 "register_operand" "f"))
2473 (match_operand:SF 3 "register_operand" "f")))]
2474 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
2475 "madd.s\t%0,%3,%1,%2"
2476 [(set_attr "type" "fmadd")
2477 (set_attr "mode" "SF")])
2480 [(set (match_operand:DF 0 "register_operand" "=f")
2481 (minus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
2482 (match_operand:DF 2 "register_operand" "f"))
2483 (match_operand:DF 3 "register_operand" "f")))]
2484 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FUSED_MADD"
2485 "msub.d\t%0,%3,%1,%2"
2486 [(set_attr "type" "fmadd")
2487 (set_attr "mode" "DF")])
2490 [(set (match_operand:SF 0 "register_operand" "=f")
2491 (minus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
2492 (match_operand:SF 2 "register_operand" "f"))
2493 (match_operand:SF 3 "register_operand" "f")))]
2495 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
2496 "msub.s\t%0,%3,%1,%2"
2497 [(set_attr "type" "fmadd")
2498 (set_attr "mode" "SF")])
2501 [(set (match_operand:DF 0 "register_operand" "=f")
2502 (neg:DF (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
2503 (match_operand:DF 2 "register_operand" "f"))
2504 (match_operand:DF 3 "register_operand" "f"))))]
2505 "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FUSED_MADD"
2506 "nmadd.d\t%0,%3,%1,%2"
2507 [(set_attr "type" "fmadd")
2508 (set_attr "mode" "DF")])
2511 [(set (match_operand:SF 0 "register_operand" "=f")
2512 (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
2513 (match_operand:SF 2 "register_operand" "f"))
2514 (match_operand:SF 3 "register_operand" "f"))))]
2515 "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
2516 "nmadd.s\t%0,%3,%1,%2"
2517 [(set_attr "type" "fmadd")
2518 (set_attr "mode" "SF")])
2521 [(set (match_operand:DF 0 "register_operand" "=f")
2522 (minus:DF (match_operand:DF 1 "register_operand" "f")
2523 (mult:DF (match_operand:DF 2 "register_operand" "f")
2524 (match_operand:DF 3 "register_operand" "f"))))]
2525 "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FUSED_MADD"
2526 "nmsub.d\t%0,%1,%2,%3"
2527 [(set_attr "type" "fmadd")
2528 (set_attr "mode" "DF")])
2531 [(set (match_operand:SF 0 "register_operand" "=f")
2532 (minus:SF (match_operand:SF 1 "register_operand" "f")
2533 (mult:SF (match_operand:SF 2 "register_operand" "f")
2534 (match_operand:SF 3 "register_operand" "f"))))]
2535 "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
2536 "nmsub.s\t%0,%1,%2,%3"
2537 [(set_attr "type" "fmadd")
2538 (set_attr "mode" "SF")])
2541 ;; ....................
2543 ;; DIVISION and REMAINDER
2545 ;; ....................
2548 (define_expand "divdf3"
2549 [(set (match_operand:DF 0 "register_operand")
2550 (div:DF (match_operand:DF 1 "reg_or_const_float_1_operand")
2551 (match_operand:DF 2 "register_operand")))]
2552 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2554 if (const_float_1_operand (operands[1], DFmode))
2555 if (!(ISA_HAS_FP4 && flag_unsafe_math_optimizations))
2559 ;; This pattern works around the early SB-1 rev2 core "F1" erratum:
2561 ;; If an mfc1 or dmfc1 happens to access the floating point register
2562 ;; file at the same time a long latency operation (div, sqrt, recip,
2563 ;; sqrt) iterates an intermediate result back through the floating
2564 ;; point register file bypass, then instead returning the correct
2565 ;; register value the mfc1 or dmfc1 operation returns the intermediate
2566 ;; result of the long latency operation.
2568 ;; The workaround is to insert an unconditional 'mov' from/to the
2569 ;; long latency op destination register.
2571 (define_insn "*divdf3"
2572 [(set (match_operand:DF 0 "register_operand" "=f")
2573 (div:DF (match_operand:DF 1 "register_operand" "f")
2574 (match_operand:DF 2 "register_operand" "f")))]
2575 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2578 return "div.d\t%0,%1,%2\;mov.d\t%0,%0";
2580 return "div.d\t%0,%1,%2";
2582 [(set_attr "type" "fdiv")
2583 (set_attr "mode" "DF")
2584 (set (attr "length")
2585 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
2590 ;; This pattern works around the early SB-1 rev2 core "F2" erratum:
2592 ;; In certain cases, div.s and div.ps may have a rounding error
2593 ;; and/or wrong inexact flag.
2595 ;; Therefore, we only allow div.s if not working around SB-1 rev2
2596 ;; errata, or if working around those errata and a slight loss of
2597 ;; precision is OK (i.e., flag_unsafe_math_optimizations is set).
2598 (define_expand "divsf3"
2599 [(set (match_operand:SF 0 "register_operand")
2600 (div:SF (match_operand:SF 1 "reg_or_const_float_1_operand")
2601 (match_operand:SF 2 "register_operand")))]
2602 "TARGET_HARD_FLOAT && (!TARGET_FIX_SB1 || flag_unsafe_math_optimizations)"
2604 if (const_float_1_operand (operands[1], SFmode))
2605 if (!(ISA_HAS_FP4 && flag_unsafe_math_optimizations))
2609 ;; This pattern works around the early SB-1 rev2 core "F1" erratum (see
2610 ;; "divdf3" comment for details).
2612 ;; This pattern works around the early SB-1 rev2 core "F2" erratum (see
2613 ;; "divsf3" comment for details).
2614 (define_insn "*divsf3"
2615 [(set (match_operand:SF 0 "register_operand" "=f")
2616 (div:SF (match_operand:SF 1 "register_operand" "f")
2617 (match_operand:SF 2 "register_operand" "f")))]
2618 "TARGET_HARD_FLOAT && (!TARGET_FIX_SB1 || flag_unsafe_math_optimizations)"
2621 return "div.s\t%0,%1,%2\;mov.s\t%0,%0";
2623 return "div.s\t%0,%1,%2";
2625 [(set_attr "type" "fdiv")
2626 (set_attr "mode" "SF")
2627 (set (attr "length")
2628 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
2632 ;; This pattern works around the early SB-1 rev2 core "F1" erratum (see
2633 ;; "divdf3" comment for details).
2635 [(set (match_operand:DF 0 "register_operand" "=f")
2636 (div:DF (match_operand:DF 1 "const_float_1_operand" "")
2637 (match_operand:DF 2 "register_operand" "f")))]
2638 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && flag_unsafe_math_optimizations"
2641 return "recip.d\t%0,%2\;mov.d\t%0,%0";
2643 return "recip.d\t%0,%2";
2645 [(set_attr "type" "fdiv")
2646 (set_attr "mode" "DF")
2647 (set (attr "length")
2648 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
2652 ;; This pattern works around the early SB-1 rev2 core "F1" erratum (see
2653 ;; "divdf3" comment for details).
2655 [(set (match_operand:SF 0 "register_operand" "=f")
2656 (div:SF (match_operand:SF 1 "const_float_1_operand" "")
2657 (match_operand:SF 2 "register_operand" "f")))]
2658 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && flag_unsafe_math_optimizations"
2661 return "recip.s\t%0,%2\;mov.s\t%0,%0";
2663 return "recip.s\t%0,%2";
2665 [(set_attr "type" "fdiv")
2666 (set_attr "mode" "SF")
2667 (set (attr "length")
2668 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
2672 ;; VR4120 errata MD(A1): signed division instructions do not work correctly
2673 ;; with negative operands. We use special libgcc functions instead.
2674 (define_insn "divmodsi4"
2675 [(set (match_operand:SI 0 "register_operand" "=l")
2676 (div:SI (match_operand:SI 1 "register_operand" "d")
2677 (match_operand:SI 2 "register_operand" "d")))
2678 (set (match_operand:SI 3 "register_operand" "=h")
2679 (mod:SI (match_dup 1)
2681 "!TARGET_FIX_VR4120"
2682 { return mips_output_division ("div\t$0,%1,%2", operands); }
2683 [(set_attr "type" "idiv")
2684 (set_attr "mode" "SI")])
2686 (define_insn "divmoddi4"
2687 [(set (match_operand:DI 0 "register_operand" "=l")
2688 (div:DI (match_operand:DI 1 "register_operand" "d")
2689 (match_operand:DI 2 "register_operand" "d")))
2690 (set (match_operand:DI 3 "register_operand" "=h")
2691 (mod:DI (match_dup 1)
2693 "TARGET_64BIT && !TARGET_FIX_VR4120"
2694 { return mips_output_division ("ddiv\t$0,%1,%2", operands); }
2695 [(set_attr "type" "idiv")
2696 (set_attr "mode" "DI")])
2698 (define_insn "udivmodsi4"
2699 [(set (match_operand:SI 0 "register_operand" "=l")
2700 (udiv:SI (match_operand:SI 1 "register_operand" "d")
2701 (match_operand:SI 2 "register_operand" "d")))
2702 (set (match_operand:SI 3 "register_operand" "=h")
2703 (umod:SI (match_dup 1)
2706 { return mips_output_division ("divu\t$0,%1,%2", operands); }
2707 [(set_attr "type" "idiv")
2708 (set_attr "mode" "SI")])
2710 (define_insn "udivmoddi4"
2711 [(set (match_operand:DI 0 "register_operand" "=l")
2712 (udiv:DI (match_operand:DI 1 "register_operand" "d")
2713 (match_operand:DI 2 "register_operand" "d")))
2714 (set (match_operand:DI 3 "register_operand" "=h")
2715 (umod:DI (match_dup 1)
2718 { return mips_output_division ("ddivu\t$0,%1,%2", operands); }
2719 [(set_attr "type" "idiv")
2720 (set_attr "mode" "DI")])
2723 ;; ....................
2727 ;; ....................
2729 ;; This pattern works around the early SB-1 rev2 core "F1" erratum (see
2730 ;; "divdf3" comment for details).
2731 (define_insn "sqrtdf2"
2732 [(set (match_operand:DF 0 "register_operand" "=f")
2733 (sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
2734 "TARGET_HARD_FLOAT && HAVE_SQRT_P() && TARGET_DOUBLE_FLOAT"
2737 return "sqrt.d\t%0,%1\;mov.d\t%0,%0";
2739 return "sqrt.d\t%0,%1";
2741 [(set_attr "type" "fsqrt")
2742 (set_attr "mode" "DF")
2743 (set (attr "length")
2744 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
2748 ;; This pattern works around the early SB-1 rev2 core "F1" erratum (see
2749 ;; "divdf3" comment for details).
2750 (define_insn "sqrtsf2"
2751 [(set (match_operand:SF 0 "register_operand" "=f")
2752 (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
2753 "TARGET_HARD_FLOAT && HAVE_SQRT_P()"
2756 return "sqrt.s\t%0,%1\;mov.s\t%0,%0";
2758 return "sqrt.s\t%0,%1";
2760 [(set_attr "type" "fsqrt")
2761 (set_attr "mode" "SF")
2762 (set (attr "length")
2763 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
2767 ;; This pattern works around the early SB-1 rev2 core "F1" erratum (see
2768 ;; "divdf3" comment for details).
2770 [(set (match_operand:DF 0 "register_operand" "=f")
2771 (div:DF (match_operand:DF 1 "const_float_1_operand" "")
2772 (sqrt:DF (match_operand:DF 2 "register_operand" "f"))))]
2773 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && flag_unsafe_math_optimizations"
2776 return "rsqrt.d\t%0,%2\;mov.d\t%0,%0";
2778 return "rsqrt.d\t%0,%2";
2780 [(set_attr "type" "frsqrt")
2781 (set_attr "mode" "DF")
2782 (set (attr "length")
2783 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
2787 ;; This pattern works around the early SB-1 rev2 core "F1" erratum (see
2788 ;; "divdf3" comment for details).
2790 [(set (match_operand:SF 0 "register_operand" "=f")
2791 (div:SF (match_operand:SF 1 "const_float_1_operand" "")
2792 (sqrt:SF (match_operand:SF 2 "register_operand" "f"))))]
2793 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && flag_unsafe_math_optimizations"
2796 return "rsqrt.s\t%0,%2\;mov.s\t%0,%0";
2798 return "rsqrt.s\t%0,%2";
2800 [(set_attr "type" "frsqrt")
2801 (set_attr "mode" "SF")
2802 (set (attr "length")
2803 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
2808 ;; ....................
2812 ;; ....................
2814 ;; Do not use the integer abs macro instruction, since that signals an
2815 ;; exception on -2147483648 (sigh).
2817 (define_insn "abssi2"
2818 [(set (match_operand:SI 0 "register_operand" "=d")
2819 (abs:SI (match_operand:SI 1 "register_operand" "d")))]
2822 operands[2] = const0_rtx;
2824 if (REGNO (operands[0]) == REGNO (operands[1]))
2826 if (GENERATE_BRANCHLIKELY)
2827 return "%(bltzl\t%1,1f\;subu\t%0,%z2,%0\n%~1:%)";
2829 return "bgez\t%1,1f%#\;subu\t%0,%z2,%0\n%~1:";
2832 return "%(bgez\t%1,1f\;move\t%0,%1\;subu\t%0,%z2,%0\n%~1:%)";
2834 [(set_attr "type" "multi")
2835 (set_attr "mode" "SI")
2836 (set_attr "length" "12")])
2838 (define_insn "absdi2"
2839 [(set (match_operand:DI 0 "register_operand" "=d")
2840 (abs:DI (match_operand:DI 1 "register_operand" "d")))]
2841 "TARGET_64BIT && !TARGET_MIPS16"
2843 unsigned int regno1;
2844 operands[2] = const0_rtx;
2846 if (GET_CODE (operands[1]) == REG)
2847 regno1 = REGNO (operands[1]);
2849 regno1 = REGNO (XEXP (operands[1], 0));
2851 if (REGNO (operands[0]) == regno1)
2852 return "%(bltzl\t%1,1f\;dsubu\t%0,%z2,%0\n%~1:%)";
2854 return "%(bgez\t%1,1f\;move\t%0,%1\;dsubu\t%0,%z2,%0\n%~1:%)";
2856 [(set_attr "type" "multi")
2857 (set_attr "mode" "DI")
2858 (set_attr "length" "12")])
2860 (define_insn "absdf2"
2861 [(set (match_operand:DF 0 "register_operand" "=f")
2862 (abs:DF (match_operand:DF 1 "register_operand" "f")))]
2863 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2865 [(set_attr "type" "fabs")
2866 (set_attr "mode" "DF")])
2868 (define_insn "abssf2"
2869 [(set (match_operand:SF 0 "register_operand" "=f")
2870 (abs:SF (match_operand:SF 1 "register_operand" "f")))]
2873 [(set_attr "type" "fabs")
2874 (set_attr "mode" "SF")])
2877 ;; ....................
2879 ;; FIND FIRST BIT INSTRUCTION
2881 ;; ....................
2884 (define_insn "ffssi2"
2885 [(set (match_operand:SI 0 "register_operand" "=&d")
2886 (ffs:SI (match_operand:SI 1 "register_operand" "d")))
2887 (clobber (match_scratch:SI 2 "=&d"))
2888 (clobber (match_scratch:SI 3 "=&d"))]
2891 if (optimize && find_reg_note (insn, REG_DEAD, operands[1]))
2895 %~1:\tand\t%2,%1,0x0001\;\
2905 %~1:\tand\t%2,%3,0x0001\;\
2911 [(set_attr "type" "multi")
2912 (set_attr "mode" "SI")
2913 (set_attr "length" "28")])
2915 (define_insn "ffsdi2"
2916 [(set (match_operand:DI 0 "register_operand" "=&d")
2917 (ffs:DI (match_operand:DI 1 "register_operand" "d")))
2918 (clobber (match_scratch:DI 2 "=&d"))
2919 (clobber (match_scratch:DI 3 "=&d"))]
2920 "TARGET_64BIT && !TARGET_MIPS16"
2922 if (optimize && find_reg_note (insn, REG_DEAD, operands[1]))
2926 %~1:\tand\t%2,%1,0x0001\;\
2936 %~1:\tand\t%2,%3,0x0001\;\
2942 [(set_attr "type" "multi")
2943 (set_attr "mode" "DI")
2944 (set_attr "length" "28")])
2947 ;; ...................
2949 ;; Count leading zeroes.
2951 ;; ...................
2954 (define_insn "clzsi2"
2955 [(set (match_operand:SI 0 "register_operand" "=d")
2956 (clz:SI (match_operand:SI 1 "register_operand" "d")))]
2959 [(set_attr "type" "clz")
2960 (set_attr "mode" "SI")])
2962 (define_insn "clzdi2"
2963 [(set (match_operand:DI 0 "register_operand" "=d")
2964 (clz:DI (match_operand:DI 1 "register_operand" "d")))]
2967 [(set_attr "type" "clz")
2968 (set_attr "mode" "DI")])
2971 ;; ....................
2973 ;; NEGATION and ONE'S COMPLEMENT
2975 ;; ....................
2977 (define_insn "negsi2"
2978 [(set (match_operand:SI 0 "register_operand" "=d")
2979 (neg:SI (match_operand:SI 1 "register_operand" "d")))]
2983 return "neg\t%0,%1";
2985 return "subu\t%0,%.,%1";
2987 [(set_attr "type" "arith")
2988 (set_attr "mode" "SI")])
2990 (define_expand "negdi2"
2991 [(parallel [(set (match_operand:DI 0 "register_operand")
2992 (neg:DI (match_operand:DI 1 "register_operand")))
2993 (clobber (match_dup 2))])]
2994 "(TARGET_64BIT || !TARGET_DEBUG_G_MODE) && !TARGET_MIPS16"
2998 emit_insn (gen_negdi2_internal_2 (operands[0], operands[1]));
3002 operands[2] = gen_reg_rtx (SImode);
3005 (define_insn "negdi2_internal"
3006 [(set (match_operand:DI 0 "register_operand" "=d")
3007 (neg:DI (match_operand:DI 1 "register_operand" "d")))
3008 (clobber (match_operand:SI 2 "register_operand" "=d"))]
3009 "! TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16"
3010 "subu\t%L0,%.,%L1\;subu\t%M0,%.,%M1\;sltu\t%2,%.,%L0\;subu\t%M0,%M0,%2"
3011 [(set_attr "type" "multi")
3012 (set_attr "mode" "DI")
3013 (set_attr "length" "16")])
3015 (define_insn "negdi2_internal_2"
3016 [(set (match_operand:DI 0 "register_operand" "=d")
3017 (neg:DI (match_operand:DI 1 "register_operand" "d")))]
3018 "TARGET_64BIT && !TARGET_MIPS16"
3020 [(set_attr "type" "arith")
3021 (set_attr "mode" "DI")])
3023 (define_insn "negdf2"
3024 [(set (match_operand:DF 0 "register_operand" "=f")
3025 (neg:DF (match_operand:DF 1 "register_operand" "f")))]
3026 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
3028 [(set_attr "type" "fneg")
3029 (set_attr "mode" "DF")])
3031 (define_insn "negsf2"
3032 [(set (match_operand:SF 0 "register_operand" "=f")
3033 (neg:SF (match_operand:SF 1 "register_operand" "f")))]
3036 [(set_attr "type" "fneg")
3037 (set_attr "mode" "SF")])
3039 (define_insn "one_cmplsi2"
3040 [(set (match_operand:SI 0 "register_operand" "=d")
3041 (not:SI (match_operand:SI 1 "register_operand" "d")))]
3045 return "not\t%0,%1";
3047 return "nor\t%0,%.,%1";
3049 [(set_attr "type" "arith")
3050 (set_attr "mode" "SI")])
3052 (define_insn "one_cmpldi2"
3053 [(set (match_operand:DI 0 "register_operand" "=d")
3054 (not:DI (match_operand:DI 1 "register_operand" "d")))]
3058 return "not\t%0,%1";
3060 return "nor\t%0,%.,%1";
3062 [(set_attr "type" "arith")
3063 (set_attr "mode" "DI")])
3066 ;; ....................
3070 ;; ....................
3073 ;; Many of these instructions use trivial define_expands, because we
3074 ;; want to use a different set of constraints when TARGET_MIPS16.
3076 (define_expand "andsi3"
3077 [(set (match_operand:SI 0 "register_operand")
3078 (and:SI (match_operand:SI 1 "uns_arith_operand")
3079 (match_operand:SI 2 "uns_arith_operand")))]
3084 operands[1] = force_reg (SImode, operands[1]);
3085 operands[2] = force_reg (SImode, operands[2]);
3090 [(set (match_operand:SI 0 "register_operand" "=d,d")
3091 (and:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
3092 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
3097 [(set_attr "type" "arith")
3098 (set_attr "mode" "SI")])
3101 [(set (match_operand:SI 0 "register_operand" "=d")
3102 (and:SI (match_operand:SI 1 "register_operand" "%0")
3103 (match_operand:SI 2 "register_operand" "d")))]
3106 [(set_attr "type" "arith")
3107 (set_attr "mode" "SI")])
3109 (define_expand "anddi3"
3110 [(set (match_operand:DI 0 "register_operand")
3111 (and:DI (match_operand:DI 1 "register_operand")
3112 (match_operand:DI 2 "uns_arith_operand")))]
3117 operands[1] = force_reg (DImode, operands[1]);
3118 operands[2] = force_reg (DImode, operands[2]);
3123 [(set (match_operand:DI 0 "register_operand" "=d,d")
3124 (and:DI (match_operand:DI 1 "register_operand" "d,d")
3125 (match_operand:DI 2 "uns_arith_operand" "d,K")))]
3126 "TARGET_64BIT && !TARGET_MIPS16"
3130 [(set_attr "type" "arith")
3131 (set_attr "mode" "DI")])
3134 [(set (match_operand:DI 0 "register_operand" "=d")
3135 (and:DI (match_operand:DI 1 "register_operand" "0")
3136 (match_operand:DI 2 "register_operand" "d")))]
3137 "TARGET_64BIT && TARGET_MIPS16"
3139 [(set_attr "type" "arith")
3140 (set_attr "mode" "DI")])
3142 (define_expand "iorsi3"
3143 [(set (match_operand:SI 0 "register_operand")
3144 (ior:SI (match_operand:SI 1 "uns_arith_operand")
3145 (match_operand:SI 2 "uns_arith_operand")))]
3150 operands[1] = force_reg (SImode, operands[1]);
3151 operands[2] = force_reg (SImode, operands[2]);
3156 [(set (match_operand:SI 0 "register_operand" "=d,d")
3157 (ior:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
3158 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
3163 [(set_attr "type" "arith")
3164 (set_attr "mode" "SI")])
3167 [(set (match_operand:SI 0 "register_operand" "=d")
3168 (ior:SI (match_operand:SI 1 "register_operand" "%0")
3169 (match_operand:SI 2 "register_operand" "d")))]
3172 [(set_attr "type" "arith")
3173 (set_attr "mode" "SI")])
3175 (define_expand "iordi3"
3176 [(set (match_operand:DI 0 "register_operand")
3177 (ior:DI (match_operand:DI 1 "register_operand")
3178 (match_operand:DI 2 "uns_arith_operand")))]
3183 operands[1] = force_reg (DImode, operands[1]);
3184 operands[2] = force_reg (DImode, operands[2]);
3189 [(set (match_operand:DI 0 "register_operand" "=d,d")
3190 (ior:DI (match_operand:DI 1 "register_operand" "d,d")
3191 (match_operand:DI 2 "uns_arith_operand" "d,K")))]
3192 "TARGET_64BIT && !TARGET_MIPS16"
3196 [(set_attr "type" "arith")
3197 (set_attr "mode" "DI")])
3200 [(set (match_operand:DI 0 "register_operand" "=d")
3201 (ior:DI (match_operand:DI 1 "register_operand" "0")
3202 (match_operand:DI 2 "register_operand" "d")))]
3203 "TARGET_64BIT && TARGET_MIPS16"
3205 [(set_attr "type" "arith")
3206 (set_attr "mode" "DI")])
3208 (define_expand "xorsi3"
3209 [(set (match_operand:SI 0 "register_operand")
3210 (xor:SI (match_operand:SI 1 "uns_arith_operand")
3211 (match_operand:SI 2 "uns_arith_operand")))]
3216 [(set (match_operand:SI 0 "register_operand" "=d,d")
3217 (xor:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
3218 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
3223 [(set_attr "type" "arith")
3224 (set_attr "mode" "SI")])
3227 [(set (match_operand:SI 0 "register_operand" "=d,t,t")
3228 (xor:SI (match_operand:SI 1 "uns_arith_operand" "%0,d,d")
3229 (match_operand:SI 2 "uns_arith_operand" "d,K,d")))]
3235 [(set_attr "type" "arith")
3236 (set_attr "mode" "SI")
3237 (set_attr_alternative "length"
3239 (if_then_else (match_operand:VOID 2 "m16_uimm8_1")
3244 (define_expand "xordi3"
3245 [(set (match_operand:DI 0 "register_operand")
3246 (xor:DI (match_operand:DI 1 "register_operand")
3247 (match_operand:DI 2 "uns_arith_operand")))]
3252 operands[1] = force_reg (DImode, operands[1]);
3253 operands[2] = force_reg (DImode, operands[2]);
3258 [(set (match_operand:DI 0 "register_operand" "=d,d")
3259 (xor:DI (match_operand:DI 1 "register_operand" "d,d")
3260 (match_operand:DI 2 "uns_arith_operand" "d,K")))]
3261 "TARGET_64BIT && !TARGET_MIPS16"
3265 [(set_attr "type" "arith")
3266 (set_attr "mode" "DI")])
3269 [(set (match_operand:DI 0 "register_operand" "=d,t,t")
3270 (xor:DI (match_operand:DI 1 "register_operand" "%0,d,d")
3271 (match_operand:DI 2 "uns_arith_operand" "d,K,d")))]
3272 "TARGET_64BIT && TARGET_MIPS16"
3277 [(set_attr "type" "arith")
3278 (set_attr "mode" "DI")
3279 (set_attr_alternative "length"
3281 (if_then_else (match_operand:VOID 2 "m16_uimm8_1")
3286 (define_insn "*norsi3"
3287 [(set (match_operand:SI 0 "register_operand" "=d")
3288 (and:SI (not:SI (match_operand:SI 1 "register_operand" "d"))
3289 (not:SI (match_operand:SI 2 "register_operand" "d"))))]
3292 [(set_attr "type" "arith")
3293 (set_attr "mode" "SI")])
3295 (define_insn "*nordi3"
3296 [(set (match_operand:DI 0 "register_operand" "=d")
3297 (and:DI (not:DI (match_operand:DI 1 "register_operand" "d"))
3298 (not:DI (match_operand:DI 2 "register_operand" "d"))))]
3299 "TARGET_64BIT && !TARGET_MIPS16"
3301 [(set_attr "type" "arith")
3302 (set_attr "mode" "DI")])
3305 ;; ....................
3309 ;; ....................
3313 (define_insn "truncdfsf2"
3314 [(set (match_operand:SF 0 "register_operand" "=f")
3315 (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
3316 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
3318 [(set_attr "type" "fcvt")
3319 (set_attr "mode" "SF")])
3321 ;; Integer truncation patterns. Truncating SImode values to smaller
3322 ;; modes is a no-op, as it is for most other GCC ports. Truncating
3323 ;; DImode values to SImode is not a no-op for TARGET_64BIT since we
3324 ;; need to make sure that the lower 32 bits are properly sign-extended
3325 ;; (see TRULY_NOOP_TRUNCATION). Truncating DImode values into modes
3326 ;; smaller than SImode is equivalent to two separate truncations:
3329 ;; DI ---> HI == DI ---> SI ---> HI
3330 ;; DI ---> QI == DI ---> SI ---> QI
3332 ;; Step A needs a real instruction but step B does not.
3334 (define_insn "truncdisi2"
3335 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,m")
3336 (truncate:SI (match_operand:DI 1 "register_operand" "d,d")))]
3341 [(set_attr "type" "shift,store")
3342 (set_attr "mode" "SI")
3343 (set_attr "extended_mips16" "yes,*")])
3345 (define_insn "truncdihi2"
3346 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,m")
3347 (truncate:HI (match_operand:DI 1 "register_operand" "d,d")))]
3352 [(set_attr "type" "shift,store")
3353 (set_attr "mode" "SI")
3354 (set_attr "extended_mips16" "yes,*")])
3356 (define_insn "truncdiqi2"
3357 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,m")
3358 (truncate:QI (match_operand:DI 1 "register_operand" "d,d")))]
3363 [(set_attr "type" "shift,store")
3364 (set_attr "mode" "SI")
3365 (set_attr "extended_mips16" "yes,*")])
3367 ;; Combiner patterns to optimize shift/truncate combinations.
3370 [(set (match_operand:SI 0 "register_operand" "=d")
3371 (truncate:SI (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
3372 (match_operand:DI 2 "small_int" "I"))))]
3373 "TARGET_64BIT && !TARGET_MIPS16 && INTVAL (operands[2]) >= 32"
3375 [(set_attr "type" "shift")
3376 (set_attr "mode" "SI")])
3379 [(set (match_operand:SI 0 "register_operand" "=d")
3380 (truncate:SI (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
3382 "TARGET_64BIT && !TARGET_MIPS16"
3384 [(set_attr "type" "shift")
3385 (set_attr "mode" "SI")])
3388 ;; Combiner patterns for truncate/sign_extend combinations. They use
3389 ;; the shift/truncate patterns above.
3391 (define_insn_and_split ""
3392 [(set (match_operand:SI 0 "register_operand" "=d")
3394 (truncate:HI (match_operand:DI 1 "register_operand" "d"))))]
3395 "TARGET_64BIT && !TARGET_MIPS16"
3397 "&& reload_completed"
3399 (ashift:DI (match_dup 1)
3402 (truncate:SI (ashiftrt:DI (match_dup 2)
3404 { operands[2] = gen_lowpart (DImode, operands[0]); })
3406 (define_insn_and_split ""
3407 [(set (match_operand:SI 0 "register_operand" "=d")
3409 (truncate:QI (match_operand:DI 1 "register_operand" "d"))))]
3410 "TARGET_64BIT && !TARGET_MIPS16"
3412 "&& reload_completed"
3414 (ashift:DI (match_dup 1)
3417 (truncate:SI (ashiftrt:DI (match_dup 2)
3419 { operands[2] = gen_lowpart (DImode, operands[0]); })
3422 ;; Combiner patterns to optimize truncate/zero_extend combinations.
3425 [(set (match_operand:SI 0 "register_operand" "=d")
3426 (zero_extend:SI (truncate:HI
3427 (match_operand:DI 1 "register_operand" "d"))))]
3428 "TARGET_64BIT && !TARGET_MIPS16"
3429 "andi\t%0,%1,0xffff"
3430 [(set_attr "type" "arith")
3431 (set_attr "mode" "SI")])
3434 [(set (match_operand:SI 0 "register_operand" "=d")
3435 (zero_extend:SI (truncate:QI
3436 (match_operand:DI 1 "register_operand" "d"))))]
3437 "TARGET_64BIT && !TARGET_MIPS16"
3439 [(set_attr "type" "arith")
3440 (set_attr "mode" "SI")])
3443 [(set (match_operand:HI 0 "register_operand" "=d")
3444 (zero_extend:HI (truncate:QI
3445 (match_operand:DI 1 "register_operand" "d"))))]
3446 "TARGET_64BIT && !TARGET_MIPS16"
3448 [(set_attr "type" "arith")
3449 (set_attr "mode" "HI")])
3452 ;; ....................
3456 ;; ....................
3459 ;; Those for integer source operand are ordered widest source type first.
3461 (define_insn_and_split "zero_extendsidi2"
3462 [(set (match_operand:DI 0 "register_operand" "=d")
3463 (zero_extend:DI (match_operand:SI 1 "register_operand" "d")))]
3466 "&& reload_completed"
3468 (ashift:DI (match_dup 1) (const_int 32)))
3470 (lshiftrt:DI (match_dup 0) (const_int 32)))]
3471 "operands[1] = gen_lowpart (DImode, operands[1]);"
3472 [(set_attr "type" "multi")
3473 (set_attr "mode" "DI")
3474 (set_attr "length" "8")])
3476 (define_insn "*zero_extendsidi2_mem"
3477 [(set (match_operand:DI 0 "register_operand" "=d")
3478 (zero_extend:DI (match_operand:SI 1 "memory_operand" "W")))]
3481 [(set_attr "type" "load")
3482 (set_attr "mode" "DI")])
3484 (define_expand "zero_extendhisi2"
3485 [(set (match_operand:SI 0 "register_operand")
3486 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand")))]
3489 if (TARGET_MIPS16 && GET_CODE (operands[1]) != MEM)
3491 rtx op = gen_lowpart (SImode, operands[1]);
3492 rtx temp = force_reg (SImode, GEN_INT (0xffff));
3494 emit_insn (gen_andsi3 (operands[0], op, temp));
3500 [(set (match_operand:SI 0 "register_operand" "=d,d")
3501 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "d,m")))]
3506 [(set_attr "type" "arith,load")
3507 (set_attr "mode" "SI")
3508 (set_attr "length" "4,*")])
3511 [(set (match_operand:SI 0 "register_operand" "=d")
3512 (zero_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
3515 [(set_attr "type" "load")
3516 (set_attr "mode" "SI")])
3518 (define_expand "zero_extendhidi2"
3519 [(set (match_operand:DI 0 "register_operand")
3520 (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand")))]
3523 if (TARGET_MIPS16 && GET_CODE (operands[1]) != MEM)
3525 rtx op = gen_lowpart (DImode, operands[1]);
3526 rtx temp = force_reg (DImode, GEN_INT (0xffff));
3528 emit_insn (gen_anddi3 (operands[0], op, temp));
3534 [(set (match_operand:DI 0 "register_operand" "=d,d")
3535 (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "d,m")))]
3536 "TARGET_64BIT && !TARGET_MIPS16"
3540 [(set_attr "type" "arith,load")
3541 (set_attr "mode" "DI")
3542 (set_attr "length" "4,*")])
3545 [(set (match_operand:DI 0 "register_operand" "=d")
3546 (zero_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
3547 "TARGET_64BIT && TARGET_MIPS16"
3549 [(set_attr "type" "load")
3550 (set_attr "mode" "DI")])
3552 (define_expand "zero_extendqihi2"
3553 [(set (match_operand:HI 0 "register_operand")
3554 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand")))]
3557 if (TARGET_MIPS16 && GET_CODE (operands[1]) != MEM)
3559 rtx op0 = gen_lowpart (SImode, operands[0]);
3560 rtx op1 = gen_lowpart (SImode, operands[1]);
3561 rtx temp = force_reg (SImode, GEN_INT (0xff));
3563 emit_insn (gen_andsi3 (op0, op1, temp));
3569 [(set (match_operand:HI 0 "register_operand" "=d,d")
3570 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
3575 [(set_attr "type" "arith,load")
3576 (set_attr "mode" "HI")
3577 (set_attr "length" "4,*")])
3580 [(set (match_operand:HI 0 "register_operand" "=d")
3581 (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
3584 [(set_attr "type" "load")
3585 (set_attr "mode" "HI")])
3587 (define_expand "zero_extendqisi2"
3588 [(set (match_operand:SI 0 "register_operand")
3589 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand")))]
3592 if (TARGET_MIPS16 && GET_CODE (operands[1]) != MEM)
3594 rtx op = gen_lowpart (SImode, operands[1]);
3595 rtx temp = force_reg (SImode, GEN_INT (0xff));
3597 emit_insn (gen_andsi3 (operands[0], op, temp));
3603 [(set (match_operand:SI 0 "register_operand" "=d,d")
3604 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
3609 [(set_attr "type" "arith,load")
3610 (set_attr "mode" "SI")
3611 (set_attr "length" "4,*")])
3614 [(set (match_operand:SI 0 "register_operand" "=d")
3615 (zero_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
3618 [(set_attr "type" "load")
3619 (set_attr "mode" "SI")])
3621 (define_expand "zero_extendqidi2"
3622 [(set (match_operand:DI 0 "register_operand")
3623 (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand")))]
3626 if (TARGET_MIPS16 && GET_CODE (operands[1]) != MEM)
3628 rtx op = gen_lowpart (DImode, operands[1]);
3629 rtx temp = force_reg (DImode, GEN_INT (0xff));
3631 emit_insn (gen_anddi3 (operands[0], op, temp));
3637 [(set (match_operand:DI 0 "register_operand" "=d,d")
3638 (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
3639 "TARGET_64BIT && !TARGET_MIPS16"
3643 [(set_attr "type" "arith,load")
3644 (set_attr "mode" "DI")
3645 (set_attr "length" "4,*")])
3648 [(set (match_operand:DI 0 "register_operand" "=d")
3649 (zero_extend:DI (match_operand:QI 1 "memory_operand" "m")))]
3650 "TARGET_64BIT && TARGET_MIPS16"
3652 [(set_attr "type" "load")
3653 (set_attr "mode" "DI")])
3656 ;; ....................
3660 ;; ....................
3663 ;; Those for integer source operand are ordered widest source type first.
3665 (define_insn "extendsidi2"
3666 [(set (match_operand:DI 0 "register_operand" "=d,d")
3667 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m")))]
3672 [(set_attr "type" "shift,load")
3673 (set_attr "mode" "DI")
3674 (set_attr "extended_mips16" "yes,*")])
3676 ;; These patterns originally accepted general_operands, however, slightly
3677 ;; better code is generated by only accepting register_operands, and then
3678 ;; letting combine generate the lh and lb insns.
3680 ;; These expanders originally put values in registers first. We split
3681 ;; all non-mem patterns after reload.
3683 (define_expand "extendhidi2"
3684 [(set (match_operand:DI 0 "register_operand")
3685 (sign_extend:DI (match_operand:HI 1 "nonimmediate_operand")))]
3689 (define_insn "*extendhidi2"
3690 [(set (match_operand:DI 0 "register_operand" "=d")
3691 (sign_extend:DI (match_operand:HI 1 "register_operand" "d")))]
3696 [(set (match_operand:DI 0 "register_operand")
3697 (sign_extend:DI (match_operand:HI 1 "register_operand")))]
3698 "TARGET_64BIT && reload_completed"
3700 (ashift:DI (match_dup 1) (const_int 48)))
3702 (ashiftrt:DI (match_dup 0) (const_int 48)))]
3703 "operands[1] = gen_lowpart (DImode, operands[1]);")
3705 (define_insn "*extendhidi2_mem"
3706 [(set (match_operand:DI 0 "register_operand" "=d")
3707 (sign_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
3710 [(set_attr "type" "load")
3711 (set_attr "mode" "DI")])
3713 (define_expand "extendhisi2"
3714 [(set (match_operand:SI 0 "register_operand")
3715 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand")))]
3718 if (ISA_HAS_SEB_SEH)
3720 emit_insn (gen_extendhisi2_hw (operands[0],
3721 force_reg (HImode, operands[1])));
3726 (define_insn "*extendhisi2"
3727 [(set (match_operand:SI 0 "register_operand" "=d")
3728 (sign_extend:SI (match_operand:HI 1 "register_operand" "d")))]
3733 [(set (match_operand:SI 0 "register_operand")
3734 (sign_extend:SI (match_operand:HI 1 "register_operand")))]
3737 (ashift:SI (match_dup 1) (const_int 16)))
3739 (ashiftrt:SI (match_dup 0) (const_int 16)))]
3740 "operands[1] = gen_lowpart (SImode, operands[1]);")
3742 (define_insn "extendhisi2_mem"
3743 [(set (match_operand:SI 0 "register_operand" "=d")
3744 (sign_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
3747 [(set_attr "type" "load")
3748 (set_attr "mode" "SI")])
3750 (define_insn "extendhisi2_hw"
3751 [(set (match_operand:SI 0 "register_operand" "=r")
3752 (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
3755 [(set_attr "type" "arith")
3756 (set_attr "mode" "SI")])
3758 (define_expand "extendqihi2"
3759 [(set (match_operand:HI 0 "register_operand")
3760 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand")))]
3764 (define_insn "*extendqihi2"
3765 [(set (match_operand:HI 0 "register_operand" "=d")
3766 (sign_extend:HI (match_operand:QI 1 "register_operand" "d")))]
3771 [(set (match_operand:HI 0 "register_operand")
3772 (sign_extend:HI (match_operand:QI 1 "register_operand")))]
3775 (ashift:SI (match_dup 1) (const_int 24)))
3777 (ashiftrt:SI (match_dup 0) (const_int 24)))]
3778 "operands[0] = gen_lowpart (SImode, operands[0]);
3779 operands[1] = gen_lowpart (SImode, operands[1]);")
3781 (define_insn "*extendqihi2_internal_mem"
3782 [(set (match_operand:HI 0 "register_operand" "=d")
3783 (sign_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
3786 [(set_attr "type" "load")
3787 (set_attr "mode" "SI")])
3790 (define_expand "extendqisi2"
3791 [(set (match_operand:SI 0 "register_operand")
3792 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand")))]
3795 if (ISA_HAS_SEB_SEH)
3797 emit_insn (gen_extendqisi2_hw (operands[0],
3798 force_reg (QImode, operands[1])));
3803 (define_insn "*extendqisi2"
3804 [(set (match_operand:SI 0 "register_operand" "=d")
3805 (sign_extend:SI (match_operand:QI 1 "register_operand" "d")))]
3810 [(set (match_operand:SI 0 "register_operand")
3811 (sign_extend:SI (match_operand:QI 1 "register_operand")))]
3814 (ashift:SI (match_dup 1) (const_int 24)))
3816 (ashiftrt:SI (match_dup 0) (const_int 24)))]
3817 "operands[1] = gen_lowpart (SImode, operands[1]);")
3819 (define_insn "*extendqisi2_mem"
3820 [(set (match_operand:SI 0 "register_operand" "=d")
3821 (sign_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
3824 [(set_attr "type" "load")
3825 (set_attr "mode" "SI")])
3827 (define_insn "extendqisi2_hw"
3828 [(set (match_operand:SI 0 "register_operand" "=r")
3829 (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
3832 [(set_attr "type" "arith")
3833 (set_attr "mode" "SI")])
3835 (define_expand "extendqidi2"
3836 [(set (match_operand:DI 0 "register_operand")
3837 (sign_extend:DI (match_operand:QI 1 "nonimmediate_operand")))]
3841 (define_insn "*extendqidi2"
3842 [(set (match_operand:DI 0 "register_operand" "=d")
3843 (sign_extend:DI (match_operand:QI 1 "register_operand" "d")))]
3848 [(set (match_operand:DI 0 "register_operand")
3849 (sign_extend:DI (match_operand:QI 1 "register_operand")))]
3850 "TARGET_64BIT && reload_completed"
3852 (ashift:DI (match_dup 1) (const_int 56)))
3854 (ashiftrt:DI (match_dup 0) (const_int 56)))]
3855 "operands[1] = gen_lowpart (DImode, operands[1]);")
3857 (define_insn "*extendqidi2_mem"
3858 [(set (match_operand:DI 0 "register_operand" "=d")
3859 (sign_extend:DI (match_operand:QI 1 "memory_operand" "m")))]
3862 [(set_attr "type" "load")
3863 (set_attr "mode" "DI")])
3865 (define_insn "extendsfdf2"
3866 [(set (match_operand:DF 0 "register_operand" "=f")
3867 (float_extend:DF (match_operand:SF 1 "register_operand" "f")))]
3868 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
3870 [(set_attr "type" "fcvt")
3871 (set_attr "mode" "DF")])
3874 ;; ....................
3878 ;; ....................
3880 (define_expand "fix_truncdfsi2"
3881 [(set (match_operand:SI 0 "register_operand")
3882 (fix:SI (match_operand:DF 1 "register_operand")))]
3883 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
3885 if (!ISA_HAS_TRUNC_W)
3887 emit_insn (gen_fix_truncdfsi2_macro (operands[0], operands[1]));
3892 (define_insn "fix_truncdfsi2_insn"
3893 [(set (match_operand:SI 0 "register_operand" "=f")
3894 (fix:SI (match_operand:DF 1 "register_operand" "f")))]
3895 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && ISA_HAS_TRUNC_W"
3897 [(set_attr "type" "fcvt")
3898 (set_attr "mode" "DF")
3899 (set_attr "length" "4")])
3901 (define_insn "fix_truncdfsi2_macro"
3902 [(set (match_operand:SI 0 "register_operand" "=f")
3903 (fix:SI (match_operand:DF 1 "register_operand" "f")))
3904 (clobber (match_scratch:DF 2 "=d"))]
3905 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !ISA_HAS_TRUNC_W"
3908 return ".set\tmacro\;trunc.w.d %0,%1,%2\;.set\tnomacro";
3910 return "trunc.w.d %0,%1,%2";
3912 [(set_attr "type" "fcvt")
3913 (set_attr "mode" "DF")
3914 (set_attr "length" "36")])
3916 (define_expand "fix_truncsfsi2"
3917 [(set (match_operand:SI 0 "register_operand")
3918 (fix:SI (match_operand:SF 1 "register_operand")))]
3921 if (!ISA_HAS_TRUNC_W)
3923 emit_insn (gen_fix_truncsfsi2_macro (operands[0], operands[1]));
3928 (define_insn "fix_truncsfsi2_insn"
3929 [(set (match_operand:SI 0 "register_operand" "=f")
3930 (fix:SI (match_operand:SF 1 "register_operand" "f")))]
3931 "TARGET_HARD_FLOAT && ISA_HAS_TRUNC_W"
3933 [(set_attr "type" "fcvt")
3934 (set_attr "mode" "DF")
3935 (set_attr "length" "4")])
3937 (define_insn "fix_truncsfsi2_macro"
3938 [(set (match_operand:SI 0 "register_operand" "=f")
3939 (fix:SI (match_operand:SF 1 "register_operand" "f")))
3940 (clobber (match_scratch:SF 2 "=d"))]
3941 "TARGET_HARD_FLOAT && !ISA_HAS_TRUNC_W"
3944 return ".set\tmacro\;trunc.w.s %0,%1,%2\;.set\tnomacro";
3946 return "trunc.w.s %0,%1,%2";
3948 [(set_attr "type" "fcvt")
3949 (set_attr "mode" "DF")
3950 (set_attr "length" "36")])
3953 (define_insn "fix_truncdfdi2"
3954 [(set (match_operand:DI 0 "register_operand" "=f")
3955 (fix:DI (match_operand:DF 1 "register_operand" "f")))]
3956 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
3958 [(set_attr "type" "fcvt")
3959 (set_attr "mode" "DF")
3960 (set_attr "length" "4")])
3963 (define_insn "fix_truncsfdi2"
3964 [(set (match_operand:DI 0 "register_operand" "=f")
3965 (fix:DI (match_operand:SF 1 "register_operand" "f")))]
3966 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
3968 [(set_attr "type" "fcvt")
3969 (set_attr "mode" "SF")
3970 (set_attr "length" "4")])
3973 (define_insn "floatsidf2"
3974 [(set (match_operand:DF 0 "register_operand" "=f")
3975 (float:DF (match_operand:SI 1 "register_operand" "f")))]
3976 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
3978 [(set_attr "type" "fcvt")
3979 (set_attr "mode" "DF")
3980 (set_attr "length" "4")])
3983 (define_insn "floatdidf2"
3984 [(set (match_operand:DF 0 "register_operand" "=f")
3985 (float:DF (match_operand:DI 1 "register_operand" "f")))]
3986 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
3988 [(set_attr "type" "fcvt")
3989 (set_attr "mode" "DF")
3990 (set_attr "length" "4")])
3993 (define_insn "floatsisf2"
3994 [(set (match_operand:SF 0 "register_operand" "=f")
3995 (float:SF (match_operand:SI 1 "register_operand" "f")))]
3998 [(set_attr "type" "fcvt")
3999 (set_attr "mode" "SF")
4000 (set_attr "length" "4")])
4003 (define_insn "floatdisf2"
4004 [(set (match_operand:SF 0 "register_operand" "=f")
4005 (float:SF (match_operand:DI 1 "register_operand" "f")))]
4006 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
4008 [(set_attr "type" "fcvt")
4009 (set_attr "mode" "SF")
4010 (set_attr "length" "4")])
4013 (define_expand "fixuns_truncdfsi2"
4014 [(set (match_operand:SI 0 "register_operand")
4015 (unsigned_fix:SI (match_operand:DF 1 "register_operand")))]
4016 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
4018 rtx reg1 = gen_reg_rtx (DFmode);
4019 rtx reg2 = gen_reg_rtx (DFmode);
4020 rtx reg3 = gen_reg_rtx (SImode);
4021 rtx label1 = gen_label_rtx ();
4022 rtx label2 = gen_label_rtx ();
4023 REAL_VALUE_TYPE offset;
4025 real_2expN (&offset, 31);
4027 if (reg1) /* Turn off complaints about unreached code. */
4029 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, DFmode));
4030 do_pending_stack_adjust ();
4032 emit_insn (gen_cmpdf (operands[1], reg1));
4033 emit_jump_insn (gen_bge (label1));
4035 emit_insn (gen_fix_truncdfsi2 (operands[0], operands[1]));
4036 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
4037 gen_rtx_LABEL_REF (VOIDmode, label2)));
4040 emit_label (label1);
4041 emit_move_insn (reg2, gen_rtx_MINUS (DFmode, operands[1], reg1));
4042 emit_move_insn (reg3, GEN_INT (trunc_int_for_mode
4043 (BITMASK_HIGH, SImode)));
4045 emit_insn (gen_fix_truncdfsi2 (operands[0], reg2));
4046 emit_insn (gen_iorsi3 (operands[0], operands[0], reg3));
4048 emit_label (label2);
4050 /* Allow REG_NOTES to be set on last insn (labels don't have enough
4051 fields, and can't be used for REG_NOTES anyway). */
4052 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
4058 (define_expand "fixuns_truncdfdi2"
4059 [(set (match_operand:DI 0 "register_operand")
4060 (unsigned_fix:DI (match_operand:DF 1 "register_operand")))]
4061 "TARGET_HARD_FLOAT && TARGET_64BIT && TARGET_DOUBLE_FLOAT"
4063 rtx reg1 = gen_reg_rtx (DFmode);
4064 rtx reg2 = gen_reg_rtx (DFmode);
4065 rtx reg3 = gen_reg_rtx (DImode);
4066 rtx label1 = gen_label_rtx ();
4067 rtx label2 = gen_label_rtx ();
4068 REAL_VALUE_TYPE offset;
4070 real_2expN (&offset, 63);
4072 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, DFmode));
4073 do_pending_stack_adjust ();
4075 emit_insn (gen_cmpdf (operands[1], reg1));
4076 emit_jump_insn (gen_bge (label1));
4078 emit_insn (gen_fix_truncdfdi2 (operands[0], operands[1]));
4079 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
4080 gen_rtx_LABEL_REF (VOIDmode, label2)));
4083 emit_label (label1);
4084 emit_move_insn (reg2, gen_rtx_MINUS (DFmode, operands[1], reg1));
4085 emit_move_insn (reg3, GEN_INT (BITMASK_HIGH));
4086 emit_insn (gen_ashldi3 (reg3, reg3, GEN_INT (32)));
4088 emit_insn (gen_fix_truncdfdi2 (operands[0], reg2));
4089 emit_insn (gen_iordi3 (operands[0], operands[0], reg3));
4091 emit_label (label2);
4093 /* Allow REG_NOTES to be set on last insn (labels don't have enough
4094 fields, and can't be used for REG_NOTES anyway). */
4095 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
4100 (define_expand "fixuns_truncsfsi2"
4101 [(set (match_operand:SI 0 "register_operand")
4102 (unsigned_fix:SI (match_operand:SF 1 "register_operand")))]
4105 rtx reg1 = gen_reg_rtx (SFmode);
4106 rtx reg2 = gen_reg_rtx (SFmode);
4107 rtx reg3 = gen_reg_rtx (SImode);
4108 rtx label1 = gen_label_rtx ();
4109 rtx label2 = gen_label_rtx ();
4110 REAL_VALUE_TYPE offset;
4112 real_2expN (&offset, 31);
4114 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, SFmode));
4115 do_pending_stack_adjust ();
4117 emit_insn (gen_cmpsf (operands[1], reg1));
4118 emit_jump_insn (gen_bge (label1));
4120 emit_insn (gen_fix_truncsfsi2 (operands[0], operands[1]));
4121 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
4122 gen_rtx_LABEL_REF (VOIDmode, label2)));
4125 emit_label (label1);
4126 emit_move_insn (reg2, gen_rtx_MINUS (SFmode, operands[1], reg1));
4127 emit_move_insn (reg3, GEN_INT (trunc_int_for_mode
4128 (BITMASK_HIGH, SImode)));
4130 emit_insn (gen_fix_truncsfsi2 (operands[0], reg2));
4131 emit_insn (gen_iorsi3 (operands[0], operands[0], reg3));
4133 emit_label (label2);
4135 /* Allow REG_NOTES to be set on last insn (labels don't have enough
4136 fields, and can't be used for REG_NOTES anyway). */
4137 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
4142 (define_expand "fixuns_truncsfdi2"
4143 [(set (match_operand:DI 0 "register_operand")
4144 (unsigned_fix:DI (match_operand:SF 1 "register_operand")))]
4145 "TARGET_HARD_FLOAT && TARGET_64BIT && TARGET_DOUBLE_FLOAT"
4147 rtx reg1 = gen_reg_rtx (SFmode);
4148 rtx reg2 = gen_reg_rtx (SFmode);
4149 rtx reg3 = gen_reg_rtx (DImode);
4150 rtx label1 = gen_label_rtx ();
4151 rtx label2 = gen_label_rtx ();
4152 REAL_VALUE_TYPE offset;
4154 real_2expN (&offset, 63);
4156 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, SFmode));
4157 do_pending_stack_adjust ();
4159 emit_insn (gen_cmpsf (operands[1], reg1));
4160 emit_jump_insn (gen_bge (label1));
4162 emit_insn (gen_fix_truncsfdi2 (operands[0], operands[1]));
4163 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
4164 gen_rtx_LABEL_REF (VOIDmode, label2)));
4167 emit_label (label1);
4168 emit_move_insn (reg2, gen_rtx_MINUS (SFmode, operands[1], reg1));
4169 emit_move_insn (reg3, GEN_INT (BITMASK_HIGH));
4170 emit_insn (gen_ashldi3 (reg3, reg3, GEN_INT (32)));
4172 emit_insn (gen_fix_truncsfdi2 (operands[0], reg2));
4173 emit_insn (gen_iordi3 (operands[0], operands[0], reg3));
4175 emit_label (label2);
4177 /* Allow REG_NOTES to be set on last insn (labels don't have enough
4178 fields, and can't be used for REG_NOTES anyway). */
4179 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
4184 ;; ....................
4188 ;; ....................
4190 ;; Bit field extract patterns which use lwl/lwr or ldl/ldr.
4192 (define_expand "extv"
4193 [(set (match_operand 0 "register_operand")
4194 (sign_extract (match_operand:QI 1 "memory_operand")
4195 (match_operand 2 "immediate_operand")
4196 (match_operand 3 "immediate_operand")))]
4199 if (mips_expand_unaligned_load (operands[0], operands[1],
4200 INTVAL (operands[2]),
4201 INTVAL (operands[3])))
4207 (define_expand "extzv"
4208 [(set (match_operand 0 "register_operand")
4209 (zero_extract (match_operand:QI 1 "memory_operand")
4210 (match_operand 2 "immediate_operand")
4211 (match_operand 3 "immediate_operand")))]
4214 if (mips_expand_unaligned_load (operands[0], operands[1],
4215 INTVAL (operands[2]),
4216 INTVAL (operands[3])))
4222 (define_expand "insv"
4223 [(set (zero_extract (match_operand:QI 0 "memory_operand")
4224 (match_operand 1 "immediate_operand")
4225 (match_operand 2 "immediate_operand"))
4226 (match_operand 3 "reg_or_0_operand"))]
4229 if (mips_expand_unaligned_store (operands[0], operands[3],
4230 INTVAL (operands[1]),
4231 INTVAL (operands[2])))
4237 ;; Unaligned word moves generated by the bit field patterns.
4239 ;; As far as the rtl is concerned, both the left-part and right-part
4240 ;; instructions can access the whole field. However, the real operand
4241 ;; refers to just the first or the last byte (depending on endianness).
4242 ;; We therefore use two memory operands to each instruction, one to
4243 ;; describe the rtl effect and one to use in the assembly output.
4245 ;; Operands 0 and 1 are the rtl-level target and source respectively.
4246 ;; This allows us to use the standard length calculations for the "load"
4247 ;; and "store" type attributes.
4249 (define_insn "mov_lwl"
4250 [(set (match_operand:SI 0 "register_operand" "=d")
4251 (unspec:SI [(match_operand:BLK 1 "memory_operand" "m")
4252 (match_operand:QI 2 "memory_operand" "m")]
4256 [(set_attr "type" "load")
4257 (set_attr "mode" "SI")
4258 (set_attr "hazard" "none")])
4260 (define_insn "mov_lwr"
4261 [(set (match_operand:SI 0 "register_operand" "=d")
4262 (unspec:SI [(match_operand:BLK 1 "memory_operand" "m")
4263 (match_operand:QI 2 "memory_operand" "m")
4264 (match_operand:SI 3 "register_operand" "0")]
4268 [(set_attr "type" "load")
4269 (set_attr "mode" "SI")])
4272 (define_insn "mov_swl"
4273 [(set (match_operand:BLK 0 "memory_operand" "=m")
4274 (unspec:BLK [(match_operand:SI 1 "reg_or_0_operand" "dJ")
4275 (match_operand:QI 2 "memory_operand" "m")]
4279 [(set_attr "type" "store")
4280 (set_attr "mode" "SI")])
4282 (define_insn "mov_swr"
4283 [(set (match_operand:BLK 0 "memory_operand" "+m")
4284 (unspec:BLK [(match_operand:SI 1 "reg_or_0_operand" "dJ")
4285 (match_operand:QI 2 "memory_operand" "m")
4290 [(set_attr "type" "store")
4291 (set_attr "mode" "SI")])
4294 (define_insn "mov_ldl"
4295 [(set (match_operand:DI 0 "register_operand" "=d")
4296 (unspec:DI [(match_operand:BLK 1 "memory_operand" "m")
4297 (match_operand:QI 2 "memory_operand" "m")]
4299 "TARGET_64BIT && !TARGET_MIPS16"
4301 [(set_attr "type" "load")
4302 (set_attr "mode" "DI")])
4304 (define_insn "mov_ldr"
4305 [(set (match_operand:DI 0 "register_operand" "=d")
4306 (unspec:DI [(match_operand:BLK 1 "memory_operand" "m")
4307 (match_operand:QI 2 "memory_operand" "m")
4308 (match_operand:DI 3 "register_operand" "0")]
4310 "TARGET_64BIT && !TARGET_MIPS16"
4312 [(set_attr "type" "load")
4313 (set_attr "mode" "DI")])
4316 (define_insn "mov_sdl"
4317 [(set (match_operand:BLK 0 "memory_operand" "=m")
4318 (unspec:BLK [(match_operand:DI 1 "reg_or_0_operand" "dJ")
4319 (match_operand:QI 2 "memory_operand" "m")]
4321 "TARGET_64BIT && !TARGET_MIPS16"
4323 [(set_attr "type" "store")
4324 (set_attr "mode" "DI")])
4326 (define_insn "mov_sdr"
4327 [(set (match_operand:BLK 0 "memory_operand" "+m")
4328 (unspec:BLK [(match_operand:DI 1 "reg_or_0_operand" "dJ")
4329 (match_operand:QI 2 "memory_operand" "m")
4332 "TARGET_64BIT && !TARGET_MIPS16"
4334 [(set_attr "type" "store")
4335 (set_attr "mode" "DI")])
4337 ;; An instruction to calculate the high part of a 64-bit SYMBOL_GENERAL.
4338 ;; The required value is:
4340 ;; (%highest(op1) << 48) + (%higher(op1) << 32) + (%hi(op1) << 16)
4342 ;; which translates to:
4344 ;; lui op0,%highest(op1)
4345 ;; daddiu op0,op0,%higher(op1)
4347 ;; daddiu op0,op0,%hi(op1)
4349 (define_insn_and_split "*lea_high64"
4350 [(set (match_operand:DI 0 "register_operand" "=d")
4351 (high:DI (match_operand:DI 1 "general_symbolic_operand" "")))]
4352 "TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS"
4354 "&& reload_completed"
4355 [(set (match_dup 0) (high:DI (match_dup 2)))
4356 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 2)))
4357 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 16)))
4358 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 3)))
4359 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 16)))]
4361 operands[2] = mips_unspec_address (operands[1], SYMBOL_64_HIGH);
4362 operands[3] = mips_unspec_address (operands[1], SYMBOL_64_MID);
4364 [(set_attr "length" "20")])
4366 ;; On most targets, the expansion of (lo_sum (high X) X) for a 64-bit
4367 ;; SYMBOL_GENERAL X will take 6 cycles. This next pattern allows combine
4368 ;; to merge the HIGH and LO_SUM parts of a move if the HIGH part is only
4369 ;; used once. We can then use the sequence:
4371 ;; lui op0,%highest(op1)
4373 ;; daddiu op0,op0,%higher(op1)
4374 ;; daddiu op2,op2,%lo(op1)
4376 ;; daddu op0,op0,op2
4378 ;; which takes 4 cycles on most superscalar targets.
4379 (define_insn_and_split "*lea64"
4380 [(set (match_operand:DI 0 "register_operand" "=d")
4381 (match_operand:DI 1 "general_symbolic_operand" ""))
4382 (clobber (match_scratch:DI 2 "=&d"))]
4383 "TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS && cse_not_expected"
4385 "&& reload_completed"
4386 [(set (match_dup 0) (high:DI (match_dup 3)))
4387 (set (match_dup 2) (high:DI (match_dup 4)))
4388 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 3)))
4389 (set (match_dup 2) (lo_sum:DI (match_dup 2) (match_dup 4)))
4390 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
4391 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))]
4393 operands[3] = mips_unspec_address (operands[1], SYMBOL_64_HIGH);
4394 operands[4] = mips_unspec_address (operands[1], SYMBOL_64_LOW);
4396 [(set_attr "length" "24")])
4398 ;; Insns to fetch a global symbol from a big GOT.
4400 (define_insn_and_split "*xgot_hisi"
4401 [(set (match_operand:SI 0 "register_operand" "=d")
4402 (high:SI (match_operand:SI 1 "global_got_operand" "")))]
4403 "TARGET_EXPLICIT_RELOCS && TARGET_XGOT"
4405 "&& reload_completed"
4406 [(set (match_dup 0) (high:SI (match_dup 2)))
4407 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 3)))]
4409 operands[2] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_GLOBAL);
4410 operands[3] = pic_offset_table_rtx;
4412 [(set_attr "got" "xgot_high")])
4414 (define_insn_and_split "*xgot_losi"
4415 [(set (match_operand:SI 0 "register_operand" "=d")
4416 (lo_sum:SI (match_operand:SI 1 "register_operand" "d")
4417 (match_operand:SI 2 "global_got_operand" "")))]
4418 "TARGET_EXPLICIT_RELOCS && TARGET_XGOT"
4420 "&& reload_completed"
4422 (unspec:SI [(match_dup 1) (match_dup 3)] UNSPEC_LOAD_GOT))]
4423 { operands[3] = mips_unspec_address (operands[2], SYMBOL_GOTOFF_GLOBAL); }
4424 [(set_attr "got" "load")])
4426 (define_insn_and_split "*xgot_hidi"
4427 [(set (match_operand:DI 0 "register_operand" "=d")
4428 (high:DI (match_operand:DI 1 "global_got_operand" "")))]
4429 "TARGET_EXPLICIT_RELOCS && TARGET_XGOT"
4431 "&& reload_completed"
4432 [(set (match_dup 0) (high:DI (match_dup 2)))
4433 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
4435 operands[2] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_GLOBAL);
4436 operands[3] = pic_offset_table_rtx;
4438 [(set_attr "got" "xgot_high")])
4440 (define_insn_and_split "*xgot_lodi"
4441 [(set (match_operand:DI 0 "register_operand" "=d")
4442 (lo_sum:DI (match_operand:DI 1 "register_operand" "d")
4443 (match_operand:DI 2 "global_got_operand" "")))]
4444 "TARGET_EXPLICIT_RELOCS && TARGET_XGOT"
4446 "&& reload_completed"
4448 (unspec:DI [(match_dup 1) (match_dup 3)] UNSPEC_LOAD_GOT))]
4449 { operands[3] = mips_unspec_address (operands[2], SYMBOL_GOTOFF_GLOBAL); }
4450 [(set_attr "got" "load")])
4452 ;; Insns to fetch a global symbol from a normal GOT.
4454 (define_insn_and_split "*got_dispsi"
4455 [(set (match_operand:SI 0 "register_operand" "=d")
4456 (match_operand:SI 1 "global_got_operand" ""))]
4457 "TARGET_EXPLICIT_RELOCS && !TARGET_XGOT"
4459 "&& reload_completed"
4461 (unspec:SI [(match_dup 2) (match_dup 3)] UNSPEC_LOAD_GOT))]
4463 operands[2] = pic_offset_table_rtx;
4464 operands[3] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_GLOBAL);
4466 [(set_attr "got" "load")])
4468 (define_insn_and_split "*got_dispdi"
4469 [(set (match_operand:DI 0 "register_operand" "=d")
4470 (match_operand:DI 1 "global_got_operand" ""))]
4471 "TARGET_EXPLICIT_RELOCS && !TARGET_XGOT"
4473 "&& reload_completed"
4475 (unspec:DI [(match_dup 2) (match_dup 3)] UNSPEC_LOAD_GOT))]
4477 operands[2] = pic_offset_table_rtx;
4478 operands[3] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_GLOBAL);
4480 [(set_attr "got" "load")])
4482 ;; Insns for loading the high part of a local symbol.
4484 (define_insn_and_split "*got_pagesi"
4485 [(set (match_operand:SI 0 "register_operand" "=d")
4486 (high:SI (match_operand:SI 1 "local_got_operand" "")))]
4487 "TARGET_EXPLICIT_RELOCS"
4489 "&& reload_completed"
4491 (unspec:SI [(match_dup 2) (match_dup 3)] UNSPEC_LOAD_GOT))]
4493 operands[2] = pic_offset_table_rtx;
4494 operands[3] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_PAGE);
4496 [(set_attr "got" "load")])
4498 (define_insn_and_split "*got_pagedi"
4499 [(set (match_operand:DI 0 "register_operand" "=d")
4500 (high:DI (match_operand:DI 1 "local_got_operand" "")))]
4501 "TARGET_EXPLICIT_RELOCS"
4503 "&& reload_completed"
4505 (unspec:DI [(match_dup 2) (match_dup 3)] UNSPEC_LOAD_GOT))]
4507 operands[2] = pic_offset_table_rtx;
4508 operands[3] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_PAGE);
4510 [(set_attr "got" "load")])
4512 ;; Lower-level instructions for loading an address from the GOT.
4513 ;; We could use MEMs, but an unspec gives more optimization
4516 (define_insn "*load_gotsi"
4517 [(set (match_operand:SI 0 "register_operand" "=d")
4518 (unspec:SI [(match_operand:SI 1 "register_operand" "d")
4519 (match_operand:SI 2 "immediate_operand" "")]
4523 [(set_attr "type" "load")
4524 (set_attr "length" "4")])
4526 (define_insn "*load_gotdi"
4527 [(set (match_operand:DI 0 "register_operand" "=d")
4528 (unspec:DI [(match_operand:DI 1 "register_operand" "d")
4529 (match_operand:DI 2 "immediate_operand" "")]
4533 [(set_attr "type" "load")
4534 (set_attr "length" "4")])
4536 ;; Instructions for adding the low 16 bits of an address to a register.
4537 ;; Operand 2 is the address: print_operand works out which relocation
4538 ;; should be applied.
4540 (define_insn "*lowsi"
4541 [(set (match_operand:SI 0 "register_operand" "=d")
4542 (lo_sum:SI (match_operand:SI 1 "register_operand" "d")
4543 (match_operand:SI 2 "immediate_operand" "")))]
4546 [(set_attr "type" "arith")
4547 (set_attr "mode" "SI")])
4549 (define_insn "*lowdi"
4550 [(set (match_operand:DI 0 "register_operand" "=d")
4551 (lo_sum:DI (match_operand:DI 1 "register_operand" "d")
4552 (match_operand:DI 2 "immediate_operand" "")))]
4553 "!TARGET_MIPS16 && TARGET_64BIT"
4555 [(set_attr "type" "arith")
4556 (set_attr "mode" "DI")])
4558 (define_insn "*lowsi_mips16"
4559 [(set (match_operand:SI 0 "register_operand" "=d")
4560 (lo_sum:SI (match_operand:SI 1 "register_operand" "0")
4561 (match_operand:SI 2 "immediate_operand" "")))]
4564 [(set_attr "type" "arith")
4565 (set_attr "mode" "SI")
4566 (set_attr "length" "8")])
4568 (define_insn "*lowdi_mips16"
4569 [(set (match_operand:DI 0 "register_operand" "=d")
4570 (lo_sum:DI (match_operand:DI 1 "register_operand" "0")
4571 (match_operand:DI 2 "immediate_operand" "")))]
4572 "TARGET_MIPS16 && TARGET_64BIT"
4574 [(set_attr "type" "arith")
4575 (set_attr "mode" "DI")
4576 (set_attr "length" "8")])
4578 ;; 64-bit integer moves
4580 ;; Unlike most other insns, the move insns can't be split with
4581 ;; different predicates, because register spilling and other parts of
4582 ;; the compiler, have memoized the insn number already.
4584 (define_expand "movdi"
4585 [(set (match_operand:DI 0 "")
4586 (match_operand:DI 1 ""))]
4589 if (mips_legitimize_move (DImode, operands[0], operands[1]))
4593 ;; For mips16, we need a special case to handle storing $31 into
4594 ;; memory, since we don't have a constraint to match $31. This
4595 ;; instruction can be generated by save_restore_insns.
4598 [(set (match_operand:DI 0 "stack_operand" "=m")
4600 "TARGET_MIPS16 && TARGET_64BIT"
4602 [(set_attr "type" "store")
4603 (set_attr "mode" "DI")])
4605 (define_insn "*movdi_32bit"
4606 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,m,*x,*d,*B*C*D,*B*C*D,*d,*m")
4607 (match_operand:DI 1 "move_operand" "d,i,m,d,*J*d,*x,*d,*m,*B*C*D,*B*C*D"))]
4608 "!TARGET_64BIT && !TARGET_MIPS16
4609 && (register_operand (operands[0], DImode)
4610 || reg_or_0_operand (operands[1], DImode))"
4611 { return mips_output_move (operands[0], operands[1]); }
4612 [(set_attr "type" "arith,arith,load,store,mthilo,mfhilo,xfer,load,xfer,store")
4613 (set_attr "mode" "DI")
4614 (set_attr "length" "8,16,*,*,8,8,8,*,8,*")])
4616 (define_insn "*movdi_32bit_mips16"
4617 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m,*d")
4618 (match_operand:DI 1 "move_operand" "d,d,y,K,N,m,d,*x"))]
4619 "!TARGET_64BIT && TARGET_MIPS16
4620 && (register_operand (operands[0], DImode)
4621 || register_operand (operands[1], DImode))"
4622 { return mips_output_move (operands[0], operands[1]); }
4623 [(set_attr "type" "arith,arith,arith,arith,arith,load,store,mfhilo")
4624 (set_attr "mode" "DI")
4625 (set_attr "length" "8,8,8,8,12,*,*,8")])
4627 (define_insn "*movdi_64bit"
4628 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,e,d,m,*f,*f,*f,*d,*m,*x,*B*C*D,*B*C*D,*d,*m")
4629 (match_operand:DI 1 "move_operand" "d,U,T,m,dJ,*f,*d*J,*m,*f,*f,*J*d,*d,*m,*B*C*D,*B*C*D"))]
4630 "TARGET_64BIT && !TARGET_MIPS16
4631 && (register_operand (operands[0], DImode)
4632 || reg_or_0_operand (operands[1], DImode))"
4633 { return mips_output_move (operands[0], operands[1]); }
4634 [(set_attr "type" "arith,const,const,load,store,fmove,xfer,fpload,xfer,fpstore,mthilo,xfer,load,xfer,store")
4635 (set_attr "mode" "DI")
4636 (set_attr "length" "4,*,*,*,*,4,4,*,4,*,4,8,*,8,*")])
4638 (define_insn "*movdi_64bit_mips16"
4639 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,y,d,d,d,d,d,m")
4640 (match_operand:DI 1 "move_operand" "d,d,y,K,N,U,m,d"))]
4641 "TARGET_64BIT && TARGET_MIPS16
4642 && (register_operand (operands[0], DImode)
4643 || register_operand (operands[1], DImode))"
4644 { return mips_output_move (operands[0], operands[1]); }
4645 [(set_attr "type" "arith,arith,arith,arith,arith,const,load,store")
4646 (set_attr "mode" "DI")
4647 (set_attr_alternative "length"
4651 (if_then_else (match_operand:VOID 1 "m16_uimm8_1")
4654 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1")
4659 (const_string "*")])])
4662 ;; On the mips16, we can split ld $r,N($r) into an add and a load,
4663 ;; when the original load is a 4 byte instruction but the add and the
4664 ;; load are 2 2 byte instructions.
4667 [(set (match_operand:DI 0 "register_operand")
4668 (mem:DI (plus:DI (match_dup 0)
4669 (match_operand:DI 1 "const_int_operand"))))]
4670 "TARGET_64BIT && TARGET_MIPS16 && reload_completed
4671 && !TARGET_DEBUG_D_MODE
4672 && GET_CODE (operands[0]) == REG
4673 && M16_REG_P (REGNO (operands[0]))
4674 && GET_CODE (operands[1]) == CONST_INT
4675 && ((INTVAL (operands[1]) < 0
4676 && INTVAL (operands[1]) >= -0x10)
4677 || (INTVAL (operands[1]) >= 32 * 8
4678 && INTVAL (operands[1]) <= 31 * 8 + 0x8)
4679 || (INTVAL (operands[1]) >= 0
4680 && INTVAL (operands[1]) < 32 * 8
4681 && (INTVAL (operands[1]) & 7) != 0))"
4682 [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1)))
4683 (set (match_dup 0) (mem:DI (plus:DI (match_dup 0) (match_dup 2))))]
4685 HOST_WIDE_INT val = INTVAL (operands[1]);
4688 operands[2] = const0_rtx;
4689 else if (val >= 32 * 8)
4693 operands[1] = GEN_INT (0x8 + off);
4694 operands[2] = GEN_INT (val - off - 0x8);
4700 operands[1] = GEN_INT (off);
4701 operands[2] = GEN_INT (val - off);
4705 ;; 32-bit Integer moves
4707 ;; Unlike most other insns, the move insns can't be split with
4708 ;; different predicates, because register spilling and other parts of
4709 ;; the compiler, have memoized the insn number already.
4711 (define_expand "movsi"
4712 [(set (match_operand:SI 0 "")
4713 (match_operand:SI 1 ""))]
4716 if (mips_legitimize_move (SImode, operands[0], operands[1]))
4720 ;; We can only store $ra directly into a small sp offset.
4723 [(set (match_operand:SI 0 "stack_operand" "=m")
4727 [(set_attr "type" "store")
4728 (set_attr "mode" "SI")])
4730 ;; The difference between these two is whether or not ints are allowed
4731 ;; in FP registers (off by default, use -mdebugh to enable).
4733 (define_insn "*movsi_internal"
4734 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,e,d,m,*f,*f,*f,*d,*m,*d,*z,*x,*B*C*D,*B*C*D,*d,*m")
4735 (match_operand:SI 1 "move_operand" "d,U,T,m,dJ,*f,*d*J,*m,*f,*f,*z,*d,*J*d,*d,*m,*B*C*D,*B*C*D"))]
4737 && (register_operand (operands[0], SImode)
4738 || reg_or_0_operand (operands[1], SImode))"
4739 { return mips_output_move (operands[0], operands[1]); }
4740 [(set_attr "type" "arith,const,const,load,store,fmove,xfer,fpload,xfer,fpstore,xfer,xfer,mthilo,xfer,load,xfer,store")
4741 (set_attr "mode" "SI")
4742 (set_attr "length" "4,*,*,*,*,4,4,*,4,*,4,4,4,4,*,4,*")])
4744 (define_insn "*movsi_mips16"
4745 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,y,d,d,d,d,d,m")
4746 (match_operand:SI 1 "move_operand" "d,d,y,K,N,U,m,d"))]
4748 && (register_operand (operands[0], SImode)
4749 || register_operand (operands[1], SImode))"
4750 { return mips_output_move (operands[0], operands[1]); }
4751 [(set_attr "type" "arith,arith,arith,arith,arith,const,load,store")
4752 (set_attr "mode" "SI")
4753 (set_attr_alternative "length"
4757 (if_then_else (match_operand:VOID 1 "m16_uimm8_1")
4760 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1")
4765 (const_string "*")])])
4767 ;; On the mips16, we can split lw $r,N($r) into an add and a load,
4768 ;; when the original load is a 4 byte instruction but the add and the
4769 ;; load are 2 2 byte instructions.
4772 [(set (match_operand:SI 0 "register_operand")
4773 (mem:SI (plus:SI (match_dup 0)
4774 (match_operand:SI 1 "const_int_operand"))))]
4775 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
4776 && GET_CODE (operands[0]) == REG
4777 && M16_REG_P (REGNO (operands[0]))
4778 && GET_CODE (operands[1]) == CONST_INT
4779 && ((INTVAL (operands[1]) < 0
4780 && INTVAL (operands[1]) >= -0x80)
4781 || (INTVAL (operands[1]) >= 32 * 4
4782 && INTVAL (operands[1]) <= 31 * 4 + 0x7c)
4783 || (INTVAL (operands[1]) >= 0
4784 && INTVAL (operands[1]) < 32 * 4
4785 && (INTVAL (operands[1]) & 3) != 0))"
4786 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
4787 (set (match_dup 0) (mem:SI (plus:SI (match_dup 0) (match_dup 2))))]
4789 HOST_WIDE_INT val = INTVAL (operands[1]);
4792 operands[2] = const0_rtx;
4793 else if (val >= 32 * 4)
4797 operands[1] = GEN_INT (0x7c + off);
4798 operands[2] = GEN_INT (val - off - 0x7c);
4804 operands[1] = GEN_INT (off);
4805 operands[2] = GEN_INT (val - off);
4809 ;; On the mips16, we can split a load of certain constants into a load
4810 ;; and an add. This turns a 4 byte instruction into 2 2 byte
4814 [(set (match_operand:SI 0 "register_operand")
4815 (match_operand:SI 1 "const_int_operand"))]
4816 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
4817 && GET_CODE (operands[0]) == REG
4818 && M16_REG_P (REGNO (operands[0]))
4819 && GET_CODE (operands[1]) == CONST_INT
4820 && INTVAL (operands[1]) >= 0x100
4821 && INTVAL (operands[1]) <= 0xff + 0x7f"
4822 [(set (match_dup 0) (match_dup 1))
4823 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]
4825 int val = INTVAL (operands[1]);
4827 operands[1] = GEN_INT (0xff);
4828 operands[2] = GEN_INT (val - 0xff);
4831 ;; On the mips16, we can split a load of a negative constant into a
4832 ;; load and a neg. That's what mips_output_move will generate anyhow.
4835 [(set (match_operand:SI 0 "register_operand")
4836 (match_operand:SI 1 "const_int_operand"))]
4837 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
4838 && GET_CODE (operands[0]) == REG
4839 && M16_REG_P (REGNO (operands[0]))
4840 && GET_CODE (operands[1]) == CONST_INT
4841 && INTVAL (operands[1]) < 0
4842 && INTVAL (operands[1]) > - 0x8000"
4843 [(set (match_dup 0) (match_dup 1))
4844 (set (match_dup 0) (neg:SI (match_dup 0)))]
4845 { operands[1] = GEN_INT (- INTVAL (operands[1])); })
4847 ;; This insn handles moving CCmode values. It's really just a
4848 ;; slightly simplified copy of movsi_internal2, with additional cases
4849 ;; to move a condition register to a general register and to move
4850 ;; between the general registers and the floating point registers.
4852 (define_insn "movcc"
4853 [(set (match_operand:CC 0 "nonimmediate_operand" "=d,*d,*d,*m,*d,*f,*f,*f,*m")
4854 (match_operand:CC 1 "general_operand" "z,*d,*m,*d,*f,*d,*f,*m,*f"))]
4855 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
4856 { return mips_output_move (operands[0], operands[1]); }
4857 [(set_attr "type" "xfer,arith,load,store,xfer,xfer,fmove,fpload,fpstore")
4858 (set_attr "mode" "SI")
4859 (set_attr "length" "8,4,*,*,4,4,4,*,*")])
4861 ;; Reload condition code registers. reload_incc and reload_outcc
4862 ;; both handle moves from arbitrary operands into condition code
4863 ;; registers. reload_incc handles the more common case in which
4864 ;; a source operand is constrained to be in a condition-code
4865 ;; register, but has not been allocated to one.
4867 ;; Sometimes, such as in movcc, we have a CCmode destination whose
4868 ;; constraints do not include 'z'. reload_outcc handles the case
4869 ;; when such an operand is allocated to a condition-code register.
4871 ;; Note that reloads from a condition code register to some
4872 ;; other location can be done using ordinary moves. Moving
4873 ;; into a GPR takes a single movcc, moving elsewhere takes
4874 ;; two. We can leave these cases to the generic reload code.
4875 (define_expand "reload_incc"
4876 [(set (match_operand:CC 0 "fcc_register_operand" "=z")
4877 (match_operand:CC 1 "general_operand" ""))
4878 (clobber (match_operand:TF 2 "register_operand" "=&f"))]
4879 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
4881 mips_emit_fcc_reload (operands[0], operands[1], operands[2]);
4885 (define_expand "reload_outcc"
4886 [(set (match_operand:CC 0 "fcc_register_operand" "=z")
4887 (match_operand:CC 1 "register_operand" ""))
4888 (clobber (match_operand:TF 2 "register_operand" "=&f"))]
4889 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
4891 mips_emit_fcc_reload (operands[0], operands[1], operands[2]);
4895 ;; MIPS4 supports loading and storing a floating point register from
4896 ;; the sum of two general registers. We use two versions for each of
4897 ;; these four instructions: one where the two general registers are
4898 ;; SImode, and one where they are DImode. This is because general
4899 ;; registers will be in SImode when they hold 32 bit values, but,
4900 ;; since the 32 bit values are always sign extended, the [ls][wd]xc1
4901 ;; instructions will still work correctly.
4903 ;; ??? Perhaps it would be better to support these instructions by
4904 ;; modifying GO_IF_LEGITIMATE_ADDRESS and friends. However, since
4905 ;; these instructions can only be used to load and store floating
4906 ;; point registers, that would probably cause trouble in reload.
4909 [(set (match_operand:SF 0 "register_operand" "=f")
4910 (mem:SF (plus:SI (match_operand:SI 1 "register_operand" "d")
4911 (match_operand:SI 2 "register_operand" "d"))))]
4912 "ISA_HAS_FP4 && TARGET_HARD_FLOAT"
4914 [(set_attr "type" "fpidxload")
4915 (set_attr "mode" "SF")
4916 (set_attr "length" "4")])
4919 [(set (match_operand:SF 0 "register_operand" "=f")
4920 (mem:SF (plus:DI (match_operand:DI 1 "register_operand" "d")
4921 (match_operand:DI 2 "register_operand" "d"))))]
4922 "ISA_HAS_FP4 && TARGET_HARD_FLOAT"
4924 [(set_attr "type" "fpidxload")
4925 (set_attr "mode" "SF")
4926 (set_attr "length" "4")])
4929 [(set (match_operand:DF 0 "register_operand" "=f")
4930 (mem:DF (plus:SI (match_operand:SI 1 "register_operand" "d")
4931 (match_operand:SI 2 "register_operand" "d"))))]
4932 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
4934 [(set_attr "type" "fpidxload")
4935 (set_attr "mode" "DF")
4936 (set_attr "length" "4")])
4939 [(set (match_operand:DF 0 "register_operand" "=f")
4940 (mem:DF (plus:DI (match_operand:DI 1 "register_operand" "d")
4941 (match_operand:DI 2 "register_operand" "d"))))]
4942 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
4944 [(set_attr "type" "fpidxload")
4945 (set_attr "mode" "DF")
4946 (set_attr "length" "4")])
4949 [(set (mem:SF (plus:SI (match_operand:SI 1 "register_operand" "d")
4950 (match_operand:SI 2 "register_operand" "d")))
4951 (match_operand:SF 0 "register_operand" "f"))]
4952 "ISA_HAS_FP4 && TARGET_HARD_FLOAT"
4954 [(set_attr "type" "fpidxstore")
4955 (set_attr "mode" "SF")
4956 (set_attr "length" "4")])
4959 [(set (mem:SF (plus:DI (match_operand:DI 1 "register_operand" "d")
4960 (match_operand:DI 2 "register_operand" "d")))
4961 (match_operand:SF 0 "register_operand" "f"))]
4962 "ISA_HAS_FP4 && TARGET_HARD_FLOAT"
4964 [(set_attr "type" "fpidxstore")
4965 (set_attr "mode" "SF")
4966 (set_attr "length" "4")])
4969 [(set (mem:DF (plus:SI (match_operand:SI 1 "register_operand" "d")
4970 (match_operand:SI 2 "register_operand" "d")))
4971 (match_operand:DF 0 "register_operand" "f"))]
4972 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
4974 [(set_attr "type" "fpidxstore")
4975 (set_attr "mode" "DF")
4976 (set_attr "length" "4")])
4979 [(set (mem:DF (plus:DI (match_operand:DI 1 "register_operand" "d")
4980 (match_operand:DI 2 "register_operand" "d")))
4981 (match_operand:DF 0 "register_operand" "f"))]
4982 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
4984 [(set_attr "type" "fpidxstore")
4985 (set_attr "mode" "DF")
4986 (set_attr "length" "4")])
4988 ;; 16-bit Integer moves
4990 ;; Unlike most other insns, the move insns can't be split with
4991 ;; different predicates, because register spilling and other parts of
4992 ;; the compiler, have memoized the insn number already.
4993 ;; Unsigned loads are used because LOAD_EXTEND_OP returns ZERO_EXTEND.
4995 (define_expand "movhi"
4996 [(set (match_operand:HI 0 "")
4997 (match_operand:HI 1 ""))]
5000 if (mips_legitimize_move (HImode, operands[0], operands[1]))
5004 (define_insn "*movhi_internal"
5005 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,m,*d,*f,*f,*x")
5006 (match_operand:HI 1 "move_operand" "d,I,m,dJ,*f,*d,*f,*d"))]
5008 && (register_operand (operands[0], HImode)
5009 || reg_or_0_operand (operands[1], HImode))"
5019 [(set_attr "type" "arith,arith,load,store,xfer,xfer,fmove,mthilo")
5020 (set_attr "mode" "HI")
5021 (set_attr "length" "4,4,*,*,4,4,4,4")])
5023 (define_insn "*movhi_mips16"
5024 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m")
5025 (match_operand:HI 1 "move_operand" "d,d,y,K,N,m,d"))]
5027 && (register_operand (operands[0], HImode)
5028 || register_operand (operands[1], HImode))"
5037 [(set_attr "type" "arith,arith,arith,arith,arith,load,store")
5038 (set_attr "mode" "HI")
5039 (set_attr_alternative "length"
5043 (if_then_else (match_operand:VOID 1 "m16_uimm8_1")
5046 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1")
5050 (const_string "*")])])
5053 ;; On the mips16, we can split lh $r,N($r) into an add and a load,
5054 ;; when the original load is a 4 byte instruction but the add and the
5055 ;; load are 2 2 byte instructions.
5058 [(set (match_operand:HI 0 "register_operand")
5059 (mem:HI (plus:SI (match_dup 0)
5060 (match_operand:SI 1 "const_int_operand"))))]
5061 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
5062 && GET_CODE (operands[0]) == REG
5063 && M16_REG_P (REGNO (operands[0]))
5064 && GET_CODE (operands[1]) == CONST_INT
5065 && ((INTVAL (operands[1]) < 0
5066 && INTVAL (operands[1]) >= -0x80)
5067 || (INTVAL (operands[1]) >= 32 * 2
5068 && INTVAL (operands[1]) <= 31 * 2 + 0x7e)
5069 || (INTVAL (operands[1]) >= 0
5070 && INTVAL (operands[1]) < 32 * 2
5071 && (INTVAL (operands[1]) & 1) != 0))"
5072 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
5073 (set (match_dup 0) (mem:HI (plus:SI (match_dup 0) (match_dup 2))))]
5075 HOST_WIDE_INT val = INTVAL (operands[1]);
5078 operands[2] = const0_rtx;
5079 else if (val >= 32 * 2)
5083 operands[1] = GEN_INT (0x7e + off);
5084 operands[2] = GEN_INT (val - off - 0x7e);
5090 operands[1] = GEN_INT (off);
5091 operands[2] = GEN_INT (val - off);
5095 ;; 8-bit Integer moves
5097 ;; Unlike most other insns, the move insns can't be split with
5098 ;; different predicates, because register spilling and other parts of
5099 ;; the compiler, have memoized the insn number already.
5100 ;; Unsigned loads are used because LOAD_EXTEND_OP returns ZERO_EXTEND.
5102 (define_expand "movqi"
5103 [(set (match_operand:QI 0 "")
5104 (match_operand:QI 1 ""))]
5107 if (mips_legitimize_move (QImode, operands[0], operands[1]))
5111 (define_insn "*movqi_internal"
5112 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,m,*d,*f,*f,*x")
5113 (match_operand:QI 1 "move_operand" "d,I,m,dJ,*f,*d,*f,*d"))]
5115 && (register_operand (operands[0], QImode)
5116 || reg_or_0_operand (operands[1], QImode))"
5126 [(set_attr "type" "arith,arith,load,store,xfer,xfer,fmove,mthilo")
5127 (set_attr "mode" "QI")
5128 (set_attr "length" "4,4,*,*,4,4,4,4")])
5130 (define_insn "*movqi_mips16"
5131 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m")
5132 (match_operand:QI 1 "move_operand" "d,d,y,K,N,m,d"))]
5134 && (register_operand (operands[0], QImode)
5135 || register_operand (operands[1], QImode))"
5144 [(set_attr "type" "arith,arith,arith,arith,arith,load,store")
5145 (set_attr "mode" "QI")
5146 (set_attr "length" "4,4,4,4,8,*,*")])
5148 ;; On the mips16, we can split lb $r,N($r) into an add and a load,
5149 ;; when the original load is a 4 byte instruction but the add and the
5150 ;; load are 2 2 byte instructions.
5153 [(set (match_operand:QI 0 "register_operand")
5154 (mem:QI (plus:SI (match_dup 0)
5155 (match_operand:SI 1 "const_int_operand"))))]
5156 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
5157 && GET_CODE (operands[0]) == REG
5158 && M16_REG_P (REGNO (operands[0]))
5159 && GET_CODE (operands[1]) == CONST_INT
5160 && ((INTVAL (operands[1]) < 0
5161 && INTVAL (operands[1]) >= -0x80)
5162 || (INTVAL (operands[1]) >= 32
5163 && INTVAL (operands[1]) <= 31 + 0x7f))"
5164 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
5165 (set (match_dup 0) (mem:QI (plus:SI (match_dup 0) (match_dup 2))))]
5167 HOST_WIDE_INT val = INTVAL (operands[1]);
5170 operands[2] = const0_rtx;
5173 operands[1] = GEN_INT (0x7f);
5174 operands[2] = GEN_INT (val - 0x7f);
5178 ;; 32-bit floating point moves
5180 (define_expand "movsf"
5181 [(set (match_operand:SF 0 "")
5182 (match_operand:SF 1 ""))]
5185 if (mips_legitimize_move (SFmode, operands[0], operands[1]))
5189 (define_insn "*movsf_hardfloat"
5190 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,f,m,*f,*d,*d,*d,*m")
5191 (match_operand:SF 1 "move_operand" "f,G,m,fG,*d,*f,*G*d,*m,*d"))]
5193 && (register_operand (operands[0], SFmode)
5194 || reg_or_0_operand (operands[1], SFmode))"
5195 { return mips_output_move (operands[0], operands[1]); }
5196 [(set_attr "type" "fmove,xfer,fpload,fpstore,xfer,xfer,arith,load,store")
5197 (set_attr "mode" "SF")
5198 (set_attr "length" "4,4,*,*,4,4,4,*,*")])
5200 (define_insn "*movsf_softfloat"
5201 [(set (match_operand:SF 0 "nonimmediate_operand" "=d,d,m")
5202 (match_operand:SF 1 "move_operand" "Gd,m,d"))]
5203 "TARGET_SOFT_FLOAT && !TARGET_MIPS16
5204 && (register_operand (operands[0], SFmode)
5205 || reg_or_0_operand (operands[1], SFmode))"
5206 { return mips_output_move (operands[0], operands[1]); }
5207 [(set_attr "type" "arith,load,store")
5208 (set_attr "mode" "SF")
5209 (set_attr "length" "4,*,*")])
5211 (define_insn "*movsf_mips16"
5212 [(set (match_operand:SF 0 "nonimmediate_operand" "=d,y,d,d,m")
5213 (match_operand:SF 1 "move_operand" "d,d,y,m,d"))]
5215 && (register_operand (operands[0], SFmode)
5216 || register_operand (operands[1], SFmode))"
5217 { return mips_output_move (operands[0], operands[1]); }
5218 [(set_attr "type" "arith,arith,arith,load,store")
5219 (set_attr "mode" "SF")
5220 (set_attr "length" "4,4,4,*,*")])
5223 ;; 64-bit floating point moves
5225 (define_expand "movdf"
5226 [(set (match_operand:DF 0 "")
5227 (match_operand:DF 1 ""))]
5230 if (mips_legitimize_move (DFmode, operands[0], operands[1]))
5234 (define_insn "*movdf_hardfloat_64bit"
5235 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,m,*f,*d,*d,*d,*m")
5236 (match_operand:DF 1 "move_operand" "f,G,m,fG,*d,*f,*d*G,*m,*d"))]
5237 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_64BIT
5238 && (register_operand (operands[0], DFmode)
5239 || reg_or_0_operand (operands[1], DFmode))"
5240 { return mips_output_move (operands[0], operands[1]); }
5241 [(set_attr "type" "fmove,xfer,fpload,fpstore,xfer,xfer,arith,load,store")
5242 (set_attr "mode" "DF")
5243 (set_attr "length" "4,4,*,*,4,4,4,*,*")])
5245 (define_insn "*movdf_hardfloat_32bit"
5246 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,m,*f,*d,*d,*d,*m")
5247 (match_operand:DF 1 "move_operand" "f,G,m,fG,*d,*f,*d*G,*m,*d"))]
5248 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT
5249 && (register_operand (operands[0], DFmode)
5250 || reg_or_0_operand (operands[1], DFmode))"
5251 { return mips_output_move (operands[0], operands[1]); }
5252 [(set_attr "type" "fmove,xfer,fpload,fpstore,xfer,xfer,arith,load,store")
5253 (set_attr "mode" "DF")
5254 (set_attr "length" "4,8,*,*,8,8,8,*,*")])
5256 (define_insn "*movdf_softfloat"
5257 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,m,d,f,f")
5258 (match_operand:DF 1 "move_operand" "dG,m,dG,f,d,f"))]
5259 "(TARGET_SOFT_FLOAT || TARGET_SINGLE_FLOAT) && !TARGET_MIPS16
5260 && (register_operand (operands[0], DFmode)
5261 || reg_or_0_operand (operands[1], DFmode))"
5262 { return mips_output_move (operands[0], operands[1]); }
5263 [(set_attr "type" "arith,load,store,xfer,xfer,fmove")
5264 (set_attr "mode" "DF")
5265 (set_attr "length" "8,*,*,4,4,4")])
5267 (define_insn "*movdf_mips16"
5268 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,y,d,d,m")
5269 (match_operand:DF 1 "move_operand" "d,d,y,m,d"))]
5271 && (register_operand (operands[0], DFmode)
5272 || register_operand (operands[1], DFmode))"
5273 { return mips_output_move (operands[0], operands[1]); }
5274 [(set_attr "type" "arith,arith,arith,load,store")
5275 (set_attr "mode" "DF")
5276 (set_attr "length" "8,8,8,*,*")])
5279 [(set (match_operand:DI 0 "nonimmediate_operand")
5280 (match_operand:DI 1 "move_operand"))]
5281 "reload_completed && !TARGET_64BIT
5282 && mips_split_64bit_move_p (operands[0], operands[1])"
5285 mips_split_64bit_move (operands[0], operands[1]);
5290 [(set (match_operand:DF 0 "nonimmediate_operand")
5291 (match_operand:DF 1 "move_operand"))]
5292 "reload_completed && !TARGET_64BIT
5293 && mips_split_64bit_move_p (operands[0], operands[1])"
5296 mips_split_64bit_move (operands[0], operands[1]);
5300 ;; The HI and LO registers are not truly independent. If we move an mthi
5301 ;; instruction before an mflo instruction, it will make the result of the
5302 ;; mflo unpredictable. The same goes for mtlo and mfhi.
5304 ;; We cope with this by making the mflo and mfhi patterns use both HI and LO.
5305 ;; Operand 1 is the register we want, operand 2 is the other one.
5307 (define_insn "mfhilo_di"
5308 [(set (match_operand:DI 0 "register_operand" "=d,d")
5309 (unspec:DI [(match_operand:DI 1 "register_operand" "h,l")
5310 (match_operand:DI 2 "register_operand" "l,h")]
5314 [(set_attr "type" "mfhilo")])
5316 (define_insn "mfhilo_si"
5317 [(set (match_operand:SI 0 "register_operand" "=d,d")
5318 (unspec:SI [(match_operand:SI 1 "register_operand" "h,l")
5319 (match_operand:SI 2 "register_operand" "l,h")]
5323 [(set_attr "type" "mfhilo")])
5325 ;; Patterns for loading or storing part of a paired floating point
5326 ;; register. We need them because odd-numbered floating-point registers
5327 ;; are not fully independent: see mips_split_64bit_move.
5329 ;; Load the low word of operand 0 with operand 1.
5330 (define_insn "load_df_low"
5331 [(set (match_operand:DF 0 "register_operand" "=f,f")
5332 (unspec:DF [(match_operand:SI 1 "general_operand" "dJ,m")]
5333 UNSPEC_LOAD_DF_LOW))]
5334 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT"
5336 operands[0] = mips_subword (operands[0], 0);
5337 return mips_output_move (operands[0], operands[1]);
5339 [(set_attr "type" "xfer,fpload")
5340 (set_attr "mode" "SF")])
5342 ;; Load the high word of operand 0 from operand 1, preserving the value
5344 (define_insn "load_df_high"
5345 [(set (match_operand:DF 0 "register_operand" "=f,f")
5346 (unspec:DF [(match_operand:SI 1 "general_operand" "dJ,m")
5347 (match_operand:DF 2 "register_operand" "0,0")]
5348 UNSPEC_LOAD_DF_HIGH))]
5349 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT"
5351 operands[0] = mips_subword (operands[0], 1);
5352 return mips_output_move (operands[0], operands[1]);
5354 [(set_attr "type" "xfer,fpload")
5355 (set_attr "mode" "SF")])
5357 ;; Store the high word of operand 1 in operand 0. The corresponding
5358 ;; low-word move is done in the normal way.
5359 (define_insn "store_df_high"
5360 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,m")
5361 (unspec:SI [(match_operand:DF 1 "register_operand" "f,f")]
5362 UNSPEC_STORE_DF_HIGH))]
5363 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT"
5365 operands[1] = mips_subword (operands[1], 1);
5366 return mips_output_move (operands[0], operands[1]);
5368 [(set_attr "type" "xfer,fpstore")
5369 (set_attr "mode" "SF")])
5371 ;; Insn to initialize $gp for n32/n64 abicalls. Operand 0 is the offset
5372 ;; of _gp from the start of this function. Operand 1 is the incoming
5373 ;; function address.
5374 (define_insn_and_split "loadgp"
5375 [(unspec_volatile [(match_operand 0 "" "")
5376 (match_operand 1 "register_operand" "")] UNSPEC_LOADGP)]
5377 "TARGET_ABICALLS && TARGET_NEWABI"
5380 [(set (match_dup 2) (match_dup 3))
5381 (set (match_dup 2) (match_dup 4))
5382 (set (match_dup 2) (match_dup 5))]
5384 operands[2] = pic_offset_table_rtx;
5385 operands[3] = gen_rtx_HIGH (Pmode, operands[0]);
5386 operands[4] = gen_rtx_PLUS (Pmode, operands[2], operands[1]);
5387 operands[5] = gen_rtx_LO_SUM (Pmode, operands[2], operands[0]);
5389 [(set_attr "length" "12")])
5391 ;; The use of gp is hidden when not using explicit relocations.
5392 ;; This blockage instruction prevents the gp load from being
5393 ;; scheduled after an implicit use of gp. It also prevents
5394 ;; the load from being deleted as dead.
5395 (define_insn "loadgp_blockage"
5396 [(unspec_volatile [(reg:DI 28)] UNSPEC_BLOCKAGE)]
5399 [(set_attr "type" "unknown")
5400 (set_attr "mode" "none")
5401 (set_attr "length" "0")])
5403 ;; Emit a .cprestore directive, which expands to a single store instruction.
5404 ;; Note that we continue to use .cprestore for explicit reloc code so that
5405 ;; jals inside inlines asms will work correctly.
5406 (define_insn "cprestore"
5407 [(unspec_volatile [(match_operand 0 "const_int_operand" "")]
5411 [(set_attr "type" "store")
5412 (set_attr "length" "4")])
5414 ;; Block moves, see mips.c for more details.
5415 ;; Argument 0 is the destination
5416 ;; Argument 1 is the source
5417 ;; Argument 2 is the length
5418 ;; Argument 3 is the alignment
5420 (define_expand "movstrsi"
5421 [(parallel [(set (match_operand:BLK 0 "general_operand")
5422 (match_operand:BLK 1 "general_operand"))
5423 (use (match_operand:SI 2 ""))
5424 (use (match_operand:SI 3 "const_int_operand"))])]
5425 "!TARGET_MIPS16 && !TARGET_MEMCPY"
5427 if (mips_expand_block_move (operands[0], operands[1], operands[2]))
5434 ;; ....................
5438 ;; ....................
5440 ;; Many of these instructions use trivial define_expands, because we
5441 ;; want to use a different set of constraints when TARGET_MIPS16.
5443 (define_expand "ashlsi3"
5444 [(set (match_operand:SI 0 "register_operand")
5445 (ashift:SI (match_operand:SI 1 "register_operand")
5446 (match_operand:SI 2 "arith_operand")))]
5449 /* On the mips16, a shift of more than 8 is a four byte instruction,
5450 so, for a shift between 8 and 16, it is just as fast to do two
5451 shifts of 8 or less. If there is a lot of shifting going on, we
5452 may win in CSE. Otherwise combine will put the shifts back
5453 together again. This can be called by function_arg, so we must
5454 be careful not to allocate a new register if we've reached the
5458 && GET_CODE (operands[2]) == CONST_INT
5459 && INTVAL (operands[2]) > 8
5460 && INTVAL (operands[2]) <= 16
5461 && ! reload_in_progress
5462 && ! reload_completed)
5464 rtx temp = gen_reg_rtx (SImode);
5466 emit_insn (gen_ashlsi3_internal2 (temp, operands[1], GEN_INT (8)));
5467 emit_insn (gen_ashlsi3_internal2 (operands[0], temp,
5468 GEN_INT (INTVAL (operands[2]) - 8)));
5473 (define_insn "ashlsi3_internal1"
5474 [(set (match_operand:SI 0 "register_operand" "=d")
5475 (ashift:SI (match_operand:SI 1 "register_operand" "d")
5476 (match_operand:SI 2 "arith_operand" "dI")))]
5479 if (GET_CODE (operands[2]) == CONST_INT)
5480 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
5482 return "sll\t%0,%1,%2";
5484 [(set_attr "type" "shift")
5485 (set_attr "mode" "SI")])
5487 (define_insn "ashlsi3_internal1_extend"
5488 [(set (match_operand:DI 0 "register_operand" "=d")
5489 (sign_extend:DI (ashift:SI (match_operand:SI 1 "register_operand" "d")
5490 (match_operand:SI 2 "arith_operand" "dI"))))]
5491 "TARGET_64BIT && !TARGET_MIPS16"
5493 if (GET_CODE (operands[2]) == CONST_INT)
5494 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
5496 return "sll\t%0,%1,%2";
5498 [(set_attr "type" "shift")
5499 (set_attr "mode" "DI")])
5502 (define_insn "ashlsi3_internal2"
5503 [(set (match_operand:SI 0 "register_operand" "=d,d")
5504 (ashift:SI (match_operand:SI 1 "register_operand" "0,d")
5505 (match_operand:SI 2 "arith_operand" "d,I")))]
5508 if (which_alternative == 0)
5509 return "sll\t%0,%2";
5511 if (GET_CODE (operands[2]) == CONST_INT)
5512 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
5514 return "sll\t%0,%1,%2";
5516 [(set_attr "type" "shift")
5517 (set_attr "mode" "SI")
5518 (set_attr_alternative "length"
5520 (if_then_else (match_operand:VOID 2 "m16_uimm3_b")
5524 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
5527 [(set (match_operand:SI 0 "register_operand")
5528 (ashift:SI (match_operand:SI 1 "register_operand")
5529 (match_operand:SI 2 "const_int_operand")))]
5530 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
5531 && GET_CODE (operands[2]) == CONST_INT
5532 && INTVAL (operands[2]) > 8
5533 && INTVAL (operands[2]) <= 16"
5534 [(set (match_dup 0) (ashift:SI (match_dup 1) (const_int 8)))
5535 (set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2)))]
5536 { operands[2] = GEN_INT (INTVAL (operands[2]) - 8); })
5538 (define_expand "ashldi3"
5539 [(parallel [(set (match_operand:DI 0 "register_operand")
5540 (ashift:DI (match_operand:DI 1 "register_operand")
5541 (match_operand:SI 2 "arith_operand")))
5542 (clobber (match_dup 3))])]
5543 "TARGET_64BIT || (!TARGET_DEBUG_G_MODE && !TARGET_MIPS16)"
5547 /* On the mips16, a shift of more than 8 is a four byte
5548 instruction, so, for a shift between 8 and 16, it is just as
5549 fast to do two shifts of 8 or less. If there is a lot of
5550 shifting going on, we may win in CSE. Otherwise combine will
5551 put the shifts back together again. This can be called by
5552 function_arg, so we must be careful not to allocate a new
5553 register if we've reached the reload pass. */
5556 && GET_CODE (operands[2]) == CONST_INT
5557 && INTVAL (operands[2]) > 8
5558 && INTVAL (operands[2]) <= 16
5559 && ! reload_in_progress
5560 && ! reload_completed)
5562 rtx temp = gen_reg_rtx (DImode);
5564 emit_insn (gen_ashldi3_internal4 (temp, operands[1], GEN_INT (8)));
5565 emit_insn (gen_ashldi3_internal4 (operands[0], temp,
5566 GEN_INT (INTVAL (operands[2]) - 8)));
5570 emit_insn (gen_ashldi3_internal4 (operands[0], operands[1],
5575 operands[3] = gen_reg_rtx (SImode);
5579 (define_insn "ashldi3_internal"
5580 [(set (match_operand:DI 0 "register_operand" "=&d")
5581 (ashift:DI (match_operand:DI 1 "register_operand" "d")
5582 (match_operand:SI 2 "register_operand" "d")))
5583 (clobber (match_operand:SI 3 "register_operand" "=d"))]
5584 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16"
5601 [(set_attr "type" "multi")
5602 (set_attr "mode" "SI")
5603 (set_attr "length" "48")])
5606 (define_insn "ashldi3_internal2"
5607 [(set (match_operand:DI 0 "register_operand" "=d")
5608 (ashift:DI (match_operand:DI 1 "register_operand" "d")
5609 (match_operand:SI 2 "small_int" "IJK")))
5610 (clobber (match_operand:SI 3 "register_operand" "=d"))]
5611 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
5612 && (INTVAL (operands[2]) & 32) != 0"
5614 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
5615 return "sll\t%M0,%L1,%2\;move\t%L0,%.";
5617 [(set_attr "type" "multi")
5618 (set_attr "mode" "DI")
5619 (set_attr "length" "8")])
5623 [(set (match_operand:DI 0 "register_operand")
5624 (ashift:DI (match_operand:DI 1 "register_operand")
5625 (match_operand:SI 2 "small_int")))
5626 (clobber (match_operand:SI 3 "register_operand"))]
5627 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
5628 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
5629 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
5630 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
5631 && (INTVAL (operands[2]) & 32) != 0"
5633 [(set (subreg:SI (match_dup 0) 4) (ashift:SI (subreg:SI (match_dup 1) 0) (match_dup 2)))
5634 (set (subreg:SI (match_dup 0) 0) (const_int 0))]
5636 "operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);")
5640 [(set (match_operand:DI 0 "register_operand")
5641 (ashift:DI (match_operand:DI 1 "register_operand")
5642 (match_operand:SI 2 "small_int")))
5643 (clobber (match_operand:SI 3 "register_operand"))]
5644 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
5645 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
5646 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
5647 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
5648 && (INTVAL (operands[2]) & 32) != 0"
5650 [(set (subreg:SI (match_dup 0) 0) (ashift:SI (subreg:SI (match_dup 1) 4) (match_dup 2)))
5651 (set (subreg:SI (match_dup 0) 4) (const_int 0))]
5653 "operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);")
5656 (define_insn "ashldi3_internal3"
5657 [(set (match_operand:DI 0 "register_operand" "=d")
5658 (ashift:DI (match_operand:DI 1 "register_operand" "d")
5659 (match_operand:SI 2 "small_int" "IJK")))
5660 (clobber (match_operand:SI 3 "register_operand" "=d"))]
5661 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
5662 && (INTVAL (operands[2]) & 63) < 32
5663 && (INTVAL (operands[2]) & 63) != 0"
5665 int amount = INTVAL (operands[2]);
5667 operands[2] = GEN_INT (amount & 31);
5668 operands[4] = GEN_INT ((-amount) & 31);
5670 return "sll\t%M0,%M1,%2\;srl\t%3,%L1,%4\;or\t%M0,%M0,%3\;sll\t%L0,%L1,%2";
5672 [(set_attr "type" "multi")
5673 (set_attr "mode" "DI")
5674 (set_attr "length" "16")])
5678 [(set (match_operand:DI 0 "register_operand")
5679 (ashift:DI (match_operand:DI 1 "register_operand")
5680 (match_operand:SI 2 "small_int")))
5681 (clobber (match_operand:SI 3 "register_operand"))]
5682 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
5683 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
5684 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
5685 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
5686 && (INTVAL (operands[2]) & 63) < 32
5687 && (INTVAL (operands[2]) & 63) != 0"
5689 [(set (subreg:SI (match_dup 0) 4)
5690 (ashift:SI (subreg:SI (match_dup 1) 4)
5694 (lshiftrt:SI (subreg:SI (match_dup 1) 0)
5697 (set (subreg:SI (match_dup 0) 4)
5698 (ior:SI (subreg:SI (match_dup 0) 4)
5701 (set (subreg:SI (match_dup 0) 0)
5702 (ashift:SI (subreg:SI (match_dup 1) 0)
5705 int amount = INTVAL (operands[2]);
5706 operands[2] = GEN_INT (amount & 31);
5707 operands[4] = GEN_INT ((-amount) & 31);
5712 [(set (match_operand:DI 0 "register_operand")
5713 (ashift:DI (match_operand:DI 1 "register_operand")
5714 (match_operand:SI 2 "small_int")))
5715 (clobber (match_operand:SI 3 "register_operand"))]
5716 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
5717 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
5718 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
5719 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
5720 && (INTVAL (operands[2]) & 63) < 32
5721 && (INTVAL (operands[2]) & 63) != 0"
5723 [(set (subreg:SI (match_dup 0) 0)
5724 (ashift:SI (subreg:SI (match_dup 1) 0)
5728 (lshiftrt:SI (subreg:SI (match_dup 1) 4)
5731 (set (subreg:SI (match_dup 0) 0)
5732 (ior:SI (subreg:SI (match_dup 0) 0)
5735 (set (subreg:SI (match_dup 0) 4)
5736 (ashift:SI (subreg:SI (match_dup 1) 4)
5739 int amount = INTVAL (operands[2]);
5740 operands[2] = GEN_INT (amount & 31);
5741 operands[4] = GEN_INT ((-amount) & 31);
5745 (define_insn "ashldi3_internal4"
5746 [(set (match_operand:DI 0 "register_operand" "=d")
5747 (ashift:DI (match_operand:DI 1 "register_operand" "d")
5748 (match_operand:SI 2 "arith_operand" "dI")))]
5749 "TARGET_64BIT && !TARGET_MIPS16"
5751 if (GET_CODE (operands[2]) == CONST_INT)
5752 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
5754 return "dsll\t%0,%1,%2";
5756 [(set_attr "type" "shift")
5757 (set_attr "mode" "DI")])
5760 [(set (match_operand:DI 0 "register_operand" "=d,d")
5761 (ashift:DI (match_operand:DI 1 "register_operand" "0,d")
5762 (match_operand:SI 2 "arith_operand" "d,I")))]
5763 "TARGET_64BIT && TARGET_MIPS16"
5765 if (which_alternative == 0)
5766 return "dsll\t%0,%2";
5768 if (GET_CODE (operands[2]) == CONST_INT)
5769 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
5771 return "dsll\t%0,%1,%2";
5773 [(set_attr "type" "shift")
5774 (set_attr "mode" "DI")
5775 (set_attr_alternative "length"
5777 (if_then_else (match_operand:VOID 2 "m16_uimm3_b")
5782 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
5785 [(set (match_operand:DI 0 "register_operand")
5786 (ashift:DI (match_operand:DI 1 "register_operand")
5787 (match_operand:SI 2 "const_int_operand")))]
5788 "TARGET_MIPS16 && TARGET_64BIT && !TARGET_DEBUG_D_MODE
5790 && GET_CODE (operands[2]) == CONST_INT
5791 && INTVAL (operands[2]) > 8
5792 && INTVAL (operands[2]) <= 16"
5793 [(set (match_dup 0) (ashift:DI (match_dup 1) (const_int 8)))
5794 (set (match_dup 0) (ashift:DI (match_dup 0) (match_dup 2)))]
5795 { operands[2] = GEN_INT (INTVAL (operands[2]) - 8); })
5797 (define_expand "ashrsi3"
5798 [(set (match_operand:SI 0 "register_operand")
5799 (ashiftrt:SI (match_operand:SI 1 "register_operand")
5800 (match_operand:SI 2 "arith_operand")))]
5803 /* On the mips16, a shift of more than 8 is a four byte instruction,
5804 so, for a shift between 8 and 16, it is just as fast to do two
5805 shifts of 8 or less. If there is a lot of shifting going on, we
5806 may win in CSE. Otherwise combine will put the shifts back
5810 && GET_CODE (operands[2]) == CONST_INT
5811 && INTVAL (operands[2]) > 8
5812 && INTVAL (operands[2]) <= 16)
5814 rtx temp = gen_reg_rtx (SImode);
5816 emit_insn (gen_ashrsi3_internal2 (temp, operands[1], GEN_INT (8)));
5817 emit_insn (gen_ashrsi3_internal2 (operands[0], temp,
5818 GEN_INT (INTVAL (operands[2]) - 8)));
5823 (define_insn "ashrsi3_internal1"
5824 [(set (match_operand:SI 0 "register_operand" "=d")
5825 (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
5826 (match_operand:SI 2 "arith_operand" "dI")))]
5829 if (GET_CODE (operands[2]) == CONST_INT)
5830 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
5832 return "sra\t%0,%1,%2";
5834 [(set_attr "type" "shift")
5835 (set_attr "mode" "SI")])
5837 (define_insn "ashrsi3_internal2"
5838 [(set (match_operand:SI 0 "register_operand" "=d,d")
5839 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0,d")
5840 (match_operand:SI 2 "arith_operand" "d,I")))]
5843 if (which_alternative == 0)
5844 return "sra\t%0,%2";
5846 if (GET_CODE (operands[2]) == CONST_INT)
5847 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
5849 return "sra\t%0,%1,%2";
5851 [(set_attr "type" "shift")
5852 (set_attr "mode" "SI")
5853 (set_attr_alternative "length"
5855 (if_then_else (match_operand:VOID 2 "m16_uimm3_b")
5860 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
5863 [(set (match_operand:SI 0 "register_operand")
5864 (ashiftrt:SI (match_operand:SI 1 "register_operand")
5865 (match_operand:SI 2 "const_int_operand")))]
5866 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
5867 && GET_CODE (operands[2]) == CONST_INT
5868 && INTVAL (operands[2]) > 8
5869 && INTVAL (operands[2]) <= 16"
5870 [(set (match_dup 0) (ashiftrt:SI (match_dup 1) (const_int 8)))
5871 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (match_dup 2)))]
5872 { operands[2] = GEN_INT (INTVAL (operands[2]) - 8); })
5874 (define_expand "ashrdi3"
5875 [(parallel [(set (match_operand:DI 0 "register_operand")
5876 (ashiftrt:DI (match_operand:DI 1 "register_operand")
5877 (match_operand:SI 2 "arith_operand")))
5878 (clobber (match_dup 3))])]
5879 "TARGET_64BIT || (!TARGET_DEBUG_G_MODE && !TARGET_MIPS16)"
5883 /* On the mips16, a shift of more than 8 is a four byte
5884 instruction, so, for a shift between 8 and 16, it is just as
5885 fast to do two shifts of 8 or less. If there is a lot of
5886 shifting going on, we may win in CSE. Otherwise combine will
5887 put the shifts back together again. */
5890 && GET_CODE (operands[2]) == CONST_INT
5891 && INTVAL (operands[2]) > 8
5892 && INTVAL (operands[2]) <= 16)
5894 rtx temp = gen_reg_rtx (DImode);
5896 emit_insn (gen_ashrdi3_internal4 (temp, operands[1], GEN_INT (8)));
5897 emit_insn (gen_ashrdi3_internal4 (operands[0], temp,
5898 GEN_INT (INTVAL (operands[2]) - 8)));
5902 emit_insn (gen_ashrdi3_internal4 (operands[0], operands[1],
5907 operands[3] = gen_reg_rtx (SImode);
5911 (define_insn "ashrdi3_internal"
5912 [(set (match_operand:DI 0 "register_operand" "=&d")
5913 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
5914 (match_operand:SI 2 "register_operand" "d")))
5915 (clobber (match_operand:SI 3 "register_operand" "=d"))]
5916 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16"
5933 [(set_attr "type" "multi")
5934 (set_attr "mode" "DI")
5935 (set_attr "length" "48")])
5938 (define_insn "ashrdi3_internal2"
5939 [(set (match_operand:DI 0 "register_operand" "=d")
5940 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
5941 (match_operand:SI 2 "small_int" "IJK")))
5942 (clobber (match_operand:SI 3 "register_operand" "=d"))]
5943 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && (INTVAL (operands[2]) & 32) != 0"
5945 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
5946 return "sra\t%L0,%M1,%2\;sra\t%M0,%M1,31";
5948 [(set_attr "type" "multi")
5949 (set_attr "mode" "DI")
5950 (set_attr "length" "8")])
5954 [(set (match_operand:DI 0 "register_operand")
5955 (ashiftrt:DI (match_operand:DI 1 "register_operand")
5956 (match_operand:SI 2 "small_int")))
5957 (clobber (match_operand:SI 3 "register_operand"))]
5958 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
5959 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
5960 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
5961 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
5962 && (INTVAL (operands[2]) & 32) != 0"
5964 [(set (subreg:SI (match_dup 0) 0) (ashiftrt:SI (subreg:SI (match_dup 1) 4) (match_dup 2)))
5965 (set (subreg:SI (match_dup 0) 4) (ashiftrt:SI (subreg:SI (match_dup 1) 4) (const_int 31)))]
5967 "operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);")
5971 [(set (match_operand:DI 0 "register_operand")
5972 (ashiftrt:DI (match_operand:DI 1 "register_operand")
5973 (match_operand:SI 2 "small_int")))
5974 (clobber (match_operand:SI 3 "register_operand"))]
5975 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
5976 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
5977 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
5978 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
5979 && (INTVAL (operands[2]) & 32) != 0"
5981 [(set (subreg:SI (match_dup 0) 4) (ashiftrt:SI (subreg:SI (match_dup 1) 0) (match_dup 2)))
5982 (set (subreg:SI (match_dup 0) 0) (ashiftrt:SI (subreg:SI (match_dup 1) 0) (const_int 31)))]
5984 "operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);")
5987 (define_insn "ashrdi3_internal3"
5988 [(set (match_operand:DI 0 "register_operand" "=d")
5989 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
5990 (match_operand:SI 2 "small_int" "IJK")))
5991 (clobber (match_operand:SI 3 "register_operand" "=d"))]
5992 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
5993 && (INTVAL (operands[2]) & 63) < 32
5994 && (INTVAL (operands[2]) & 63) != 0"
5996 int amount = INTVAL (operands[2]);
5998 operands[2] = GEN_INT (amount & 31);
5999 operands[4] = GEN_INT ((-amount) & 31);
6001 return "srl\t%L0,%L1,%2\;sll\t%3,%M1,%4\;or\t%L0,%L0,%3\;sra\t%M0,%M1,%2";
6003 [(set_attr "type" "multi")
6004 (set_attr "mode" "DI")
6005 (set_attr "length" "16")])
6009 [(set (match_operand:DI 0 "register_operand")
6010 (ashiftrt:DI (match_operand:DI 1 "register_operand")
6011 (match_operand:SI 2 "small_int")))
6012 (clobber (match_operand:SI 3 "register_operand"))]
6013 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
6014 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
6015 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
6016 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
6017 && (INTVAL (operands[2]) & 63) < 32
6018 && (INTVAL (operands[2]) & 63) != 0"
6020 [(set (subreg:SI (match_dup 0) 0)
6021 (lshiftrt:SI (subreg:SI (match_dup 1) 0)
6025 (ashift:SI (subreg:SI (match_dup 1) 4)
6028 (set (subreg:SI (match_dup 0) 0)
6029 (ior:SI (subreg:SI (match_dup 0) 0)
6032 (set (subreg:SI (match_dup 0) 4)
6033 (ashiftrt:SI (subreg:SI (match_dup 1) 4)
6036 int amount = INTVAL (operands[2]);
6037 operands[2] = GEN_INT (amount & 31);
6038 operands[4] = GEN_INT ((-amount) & 31);
6043 [(set (match_operand:DI 0 "register_operand")
6044 (ashiftrt:DI (match_operand:DI 1 "register_operand")
6045 (match_operand:SI 2 "small_int")))
6046 (clobber (match_operand:SI 3 "register_operand"))]
6047 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
6048 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
6049 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
6050 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
6051 && (INTVAL (operands[2]) & 63) < 32
6052 && (INTVAL (operands[2]) & 63) != 0"
6054 [(set (subreg:SI (match_dup 0) 4)
6055 (lshiftrt:SI (subreg:SI (match_dup 1) 4)
6059 (ashift:SI (subreg:SI (match_dup 1) 0)
6062 (set (subreg:SI (match_dup 0) 4)
6063 (ior:SI (subreg:SI (match_dup 0) 4)
6066 (set (subreg:SI (match_dup 0) 0)
6067 (ashiftrt:SI (subreg:SI (match_dup 1) 0)
6070 int amount = INTVAL (operands[2]);
6071 operands[2] = GEN_INT (amount & 31);
6072 operands[4] = GEN_INT ((-amount) & 31);
6076 (define_insn "ashrdi3_internal4"
6077 [(set (match_operand:DI 0 "register_operand" "=d")
6078 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
6079 (match_operand:SI 2 "arith_operand" "dI")))]
6080 "TARGET_64BIT && !TARGET_MIPS16"
6082 if (GET_CODE (operands[2]) == CONST_INT)
6083 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
6085 return "dsra\t%0,%1,%2";
6087 [(set_attr "type" "shift")
6088 (set_attr "mode" "DI")])
6091 [(set (match_operand:DI 0 "register_operand" "=d,d")
6092 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0,0")
6093 (match_operand:SI 2 "arith_operand" "d,I")))]
6094 "TARGET_64BIT && TARGET_MIPS16"
6096 if (GET_CODE (operands[2]) == CONST_INT)
6097 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
6099 return "dsra\t%0,%2";
6101 [(set_attr "type" "shift")
6102 (set_attr "mode" "DI")
6103 (set_attr_alternative "length"
6105 (if_then_else (match_operand:VOID 2 "m16_uimm3_b")
6109 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
6112 [(set (match_operand:DI 0 "register_operand")
6113 (ashiftrt:DI (match_operand:DI 1 "register_operand")
6114 (match_operand:SI 2 "const_int_operand")))]
6115 "TARGET_MIPS16 && TARGET_64BIT && !TARGET_DEBUG_D_MODE
6117 && GET_CODE (operands[2]) == CONST_INT
6118 && INTVAL (operands[2]) > 8
6119 && INTVAL (operands[2]) <= 16"
6120 [(set (match_dup 0) (ashiftrt:DI (match_dup 1) (const_int 8)))
6121 (set (match_dup 0) (ashiftrt:DI (match_dup 0) (match_dup 2)))]
6122 { operands[2] = GEN_INT (INTVAL (operands[2]) - 8); })
6124 (define_expand "lshrsi3"
6125 [(set (match_operand:SI 0 "register_operand")
6126 (lshiftrt:SI (match_operand:SI 1 "register_operand")
6127 (match_operand:SI 2 "arith_operand")))]
6130 /* On the mips16, a shift of more than 8 is a four byte instruction,
6131 so, for a shift between 8 and 16, it is just as fast to do two
6132 shifts of 8 or less. If there is a lot of shifting going on, we
6133 may win in CSE. Otherwise combine will put the shifts back
6137 && GET_CODE (operands[2]) == CONST_INT
6138 && INTVAL (operands[2]) > 8
6139 && INTVAL (operands[2]) <= 16)
6141 rtx temp = gen_reg_rtx (SImode);
6143 emit_insn (gen_lshrsi3_internal2 (temp, operands[1], GEN_INT (8)));
6144 emit_insn (gen_lshrsi3_internal2 (operands[0], temp,
6145 GEN_INT (INTVAL (operands[2]) - 8)));
6150 (define_insn "lshrsi3_internal1"
6151 [(set (match_operand:SI 0 "register_operand" "=d")
6152 (lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
6153 (match_operand:SI 2 "arith_operand" "dI")))]
6156 if (GET_CODE (operands[2]) == CONST_INT)
6157 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
6159 return "srl\t%0,%1,%2";
6161 [(set_attr "type" "shift")
6162 (set_attr "mode" "SI")])
6164 (define_insn "lshrsi3_internal2"
6165 [(set (match_operand:SI 0 "register_operand" "=d,d")
6166 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0,d")
6167 (match_operand:SI 2 "arith_operand" "d,I")))]
6170 if (which_alternative == 0)
6171 return "srl\t%0,%2";
6173 if (GET_CODE (operands[2]) == CONST_INT)
6174 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
6176 return "srl\t%0,%1,%2";
6178 [(set_attr "type" "shift")
6179 (set_attr "mode" "SI")
6180 (set_attr_alternative "length"
6182 (if_then_else (match_operand:VOID 2 "m16_uimm3_b")
6187 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
6190 [(set (match_operand:SI 0 "register_operand")
6191 (lshiftrt:SI (match_operand:SI 1 "register_operand")
6192 (match_operand:SI 2 "const_int_operand")))]
6193 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
6194 && GET_CODE (operands[2]) == CONST_INT
6195 && INTVAL (operands[2]) > 8
6196 && INTVAL (operands[2]) <= 16"
6197 [(set (match_dup 0) (lshiftrt:SI (match_dup 1) (const_int 8)))
6198 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
6199 { operands[2] = GEN_INT (INTVAL (operands[2]) - 8); })
6201 ;; If we load a byte on the mips16 as a bitfield, the resulting
6202 ;; sequence of instructions is too complicated for combine, because it
6203 ;; involves four instructions: a load, a shift, a constant load into a
6204 ;; register, and an and (the key problem here is that the mips16 does
6205 ;; not have and immediate). We recognize a shift of a load in order
6206 ;; to make it simple enough for combine to understand.
6208 ;; The length here is the worst case: the length of the split version
6209 ;; will be more accurate.
6210 (define_insn_and_split ""
6211 [(set (match_operand:SI 0 "register_operand" "=d")
6212 (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6213 (match_operand:SI 2 "immediate_operand" "I")))]
6217 [(set (match_dup 0) (match_dup 1))
6218 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
6220 [(set_attr "type" "load")
6221 (set_attr "mode" "SI")
6222 (set_attr "length" "16")])
6224 (define_expand "lshrdi3"
6225 [(parallel [(set (match_operand:DI 0 "register_operand")
6226 (lshiftrt:DI (match_operand:DI 1 "register_operand")
6227 (match_operand:SI 2 "arith_operand")))
6228 (clobber (match_dup 3))])]
6229 "TARGET_64BIT || (!TARGET_DEBUG_G_MODE && !TARGET_MIPS16)"
6233 /* On the mips16, a shift of more than 8 is a four byte
6234 instruction, so, for a shift between 8 and 16, it is just as
6235 fast to do two shifts of 8 or less. If there is a lot of
6236 shifting going on, we may win in CSE. Otherwise combine will
6237 put the shifts back together again. */
6240 && GET_CODE (operands[2]) == CONST_INT
6241 && INTVAL (operands[2]) > 8
6242 && INTVAL (operands[2]) <= 16)
6244 rtx temp = gen_reg_rtx (DImode);
6246 emit_insn (gen_lshrdi3_internal4 (temp, operands[1], GEN_INT (8)));
6247 emit_insn (gen_lshrdi3_internal4 (operands[0], temp,
6248 GEN_INT (INTVAL (operands[2]) - 8)));
6252 emit_insn (gen_lshrdi3_internal4 (operands[0], operands[1],
6257 operands[3] = gen_reg_rtx (SImode);
6261 (define_insn "lshrdi3_internal"
6262 [(set (match_operand:DI 0 "register_operand" "=&d")
6263 (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
6264 (match_operand:SI 2 "register_operand" "d")))
6265 (clobber (match_operand:SI 3 "register_operand" "=d"))]
6266 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16"
6283 [(set_attr "type" "multi")
6284 (set_attr "mode" "DI")
6285 (set_attr "length" "48")])
6288 (define_insn "lshrdi3_internal2"
6289 [(set (match_operand:DI 0 "register_operand" "=d")
6290 (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
6291 (match_operand:SI 2 "small_int" "IJK")))
6292 (clobber (match_operand:SI 3 "register_operand" "=d"))]
6293 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
6294 && (INTVAL (operands[2]) & 32) != 0"
6296 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
6297 return "srl\t%L0,%M1,%2\;move\t%M0,%.";
6299 [(set_attr "type" "multi")
6300 (set_attr "mode" "DI")
6301 (set_attr "length" "8")])
6305 [(set (match_operand:DI 0 "register_operand")
6306 (lshiftrt:DI (match_operand:DI 1 "register_operand")
6307 (match_operand:SI 2 "small_int")))
6308 (clobber (match_operand:SI 3 "register_operand"))]
6309 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
6310 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
6311 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
6312 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
6313 && (INTVAL (operands[2]) & 32) != 0"
6315 [(set (subreg:SI (match_dup 0) 0) (lshiftrt:SI (subreg:SI (match_dup 1) 4) (match_dup 2)))
6316 (set (subreg:SI (match_dup 0) 4) (const_int 0))]
6318 "operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);")
6322 [(set (match_operand:DI 0 "register_operand")
6323 (lshiftrt:DI (match_operand:DI 1 "register_operand")
6324 (match_operand:SI 2 "small_int")))
6325 (clobber (match_operand:SI 3 "register_operand"))]
6326 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
6327 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
6328 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
6329 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
6330 && (INTVAL (operands[2]) & 32) != 0"
6332 [(set (subreg:SI (match_dup 0) 4) (lshiftrt:SI (subreg:SI (match_dup 1) 0) (match_dup 2)))
6333 (set (subreg:SI (match_dup 0) 0) (const_int 0))]
6335 "operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);")
6338 (define_insn "lshrdi3_internal3"
6339 [(set (match_operand:DI 0 "register_operand" "=d")
6340 (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
6341 (match_operand:SI 2 "small_int" "IJK")))
6342 (clobber (match_operand:SI 3 "register_operand" "=d"))]
6343 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
6344 && (INTVAL (operands[2]) & 63) < 32
6345 && (INTVAL (operands[2]) & 63) != 0"
6347 int amount = INTVAL (operands[2]);
6349 operands[2] = GEN_INT (amount & 31);
6350 operands[4] = GEN_INT ((-amount) & 31);
6352 return "srl\t%L0,%L1,%2\;sll\t%3,%M1,%4\;or\t%L0,%L0,%3\;srl\t%M0,%M1,%2";
6354 [(set_attr "type" "multi")
6355 (set_attr "mode" "DI")
6356 (set_attr "length" "16")])
6360 [(set (match_operand:DI 0 "register_operand")
6361 (lshiftrt:DI (match_operand:DI 1 "register_operand")
6362 (match_operand:SI 2 "small_int")))
6363 (clobber (match_operand:SI 3 "register_operand"))]
6364 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
6365 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
6366 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
6367 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
6368 && (INTVAL (operands[2]) & 63) < 32
6369 && (INTVAL (operands[2]) & 63) != 0"
6371 [(set (subreg:SI (match_dup 0) 0)
6372 (lshiftrt:SI (subreg:SI (match_dup 1) 0)
6376 (ashift:SI (subreg:SI (match_dup 1) 4)
6379 (set (subreg:SI (match_dup 0) 0)
6380 (ior:SI (subreg:SI (match_dup 0) 0)
6383 (set (subreg:SI (match_dup 0) 4)
6384 (lshiftrt:SI (subreg:SI (match_dup 1) 4)
6387 int amount = INTVAL (operands[2]);
6388 operands[2] = GEN_INT (amount & 31);
6389 operands[4] = GEN_INT ((-amount) & 31);
6394 [(set (match_operand:DI 0 "register_operand")
6395 (lshiftrt:DI (match_operand:DI 1 "register_operand")
6396 (match_operand:SI 2 "small_int")))
6397 (clobber (match_operand:SI 3 "register_operand"))]
6398 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
6399 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
6400 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
6401 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
6402 && (INTVAL (operands[2]) & 63) < 32
6403 && (INTVAL (operands[2]) & 63) != 0"
6405 [(set (subreg:SI (match_dup 0) 4)
6406 (lshiftrt:SI (subreg:SI (match_dup 1) 4)
6410 (ashift:SI (subreg:SI (match_dup 1) 0)
6413 (set (subreg:SI (match_dup 0) 4)
6414 (ior:SI (subreg:SI (match_dup 0) 4)
6417 (set (subreg:SI (match_dup 0) 0)
6418 (lshiftrt:SI (subreg:SI (match_dup 1) 0)
6421 int amount = INTVAL (operands[2]);
6422 operands[2] = GEN_INT (amount & 31);
6423 operands[4] = GEN_INT ((-amount) & 31);
6427 (define_insn "lshrdi3_internal4"
6428 [(set (match_operand:DI 0 "register_operand" "=d")
6429 (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
6430 (match_operand:SI 2 "arith_operand" "dI")))]
6431 "TARGET_64BIT && !TARGET_MIPS16"
6433 if (GET_CODE (operands[2]) == CONST_INT)
6434 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
6436 return "dsrl\t%0,%1,%2";
6438 [(set_attr "type" "shift")
6439 (set_attr "mode" "DI")])
6442 [(set (match_operand:DI 0 "register_operand" "=d,d")
6443 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0,0")
6444 (match_operand:SI 2 "arith_operand" "d,I")))]
6445 "TARGET_64BIT && TARGET_MIPS16"
6447 if (GET_CODE (operands[2]) == CONST_INT)
6448 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
6450 return "dsrl\t%0,%2";
6452 [(set_attr "type" "shift")
6453 (set_attr "mode" "DI")
6454 (set_attr_alternative "length"
6456 (if_then_else (match_operand:VOID 2 "m16_uimm3_b")
6460 (define_insn "rotrsi3"
6461 [(set (match_operand:SI 0 "register_operand" "=d")
6462 (rotatert:SI (match_operand:SI 1 "register_operand" "d")
6463 (match_operand:SI 2 "arith_operand" "dn")))]
6466 if (TARGET_SR71K && GET_CODE (operands[2]) != CONST_INT)
6467 return "rorv\t%0,%1,%2";
6469 if ((GET_CODE (operands[2]) == CONST_INT)
6470 && (INTVAL (operands[2]) < 0 || INTVAL (operands[2]) >= 32))
6473 return "ror\t%0,%1,%2";
6475 [(set_attr "type" "shift")
6476 (set_attr "mode" "SI")])
6478 (define_insn "rotrdi3"
6479 [(set (match_operand:DI 0 "register_operand" "=d")
6480 (rotatert:DI (match_operand:DI 1 "register_operand" "d")
6481 (match_operand:DI 2 "arith_operand" "dn")))]
6486 if (GET_CODE (operands[2]) != CONST_INT)
6487 return "drorv\t%0,%1,%2";
6489 if (INTVAL (operands[2]) >= 32 && INTVAL (operands[2]) <= 63)
6490 return "dror32\t%0,%1,%2";
6493 if ((GET_CODE (operands[2]) == CONST_INT)
6494 && (INTVAL (operands[2]) < 0 || INTVAL (operands[2]) >= 64))
6497 return "dror\t%0,%1,%2";
6499 [(set_attr "type" "shift")
6500 (set_attr "mode" "DI")])
6503 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
6506 [(set (match_operand:DI 0 "register_operand")
6507 (lshiftrt:DI (match_operand:DI 1 "register_operand")
6508 (match_operand:SI 2 "const_int_operand")))]
6509 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
6510 && GET_CODE (operands[2]) == CONST_INT
6511 && INTVAL (operands[2]) > 8
6512 && INTVAL (operands[2]) <= 16"
6513 [(set (match_dup 0) (lshiftrt:DI (match_dup 1) (const_int 8)))
6514 (set (match_dup 0) (lshiftrt:DI (match_dup 0) (match_dup 2)))]
6515 { operands[2] = GEN_INT (INTVAL (operands[2]) - 8); })
6518 ;; ....................
6522 ;; ....................
6524 ;; Flow here is rather complex:
6526 ;; 1) The cmp{si,di,sf,df} routine is called. It deposits the
6527 ;; arguments into the branch_cmp array, and the type into
6528 ;; branch_type. No RTL is generated.
6530 ;; 2) The appropriate branch define_expand is called, which then
6531 ;; creates the appropriate RTL for the comparison and branch.
6532 ;; Different CC modes are used, based on what type of branch is
6533 ;; done, so that we can constrain things appropriately. There
6534 ;; are assumptions in the rest of GCC that break if we fold the
6535 ;; operands into the branches for integer operations, and use cc0
6536 ;; for floating point, so we use the fp status register instead.
6537 ;; If needed, an appropriate temporary is created to hold the
6538 ;; of the integer compare.
6540 (define_expand "cmpsi"
6542 (compare:CC (match_operand:SI 0 "register_operand")
6543 (match_operand:SI 1 "arith_operand")))]
6546 branch_cmp[0] = operands[0];
6547 branch_cmp[1] = operands[1];
6548 branch_type = CMP_SI;
6552 (define_expand "cmpdi"
6554 (compare:CC (match_operand:DI 0 "register_operand")
6555 (match_operand:DI 1 "arith_operand")))]
6558 branch_cmp[0] = operands[0];
6559 branch_cmp[1] = operands[1];
6560 branch_type = CMP_DI;
6564 (define_expand "cmpdf"
6566 (compare:CC (match_operand:DF 0 "register_operand")
6567 (match_operand:DF 1 "register_operand")))]
6568 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
6570 branch_cmp[0] = operands[0];
6571 branch_cmp[1] = operands[1];
6572 branch_type = CMP_DF;
6576 (define_expand "cmpsf"
6578 (compare:CC (match_operand:SF 0 "register_operand")
6579 (match_operand:SF 1 "register_operand")))]
6582 branch_cmp[0] = operands[0];
6583 branch_cmp[1] = operands[1];
6584 branch_type = CMP_SF;
6589 ;; ....................
6591 ;; CONDITIONAL BRANCHES
6593 ;; ....................
6595 ;; Conditional branches on floating-point equality tests.
6597 (define_insn "branch_fp"
6600 (match_operator:CC 0 "cmp_op"
6601 [(match_operand:CC 2 "register_operand" "z")
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_fp_inverted"
6620 (match_operator:CC 0 "cmp_op"
6621 [(match_operand:CC 2 "register_operand" "z")
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 branches on comparisons with zero.
6639 (define_insn "branch_zero"
6642 (match_operator:SI 0 "cmp_op"
6643 [(match_operand:SI 2 "register_operand" "d")
6645 (label_ref (match_operand 1 "" ""))
6649 return mips_output_conditional_branch (insn,
6651 /*two_operands_p=*/0,
6654 get_attr_length (insn));
6656 [(set_attr "type" "branch")
6657 (set_attr "mode" "none")])
6659 (define_insn "branch_zero_inverted"
6662 (match_operator:SI 0 "cmp_op"
6663 [(match_operand:SI 2 "register_operand" "d")
6666 (label_ref (match_operand 1 "" ""))))]
6669 return mips_output_conditional_branch (insn,
6671 /*two_operands_p=*/0,
6674 get_attr_length (insn));
6676 [(set_attr "type" "branch")
6677 (set_attr "mode" "none")])
6679 (define_insn "branch_zero_di"
6682 (match_operator:DI 0 "cmp_op"
6683 [(match_operand:DI 2 "register_operand" "d")
6685 (label_ref (match_operand 1 "" ""))
6689 return mips_output_conditional_branch (insn,
6691 /*two_operands_p=*/0,
6694 get_attr_length (insn));
6696 [(set_attr "type" "branch")
6697 (set_attr "mode" "none")])
6699 (define_insn "branch_zero_di_inverted"
6702 (match_operator:DI 0 "cmp_op"
6703 [(match_operand:DI 2 "register_operand" "d")
6706 (label_ref (match_operand 1 "" ""))))]
6709 return mips_output_conditional_branch (insn,
6711 /*two_operands_p=*/0,
6714 get_attr_length (insn));
6716 [(set_attr "type" "branch")
6717 (set_attr "mode" "none")])
6719 ;; Conditional branch on equality comparison.
6721 (define_insn "branch_equality"
6724 (match_operator:SI 0 "equality_op"
6725 [(match_operand:SI 2 "register_operand" "d")
6726 (match_operand:SI 3 "register_operand" "d")])
6727 (label_ref (match_operand 1 "" ""))
6731 return mips_output_conditional_branch (insn,
6733 /*two_operands_p=*/1,
6736 get_attr_length (insn));
6738 [(set_attr "type" "branch")
6739 (set_attr "mode" "none")])
6741 (define_insn "branch_equality_di"
6744 (match_operator:DI 0 "equality_op"
6745 [(match_operand:DI 2 "register_operand" "d")
6746 (match_operand:DI 3 "register_operand" "d")])
6747 (label_ref (match_operand 1 "" ""))
6751 return mips_output_conditional_branch (insn,
6753 /*two_operands_p=*/1,
6756 get_attr_length (insn));
6758 [(set_attr "type" "branch")
6759 (set_attr "mode" "none")])
6761 (define_insn "branch_equality_inverted"
6764 (match_operator:SI 0 "equality_op"
6765 [(match_operand:SI 2 "register_operand" "d")
6766 (match_operand:SI 3 "register_operand" "d")])
6768 (label_ref (match_operand 1 "" ""))))]
6771 return mips_output_conditional_branch (insn,
6773 /*two_operands_p=*/1,
6776 get_attr_length (insn));
6778 [(set_attr "type" "branch")
6779 (set_attr "mode" "none")])
6781 (define_insn "branch_equality_di_inverted"
6784 (match_operator:DI 0 "equality_op"
6785 [(match_operand:DI 2 "register_operand" "d")
6786 (match_operand:DI 3 "register_operand" "d")])
6788 (label_ref (match_operand 1 "" ""))))]
6791 return mips_output_conditional_branch (insn,
6793 /*two_operands_p=*/1,
6796 get_attr_length (insn));
6798 [(set_attr "type" "branch")
6799 (set_attr "mode" "none")])
6805 (if_then_else (match_operator:SI 0 "equality_op"
6806 [(match_operand:SI 1 "register_operand" "d,t")
6808 (match_operand 2 "pc_or_label_operand" "")
6809 (match_operand 3 "pc_or_label_operand" "")))]
6812 if (operands[2] != pc_rtx)
6814 if (which_alternative == 0)
6815 return "b%C0z\t%1,%2";
6817 return "bt%C0z\t%2";
6821 if (which_alternative == 0)
6822 return "b%N0z\t%1,%3";
6824 return "bt%N0z\t%3";
6827 [(set_attr "type" "branch")
6828 (set_attr "mode" "none")
6829 (set_attr "length" "8")])
6833 (if_then_else (match_operator:DI 0 "equality_op"
6834 [(match_operand:DI 1 "register_operand" "d,t")
6836 (match_operand 2 "pc_or_label_operand" "")
6837 (match_operand 3 "pc_or_label_operand" "")))]
6840 if (operands[2] != pc_rtx)
6842 if (which_alternative == 0)
6843 return "b%C0z\t%1,%2";
6845 return "bt%C0z\t%2";
6849 if (which_alternative == 0)
6850 return "b%N0z\t%1,%3";
6852 return "bt%N0z\t%3";
6855 [(set_attr "type" "branch")
6856 (set_attr "mode" "none")
6857 (set_attr "length" "8")])
6859 (define_expand "bunordered"
6861 (if_then_else (unordered:CC (cc0)
6863 (label_ref (match_operand 0 ""))
6867 gen_conditional_branch (operands, UNORDERED);
6871 (define_expand "bordered"
6873 (if_then_else (ordered:CC (cc0)
6875 (label_ref (match_operand 0 ""))
6879 gen_conditional_branch (operands, ORDERED);
6883 (define_expand "bunlt"
6885 (if_then_else (unlt:CC (cc0)
6887 (label_ref (match_operand 0 ""))
6891 gen_conditional_branch (operands, UNLT);
6895 (define_expand "bunge"
6897 (if_then_else (unge:CC (cc0)
6899 (label_ref (match_operand 0 ""))
6903 gen_conditional_branch (operands, UNGE);
6907 (define_expand "buneq"
6909 (if_then_else (uneq:CC (cc0)
6911 (label_ref (match_operand 0 ""))
6915 gen_conditional_branch (operands, UNEQ);
6919 (define_expand "bltgt"
6921 (if_then_else (ltgt:CC (cc0)
6923 (label_ref (match_operand 0 ""))
6927 gen_conditional_branch (operands, LTGT);
6931 (define_expand "bunle"
6933 (if_then_else (unle:CC (cc0)
6935 (label_ref (match_operand 0 ""))
6939 gen_conditional_branch (operands, UNLE);
6943 (define_expand "bungt"
6945 (if_then_else (ungt:CC (cc0)
6947 (label_ref (match_operand 0 ""))
6951 gen_conditional_branch (operands, UNGT);
6955 (define_expand "beq"
6957 (if_then_else (eq:CC (cc0)
6959 (label_ref (match_operand 0 ""))
6963 gen_conditional_branch (operands, EQ);
6967 (define_expand "bne"
6969 (if_then_else (ne:CC (cc0)
6971 (label_ref (match_operand 0 ""))
6975 gen_conditional_branch (operands, NE);
6979 (define_expand "bgt"
6981 (if_then_else (gt:CC (cc0)
6983 (label_ref (match_operand 0 ""))
6987 gen_conditional_branch (operands, GT);
6991 (define_expand "bge"
6993 (if_then_else (ge:CC (cc0)
6995 (label_ref (match_operand 0 ""))
6999 gen_conditional_branch (operands, GE);
7003 (define_expand "blt"
7005 (if_then_else (lt:CC (cc0)
7007 (label_ref (match_operand 0 ""))
7011 gen_conditional_branch (operands, LT);
7015 (define_expand "ble"
7017 (if_then_else (le:CC (cc0)
7019 (label_ref (match_operand 0 ""))
7023 gen_conditional_branch (operands, LE);
7027 (define_expand "bgtu"
7029 (if_then_else (gtu:CC (cc0)
7031 (label_ref (match_operand 0 ""))
7035 gen_conditional_branch (operands, GTU);
7039 (define_expand "bgeu"
7041 (if_then_else (geu:CC (cc0)
7043 (label_ref (match_operand 0 ""))
7047 gen_conditional_branch (operands, GEU);
7051 (define_expand "bltu"
7053 (if_then_else (ltu:CC (cc0)
7055 (label_ref (match_operand 0 ""))
7059 gen_conditional_branch (operands, LTU);
7063 (define_expand "bleu"
7065 (if_then_else (leu:CC (cc0)
7067 (label_ref (match_operand 0 ""))
7071 gen_conditional_branch (operands, LEU);
7076 ;; ....................
7078 ;; SETTING A REGISTER FROM A COMPARISON
7080 ;; ....................
7082 (define_expand "seq"
7083 [(set (match_operand:SI 0 "register_operand")
7084 (eq:SI (match_dup 1)
7088 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
7091 /* Set up operands from compare. */
7092 operands[1] = branch_cmp[0];
7093 operands[2] = branch_cmp[1];
7095 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
7097 gen_int_relational (EQ, operands[0], operands[1], operands[2], (int *)0);
7101 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
7102 operands[2] = force_reg (SImode, operands[2]);
7104 /* Fall through and generate default code. */
7108 (define_insn "seq_si_zero"
7109 [(set (match_operand:SI 0 "register_operand" "=d")
7110 (eq:SI (match_operand:SI 1 "register_operand" "d")
7114 [(set_attr "type" "slt")
7115 (set_attr "mode" "SI")])
7118 [(set (match_operand:SI 0 "register_operand" "=t")
7119 (eq:SI (match_operand:SI 1 "register_operand" "d")
7123 [(set_attr "type" "slt")
7124 (set_attr "mode" "SI")])
7126 (define_insn "seq_di_zero"
7127 [(set (match_operand:DI 0 "register_operand" "=d")
7128 (eq:DI (match_operand:DI 1 "register_operand" "d")
7130 "TARGET_64BIT && !TARGET_MIPS16"
7132 [(set_attr "type" "slt")
7133 (set_attr "mode" "DI")])
7136 [(set (match_operand:DI 0 "register_operand" "=t")
7137 (eq:DI (match_operand:DI 1 "register_operand" "d")
7139 "TARGET_64BIT && TARGET_MIPS16"
7141 [(set_attr "type" "slt")
7142 (set_attr "mode" "DI")])
7144 (define_insn "seq_si"
7145 [(set (match_operand:SI 0 "register_operand" "=d,d")
7146 (eq:SI (match_operand:SI 1 "register_operand" "%d,d")
7147 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
7148 "TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7150 xor\t%0,%1,%2\;sltu\t%0,%0,1
7151 xori\t%0,%1,%2\;sltu\t%0,%0,1"
7152 [(set_attr "type" "multi")
7153 (set_attr "mode" "SI")
7154 (set_attr "length" "8")])
7157 [(set (match_operand:SI 0 "register_operand")
7158 (eq:SI (match_operand:SI 1 "register_operand")
7159 (match_operand:SI 2 "uns_arith_operand")))]
7160 "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE && !TARGET_MIPS16
7161 && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)"
7163 (xor:SI (match_dup 1)
7166 (ltu:SI (match_dup 0)
7170 (define_insn "seq_di"
7171 [(set (match_operand:DI 0 "register_operand" "=d,d")
7172 (eq:DI (match_operand:DI 1 "register_operand" "%d,d")
7173 (match_operand:DI 2 "uns_arith_operand" "d,K")))]
7174 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7176 xor\t%0,%1,%2\;sltu\t%0,%0,1
7177 xori\t%0,%1,%2\;sltu\t%0,%0,1"
7178 [(set_attr "type" "multi")
7179 (set_attr "mode" "DI")
7180 (set_attr "length" "8")])
7183 [(set (match_operand:DI 0 "register_operand")
7184 (eq:DI (match_operand:DI 1 "register_operand")
7185 (match_operand:DI 2 "uns_arith_operand")))]
7186 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
7188 && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)"
7190 (xor:DI (match_dup 1)
7193 (ltu:DI (match_dup 0)
7197 ;; On the mips16 the default code is better than using sltu.
7199 (define_expand "sne"
7200 [(set (match_operand:SI 0 "register_operand")
7201 (ne:SI (match_dup 1)
7205 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
7208 /* Set up operands from compare. */
7209 operands[1] = branch_cmp[0];
7210 operands[2] = branch_cmp[1];
7212 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE)
7214 gen_int_relational (NE, operands[0], operands[1], operands[2], (int *)0);
7218 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
7219 operands[2] = force_reg (SImode, operands[2]);
7221 /* Fall through and generate default code. */
7224 (define_insn "sne_si_zero"
7225 [(set (match_operand:SI 0 "register_operand" "=d")
7226 (ne:SI (match_operand:SI 1 "register_operand" "d")
7230 [(set_attr "type" "slt")
7231 (set_attr "mode" "SI")])
7233 (define_insn "sne_di_zero"
7234 [(set (match_operand:DI 0 "register_operand" "=d")
7235 (ne:DI (match_operand:DI 1 "register_operand" "d")
7237 "TARGET_64BIT && !TARGET_MIPS16"
7239 [(set_attr "type" "slt")
7240 (set_attr "mode" "DI")])
7242 (define_insn "sne_si"
7243 [(set (match_operand:SI 0 "register_operand" "=d,d")
7244 (ne:SI (match_operand:SI 1 "register_operand" "%d,d")
7245 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
7246 "TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7248 xor\t%0,%1,%2\;sltu\t%0,%.,%0
7249 xori\t%0,%1,%x2\;sltu\t%0,%.,%0"
7250 [(set_attr "type" "multi")
7251 (set_attr "mode" "SI")
7252 (set_attr "length" "8")])
7255 [(set (match_operand:SI 0 "register_operand")
7256 (ne:SI (match_operand:SI 1 "register_operand")
7257 (match_operand:SI 2 "uns_arith_operand")))]
7258 "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE && !TARGET_MIPS16
7259 && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)"
7261 (xor:SI (match_dup 1)
7264 (gtu:SI (match_dup 0)
7268 (define_insn "sne_di"
7269 [(set (match_operand:DI 0 "register_operand" "=d,d")
7270 (ne:DI (match_operand:DI 1 "register_operand" "%d,d")
7271 (match_operand:DI 2 "uns_arith_operand" "d,K")))]
7272 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7274 xor\t%0,%1,%2\;sltu\t%0,%.,%0
7275 xori\t%0,%1,%x2\;sltu\t%0,%.,%0"
7276 [(set_attr "type" "multi")
7277 (set_attr "mode" "DI")
7278 (set_attr "length" "8")])
7281 [(set (match_operand:DI 0 "register_operand")
7282 (ne:DI (match_operand:DI 1 "register_operand")
7283 (match_operand:DI 2 "uns_arith_operand")))]
7284 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
7286 && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)"
7288 (xor:DI (match_dup 1)
7291 (gtu:DI (match_dup 0)
7295 (define_expand "sgt"
7296 [(set (match_operand:SI 0 "register_operand")
7297 (gt:SI (match_dup 1)
7301 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
7304 /* Set up operands from compare. */
7305 operands[1] = branch_cmp[0];
7306 operands[2] = branch_cmp[1];
7308 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
7310 gen_int_relational (GT, operands[0], operands[1], operands[2], (int *)0);
7314 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) != 0)
7315 operands[2] = force_reg (SImode, operands[2]);
7317 /* Fall through and generate default code. */
7320 (define_insn "sgt_si"
7321 [(set (match_operand:SI 0 "register_operand" "=d")
7322 (gt:SI (match_operand:SI 1 "register_operand" "d")
7323 (match_operand:SI 2 "reg_or_0_operand" "dJ")))]
7326 [(set_attr "type" "slt")
7327 (set_attr "mode" "SI")])
7330 [(set (match_operand:SI 0 "register_operand" "=t")
7331 (gt:SI (match_operand:SI 1 "register_operand" "d")
7332 (match_operand:SI 2 "register_operand" "d")))]
7335 [(set_attr "type" "slt")
7336 (set_attr "mode" "SI")])
7338 (define_insn "sgt_di"
7339 [(set (match_operand:DI 0 "register_operand" "=d")
7340 (gt:DI (match_operand:DI 1 "register_operand" "d")
7341 (match_operand:DI 2 "reg_or_0_operand" "dJ")))]
7342 "TARGET_64BIT && !TARGET_MIPS16"
7344 [(set_attr "type" "slt")
7345 (set_attr "mode" "DI")])
7348 [(set (match_operand:DI 0 "register_operand" "=d")
7349 (gt:DI (match_operand:DI 1 "register_operand" "d")
7350 (match_operand:DI 2 "register_operand" "d")))]
7351 "TARGET_64BIT && TARGET_MIPS16"
7353 [(set_attr "type" "slt")
7354 (set_attr "mode" "DI")])
7356 (define_expand "sge"
7357 [(set (match_operand:SI 0 "register_operand")
7358 (ge:SI (match_dup 1)
7362 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
7365 /* Set up operands from compare. */
7366 operands[1] = branch_cmp[0];
7367 operands[2] = branch_cmp[1];
7369 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
7371 gen_int_relational (GE, operands[0], operands[1], operands[2], (int *)0);
7375 /* Fall through and generate default code. */
7378 (define_insn "sge_si"
7379 [(set (match_operand:SI 0 "register_operand" "=d")
7380 (ge:SI (match_operand:SI 1 "register_operand" "d")
7381 (match_operand:SI 2 "arith_operand" "dI")))]
7382 "TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7383 "slt\t%0,%1,%2\;xori\t%0,%0,0x0001"
7384 [(set_attr "type" "multi")
7385 (set_attr "mode" "SI")
7386 (set_attr "length" "8")])
7389 [(set (match_operand:SI 0 "register_operand")
7390 (ge:SI (match_operand:SI 1 "register_operand")
7391 (match_operand:SI 2 "arith_operand")))]
7392 "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE && !TARGET_MIPS16"
7394 (lt:SI (match_dup 1)
7397 (xor:SI (match_dup 0)
7401 (define_insn "sge_di"
7402 [(set (match_operand:DI 0 "register_operand" "=d")
7403 (ge:DI (match_operand:DI 1 "register_operand" "d")
7404 (match_operand:DI 2 "arith_operand" "dI")))]
7405 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7406 "slt\t%0,%1,%2\;xori\t%0,%0,0x0001"
7407 [(set_attr "type" "multi")
7408 (set_attr "mode" "DI")
7409 (set_attr "length" "8")])
7412 [(set (match_operand:DI 0 "register_operand")
7413 (ge:DI (match_operand:DI 1 "register_operand")
7414 (match_operand:DI 2 "arith_operand")))]
7415 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
7418 (lt:DI (match_dup 1)
7421 (xor:DI (match_dup 0)
7425 (define_expand "slt"
7426 [(set (match_operand:SI 0 "register_operand")
7427 (lt:SI (match_dup 1)
7431 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
7434 /* Set up operands from compare. */
7435 operands[1] = branch_cmp[0];
7436 operands[2] = branch_cmp[1];
7438 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
7440 gen_int_relational (LT, operands[0], operands[1], operands[2], (int *)0);
7444 /* Fall through and generate default code. */
7447 (define_insn "slt_si"
7448 [(set (match_operand:SI 0 "register_operand" "=d")
7449 (lt:SI (match_operand:SI 1 "register_operand" "d")
7450 (match_operand:SI 2 "arith_operand" "dI")))]
7453 [(set_attr "type" "slt")
7454 (set_attr "mode" "SI")])
7457 [(set (match_operand:SI 0 "register_operand" "=t,t")
7458 (lt:SI (match_operand:SI 1 "register_operand" "d,d")
7459 (match_operand:SI 2 "arith_operand" "d,I")))]
7462 [(set_attr "type" "slt")
7463 (set_attr "mode" "SI")
7464 (set_attr_alternative "length"
7466 (if_then_else (match_operand:VOID 2 "m16_uimm8_1")
7470 (define_insn "slt_di"
7471 [(set (match_operand:DI 0 "register_operand" "=d")
7472 (lt:DI (match_operand:DI 1 "register_operand" "d")
7473 (match_operand:DI 2 "arith_operand" "dI")))]
7474 "TARGET_64BIT && !TARGET_MIPS16"
7476 [(set_attr "type" "slt")
7477 (set_attr "mode" "DI")])
7480 [(set (match_operand:DI 0 "register_operand" "=t,t")
7481 (lt:DI (match_operand:DI 1 "register_operand" "d,d")
7482 (match_operand:DI 2 "arith_operand" "d,I")))]
7483 "TARGET_64BIT && TARGET_MIPS16"
7485 [(set_attr "type" "slt")
7486 (set_attr "mode" "DI")
7487 (set_attr_alternative "length"
7489 (if_then_else (match_operand:VOID 2 "m16_uimm8_1")
7493 (define_expand "sle"
7494 [(set (match_operand:SI 0 "register_operand")
7495 (le:SI (match_dup 1)
7499 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
7502 /* Set up operands from compare. */
7503 operands[1] = branch_cmp[0];
7504 operands[2] = branch_cmp[1];
7506 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
7508 gen_int_relational (LE, operands[0], operands[1], operands[2], (int *)0);
7512 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 32767)
7513 operands[2] = force_reg (SImode, operands[2]);
7515 /* Fall through and generate default code. */
7518 (define_insn "sle_si_const"
7519 [(set (match_operand:SI 0 "register_operand" "=d")
7520 (le:SI (match_operand:SI 1 "register_operand" "d")
7521 (match_operand:SI 2 "small_int" "I")))]
7522 "!TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
7524 operands[2] = GEN_INT (INTVAL (operands[2])+1);
7525 return "slt\t%0,%1,%2";
7527 [(set_attr "type" "slt")
7528 (set_attr "mode" "SI")])
7531 [(set (match_operand:SI 0 "register_operand" "=t")
7532 (le:SI (match_operand:SI 1 "register_operand" "d")
7533 (match_operand:SI 2 "small_int" "I")))]
7534 "TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
7536 operands[2] = GEN_INT (INTVAL (operands[2])+1);
7537 return "slt\t%1,%2";
7539 [(set_attr "type" "slt")
7540 (set_attr "mode" "SI")
7541 (set (attr "length") (if_then_else (match_operand:VOID 2 "m16_uimm8_m1_1")
7545 (define_insn "sle_di_const"
7546 [(set (match_operand:DI 0 "register_operand" "=d")
7547 (le:DI (match_operand:DI 1 "register_operand" "d")
7548 (match_operand:DI 2 "small_int" "I")))]
7549 "TARGET_64BIT && !TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
7551 operands[2] = GEN_INT (INTVAL (operands[2])+1);
7552 return "slt\t%0,%1,%2";
7554 [(set_attr "type" "slt")
7555 (set_attr "mode" "DI")])
7558 [(set (match_operand:DI 0 "register_operand" "=t")
7559 (le:DI (match_operand:DI 1 "register_operand" "d")
7560 (match_operand:DI 2 "small_int" "I")))]
7561 "TARGET_64BIT && TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
7563 operands[2] = GEN_INT (INTVAL (operands[2])+1);
7564 return "slt\t%1,%2";
7566 [(set_attr "type" "slt")
7567 (set_attr "mode" "DI")
7568 (set (attr "length") (if_then_else (match_operand:VOID 2 "m16_uimm8_m1_1")
7572 (define_insn "sle_si_reg"
7573 [(set (match_operand:SI 0 "register_operand" "=d")
7574 (le:SI (match_operand:SI 1 "register_operand" "d")
7575 (match_operand:SI 2 "register_operand" "d")))]
7576 "TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7577 "slt\t%0,%z2,%1\;xori\t%0,%0,0x0001"
7578 [(set_attr "type" "multi")
7579 (set_attr "mode" "SI")
7580 (set_attr "length" "8")])
7583 [(set (match_operand:SI 0 "register_operand")
7584 (le:SI (match_operand:SI 1 "register_operand")
7585 (match_operand:SI 2 "register_operand")))]
7586 "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE && !TARGET_MIPS16"
7588 (lt:SI (match_dup 2)
7591 (xor:SI (match_dup 0)
7595 (define_insn "sle_di_reg"
7596 [(set (match_operand:DI 0 "register_operand" "=d")
7597 (le:DI (match_operand:DI 1 "register_operand" "d")
7598 (match_operand:DI 2 "register_operand" "d")))]
7599 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7600 "slt\t%0,%z2,%1\;xori\t%0,%0,0x0001"
7601 [(set_attr "type" "multi")
7602 (set_attr "mode" "DI")
7603 (set_attr "length" "8")])
7606 [(set (match_operand:DI 0 "register_operand")
7607 (le:DI (match_operand:DI 1 "register_operand")
7608 (match_operand:DI 2 "register_operand")))]
7609 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
7612 (lt:DI (match_dup 2)
7615 (xor:DI (match_dup 0)
7619 (define_expand "sgtu"
7620 [(set (match_operand:SI 0 "register_operand")
7621 (gtu:SI (match_dup 1)
7625 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
7628 /* Set up operands from compare. */
7629 operands[1] = branch_cmp[0];
7630 operands[2] = branch_cmp[1];
7632 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
7634 gen_int_relational (GTU, operands[0], operands[1], operands[2], (int *)0);
7638 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) != 0)
7639 operands[2] = force_reg (SImode, operands[2]);
7641 /* Fall through and generate default code. */
7644 (define_insn "sgtu_si"
7645 [(set (match_operand:SI 0 "register_operand" "=d")
7646 (gtu:SI (match_operand:SI 1 "register_operand" "d")
7647 (match_operand:SI 2 "reg_or_0_operand" "dJ")))]
7650 [(set_attr "type" "slt")
7651 (set_attr "mode" "SI")])
7654 [(set (match_operand:SI 0 "register_operand" "=t")
7655 (gtu:SI (match_operand:SI 1 "register_operand" "d")
7656 (match_operand:SI 2 "register_operand" "d")))]
7659 [(set_attr "type" "slt")
7660 (set_attr "mode" "SI")])
7662 (define_insn "sgtu_di"
7663 [(set (match_operand:DI 0 "register_operand" "=d")
7664 (gtu:DI (match_operand:DI 1 "register_operand" "d")
7665 (match_operand:DI 2 "reg_or_0_operand" "dJ")))]
7666 "TARGET_64BIT && !TARGET_MIPS16"
7668 [(set_attr "type" "slt")
7669 (set_attr "mode" "DI")])
7672 [(set (match_operand:DI 0 "register_operand" "=t")
7673 (gtu:DI (match_operand:DI 1 "register_operand" "d")
7674 (match_operand:DI 2 "register_operand" "d")))]
7675 "TARGET_64BIT && TARGET_MIPS16"
7677 [(set_attr "type" "slt")
7678 (set_attr "mode" "DI")])
7680 (define_expand "sgeu"
7681 [(set (match_operand:SI 0 "register_operand")
7682 (geu:SI (match_dup 1)
7686 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
7689 /* Set up operands from compare. */
7690 operands[1] = branch_cmp[0];
7691 operands[2] = branch_cmp[1];
7693 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
7695 gen_int_relational (GEU, operands[0], operands[1], operands[2], (int *)0);
7699 /* Fall through and generate default code. */
7702 (define_insn "sgeu_si"
7703 [(set (match_operand:SI 0 "register_operand" "=d")
7704 (geu:SI (match_operand:SI 1 "register_operand" "d")
7705 (match_operand:SI 2 "arith_operand" "dI")))]
7706 "TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7707 "sltu\t%0,%1,%2\;xori\t%0,%0,0x0001"
7708 [(set_attr "type" "multi")
7709 (set_attr "mode" "SI")
7710 (set_attr "length" "8")])
7713 [(set (match_operand:SI 0 "register_operand")
7714 (geu:SI (match_operand:SI 1 "register_operand")
7715 (match_operand:SI 2 "arith_operand")))]
7716 "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE && !TARGET_MIPS16"
7718 (ltu:SI (match_dup 1)
7721 (xor:SI (match_dup 0)
7725 (define_insn "sgeu_di"
7726 [(set (match_operand:DI 0 "register_operand" "=d")
7727 (geu:DI (match_operand:DI 1 "register_operand" "d")
7728 (match_operand:DI 2 "arith_operand" "dI")))]
7729 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7730 "sltu\t%0,%1,%2\;xori\t%0,%0,0x0001"
7731 [(set_attr "type" "multi")
7732 (set_attr "mode" "DI")
7733 (set_attr "length" "8")])
7736 [(set (match_operand:DI 0 "register_operand")
7737 (geu:DI (match_operand:DI 1 "register_operand")
7738 (match_operand:DI 2 "arith_operand")))]
7739 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
7742 (ltu:DI (match_dup 1)
7745 (xor:DI (match_dup 0)
7749 (define_expand "sltu"
7750 [(set (match_operand:SI 0 "register_operand")
7751 (ltu:SI (match_dup 1)
7755 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
7758 /* Set up operands from compare. */
7759 operands[1] = branch_cmp[0];
7760 operands[2] = branch_cmp[1];
7762 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
7764 gen_int_relational (LTU, operands[0], operands[1], operands[2], (int *)0);
7768 /* Fall through and generate default code. */
7771 (define_insn "sltu_si"
7772 [(set (match_operand:SI 0 "register_operand" "=d")
7773 (ltu:SI (match_operand:SI 1 "register_operand" "d")
7774 (match_operand:SI 2 "arith_operand" "dI")))]
7777 [(set_attr "type" "slt")
7778 (set_attr "mode" "SI")])
7781 [(set (match_operand:SI 0 "register_operand" "=t,t")
7782 (ltu:SI (match_operand:SI 1 "register_operand" "d,d")
7783 (match_operand:SI 2 "arith_operand" "d,I")))]
7786 [(set_attr "type" "slt")
7787 (set_attr "mode" "SI")
7788 (set_attr_alternative "length"
7790 (if_then_else (match_operand:VOID 2 "m16_uimm8_1")
7794 (define_insn "sltu_di"
7795 [(set (match_operand:DI 0 "register_operand" "=d")
7796 (ltu:DI (match_operand:DI 1 "register_operand" "d")
7797 (match_operand:DI 2 "arith_operand" "dI")))]
7798 "TARGET_64BIT && !TARGET_MIPS16"
7800 [(set_attr "type" "slt")
7801 (set_attr "mode" "DI")])
7804 [(set (match_operand:DI 0 "register_operand" "=t,t")
7805 (ltu:DI (match_operand:DI 1 "register_operand" "d,d")
7806 (match_operand:DI 2 "arith_operand" "d,I")))]
7807 "TARGET_64BIT && TARGET_MIPS16"
7809 [(set_attr "type" "slt")
7810 (set_attr "mode" "DI")
7811 (set_attr_alternative "length"
7813 (if_then_else (match_operand:VOID 2 "m16_uimm8_1")
7817 (define_expand "sleu"
7818 [(set (match_operand:SI 0 "register_operand")
7819 (leu:SI (match_dup 1)
7823 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
7826 /* Set up operands from compare. */
7827 operands[1] = branch_cmp[0];
7828 operands[2] = branch_cmp[1];
7830 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
7832 gen_int_relational (LEU, operands[0], operands[1], operands[2], (int *)0);
7836 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 32767)
7837 operands[2] = force_reg (SImode, operands[2]);
7839 /* Fall through and generate default code. */
7842 (define_insn "sleu_si_const"
7843 [(set (match_operand:SI 0 "register_operand" "=d")
7844 (leu:SI (match_operand:SI 1 "register_operand" "d")
7845 (match_operand:SI 2 "small_int" "I")))]
7846 "!TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
7848 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
7849 return "sltu\t%0,%1,%2";
7851 [(set_attr "type" "slt")
7852 (set_attr "mode" "SI")])
7855 [(set (match_operand:SI 0 "register_operand" "=t")
7856 (leu:SI (match_operand:SI 1 "register_operand" "d")
7857 (match_operand:SI 2 "small_int" "I")))]
7858 "TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
7860 operands[2] = GEN_INT (INTVAL (operands[2])+1);
7861 return "sltu\t%1,%2";
7863 [(set_attr "type" "slt")
7864 (set_attr "mode" "SI")
7865 (set (attr "length") (if_then_else (match_operand:VOID 2 "m16_uimm8_m1_1")
7869 (define_insn "sleu_di_const"
7870 [(set (match_operand:DI 0 "register_operand" "=d")
7871 (leu:DI (match_operand:DI 1 "register_operand" "d")
7872 (match_operand:DI 2 "small_int" "I")))]
7873 "TARGET_64BIT && !TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
7875 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
7876 return "sltu\t%0,%1,%2";
7878 [(set_attr "type" "slt")
7879 (set_attr "mode" "DI")])
7882 [(set (match_operand:DI 0 "register_operand" "=t")
7883 (leu:DI (match_operand:DI 1 "register_operand" "d")
7884 (match_operand:DI 2 "small_int" "I")))]
7885 "TARGET_64BIT && TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
7887 operands[2] = GEN_INT (INTVAL (operands[2])+1);
7888 return "sltu\t%1,%2";
7890 [(set_attr "type" "slt")
7891 (set_attr "mode" "DI")
7892 (set (attr "length") (if_then_else (match_operand:VOID 2 "m16_uimm8_m1_1")
7896 (define_insn "sleu_si_reg"
7897 [(set (match_operand:SI 0 "register_operand" "=d")
7898 (leu:SI (match_operand:SI 1 "register_operand" "d")
7899 (match_operand:SI 2 "register_operand" "d")))]
7900 "TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7901 "sltu\t%0,%z2,%1\;xori\t%0,%0,0x0001"
7902 [(set_attr "type" "multi")
7903 (set_attr "mode" "SI")
7904 (set_attr "length" "8")])
7907 [(set (match_operand:SI 0 "register_operand")
7908 (leu:SI (match_operand:SI 1 "register_operand")
7909 (match_operand:SI 2 "register_operand")))]
7910 "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE && !TARGET_MIPS16"
7912 (ltu:SI (match_dup 2)
7915 (xor:SI (match_dup 0)
7919 (define_insn "sleu_di_reg"
7920 [(set (match_operand:DI 0 "register_operand" "=d")
7921 (leu:DI (match_operand:DI 1 "register_operand" "d")
7922 (match_operand:DI 2 "register_operand" "d")))]
7923 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
7924 "sltu\t%0,%z2,%1\;xori\t%0,%0,0x0001"
7925 [(set_attr "type" "multi")
7926 (set_attr "mode" "DI")
7927 (set_attr "length" "8")])
7930 [(set (match_operand:DI 0 "register_operand")
7931 (leu:DI (match_operand:DI 1 "register_operand")
7932 (match_operand:DI 2 "register_operand")))]
7933 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
7936 (ltu:DI (match_dup 2)
7939 (xor:DI (match_dup 0)
7944 ;; ....................
7946 ;; FLOATING POINT COMPARISONS
7948 ;; ....................
7950 (define_insn "sunordered_df"
7951 [(set (match_operand:CC 0 "register_operand" "=z")
7952 (unordered:CC (match_operand:DF 1 "register_operand" "f")
7953 (match_operand:DF 2 "register_operand" "f")))]
7954 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
7956 [(set_attr "type" "fcmp")
7957 (set_attr "mode" "FPSW")])
7959 (define_insn "sunlt_df"
7960 [(set (match_operand:CC 0 "register_operand" "=z")
7961 (unlt:CC (match_operand:DF 1 "register_operand" "f")
7962 (match_operand:DF 2 "register_operand" "f")))]
7963 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
7965 [(set_attr "type" "fcmp")
7966 (set_attr "mode" "FPSW")])
7968 (define_insn "suneq_df"
7969 [(set (match_operand:CC 0 "register_operand" "=z")
7970 (uneq:CC (match_operand:DF 1 "register_operand" "f")
7971 (match_operand:DF 2 "register_operand" "f")))]
7972 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
7974 [(set_attr "type" "fcmp")
7975 (set_attr "mode" "FPSW")])
7977 (define_insn "sunle_df"
7978 [(set (match_operand:CC 0 "register_operand" "=z")
7979 (unle:CC (match_operand:DF 1 "register_operand" "f")
7980 (match_operand:DF 2 "register_operand" "f")))]
7981 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
7983 [(set_attr "type" "fcmp")
7984 (set_attr "mode" "FPSW")])
7986 (define_insn "seq_df"
7987 [(set (match_operand:CC 0 "register_operand" "=z")
7988 (eq:CC (match_operand:DF 1 "register_operand" "f")
7989 (match_operand:DF 2 "register_operand" "f")))]
7990 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
7992 [(set_attr "type" "fcmp")
7993 (set_attr "mode" "FPSW")])
7995 (define_insn "slt_df"
7996 [(set (match_operand:CC 0 "register_operand" "=z")
7997 (lt:CC (match_operand:DF 1 "register_operand" "f")
7998 (match_operand:DF 2 "register_operand" "f")))]
7999 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
8001 [(set_attr "type" "fcmp")
8002 (set_attr "mode" "FPSW")])
8004 (define_insn "sle_df"
8005 [(set (match_operand:CC 0 "register_operand" "=z")
8006 (le:CC (match_operand:DF 1 "register_operand" "f")
8007 (match_operand:DF 2 "register_operand" "f")))]
8008 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
8010 [(set_attr "type" "fcmp")
8011 (set_attr "mode" "FPSW")])
8013 (define_insn "sgt_df"
8014 [(set (match_operand:CC 0 "register_operand" "=z")
8015 (gt:CC (match_operand:DF 1 "register_operand" "f")
8016 (match_operand:DF 2 "register_operand" "f")))]
8017 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
8019 [(set_attr "type" "fcmp")
8020 (set_attr "mode" "FPSW")])
8022 (define_insn "sge_df"
8023 [(set (match_operand:CC 0 "register_operand" "=z")
8024 (ge:CC (match_operand:DF 1 "register_operand" "f")
8025 (match_operand:DF 2 "register_operand" "f")))]
8026 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
8028 [(set_attr "type" "fcmp")
8029 (set_attr "mode" "FPSW")])
8031 (define_insn "sunordered_sf"
8032 [(set (match_operand:CC 0 "register_operand" "=z")
8033 (unordered:CC (match_operand:SF 1 "register_operand" "f")
8034 (match_operand:SF 2 "register_operand" "f")))]
8037 [(set_attr "type" "fcmp")
8038 (set_attr "mode" "FPSW")])
8040 (define_insn "sunlt_sf"
8041 [(set (match_operand:CC 0 "register_operand" "=z")
8042 (unlt:CC (match_operand:SF 1 "register_operand" "f")
8043 (match_operand:SF 2 "register_operand" "f")))]
8046 [(set_attr "type" "fcmp")
8047 (set_attr "mode" "FPSW")])
8049 (define_insn "suneq_sf"
8050 [(set (match_operand:CC 0 "register_operand" "=z")
8051 (uneq:CC (match_operand:SF 1 "register_operand" "f")
8052 (match_operand:SF 2 "register_operand" "f")))]
8055 [(set_attr "type" "fcmp")
8056 (set_attr "mode" "FPSW")])
8058 (define_insn "sunle_sf"
8059 [(set (match_operand:CC 0 "register_operand" "=z")
8060 (unle:CC (match_operand:SF 1 "register_operand" "f")
8061 (match_operand:SF 2 "register_operand" "f")))]
8064 [(set_attr "type" "fcmp")
8065 (set_attr "mode" "FPSW")])
8067 (define_insn "seq_sf"
8068 [(set (match_operand:CC 0 "register_operand" "=z")
8069 (eq:CC (match_operand:SF 1 "register_operand" "f")
8070 (match_operand:SF 2 "register_operand" "f")))]
8073 [(set_attr "type" "fcmp")
8074 (set_attr "mode" "FPSW")])
8076 (define_insn "slt_sf"
8077 [(set (match_operand:CC 0 "register_operand" "=z")
8078 (lt:CC (match_operand:SF 1 "register_operand" "f")
8079 (match_operand:SF 2 "register_operand" "f")))]
8082 [(set_attr "type" "fcmp")
8083 (set_attr "mode" "FPSW")])
8085 (define_insn "sle_sf"
8086 [(set (match_operand:CC 0 "register_operand" "=z")
8087 (le:CC (match_operand:SF 1 "register_operand" "f")
8088 (match_operand:SF 2 "register_operand" "f")))]
8091 [(set_attr "type" "fcmp")
8092 (set_attr "mode" "FPSW")])
8094 (define_insn "sgt_sf"
8095 [(set (match_operand:CC 0 "register_operand" "=z")
8096 (gt:CC (match_operand:SF 1 "register_operand" "f")
8097 (match_operand:SF 2 "register_operand" "f")))]
8100 [(set_attr "type" "fcmp")
8101 (set_attr "mode" "FPSW")])
8103 (define_insn "sge_sf"
8104 [(set (match_operand:CC 0 "register_operand" "=z")
8105 (ge:CC (match_operand:SF 1 "register_operand" "f")
8106 (match_operand:SF 2 "register_operand" "f")))]
8109 [(set_attr "type" "fcmp")
8110 (set_attr "mode" "FPSW")])
8113 ;; ....................
8115 ;; UNCONDITIONAL BRANCHES
8117 ;; ....................
8119 ;; Unconditional branches.
8123 (label_ref (match_operand 0 "" "")))]
8128 if (get_attr_length (insn) <= 8)
8129 return "%*b\t%l0%/";
8132 output_asm_insn (mips_output_load_label (), operands);
8133 return "%*jr\t%@%/%]";
8137 return "%*j\t%l0%/";
8139 [(set_attr "type" "jump")
8140 (set_attr "mode" "none")
8141 (set (attr "length")
8142 ;; We can't use `j' when emitting PIC. Emit a branch if it's
8143 ;; in range, otherwise load the address of the branch target into
8144 ;; $at and then jump to it.
8146 (ior (eq (symbol_ref "flag_pic") (const_int 0))
8147 (lt (abs (minus (match_dup 0)
8148 (plus (pc) (const_int 4))))
8149 (const_int 131072)))
8150 (const_int 4) (const_int 16)))])
8152 ;; We need a different insn for the mips16, because a mips16 branch
8153 ;; does not have a delay slot.
8157 (label_ref (match_operand 0 "" "")))]
8160 [(set_attr "type" "branch")
8161 (set_attr "mode" "none")
8162 (set_attr "length" "8")])
8164 (define_expand "indirect_jump"
8165 [(set (pc) (match_operand 0 "register_operand"))]
8171 if (GET_CODE (dest) != REG || GET_MODE (dest) != Pmode)
8172 operands[0] = copy_to_mode_reg (Pmode, dest);
8174 if (!(Pmode == DImode))
8175 emit_jump_insn (gen_indirect_jump_internal1 (operands[0]));
8177 emit_jump_insn (gen_indirect_jump_internal2 (operands[0]));
8182 (define_insn "indirect_jump_internal1"
8183 [(set (pc) (match_operand:SI 0 "register_operand" "d"))]
8184 "!(Pmode == DImode)"
8186 [(set_attr "type" "jump")
8187 (set_attr "mode" "none")])
8189 (define_insn "indirect_jump_internal2"
8190 [(set (pc) (match_operand:DI 0 "register_operand" "d"))]
8193 [(set_attr "type" "jump")
8194 (set_attr "mode" "none")])
8196 (define_expand "tablejump"
8198 (match_operand 0 "register_operand"))
8199 (use (label_ref (match_operand 1 "")))]
8204 if (GET_MODE (operands[0]) != HImode)
8206 if (!(Pmode == DImode))
8207 emit_insn (gen_tablejump_mips161 (operands[0], operands[1]));
8209 emit_insn (gen_tablejump_mips162 (operands[0], operands[1]));
8213 if (GET_MODE (operands[0]) != ptr_mode)
8217 operands[0] = expand_binop (ptr_mode, add_optab, operands[0],
8218 pic_offset_table_rtx, 0, 0, OPTAB_WIDEN);
8220 if (Pmode == SImode)
8221 emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
8223 emit_jump_insn (gen_tablejump_internal2 (operands[0], operands[1]));
8227 (define_insn "tablejump_internal1"
8229 (match_operand:SI 0 "register_operand" "d"))
8230 (use (label_ref (match_operand 1 "" "")))]
8233 [(set_attr "type" "jump")
8234 (set_attr "mode" "none")])
8236 (define_insn "tablejump_internal2"
8238 (match_operand:DI 0 "register_operand" "d"))
8239 (use (label_ref (match_operand 1 "" "")))]
8242 [(set_attr "type" "jump")
8243 (set_attr "mode" "none")])
8245 (define_expand "tablejump_mips161"
8246 [(set (pc) (plus:SI (sign_extend:SI (match_operand:HI 0 "register_operand"))
8247 (label_ref:SI (match_operand 1 ""))))]
8248 "TARGET_MIPS16 && !(Pmode == DImode)"
8252 t1 = gen_reg_rtx (SImode);
8253 t2 = gen_reg_rtx (SImode);
8254 t3 = gen_reg_rtx (SImode);
8255 emit_insn (gen_extendhisi2 (t1, operands[0]));
8256 emit_move_insn (t2, gen_rtx_LABEL_REF (SImode, operands[1]));
8257 emit_insn (gen_addsi3 (t3, t1, t2));
8258 emit_jump_insn (gen_tablejump_internal1 (t3, operands[1]));
8262 (define_expand "tablejump_mips162"
8263 [(set (pc) (plus:DI (sign_extend:DI (match_operand:HI 0 "register_operand"))
8264 (label_ref:DI (match_operand 1 ""))))]
8265 "TARGET_MIPS16 && Pmode == DImode"
8269 t1 = gen_reg_rtx (DImode);
8270 t2 = gen_reg_rtx (DImode);
8271 t3 = gen_reg_rtx (DImode);
8272 emit_insn (gen_extendhidi2 (t1, operands[0]));
8273 emit_move_insn (t2, gen_rtx_LABEL_REF (DImode, operands[1]));
8274 emit_insn (gen_adddi3 (t3, t1, t2));
8275 emit_jump_insn (gen_tablejump_internal2 (t3, operands[1]));
8279 ;; For TARGET_ABICALLS, we save the gp in the jmp_buf as well.
8280 ;; While it is possible to either pull it off the stack (in the
8281 ;; o32 case) or recalculate it given t9 and our target label,
8282 ;; it takes 3 or 4 insns to do so.
8284 (define_expand "builtin_setjmp_setup"
8285 [(use (match_operand 0 "register_operand"))]
8290 addr = plus_constant (operands[0], GET_MODE_SIZE (Pmode) * 3);
8291 emit_move_insn (gen_rtx_MEM (Pmode, addr), pic_offset_table_rtx);
8295 ;; Restore the gp that we saved above. Despite the earlier comment, it seems
8296 ;; that older code did recalculate the gp from $25. Continue to jump through
8297 ;; $25 for compatibility (we lose nothing by doing so).
8299 (define_expand "builtin_longjmp"
8300 [(use (match_operand 0 "register_operand"))]
8303 /* The elements of the buffer are, in order: */
8304 int W = GET_MODE_SIZE (Pmode);
8305 rtx fp = gen_rtx_MEM (Pmode, operands[0]);
8306 rtx lab = gen_rtx_MEM (Pmode, plus_constant (operands[0], 1*W));
8307 rtx stack = gen_rtx_MEM (Pmode, plus_constant (operands[0], 2*W));
8308 rtx gpv = gen_rtx_MEM (Pmode, plus_constant (operands[0], 3*W));
8309 rtx pv = gen_rtx_REG (Pmode, PIC_FUNCTION_ADDR_REGNUM);
8310 /* Use gen_raw_REG to avoid being given pic_offset_table_rtx.
8311 The target is bound to be using $28 as the global pointer
8312 but the current function might not be. */
8313 rtx gp = gen_raw_REG (Pmode, GLOBAL_POINTER_REGNUM);
8315 /* This bit is similar to expand_builtin_longjmp except that it
8316 restores $gp as well. */
8317 emit_move_insn (hard_frame_pointer_rtx, fp);
8318 emit_move_insn (pv, lab);
8319 emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
8320 emit_move_insn (gp, gpv);
8321 emit_insn (gen_rtx_USE (VOIDmode, hard_frame_pointer_rtx));
8322 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
8323 emit_insn (gen_rtx_USE (VOIDmode, gp));
8324 emit_indirect_jump (pv);
8329 ;; ....................
8331 ;; Function prologue/epilogue
8333 ;; ....................
8336 (define_expand "prologue"
8340 mips_expand_prologue ();
8344 ;; Block any insns from being moved before this point, since the
8345 ;; profiling call to mcount can use various registers that aren't
8346 ;; saved or used to pass arguments.
8348 (define_insn "blockage"
8349 [(unspec_volatile [(const_int 0)] UNSPEC_BLOCKAGE)]
8352 [(set_attr "type" "unknown")
8353 (set_attr "mode" "none")
8354 (set_attr "length" "0")])
8356 (define_expand "epilogue"
8360 mips_expand_epilogue (false);
8364 (define_expand "sibcall_epilogue"
8368 mips_expand_epilogue (true);
8372 ;; Trivial return. Make it look like a normal return insn as that
8373 ;; allows jump optimizations to work better.
8375 (define_insn "return"
8377 "mips_can_use_return_insn ()"
8379 [(set_attr "type" "jump")
8380 (set_attr "mode" "none")])
8384 (define_insn "return_internal"
8386 (use (match_operand 0 "pmode_register_operand" ""))]
8389 [(set_attr "type" "jump")
8390 (set_attr "mode" "none")])
8392 ;; This is used in compiling the unwind routines.
8393 (define_expand "eh_return"
8394 [(use (match_operand 0 "general_operand"))]
8397 enum machine_mode gpr_mode = TARGET_64BIT ? DImode : SImode;
8399 if (GET_MODE (operands[0]) != gpr_mode)
8400 operands[0] = convert_to_mode (gpr_mode, operands[0], 0);
8402 emit_insn (gen_eh_set_lr_di (operands[0]));
8404 emit_insn (gen_eh_set_lr_si (operands[0]));
8409 ;; Clobber the return address on the stack. We can't expand this
8410 ;; until we know where it will be put in the stack frame.
8412 (define_insn "eh_set_lr_si"
8413 [(unspec [(match_operand:SI 0 "register_operand" "d")] UNSPEC_EH_RETURN)
8414 (clobber (match_scratch:SI 1 "=&d"))]
8418 (define_insn "eh_set_lr_di"
8419 [(unspec [(match_operand:DI 0 "register_operand" "d")] UNSPEC_EH_RETURN)
8420 (clobber (match_scratch:DI 1 "=&d"))]
8425 [(unspec [(match_operand 0 "register_operand")] UNSPEC_EH_RETURN)
8426 (clobber (match_scratch 1))]
8427 "reload_completed && !TARGET_DEBUG_D_MODE"
8430 mips_set_return_address (operands[0], operands[1]);
8434 (define_insn "exception_receiver"
8436 (unspec_volatile:SI [(const_int 0)] UNSPEC_EH_RECEIVER))]
8437 "TARGET_ABICALLS && TARGET_OLDABI"
8439 operands[0] = pic_offset_table_rtx;
8440 operands[1] = mips_gp_save_slot ();
8441 return mips_output_move (operands[0], operands[1]);
8443 [(set_attr "type" "load")
8444 (set_attr "length" "8")])
8447 ;; ....................
8451 ;; ....................
8453 ;; Instructions to load a call address from the GOT. The address might
8454 ;; point to a function or to a lazy binding stub. In the latter case,
8455 ;; the stub will use the dynamic linker to resolve the function, which
8456 ;; in turn will change the GOT entry to point to the function's real
8459 ;; This means that every call, even pure and constant ones, can
8460 ;; potentially modify the GOT entry. And once a stub has been called,
8461 ;; we must not call it again.
8463 ;; We represent this restriction using an imaginary fixed register that
8464 ;; acts like a GOT version number. By making the register call-clobbered,
8465 ;; we tell the target-independent code that the address could be changed
8466 ;; by any call insn.
8467 (define_insn "load_callsi"
8468 [(set (match_operand:SI 0 "register_operand" "=c")
8469 (unspec:SI [(match_operand:SI 1 "register_operand" "r")
8470 (match_operand:SI 2 "immediate_operand" "")
8471 (reg:SI FAKE_CALL_REGNO)]
8475 [(set_attr "type" "load")
8476 (set_attr "length" "4")])
8478 (define_insn "load_calldi"
8479 [(set (match_operand:DI 0 "register_operand" "=c")
8480 (unspec:DI [(match_operand:DI 1 "register_operand" "r")
8481 (match_operand:DI 2 "immediate_operand" "")
8482 (reg:DI FAKE_CALL_REGNO)]
8486 [(set_attr "type" "load")
8487 (set_attr "length" "4")])
8489 ;; Sibling calls. All these patterns use jump instructions.
8491 ;; If TARGET_SIBCALLS, call_insn_operand will only accept constant
8492 ;; addresses if a direct jump is acceptable. Since the 'S' constraint
8493 ;; is defined in terms of call_insn_operand, the same is true of the
8496 ;; When we use an indirect jump, we need a register that will be
8497 ;; preserved by the epilogue. Since TARGET_ABICALLS forces us to
8498 ;; use $25 for this purpose -- and $25 is never clobbered by the
8499 ;; epilogue -- we might as well use it for !TARGET_ABICALLS as well.
8501 (define_expand "sibcall"
8502 [(parallel [(call (match_operand 0 "")
8503 (match_operand 1 ""))
8504 (use (match_operand 2 "")) ;; next_arg_reg
8505 (use (match_operand 3 ""))])] ;; struct_value_size_rtx
8508 mips_expand_call (0, XEXP (operands[0], 0), operands[1], operands[2], true);
8512 (define_insn "sibcall_internal"
8513 [(call (mem:SI (match_operand 0 "call_insn_operand" "j,S"))
8514 (match_operand 1 "" ""))]
8515 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
8519 [(set_attr "type" "call")])
8521 (define_expand "sibcall_value"
8522 [(parallel [(set (match_operand 0 "")
8523 (call (match_operand 1 "")
8524 (match_operand 2 "")))
8525 (use (match_operand 3 ""))])] ;; next_arg_reg
8528 mips_expand_call (operands[0], XEXP (operands[1], 0),
8529 operands[2], operands[3], true);
8533 (define_insn "sibcall_value_internal"
8534 [(set (match_operand 0 "register_operand" "=df,df")
8535 (call (mem:SI (match_operand 1 "call_insn_operand" "j,S"))
8536 (match_operand 2 "" "")))]
8537 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
8541 [(set_attr "type" "call")])
8543 (define_insn "sibcall_value_multiple_internal"
8544 [(set (match_operand 0 "register_operand" "=df,df")
8545 (call (mem:SI (match_operand 1 "call_insn_operand" "j,S"))
8546 (match_operand 2 "" "")))
8547 (set (match_operand 3 "register_operand" "=df,df")
8548 (call (mem:SI (match_dup 1))
8550 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
8554 [(set_attr "type" "call")])
8556 (define_expand "call"
8557 [(parallel [(call (match_operand 0 "")
8558 (match_operand 1 ""))
8559 (use (match_operand 2 "")) ;; next_arg_reg
8560 (use (match_operand 3 ""))])] ;; struct_value_size_rtx
8563 mips_expand_call (0, XEXP (operands[0], 0), operands[1], operands[2], false);
8567 ;; This instruction directly corresponds to an assembly-language "jal".
8568 ;; There are four cases:
8571 ;; Both symbolic and register destinations are OK. The pattern
8572 ;; always expands to a single mips instruction.
8574 ;; - -mabicalls/-mno-explicit-relocs:
8575 ;; Again, both symbolic and register destinations are OK.
8576 ;; The call is treated as a multi-instruction black box.
8578 ;; - -mabicalls/-mexplicit-relocs with n32 or n64:
8579 ;; Only "jal $25" is allowed. This expands to a single "jalr $25"
8582 ;; - -mabicalls/-mexplicit-relocs with o32 or o64:
8583 ;; Only "jal $25" is allowed. The call is actually two instructions:
8584 ;; "jalr $25" followed by an insn to reload $gp.
8586 ;; In the last case, we can generate the individual instructions with
8587 ;; a define_split. There are several things to be wary of:
8589 ;; - We can't expose the load of $gp before reload. If we did,
8590 ;; it might get removed as dead, but reload can introduce new
8591 ;; uses of $gp by rematerializing constants.
8593 ;; - We shouldn't restore $gp after calls that never return.
8594 ;; It isn't valid to insert instructions between a noreturn
8595 ;; call and the following barrier.
8597 ;; - The splitter deliberately changes the liveness of $gp. The unsplit
8598 ;; instruction preserves $gp and so have no effect on its liveness.
8599 ;; But once we generate the separate insns, it becomes obvious that
8600 ;; $gp is not live on entry to the call.
8602 ;; ??? The operands[2] = insn check is a hack to make the original insn
8603 ;; available to the splitter.
8604 (define_insn_and_split "call_internal"
8605 [(call (mem:SI (match_operand 0 "call_insn_operand" "c,S"))
8606 (match_operand 1 "" ""))
8607 (clobber (reg:SI 31))]
8609 { return TARGET_SPLIT_CALLS ? "#" : "%*jal\t%0%/"; }
8610 "reload_completed && TARGET_SPLIT_CALLS && (operands[2] = insn)"
8613 emit_call_insn (gen_call_split (operands[0], operands[1]));
8614 if (!find_reg_note (operands[2], REG_NORETURN, 0))
8615 emit_move_insn (pic_offset_table_rtx, mips_gp_save_slot ());
8618 [(set_attr "jal" "indirect,direct")
8619 (set_attr "extended_mips16" "no,yes")])
8621 (define_insn "call_split"
8622 [(call (mem:SI (match_operand 0 "call_insn_operand" "c"))
8623 (match_operand 1 "" ""))
8624 (clobber (reg:SI 31))
8625 (clobber (reg:SI 28))]
8626 "TARGET_SPLIT_CALLS"
8628 [(set_attr "type" "call")])
8630 (define_expand "call_value"
8631 [(parallel [(set (match_operand 0 "")
8632 (call (match_operand 1 "")
8633 (match_operand 2 "")))
8634 (use (match_operand 3 ""))])] ;; next_arg_reg
8637 mips_expand_call (operands[0], XEXP (operands[1], 0),
8638 operands[2], operands[3], false);
8642 ;; See comment for call_internal.
8643 (define_insn_and_split "call_value_internal"
8644 [(set (match_operand 0 "register_operand" "=df,df")
8645 (call (mem:SI (match_operand 1 "call_insn_operand" "c,S"))
8646 (match_operand 2 "" "")))
8647 (clobber (reg:SI 31))]
8649 { return TARGET_SPLIT_CALLS ? "#" : "%*jal\t%1%/"; }
8650 "reload_completed && TARGET_SPLIT_CALLS && (operands[3] = insn)"
8653 emit_call_insn (gen_call_value_split (operands[0], operands[1],
8655 if (!find_reg_note (operands[3], REG_NORETURN, 0))
8656 emit_move_insn (pic_offset_table_rtx, mips_gp_save_slot ());
8659 [(set_attr "jal" "indirect,direct")
8660 (set_attr "extended_mips16" "no,yes")])
8662 (define_insn "call_value_split"
8663 [(set (match_operand 0 "register_operand" "=df")
8664 (call (mem:SI (match_operand 1 "call_insn_operand" "c"))
8665 (match_operand 2 "" "")))
8666 (clobber (reg:SI 31))
8667 (clobber (reg:SI 28))]
8668 "TARGET_SPLIT_CALLS"
8670 [(set_attr "type" "call")])
8672 ;; See comment for call_internal.
8673 (define_insn_and_split "call_value_multiple_internal"
8674 [(set (match_operand 0 "register_operand" "=df,df")
8675 (call (mem:SI (match_operand 1 "call_insn_operand" "c,S"))
8676 (match_operand 2 "" "")))
8677 (set (match_operand 3 "register_operand" "=df,df")
8678 (call (mem:SI (match_dup 1))
8680 (clobber (reg:SI 31))]
8682 { return TARGET_SPLIT_CALLS ? "#" : "%*jal\t%1%/"; }
8683 "reload_completed && TARGET_SPLIT_CALLS && (operands[4] = insn)"
8686 emit_call_insn (gen_call_value_multiple_split (operands[0], operands[1],
8687 operands[2], operands[3]));
8688 if (!find_reg_note (operands[4], REG_NORETURN, 0))
8689 emit_move_insn (pic_offset_table_rtx, mips_gp_save_slot ());
8692 [(set_attr "jal" "indirect,direct")
8693 (set_attr "extended_mips16" "no,yes")])
8695 (define_insn "call_value_multiple_split"
8696 [(set (match_operand 0 "register_operand" "=df")
8697 (call (mem:SI (match_operand 1 "call_insn_operand" "c"))
8698 (match_operand 2 "" "")))
8699 (set (match_operand 3 "register_operand" "=df")
8700 (call (mem:SI (match_dup 1))
8702 (clobber (reg:SI 31))
8703 (clobber (reg:SI 28))]
8704 "TARGET_SPLIT_CALLS"
8706 [(set_attr "type" "call")])
8708 ;; Call subroutine returning any type.
8710 (define_expand "untyped_call"
8711 [(parallel [(call (match_operand 0 "")
8713 (match_operand 1 "")
8714 (match_operand 2 "")])]
8719 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
8721 for (i = 0; i < XVECLEN (operands[2], 0); i++)
8723 rtx set = XVECEXP (operands[2], 0, i);
8724 emit_move_insn (SET_DEST (set), SET_SRC (set));
8727 emit_insn (gen_blockage ());
8732 ;; ....................
8736 ;; ....................
8740 (define_expand "prefetch"
8741 [(prefetch (match_operand 0 "address_operand")
8742 (match_operand 1 "const_int_operand")
8743 (match_operand 2 "const_int_operand"))]
8746 if (symbolic_operand (operands[0], GET_MODE (operands[0])))
8747 operands[0] = force_reg (GET_MODE (operands[0]), operands[0]);
8750 (define_insn "prefetch_si_address"
8751 [(prefetch (plus:SI (match_operand:SI 0 "register_operand" "r")
8752 (match_operand:SI 3 "const_int_operand" "I"))
8753 (match_operand:SI 1 "const_int_operand" "n")
8754 (match_operand:SI 2 "const_int_operand" "n"))]
8755 "ISA_HAS_PREFETCH && Pmode == SImode"
8756 { return mips_emit_prefetch (operands); }
8757 [(set_attr "type" "prefetch")])
8759 (define_insn "prefetch_indexed_si"
8760 [(prefetch (plus:SI (match_operand:SI 0 "register_operand" "r")
8761 (match_operand:SI 3 "register_operand" "r"))
8762 (match_operand:SI 1 "const_int_operand" "n")
8763 (match_operand:SI 2 "const_int_operand" "n"))]
8764 "ISA_HAS_PREFETCHX && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && Pmode == SImode"
8765 { return mips_emit_prefetch (operands); }
8766 [(set_attr "type" "prefetchx")])
8768 (define_insn "prefetch_si"
8769 [(prefetch (match_operand:SI 0 "register_operand" "r")
8770 (match_operand:SI 1 "const_int_operand" "n")
8771 (match_operand:SI 2 "const_int_operand" "n"))]
8772 "ISA_HAS_PREFETCH && Pmode == SImode"
8774 operands[3] = const0_rtx;
8775 return mips_emit_prefetch (operands);
8777 [(set_attr "type" "prefetch")])
8779 (define_insn "prefetch_di_address"
8780 [(prefetch (plus:DI (match_operand:DI 0 "register_operand" "r")
8781 (match_operand:DI 3 "const_int_operand" "I"))
8782 (match_operand:DI 1 "const_int_operand" "n")
8783 (match_operand:DI 2 "const_int_operand" "n"))]
8784 "ISA_HAS_PREFETCH && Pmode == DImode"
8785 { return mips_emit_prefetch (operands); }
8786 [(set_attr "type" "prefetch")])
8788 (define_insn "prefetch_indexed_di"
8789 [(prefetch (plus:DI (match_operand:DI 0 "register_operand" "r")
8790 (match_operand:DI 3 "register_operand" "r"))
8791 (match_operand:DI 1 "const_int_operand" "n")
8792 (match_operand:DI 2 "const_int_operand" "n"))]
8793 "ISA_HAS_PREFETCHX && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && Pmode == DImode"
8794 { return mips_emit_prefetch (operands); }
8795 [(set_attr "type" "prefetchx")])
8797 (define_insn "prefetch_di"
8798 [(prefetch (match_operand:DI 0 "register_operand" "r")
8799 (match_operand:DI 1 "const_int_operand" "n")
8800 (match_operand:DI 2 "const_int_operand" "n"))]
8801 "ISA_HAS_PREFETCH && Pmode == DImode"
8803 operands[3] = const0_rtx;
8804 return mips_emit_prefetch (operands);
8806 [(set_attr "type" "prefetch")])
8812 [(set_attr "type" "nop")
8813 (set_attr "mode" "none")])
8815 ;; Like nop, but commented out when outside a .set noreorder block.
8816 (define_insn "hazard_nop"
8825 [(set_attr "type" "nop")])
8827 ;; MIPS4 Conditional move instructions.
8830 [(set (match_operand:SI 0 "register_operand" "=d,d")
8832 (match_operator 4 "equality_op"
8833 [(match_operand:SI 1 "register_operand" "d,d")
8835 (match_operand:SI 2 "reg_or_0_operand" "dJ,0")
8836 (match_operand:SI 3 "reg_or_0_operand" "0,dJ")))]
8837 "ISA_HAS_CONDMOVE || ISA_HAS_INT_CONDMOVE"
8841 [(set_attr "type" "condmove")
8842 (set_attr "mode" "SI")])
8845 [(set (match_operand:SI 0 "register_operand" "=d,d")
8847 (match_operator 4 "equality_op"
8848 [(match_operand:DI 1 "register_operand" "d,d")
8850 (match_operand:SI 2 "reg_or_0_operand" "dJ,0")
8851 (match_operand:SI 3 "reg_or_0_operand" "0,dJ")))]
8852 "ISA_HAS_CONDMOVE || ISA_HAS_INT_CONDMOVE"
8856 [(set_attr "type" "condmove")
8857 (set_attr "mode" "SI")])
8860 [(set (match_operand:SI 0 "register_operand" "=d,d")
8862 (match_operator 3 "equality_op" [(match_operand:CC 4
8866 (match_operand:SI 1 "reg_or_0_operand" "dJ,0")
8867 (match_operand:SI 2 "reg_or_0_operand" "0,dJ")))]
8868 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT"
8872 [(set_attr "type" "condmove")
8873 (set_attr "mode" "SI")])
8876 [(set (match_operand:DI 0 "register_operand" "=d,d")
8878 (match_operator 4 "equality_op"
8879 [(match_operand:SI 1 "register_operand" "d,d")
8881 (match_operand:DI 2 "reg_or_0_operand" "dJ,0")
8882 (match_operand:DI 3 "reg_or_0_operand" "0,dJ")))]
8883 "(ISA_HAS_CONDMOVE || ISA_HAS_INT_CONDMOVE) && TARGET_64BIT"
8887 [(set_attr "type" "condmove")
8888 (set_attr "mode" "DI")])
8891 [(set (match_operand:DI 0 "register_operand" "=d,d")
8893 (match_operator 4 "equality_op"
8894 [(match_operand:DI 1 "register_operand" "d,d")
8896 (match_operand:DI 2 "reg_or_0_operand" "dJ,0")
8897 (match_operand:DI 3 "reg_or_0_operand" "0,dJ")))]
8898 "(ISA_HAS_CONDMOVE || ISA_HAS_INT_CONDMOVE) && TARGET_64BIT"
8902 [(set_attr "type" "condmove")
8903 (set_attr "mode" "DI")])
8906 [(set (match_operand:DI 0 "register_operand" "=d,d")
8908 (match_operator 3 "equality_op" [(match_operand:CC 4
8912 (match_operand:DI 1 "reg_or_0_operand" "dJ,0")
8913 (match_operand:DI 2 "reg_or_0_operand" "0,dJ")))]
8914 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT && TARGET_64BIT"
8918 [(set_attr "type" "condmove")
8919 (set_attr "mode" "DI")])
8922 [(set (match_operand:SF 0 "register_operand" "=f,f")
8924 (match_operator 4 "equality_op"
8925 [(match_operand:SI 1 "register_operand" "d,d")
8927 (match_operand:SF 2 "register_operand" "f,0")
8928 (match_operand:SF 3 "register_operand" "0,f")))]
8929 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT"
8933 [(set_attr "type" "condmove")
8934 (set_attr "mode" "SF")])
8937 [(set (match_operand:SF 0 "register_operand" "=f,f")
8939 (match_operator 4 "equality_op"
8940 [(match_operand:DI 1 "register_operand" "d,d")
8942 (match_operand:SF 2 "register_operand" "f,0")
8943 (match_operand:SF 3 "register_operand" "0,f")))]
8944 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT"
8948 [(set_attr "type" "condmove")
8949 (set_attr "mode" "SF")])
8952 [(set (match_operand:SF 0 "register_operand" "=f,f")
8954 (match_operator 3 "equality_op" [(match_operand:CC 4
8958 (match_operand:SF 1 "register_operand" "f,0")
8959 (match_operand:SF 2 "register_operand" "0,f")))]
8960 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT"
8964 [(set_attr "type" "condmove")
8965 (set_attr "mode" "SF")])
8968 [(set (match_operand:DF 0 "register_operand" "=f,f")
8970 (match_operator 4 "equality_op"
8971 [(match_operand:SI 1 "register_operand" "d,d")
8973 (match_operand:DF 2 "register_operand" "f,0")
8974 (match_operand:DF 3 "register_operand" "0,f")))]
8975 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
8979 [(set_attr "type" "condmove")
8980 (set_attr "mode" "DF")])
8983 [(set (match_operand:DF 0 "register_operand" "=f,f")
8985 (match_operator 4 "equality_op"
8986 [(match_operand:DI 1 "register_operand" "d,d")
8988 (match_operand:DF 2 "register_operand" "f,0")
8989 (match_operand:DF 3 "register_operand" "0,f")))]
8990 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
8994 [(set_attr "type" "condmove")
8995 (set_attr "mode" "DF")])
8998 [(set (match_operand:DF 0 "register_operand" "=f,f")
9000 (match_operator 3 "equality_op" [(match_operand:CC 4
9004 (match_operand:DF 1 "register_operand" "f,0")
9005 (match_operand:DF 2 "register_operand" "0,f")))]
9006 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
9010 [(set_attr "type" "condmove")
9011 (set_attr "mode" "DF")])
9013 ;; These are the main define_expand's used to make conditional moves.
9015 (define_expand "movsicc"
9016 [(set (match_dup 4) (match_operand 1 "comparison_operator"))
9017 (set (match_operand:SI 0 "register_operand")
9018 (if_then_else:SI (match_dup 5)
9019 (match_operand:SI 2 "reg_or_0_operand")
9020 (match_operand:SI 3 "reg_or_0_operand")))]
9021 "ISA_HAS_CONDMOVE || ISA_HAS_INT_CONDMOVE"
9023 gen_conditional_move (operands);
9027 (define_expand "movdicc"
9028 [(set (match_dup 4) (match_operand 1 "comparison_operator"))
9029 (set (match_operand:DI 0 "register_operand")
9030 (if_then_else:DI (match_dup 5)
9031 (match_operand:DI 2 "reg_or_0_operand")
9032 (match_operand:DI 3 "reg_or_0_operand")))]
9033 "(ISA_HAS_CONDMOVE || ISA_HAS_INT_CONDMOVE) && TARGET_64BIT"
9035 gen_conditional_move (operands);
9039 (define_expand "movsfcc"
9040 [(set (match_dup 4) (match_operand 1 "comparison_operator"))
9041 (set (match_operand:SF 0 "register_operand")
9042 (if_then_else:SF (match_dup 5)
9043 (match_operand:SF 2 "register_operand")
9044 (match_operand:SF 3 "register_operand")))]
9045 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT"
9047 gen_conditional_move (operands);
9051 (define_expand "movdfcc"
9052 [(set (match_dup 4) (match_operand 1 "comparison_operator"))
9053 (set (match_operand:DF 0 "register_operand")
9054 (if_then_else:DF (match_dup 5)
9055 (match_operand:DF 2 "register_operand")
9056 (match_operand:DF 3 "register_operand")))]
9057 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
9059 gen_conditional_move (operands);
9064 ;; ....................
9066 ;; mips16 inline constant tables
9068 ;; ....................
9071 (define_insn "consttable_int"
9072 [(unspec_volatile [(match_operand 0 "consttable_operand" "")
9073 (match_operand 1 "const_int_operand" "")]
9074 UNSPEC_CONSTTABLE_INT)]
9077 assemble_integer (operands[0], INTVAL (operands[1]),
9078 BITS_PER_UNIT * INTVAL (operands[1]), 1);
9081 [(set (attr "length") (symbol_ref "INTVAL (operands[1])"))])
9083 (define_insn "consttable_float"
9084 [(unspec_volatile [(match_operand 0 "consttable_operand" "")]
9085 UNSPEC_CONSTTABLE_FLOAT)]
9090 if (GET_CODE (operands[0]) != CONST_DOUBLE)
9092 REAL_VALUE_FROM_CONST_DOUBLE (d, operands[0]);
9093 assemble_real (d, GET_MODE (operands[0]),
9094 GET_MODE_BITSIZE (GET_MODE (operands[0])));
9097 [(set (attr "length")
9098 (symbol_ref "GET_MODE_SIZE (GET_MODE (operands[0]))"))])
9100 (define_insn "align"
9101 [(unspec_volatile [(match_operand 0 "const_int_operand" "")] UNSPEC_ALIGN)]
9104 [(set (attr "length") (symbol_ref "(1 << INTVAL (operands[0])) - 1"))])
9107 ;; ....................
9111 ;; ....................
9114 ;; On the mips16, reload will sometimes decide that a pseudo register
9115 ;; should go into $24, and then later on have to reload that register.
9116 ;; When that happens, we get a load of a general register followed by
9117 ;; a move from the general register to $24 followed by a branch.
9118 ;; These peepholes catch the common case, and fix it to just use the
9119 ;; general register for the branch.
9122 [(set (match_operand:SI 0 "register_operand" "=t")
9123 (match_operand:SI 1 "register_operand" "d"))
9125 (if_then_else (match_operator:SI 2 "equality_op" [(match_dup 0)
9127 (match_operand 3 "pc_or_label_operand" "")
9128 (match_operand 4 "pc_or_label_operand" "")))]
9130 && GET_CODE (operands[0]) == REG
9131 && REGNO (operands[0]) == 24
9132 && dead_or_set_p (insn, operands[0])
9133 && GET_CODE (operands[1]) == REG
9134 && M16_REG_P (REGNO (operands[1]))"
9136 if (operands[3] != pc_rtx)
9137 return "b%C2z\t%1,%3";
9139 return "b%N2z\t%1,%4";
9141 [(set_attr "type" "branch")
9142 (set_attr "mode" "none")
9143 (set_attr "length" "8")])
9146 [(set (match_operand:DI 0 "register_operand" "=t")
9147 (match_operand:DI 1 "register_operand" "d"))
9149 (if_then_else (match_operator:DI 2 "equality_op" [(match_dup 0)
9151 (match_operand 3 "pc_or_label_operand" "")
9152 (match_operand 4 "pc_or_label_operand" "")))]
9153 "TARGET_MIPS16 && TARGET_64BIT
9154 && GET_CODE (operands[0]) == REG
9155 && REGNO (operands[0]) == 24
9156 && dead_or_set_p (insn, operands[0])
9157 && GET_CODE (operands[1]) == REG
9158 && M16_REG_P (REGNO (operands[1]))"
9160 if (operands[3] != pc_rtx)
9161 return "b%C2z\t%1,%3";
9163 return "b%N2z\t%1,%4";
9165 [(set_attr "type" "branch")
9166 (set_attr "mode" "none")
9167 (set_attr "length" "8")])
9169 ;; We can also have the reverse reload: reload will spill $24 into
9170 ;; another register, and then do a branch on that register when it
9171 ;; could have just stuck with $24.
9174 [(set (match_operand:SI 0 "register_operand" "=d")
9175 (match_operand:SI 1 "register_operand" "t"))
9177 (if_then_else (match_operator:SI 2 "equality_op" [(match_dup 0)
9179 (match_operand 3 "pc_or_label_operand" "")
9180 (match_operand 4 "pc_or_label_operand" "")))]
9182 && GET_CODE (operands[1]) == REG
9183 && REGNO (operands[1]) == 24
9184 && GET_CODE (operands[0]) == REG
9185 && M16_REG_P (REGNO (operands[0]))
9186 && dead_or_set_p (insn, operands[0])"
9188 if (operands[3] != pc_rtx)
9189 return "bt%C2z\t%3";
9191 return "bt%N2z\t%4";
9193 [(set_attr "type" "branch")
9194 (set_attr "mode" "none")
9195 (set_attr "length" "8")])
9198 [(set (match_operand:DI 0 "register_operand" "=d")
9199 (match_operand:DI 1 "register_operand" "t"))
9201 (if_then_else (match_operator:DI 2 "equality_op" [(match_dup 0)
9203 (match_operand 3 "pc_or_label_operand" "")
9204 (match_operand 4 "pc_or_label_operand" "")))]
9205 "TARGET_MIPS16 && TARGET_64BIT
9206 && GET_CODE (operands[1]) == REG
9207 && REGNO (operands[1]) == 24
9208 && GET_CODE (operands[0]) == REG
9209 && M16_REG_P (REGNO (operands[0]))
9210 && dead_or_set_p (insn, operands[0])"
9212 if (operands[3] != pc_rtx)
9213 return "bt%C2z\t%3";
9215 return "bt%N2z\t%4";
9217 [(set_attr "type" "branch")
9218 (set_attr "mode" "none")
9219 (set_attr "length" "8")])
9222 [(match_operand 0 "small_data_pattern")]
9225 { operands[0] = mips_rewrite_small_data (operands[0]); })