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 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 GNU CC.
11 ;; GNU CC 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 ;; GNU CC 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 GNU CC; 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)
39 (UNSPEC_EH_RECEIVER 10)
41 (UNSPEC_CONSTTABLE_QI 12)
42 (UNSPEC_CONSTTABLE_HI 13)
43 (UNSPEC_CONSTTABLE_SI 14)
44 (UNSPEC_CONSTTABLE_DI 15)
45 (UNSPEC_CONSTTABLE_SF 16)
46 (UNSPEC_CONSTTABLE_DF 17)
60 ;; Constants used in relocation unspecs. RELOC_GOT_PAGE and RELOC_GOT_DISP
61 ;; are really only available for n32 and n64. However, it is convenient
62 ;; to reuse them for SVR4 PIC, where they represent the local and global
63 ;; forms of R_MIPS_GOT16.
74 ;; ....................
78 ;; ....................
80 ;; For jal instructions, this attribute is DIRECT when the target address
81 ;; is symbolic and INDIRECT when it is a register.
82 (define_attr "jal" "unset,direct,indirect"
83 (const_string "unset"))
85 ;; True for multi-instruction jal macros. jal is always a macro
86 ;; in SVR4 PIC since it includes an instruction to restore $gp.
87 ;; Direct jals are also macros in NewABI PIC since they load the
88 ;; target address into $25.
89 (define_attr "jal_macro" "no,yes"
90 (cond [(eq_attr "jal" "direct")
91 (symbol_ref "TARGET_ABICALLS != 0")
92 (eq_attr "jal" "indirect")
93 (symbol_ref "(TARGET_ABICALLS && !TARGET_NEWABI) != 0")]
96 ;; Classification of each insn.
97 ;; branch conditional branch
98 ;; jump unconditional jump
99 ;; call unconditional call
100 ;; load load instruction(s)
101 ;; store store instruction(s)
102 ;; prefetch memory prefetch
103 ;; move data movement within same register set
104 ;; xfer transfer to/from coprocessor
105 ;; hilo transfer of hi/lo registers
106 ;; arith integer arithmetic instruction
107 ;; darith double precision integer arithmetic instructions
108 ;; const load constant
109 ;; imul integer multiply
110 ;; imadd integer multiply-add
111 ;; idiv integer divide
112 ;; icmp integer compare
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,store,prefetch,move,xfer,hilo,const,arith,darith,imul,imadd,idiv,icmp,fadd,fmul,fmadd,fdiv,fabs,fneg,fcmp,fcvt,fsqrt,frsqrt,multi,nop"
127 (cond [(eq_attr "jal" "!unset")
128 (const_string "call")]
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" (const_string "unknown"))
134 ;; Is this an extended instruction in mips16 mode?
135 (define_attr "extended_mips16" "no,yes"
138 ;; Length (in # of bytes). A conditional branch is allowed only to a
139 ;; location within a signed 18-bit offset of the delay slot. If that
140 ;; provides too smal a range, we use the `j' instruction. This
141 ;; instruction takes a 28-bit value, but that value is not an offset.
142 ;; Instead, it's bitwise-ored with the high-order four bits of the
143 ;; instruction in the delay slot, which means it cannot be used to
144 ;; cross a 256MB boundary. We could fall back back on the jr,
145 ;; instruction which allows full access to the entire address space,
146 ;; but we do not do so at present.
148 (define_attr "length" ""
149 (cond [(eq_attr "type" "branch")
150 (cond [(lt (abs (minus (match_dup 1) (plus (pc) (const_int 4))))
153 (ne (symbol_ref "flag_pic && ! TARGET_EMBEDDED_PIC")
157 (eq_attr "type" "const")
158 (symbol_ref "mips_const_insns (operands[1]) * 4")
159 (eq_attr "type" "load")
160 (symbol_ref "mips_fetch_insns (operands[1]) * 4")
161 (eq_attr "type" "store")
162 (symbol_ref "mips_fetch_insns (operands[0]) * 4")
163 ;; In the worst case, a call macro will take 8 instructions:
165 ;; lui $25,%call_hi(FOO)
167 ;; lw $25,%call_lo(FOO)($25)
173 (eq_attr "jal_macro" "yes")
175 (and (eq_attr "extended_mips16" "yes")
176 (ne (symbol_ref "TARGET_MIPS16") (const_int 0)))
180 ;; Attribute describing the processor. This attribute must match exactly
181 ;; with the processor_type enumeration in mips.h.
183 ;; Attribute describing the processor
184 ;; (define_attr "cpu" "default,r3000,r6000,r4000"
186 ;; (cond [(eq (symbol_ref "mips_cpu") (symbol_ref "PROCESSOR_R3000")) (const_string "r3000")
187 ;; (eq (symbol_ref "mips_cpu") (symbol_ref "PROCESSOR_R4000")) (const_string "r4000")
188 ;; (eq (symbol_ref "mips_cpu") (symbol_ref "PROCESSOR_R6000")) (const_string "r6000")]
189 ;; (const_string "default"))))
191 ;; ??? Fix everything that tests this attribute.
193 "default,4kc,5kc,20kc,m4k,r3000,r3900,r6000,r4000,r4100,r4111,r4120,r4300,r4600,r4650,r5000,r5400,r5500,r8000,sb1,sr71000"
194 (const (symbol_ref "mips_cpu_attr")))
196 ;; The type of hardware hazard associated with this instruction.
197 ;; DELAY means that the next instruction cannot read the result
198 ;; of this one. HILO means that the next two instructions cannot
199 ;; write to HI or LO.
200 (define_attr "hazard" "none,delay,hilo"
201 (cond [(and (eq_attr "type" "load")
202 (ne (symbol_ref "ISA_HAS_LOAD_DELAY") (const_int 0)))
203 (const_string "delay")
205 (and (eq_attr "type" "xfer")
206 (ne (symbol_ref "ISA_HAS_XFER_DELAY") (const_int 0)))
207 (const_string "delay")
209 (and (eq_attr "type" "fcmp")
210 (ne (symbol_ref "ISA_HAS_FCMP_DELAY") (const_int 0)))
211 (const_string "delay")
213 ;; The r4000 multiplication patterns include an mflo instruction.
214 (and (eq_attr "type" "imul")
215 (ne (symbol_ref "TARGET_MIPS4000") (const_int 0)))
216 (const_string "hilo")
218 (and (eq_attr "type" "hilo")
219 (and (eq (symbol_ref "ISA_HAS_HILO_INTERLOCKS") (const_int 0))
220 (match_operand 1 "hilo_operand" "")))
221 (const_string "hilo")]
222 (const_string "none")))
224 ;; Is it a single instruction?
225 (define_attr "single_insn" "no,yes"
226 (symbol_ref "get_attr_length (insn) == (TARGET_MIPS16 ? 2 : 4)"))
228 ;; Can the instruction be put into a delay slot?
229 (define_attr "can_delay" "no,yes"
230 (if_then_else (and (eq_attr "type" "!branch,call,jump")
231 (and (eq_attr "hazard" "none")
232 (eq_attr "single_insn" "yes")))
234 (const_string "no")))
236 ;; Attribute defining whether or not we can use the branch-likely instructions
238 (define_attr "branch_likely" "no,yes"
240 (if_then_else (ne (symbol_ref "GENERATE_BRANCHLIKELY") (const_int 0))
242 (const_string "no"))))
245 ;; Describe a user's asm statement.
246 (define_asm_attributes
247 [(set_attr "type" "multi")])
251 ;; .........................
253 ;; Delay slots, can't describe load/fcmp/xfer delay slots here
255 ;; .........................
257 (define_delay (and (eq_attr "type" "branch")
258 (eq (symbol_ref "mips16") (const_int 0)))
259 [(eq_attr "can_delay" "yes")
261 (and (eq_attr "branch_likely" "yes")
262 (eq_attr "can_delay" "yes"))])
264 (define_delay (eq_attr "type" "jump")
265 [(eq_attr "can_delay" "yes")
269 (define_delay (and (eq_attr "type" "call")
270 (eq_attr "jal_macro" "no"))
271 [(eq_attr "can_delay" "yes")
277 ;; .........................
281 ;; .........................
283 ; (define_function_unit NAME MULTIPLICITY SIMULTANEITY
284 ; TEST READY-DELAY ISSUE-DELAY [CONFLICT-LIST])
286 ;; Make the default case (PROCESSOR_DEFAULT) handle the worst case
288 (define_function_unit "memory" 1 0
289 (and (eq_attr "type" "load")
290 (eq_attr "cpu" "!r3000,r3900,r4600,r4650,r4100,r4120,r4300,r5000"))
293 (define_function_unit "memory" 1 0
294 (and (eq_attr "type" "load")
295 (eq_attr "cpu" "r3000,r3900,r4600,r4650,r4100,r4120,r4300,r5000"))
298 (define_function_unit "memory" 1 0 (eq_attr "type" "store") 1 0)
300 (define_function_unit "memory" 1 0 (eq_attr "type" "xfer") 2 0)
302 (define_function_unit "imuldiv" 1 0
303 (eq_attr "type" "hilo")
306 (define_function_unit "imuldiv" 1 0
307 (and (eq_attr "type" "imul,imadd")
308 (eq_attr "cpu" "!r3000,r3900,r4000,r4600,r4650,r4100,r4120,r4300,r5000"))
311 ;; On them mips16, we want to stronly discourage a mult from appearing
312 ;; after an mflo, since that requires explicit nop instructions. We
313 ;; do this by pretending that mflo ties up the function unit for long
314 ;; enough that the scheduler will ignore load stalls and the like when
315 ;; selecting instructions to between the two instructions.
317 (define_function_unit "imuldiv" 1 0
318 (and (eq_attr "type" "hilo") (ne (symbol_ref "mips16") (const_int 0)))
321 (define_function_unit "imuldiv" 1 0
322 (and (eq_attr "type" "imul,imadd") (eq_attr "cpu" "r3000,r3900"))
325 (define_function_unit "imuldiv" 1 0
326 (and (eq_attr "type" "imul,imadd") (eq_attr "cpu" "r4000,r4600"))
329 (define_function_unit "imuldiv" 1 0
330 (and (eq_attr "type" "imul,imadd") (eq_attr "cpu" "r4650"))
333 (define_function_unit "imuldiv" 1 0
334 (and (eq_attr "type" "imul,imadd")
335 (and (eq_attr "mode" "SI") (eq_attr "cpu" "r4100,r4120")))
338 (define_function_unit "imuldiv" 1 0
339 (and (eq_attr "type" "imul,imadd")
340 (and (eq_attr "mode" "DI") (eq_attr "cpu" "r4100,r4120")))
343 (define_function_unit "imuldiv" 1 0
344 (and (eq_attr "type" "imul,imadd")
345 (and (eq_attr "mode" "SI") (eq_attr "cpu" "r4300,r5000")))
348 (define_function_unit "imuldiv" 1 0
349 (and (eq_attr "type" "imul,imadd")
350 (and (eq_attr "mode" "DI") (eq_attr "cpu" "r4300")))
353 (define_function_unit "imuldiv" 1 0
354 (and (eq_attr "type" "imul,imadd")
355 (and (eq_attr "mode" "DI") (eq_attr "cpu" "r5000")))
358 (define_function_unit "imuldiv" 1 0
359 (and (eq_attr "type" "idiv")
360 (eq_attr "cpu" "!r3000,r3900,r4000,r4600,r4650,r4100,r4120,r4300,r5000"))
363 (define_function_unit "imuldiv" 1 0
364 (and (eq_attr "type" "idiv") (eq_attr "cpu" "r3000,r3900"))
367 (define_function_unit "imuldiv" 1 0
368 (and (eq_attr "type" "idiv") (eq_attr "cpu" "r4600"))
371 (define_function_unit "imuldiv" 1 0
372 (and (eq_attr "type" "idiv") (eq_attr "cpu" "r4650"))
375 (define_function_unit "imuldiv" 1 0
376 (and (eq_attr "type" "idiv") (eq_attr "cpu" "r4000"))
379 (define_function_unit "imuldiv" 1 0
380 (and (eq_attr "type" "idiv")
381 (and (eq_attr "mode" "SI") (eq_attr "cpu" "r4100,r4120")))
384 (define_function_unit "imuldiv" 1 0
385 (and (eq_attr "type" "idiv")
386 (and (eq_attr "mode" "DI") (eq_attr "cpu" "r4100,r4120")))
389 (define_function_unit "imuldiv" 1 0
390 (and (eq_attr "type" "idiv")
391 (and (eq_attr "mode" "SI") (eq_attr "cpu" "r4300")))
394 (define_function_unit "imuldiv" 1 0
395 (and (eq_attr "type" "idiv")
396 (and (eq_attr "mode" "DI") (eq_attr "cpu" "r4300")))
399 (define_function_unit "imuldiv" 1 0
400 (and (eq_attr "type" "idiv")
401 (and (eq_attr "mode" "SI") (eq_attr "cpu" "r5000")))
404 (define_function_unit "imuldiv" 1 0
405 (and (eq_attr "type" "idiv")
406 (and (eq_attr "mode" "DI") (eq_attr "cpu" "r5000")))
409 ;; The R4300 does *NOT* have a separate Floating Point Unit, instead
410 ;; the FP hardware is part of the normal ALU circuitry. This means FP
411 ;; instructions affect the pipe-line, and no functional unit
412 ;; parallelism can occur on R4300 processors. To force GCC into coding
413 ;; for only a single functional unit, we force the R4300 FP
414 ;; instructions to be processed in the "imuldiv" unit.
416 (define_function_unit "adder" 1 1
417 (and (eq_attr "type" "fcmp") (eq_attr "cpu" "!r3000,r3900,r6000,r4300,r5000"))
420 (define_function_unit "adder" 1 1
421 (and (eq_attr "type" "fcmp") (eq_attr "cpu" "r3000,r3900,r6000"))
424 (define_function_unit "adder" 1 1
425 (and (eq_attr "type" "fcmp") (eq_attr "cpu" "r5000"))
428 (define_function_unit "adder" 1 1
429 (and (eq_attr "type" "fadd") (eq_attr "cpu" "!r3000,r3900,r6000,r4300"))
432 (define_function_unit "adder" 1 1
433 (and (eq_attr "type" "fadd") (eq_attr "cpu" "r3000,r3900"))
436 (define_function_unit "adder" 1 1
437 (and (eq_attr "type" "fadd") (eq_attr "cpu" "r6000"))
440 (define_function_unit "adder" 1 1
441 (and (eq_attr "type" "fabs,fneg")
442 (eq_attr "cpu" "!r3000,r3900,r4600,r4650,r4300,r5000"))
445 (define_function_unit "adder" 1 1
446 (and (eq_attr "type" "fabs,fneg") (eq_attr "cpu" "r3000,r3900,r4600,r4650,r5000"))
449 (define_function_unit "mult" 1 1
450 (and (eq_attr "type" "fmul")
451 (and (eq_attr "mode" "SF")
452 (eq_attr "cpu" "!r3000,r3900,r6000,r4600,r4650,r4300,r5000")))
455 (define_function_unit "mult" 1 1
456 (and (eq_attr "type" "fmul")
457 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r3000,r3900,r5000")))
460 (define_function_unit "mult" 1 1
461 (and (eq_attr "type" "fmul")
462 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r6000")))
465 (define_function_unit "mult" 1 1
466 (and (eq_attr "type" "fmul")
467 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r4600,r4650")))
470 (define_function_unit "mult" 1 1
471 (and (eq_attr "type" "fmul")
472 (and (eq_attr "mode" "DF") (eq_attr "cpu" "!r3000,r3900,r6000,r4300,r5000")))
475 (define_function_unit "mult" 1 1
476 (and (eq_attr "type" "fmul")
477 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r3000,r3900,r5000")))
480 (define_function_unit "mult" 1 1
481 (and (eq_attr "type" "fmul")
482 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r6000")))
485 (define_function_unit "divide" 1 1
486 (and (eq_attr "type" "fdiv")
487 (and (eq_attr "mode" "SF")
488 (eq_attr "cpu" "!r3000,r3900,r6000,r4600,r4650,r4300,r5000")))
491 (define_function_unit "divide" 1 1
492 (and (eq_attr "type" "fdiv")
493 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r3000,r3900")))
496 (define_function_unit "divide" 1 1
497 (and (eq_attr "type" "fdiv")
498 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r6000")))
501 (define_function_unit "divide" 1 1
502 (and (eq_attr "type" "fdiv")
503 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r4600,r4650")))
506 (define_function_unit "divide" 1 1
507 (and (eq_attr "type" "fdiv")
508 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r5000")))
511 (define_function_unit "divide" 1 1
512 (and (eq_attr "type" "fdiv")
513 (and (eq_attr "mode" "DF")
514 (eq_attr "cpu" "!r3000,r3900,r6000,r4600,r4650,r4300")))
517 (define_function_unit "divide" 1 1
518 (and (eq_attr "type" "fdiv")
519 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r3000,r3900")))
522 (define_function_unit "divide" 1 1
523 (and (eq_attr "type" "fdiv")
524 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r6000")))
527 (define_function_unit "divide" 1 1
528 (and (eq_attr "type" "fdiv")
529 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r4600,r4650")))
532 ;;; ??? Is this number right?
533 (define_function_unit "divide" 1 1
534 (and (eq_attr "type" "fsqrt,frsqrt")
535 (and (eq_attr "mode" "SF") (eq_attr "cpu" "!r4600,r4650,r4300,r5000")))
538 (define_function_unit "divide" 1 1
539 (and (eq_attr "type" "fsqrt,frsqrt")
540 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r4600,r4650")))
543 (define_function_unit "divide" 1 1
544 (and (eq_attr "type" "fsqrt,frsqrt")
545 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r5000")))
548 ;;; ??? Is this number right?
549 (define_function_unit "divide" 1 1
550 (and (eq_attr "type" "fsqrt,frsqrt")
551 (and (eq_attr "mode" "DF") (eq_attr "cpu" "!r4600,r4650,r4300,r5000")))
554 (define_function_unit "divide" 1 1
555 (and (eq_attr "type" "fsqrt,frsqrt")
556 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r4600,r4650")))
559 (define_function_unit "divide" 1 1
560 (and (eq_attr "type" "fsqrt,frsqrt")
561 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r5000")))
564 ;; R4300 FP instruction classes treated as part of the "imuldiv"
567 (define_function_unit "imuldiv" 1 0
568 (and (eq_attr "type" "fadd") (eq_attr "cpu" "r4300"))
571 (define_function_unit "imuldiv" 1 0
572 (and (eq_attr "type" "fcmp,fabs,fneg") (eq_attr "cpu" "r4300"))
575 (define_function_unit "imuldiv" 1 0
576 (and (eq_attr "type" "fmul") (and (eq_attr "mode" "SF") (eq_attr "cpu" "r4300")))
578 (define_function_unit "imuldiv" 1 0
579 (and (eq_attr "type" "fmul") (and (eq_attr "mode" "DF") (eq_attr "cpu" "r4300")))
582 (define_function_unit "imuldiv" 1 0
583 (and (and (eq_attr "type" "fdiv") (eq_attr "type" "fsqrt,frsqrt"))
584 (and (eq_attr "mode" "SF") (eq_attr "cpu" "r4300")))
586 (define_function_unit "imuldiv" 1 0
587 (and (and (eq_attr "type" "fdiv") (eq_attr "type" "fsqrt,frsqrt"))
588 (and (eq_attr "mode" "DF") (eq_attr "cpu" "r4300")))
591 ;; The following functional units do not use the cpu type, and use
592 ;; much less memory in genattrtab.c.
594 ;; (define_function_unit "memory" 1 0 (eq_attr "type" "load") 3 0)
595 ;; (define_function_unit "memory" 1 0 (eq_attr "type" "store") 1 0)
597 ;; (define_function_unit "fp_comp" 1 0 (eq_attr "type" "fcmp") 2 0)
599 ;; (define_function_unit "transfer" 1 0 (eq_attr "type" "xfer") 2 0)
600 ;; (define_function_unit "transfer" 1 0 (eq_attr "type" "hilo") 3 0)
602 ;; (define_function_unit "imuldiv" 1 1 (eq_attr "type" "imul") 17 0)
603 ;; (define_function_unit "imuldiv" 1 1 (eq_attr "type" "idiv") 38 0)
605 ;; (define_function_unit "adder" 1 1 (eq_attr "type" "fadd") 4 0)
606 ;; (define_function_unit "adder" 1 1 (eq_attr "type" "fabs,fneg") 2 0)
608 ;; (define_function_unit "mult" 1 1 (and (eq_attr "type" "fmul") (eq_attr "mode" "SF")) 7 0)
609 ;; (define_function_unit "mult" 1 1 (and (eq_attr "type" "fmul") (eq_attr "mode" "DF")) 8 0)
611 ;; (define_function_unit "divide" 1 1 (and (eq_attr "type" "fdiv") (eq_attr "mode" "SF")) 23 0)
612 ;; (define_function_unit "divide" 1 1 (and (eq_attr "type" "fdiv") (eq_attr "mode" "DF")) 36 0)
614 ;; (define_function_unit "sqrt" 1 1 (and (eq_attr "type" "fsqrt") (eq_attr "mode" "SF")) 54 0)
615 ;; (define_function_unit "sqrt" 1 1 (and (eq_attr "type" "fsqrt") (eq_attr "mode" "DF")) 112 0)
617 ;; Include scheduling descriptions.
625 ;; ....................
629 ;; ....................
633 [(trap_if (const_int 1) (const_int 0))]
637 if (ISA_HAS_COND_TRAP)
638 return \"teq\\t$0,$0\";
639 else if (TARGET_MIPS16)
645 (define_expand "conditional_trap"
646 [(trap_if (match_operator 0 "cmp_op"
647 [(match_dup 2) (match_dup 3)])
648 (match_operand 1 "const_int_operand" ""))]
652 mips_gen_conditional_trap (operands);
656 ;; Match a TRAP_IF with 2nd arg of 0. The div_trap_* insns match a
657 ;; 2nd arg of any CONST_INT, so this insn must appear first.
658 ;; gen_div_trap always generates TRAP_IF with 2nd arg of 6 or 7.
661 [(trap_if (match_operator 0 "trap_cmp_op"
662 [(match_operand:SI 1 "reg_or_0_operand" "d")
663 (match_operand:SI 2 "nonmemory_operand" "dI")])
669 ;; ....................
673 ;; ....................
676 (define_insn "adddf3"
677 [(set (match_operand:DF 0 "register_operand" "=f")
678 (plus:DF (match_operand:DF 1 "register_operand" "f")
679 (match_operand:DF 2 "register_operand" "f")))]
680 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
682 [(set_attr "type" "fadd")
683 (set_attr "mode" "DF")])
685 (define_insn "addsf3"
686 [(set (match_operand:SF 0 "register_operand" "=f")
687 (plus:SF (match_operand:SF 1 "register_operand" "f")
688 (match_operand:SF 2 "register_operand" "f")))]
691 [(set_attr "type" "fadd")
692 (set_attr "mode" "SF")])
694 (define_expand "addsi3"
695 [(set (match_operand:SI 0 "register_operand" "")
696 (plus:SI (match_operand:SI 1 "reg_or_0_operand" "")
697 (match_operand:SI 2 "arith_operand" "")))]
701 /* The mips16 assembler handles -32768 correctly, and so does gas,
702 but some other MIPS assemblers think that -32768 needs to be
703 loaded into a register before it can be added in. */
706 && GET_CODE (operands[2]) == CONST_INT
707 && INTVAL (operands[2]) == -32768)
708 operands[2] = force_reg (SImode, operands[2]);
710 /* If a large stack adjustment was forced into a register, we may be
711 asked to generate rtx such as:
713 (set (reg:SI sp) (plus:SI (reg:SI sp) (reg:SI pseudo)))
715 but no such instruction is available in mips16. Handle it by
716 using a temporary. */
718 && REGNO (operands[0]) == STACK_POINTER_REGNUM
719 && ((GET_CODE (operands[1]) == REG
720 && REGNO (operands[1]) != STACK_POINTER_REGNUM)
721 || GET_CODE (operands[2]) != CONST_INT))
723 rtx tmp = gen_reg_rtx (SImode);
725 emit_move_insn (tmp, operands[1]);
726 emit_insn (gen_addsi3 (tmp, tmp, operands[2]));
727 emit_move_insn (operands[0], tmp);
732 (define_insn "addsi3_internal"
733 [(set (match_operand:SI 0 "register_operand" "=d,d")
734 (plus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ,dJ")
735 (match_operand:SI 2 "arith_operand" "d,Q")))]
738 || GET_CODE (operands[2]) != CONST_INT
739 || INTVAL (operands[2]) != -32768)"
743 [(set_attr "type" "arith")
744 (set_attr "mode" "SI")])
746 ;; For the mips16, we need to recognize stack pointer additions
747 ;; explicitly, since we don't have a constraint for $sp. These insns
748 ;; will be generated by the save_restore_insns functions.
753 (match_operand:SI 0 "small_int" "I")))]
756 [(set_attr "type" "arith")
757 (set_attr "mode" "SI")
758 (set (attr "length") (if_then_else (match_operand:VOID 0 "m16_simm8_8" "")
763 [(set (match_operand:SI 0 "register_operand" "=d")
765 (match_operand:SI 1 "small_int" "I")))]
768 [(set_attr "type" "arith")
769 (set_attr "mode" "SI")
770 (set (attr "length") (if_then_else (match_operand:VOID 1 "m16_uimm8_4" "")
775 [(set (match_operand:SI 0 "register_operand" "=d,d,d")
776 (plus:SI (match_operand:SI 1 "register_operand" "0,d,d")
777 (match_operand:SI 2 "arith_operand" "Q,O,d")))]
779 && (GET_CODE (operands[1]) != REG
780 || REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER
781 || M16_REG_P (REGNO (operands[1]))
782 || REGNO (operands[1]) == ARG_POINTER_REGNUM
783 || REGNO (operands[1]) == FRAME_POINTER_REGNUM
784 || REGNO (operands[1]) == STACK_POINTER_REGNUM)
785 && (GET_CODE (operands[2]) != REG
786 || REGNO (operands[2]) >= FIRST_PSEUDO_REGISTER
787 || M16_REG_P (REGNO (operands[2]))
788 || REGNO (operands[2]) == ARG_POINTER_REGNUM
789 || REGNO (operands[2]) == FRAME_POINTER_REGNUM
790 || REGNO (operands[2]) == STACK_POINTER_REGNUM)"
793 if (REGNO (operands[0]) == REGNO (operands[1]))
794 return \"addu\\t%0,%2\";
795 return \"addu\\t%0,%1,%2\";
797 [(set_attr "type" "arith")
798 (set_attr "mode" "SI")
799 (set_attr_alternative "length"
800 [(if_then_else (match_operand:VOID 2 "m16_simm8_1" "")
803 (if_then_else (match_operand:VOID 2 "m16_simm4_1" "")
809 ;; On the mips16, we can sometimes split an add of a constant which is
810 ;; a 4 byte instruction into two adds which are both 2 byte
811 ;; instructions. There are two cases: one where we are adding a
812 ;; constant plus a register to another register, and one where we are
813 ;; simply adding a constant to a register.
816 [(set (match_operand:SI 0 "register_operand" "")
817 (plus:SI (match_dup 0)
818 (match_operand:SI 1 "const_int_operand" "")))]
819 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
820 && GET_CODE (operands[0]) == REG
821 && M16_REG_P (REGNO (operands[0]))
822 && GET_CODE (operands[1]) == CONST_INT
823 && ((INTVAL (operands[1]) > 0x7f
824 && INTVAL (operands[1]) <= 0x7f + 0x7f)
825 || (INTVAL (operands[1]) < - 0x80
826 && INTVAL (operands[1]) >= - 0x80 - 0x80))"
827 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
828 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]
831 HOST_WIDE_INT val = INTVAL (operands[1]);
835 operands[1] = GEN_INT (0x7f);
836 operands[2] = GEN_INT (val - 0x7f);
840 operands[1] = GEN_INT (- 0x80);
841 operands[2] = GEN_INT (val + 0x80);
846 [(set (match_operand:SI 0 "register_operand" "")
847 (plus:SI (match_operand:SI 1 "register_operand" "")
848 (match_operand:SI 2 "const_int_operand" "")))]
849 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
850 && GET_CODE (operands[0]) == REG
851 && M16_REG_P (REGNO (operands[0]))
852 && GET_CODE (operands[1]) == REG
853 && M16_REG_P (REGNO (operands[1]))
854 && REGNO (operands[0]) != REGNO (operands[1])
855 && GET_CODE (operands[2]) == CONST_INT
856 && ((INTVAL (operands[2]) > 0x7
857 && INTVAL (operands[2]) <= 0x7 + 0x7f)
858 || (INTVAL (operands[2]) < - 0x8
859 && INTVAL (operands[2]) >= - 0x8 - 0x80))"
860 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))
861 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 3)))]
864 HOST_WIDE_INT val = INTVAL (operands[2]);
868 operands[2] = GEN_INT (0x7);
869 operands[3] = GEN_INT (val - 0x7);
873 operands[2] = GEN_INT (- 0x8);
874 operands[3] = GEN_INT (val + 0x8);
878 (define_expand "adddi3"
879 [(parallel [(set (match_operand:DI 0 "register_operand" "")
880 (plus:DI (match_operand:DI 1 "register_operand" "")
881 (match_operand:DI 2 "arith_operand" "")))
882 (clobber (match_dup 3))])]
883 "TARGET_64BIT || (!TARGET_DEBUG_G_MODE && !TARGET_MIPS16)"
886 /* The mips16 assembler handles -32768 correctly, and so does gas,
887 but some other MIPS assemblers think that -32768 needs to be
888 loaded into a register before it can be added in. */
891 && GET_CODE (operands[2]) == CONST_INT
892 && INTVAL (operands[2]) == -32768)
893 operands[2] = force_reg (DImode, operands[2]);
895 /* If a large stack adjustment was forced into a register, we may be
896 asked to generate rtx such as:
898 (set (reg:DI sp) (plus:DI (reg:DI sp) (reg:DI pseudo)))
900 but no such instruction is available in mips16. Handle it by
901 using a temporary. */
903 && REGNO (operands[0]) == STACK_POINTER_REGNUM
904 && ((GET_CODE (operands[1]) == REG
905 && REGNO (operands[1]) != STACK_POINTER_REGNUM)
906 || GET_CODE (operands[2]) != CONST_INT))
908 rtx tmp = gen_reg_rtx (DImode);
910 emit_move_insn (tmp, operands[1]);
911 emit_insn (gen_addsi3 (tmp, tmp, operands[2]));
912 emit_move_insn (operands[0], tmp);
918 emit_insn (gen_adddi3_internal_3 (operands[0], operands[1],
923 operands[3] = gen_reg_rtx (SImode);
926 (define_insn "adddi3_internal_1"
927 [(set (match_operand:DI 0 "register_operand" "=d,&d")
928 (plus:DI (match_operand:DI 1 "register_operand" "0,d")
929 (match_operand:DI 2 "register_operand" "d,d")))
930 (clobber (match_operand:SI 3 "register_operand" "=d,d"))]
931 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16"
934 return (REGNO (operands[0]) == REGNO (operands[1])
935 && REGNO (operands[0]) == REGNO (operands[2]))
936 ? \"srl\\t%3,%L0,31\;sll\\t%M0,%M0,1\;sll\\t%L0,%L1,1\;addu\\t%M0,%M0,%3\"
937 : \"addu\\t%L0,%L1,%L2\;sltu\\t%3,%L0,%L2\;addu\\t%M0,%M1,%M2\;addu\\t%M0,%M0,%3\";
939 [(set_attr "type" "darith")
940 (set_attr "mode" "DI")
941 (set_attr "length" "16")])
944 [(set (match_operand:DI 0 "register_operand" "")
945 (plus:DI (match_operand:DI 1 "register_operand" "")
946 (match_operand:DI 2 "register_operand" "")))
947 (clobber (match_operand:SI 3 "register_operand" ""))]
948 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
949 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
950 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
951 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
952 && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))
953 && (REGNO (operands[0]) != REGNO (operands[1])
954 || REGNO (operands[0]) != REGNO (operands[2]))"
956 [(set (subreg:SI (match_dup 0) 0)
957 (plus:SI (subreg:SI (match_dup 1) 0)
958 (subreg:SI (match_dup 2) 0)))
961 (ltu:SI (subreg:SI (match_dup 0) 0)
962 (subreg:SI (match_dup 2) 0)))
964 (set (subreg:SI (match_dup 0) 4)
965 (plus:SI (subreg:SI (match_dup 1) 4)
966 (subreg:SI (match_dup 2) 4)))
968 (set (subreg:SI (match_dup 0) 4)
969 (plus:SI (subreg:SI (match_dup 0) 4)
974 [(set (match_operand:DI 0 "register_operand" "")
975 (plus:DI (match_operand:DI 1 "register_operand" "")
976 (match_operand:DI 2 "register_operand" "")))
977 (clobber (match_operand:SI 3 "register_operand" ""))]
978 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
979 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
980 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
981 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
982 && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))
983 && (REGNO (operands[0]) != REGNO (operands[1])
984 || REGNO (operands[0]) != REGNO (operands[2]))"
986 [(set (subreg:SI (match_dup 0) 4)
987 (plus:SI (subreg:SI (match_dup 1) 4)
988 (subreg:SI (match_dup 2) 4)))
991 (ltu:SI (subreg:SI (match_dup 0) 4)
992 (subreg:SI (match_dup 2) 4)))
994 (set (subreg:SI (match_dup 0) 0)
995 (plus:SI (subreg:SI (match_dup 1) 0)
996 (subreg:SI (match_dup 2) 0)))
998 (set (subreg:SI (match_dup 0) 0)
999 (plus:SI (subreg:SI (match_dup 0) 0)
1003 (define_insn "adddi3_internal_2"
1004 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1005 (plus:DI (match_operand:DI 1 "register_operand" "%d,%d,%d")
1006 (match_operand:DI 2 "small_int" "P,J,N")))
1007 (clobber (match_operand:SI 3 "register_operand" "=d,d,d"))]
1008 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
1010 || GET_CODE (operands[2]) != CONST_INT
1011 || INTVAL (operands[2]) != -32768)"
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" "darith")
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")))]
1075 || GET_CODE (operands[2]) != CONST_INT
1076 || INTVAL (operands[2]) != -32768)"
1080 [(set_attr "type" "darith")
1081 (set_attr "mode" "DI")])
1083 ;; For the mips16, we need to recognize stack pointer additions
1084 ;; explicitly, since we don't have a constraint for $sp. These insns
1085 ;; will be generated by the save_restore_insns functions.
1089 (plus:DI (reg:DI 29)
1090 (match_operand:DI 0 "small_int" "I")))]
1091 "TARGET_MIPS16 && TARGET_64BIT"
1093 [(set_attr "type" "arith")
1094 (set_attr "mode" "DI")
1095 (set (attr "length") (if_then_else (match_operand:VOID 0 "m16_simm8_8" "")
1100 [(set (match_operand:DI 0 "register_operand" "=d")
1101 (plus:DI (reg:DI 29)
1102 (match_operand:DI 1 "small_int" "I")))]
1103 "TARGET_MIPS16 && TARGET_64BIT"
1105 [(set_attr "type" "arith")
1106 (set_attr "mode" "DI")
1107 (set (attr "length") (if_then_else (match_operand:VOID 0 "m16_uimm5_4" "")
1112 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1113 (plus:DI (match_operand:DI 1 "register_operand" "0,d,d")
1114 (match_operand:DI 2 "arith_operand" "Q,O,d")))]
1115 "TARGET_MIPS16 && TARGET_64BIT
1116 && (GET_CODE (operands[1]) != REG
1117 || REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER
1118 || M16_REG_P (REGNO (operands[1]))
1119 || REGNO (operands[1]) == ARG_POINTER_REGNUM
1120 || REGNO (operands[1]) == FRAME_POINTER_REGNUM
1121 || REGNO (operands[1]) == STACK_POINTER_REGNUM)
1122 && (GET_CODE (operands[2]) != REG
1123 || REGNO (operands[2]) >= FIRST_PSEUDO_REGISTER
1124 || M16_REG_P (REGNO (operands[2]))
1125 || REGNO (operands[2]) == ARG_POINTER_REGNUM
1126 || REGNO (operands[2]) == FRAME_POINTER_REGNUM
1127 || REGNO (operands[2]) == STACK_POINTER_REGNUM)"
1130 if (REGNO (operands[0]) == REGNO (operands[1]))
1131 return \"daddu\\t%0,%2\";
1132 return \"daddu\\t%0,%1,%2\";
1134 [(set_attr "type" "arith")
1135 (set_attr "mode" "DI")
1136 (set_attr_alternative "length"
1137 [(if_then_else (match_operand:VOID 2 "m16_simm5_1" "")
1140 (if_then_else (match_operand:VOID 2 "m16_simm4_1" "")
1146 ;; On the mips16, we can sometimes split an add of a constant which is
1147 ;; a 4 byte instruction into two adds which are both 2 byte
1148 ;; instructions. There are two cases: one where we are adding a
1149 ;; constant plus a register to another register, and one where we are
1150 ;; simply adding a constant to a register.
1153 [(set (match_operand:DI 0 "register_operand" "")
1154 (plus:DI (match_dup 0)
1155 (match_operand:DI 1 "const_int_operand" "")))]
1156 "TARGET_MIPS16 && TARGET_64BIT && reload_completed && !TARGET_DEBUG_D_MODE
1157 && GET_CODE (operands[0]) == REG
1158 && M16_REG_P (REGNO (operands[0]))
1159 && GET_CODE (operands[1]) == CONST_INT
1160 && ((INTVAL (operands[1]) > 0xf
1161 && INTVAL (operands[1]) <= 0xf + 0xf)
1162 || (INTVAL (operands[1]) < - 0x10
1163 && INTVAL (operands[1]) >= - 0x10 - 0x10))"
1164 [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1)))
1165 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))]
1168 HOST_WIDE_INT val = INTVAL (operands[1]);
1172 operands[1] = GEN_INT (0xf);
1173 operands[2] = GEN_INT (val - 0xf);
1177 operands[1] = GEN_INT (- 0x10);
1178 operands[2] = GEN_INT (val + 0x10);
1183 [(set (match_operand:DI 0 "register_operand" "")
1184 (plus:DI (match_operand:DI 1 "register_operand" "")
1185 (match_operand:DI 2 "const_int_operand" "")))]
1186 "TARGET_MIPS16 && TARGET_64BIT && reload_completed && !TARGET_DEBUG_D_MODE
1187 && GET_CODE (operands[0]) == REG
1188 && M16_REG_P (REGNO (operands[0]))
1189 && GET_CODE (operands[1]) == REG
1190 && M16_REG_P (REGNO (operands[1]))
1191 && REGNO (operands[0]) != REGNO (operands[1])
1192 && GET_CODE (operands[2]) == CONST_INT
1193 && ((INTVAL (operands[2]) > 0x7
1194 && INTVAL (operands[2]) <= 0x7 + 0xf)
1195 || (INTVAL (operands[2]) < - 0x8
1196 && INTVAL (operands[2]) >= - 0x8 - 0x10))"
1197 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))
1198 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
1201 HOST_WIDE_INT val = INTVAL (operands[2]);
1205 operands[2] = GEN_INT (0x7);
1206 operands[3] = GEN_INT (val - 0x7);
1210 operands[2] = GEN_INT (- 0x8);
1211 operands[3] = GEN_INT (val + 0x8);
1215 (define_insn "addsi3_internal_2"
1216 [(set (match_operand:DI 0 "register_operand" "=d,d")
1217 (sign_extend:DI (plus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ,dJ")
1218 (match_operand:SI 2 "arith_operand" "d,Q"))))]
1222 || GET_CODE (operands[2]) != CONST_INT
1223 || INTVAL (operands[2]) != -32768)"
1227 [(set_attr "type" "arith")
1228 (set_attr "mode" "SI")])
1231 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1232 (sign_extend:DI (plus:SI (match_operand:SI 1 "register_operand" "0,d,d")
1233 (match_operand:SI 2 "arith_operand" "Q,O,d"))))]
1234 "TARGET_MIPS16 && TARGET_64BIT"
1237 if (REGNO (operands[0]) == REGNO (operands[1]))
1238 return \"addu\\t%0,%2\";
1239 return \"addu\\t%0,%1,%2\";
1241 [(set_attr "type" "arith")
1242 (set_attr "mode" "SI")
1243 (set_attr_alternative "length"
1244 [(if_then_else (match_operand:VOID 2 "m16_simm8_1" "")
1247 (if_then_else (match_operand:VOID 2 "m16_simm4_1" "")
1254 ;; ....................
1258 ;; ....................
1261 (define_insn "subdf3"
1262 [(set (match_operand:DF 0 "register_operand" "=f")
1263 (minus:DF (match_operand:DF 1 "register_operand" "f")
1264 (match_operand:DF 2 "register_operand" "f")))]
1265 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
1267 [(set_attr "type" "fadd")
1268 (set_attr "mode" "DF")])
1270 (define_insn "subsf3"
1271 [(set (match_operand:SF 0 "register_operand" "=f")
1272 (minus:SF (match_operand:SF 1 "register_operand" "f")
1273 (match_operand:SF 2 "register_operand" "f")))]
1276 [(set_attr "type" "fadd")
1277 (set_attr "mode" "SF")])
1279 (define_expand "subsi3"
1280 [(set (match_operand:SI 0 "register_operand" "=d")
1281 (minus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ")
1282 (match_operand:SI 2 "arith_operand" "dI")))]
1286 if (GET_CODE (operands[2]) == CONST_INT
1287 && (INTVAL (operands[2]) == -32768
1289 && INTVAL (operands[2]) == -0x4000)))
1290 operands[2] = force_reg (SImode, operands[2]);
1293 (define_insn "subsi3_internal"
1294 [(set (match_operand:SI 0 "register_operand" "=d")
1295 (minus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ")
1296 (match_operand:SI 2 "arith_operand" "dI")))]
1298 && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != -32768)"
1300 [(set_attr "type" "arith")
1301 (set_attr "mode" "SI")])
1303 ;; For the mips16, we need to recognize stack pointer subtractions
1304 ;; explicitly, since we don't have a constraint for $sp. These insns
1305 ;; will be generated by the save_restore_insns functions.
1309 (minus:SI (reg:SI 29)
1310 (match_operand:SI 0 "small_int" "I")))]
1312 && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != -32768)"
1314 [(set_attr "type" "arith")
1315 (set_attr "mode" "SI")
1316 (set (attr "length") (if_then_else (match_operand:VOID 0 "m16_nsimm8_8" "")
1321 [(set (match_operand:SI 0 "register_operand" "=d")
1322 (minus:SI (reg:SI 29)
1323 (match_operand:SI 1 "small_int" "I")))]
1325 && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != -32768)"
1327 [(set_attr "type" "arith")
1328 (set_attr "mode" "SI")
1329 (set (attr "length") (if_then_else (match_operand:VOID 1 "m16_nuimm8_4" "")
1335 [(set (match_operand:SI 0 "register_operand" "=d,d,d")
1336 (minus:SI (match_operand:SI 1 "register_operand" "0,d,d")
1337 (match_operand:SI 2 "arith_operand" "I,O,d")))]
1339 && (GET_CODE (operands[2]) != CONST_INT
1340 || (INTVAL (operands[2]) != -32768 && INTVAL (operands[2]) != -0x4000))"
1343 if (REGNO (operands[0]) == REGNO (operands[1]))
1344 return \"subu\\t%0,%2\";
1345 return \"subu\\t%0,%1,%2\";
1347 [(set_attr "type" "arith")
1348 (set_attr "mode" "SI")
1349 (set_attr_alternative "length"
1350 [(if_then_else (match_operand:VOID 2 "m16_nsimm8_1" "")
1353 (if_then_else (match_operand:VOID 2 "m16_nsimm4_1" "")
1358 ;; On the mips16, we can sometimes split a subtract of a constant
1359 ;; which is a 4 byte instruction into two adds which are both 2 byte
1360 ;; instructions. There are two cases: one where we are setting a
1361 ;; register to a register minus a constant, and one where we are
1362 ;; simply subtracting a constant from a register.
1365 [(set (match_operand:SI 0 "register_operand" "")
1366 (minus:SI (match_dup 0)
1367 (match_operand:SI 1 "const_int_operand" "")))]
1368 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
1369 && GET_CODE (operands[0]) == REG
1370 && M16_REG_P (REGNO (operands[0]))
1371 && GET_CODE (operands[1]) == CONST_INT
1372 && ((INTVAL (operands[1]) > 0x80
1373 && INTVAL (operands[1]) <= 0x80 + 0x80)
1374 || (INTVAL (operands[1]) < - 0x7f
1375 && INTVAL (operands[1]) >= - 0x7f - 0x7f))"
1376 [(set (match_dup 0) (minus:SI (match_dup 0) (match_dup 1)))
1377 (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
1380 HOST_WIDE_INT val = INTVAL (operands[1]);
1384 operands[1] = GEN_INT (0x80);
1385 operands[2] = GEN_INT (val - 0x80);
1389 operands[1] = GEN_INT (- 0x7f);
1390 operands[2] = GEN_INT (val + 0x7f);
1395 [(set (match_operand:SI 0 "register_operand" "")
1396 (minus:SI (match_operand:SI 1 "register_operand" "")
1397 (match_operand:SI 2 "const_int_operand" "")))]
1398 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
1399 && GET_CODE (operands[0]) == REG
1400 && M16_REG_P (REGNO (operands[0]))
1401 && GET_CODE (operands[1]) == REG
1402 && M16_REG_P (REGNO (operands[1]))
1403 && REGNO (operands[0]) != REGNO (operands[1])
1404 && GET_CODE (operands[2]) == CONST_INT
1405 && ((INTVAL (operands[2]) > 0x8
1406 && INTVAL (operands[2]) <= 0x8 + 0x80)
1407 || (INTVAL (operands[2]) < - 0x7
1408 && INTVAL (operands[2]) >= - 0x7 - 0x7f))"
1409 [(set (match_dup 0) (minus:SI (match_dup 1) (match_dup 2)))
1410 (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 3)))]
1413 HOST_WIDE_INT val = INTVAL (operands[2]);
1417 operands[2] = GEN_INT (0x8);
1418 operands[3] = GEN_INT (val - 0x8);
1422 operands[2] = GEN_INT (- 0x7);
1423 operands[3] = GEN_INT (val + 0x7);
1427 (define_expand "subdi3"
1428 [(parallel [(set (match_operand:DI 0 "register_operand" "=d")
1429 (minus:DI (match_operand:DI 1 "register_operand" "d")
1430 (match_operand:DI 2 "register_operand" "d")))
1431 (clobber (match_dup 3))])]
1432 "TARGET_64BIT || (!TARGET_DEBUG_G_MODE && !TARGET_MIPS16)"
1437 emit_insn (gen_subdi3_internal_3 (operands[0], operands[1],
1442 operands[3] = gen_reg_rtx (SImode);
1445 (define_insn "subdi3_internal"
1446 [(set (match_operand:DI 0 "register_operand" "=d")
1447 (minus:DI (match_operand:DI 1 "register_operand" "d")
1448 (match_operand:DI 2 "register_operand" "d")))
1449 (clobber (match_operand:SI 3 "register_operand" "=d"))]
1450 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16"
1451 "sltu\\t%3,%L1,%L2\;subu\\t%L0,%L1,%L2\;subu\\t%M0,%M1,%M2\;subu\\t%M0,%M0,%3"
1452 [(set_attr "type" "darith")
1453 (set_attr "mode" "DI")
1454 (set_attr "length" "16")])
1457 [(set (match_operand:DI 0 "register_operand" "")
1458 (minus:DI (match_operand:DI 1 "register_operand" "")
1459 (match_operand:DI 2 "register_operand" "")))
1460 (clobber (match_operand:SI 3 "register_operand" ""))]
1461 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
1462 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
1463 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1464 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1465 && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))"
1468 (ltu:SI (subreg:SI (match_dup 1) 0)
1469 (subreg:SI (match_dup 2) 0)))
1471 (set (subreg:SI (match_dup 0) 0)
1472 (minus:SI (subreg:SI (match_dup 1) 0)
1473 (subreg:SI (match_dup 2) 0)))
1475 (set (subreg:SI (match_dup 0) 4)
1476 (minus:SI (subreg:SI (match_dup 1) 4)
1477 (subreg:SI (match_dup 2) 4)))
1479 (set (subreg:SI (match_dup 0) 4)
1480 (minus:SI (subreg:SI (match_dup 0) 4)
1485 [(set (match_operand:DI 0 "register_operand" "")
1486 (minus:DI (match_operand:DI 1 "register_operand" "")
1487 (match_operand:DI 2 "register_operand" "")))
1488 (clobber (match_operand:SI 3 "register_operand" ""))]
1489 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
1490 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
1491 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1492 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1493 && GET_CODE (operands[2]) == REG && GP_REG_P (REGNO (operands[2]))"
1496 (ltu:SI (subreg:SI (match_dup 1) 4)
1497 (subreg:SI (match_dup 2) 4)))
1499 (set (subreg:SI (match_dup 0) 4)
1500 (minus:SI (subreg:SI (match_dup 1) 4)
1501 (subreg:SI (match_dup 2) 4)))
1503 (set (subreg:SI (match_dup 0) 0)
1504 (minus:SI (subreg:SI (match_dup 1) 0)
1505 (subreg:SI (match_dup 2) 0)))
1507 (set (subreg:SI (match_dup 0) 0)
1508 (minus:SI (subreg:SI (match_dup 0) 0)
1512 (define_insn "subdi3_internal_2"
1513 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1514 (minus:DI (match_operand:DI 1 "register_operand" "d,d,d")
1515 (match_operand:DI 2 "small_int" "P,J,N")))
1516 (clobber (match_operand:SI 3 "register_operand" "=d,d,d"))]
1517 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
1518 && INTVAL (operands[2]) != -32768"
1520 sltu\\t%3,%L1,%2\;subu\\t%L0,%L1,%2\;subu\\t%M0,%M1,%3
1521 move\\t%L0,%L1\;move\\t%M0,%M1
1522 sltu\\t%3,%L1,%2\;subu\\t%L0,%L1,%2\;subu\\t%M0,%M1,1\;subu\\t%M0,%M0,%3"
1523 [(set_attr "type" "darith")
1524 (set_attr "mode" "DI")
1525 (set_attr "length" "12,8,16")])
1528 [(set (match_operand:DI 0 "register_operand" "")
1529 (minus:DI (match_operand:DI 1 "register_operand" "")
1530 (match_operand:DI 2 "small_int" "")))
1531 (clobber (match_operand:SI 3 "register_operand" ""))]
1532 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
1533 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
1534 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1535 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1536 && INTVAL (operands[2]) > 0"
1539 (ltu:SI (subreg:SI (match_dup 1) 0)
1542 (set (subreg:SI (match_dup 0) 0)
1543 (minus:SI (subreg:SI (match_dup 1) 0)
1546 (set (subreg:SI (match_dup 0) 4)
1547 (minus:SI (subreg:SI (match_dup 1) 4)
1552 [(set (match_operand:DI 0 "register_operand" "")
1553 (minus:DI (match_operand:DI 1 "register_operand" "")
1554 (match_operand:DI 2 "small_int" "")))
1555 (clobber (match_operand:SI 3 "register_operand" ""))]
1556 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
1557 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
1558 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1559 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1560 && INTVAL (operands[2]) > 0"
1563 (ltu:SI (subreg:SI (match_dup 1) 4)
1566 (set (subreg:SI (match_dup 0) 4)
1567 (minus:SI (subreg:SI (match_dup 1) 4)
1570 (set (subreg:SI (match_dup 0) 0)
1571 (minus:SI (subreg:SI (match_dup 1) 0)
1575 (define_insn "subdi3_internal_3"
1576 [(set (match_operand:DI 0 "register_operand" "=d")
1577 (minus:DI (match_operand:DI 1 "reg_or_0_operand" "dJ")
1578 (match_operand:DI 2 "arith_operand" "dI")))]
1579 "TARGET_64BIT && !TARGET_MIPS16
1580 && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != -32768)"
1583 return (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
1584 ? \"daddu\\t%0,%z1,%n2\"
1585 : \"dsubu\\t%0,%z1,%2\";
1587 [(set_attr "type" "darith")
1588 (set_attr "mode" "DI")])
1590 ;; For the mips16, we need to recognize stack pointer subtractions
1591 ;; explicitly, since we don't have a constraint for $sp. These insns
1592 ;; will be generated by the save_restore_insns functions.
1596 (minus:DI (reg:DI 29)
1597 (match_operand:DI 0 "small_int" "I")))]
1599 && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != -32768)"
1601 [(set_attr "type" "arith")
1602 (set_attr "mode" "DI")
1603 (set (attr "length") (if_then_else (match_operand:VOID 0 "m16_nsimm8_8" "")
1608 [(set (match_operand:DI 0 "register_operand" "=d")
1609 (minus:DI (reg:DI 29)
1610 (match_operand:DI 1 "small_int" "I")))]
1612 && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != -32768)"
1614 [(set_attr "type" "arith")
1615 (set_attr "mode" "DI")
1616 (set (attr "length") (if_then_else (match_operand:VOID 0 "m16_nuimm5_4" "")
1621 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1622 (minus:DI (match_operand:DI 1 "register_operand" "0,d,d")
1623 (match_operand:DI 2 "arith_operand" "I,O,d")))]
1625 && (GET_CODE (operands[2]) != CONST_INT
1626 || (INTVAL (operands[2]) != -32768 && INTVAL (operands[2]) != -0x4000))"
1629 if (REGNO (operands[0]) == REGNO (operands[1]))
1630 return \"dsubu\\t%0,%2\";
1631 return \"dsubu\\t%0,%1,%2\";
1633 [(set_attr "type" "arith")
1634 (set_attr "mode" "DI")
1635 (set_attr_alternative "length"
1636 [(if_then_else (match_operand:VOID 2 "m16_nsimm5_1" "")
1639 (if_then_else (match_operand:VOID 2 "m16_nsimm4_1" "")
1644 ;; On the mips16, we can sometimes split an add of a constant which is
1645 ;; a 4 byte instruction into two adds which are both 2 byte
1646 ;; instructions. There are two cases: one where we are adding a
1647 ;; constant plus a register to another register, and one where we are
1648 ;; simply adding a constant to a register.
1651 [(set (match_operand:DI 0 "register_operand" "")
1652 (minus:DI (match_dup 0)
1653 (match_operand:DI 1 "const_int_operand" "")))]
1654 "TARGET_MIPS16 && TARGET_64BIT && reload_completed && !TARGET_DEBUG_D_MODE
1655 && GET_CODE (operands[0]) == REG
1656 && M16_REG_P (REGNO (operands[0]))
1657 && GET_CODE (operands[1]) == CONST_INT
1658 && ((INTVAL (operands[1]) > 0x10
1659 && INTVAL (operands[1]) <= 0x10 + 0x10)
1660 || (INTVAL (operands[1]) < - 0xf
1661 && INTVAL (operands[1]) >= - 0xf - 0xf))"
1662 [(set (match_dup 0) (minus:DI (match_dup 0) (match_dup 1)))
1663 (set (match_dup 0) (minus:DI (match_dup 0) (match_dup 2)))]
1666 HOST_WIDE_INT val = INTVAL (operands[1]);
1670 operands[1] = GEN_INT (0xf);
1671 operands[2] = GEN_INT (val - 0xf);
1675 operands[1] = GEN_INT (- 0x10);
1676 operands[2] = GEN_INT (val + 0x10);
1681 [(set (match_operand:DI 0 "register_operand" "")
1682 (minus:DI (match_operand:DI 1 "register_operand" "")
1683 (match_operand:DI 2 "const_int_operand" "")))]
1684 "TARGET_MIPS16 && TARGET_64BIT && reload_completed && !TARGET_DEBUG_D_MODE
1685 && GET_CODE (operands[0]) == REG
1686 && M16_REG_P (REGNO (operands[0]))
1687 && GET_CODE (operands[1]) == REG
1688 && M16_REG_P (REGNO (operands[1]))
1689 && REGNO (operands[0]) != REGNO (operands[1])
1690 && GET_CODE (operands[2]) == CONST_INT
1691 && ((INTVAL (operands[2]) > 0x8
1692 && INTVAL (operands[2]) <= 0x8 + 0x10)
1693 || (INTVAL (operands[2]) < - 0x7
1694 && INTVAL (operands[2]) >= - 0x7 - 0xf))"
1695 [(set (match_dup 0) (minus:DI (match_dup 1) (match_dup 2)))
1696 (set (match_dup 0) (minus:DI (match_dup 0) (match_dup 3)))]
1699 HOST_WIDE_INT val = INTVAL (operands[2]);
1703 operands[2] = GEN_INT (0x8);
1704 operands[3] = GEN_INT (val - 0x8);
1708 operands[2] = GEN_INT (- 0x7);
1709 operands[3] = GEN_INT (val + 0x7);
1713 (define_insn "subsi3_internal_2"
1714 [(set (match_operand:DI 0 "register_operand" "=d")
1715 (sign_extend:DI (minus:SI (match_operand:SI 1 "reg_or_0_operand" "dJ")
1716 (match_operand:SI 2 "arith_operand" "dI"))))]
1717 "TARGET_64BIT && !TARGET_MIPS16
1718 && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != -32768)"
1721 return (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
1722 ? \"addu\\t%0,%z1,%n2\"
1723 : \"subu\\t%0,%z1,%2\";
1725 [(set_attr "type" "arith")
1726 (set_attr "mode" "DI")])
1729 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1730 (sign_extend:DI (minus:SI (match_operand:SI 1 "register_operand" "0,d,d")
1731 (match_operand:SI 2 "arith_operand" "I,O,d"))))]
1732 "TARGET_64BIT && TARGET_MIPS16
1733 && (GET_CODE (operands[2]) != CONST_INT
1734 || (INTVAL (operands[2]) != -32768 && INTVAL (operands[2]) != -0x4000))"
1737 if (REGNO (operands[0]) == REGNO (operands[1]))
1738 return \"subu\\t%0,%2\";
1739 return \"subu\\t%0,%1,%2\";
1741 [(set_attr "type" "arith")
1742 (set_attr "mode" "SI")
1743 (set_attr_alternative "length"
1744 [(if_then_else (match_operand:VOID 2 "m16_nsimm8_1" "")
1747 (if_then_else (match_operand:VOID 2 "m16_nsimm4_1" "")
1755 ;; ....................
1759 ;; ....................
1762 ;; Early Vr4300 silicon has a CPU bug where multiplies with certain
1763 ;; operands may corrupt immediately following multiplies. This is a
1764 ;; simple fix to insert NOPs.
1766 (define_expand "muldf3"
1767 [(set (match_operand:DF 0 "register_operand" "=f")
1768 (mult:DF (match_operand:DF 1 "register_operand" "f")
1769 (match_operand:DF 2 "register_operand" "f")))]
1770 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
1773 if (!TARGET_MIPS4300)
1774 emit_insn (gen_muldf3_internal (operands[0], operands[1], operands[2]));
1776 emit_insn (gen_muldf3_r4300 (operands[0], operands[1], operands[2]));
1780 (define_insn "muldf3_internal"
1781 [(set (match_operand:DF 0 "register_operand" "=f")
1782 (mult:DF (match_operand:DF 1 "register_operand" "f")
1783 (match_operand:DF 2 "register_operand" "f")))]
1784 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_MIPS4300"
1786 [(set_attr "type" "fmul")
1787 (set_attr "mode" "DF")])
1789 (define_insn "muldf3_r4300"
1790 [(set (match_operand:DF 0 "register_operand" "=f")
1791 (mult:DF (match_operand:DF 1 "register_operand" "f")
1792 (match_operand:DF 2 "register_operand" "f")))]
1793 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_MIPS4300"
1796 output_asm_insn (\"mul.d\\t%0,%1,%2\", operands);
1797 if (TARGET_4300_MUL_FIX)
1798 output_asm_insn (\"nop\", operands);
1801 [(set_attr "type" "fmul")
1802 (set_attr "mode" "DF")
1803 (set_attr "length" "8")]) ;; mul.d + nop
1805 (define_expand "mulsf3"
1806 [(set (match_operand:SF 0 "register_operand" "=f")
1807 (mult:SF (match_operand:SF 1 "register_operand" "f")
1808 (match_operand:SF 2 "register_operand" "f")))]
1812 if (!TARGET_MIPS4300)
1813 emit_insn( gen_mulsf3_internal (operands[0], operands[1], operands[2]));
1815 emit_insn( gen_mulsf3_r4300 (operands[0], operands[1], operands[2]));
1819 (define_insn "mulsf3_internal"
1820 [(set (match_operand:SF 0 "register_operand" "=f")
1821 (mult:SF (match_operand:SF 1 "register_operand" "f")
1822 (match_operand:SF 2 "register_operand" "f")))]
1823 "TARGET_HARD_FLOAT && !TARGET_MIPS4300"
1825 [(set_attr "type" "fmul")
1826 (set_attr "mode" "SF")])
1828 (define_insn "mulsf3_r4300"
1829 [(set (match_operand:SF 0 "register_operand" "=f")
1830 (mult:SF (match_operand:SF 1 "register_operand" "f")
1831 (match_operand:SF 2 "register_operand" "f")))]
1832 "TARGET_HARD_FLOAT && TARGET_MIPS4300"
1835 output_asm_insn (\"mul.s\\t%0,%1,%2\", operands);
1836 if (TARGET_4300_MUL_FIX)
1837 output_asm_insn (\"nop\", operands);
1840 [(set_attr "type" "fmul")
1841 (set_attr "mode" "SF")
1842 (set_attr "length" "8")]) ;; mul.s + nop
1845 ;; ??? The R4000 (only) has a cpu bug. If a double-word shift executes while
1846 ;; a multiply is in progress, it may give an incorrect result. Avoid
1847 ;; this by keeping the mflo with the mult on the R4000.
1849 (define_expand "mulsi3"
1850 [(set (match_operand:SI 0 "register_operand" "=l")
1851 (mult:SI (match_operand:SI 1 "register_operand" "d")
1852 (match_operand:SI 2 "register_operand" "d")))
1853 (clobber (match_scratch:SI 3 "=h"))
1854 (clobber (match_scratch:SI 4 "=a"))]
1858 if (GENERATE_MULT3_SI || TARGET_MAD)
1859 emit_insn (gen_mulsi3_mult3 (operands[0], operands[1], operands[2]));
1860 else if (!TARGET_MIPS4000 || TARGET_MIPS16)
1861 emit_insn (gen_mulsi3_internal (operands[0], operands[1], operands[2]));
1863 emit_insn (gen_mulsi3_r4000 (operands[0], operands[1], operands[2]));
1867 (define_insn "mulsi3_mult3"
1868 [(set (match_operand:SI 0 "register_operand" "=d,l")
1869 (mult:SI (match_operand:SI 1 "register_operand" "d,d")
1870 (match_operand:SI 2 "register_operand" "d,d")))
1871 (clobber (match_scratch:SI 3 "=h,h"))
1872 (clobber (match_scratch:SI 4 "=l,X"))
1873 (clobber (match_scratch:SI 5 "=a,a"))]
1878 if (which_alternative == 1)
1879 return \"mult\\t%1,%2\";
1886 return \"mul\\t%0,%1,%2\";
1887 return \"mult\\t%0,%1,%2\";
1889 [(set_attr "type" "imul")
1890 (set_attr "mode" "SI")])
1892 ;; If a register gets allocated to LO, and we spill to memory, the reload
1893 ;; will include a move from LO to a GPR. Merge it into the multiplication
1894 ;; if it can set the GPR directly.
1897 ;; Operand 1: GPR (1st multiplication operand)
1898 ;; Operand 2: GPR (2nd multiplication operand)
1901 ;; Operand 5: GPR (destination)
1904 [(set (match_operand:SI 0 "register_operand" "")
1905 (mult:SI (match_operand:SI 1 "register_operand" "")
1906 (match_operand:SI 2 "register_operand" "")))
1907 (clobber (match_operand:SI 3 "register_operand" ""))
1908 (clobber (scratch:SI))
1909 (clobber (match_operand:SI 4 "register_operand" ""))])
1910 (set (match_operand:SI 5 "register_operand" "")
1913 && true_regnum (operands[0]) == LO_REGNUM
1914 && GP_REG_P (true_regnum (operands[5]))
1915 && peep2_reg_dead_p (2, operands[0])"
1918 (mult:SI (match_dup 1)
1920 (clobber (match_dup 3))
1921 (clobber (match_dup 0))
1922 (clobber (match_dup 4))])])
1924 (define_insn "mulsi3_internal"
1925 [(set (match_operand:SI 0 "register_operand" "=l")
1926 (mult:SI (match_operand:SI 1 "register_operand" "d")
1927 (match_operand:SI 2 "register_operand" "d")))
1928 (clobber (match_scratch:SI 3 "=h"))
1929 (clobber (match_scratch:SI 4 "=a"))]
1930 "!TARGET_MIPS4000 || TARGET_MIPS16"
1932 [(set_attr "type" "imul")
1933 (set_attr "mode" "SI")])
1935 (define_insn "mulsi3_r4000"
1936 [(set (match_operand:SI 0 "register_operand" "=d")
1937 (mult:SI (match_operand:SI 1 "register_operand" "d")
1938 (match_operand:SI 2 "register_operand" "d")))
1939 (clobber (match_scratch:SI 3 "=h"))
1940 (clobber (match_scratch:SI 4 "=l"))
1941 (clobber (match_scratch:SI 5 "=a"))]
1942 "TARGET_MIPS4000 && !TARGET_MIPS16"
1943 "mult\t%1,%2\;mflo\t%0"
1944 [(set_attr "type" "imul")
1945 (set_attr "mode" "SI")
1946 (set_attr "length" "8")])
1948 ;; Multiply-accumulate patterns
1950 ;; For processors that can copy the output to a general register:
1952 ;; The all-d alternative is needed because the combiner will find this
1953 ;; pattern and then register alloc/reload will move registers around to
1954 ;; make them fit, and we don't want to trigger unnecessary loads to LO.
1956 ;; The last alternative should be made slightly less desirable, but adding
1957 ;; "?" to the constraint is too strong, and causes values to be loaded into
1958 ;; LO even when that's more costly. For now, using "*d" mostly does the
1960 (define_insn "*mul_acc_si"
1961 [(set (match_operand:SI 0 "register_operand" "=l,*d,*d")
1962 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d,d")
1963 (match_operand:SI 2 "register_operand" "d,d,d"))
1964 (match_operand:SI 3 "register_operand" "0,l,*d")))
1965 (clobber (match_scratch:SI 4 "=h,h,h"))
1966 (clobber (match_scratch:SI 5 "=X,3,l"))
1967 (clobber (match_scratch:SI 6 "=a,a,a"))
1968 (clobber (match_scratch:SI 7 "=X,X,d"))]
1970 || ISA_HAS_MADD_MSUB)
1974 static const char *const madd[] = { \"madd\\t%1,%2\", \"madd\\t%0,%1,%2\" };
1975 if (which_alternative == 2)
1977 if (ISA_HAS_MADD_MSUB && which_alternative != 0)
1979 return madd[which_alternative];
1981 [(set_attr "type" "imadd,imadd,multi")
1982 (set_attr "mode" "SI")
1983 (set_attr "length" "4,4,8")])
1985 ;; Split the above insn if we failed to get LO allocated.
1987 [(set (match_operand:SI 0 "register_operand" "")
1988 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
1989 (match_operand:SI 2 "register_operand" ""))
1990 (match_operand:SI 3 "register_operand" "")))
1991 (clobber (match_scratch:SI 4 ""))
1992 (clobber (match_scratch:SI 5 ""))
1993 (clobber (match_scratch:SI 6 ""))
1994 (clobber (match_scratch:SI 7 ""))]
1995 "reload_completed && !TARGET_DEBUG_D_MODE
1996 && GP_REG_P (true_regnum (operands[0]))
1997 && GP_REG_P (true_regnum (operands[3]))"
1998 [(parallel [(set (match_dup 7)
1999 (mult:SI (match_dup 1) (match_dup 2)))
2000 (clobber (match_dup 4))
2001 (clobber (match_dup 5))
2002 (clobber (match_dup 6))])
2003 (set (match_dup 0) (plus:SI (match_dup 7) (match_dup 3)))]
2006 ;; Splitter to copy result of MADD to a general register
2008 [(set (match_operand:SI 0 "register_operand" "")
2009 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
2010 (match_operand:SI 2 "register_operand" ""))
2011 (match_operand:SI 3 "register_operand" "")))
2012 (clobber (match_scratch:SI 4 ""))
2013 (clobber (match_scratch:SI 5 ""))
2014 (clobber (match_scratch:SI 6 ""))
2015 (clobber (match_scratch:SI 7 ""))]
2016 "reload_completed && !TARGET_DEBUG_D_MODE
2017 && GP_REG_P (true_regnum (operands[0]))
2018 && true_regnum (operands[3]) == LO_REGNUM"
2019 [(parallel [(set (match_dup 3)
2020 (plus:SI (mult:SI (match_dup 1) (match_dup 2))
2022 (clobber (match_dup 4))
2023 (clobber (match_dup 5))
2024 (clobber (match_dup 6))
2025 (clobber (match_dup 7))])
2026 (set (match_dup 0) (match_dup 3))]
2029 (define_insn "*macc"
2030 [(set (match_operand:SI 0 "register_operand" "=l,d")
2031 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d")
2032 (match_operand:SI 2 "register_operand" "d,d"))
2033 (match_operand:SI 3 "register_operand" "0,l")))
2034 (clobber (match_scratch:SI 4 "=h,h"))
2035 (clobber (match_scratch:SI 5 "=X,3"))
2036 (clobber (match_scratch:SI 6 "=a,a"))]
2040 if (which_alternative == 1)
2041 return \"macc\\t%0,%1,%2\";
2042 else if (TARGET_MIPS5500)
2043 return \"madd\\t%1,%2\";
2045 return \"macc\\t%.,%1,%2\";
2047 [(set_attr "type" "imadd")
2048 (set_attr "mode" "SI")])
2050 ;; Pattern generated by define_peephole2 below
2051 (define_insn "*macc2"
2052 [(set (match_operand:SI 0 "register_operand" "=l")
2053 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d")
2054 (match_operand:SI 2 "register_operand" "d"))
2056 (set (match_operand:SI 3 "register_operand" "=d")
2057 (plus:SI (mult:SI (match_dup 1)
2060 (clobber (match_scratch:SI 4 "=h"))
2061 (clobber (match_scratch:SI 5 "=a"))]
2062 "ISA_HAS_MACC && reload_completed"
2064 [(set_attr "type" "imadd")
2065 (set_attr "mode" "SI")])
2067 ;; Convert macc $0,<r1>,<r2> & mflo <r3> into macc <r3>,<r1>,<r2>
2070 ;; Operand 1: GPR (1st multiplication operand)
2071 ;; Operand 2: GPR (2nd multiplication operand)
2074 ;; Operand 5: GPR (destination)
2077 [(set (match_operand:SI 0 "register_operand" "")
2078 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
2079 (match_operand:SI 2 "register_operand" ""))
2081 (clobber (match_operand:SI 3 "register_operand" ""))
2082 (clobber (scratch:SI))
2083 (clobber (match_operand:SI 4 "register_operand" ""))])
2084 (set (match_operand:SI 5 "register_operand" "")
2087 && true_regnum (operands[0]) == LO_REGNUM
2088 && GP_REG_P (true_regnum (operands[5]))"
2089 [(parallel [(set (match_dup 0)
2090 (plus:SI (mult:SI (match_dup 1)
2094 (plus:SI (mult:SI (match_dup 1)
2097 (clobber (match_dup 3))
2098 (clobber (match_dup 4))])]
2101 ;; When we have a three-address multiplication instruction, it should
2102 ;; be faster to do a separate multiply and add, rather than moving
2103 ;; something into LO in order to use a macc instruction.
2105 ;; This peephole needs a scratch register to cater for the case when one
2106 ;; of the multiplication operands is the same as the destination.
2108 ;; Operand 0: GPR (scratch)
2110 ;; Operand 2: GPR (addend)
2111 ;; Operand 3: GPR (destination)
2112 ;; Operand 4: GPR (1st multiplication operand)
2113 ;; Operand 5: GPR (2nd multiplication operand)
2117 [(match_scratch:SI 0 "d")
2118 (set (match_operand:SI 1 "register_operand" "")
2119 (match_operand:SI 2 "register_operand" ""))
2122 [(set (match_operand:SI 3 "register_operand" "")
2123 (plus:SI (mult:SI (match_operand:SI 4 "register_operand" "")
2124 (match_operand:SI 5 "register_operand" ""))
2126 (clobber (match_operand:SI 6 "register_operand" ""))
2127 (clobber (match_dup 1))
2128 (clobber (match_operand:SI 7 "register_operand" ""))])]
2129 "ISA_HAS_MACC && GENERATE_MULT3_SI
2130 && true_regnum (operands[1]) == LO_REGNUM
2131 && peep2_reg_dead_p (2, operands[1])
2132 && GP_REG_P (true_regnum (operands[3]))"
2133 [(parallel [(set (match_dup 0)
2134 (mult:SI (match_dup 4)
2136 (clobber (match_dup 6))
2137 (clobber (match_dup 1))
2138 (clobber (match_dup 7))])
2140 (plus:SI (match_dup 0)
2144 ;; Same as above, except LO is the initial target of the macc.
2146 ;; Operand 0: GPR (scratch)
2148 ;; Operand 2: GPR (addend)
2149 ;; Operand 3: GPR (1st multiplication operand)
2150 ;; Operand 4: GPR (2nd multiplication operand)
2153 ;; Operand 7: GPR (destination)
2155 [(match_scratch:SI 0 "d")
2156 (set (match_operand:SI 1 "register_operand" "")
2157 (match_operand:SI 2 "register_operand" ""))
2161 (plus:SI (mult:SI (match_operand:SI 3 "register_operand" "")
2162 (match_operand:SI 4 "register_operand" ""))
2164 (clobber (match_operand:SI 5 "register_operand" ""))
2165 (clobber (scratch:SI))
2166 (clobber (match_operand:SI 6 "register_operand" ""))])
2168 (set (match_operand:SI 7 "register_operand" "")
2170 "ISA_HAS_MACC && GENERATE_MULT3_SI
2171 && true_regnum (operands[1]) == LO_REGNUM
2172 && peep2_reg_dead_p (3, operands[1])
2173 && GP_REG_P (true_regnum (operands[7]))"
2174 [(parallel [(set (match_dup 0)
2175 (mult:SI (match_dup 3)
2177 (clobber (match_dup 5))
2178 (clobber (match_dup 1))
2179 (clobber (match_dup 6))])
2181 (plus:SI (match_dup 0)
2185 (define_insn "*mul_sub_si"
2186 [(set (match_operand:SI 0 "register_operand" "=l,*d,*d")
2187 (minus:SI (match_operand:SI 1 "register_operand" "0,l,*d")
2188 (mult:SI (match_operand:SI 2 "register_operand" "d,d,d")
2189 (match_operand:SI 3 "register_operand" "d,d,d"))))
2190 (clobber (match_scratch:SI 4 "=h,h,h"))
2191 (clobber (match_scratch:SI 5 "=X,1,l"))
2192 (clobber (match_scratch:SI 6 "=a,a,a"))
2193 (clobber (match_scratch:SI 7 "=X,X,d"))]
2197 if (which_alternative != 0)
2199 return \"msub\\t%2,%3\";
2201 [(set_attr "type" "imadd,multi,multi")
2202 (set_attr "mode" "SI")
2203 (set_attr "length" "4,8,8")])
2205 ;; Split the above insn if we failed to get LO allocated.
2207 [(set (match_operand:SI 0 "register_operand" "")
2208 (minus:SI (match_operand:SI 1 "register_operand" "")
2209 (mult:SI (match_operand:SI 2 "register_operand" "")
2210 (match_operand:SI 3 "register_operand" ""))))
2211 (clobber (match_scratch:SI 4 ""))
2212 (clobber (match_scratch:SI 5 ""))
2213 (clobber (match_scratch:SI 6 ""))
2214 (clobber (match_scratch:SI 7 ""))]
2215 "reload_completed && !TARGET_DEBUG_D_MODE
2216 && GP_REG_P (true_regnum (operands[0]))
2217 && GP_REG_P (true_regnum (operands[1]))"
2218 [(parallel [(set (match_dup 7)
2219 (mult:SI (match_dup 2) (match_dup 3)))
2220 (clobber (match_dup 4))
2221 (clobber (match_dup 5))
2222 (clobber (match_dup 6))])
2223 (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 7)))]
2226 ;; Splitter to copy result of MSUB to a general register
2228 [(set (match_operand:SI 0 "register_operand" "")
2229 (minus:SI (match_operand:SI 1 "register_operand" "")
2230 (mult:SI (match_operand:SI 2 "register_operand" "")
2231 (match_operand:SI 3 "register_operand" ""))))
2232 (clobber (match_scratch:SI 4 ""))
2233 (clobber (match_scratch:SI 5 ""))
2234 (clobber (match_scratch:SI 6 ""))
2235 (clobber (match_scratch:SI 7 ""))]
2236 "reload_completed && !TARGET_DEBUG_D_MODE
2237 && GP_REG_P (true_regnum (operands[0]))
2238 && true_regnum (operands[1]) == LO_REGNUM"
2239 [(parallel [(set (match_dup 1)
2240 (minus:SI (match_dup 1)
2241 (mult:SI (match_dup 2) (match_dup 3))))
2242 (clobber (match_dup 4))
2243 (clobber (match_dup 5))
2244 (clobber (match_dup 6))
2245 (clobber (match_dup 7))])
2246 (set (match_dup 0) (match_dup 1))]
2249 (define_insn "*muls"
2250 [(set (match_operand:SI 0 "register_operand" "=l,d")
2251 (neg:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d")
2252 (match_operand:SI 2 "register_operand" "d,d"))))
2253 (clobber (match_scratch:SI 3 "=h,h"))
2254 (clobber (match_scratch:SI 4 "=a,a"))
2255 (clobber (match_scratch:SI 5 "=X,l"))]
2260 [(set_attr "type" "imul")
2261 (set_attr "mode" "SI")])
2263 (define_insn "*msac"
2264 [(set (match_operand:SI 0 "register_operand" "=l,d")
2265 (minus:SI (match_operand:SI 1 "register_operand" "0,l")
2266 (mult:SI (match_operand:SI 2 "register_operand" "d,d")
2267 (match_operand:SI 3 "register_operand" "d,d"))))
2268 (clobber (match_scratch:SI 4 "=h,h"))
2269 (clobber (match_scratch:SI 5 "=X,1"))
2270 (clobber (match_scratch:SI 6 "=a,a"))]
2274 if (which_alternative == 1)
2275 return \"msac\\t%0,%2,%3\";
2276 else if (TARGET_MIPS5500)
2277 return \"msub\\t%2,%3\";
2279 return \"msac\\t$0,%2,%3\";
2281 [(set_attr "type" "imadd")
2282 (set_attr "mode" "SI")])
2284 (define_expand "muldi3"
2285 [(set (match_operand:DI 0 "register_operand" "=l")
2286 (mult:DI (match_operand:DI 1 "register_operand" "d")
2287 (match_operand:DI 2 "register_operand" "d")))
2288 (clobber (match_scratch:DI 3 "=h"))
2289 (clobber (match_scratch:DI 4 "=a"))]
2294 if (GENERATE_MULT3_DI || TARGET_MIPS4000)
2295 emit_insn (gen_muldi3_internal2 (operands[0], operands[1], operands[2]));
2297 emit_insn (gen_muldi3_internal (operands[0], operands[1], operands[2]));
2301 (define_insn "muldi3_internal"
2302 [(set (match_operand:DI 0 "register_operand" "=l")
2303 (mult:DI (match_operand:DI 1 "register_operand" "d")
2304 (match_operand:DI 2 "register_operand" "d")))
2305 (clobber (match_scratch:DI 3 "=h"))
2306 (clobber (match_scratch:DI 4 "=a"))]
2307 "TARGET_64BIT && !TARGET_MIPS4000"
2309 [(set_attr "type" "imul")
2310 (set_attr "mode" "DI")])
2312 (define_insn "muldi3_internal2"
2313 [(set (match_operand:DI 0 "register_operand" "=d")
2314 (mult:DI (match_operand:DI 1 "register_operand" "d")
2315 (match_operand:DI 2 "register_operand" "d")))
2316 (clobber (match_scratch:DI 3 "=h"))
2317 (clobber (match_scratch:DI 4 "=l"))
2318 (clobber (match_scratch:DI 5 "=a"))]
2319 "TARGET_64BIT && (GENERATE_MULT3_DI || TARGET_MIPS4000)"
2321 if (GENERATE_MULT3_DI)
2322 return "dmult\t%0,%1,%2";
2324 return "dmult\t%1,%2\n\tmflo\t%0";
2326 [(set_attr "type" "imul")
2327 (set_attr "mode" "DI")
2328 (set (attr "length")
2329 (if_then_else (ne (symbol_ref "GENERATE_MULT3_DI") (const_int 0))
2333 ;; ??? We could define a mulditi3 pattern when TARGET_64BIT.
2335 (define_expand "mulsidi3"
2336 [(set (match_operand:DI 0 "register_operand" "=x")
2337 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
2338 (sign_extend:DI (match_operand:SI 2 "register_operand" "d"))))]
2343 emit_insn (gen_mulsidi3_64bit (operands[0], operands[1], operands[2]));
2345 emit_insn (gen_mulsidi3_internal (operands[0], operands[1], operands[2]));
2349 (define_insn "mulsidi3_internal"
2350 [(set (match_operand:DI 0 "register_operand" "=x")
2351 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
2352 (sign_extend:DI (match_operand:SI 2 "register_operand" "d"))))
2353 (clobber (match_scratch:SI 3 "=a"))]
2356 [(set_attr "type" "imul")
2357 (set_attr "mode" "SI")])
2359 (define_insn "mulsidi3_64bit"
2360 [(set (match_operand:DI 0 "register_operand" "=a")
2361 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
2362 (sign_extend:DI (match_operand:SI 2 "register_operand" "d"))))
2363 (clobber (match_scratch:DI 3 "=l"))
2364 (clobber (match_scratch:DI 4 "=h"))]
2367 [(set_attr "type" "imul")
2368 (set_attr "mode" "SI")])
2370 (define_expand "umulsidi3"
2371 [(set (match_operand:DI 0 "register_operand" "=x")
2372 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
2373 (zero_extend:DI (match_operand:SI 2 "register_operand" "d"))))]
2378 emit_insn (gen_umulsidi3_64bit (operands[0], operands[1], operands[2]));
2380 emit_insn (gen_umulsidi3_internal (operands[0], operands[1], operands[2]));
2386 (define_insn "umulsidi3_internal"
2387 [(set (match_operand:DI 0 "register_operand" "=x")
2388 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
2389 (zero_extend:DI (match_operand:SI 2 "register_operand" "d"))))
2390 (clobber (match_scratch:SI 3 "=a"))]
2393 [(set_attr "type" "imul")
2394 (set_attr "mode" "SI")])
2396 (define_insn "umulsidi3_64bit"
2397 [(set (match_operand:DI 0 "register_operand" "=a")
2398 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
2399 (zero_extend:DI (match_operand:SI 2 "register_operand" "d"))))
2400 (clobber (match_scratch:DI 3 "=l"))
2401 (clobber (match_scratch:DI 4 "=h"))]
2404 [(set_attr "type" "imul")
2405 (set_attr "mode" "SI")])
2407 ;; Widening multiply with negation. It isn't worth using this pattern
2408 ;; for 64-bit code since the reload sequence for HILO_REGNUM is so long.
2409 (define_insn "*muls_di"
2410 [(set (match_operand:DI 0 "register_operand" "=x")
2413 (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
2414 (sign_extend:DI (match_operand:SI 2 "register_operand" "d")))))
2415 (clobber (match_scratch:SI 3 "=a"))]
2416 "!TARGET_64BIT && ISA_HAS_MULS"
2418 [(set_attr "type" "imul")
2419 (set_attr "length" "4")
2420 (set_attr "mode" "SI")])
2422 (define_insn "*umuls_di"
2423 [(set (match_operand:DI 0 "register_operand" "=x")
2426 (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
2427 (zero_extend:DI (match_operand:SI 2 "register_operand" "d")))))
2428 (clobber (match_scratch:SI 3 "=a"))]
2429 "!TARGET_64BIT && ISA_HAS_MULS"
2431 [(set_attr "type" "imul")
2432 (set_attr "length" "4")
2433 (set_attr "mode" "SI")])
2435 ;; Not used for 64-bit code: see comment for *muls_di.
2436 (define_insn "*smsac_di"
2437 [(set (match_operand:DI 0 "register_operand" "=x")
2438 (minus:DI (match_operand:DI 3 "register_operand" "0")
2440 (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
2441 (sign_extend:DI (match_operand:SI 2 "register_operand" "d")))))
2442 (clobber (match_scratch:SI 4 "=a"))]
2443 "!TARGET_64BIT && ISA_HAS_MSAC"
2446 if (TARGET_MIPS5500)
2447 return \"msub\\t%1,%2\";
2449 return \"msac\\t$0,%1,%2\";
2451 [(set_attr "type" "imadd")
2452 (set_attr "length" "4")
2453 (set_attr "mode" "SI")])
2455 (define_insn "*umsac_di"
2456 [(set (match_operand:DI 0 "register_operand" "=x")
2457 (minus:DI (match_operand:DI 3 "register_operand" "0")
2459 (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
2460 (zero_extend:DI (match_operand:SI 2 "register_operand" "d")))))
2461 (clobber (match_scratch:SI 4 "=a"))]
2462 "!TARGET_64BIT && ISA_HAS_MSAC"
2465 if (TARGET_MIPS5500)
2466 return \"msubu\\t%1,%2\";
2468 return \"msacu\\t$0,%1,%2\";
2470 [(set_attr "type" "imadd")
2471 (set_attr "length" "4")
2472 (set_attr "mode" "SI")])
2474 ;; _highpart patterns
2475 (define_expand "umulsi3_highpart"
2476 [(set (match_operand:SI 0 "register_operand" "=h")
2479 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
2480 (zero_extend:DI (match_operand:SI 2 "register_operand" "d")))
2486 emit_insn (gen_umulsi3_highpart_mulhi_internal (operands[0], operands[1],
2489 emit_insn (gen_umulsi3_highpart_internal (operands[0], operands[1],
2494 (define_insn "umulsi3_highpart_internal"
2495 [(set (match_operand:SI 0 "register_operand" "=h")
2498 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
2499 (zero_extend:DI (match_operand:SI 2 "register_operand" "d")))
2501 (clobber (match_scratch:SI 3 "=l"))
2502 (clobber (match_scratch:SI 4 "=a"))]
2505 [(set_attr "type" "imul")
2506 (set_attr "mode" "SI")
2507 (set_attr "length" "4")])
2509 (define_insn "umulsi3_highpart_mulhi_internal"
2510 [(set (match_operand:SI 0 "register_operand" "=h,d")
2513 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "d,d"))
2514 (zero_extend:DI (match_operand:SI 2 "register_operand" "d,d")))
2516 (clobber (match_scratch:SI 3 "=l,l"))
2517 (clobber (match_scratch:SI 4 "=a,a"))
2518 (clobber (match_scratch:SI 5 "=X,h"))]
2523 [(set_attr "type" "imul")
2524 (set_attr "mode" "SI")
2525 (set_attr "length" "4")])
2527 (define_insn "umulsi3_highpart_neg_mulhi_internal"
2528 [(set (match_operand:SI 0 "register_operand" "=h,d")
2532 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "d,d"))
2533 (zero_extend:DI (match_operand:SI 2 "register_operand" "d,d"))))
2535 (clobber (match_scratch:SI 3 "=l,l"))
2536 (clobber (match_scratch:SI 4 "=a,a"))
2537 (clobber (match_scratch:SI 5 "=X,h"))]
2542 [(set_attr "type" "imul")
2543 (set_attr "mode" "SI")
2544 (set_attr "length" "4")])
2546 (define_expand "smulsi3_highpart"
2547 [(set (match_operand:SI 0 "register_operand" "=h")
2550 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
2551 (sign_extend:DI (match_operand:SI 2 "register_operand" "d")))
2557 emit_insn (gen_smulsi3_highpart_mulhi_internal (operands[0], operands[1],
2560 emit_insn (gen_smulsi3_highpart_internal (operands[0], operands[1],
2565 (define_insn "smulsi3_highpart_internal"
2566 [(set (match_operand:SI 0 "register_operand" "=h")
2569 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
2570 (sign_extend:DI (match_operand:SI 2 "register_operand" "d")))
2572 (clobber (match_scratch:SI 3 "=l"))
2573 (clobber (match_scratch:SI 4 "=a"))]
2576 [(set_attr "type" "imul")
2577 (set_attr "mode" "SI")
2578 (set_attr "length" "4")])
2580 (define_insn "smulsi3_highpart_mulhi_internal"
2581 [(set (match_operand:SI 0 "register_operand" "=h,d")
2584 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d,d"))
2585 (sign_extend:DI (match_operand:SI 2 "register_operand" "d,d")))
2587 (clobber (match_scratch:SI 3 "=l,l"))
2588 (clobber (match_scratch:SI 4 "=a,a"))
2589 (clobber (match_scratch:SI 5 "=X,h"))]
2594 [(set_attr "type" "imul")
2595 (set_attr "mode" "SI")
2596 (set_attr "length" "4")])
2598 (define_insn "smulsi3_highpart_neg_mulhi_internal"
2599 [(set (match_operand:SI 0 "register_operand" "=h,d")
2603 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d,d"))
2604 (sign_extend:DI (match_operand:SI 2 "register_operand" "d,d"))))
2606 (clobber (match_scratch:SI 3 "=l,l"))
2607 (clobber (match_scratch:SI 4 "=a,a"))
2608 (clobber (match_scratch:SI 5 "=X,h"))]
2613 [(set_attr "type" "imul")
2614 (set_attr "mode" "SI")])
2616 (define_insn "smuldi3_highpart"
2617 [(set (match_operand:DI 0 "register_operand" "=h")
2621 (sign_extend:TI (match_operand:DI 1 "register_operand" "d"))
2622 (sign_extend:TI (match_operand:DI 2 "register_operand" "d")))
2624 (clobber (match_scratch:DI 3 "=l"))
2625 (clobber (match_scratch:DI 4 "=a"))]
2628 [(set_attr "type" "imul")
2629 (set_attr "mode" "DI")])
2631 (define_insn "umuldi3_highpart"
2632 [(set (match_operand:DI 0 "register_operand" "=h")
2636 (zero_extend:TI (match_operand:DI 1 "register_operand" "d"))
2637 (zero_extend:TI (match_operand:DI 2 "register_operand" "d")))
2639 (clobber (match_scratch:DI 3 "=l"))
2640 (clobber (match_scratch:DI 4 "=a"))]
2643 [(set_attr "type" "imul")
2644 (set_attr "mode" "DI")])
2647 ;; The R4650 supports a 32 bit multiply/ 64 bit accumulate
2648 ;; instruction. The HI/LO registers are used as a 64 bit accumulator.
2650 (define_insn "madsi"
2651 [(set (match_operand:SI 0 "register_operand" "+l")
2652 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d")
2653 (match_operand:SI 2 "register_operand" "d"))
2655 (clobber (match_scratch:SI 3 "=h"))
2656 (clobber (match_scratch:SI 4 "=a"))]
2659 [(set_attr "type" "imadd")
2660 (set_attr "mode" "SI")])
2662 ;; Only use this pattern in 32-bit code: see *muls_di.
2663 (define_insn "*umul_acc_di"
2664 [(set (match_operand:DI 0 "register_operand" "=x")
2666 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
2667 (zero_extend:DI (match_operand:SI 2 "register_operand" "d")))
2668 (match_operand:DI 3 "register_operand" "0")))
2669 (clobber (match_scratch:SI 4 "=a"))]
2670 "(TARGET_MAD || ISA_HAS_MACC)
2675 return \"madu\\t%1,%2\";
2676 else if (TARGET_MIPS5500)
2677 return \"maddu\\t%1,%2\";
2679 return \"maccu\\t%.,%1,%2\";
2681 [(set_attr "type" "imadd")
2682 (set_attr "mode" "SI")])
2685 (define_insn "*smul_acc_di"
2686 [(set (match_operand:DI 0 "register_operand" "=x")
2688 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
2689 (sign_extend:DI (match_operand:SI 2 "register_operand" "d")))
2690 (match_operand:DI 3 "register_operand" "0")))
2691 (clobber (match_scratch:SI 4 "=a"))]
2692 "(TARGET_MAD || ISA_HAS_MACC)
2697 return \"mad\\t%1,%2\";
2698 else if (TARGET_MIPS5500)
2699 return \"madd\\t%1,%2\";
2701 return \"macc\\t%.,%1,%2\";
2703 [(set_attr "type" "imadd")
2704 (set_attr "mode" "SI")])
2706 ;; Floating point multiply accumulate instructions.
2709 [(set (match_operand:DF 0 "register_operand" "=f")
2710 (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
2711 (match_operand:DF 2 "register_operand" "f"))
2712 (match_operand:DF 3 "register_operand" "f")))]
2713 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FUSED_MADD"
2714 "madd.d\\t%0,%3,%1,%2"
2715 [(set_attr "type" "fmadd")
2716 (set_attr "mode" "DF")])
2719 [(set (match_operand:SF 0 "register_operand" "=f")
2720 (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
2721 (match_operand:SF 2 "register_operand" "f"))
2722 (match_operand:SF 3 "register_operand" "f")))]
2723 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
2724 "madd.s\\t%0,%3,%1,%2"
2725 [(set_attr "type" "fmadd")
2726 (set_attr "mode" "SF")])
2729 [(set (match_operand:DF 0 "register_operand" "=f")
2730 (minus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
2731 (match_operand:DF 2 "register_operand" "f"))
2732 (match_operand:DF 3 "register_operand" "f")))]
2733 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FUSED_MADD"
2734 "msub.d\\t%0,%3,%1,%2"
2735 [(set_attr "type" "fmadd")
2736 (set_attr "mode" "DF")])
2739 [(set (match_operand:SF 0 "register_operand" "=f")
2740 (minus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
2741 (match_operand:SF 2 "register_operand" "f"))
2742 (match_operand:SF 3 "register_operand" "f")))]
2744 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
2745 "msub.s\\t%0,%3,%1,%2"
2746 [(set_attr "type" "fmadd")
2747 (set_attr "mode" "SF")])
2750 [(set (match_operand:DF 0 "register_operand" "=f")
2751 (neg:DF (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
2752 (match_operand:DF 2 "register_operand" "f"))
2753 (match_operand:DF 3 "register_operand" "f"))))]
2754 "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FUSED_MADD"
2755 "nmadd.d\\t%0,%3,%1,%2"
2756 [(set_attr "type" "fmadd")
2757 (set_attr "mode" "DF")])
2760 [(set (match_operand:SF 0 "register_operand" "=f")
2761 (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
2762 (match_operand:SF 2 "register_operand" "f"))
2763 (match_operand:SF 3 "register_operand" "f"))))]
2764 "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
2765 "nmadd.s\\t%0,%3,%1,%2"
2766 [(set_attr "type" "fmadd")
2767 (set_attr "mode" "SF")])
2770 [(set (match_operand:DF 0 "register_operand" "=f")
2771 (minus:DF (match_operand:DF 1 "register_operand" "f")
2772 (mult:DF (match_operand:DF 2 "register_operand" "f")
2773 (match_operand:DF 3 "register_operand" "f"))))]
2774 "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FUSED_MADD"
2775 "nmsub.d\\t%0,%1,%2,%3"
2776 [(set_attr "type" "fmadd")
2777 (set_attr "mode" "DF")])
2780 [(set (match_operand:SF 0 "register_operand" "=f")
2781 (minus:SF (match_operand:SF 1 "register_operand" "f")
2782 (mult:SF (match_operand:SF 2 "register_operand" "f")
2783 (match_operand:SF 3 "register_operand" "f"))))]
2784 "ISA_HAS_NMADD_NMSUB && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
2785 "nmsub.s\\t%0,%1,%2,%3"
2786 [(set_attr "type" "fmadd")
2787 (set_attr "mode" "SF")])
2790 ;; ....................
2792 ;; DIVISION and REMAINDER
2794 ;; ....................
2797 (define_insn "divdf3"
2798 [(set (match_operand:DF 0 "register_operand" "=f")
2799 (div:DF (match_operand:DF 1 "register_operand" "f")
2800 (match_operand:DF 2 "register_operand" "f")))]
2801 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2803 [(set_attr "type" "fdiv")
2804 (set_attr "mode" "DF")])
2806 (define_insn "divsf3"
2807 [(set (match_operand:SF 0 "register_operand" "=f")
2808 (div:SF (match_operand:SF 1 "register_operand" "f")
2809 (match_operand:SF 2 "register_operand" "f")))]
2812 [(set_attr "type" "fdiv")
2813 (set_attr "mode" "SF")])
2816 [(set (match_operand:DF 0 "register_operand" "=f")
2817 (div:DF (match_operand:DF 1 "const_float_1_operand" "")
2818 (match_operand:DF 2 "register_operand" "f")))]
2819 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && flag_unsafe_math_optimizations"
2821 [(set_attr "type" "fdiv")
2822 (set_attr "mode" "DF")])
2825 [(set (match_operand:SF 0 "register_operand" "=f")
2826 (div:SF (match_operand:SF 1 "const_float_1_operand" "")
2827 (match_operand:SF 2 "register_operand" "f")))]
2828 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && flag_unsafe_math_optimizations"
2830 [(set_attr "type" "fdiv")
2831 (set_attr "mode" "SF")])
2833 ;; If optimizing, prefer the divmod functions over separate div and
2834 ;; mod functions, since this will allow using one instruction for both
2835 ;; the quotient and remainder. At present, the divmod is not moved out
2836 ;; of loops if it is constant within the loop, so allow -mdebugc to
2837 ;; use the old method of doing things.
2839 ;; 64 is the multiply/divide hi register
2840 ;; 65 is the multiply/divide lo register
2842 ;; ??? We can't accept constants here, because the MIPS assembler will replace
2843 ;; a divide by power of 2 with a shift, and then the remainder is no longer
2846 (define_expand "divmodsi4"
2847 [(set (match_operand:SI 0 "register_operand" "=d")
2848 (div:SI (match_operand:SI 1 "register_operand" "d")
2849 (match_operand:SI 2 "register_operand" "d")))
2850 (set (match_operand:SI 3 "register_operand" "=d")
2851 (mod:SI (match_dup 1)
2853 (clobber (match_scratch:SI 4 "=l"))
2854 (clobber (match_scratch:SI 5 "=h"))
2855 (clobber (match_scratch:SI 6 "=a"))]
2859 emit_insn (gen_divmodsi4_internal (operands[0], operands[1], operands[2],
2861 if (!TARGET_NO_CHECK_ZERO_DIV)
2863 emit_insn (gen_div_trap (operands[2],
2867 if (TARGET_CHECK_RANGE_DIV)
2869 emit_insn (gen_div_trap (operands[2],
2870 copy_to_mode_reg (SImode, GEN_INT (-1)),
2872 emit_insn (gen_div_trap (operands[2],
2873 copy_to_mode_reg (SImode,
2876 (BITMASK_HIGH, SImode))),
2883 (define_insn "divmodsi4_internal"
2884 [(set (match_operand:SI 0 "register_operand" "=l")
2885 (div:SI (match_operand:SI 1 "register_operand" "d")
2886 (match_operand:SI 2 "register_operand" "d")))
2887 (set (match_operand:SI 3 "register_operand" "=h")
2888 (mod:SI (match_dup 1)
2890 (clobber (match_scratch:SI 4 "=a"))]
2893 [(set_attr "type" "idiv")
2894 (set_attr "mode" "SI")])
2896 (define_expand "divmoddi4"
2897 [(set (match_operand:DI 0 "register_operand" "=d")
2898 (div:DI (match_operand:DI 1 "register_operand" "d")
2899 (match_operand:DI 2 "register_operand" "d")))
2900 (set (match_operand:DI 3 "register_operand" "=d")
2901 (mod:DI (match_dup 1)
2903 (clobber (match_scratch:DI 4 "=l"))
2904 (clobber (match_scratch:DI 5 "=h"))
2905 (clobber (match_scratch:DI 6 "=a"))]
2906 "TARGET_64BIT && optimize"
2909 emit_insn (gen_divmoddi4_internal (operands[0], operands[1], operands[2],
2911 if (!TARGET_NO_CHECK_ZERO_DIV)
2913 emit_insn (gen_div_trap (operands[2],
2917 if (TARGET_CHECK_RANGE_DIV)
2919 emit_insn (gen_div_trap (operands[2],
2920 copy_to_mode_reg (DImode, GEN_INT (-1)),
2922 emit_insn (gen_div_trap (operands[2],
2923 copy_to_mode_reg (DImode,
2924 GEN_INT (BITMASK_HIGH)),
2931 (define_insn "divmoddi4_internal"
2932 [(set (match_operand:DI 0 "register_operand" "=l")
2933 (div:DI (match_operand:DI 1 "register_operand" "d")
2934 (match_operand:DI 2 "register_operand" "d")))
2935 (set (match_operand:DI 3 "register_operand" "=h")
2936 (mod:DI (match_dup 1)
2938 (clobber (match_scratch:DI 4 "=a"))]
2939 "TARGET_64BIT && optimize"
2941 [(set_attr "type" "idiv")
2942 (set_attr "mode" "SI")])
2944 (define_expand "udivmodsi4"
2945 [(set (match_operand:SI 0 "register_operand" "=d")
2946 (udiv:SI (match_operand:SI 1 "register_operand" "d")
2947 (match_operand:SI 2 "register_operand" "d")))
2948 (set (match_operand:SI 3 "register_operand" "=d")
2949 (umod:SI (match_dup 1)
2951 (clobber (match_scratch:SI 4 "=l"))
2952 (clobber (match_scratch:SI 5 "=h"))
2953 (clobber (match_scratch:SI 6 "=a"))]
2957 emit_insn (gen_udivmodsi4_internal (operands[0], operands[1], operands[2],
2959 if (!TARGET_NO_CHECK_ZERO_DIV)
2961 emit_insn (gen_div_trap (operands[2],
2969 (define_insn "udivmodsi4_internal"
2970 [(set (match_operand:SI 0 "register_operand" "=l")
2971 (udiv:SI (match_operand:SI 1 "register_operand" "d")
2972 (match_operand:SI 2 "register_operand" "d")))
2973 (set (match_operand:SI 3 "register_operand" "=h")
2974 (umod:SI (match_dup 1)
2976 (clobber (match_scratch:SI 4 "=a"))]
2979 [(set_attr "type" "idiv")
2980 (set_attr "mode" "SI")])
2982 (define_expand "udivmoddi4"
2983 [(set (match_operand:DI 0 "register_operand" "=d")
2984 (udiv:DI (match_operand:DI 1 "register_operand" "d")
2985 (match_operand:DI 2 "register_operand" "d")))
2986 (set (match_operand:DI 3 "register_operand" "=d")
2987 (umod:DI (match_dup 1)
2989 (clobber (match_scratch:DI 4 "=l"))
2990 (clobber (match_scratch:DI 5 "=h"))
2991 (clobber (match_scratch:DI 6 "=a"))]
2992 "TARGET_64BIT && optimize"
2995 emit_insn (gen_udivmoddi4_internal (operands[0], operands[1], operands[2],
2997 if (!TARGET_NO_CHECK_ZERO_DIV)
2999 emit_insn (gen_div_trap (operands[2],
3007 (define_insn "udivmoddi4_internal"
3008 [(set (match_operand:DI 0 "register_operand" "=l")
3009 (udiv:DI (match_operand:DI 1 "register_operand" "d")
3010 (match_operand:DI 2 "register_operand" "d")))
3011 (set (match_operand:DI 3 "register_operand" "=h")
3012 (umod:DI (match_dup 1)
3014 (clobber (match_scratch:DI 4 "=a"))]
3015 "TARGET_64BIT && optimize"
3017 [(set_attr "type" "idiv")
3018 (set_attr "mode" "SI")])
3022 (define_expand "div_trap"
3023 [(trap_if (eq (match_operand 0 "register_operand" "d")
3024 (match_operand 1 "true_reg_or_0_operand" "dJ"))
3025 (match_operand 2 "immediate_operand" ""))]
3030 emit_insn (gen_div_trap_mips16 (operands[0],operands[1],operands[2]));
3032 emit_insn (gen_div_trap_normal (operands[0],operands[1],operands[2]));
3036 (define_insn "div_trap_normal"
3037 [(trap_if (eq (match_operand 0 "register_operand" "d,d")
3038 (match_operand 1 "true_reg_or_0_operand" "d,J"))
3039 (match_operand 2 "immediate_operand" ""))]
3044 int have_dep_anti = 0;
3046 /* For divmod if one division is not needed then we don't need an extra
3047 divide by zero trap, which is anti dependent on previous trap */
3048 for (link = LOG_LINKS (insn); link; link = XEXP (link, 1))
3050 if ((int) REG_DEP_ANTI == (int) REG_NOTE_KIND (link)
3051 && GET_CODE (XEXP (link, 0)) == INSN
3052 && GET_CODE (PATTERN (XEXP (link, 0))) == TRAP_IF
3053 && which_alternative == 1)
3055 if (! have_dep_anti)
3057 if (GENERATE_BRANCHLIKELY)
3059 if (which_alternative == 1)
3060 return \"%(beql\\t%0,$0,1f\\n\\tbreak\\t%2\\n%~1:%)\";
3062 return \"%(beql\\t%0,%1,1f\\n\\tbreak\\t%2\\n%~1:%)\";
3066 if (which_alternative == 1)
3067 return \"%(bne\\t%0,$0,1f\\n\\tnop\\n\\tbreak\\t%2\\n%~1:%)\";
3069 return \"%(bne\\t%0,%1,1f\\n\\tnop\\n\\tbreak\\t%2\\n%~1:%)\";
3074 [(set_attr "type" "unknown")
3075 (set_attr "length" "12")])
3078 ;; The mips16 bne insns is a macro which uses reg 24 as an intermediate.
3080 (define_insn "div_trap_mips16"
3081 [(trap_if (eq (match_operand 0 "register_operand" "d,d")
3082 (match_operand 1 "true_reg_or_0_operand" "d,J"))
3083 (match_operand 2 "immediate_operand" ""))
3084 (clobber (reg:SI 24))]
3089 int have_dep_anti = 0;
3091 /* For divmod if one division is not needed then we don't need an extra
3092 divide by zero trap, which is anti dependent on previous trap */
3093 for (link = LOG_LINKS (insn); link; link = XEXP (link, 1))
3095 if ((int) REG_DEP_ANTI == (int) REG_NOTE_KIND (link)
3096 && GET_CODE (XEXP (link, 0)) == INSN
3097 && GET_CODE (PATTERN (XEXP (link, 0))) == TRAP_IF
3098 && which_alternative == 1)
3100 if (! have_dep_anti)
3102 /* No branch delay slots on mips16. */
3103 if (which_alternative == 1)
3104 return \"%(bnez\\t%0,1f\\n\\tbreak\\t%2\\n%~1:%)\";
3106 return \"%(bne\\t%0,%1,1f\\n\\tbreak\\t%2\\n%~1:%)\";
3110 [(set_attr "type" "unknown")
3111 (set_attr "length" "12")])
3113 (define_expand "divsi3"
3114 [(set (match_operand:SI 0 "register_operand" "=l")
3115 (div:SI (match_operand:SI 1 "register_operand" "d")
3116 (match_operand:SI 2 "register_operand" "d")))
3117 (clobber (match_scratch:SI 3 "=h"))
3118 (clobber (match_scratch:SI 4 "=a"))]
3122 emit_insn (gen_divsi3_internal (operands[0], operands[1], operands[2]));
3124 if (!TARGET_NO_CHECK_ZERO_DIV)
3126 emit_insn (gen_div_trap (operands[2],
3130 if (TARGET_CHECK_RANGE_DIV)
3132 emit_insn (gen_div_trap (operands[2],
3133 copy_to_mode_reg (SImode, GEN_INT (-1)),
3135 emit_insn (gen_div_trap (operands[2],
3136 copy_to_mode_reg (SImode,
3139 (BITMASK_HIGH, SImode))),
3146 (define_insn "divsi3_internal"
3147 [(set (match_operand:SI 0 "register_operand" "=l")
3148 (div:SI (match_operand:SI 1 "register_operand" "d")
3149 (match_operand:SI 2 "nonmemory_operand" "di")))
3150 (clobber (match_scratch:SI 3 "=h"))
3151 (clobber (match_scratch:SI 4 "=a"))]
3154 [(set_attr "type" "idiv")
3155 (set_attr "mode" "SI")])
3157 (define_expand "divdi3"
3158 [(set (match_operand:DI 0 "register_operand" "=l")
3159 (div:DI (match_operand:DI 1 "register_operand" "d")
3160 (match_operand:DI 2 "register_operand" "d")))
3161 (clobber (match_scratch:DI 3 "=h"))
3162 (clobber (match_scratch:DI 4 "=a"))]
3163 "TARGET_64BIT && !optimize"
3166 emit_insn (gen_divdi3_internal (operands[0], operands[1], operands[2]));
3167 if (!TARGET_NO_CHECK_ZERO_DIV)
3169 emit_insn (gen_div_trap (operands[2],
3173 if (TARGET_CHECK_RANGE_DIV)
3175 emit_insn (gen_div_trap (operands[2],
3176 copy_to_mode_reg (DImode, GEN_INT (-1)),
3178 emit_insn (gen_div_trap (operands[2],
3179 copy_to_mode_reg (DImode,
3180 GEN_INT (BITMASK_HIGH)),
3187 (define_insn "divdi3_internal"
3188 [(set (match_operand:DI 0 "register_operand" "=l")
3189 (div:DI (match_operand:DI 1 "register_operand" "d")
3190 (match_operand:DI 2 "nonmemory_operand" "di")))
3191 (clobber (match_scratch:SI 3 "=h"))
3192 (clobber (match_scratch:SI 4 "=a"))]
3193 "TARGET_64BIT && !optimize"
3195 [(set_attr "type" "idiv")
3196 (set_attr "mode" "DI")])
3198 (define_expand "modsi3"
3199 [(set (match_operand:SI 0 "register_operand" "=h")
3200 (mod:SI (match_operand:SI 1 "register_operand" "d")
3201 (match_operand:SI 2 "register_operand" "d")))
3202 (clobber (match_scratch:SI 3 "=l"))
3203 (clobber (match_scratch:SI 4 "=a"))]
3207 emit_insn (gen_modsi3_internal (operands[0], operands[1], operands[2]));
3208 if (!TARGET_NO_CHECK_ZERO_DIV)
3210 emit_insn (gen_div_trap (operands[2],
3214 if (TARGET_CHECK_RANGE_DIV)
3216 emit_insn (gen_div_trap (operands[2],
3217 copy_to_mode_reg (SImode, GEN_INT (-1)),
3219 emit_insn (gen_div_trap (operands[2],
3220 copy_to_mode_reg (SImode,
3223 (BITMASK_HIGH, SImode))),
3230 (define_insn "modsi3_internal"
3231 [(set (match_operand:SI 0 "register_operand" "=h")
3232 (mod:SI (match_operand:SI 1 "register_operand" "d")
3233 (match_operand:SI 2 "nonmemory_operand" "di")))
3234 (clobber (match_scratch:SI 3 "=l"))
3235 (clobber (match_scratch:SI 4 "=a"))]
3238 [(set_attr "type" "idiv")
3239 (set_attr "mode" "SI")])
3241 (define_expand "moddi3"
3242 [(set (match_operand:DI 0 "register_operand" "=h")
3243 (mod:DI (match_operand:DI 1 "register_operand" "d")
3244 (match_operand:DI 2 "register_operand" "d")))
3245 (clobber (match_scratch:DI 3 "=l"))
3246 (clobber (match_scratch:DI 4 "=a"))]
3247 "TARGET_64BIT && !optimize"
3250 emit_insn (gen_moddi3_internal (operands[0], operands[1], operands[2]));
3251 if (!TARGET_NO_CHECK_ZERO_DIV)
3253 emit_insn (gen_div_trap (operands[2],
3257 if (TARGET_CHECK_RANGE_DIV)
3259 emit_insn (gen_div_trap (operands[2],
3260 copy_to_mode_reg (DImode, GEN_INT (-1)),
3262 emit_insn (gen_div_trap (operands[2],
3263 copy_to_mode_reg (DImode,
3264 GEN_INT (BITMASK_HIGH)),
3271 (define_insn "moddi3_internal"
3272 [(set (match_operand:DI 0 "register_operand" "=h")
3273 (mod:DI (match_operand:DI 1 "register_operand" "d")
3274 (match_operand:DI 2 "nonmemory_operand" "di")))
3275 (clobber (match_scratch:SI 3 "=l"))
3276 (clobber (match_scratch:SI 4 "=a"))]
3277 "TARGET_64BIT && !optimize"
3279 [(set_attr "type" "idiv")
3280 (set_attr "mode" "DI")])
3282 (define_expand "udivsi3"
3283 [(set (match_operand:SI 0 "register_operand" "=l")
3284 (udiv:SI (match_operand:SI 1 "register_operand" "d")
3285 (match_operand:SI 2 "register_operand" "d")))
3286 (clobber (match_scratch:SI 3 "=h"))
3287 (clobber (match_scratch:SI 4 "=a"))]
3291 emit_insn (gen_udivsi3_internal (operands[0], operands[1], operands[2]));
3292 if (!TARGET_NO_CHECK_ZERO_DIV)
3294 emit_insn (gen_div_trap (operands[2],
3302 (define_insn "udivsi3_internal"
3303 [(set (match_operand:SI 0 "register_operand" "=l")
3304 (udiv:SI (match_operand:SI 1 "register_operand" "d")
3305 (match_operand:SI 2 "nonmemory_operand" "di")))
3306 (clobber (match_scratch:SI 3 "=h"))
3307 (clobber (match_scratch:SI 4 "=a"))]
3310 [(set_attr "type" "idiv")
3311 (set_attr "mode" "SI")])
3313 (define_expand "udivdi3"
3314 [(set (match_operand:DI 0 "register_operand" "=l")
3315 (udiv:DI (match_operand:DI 1 "register_operand" "d")
3316 (match_operand:DI 2 "register_operand" "di")))
3317 (clobber (match_scratch:DI 3 "=h"))
3318 (clobber (match_scratch:DI 4 "=a"))]
3319 "TARGET_64BIT && !optimize"
3322 emit_insn (gen_udivdi3_internal (operands[0], operands[1], operands[2]));
3323 if (!TARGET_NO_CHECK_ZERO_DIV)
3325 emit_insn (gen_div_trap (operands[2],
3333 (define_insn "udivdi3_internal"
3334 [(set (match_operand:DI 0 "register_operand" "=l")
3335 (udiv:DI (match_operand:DI 1 "register_operand" "d")
3336 (match_operand:DI 2 "nonmemory_operand" "di")))
3337 (clobber (match_scratch:SI 3 "=h"))
3338 (clobber (match_scratch:SI 4 "=a"))]
3339 "TARGET_64BIT && !optimize"
3341 [(set_attr "type" "idiv")
3342 (set_attr "mode" "DI")])
3344 (define_expand "umodsi3"
3345 [(set (match_operand:SI 0 "register_operand" "=h")
3346 (umod:SI (match_operand:SI 1 "register_operand" "d")
3347 (match_operand:SI 2 "register_operand" "d")))
3348 (clobber (match_scratch:SI 3 "=l"))
3349 (clobber (match_scratch:SI 4 "=a"))]
3353 emit_insn (gen_umodsi3_internal (operands[0], operands[1], operands[2]));
3354 if (!TARGET_NO_CHECK_ZERO_DIV)
3356 emit_insn (gen_div_trap (operands[2],
3364 (define_insn "umodsi3_internal"
3365 [(set (match_operand:SI 0 "register_operand" "=h")
3366 (umod:SI (match_operand:SI 1 "register_operand" "d")
3367 (match_operand:SI 2 "nonmemory_operand" "di")))
3368 (clobber (match_scratch:SI 3 "=l"))
3369 (clobber (match_scratch:SI 4 "=a"))]
3372 [(set_attr "type" "idiv")
3373 (set_attr "mode" "SI")])
3375 (define_expand "umoddi3"
3376 [(set (match_operand:DI 0 "register_operand" "=h")
3377 (umod:DI (match_operand:DI 1 "register_operand" "d")
3378 (match_operand:DI 2 "register_operand" "di")))
3379 (clobber (match_scratch:DI 3 "=l"))
3380 (clobber (match_scratch:DI 4 "=a"))]
3381 "TARGET_64BIT && !optimize"
3384 emit_insn (gen_umoddi3_internal (operands[0], operands[1], operands[2]));
3385 if (!TARGET_NO_CHECK_ZERO_DIV)
3387 emit_insn (gen_div_trap (operands[2],
3395 (define_insn "umoddi3_internal"
3396 [(set (match_operand:DI 0 "register_operand" "=h")
3397 (umod:DI (match_operand:DI 1 "register_operand" "d")
3398 (match_operand:DI 2 "nonmemory_operand" "di")))
3399 (clobber (match_scratch:SI 3 "=l"))
3400 (clobber (match_scratch:SI 4 "=a"))]
3401 "TARGET_64BIT && !optimize"
3403 [(set_attr "type" "idiv")
3404 (set_attr "mode" "DI")])
3407 ;; ....................
3411 ;; ....................
3413 (define_insn "sqrtdf2"
3414 [(set (match_operand:DF 0 "register_operand" "=f")
3415 (sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
3416 "TARGET_HARD_FLOAT && HAVE_SQRT_P() && TARGET_DOUBLE_FLOAT"
3418 [(set_attr "type" "fsqrt")
3419 (set_attr "mode" "DF")])
3421 (define_insn "sqrtsf2"
3422 [(set (match_operand:SF 0 "register_operand" "=f")
3423 (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
3424 "TARGET_HARD_FLOAT && HAVE_SQRT_P()"
3426 [(set_attr "type" "fsqrt")
3427 (set_attr "mode" "SF")])
3430 [(set (match_operand:DF 0 "register_operand" "=f")
3431 (div:DF (match_operand:DF 1 "const_float_1_operand" "")
3432 (sqrt:DF (match_operand:DF 2 "register_operand" "f"))))]
3433 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && flag_unsafe_math_optimizations"
3435 [(set_attr "type" "frsqrt")
3436 (set_attr "mode" "DF")])
3439 [(set (match_operand:SF 0 "register_operand" "=f")
3440 (div:SF (match_operand:SF 1 "const_float_1_operand" "")
3441 (sqrt:SF (match_operand:SF 2 "register_operand" "f"))))]
3442 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && flag_unsafe_math_optimizations"
3444 [(set_attr "type" "frsqrt")
3445 (set_attr "mode" "SF")])
3449 ;; ....................
3453 ;; ....................
3455 ;; Do not use the integer abs macro instruction, since that signals an
3456 ;; exception on -2147483648 (sigh).
3458 (define_insn "abssi2"
3459 [(set (match_operand:SI 0 "register_operand" "=d")
3460 (abs:SI (match_operand:SI 1 "register_operand" "d")))]
3464 operands[2] = const0_rtx;
3466 if (REGNO (operands[0]) == REGNO (operands[1]))
3468 if (GENERATE_BRANCHLIKELY)
3469 return \"%(bltzl\\t%1,1f\\n\\tsubu\\t%0,%z2,%0\\n%~1:%)\";
3471 return \"bgez\\t%1,1f%#\\n\\tsubu\\t%0,%z2,%0\\n%~1:\";
3474 return \"%(bgez\\t%1,1f\\n\\tmove\\t%0,%1\\n\\tsubu\\t%0,%z2,%0\\n%~1:%)\";
3476 [(set_attr "type" "multi")
3477 (set_attr "mode" "SI")
3478 (set_attr "length" "12")])
3480 (define_insn "absdi2"
3481 [(set (match_operand:DI 0 "register_operand" "=d")
3482 (abs:DI (match_operand:DI 1 "register_operand" "d")))]
3483 "TARGET_64BIT && !TARGET_MIPS16"
3486 unsigned int regno1;
3487 operands[2] = const0_rtx;
3489 if (GET_CODE (operands[1]) == REG)
3490 regno1 = REGNO (operands[1]);
3492 regno1 = REGNO (XEXP (operands[1], 0));
3494 if (REGNO (operands[0]) == regno1)
3495 return \"%(bltzl\\t%1,1f\\n\\tdsubu\\t%0,%z2,%0\\n%~1:%)\";
3497 return \"%(bgez\\t%1,1f\\n\\tmove\\t%0,%1\\n\\tdsubu\\t%0,%z2,%0\\n%~1:%)\";
3499 [(set_attr "type" "multi")
3500 (set_attr "mode" "DI")
3501 (set_attr "length" "12")])
3503 (define_insn "absdf2"
3504 [(set (match_operand:DF 0 "register_operand" "=f")
3505 (abs:DF (match_operand:DF 1 "register_operand" "f")))]
3506 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
3508 [(set_attr "type" "fabs")
3509 (set_attr "mode" "DF")])
3511 (define_insn "abssf2"
3512 [(set (match_operand:SF 0 "register_operand" "=f")
3513 (abs:SF (match_operand:SF 1 "register_operand" "f")))]
3516 [(set_attr "type" "fabs")
3517 (set_attr "mode" "SF")])
3521 ;; ....................
3523 ;; FIND FIRST BIT INSTRUCTION
3525 ;; ....................
3528 (define_insn "ffssi2"
3529 [(set (match_operand:SI 0 "register_operand" "=&d")
3530 (ffs:SI (match_operand:SI 1 "register_operand" "d")))
3531 (clobber (match_scratch:SI 2 "=&d"))
3532 (clobber (match_scratch:SI 3 "=&d"))]
3536 operands[4] = const0_rtx;
3538 if (optimize && find_reg_note (insn, REG_DEAD, operands[1]))
3541 \\tbeq\\t%1,%z4,2f\\n\\
3542 %~1:\\tand\\t%2,%1,0x0001\\n\\
3543 \\taddu\\t%0,%0,1\\n\\
3544 \\tbeq\\t%2,%z4,1b\\n\\
3545 \\tsrl\\t%1,%1,1\\n\\
3550 \\tmove\\t%3,%1\\n\\
3551 \\tbeq\\t%3,%z4,2f\\n\\
3552 %~1:\\tand\\t%2,%3,0x0001\\n\\
3553 \\taddu\\t%0,%0,1\\n\\
3554 \\tbeq\\t%2,%z4,1b\\n\\
3555 \\tsrl\\t%3,%3,1\\n\\
3558 [(set_attr "type" "multi")
3559 (set_attr "mode" "SI")
3560 (set_attr "length" "12")])
3562 (define_insn "ffsdi2"
3563 [(set (match_operand:DI 0 "register_operand" "=&d")
3564 (ffs:DI (match_operand:DI 1 "register_operand" "d")))
3565 (clobber (match_scratch:DI 2 "=&d"))
3566 (clobber (match_scratch:DI 3 "=&d"))]
3567 "TARGET_64BIT && !TARGET_MIPS16"
3570 operands[4] = const0_rtx;
3572 if (optimize && find_reg_note (insn, REG_DEAD, operands[1]))
3575 \\tbeq\\t%1,%z4,2f\\n\\
3576 %~1:\\tand\\t%2,%1,0x0001\\n\\
3577 \\tdaddu\\t%0,%0,1\\n\\
3578 \\tbeq\\t%2,%z4,1b\\n\\
3579 \\tdsrl\\t%1,%1,1\\n\\
3584 \\tmove\\t%3,%1\\n\\
3585 \\tbeq\\t%3,%z4,2f\\n\\
3586 %~1:\\tand\\t%2,%3,0x0001\\n\\
3587 \\tdaddu\\t%0,%0,1\\n\\
3588 \\tbeq\\t%2,%z4,1b\\n\\
3589 \\tdsrl\\t%3,%3,1\\n\\
3592 [(set_attr "type" "multi")
3593 (set_attr "mode" "DI")
3594 (set_attr "length" "24")])
3598 ;; ....................
3600 ;; NEGATION and ONE'S COMPLEMENT
3602 ;; ....................
3604 (define_insn "negsi2"
3605 [(set (match_operand:SI 0 "register_operand" "=d")
3606 (neg:SI (match_operand:SI 1 "register_operand" "d")))]
3611 return \"neg\\t%0,%1\";
3612 operands[2] = const0_rtx;
3613 return \"subu\\t%0,%z2,%1\";
3615 [(set_attr "type" "arith")
3616 (set_attr "mode" "SI")])
3618 (define_expand "negdi2"
3619 [(parallel [(set (match_operand:DI 0 "register_operand" "=d")
3620 (neg:DI (match_operand:DI 1 "register_operand" "d")))
3621 (clobber (match_dup 2))])]
3622 "(TARGET_64BIT || !TARGET_DEBUG_G_MODE) && !TARGET_MIPS16"
3627 emit_insn (gen_negdi2_internal_2 (operands[0], operands[1]));
3631 operands[2] = gen_reg_rtx (SImode);
3634 (define_insn "negdi2_internal"
3635 [(set (match_operand:DI 0 "register_operand" "=d")
3636 (neg:DI (match_operand:DI 1 "register_operand" "d")))
3637 (clobber (match_operand:SI 2 "register_operand" "=d"))]
3638 "! TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16"
3641 operands[3] = const0_rtx;
3642 return \"subu\\t%L0,%z3,%L1\;subu\\t%M0,%z3,%M1\;sltu\\t%2,%z3,%L0\;subu\\t%M0,%M0,%2\";
3644 [(set_attr "type" "darith")
3645 (set_attr "mode" "DI")
3646 (set_attr "length" "16")])
3648 (define_insn "negdi2_internal_2"
3649 [(set (match_operand:DI 0 "register_operand" "=d")
3650 (neg:DI (match_operand:DI 1 "register_operand" "d")))]
3651 "TARGET_64BIT && !TARGET_MIPS16"
3654 operands[2] = const0_rtx;
3655 return \"dsubu\\t%0,%z2,%1\";
3657 [(set_attr "type" "arith")
3658 (set_attr "mode" "DI")])
3660 (define_insn "negdf2"
3661 [(set (match_operand:DF 0 "register_operand" "=f")
3662 (neg:DF (match_operand:DF 1 "register_operand" "f")))]
3663 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
3665 [(set_attr "type" "fneg")
3666 (set_attr "mode" "DF")])
3668 (define_insn "negsf2"
3669 [(set (match_operand:SF 0 "register_operand" "=f")
3670 (neg:SF (match_operand:SF 1 "register_operand" "f")))]
3673 [(set_attr "type" "fneg")
3674 (set_attr "mode" "SF")])
3676 (define_insn "one_cmplsi2"
3677 [(set (match_operand:SI 0 "register_operand" "=d")
3678 (not:SI (match_operand:SI 1 "register_operand" "d")))]
3683 return \"not\\t%0,%1\";
3684 operands[2] = const0_rtx;
3685 return \"nor\\t%0,%z2,%1\";
3687 [(set_attr "type" "arith")
3688 (set_attr "mode" "SI")])
3690 (define_insn "one_cmpldi2"
3691 [(set (match_operand:DI 0 "register_operand" "=d")
3692 (not:DI (match_operand:DI 1 "register_operand" "d")))]
3697 return \"not\\t%0,%1\";
3698 return \"nor\\t%0,%.,%1\";
3700 [(set_attr "type" "darith")
3701 (set_attr "mode" "DI")])
3704 ;; ....................
3708 ;; ....................
3711 ;; Many of these instructions uses trivial define_expands, because we
3712 ;; want to use a different set of constraints when TARGET_MIPS16.
3714 (define_expand "andsi3"
3715 [(set (match_operand:SI 0 "register_operand" "=d,d")
3716 (and:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
3717 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
3723 operands[1] = force_reg (SImode, operands[1]);
3724 operands[2] = force_reg (SImode, operands[2]);
3729 [(set (match_operand:SI 0 "register_operand" "=d,d")
3730 (and:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
3731 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
3736 [(set_attr "type" "arith")
3737 (set_attr "mode" "SI")])
3740 [(set (match_operand:SI 0 "register_operand" "=d")
3741 (and:SI (match_operand:SI 1 "register_operand" "%0")
3742 (match_operand:SI 2 "register_operand" "d")))]
3745 [(set_attr "type" "arith")
3746 (set_attr "mode" "SI")])
3748 (define_expand "anddi3"
3749 [(set (match_operand:DI 0 "register_operand" "")
3750 (and:DI (match_operand:DI 1 "register_operand" "")
3751 (match_operand:DI 2 "uns_arith_operand" "")))]
3757 operands[1] = force_reg (DImode, operands[1]);
3758 operands[2] = force_reg (DImode, operands[2]);
3763 [(set (match_operand:DI 0 "register_operand" "=d,d")
3764 (and:DI (match_operand:DI 1 "register_operand" "d,d")
3765 (match_operand:DI 2 "uns_arith_operand" "d,K")))]
3766 "TARGET_64BIT && !TARGET_MIPS16"
3770 [(set_attr "type" "darith")
3771 (set_attr "mode" "DI")])
3774 [(set (match_operand:DI 0 "register_operand" "=d")
3775 (and:DI (match_operand:DI 1 "register_operand" "0")
3776 (match_operand:DI 2 "register_operand" "d")))]
3777 "TARGET_64BIT && TARGET_MIPS16"
3779 [(set_attr "type" "darith")
3780 (set_attr "mode" "DI")])
3782 (define_expand "iorsi3"
3783 [(set (match_operand:SI 0 "register_operand" "=d,d")
3784 (ior:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
3785 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
3791 operands[1] = force_reg (SImode, operands[1]);
3792 operands[2] = force_reg (SImode, operands[2]);
3797 [(set (match_operand:SI 0 "register_operand" "=d,d")
3798 (ior:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
3799 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
3804 [(set_attr "type" "arith")
3805 (set_attr "mode" "SI")])
3808 [(set (match_operand:SI 0 "register_operand" "=d")
3809 (ior:SI (match_operand:SI 1 "register_operand" "%0")
3810 (match_operand:SI 2 "register_operand" "d")))]
3813 [(set_attr "type" "arith")
3814 (set_attr "mode" "SI")])
3816 (define_expand "iordi3"
3817 [(set (match_operand:DI 0 "register_operand" "")
3818 (ior:DI (match_operand:DI 1 "register_operand" "")
3819 (match_operand:DI 2 "uns_arith_operand" "")))]
3825 operands[1] = force_reg (DImode, operands[1]);
3826 operands[2] = force_reg (DImode, operands[2]);
3831 [(set (match_operand:DI 0 "register_operand" "=d,d")
3832 (ior:DI (match_operand:DI 1 "register_operand" "d,d")
3833 (match_operand:DI 2 "uns_arith_operand" "d,K")))]
3834 "TARGET_64BIT && !TARGET_MIPS16"
3838 [(set_attr "type" "darith")
3839 (set_attr "mode" "DI")])
3842 [(set (match_operand:DI 0 "register_operand" "=d")
3843 (ior:DI (match_operand:DI 1 "register_operand" "0")
3844 (match_operand:DI 2 "register_operand" "d")))]
3845 "TARGET_64BIT && TARGET_MIPS16"
3847 [(set_attr "type" "darith")
3848 (set_attr "mode" "DI")])
3850 (define_expand "xorsi3"
3851 [(set (match_operand:SI 0 "register_operand" "=d,d")
3852 (xor:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
3853 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
3858 [(set (match_operand:SI 0 "register_operand" "=d,d")
3859 (xor:SI (match_operand:SI 1 "uns_arith_operand" "%d,d")
3860 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
3865 [(set_attr "type" "arith")
3866 (set_attr "mode" "SI")])
3869 [(set (match_operand:SI 0 "register_operand" "=d,t,t")
3870 (xor:SI (match_operand:SI 1 "uns_arith_operand" "%0,d,d")
3871 (match_operand:SI 2 "uns_arith_operand" "d,K,d")))]
3877 [(set_attr "type" "arith")
3878 (set_attr "mode" "SI")
3879 (set_attr_alternative "length"
3881 (if_then_else (match_operand:VOID 2 "m16_uimm8_1" "")
3886 (define_expand "xordi3"
3887 [(set (match_operand:DI 0 "register_operand" "")
3888 (xor:DI (match_operand:DI 1 "register_operand" "")
3889 (match_operand:DI 2 "uns_arith_operand" "")))]
3895 operands[1] = force_reg (DImode, operands[1]);
3896 operands[2] = force_reg (DImode, operands[2]);
3901 [(set (match_operand:DI 0 "register_operand" "=d,d")
3902 (xor:DI (match_operand:DI 1 "register_operand" "d,d")
3903 (match_operand:DI 2 "uns_arith_operand" "d,K")))]
3904 "TARGET_64BIT && !TARGET_MIPS16"
3908 [(set_attr "type" "darith")
3909 (set_attr "mode" "DI")])
3912 [(set (match_operand:DI 0 "register_operand" "=d,t,t")
3913 (xor:DI (match_operand:DI 1 "register_operand" "%0,d,d")
3914 (match_operand:DI 2 "uns_arith_operand" "d,K,d")))]
3915 "TARGET_64BIT && TARGET_MIPS16"
3920 [(set_attr "type" "arith")
3921 (set_attr "mode" "DI")
3922 (set_attr_alternative "length"
3924 (if_then_else (match_operand:VOID 2 "m16_uimm8_1" "")
3929 (define_insn "*norsi3"
3930 [(set (match_operand:SI 0 "register_operand" "=d")
3931 (and:SI (not:SI (match_operand:SI 1 "register_operand" "d"))
3932 (not:SI (match_operand:SI 2 "register_operand" "d"))))]
3935 [(set_attr "type" "arith")
3936 (set_attr "mode" "SI")])
3938 (define_insn "*nordi3"
3939 [(set (match_operand:DI 0 "register_operand" "=d")
3940 (and:DI (not:DI (match_operand:DI 1 "register_operand" "d"))
3941 (not:DI (match_operand:DI 2 "register_operand" "d"))))]
3942 "TARGET_64BIT && !TARGET_MIPS16"
3944 [(set_attr "type" "darith")
3945 (set_attr "mode" "DI")])
3948 ;; ....................
3952 ;; ....................
3956 (define_insn "truncdfsf2"
3957 [(set (match_operand:SF 0 "register_operand" "=f")
3958 (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
3959 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
3961 [(set_attr "type" "fcvt")
3962 (set_attr "mode" "SF")])
3964 ;; Integer truncation patterns. Truncating SImode values to smaller
3965 ;; modes is a no-op, as it is for most other GCC ports. Truncating
3966 ;; DImode values to SImode is not a no-op for TARGET_64BIT since we
3967 ;; need to make sure that the lower 32 bits are properly sign-extended
3968 ;; (see TRULY_NOOP_TRUNCATION). Truncating DImode values into modes
3969 ;; smaller than SImode is equivalent to two separate truncations:
3972 ;; DI ---> HI == DI ---> SI ---> HI
3973 ;; DI ---> QI == DI ---> SI ---> QI
3975 ;; Step A needs a real instruction but step B does not.
3977 (define_insn "truncdisi2"
3978 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,m")
3979 (truncate:SI (match_operand:DI 1 "register_operand" "d,d")))]
3984 [(set_attr "type" "darith")
3985 (set_attr "mode" "SI")
3986 (set_attr "extended_mips16" "yes,*")])
3988 (define_insn "truncdihi2"
3989 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,m")
3990 (truncate:HI (match_operand:DI 1 "register_operand" "d,d")))]
3995 [(set_attr "type" "darith")
3996 (set_attr "mode" "SI")
3997 (set_attr "extended_mips16" "yes,*")])
3999 (define_insn "truncdiqi2"
4000 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,m")
4001 (truncate:QI (match_operand:DI 1 "register_operand" "d,d")))]
4006 [(set_attr "type" "darith")
4007 (set_attr "mode" "SI")
4008 (set_attr "extended_mips16" "yes,*")])
4010 ;; Combiner patterns to optimize shift/truncate combinations.
4013 [(set (match_operand:SI 0 "register_operand" "=d")
4014 (truncate:SI (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
4015 (match_operand:DI 2 "small_int" "I"))))]
4016 "TARGET_64BIT && !TARGET_MIPS16 && INTVAL (operands[2]) >= 32"
4018 [(set_attr "type" "darith")
4019 (set_attr "mode" "SI")])
4022 [(set (match_operand:SI 0 "register_operand" "=d")
4023 (truncate:SI (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
4025 "TARGET_64BIT && !TARGET_MIPS16"
4027 [(set_attr "type" "darith")
4028 (set_attr "mode" "SI")])
4031 ;; Combiner patterns for truncate/sign_extend combinations. They use
4032 ;; the shift/truncate patterns above.
4034 (define_insn_and_split ""
4035 [(set (match_operand:SI 0 "register_operand" "=d")
4037 (truncate:HI (match_operand:DI 1 "register_operand" "d"))))]
4038 "TARGET_64BIT && !TARGET_MIPS16"
4040 "&& reload_completed"
4042 (ashift:DI (match_dup 1)
4045 (truncate:SI (ashiftrt:DI (match_dup 2)
4047 { operands[2] = gen_lowpart (DImode, operands[0]); })
4049 (define_insn_and_split ""
4050 [(set (match_operand:SI 0 "register_operand" "=d")
4052 (truncate:QI (match_operand:DI 1 "register_operand" "d"))))]
4053 "TARGET_64BIT && !TARGET_MIPS16"
4055 "&& reload_completed"
4057 (ashift:DI (match_dup 1)
4060 (truncate:SI (ashiftrt:DI (match_dup 2)
4062 { operands[2] = gen_lowpart (DImode, operands[0]); })
4065 ;; Combiner patterns to optimize truncate/zero_extend combinations.
4068 [(set (match_operand:SI 0 "register_operand" "=d")
4069 (zero_extend:SI (truncate:HI
4070 (match_operand:DI 1 "register_operand" "d"))))]
4071 "TARGET_64BIT && !TARGET_MIPS16"
4072 "andi\\t%0,%1,0xffff"
4073 [(set_attr "type" "darith")
4074 (set_attr "mode" "SI")])
4077 [(set (match_operand:SI 0 "register_operand" "=d")
4078 (zero_extend:SI (truncate:QI
4079 (match_operand:DI 1 "register_operand" "d"))))]
4080 "TARGET_64BIT && !TARGET_MIPS16"
4082 [(set_attr "type" "darith")
4083 (set_attr "mode" "SI")])
4086 [(set (match_operand:HI 0 "register_operand" "=d")
4087 (zero_extend:HI (truncate:QI
4088 (match_operand:DI 1 "register_operand" "d"))))]
4089 "TARGET_64BIT && !TARGET_MIPS16"
4091 [(set_attr "type" "darith")
4092 (set_attr "mode" "HI")])
4096 ;; ....................
4100 ;; ....................
4103 ;; Those for integer source operand are ordered widest source type first.
4105 (define_insn_and_split "zero_extendsidi2"
4106 [(set (match_operand:DI 0 "register_operand" "=d")
4107 (zero_extend:DI (match_operand:SI 1 "register_operand" "d")))]
4110 "&& reload_completed"
4112 (ashift:DI (match_dup 1) (const_int 32)))
4114 (lshiftrt:DI (match_dup 0) (const_int 32)))]
4115 "operands[1] = gen_lowpart (DImode, operands[1]);"
4116 [(set_attr "type" "arith")
4117 (set_attr "mode" "DI")])
4119 (define_insn "*zero_extendsidi2_mem"
4120 [(set (match_operand:DI 0 "register_operand" "=d")
4121 (zero_extend:DI (match_operand:SI 1 "memory_operand" "m")))]
4122 "TARGET_64BIT && !TARGET_MIPS16"
4124 [(set_attr "type" "load")
4125 (set_attr "mode" "DI")])
4127 (define_expand "zero_extendhisi2"
4128 [(set (match_operand:SI 0 "register_operand" "")
4129 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
4133 if (TARGET_MIPS16 && GET_CODE (operands[1]) != MEM)
4135 rtx op = gen_lowpart (SImode, operands[1]);
4136 rtx temp = force_reg (SImode, GEN_INT (0xffff));
4138 emit_insn (gen_andsi3 (operands[0], op, temp));
4144 [(set (match_operand:SI 0 "register_operand" "=d,d")
4145 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "d,m")))]
4150 [(set_attr "type" "arith,load")
4151 (set_attr "mode" "SI")
4152 (set_attr "length" "4,*")])
4155 [(set (match_operand:SI 0 "register_operand" "=d")
4156 (zero_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
4159 [(set_attr "type" "load")
4160 (set_attr "mode" "SI")])
4162 (define_expand "zero_extendhidi2"
4163 [(set (match_operand:DI 0 "register_operand" "")
4164 (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "")))]
4168 if (TARGET_MIPS16 && GET_CODE (operands[1]) != MEM)
4170 rtx op = gen_lowpart (DImode, operands[1]);
4171 rtx temp = force_reg (DImode, GEN_INT (0xffff));
4173 emit_insn (gen_anddi3 (operands[0], op, temp));
4179 [(set (match_operand:DI 0 "register_operand" "=d,d")
4180 (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "d,m")))]
4181 "TARGET_64BIT && !TARGET_MIPS16"
4185 [(set_attr "type" "arith,load")
4186 (set_attr "mode" "DI")
4187 (set_attr "length" "4,*")])
4190 [(set (match_operand:DI 0 "register_operand" "=d")
4191 (zero_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
4192 "TARGET_64BIT && TARGET_MIPS16"
4194 [(set_attr "type" "load")
4195 (set_attr "mode" "DI")])
4197 (define_expand "zero_extendqihi2"
4198 [(set (match_operand:HI 0 "register_operand" "")
4199 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))]
4203 if (TARGET_MIPS16 && GET_CODE (operands[1]) != MEM)
4205 rtx op0 = gen_lowpart (SImode, operands[0]);
4206 rtx op1 = gen_lowpart (SImode, operands[1]);
4207 rtx temp = force_reg (SImode, GEN_INT (0xff));
4209 emit_insn (gen_andsi3 (op0, op1, temp));
4215 [(set (match_operand:HI 0 "register_operand" "=d,d")
4216 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
4221 [(set_attr "type" "arith,load")
4222 (set_attr "mode" "HI")
4223 (set_attr "length" "4,*")])
4226 [(set (match_operand:HI 0 "register_operand" "=d")
4227 (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
4230 [(set_attr "type" "load")
4231 (set_attr "mode" "HI")])
4233 (define_expand "zero_extendqisi2"
4234 [(set (match_operand:SI 0 "register_operand" "")
4235 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
4239 if (TARGET_MIPS16 && GET_CODE (operands[1]) != MEM)
4241 rtx op = gen_lowpart (SImode, operands[1]);
4242 rtx temp = force_reg (SImode, GEN_INT (0xff));
4244 emit_insn (gen_andsi3 (operands[0], op, temp));
4250 [(set (match_operand:SI 0 "register_operand" "=d,d")
4251 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
4256 [(set_attr "type" "arith,load")
4257 (set_attr "mode" "SI")
4258 (set_attr "length" "4,*")])
4261 [(set (match_operand:SI 0 "register_operand" "=d")
4262 (zero_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
4265 [(set_attr "type" "load")
4266 (set_attr "mode" "SI")])
4268 (define_expand "zero_extendqidi2"
4269 [(set (match_operand:DI 0 "register_operand" "")
4270 (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "")))]
4274 if (TARGET_MIPS16 && GET_CODE (operands[1]) != MEM)
4276 rtx op = gen_lowpart (DImode, operands[1]);
4277 rtx temp = force_reg (DImode, GEN_INT (0xff));
4279 emit_insn (gen_anddi3 (operands[0], op, temp));
4285 [(set (match_operand:DI 0 "register_operand" "=d,d")
4286 (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
4287 "TARGET_64BIT && !TARGET_MIPS16"
4291 [(set_attr "type" "arith,load")
4292 (set_attr "mode" "DI")
4293 (set_attr "length" "4,*")])
4296 [(set (match_operand:DI 0 "register_operand" "=d")
4297 (zero_extend:DI (match_operand:QI 1 "memory_operand" "m")))]
4298 "TARGET_64BIT && TARGET_MIPS16"
4300 [(set_attr "type" "load")
4301 (set_attr "mode" "DI")])
4304 ;; ....................
4308 ;; ....................
4311 ;; Those for integer source operand are ordered widest source type first.
4313 (define_expand "extendsidi2"
4314 [(set (match_operand:DI 0 "register_operand" "")
4315 (sign_extend:DI (match_operand:SI 1 "move_operand" "")))]
4319 if (symbolic_operand (operands[1], SImode))
4321 emit_move_insn (operands[0], convert_memory_address (DImode, operands[1]));
4327 (define_insn "*extendsidi2"
4328 [(set (match_operand:DI 0 "register_operand" "=d,d")
4329 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m")))]
4334 [(set_attr "type" "arith,load")
4335 (set_attr "mode" "DI")
4336 (set_attr "extended_mips16" "yes,*")])
4338 ;; These patterns originally accepted general_operands, however, slightly
4339 ;; better code is generated by only accepting register_operands, and then
4340 ;; letting combine generate the lh and lb insns.
4342 ;; These expanders originally put values in registers first. We split
4343 ;; all non-mem patterns after reload.
4345 (define_expand "extendhidi2"
4346 [(set (match_operand:DI 0 "register_operand" "")
4347 (sign_extend:DI (match_operand:HI 1 "nonimmediate_operand" "")))]
4351 (define_insn "*extendhidi2"
4352 [(set (match_operand:DI 0 "register_operand" "=d")
4353 (sign_extend:DI (match_operand:HI 1 "register_operand" "d")))]
4358 [(set (match_operand:DI 0 "register_operand" "")
4359 (sign_extend:DI (match_operand:HI 1 "register_operand" "")))]
4360 "TARGET_64BIT && reload_completed"
4362 (ashift:DI (match_dup 1) (const_int 48)))
4364 (ashiftrt:DI (match_dup 0) (const_int 48)))]
4365 "operands[1] = gen_lowpart (DImode, operands[1]);")
4367 (define_insn "*extendhidi2_mem"
4368 [(set (match_operand:DI 0 "register_operand" "=d")
4369 (sign_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
4372 [(set_attr "type" "load")
4373 (set_attr "mode" "DI")])
4375 (define_expand "extendhisi2"
4376 [(set (match_operand:SI 0 "register_operand" "")
4377 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
4380 if (ISA_HAS_SEB_SEH)
4382 emit_insn (gen_extendhisi2_hw (operands[0],
4383 force_reg (HImode, operands[1])));
4388 (define_insn "*extendhisi2"
4389 [(set (match_operand:SI 0 "register_operand" "=d")
4390 (sign_extend:SI (match_operand:HI 1 "register_operand" "d")))]
4395 [(set (match_operand:SI 0 "register_operand" "")
4396 (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
4399 (ashift:SI (match_dup 1) (const_int 16)))
4401 (ashiftrt:SI (match_dup 0) (const_int 16)))]
4402 "operands[1] = gen_lowpart (SImode, operands[1]);")
4404 (define_insn "extendhisi2_mem"
4405 [(set (match_operand:SI 0 "register_operand" "=d")
4406 (sign_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
4409 [(set_attr "type" "load")
4410 (set_attr "mode" "SI")])
4412 (define_insn "extendhisi2_hw"
4413 [(set (match_operand:SI 0 "register_operand" "=r")
4414 (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
4417 [(set_attr "type" "arith")
4418 (set_attr "mode" "SI")])
4420 (define_expand "extendqihi2"
4421 [(set (match_operand:HI 0 "register_operand" "")
4422 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))]
4426 (define_insn "*extendqihi2"
4427 [(set (match_operand:HI 0 "register_operand" "=d")
4428 (sign_extend:HI (match_operand:QI 1 "register_operand" "d")))]
4433 [(set (match_operand:HI 0 "register_operand" "")
4434 (sign_extend:HI (match_operand:QI 1 "register_operand" "")))]
4437 (ashift:SI (match_dup 1) (const_int 24)))
4439 (ashiftrt:SI (match_dup 0) (const_int 24)))]
4440 "operands[0] = gen_lowpart (SImode, operands[0]);
4441 operands[1] = gen_lowpart (SImode, operands[1]);")
4443 (define_insn "*extendqihi2_internal_mem"
4444 [(set (match_operand:HI 0 "register_operand" "=d")
4445 (sign_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
4448 [(set_attr "type" "load")
4449 (set_attr "mode" "SI")])
4452 (define_expand "extendqisi2"
4453 [(set (match_operand:SI 0 "register_operand" "")
4454 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
4457 if (ISA_HAS_SEB_SEH)
4459 emit_insn (gen_extendqisi2_hw (operands[0],
4460 force_reg (QImode, operands[1])));
4465 (define_insn "*extendqisi2"
4466 [(set (match_operand:SI 0 "register_operand" "=d")
4467 (sign_extend:SI (match_operand:QI 1 "register_operand" "d")))]
4472 [(set (match_operand:SI 0 "register_operand" "")
4473 (sign_extend:SI (match_operand:QI 1 "register_operand" "")))]
4476 (ashift:SI (match_dup 1) (const_int 24)))
4478 (ashiftrt:SI (match_dup 0) (const_int 24)))]
4479 "operands[1] = gen_lowpart (SImode, operands[1]);")
4481 (define_insn "*extendqisi2_mem"
4482 [(set (match_operand:SI 0 "register_operand" "=d")
4483 (sign_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
4486 [(set_attr "type" "load")
4487 (set_attr "mode" "SI")])
4489 (define_insn "extendqisi2_hw"
4490 [(set (match_operand:SI 0 "register_operand" "=r")
4491 (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
4494 [(set_attr "type" "arith")
4495 (set_attr "mode" "SI")])
4497 (define_expand "extendqidi2"
4498 [(set (match_operand:DI 0 "register_operand" "")
4499 (sign_extend:DI (match_operand:QI 1 "nonimmediate_operand" "")))]
4503 (define_insn "*extendqidi2"
4504 [(set (match_operand:DI 0 "register_operand" "=d")
4505 (sign_extend:DI (match_operand:QI 1 "register_operand" "d")))]
4510 [(set (match_operand:DI 0 "register_operand" "")
4511 (sign_extend:DI (match_operand:QI 1 "register_operand" "")))]
4512 "TARGET_64BIT && reload_completed"
4514 (ashift:DI (match_dup 1) (const_int 56)))
4516 (ashiftrt:DI (match_dup 0) (const_int 56)))]
4517 "operands[1] = gen_lowpart (DImode, operands[1]);")
4519 (define_insn "*extendqidi2_mem"
4520 [(set (match_operand:DI 0 "register_operand" "=d")
4521 (sign_extend:DI (match_operand:QI 1 "memory_operand" "m")))]
4524 [(set_attr "type" "load")
4525 (set_attr "mode" "DI")])
4527 (define_insn "extendsfdf2"
4528 [(set (match_operand:DF 0 "register_operand" "=f")
4529 (float_extend:DF (match_operand:SF 1 "register_operand" "f")))]
4530 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
4532 [(set_attr "type" "fcvt")
4533 (set_attr "mode" "DF")])
4538 ;; ....................
4542 ;; ....................
4544 (define_expand "fix_truncdfsi2"
4545 [(set (match_operand:SI 0 "register_operand" "=f")
4546 (fix:SI (match_operand:DF 1 "register_operand" "f")))]
4547 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
4549 if (!ISA_HAS_TRUNC_W)
4551 emit_insn (gen_fix_truncdfsi2_macro (operands[0], operands[1]));
4556 (define_insn "fix_truncdfsi2_insn"
4557 [(set (match_operand:SI 0 "register_operand" "=f")
4558 (fix:SI (match_operand:DF 1 "register_operand" "f")))]
4559 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && ISA_HAS_TRUNC_W"
4561 [(set_attr "type" "fcvt")
4562 (set_attr "mode" "DF")
4563 (set_attr "length" "4")])
4565 (define_insn "fix_truncdfsi2_macro"
4566 [(set (match_operand:SI 0 "register_operand" "=f")
4567 (fix:SI (match_operand:DF 1 "register_operand" "f")))
4568 (clobber (match_scratch:DF 2 "=d"))]
4569 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !ISA_HAS_TRUNC_W"
4570 "trunc.w.d %0,%1,%2"
4571 [(set_attr "type" "fcvt")
4572 (set_attr "mode" "DF")
4573 (set_attr "length" "36")])
4575 (define_expand "fix_truncsfsi2"
4576 [(set (match_operand:SI 0 "register_operand" "=f")
4577 (fix:SI (match_operand:SF 1 "register_operand" "f")))]
4580 if (!ISA_HAS_TRUNC_W)
4582 emit_insn (gen_fix_truncsfsi2_macro (operands[0], operands[1]));
4587 (define_insn "fix_truncsfsi2_insn"
4588 [(set (match_operand:SI 0 "register_operand" "=f")
4589 (fix:SI (match_operand:SF 1 "register_operand" "f")))]
4590 "TARGET_HARD_FLOAT && ISA_HAS_TRUNC_W"
4592 [(set_attr "type" "fcvt")
4593 (set_attr "mode" "DF")
4594 (set_attr "length" "4")])
4596 (define_insn "fix_truncsfsi2_macro"
4597 [(set (match_operand:SI 0 "register_operand" "=f")
4598 (fix:SI (match_operand:SF 1 "register_operand" "f")))
4599 (clobber (match_scratch:SF 2 "=d"))]
4600 "TARGET_HARD_FLOAT && !ISA_HAS_TRUNC_W"
4601 "trunc.w.s %0,%1,%2"
4602 [(set_attr "type" "fcvt")
4603 (set_attr "mode" "DF")
4604 (set_attr "length" "36")])
4606 ;;; ??? trunc.l.d is mentioned in the appendix of the 1993 r4000/r4600 manuals
4607 ;;; but not in the chapter that describes the FPU. It is not mentioned at all
4608 ;;; in the 1991 manuals. The r4000 at Cygnus does not have this instruction.
4610 ;;; Deleting this means that we now need two libgcc2.a libraries. One for
4611 ;;; the 32 bit calling convention and one for the 64 bit calling convention.
4613 ;;; If this is disabled, then fixuns_truncdfdi2 must be disabled also.
4615 (define_insn "fix_truncdfdi2"
4616 [(set (match_operand:DI 0 "register_operand" "=f")
4617 (fix:DI (match_operand:DF 1 "register_operand" "f")))]
4618 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
4620 [(set_attr "type" "fcvt")
4621 (set_attr "mode" "DF")
4622 (set_attr "length" "4")])
4625 ;;; ??? trunc.l.s is mentioned in the appendix of the 1993 r4000/r4600 manuals
4626 ;;; but not in the chapter that describes the FPU. It is not mentioned at all
4627 ;;; in the 1991 manuals. The r4000 at Cygnus does not have this instruction.
4628 (define_insn "fix_truncsfdi2"
4629 [(set (match_operand:DI 0 "register_operand" "=f")
4630 (fix:DI (match_operand:SF 1 "register_operand" "f")))]
4631 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
4633 [(set_attr "type" "fcvt")
4634 (set_attr "mode" "SF")
4635 (set_attr "length" "4")])
4638 (define_insn "floatsidf2"
4639 [(set (match_operand:DF 0 "register_operand" "=f")
4640 (float:DF (match_operand:SI 1 "register_operand" "f")))]
4641 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
4643 [(set_attr "type" "fcvt")
4644 (set_attr "mode" "DF")
4645 (set_attr "length" "4")])
4648 (define_insn "floatdidf2"
4649 [(set (match_operand:DF 0 "register_operand" "=f")
4650 (float:DF (match_operand:DI 1 "register_operand" "f")))]
4651 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
4653 [(set_attr "type" "fcvt")
4654 (set_attr "mode" "DF")
4655 (set_attr "length" "4")])
4658 (define_insn "floatsisf2"
4659 [(set (match_operand:SF 0 "register_operand" "=f")
4660 (float:SF (match_operand:SI 1 "register_operand" "f")))]
4663 [(set_attr "type" "fcvt")
4664 (set_attr "mode" "SF")
4665 (set_attr "length" "4")])
4668 (define_insn "floatdisf2"
4669 [(set (match_operand:SF 0 "register_operand" "=f")
4670 (float:SF (match_operand:DI 1 "register_operand" "f")))]
4671 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
4673 [(set_attr "type" "fcvt")
4674 (set_attr "mode" "SF")
4675 (set_attr "length" "4")])
4678 (define_expand "fixuns_truncdfsi2"
4679 [(set (match_operand:SI 0 "register_operand" "")
4680 (unsigned_fix:SI (match_operand:DF 1 "register_operand" "")))]
4681 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
4684 rtx reg1 = gen_reg_rtx (DFmode);
4685 rtx reg2 = gen_reg_rtx (DFmode);
4686 rtx reg3 = gen_reg_rtx (SImode);
4687 rtx label1 = gen_label_rtx ();
4688 rtx label2 = gen_label_rtx ();
4689 REAL_VALUE_TYPE offset;
4691 real_2expN (&offset, 31);
4693 if (reg1) /* turn off complaints about unreached code */
4695 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, DFmode));
4696 do_pending_stack_adjust ();
4698 emit_insn (gen_cmpdf (operands[1], reg1));
4699 emit_jump_insn (gen_bge (label1));
4701 emit_insn (gen_fix_truncdfsi2 (operands[0], operands[1]));
4702 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
4703 gen_rtx_LABEL_REF (VOIDmode, label2)));
4706 emit_label (label1);
4707 emit_move_insn (reg2, gen_rtx_MINUS (DFmode, operands[1], reg1));
4708 emit_move_insn (reg3, GEN_INT (trunc_int_for_mode
4709 (BITMASK_HIGH, SImode)));
4711 emit_insn (gen_fix_truncdfsi2 (operands[0], reg2));
4712 emit_insn (gen_iorsi3 (operands[0], operands[0], reg3));
4714 emit_label (label2);
4716 /* allow REG_NOTES to be set on last insn (labels don't have enough
4717 fields, and can't be used for REG_NOTES anyway). */
4718 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
4724 (define_expand "fixuns_truncdfdi2"
4725 [(set (match_operand:DI 0 "register_operand" "")
4726 (unsigned_fix:DI (match_operand:DF 1 "register_operand" "")))]
4727 "TARGET_HARD_FLOAT && TARGET_64BIT && TARGET_DOUBLE_FLOAT"
4730 rtx reg1 = gen_reg_rtx (DFmode);
4731 rtx reg2 = gen_reg_rtx (DFmode);
4732 rtx reg3 = gen_reg_rtx (DImode);
4733 rtx label1 = gen_label_rtx ();
4734 rtx label2 = gen_label_rtx ();
4735 REAL_VALUE_TYPE offset;
4737 real_2expN (&offset, 63);
4739 if (reg1) /* turn off complaints about unreached code */
4741 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, DFmode));
4742 do_pending_stack_adjust ();
4744 emit_insn (gen_cmpdf (operands[1], reg1));
4745 emit_jump_insn (gen_bge (label1));
4747 emit_insn (gen_fix_truncdfdi2 (operands[0], operands[1]));
4748 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
4749 gen_rtx_LABEL_REF (VOIDmode, label2)));
4752 emit_label (label1);
4753 emit_move_insn (reg2, gen_rtx_MINUS (DFmode, operands[1], reg1));
4754 emit_move_insn (reg3, GEN_INT (BITMASK_HIGH));
4755 emit_insn (gen_ashldi3 (reg3, reg3, GEN_INT (32)));
4757 emit_insn (gen_fix_truncdfdi2 (operands[0], reg2));
4758 emit_insn (gen_iordi3 (operands[0], operands[0], reg3));
4760 emit_label (label2);
4762 /* allow REG_NOTES to be set on last insn (labels don't have enough
4763 fields, and can't be used for REG_NOTES anyway). */
4764 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
4770 (define_expand "fixuns_truncsfsi2"
4771 [(set (match_operand:SI 0 "register_operand" "")
4772 (unsigned_fix:SI (match_operand:SF 1 "register_operand" "")))]
4776 rtx reg1 = gen_reg_rtx (SFmode);
4777 rtx reg2 = gen_reg_rtx (SFmode);
4778 rtx reg3 = gen_reg_rtx (SImode);
4779 rtx label1 = gen_label_rtx ();
4780 rtx label2 = gen_label_rtx ();
4781 REAL_VALUE_TYPE offset;
4783 real_2expN (&offset, 31);
4785 if (reg1) /* turn off complaints about unreached code */
4787 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, SFmode));
4788 do_pending_stack_adjust ();
4790 emit_insn (gen_cmpsf (operands[1], reg1));
4791 emit_jump_insn (gen_bge (label1));
4793 emit_insn (gen_fix_truncsfsi2 (operands[0], operands[1]));
4794 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
4795 gen_rtx_LABEL_REF (VOIDmode, label2)));
4798 emit_label (label1);
4799 emit_move_insn (reg2, gen_rtx_MINUS (SFmode, operands[1], reg1));
4800 emit_move_insn (reg3, GEN_INT (trunc_int_for_mode
4801 (BITMASK_HIGH, SImode)));
4803 emit_insn (gen_fix_truncsfsi2 (operands[0], reg2));
4804 emit_insn (gen_iorsi3 (operands[0], operands[0], reg3));
4806 emit_label (label2);
4808 /* allow REG_NOTES to be set on last insn (labels don't have enough
4809 fields, and can't be used for REG_NOTES anyway). */
4810 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
4816 (define_expand "fixuns_truncsfdi2"
4817 [(set (match_operand:DI 0 "register_operand" "")
4818 (unsigned_fix:DI (match_operand:SF 1 "register_operand" "")))]
4819 "TARGET_HARD_FLOAT && TARGET_64BIT && TARGET_DOUBLE_FLOAT"
4822 rtx reg1 = gen_reg_rtx (SFmode);
4823 rtx reg2 = gen_reg_rtx (SFmode);
4824 rtx reg3 = gen_reg_rtx (DImode);
4825 rtx label1 = gen_label_rtx ();
4826 rtx label2 = gen_label_rtx ();
4827 REAL_VALUE_TYPE offset;
4829 real_2expN (&offset, 63);
4831 if (reg1) /* turn off complaints about unreached code */
4833 emit_move_insn (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, SFmode));
4834 do_pending_stack_adjust ();
4836 emit_insn (gen_cmpsf (operands[1], reg1));
4837 emit_jump_insn (gen_bge (label1));
4839 emit_insn (gen_fix_truncsfdi2 (operands[0], operands[1]));
4840 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
4841 gen_rtx_LABEL_REF (VOIDmode, label2)));
4844 emit_label (label1);
4845 emit_move_insn (reg2, gen_rtx_MINUS (SFmode, operands[1], reg1));
4846 emit_move_insn (reg3, GEN_INT (BITMASK_HIGH));
4847 emit_insn (gen_ashldi3 (reg3, reg3, GEN_INT (32)));
4849 emit_insn (gen_fix_truncsfdi2 (operands[0], reg2));
4850 emit_insn (gen_iordi3 (operands[0], operands[0], reg3));
4852 emit_label (label2);
4854 /* allow REG_NOTES to be set on last insn (labels don't have enough
4855 fields, and can't be used for REG_NOTES anyway). */
4856 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
4863 ;; ....................
4867 ;; ....................
4869 ;; Bit field extract patterns which use lwl/lwr or ldl/ldr.
4871 (define_expand "extv"
4872 [(set (match_operand 0 "register_operand" "")
4873 (sign_extract (match_operand:QI 1 "memory_operand" "")
4874 (match_operand 2 "immediate_operand" "")
4875 (match_operand 3 "immediate_operand" "")))]
4878 if (mips_expand_unaligned_load (operands[0], operands[1],
4879 INTVAL (operands[2]),
4880 INTVAL (operands[3])))
4886 (define_expand "extzv"
4887 [(set (match_operand 0 "register_operand" "")
4888 (zero_extract (match_operand:QI 1 "memory_operand" "")
4889 (match_operand 2 "immediate_operand" "")
4890 (match_operand 3 "immediate_operand" "")))]
4893 if (mips_expand_unaligned_load (operands[0], operands[1],
4894 INTVAL (operands[2]),
4895 INTVAL (operands[3])))
4901 (define_expand "insv"
4902 [(set (zero_extract (match_operand:QI 0 "memory_operand" "")
4903 (match_operand 1 "immediate_operand" "")
4904 (match_operand 2 "immediate_operand" ""))
4905 (match_operand 3 "reg_or_0_operand" ""))]
4908 if (mips_expand_unaligned_store (operands[0], operands[3],
4909 INTVAL (operands[1]),
4910 INTVAL (operands[2])))
4916 ;; Unaligned word moves generated by the bit field patterns.
4918 ;; As far as the rtl is concerned, both the left-part and right-part
4919 ;; instructions can access the whole field. However, the real operand
4920 ;; refers to just the first or the last byte (depending on endianness).
4921 ;; We therefore use two memory operands to each instruction, one to
4922 ;; describe the rtl effect and one to use in the assembly output.
4924 (define_insn "mov_lwl"
4925 [(set (match_operand:SI 0 "register_operand" "=d")
4926 (unspec:SI [(match_operand:BLK 1 "general_operand" "m")
4927 (match_operand:QI 2 "general_operand" "m")]
4931 [(set_attr "type" "load")
4932 (set_attr "mode" "SI")])
4934 (define_insn "mov_lwr"
4935 [(set (match_operand:SI 0 "register_operand" "=d")
4936 (unspec:SI [(match_operand:BLK 1 "general_operand" "m")
4937 (match_operand:QI 2 "general_operand" "m")
4938 (match_operand:SI 3 "register_operand" "0")]
4942 [(set_attr "type" "load")
4943 (set_attr "mode" "SI")])
4946 (define_insn "mov_swl"
4947 [(set (match_operand:BLK 0 "memory_operand" "=m")
4948 (unspec:BLK [(match_operand:SI 1 "reg_or_0_operand" "dJ")
4949 (match_operand:QI 2 "general_operand" "m")]
4953 [(set_attr "type" "store")
4954 (set_attr "mode" "SI")])
4956 (define_insn "mov_swr"
4957 [(set (match_operand:BLK 0 "memory_operand" "+m")
4958 (unspec:BLK [(match_operand:SI 1 "reg_or_0_operand" "dJ")
4959 (match_operand:QI 2 "general_operand" "m")
4964 [(set_attr "type" "store")
4965 (set_attr "mode" "SI")])
4968 (define_insn "mov_ldl"
4969 [(set (match_operand:DI 0 "register_operand" "=d")
4970 (unspec:DI [(match_operand:BLK 1 "general_operand" "m")
4971 (match_operand:QI 2 "general_operand" "m")]
4973 "TARGET_64BIT && !TARGET_MIPS16"
4975 [(set_attr "type" "load")
4976 (set_attr "mode" "DI")])
4978 (define_insn "mov_ldr"
4979 [(set (match_operand:DI 0 "register_operand" "=d")
4980 (unspec:DI [(match_operand:BLK 1 "general_operand" "m")
4981 (match_operand:QI 2 "general_operand" "m")
4982 (match_operand:DI 3 "register_operand" "0")]
4984 "TARGET_64BIT && !TARGET_MIPS16"
4986 [(set_attr "type" "load")
4987 (set_attr "mode" "DI")])
4990 (define_insn "mov_sdl"
4991 [(set (match_operand:BLK 0 "memory_operand" "=m")
4992 (unspec:BLK [(match_operand:DI 1 "reg_or_0_operand" "dJ")
4993 (match_operand:QI 2 "general_operand" "m")]
4995 "TARGET_64BIT && !TARGET_MIPS16"
4997 [(set_attr "type" "store")
4998 (set_attr "mode" "DI")])
5000 (define_insn "mov_sdr"
5001 [(set (match_operand:BLK 0 "memory_operand" "+m")
5002 (unspec:BLK [(match_operand:DI 1 "reg_or_0_operand" "dJ")
5003 (match_operand:QI 2 "general_operand" "m")
5006 "TARGET_64BIT && !TARGET_MIPS16"
5008 [(set_attr "type" "store")
5009 (set_attr "mode" "DI")])
5012 ;; Instructions for loading a relocation expression using "lui".
5014 (define_insn "luisi"
5015 [(set (match_operand:SI 0 "register_operand" "=r")
5016 (unspec:SI [(match_operand 1 "const_arith_operand" "")] UNSPEC_HIGH))]
5019 [(set_attr "type" "arith")])
5021 (define_insn "luidi"
5022 [(set (match_operand:DI 0 "register_operand" "=r")
5023 (unspec:DI [(match_operand 1 "const_arith_operand" "")] UNSPEC_HIGH))]
5026 [(set_attr "type" "arith")])
5029 ;; Instructions for adding the low 16 bits of an address to a register.
5030 ;; Operand 2 is the address: print_operand works out which relocation
5031 ;; should be applied.
5033 (define_insn "lowsi"
5034 [(set (match_operand:SI 0 "register_operand" "=r")
5035 (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
5036 (match_operand:SI 2 "immediate_operand" "")))]
5039 [(set_attr "type" "arith")
5040 (set_attr "mode" "SI")])
5042 (define_insn "lowdi"
5043 [(set (match_operand:DI 0 "register_operand" "=r")
5044 (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
5045 (match_operand:DI 2 "immediate_operand" "")))]
5046 "!TARGET_MIPS16 && TARGET_64BIT"
5047 "daddiu\\t%0,%1,%R2"
5048 [(set_attr "type" "arith")
5049 (set_attr "mode" "DI")])
5051 ;; 64-bit integer moves
5053 ;; Unlike most other insns, the move insns can't be split with
5054 ;; different predicates, because register spilling and other parts of
5055 ;; the compiler, have memoized the insn number already.
5057 (define_expand "movdi"
5058 [(set (match_operand:DI 0 "nonimmediate_operand" "")
5059 (match_operand:DI 1 "" ""))]
5063 if (mips_legitimize_move (DImode, operands[0], operands[1]))
5066 /* If we are generating embedded PIC code, and we are referring to a
5067 symbol in the .text section, we must use an offset from the start
5069 if (TARGET_EMBEDDED_PIC
5070 && (GET_CODE (operands[1]) == LABEL_REF
5071 || (GET_CODE (operands[1]) == SYMBOL_REF
5072 && ! SYMBOL_REF_FLAG (operands[1]))))
5076 temp = embedded_pic_offset (operands[1]);
5077 temp = gen_rtx_PLUS (Pmode, embedded_pic_fnaddr_reg (),
5078 force_reg (DImode, temp));
5079 emit_move_insn (operands[0], force_reg (DImode, temp));
5084 ;; For mips16, we need a special case to handle storing $31 into
5085 ;; memory, since we don't have a constraint to match $31. This
5086 ;; instruction can be generated by save_restore_insns.
5089 [(set (match_operand:DI 0 "memory_operand" "=m")
5091 "TARGET_MIPS16 && TARGET_64BIT"
5093 [(set_attr "type" "store")
5094 (set_attr "mode" "DI")])
5096 (define_insn "movdi_internal"
5097 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,m,*x,*d,*x,*B*C*D,*B*C*D,*d,*m")
5098 (match_operand:DI 1 "general_operand" "d,iF,m,d,J,*x,*d,*d,*m,*B*C*D,*B*C*D"))]
5099 "!TARGET_64BIT && !TARGET_MIPS16
5100 && (register_operand (operands[0], DImode)
5101 || register_operand (operands[1], DImode)
5102 || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0)
5103 || operands[1] == CONST0_RTX (DImode))"
5104 { return mips_output_move (operands[0], operands[1]); }
5105 [(set_attr "type" "move,arith,load,store,hilo,hilo,hilo,xfer,load,xfer,store")
5106 (set_attr "mode" "DI")
5107 (set_attr "length" "8,16,*,*,8,8,8,8,*,8,*")])
5110 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m,*d")
5111 (match_operand:DI 1 "general_operand" "d,d,y,K,N,m,d,*x"))]
5112 "!TARGET_64BIT && TARGET_MIPS16
5113 && (register_operand (operands[0], DImode)
5114 || register_operand (operands[1], DImode))"
5115 { return mips_output_move (operands[0], operands[1]); }
5116 [(set_attr "type" "move,move,move,arith,arith,load,store,hilo")
5117 (set_attr "mode" "DI")
5118 (set_attr "length" "8,8,8,8,12,*,*,8")])
5120 (define_insn "movdi_internal2"
5121 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,e,d,m,*f,*f,*f,*d,*m,*x,*d,*x,*a,*B*C*D,*B*C*D,*d,*m")
5122 (match_operand:DI 1 "move_operand" "d,U,T,m,dJ,*f,*d*J,*m,*f,*f,*J,*x,*d,*J,*d,*m,*B*C*D,*B*C*D"))]
5123 "TARGET_64BIT && !TARGET_MIPS16
5124 && (register_operand (operands[0], DImode)
5125 || register_operand (operands[1], DImode)
5126 || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0)
5127 || operands[1] == CONST0_RTX (DImode))"
5128 { return mips_output_move (operands[0], operands[1]); }
5129 [(set_attr "type" "move,const,const,load,store,move,xfer,load,xfer,store,hilo,hilo,hilo,hilo,xfer,load,xfer,store")
5130 (set_attr "mode" "DI")
5131 (set_attr "length" "4,*,*,*,*,4,4,*,4,*,4,4,4,8,8,*,8,*")])
5133 (define_insn "*movdi_internal2_mips16"
5134 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,y,d,d,d,d,d,m,*d")
5135 (match_operand:DI 1 "move_operand" "d,d,y,K,N,U,m,d,*x"))]
5136 "TARGET_64BIT && TARGET_MIPS16
5137 && (register_operand (operands[0], DImode)
5138 || register_operand (operands[1], DImode))"
5139 { return mips_output_move (operands[0], operands[1]); }
5140 [(set_attr "type" "move,move,move,arith,arith,const,load,store,hilo")
5141 (set_attr "mode" "DI")
5142 (set_attr_alternative "length"
5146 (if_then_else (match_operand:VOID 1 "m16_uimm8_1" "")
5149 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1" "")
5158 ;; On the mips16, we can split ld $r,N($r) into an add and a load,
5159 ;; when the original load is a 4 byte instruction but the add and the
5160 ;; load are 2 2 byte instructions.
5163 [(set (match_operand:DI 0 "register_operand" "")
5164 (mem:DI (plus:DI (match_dup 0)
5165 (match_operand:DI 1 "const_int_operand" ""))))]
5166 "TARGET_64BIT && TARGET_MIPS16 && reload_completed
5167 && !TARGET_DEBUG_D_MODE
5168 && GET_CODE (operands[0]) == REG
5169 && M16_REG_P (REGNO (operands[0]))
5170 && GET_CODE (operands[1]) == CONST_INT
5171 && ((INTVAL (operands[1]) < 0
5172 && INTVAL (operands[1]) >= -0x10)
5173 || (INTVAL (operands[1]) >= 32 * 8
5174 && INTVAL (operands[1]) <= 31 * 8 + 0x8)
5175 || (INTVAL (operands[1]) >= 0
5176 && INTVAL (operands[1]) < 32 * 8
5177 && (INTVAL (operands[1]) & 7) != 0))"
5178 [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1)))
5179 (set (match_dup 0) (mem:DI (plus:DI (match_dup 0) (match_dup 2))))]
5182 HOST_WIDE_INT val = INTVAL (operands[1]);
5185 operands[2] = GEN_INT (0);
5186 else if (val >= 32 * 8)
5190 operands[1] = GEN_INT (0x8 + off);
5191 operands[2] = GEN_INT (val - off - 0x8);
5197 operands[1] = GEN_INT (off);
5198 operands[2] = GEN_INT (val - off);
5202 ;; Handle input reloads in DImode.
5203 ;; This is mainly to handle reloading HILO_REGNUM. Note that we may
5204 ;; see it as the source or the destination, depending upon which way
5205 ;; reload handles the instruction.
5206 ;; Making the second operand TImode is a trick. The compiler may
5207 ;; reuse the same register for operand 0 and operand 2. Using TImode
5208 ;; gives us two registers, so we can always use the one which is not
5211 (define_expand "reload_indi"
5212 [(set (match_operand:DI 0 "register_operand" "=b")
5213 (match_operand:DI 1 "" "b"))
5214 (clobber (match_operand:TI 2 "register_operand" "=&d"))]
5218 rtx scratch = gen_rtx_REG (DImode,
5219 (REGNO (operands[0]) == REGNO (operands[2])
5220 ? REGNO (operands[2]) + 1
5221 : REGNO (operands[2])));
5223 if (GET_CODE (operands[0]) == REG && REGNO (operands[0]) == HILO_REGNUM)
5225 if (GET_CODE (operands[1]) == MEM)
5227 rtx memword, offword, hi_word, lo_word;
5228 rtx addr = find_replacement (&XEXP (operands[1], 0));
5229 rtx op1 = replace_equiv_address (operands[1], addr);
5231 scratch = gen_rtx_REG (SImode, REGNO (scratch));
5232 memword = adjust_address (op1, SImode, 0);
5233 offword = adjust_address (op1, SImode, 4);
5235 if (BYTES_BIG_ENDIAN)
5245 emit_move_insn (scratch, hi_word);
5246 emit_move_insn (gen_rtx_REG (SImode, 64), scratch);
5247 emit_move_insn (scratch, lo_word);
5248 emit_move_insn (gen_rtx (REG, SImode, 65), scratch);
5249 emit_insn (gen_hilo_delay (operands[0]));
5253 emit_insn (gen_ashrdi3 (scratch, operands[1], GEN_INT (32)));
5254 emit_insn (gen_movdi (gen_rtx_REG (DImode, 64), scratch));
5255 emit_insn (gen_ashldi3 (scratch, operands[1], GEN_INT (32)));
5256 emit_insn (gen_ashrdi3 (scratch, scratch, GEN_INT (32)));
5257 emit_insn (gen_movdi (gen_rtx (REG, DImode, 65), scratch));
5258 emit_insn (gen_hilo_delay (operands[0]));
5262 if (GET_CODE (operands[1]) == REG && REGNO (operands[1]) == HILO_REGNUM)
5264 emit_insn (gen_movdi (scratch, gen_rtx_REG (DImode, 65)));
5265 emit_insn (gen_ashldi3 (scratch, scratch, GEN_INT (32)));
5266 emit_insn (gen_lshrdi3 (scratch, scratch, GEN_INT (32)));
5267 emit_insn (gen_movdi (operands[0], gen_rtx_REG (DImode, 64)));
5268 emit_insn (gen_ashldi3 (operands[0], operands[0], GEN_INT (32)));
5269 emit_insn (gen_iordi3 (operands[0], operands[0], scratch));
5270 emit_insn (gen_hilo_delay (operands[1]));
5273 /* This handles moves between a float register and HI/LO. */
5274 emit_move_insn (scratch, operands[1]);
5275 emit_move_insn (operands[0], scratch);
5279 ;; Handle output reloads in DImode.
5281 ;; Reloading HILO_REG in MIPS16 mode requires two scratch registers, so we
5282 ;; use a TImode scratch reg.
5284 (define_expand "reload_outdi"
5285 [(set (match_operand:DI 0 "general_operand" "=b")
5286 (match_operand:DI 1 "register_operand" "b"))
5287 (clobber (match_operand:TI 2 "register_operand" "=&d"))]
5291 rtx scratch = gen_rtx_REG (DImode, REGNO (operands[2]));
5293 if (GET_CODE (operands[0]) == REG && REGNO (operands[0]) == HILO_REGNUM)
5295 emit_insn (gen_ashrdi3 (scratch, operands[1], GEN_INT (32)));
5296 emit_insn (gen_movdi (gen_rtx (REG, DImode, 64), scratch));
5297 emit_insn (gen_ashldi3 (scratch, operands[1], GEN_INT (32)));
5298 emit_insn (gen_ashrdi3 (scratch, scratch, GEN_INT (32)));
5299 emit_insn (gen_movdi (gen_rtx (REG, DImode, 65), scratch));
5300 emit_insn (gen_hilo_delay (operands[0]));
5303 if (GET_CODE (operands[1]) == REG && REGNO (operands[1]) == HILO_REGNUM)
5305 if (GET_CODE (operands[0]) == MEM)
5307 rtx scratch, memword, offword, hi_word, lo_word;
5308 rtx addr = find_replacement (&XEXP (operands[0], 0));
5309 rtx op0 = replace_equiv_address (operands[0], addr);
5311 scratch = gen_rtx_REG (SImode, REGNO (operands[2]));
5312 memword = adjust_address (op0, SImode, 0);
5313 offword = adjust_address (op0, SImode, 4);
5315 if (BYTES_BIG_ENDIAN)
5325 emit_move_insn (scratch, gen_rtx_REG (SImode, 64));
5326 emit_move_insn (hi_word, scratch);
5327 emit_move_insn (scratch, gen_rtx_REG (SImode, 65));
5328 emit_move_insn (lo_word, scratch);
5329 emit_insn (gen_hilo_delay (operands[1]));
5331 else if (TARGET_MIPS16 && ! M16_REG_P (REGNO (operands[0])))
5333 /* Handle the case where operand[0] is not a 'd' register,
5334 and hence we can not directly move from the HILO register
5336 rtx scratch2 = gen_rtx_REG (DImode, REGNO (operands[2]) + 1);
5337 emit_insn (gen_movdi (scratch, gen_rtx (REG, DImode, 65)));
5338 emit_insn (gen_ashldi3 (scratch, scratch, GEN_INT (32)));
5339 emit_insn (gen_lshrdi3 (scratch, scratch, GEN_INT (32)));
5340 emit_insn (gen_movdi (scratch2, gen_rtx (REG, DImode, 64)));
5341 emit_insn (gen_ashldi3 (scratch2, scratch2, GEN_INT (32)));
5342 emit_insn (gen_iordi3 (scratch, scratch, scratch2));
5343 emit_insn (gen_movdi (operands[0], scratch));
5344 emit_insn (gen_hilo_delay (operands[1]));
5348 emit_insn (gen_movdi (scratch, gen_rtx (REG, DImode, 65)));
5349 emit_insn (gen_ashldi3 (scratch, scratch, GEN_INT (32)));
5350 emit_insn (gen_lshrdi3 (scratch, scratch, GEN_INT (32)));
5351 emit_insn (gen_movdi (operands[0], gen_rtx (REG, DImode, 64)));
5352 emit_insn (gen_ashldi3 (operands[0], operands[0], GEN_INT (32)));
5353 emit_insn (gen_iordi3 (operands[0], operands[0], scratch));
5354 emit_insn (gen_hilo_delay (operands[1]));
5358 /* This handles moves between a float register and HI/LO. */
5359 emit_move_insn (scratch, operands[1]);
5360 emit_move_insn (operands[0], scratch);
5364 ;; 32-bit Integer moves
5366 ;; Unlike most other insns, the move insns can't be split with
5367 ;; different predicates, because register spilling and other parts of
5368 ;; the compiler, have memoized the insn number already.
5370 (define_expand "movsi"
5371 [(set (match_operand:SI 0 "nonimmediate_operand" "")
5372 (match_operand:SI 1 "" ""))]
5376 if (mips_legitimize_move (SImode, operands[0], operands[1]))
5379 /* If we are generating embedded PIC code, and we are referring to a
5380 symbol in the .text section, we must use an offset from the start
5382 if (TARGET_EMBEDDED_PIC
5383 && (GET_CODE (operands[1]) == LABEL_REF
5384 || (GET_CODE (operands[1]) == SYMBOL_REF
5385 && ! SYMBOL_REF_FLAG (operands[1]))))
5389 temp = embedded_pic_offset (operands[1]);
5390 temp = gen_rtx_PLUS (Pmode, embedded_pic_fnaddr_reg (),
5391 force_reg (SImode, temp));
5392 emit_move_insn (operands[0], force_reg (SImode, temp));
5397 ;; We can only store $ra directly into a small sp offset. Should the
5398 ;; offset be too wide, non-constant or not sp-based, leave it up to
5399 ;; reload to choose a scratch register.
5402 [(set (mem:SI (plus:SI (reg:SI 29)
5403 (match_operand:SI 0 "small_int" "n")))
5407 [(set_attr "type" "store")
5408 (set_attr "mode" "SI")
5409 (set_attr_alternative
5412 (lt (symbol_ref "(unsigned HOST_WIDE_INT) INTVAL (operands[0])")
5417 ;; The difference between these two is whether or not ints are allowed
5418 ;; in FP registers (off by default, use -mdebugh to enable).
5420 (define_insn "movsi_internal"
5421 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,e,d,m,*f,*f,*f,*d,*m,*d,*z,*x,*d,*x,*d,*B*C*D,*B*C*D,*d,*m")
5422 (match_operand:SI 1 "move_operand" "d,U,T,m,dJ,*f,*d*J,*m,*f,*f,*z,*d,J,*x,*d,*a,*d,*m,*B*C*D,*B*C*D"))]
5424 && (register_operand (operands[0], SImode)
5425 || register_operand (operands[1], SImode)
5426 || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
5427 { return mips_output_move (operands[0], operands[1]); }
5428 [(set_attr "type" "move,const,const,load,store,move,xfer,load,xfer,store,xfer,xfer,hilo,hilo,hilo,hilo,xfer,load,xfer,store")
5429 (set_attr "mode" "SI")
5430 (set_attr "length" "4,*,*,*,*,4,4,*,4,*,4,4,4,4,4,4,4,*,4,*")])
5433 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,y,d,d,d,d,d,m,*d,*d")
5434 (match_operand:SI 1 "move_operand" "d,d,y,K,N,U,m,d,*x,*a"))]
5436 && (register_operand (operands[0], SImode)
5437 || register_operand (operands[1], SImode))"
5438 { return mips_output_move (operands[0], operands[1]); }
5439 [(set_attr "type" "move,move,move,arith,arith,const,load,store,hilo,hilo")
5440 (set_attr "mode" "SI")
5441 (set_attr_alternative "length"
5445 (if_then_else (match_operand:VOID 1 "m16_uimm8_1" "")
5448 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1" "")
5457 ;; On the mips16, we can split lw $r,N($r) into an add and a load,
5458 ;; when the original load is a 4 byte instruction but the add and the
5459 ;; load are 2 2 byte instructions.
5462 [(set (match_operand:SI 0 "register_operand" "")
5463 (mem:SI (plus:SI (match_dup 0)
5464 (match_operand:SI 1 "const_int_operand" ""))))]
5465 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
5466 && GET_CODE (operands[0]) == REG
5467 && M16_REG_P (REGNO (operands[0]))
5468 && GET_CODE (operands[1]) == CONST_INT
5469 && ((INTVAL (operands[1]) < 0
5470 && INTVAL (operands[1]) >= -0x80)
5471 || (INTVAL (operands[1]) >= 32 * 4
5472 && INTVAL (operands[1]) <= 31 * 4 + 0x7c)
5473 || (INTVAL (operands[1]) >= 0
5474 && INTVAL (operands[1]) < 32 * 4
5475 && (INTVAL (operands[1]) & 3) != 0))"
5476 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
5477 (set (match_dup 0) (mem:SI (plus:SI (match_dup 0) (match_dup 2))))]
5480 HOST_WIDE_INT val = INTVAL (operands[1]);
5483 operands[2] = GEN_INT (0);
5484 else if (val >= 32 * 4)
5488 operands[1] = GEN_INT (0x7c + off);
5489 operands[2] = GEN_INT (val - off - 0x7c);
5495 operands[1] = GEN_INT (off);
5496 operands[2] = GEN_INT (val - off);
5500 ;; On the mips16, we can split a load of certain constants into a load
5501 ;; and an add. This turns a 4 byte instruction into 2 2 byte
5505 [(set (match_operand:SI 0 "register_operand" "")
5506 (match_operand:SI 1 "const_int_operand" ""))]
5507 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
5508 && GET_CODE (operands[0]) == REG
5509 && M16_REG_P (REGNO (operands[0]))
5510 && GET_CODE (operands[1]) == CONST_INT
5511 && INTVAL (operands[1]) >= 0x100
5512 && INTVAL (operands[1]) <= 0xff + 0x7f"
5513 [(set (match_dup 0) (match_dup 1))
5514 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]
5517 int val = INTVAL (operands[1]);
5519 operands[1] = GEN_INT (0xff);
5520 operands[2] = GEN_INT (val - 0xff);
5523 ;; On the mips16, we can split a load of a negative constant into a
5524 ;; load and a neg. That's what mips_output_move will generate anyhow.
5527 [(set (match_operand:SI 0 "register_operand" "")
5528 (match_operand:SI 1 "const_int_operand" ""))]
5529 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
5530 && GET_CODE (operands[0]) == REG
5531 && M16_REG_P (REGNO (operands[0]))
5532 && GET_CODE (operands[1]) == CONST_INT
5533 && INTVAL (operands[1]) < 0
5534 && INTVAL (operands[1]) > - 0x8000"
5535 [(set (match_dup 0) (match_dup 1))
5536 (set (match_dup 0) (neg:SI (match_dup 0)))]
5539 operands[1] = GEN_INT (- INTVAL (operands[1]));
5542 ;; Reload HILO_REGNUM in SI mode. This needs a scratch register in
5543 ;; order to set the sign bit correctly in the HI register.
5545 (define_expand "reload_outsi"
5546 [(set (match_operand:SI 0 "general_operand" "=b")
5547 (match_operand:SI 1 "register_operand" "b"))
5548 (clobber (match_operand:SI 2 "register_operand" "=&d"))]
5549 "TARGET_64BIT || TARGET_MIPS16"
5553 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) == HILO_REGNUM)
5555 emit_insn (gen_movsi (gen_rtx_REG (SImode, 65), operands[1]));
5556 emit_insn (gen_ashrsi3 (operands[2], operands[1], GEN_INT (31)));
5557 emit_insn (gen_movsi (gen_rtx (REG, SImode, 64), operands[2]));
5558 emit_insn (gen_hilo_delay (operands[0]));
5561 /* Use a mult to reload LO on mips16. ??? This is hideous. */
5563 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) == LO_REGNUM)
5565 emit_insn (gen_movsi (operands[2], GEN_INT (1)));
5566 /* This is gen_mulsi3_internal, but we need to fill in the
5567 scratch registers. */
5568 emit_insn (gen_rtx (PARALLEL, VOIDmode,
5570 gen_rtx (SET, VOIDmode,
5572 gen_rtx (MULT, SImode,
5575 gen_rtx (CLOBBER, VOIDmode,
5576 gen_rtx (REG, SImode, 64)),
5577 gen_rtx (CLOBBER, VOIDmode,
5578 gen_rtx (REG, SImode, 66)))));
5581 /* FIXME: I don't know how to get a value into the HI register. */
5582 if (GET_CODE (operands[0]) == REG
5583 && (TARGET_MIPS16 ? M16_REG_P (REGNO (operands[0]))
5584 : GP_REG_P (REGNO (operands[0]))))
5586 emit_move_insn (operands[0], operands[1]);
5589 /* This handles moves between a float register and HI/LO. */
5590 emit_move_insn (operands[2], operands[1]);
5591 emit_move_insn (operands[0], operands[2]);
5595 ;; Reload a value into HI or LO. There is no mthi or mtlo on mips16,
5596 ;; so we use a mult. ??? This is hideous, and we ought to figure out
5597 ;; something better.
5599 ;; We use no predicate for operand1, because it may be a PLUS, and there
5600 ;; is no convenient predicate for that.
5602 (define_expand "reload_insi"
5603 [(set (match_operand:SI 0 "register_operand" "=b")
5604 (match_operand:SI 1 "" "b"))
5605 (clobber (match_operand:SI 2 "register_operand" "=&d"))]
5610 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) == LO_REGNUM)
5612 emit_insn (gen_movsi (operands[2], GEN_INT (1)));
5613 /* This is gen_mulsi3_internal, but we need to fill in the
5614 scratch registers. */
5615 emit_insn (gen_rtx (PARALLEL, VOIDmode,
5617 gen_rtx (SET, VOIDmode,
5619 gen_rtx (MULT, SImode,
5622 gen_rtx (CLOBBER, VOIDmode,
5623 gen_rtx (REG, SImode, 64)),
5624 gen_rtx (CLOBBER, VOIDmode,
5625 gen_rtx (REG, SImode, 66)))));
5629 /* If this is a plus, then this must be an add of the stack pointer against
5630 either a hard register or a pseudo. */
5631 if (TARGET_MIPS16 && GET_CODE (operands[1]) == PLUS)
5635 if (XEXP (operands[1], 0) == stack_pointer_rtx)
5636 plus_op = XEXP (operands[1], 1);
5637 else if (XEXP (operands[1], 1) == stack_pointer_rtx)
5638 plus_op = XEXP (operands[1], 0);
5642 /* We should have a register now. */
5643 if (GET_CODE (plus_op) != REG)
5646 if (REGNO (plus_op) < FIRST_PSEUDO_REGISTER)
5648 /* We have to have at least one temporary register which is not
5649 overlapping plus_op. */
5650 if (! rtx_equal_p (plus_op, operands[0]))
5652 emit_move_insn (operands[0], stack_pointer_rtx);
5653 emit_insn (gen_addsi3 (operands[0], operands[0], plus_op));
5655 else if (! rtx_equal_p (plus_op, operands[2]))
5657 emit_move_insn (operands[2], stack_pointer_rtx);
5658 emit_insn (gen_addsi3 (operands[0], plus_op, operands[2]));
5665 /* We need two registers in this case. */
5666 if (! rtx_equal_p (operands[0], operands[2]))
5668 emit_move_insn (operands[0], stack_pointer_rtx);
5669 emit_move_insn (operands[2], plus_op);
5670 emit_insn (gen_addsi3 (operands[0], operands[0], operands[2]));
5678 /* FIXME: I don't know how to get a value into the HI register. */
5679 emit_move_insn (operands[0], operands[1]);
5683 ;; This insn is for the unspec delay for HILO.
5685 (define_insn "hilo_delay"
5686 [(unspec [(match_operand 0 "register_operand" "=b")] UNSPEC_HILO_DELAY)]
5689 [(set_attr "type" "nop")
5690 (set_attr "mode" "none")
5691 (set_attr "can_delay" "no")])
5693 ;; This insn handles moving CCmode values. It's really just a
5694 ;; slightly simplified copy of movsi_internal2, with additional cases
5695 ;; to move a condition register to a general register and to move
5696 ;; between the general registers and the floating point registers.
5698 (define_insn "movcc"
5699 [(set (match_operand:CC 0 "nonimmediate_operand" "=d,*d,*d,*m,*d,*f,*f,*f,*m")
5700 (match_operand:CC 1 "general_operand" "z,*d,*m,*d,*f,*d,*f,*m,*f"))]
5701 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
5702 { return mips_output_move (operands[0], operands[1]); }
5703 [(set_attr "type" "move,move,load,store,xfer,xfer,move,load,store")
5704 (set_attr "mode" "SI")
5705 (set_attr "length" "8,4,*,*,4,4,4,*,*")])
5707 ;; Reload condition code registers. reload_incc and reload_outcc
5708 ;; both handle moves from arbitrary operands into condition code
5709 ;; registers. reload_incc handles the more common case in which
5710 ;; a source operand is constrained to be in a condition-code
5711 ;; register, but has not been allocated to one.
5713 ;; Sometimes, such as in movcc, we have a CCmode destination whose
5714 ;; constraints do not include 'z'. reload_outcc handles the case
5715 ;; when such an operand is allocated to a condition-code register.
5717 ;; Note that reloads from a condition code register to some
5718 ;; other location can be done using ordinary moves. Moving
5719 ;; into a GPR takes a single movcc, moving elsewhere takes
5720 ;; two. We can leave these cases to the generic reload code.
5721 (define_expand "reload_incc"
5722 [(set (match_operand:CC 0 "fcc_register_operand" "=z")
5723 (match_operand:CC 1 "general_operand" ""))
5724 (clobber (match_operand:TF 2 "register_operand" "=&f"))]
5725 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
5728 mips_emit_fcc_reload (operands[0], operands[1], operands[2]);
5732 (define_expand "reload_outcc"
5733 [(set (match_operand:CC 0 "fcc_register_operand" "=z")
5734 (match_operand:CC 1 "register_operand" ""))
5735 (clobber (match_operand:TF 2 "register_operand" "=&f"))]
5736 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
5739 mips_emit_fcc_reload (operands[0], operands[1], operands[2]);
5743 ;; MIPS4 supports loading and storing a floating point register from
5744 ;; the sum of two general registers. We use two versions for each of
5745 ;; these four instructions: one where the two general registers are
5746 ;; SImode, and one where they are DImode. This is because general
5747 ;; registers will be in SImode when they hold 32 bit values, but,
5748 ;; since the 32 bit values are always sign extended, the [ls][wd]xc1
5749 ;; instructions will still work correctly.
5751 ;; ??? Perhaps it would be better to support these instructions by
5752 ;; modifying GO_IF_LEGITIMATE_ADDRESS and friends. However, since
5753 ;; these instructions can only be used to load and store floating
5754 ;; point registers, that would probably cause trouble in reload.
5757 [(set (match_operand:SF 0 "register_operand" "=f")
5758 (mem:SF (plus:SI (match_operand:SI 1 "register_operand" "d")
5759 (match_operand:SI 2 "register_operand" "d"))))]
5760 "ISA_HAS_FP4 && TARGET_HARD_FLOAT"
5762 [(set_attr "type" "load")
5763 (set_attr "mode" "SF")
5764 (set_attr "length" "4")])
5767 [(set (match_operand:SF 0 "register_operand" "=f")
5768 (mem:SF (plus:DI (match_operand:DI 1 "register_operand" "d")
5769 (match_operand:DI 2 "register_operand" "d"))))]
5770 "ISA_HAS_FP4 && TARGET_HARD_FLOAT"
5772 [(set_attr "type" "load")
5773 (set_attr "mode" "SF")
5774 (set_attr "length" "4")])
5777 [(set (match_operand:DF 0 "register_operand" "=f")
5778 (mem:DF (plus:SI (match_operand:SI 1 "register_operand" "d")
5779 (match_operand:SI 2 "register_operand" "d"))))]
5780 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
5782 [(set_attr "type" "load")
5783 (set_attr "mode" "DF")
5784 (set_attr "length" "4")])
5787 [(set (match_operand:DF 0 "register_operand" "=f")
5788 (mem:DF (plus:DI (match_operand:DI 1 "register_operand" "d")
5789 (match_operand:DI 2 "register_operand" "d"))))]
5790 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
5792 [(set_attr "type" "load")
5793 (set_attr "mode" "DF")
5794 (set_attr "length" "4")])
5797 [(set (mem:SF (plus:SI (match_operand:SI 1 "register_operand" "d")
5798 (match_operand:SI 2 "register_operand" "d")))
5799 (match_operand:SF 0 "register_operand" "f"))]
5800 "ISA_HAS_FP4 && TARGET_HARD_FLOAT"
5802 [(set_attr "type" "store")
5803 (set_attr "mode" "SF")
5804 (set_attr "length" "4")])
5807 [(set (mem:SF (plus:DI (match_operand:DI 1 "register_operand" "d")
5808 (match_operand:DI 2 "register_operand" "d")))
5809 (match_operand:SF 0 "register_operand" "f"))]
5810 "ISA_HAS_FP4 && TARGET_HARD_FLOAT"
5812 [(set_attr "type" "store")
5813 (set_attr "mode" "SF")
5814 (set_attr "length" "4")])
5817 [(set (mem:DF (plus:SI (match_operand:SI 1 "register_operand" "d")
5818 (match_operand:SI 2 "register_operand" "d")))
5819 (match_operand:DF 0 "register_operand" "f"))]
5820 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
5822 [(set_attr "type" "store")
5823 (set_attr "mode" "DF")
5824 (set_attr "length" "4")])
5827 [(set (mem:DF (plus:DI (match_operand:DI 1 "register_operand" "d")
5828 (match_operand:DI 2 "register_operand" "d")))
5829 (match_operand:DF 0 "register_operand" "f"))]
5830 "ISA_HAS_FP4 && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
5832 [(set_attr "type" "store")
5833 (set_attr "mode" "DF")
5834 (set_attr "length" "4")])
5836 ;; 16-bit Integer moves
5838 ;; Unlike most other insns, the move insns can't be split with
5839 ;; different predicates, because register spilling and other parts of
5840 ;; the compiler, have memoized the insn number already.
5841 ;; Unsigned loads are used because BYTE_LOADS_ZERO_EXTEND is defined
5843 (define_expand "movhi"
5844 [(set (match_operand:HI 0 "nonimmediate_operand" "")
5845 (match_operand:HI 1 "general_operand" ""))]
5849 if ((reload_in_progress | reload_completed) == 0
5850 && !register_operand (operands[0], HImode)
5851 && !register_operand (operands[1], HImode)
5853 || (GET_CODE (operands[1]) != CONST_INT
5854 || INTVAL (operands[1]) != 0)))
5856 rtx temp = force_reg (HImode, operands[1]);
5857 emit_move_insn (operands[0], temp);
5862 ;; The difference between these two is whether or not ints are allowed
5863 ;; in FP registers (off by default, use -mdebugh to enable).
5865 (define_insn "movhi_internal"
5866 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,m,*d,*f,*f,*x,*d")
5867 (match_operand:HI 1 "general_operand" "d,IK,m,dJ,*f,*d,*f,*d,*x"))]
5869 && (register_operand (operands[0], HImode)
5870 || register_operand (operands[1], HImode)
5871 || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
5882 [(set_attr "type" "move,arith,load,store,xfer,xfer,move,hilo,hilo")
5883 (set_attr "mode" "HI")
5884 (set_attr "length" "4,4,*,*,4,4,4,4,4")])
5887 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m,*d")
5888 (match_operand:HI 1 "general_operand" "d,d,y,K,N,m,d,*x"))]
5890 && (register_operand (operands[0], HImode)
5891 || register_operand (operands[1], HImode))"
5901 [(set_attr "type" "move,move,move,arith,arith,load,store,hilo")
5902 (set_attr "mode" "HI")
5903 (set_attr_alternative "length"
5907 (if_then_else (match_operand:VOID 1 "m16_uimm8_1" "")
5910 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1" "")
5918 ;; On the mips16, we can split lh $r,N($r) into an add and a load,
5919 ;; when the original load is a 4 byte instruction but the add and the
5920 ;; load are 2 2 byte instructions.
5923 [(set (match_operand:HI 0 "register_operand" "")
5924 (mem:HI (plus:SI (match_dup 0)
5925 (match_operand:SI 1 "const_int_operand" ""))))]
5926 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
5927 && GET_CODE (operands[0]) == REG
5928 && M16_REG_P (REGNO (operands[0]))
5929 && GET_CODE (operands[1]) == CONST_INT
5930 && ((INTVAL (operands[1]) < 0
5931 && INTVAL (operands[1]) >= -0x80)
5932 || (INTVAL (operands[1]) >= 32 * 2
5933 && INTVAL (operands[1]) <= 31 * 2 + 0x7e)
5934 || (INTVAL (operands[1]) >= 0
5935 && INTVAL (operands[1]) < 32 * 2
5936 && (INTVAL (operands[1]) & 1) != 0))"
5937 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
5938 (set (match_dup 0) (mem:HI (plus:SI (match_dup 0) (match_dup 2))))]
5941 HOST_WIDE_INT val = INTVAL (operands[1]);
5944 operands[2] = GEN_INT (0);
5945 else if (val >= 32 * 2)
5949 operands[1] = GEN_INT (0x7e + off);
5950 operands[2] = GEN_INT (val - off - 0x7e);
5956 operands[1] = GEN_INT (off);
5957 operands[2] = GEN_INT (val - off);
5961 ;; 8-bit Integer moves
5963 ;; Unlike most other insns, the move insns can't be split with
5964 ;; different predicates, because register spilling and other parts of
5965 ;; the compiler, have memoized the insn number already.
5966 ;; Unsigned loads are used because BYTE_LOADS_ZERO_EXTEND is defined
5968 (define_expand "movqi"
5969 [(set (match_operand:QI 0 "nonimmediate_operand" "")
5970 (match_operand:QI 1 "general_operand" ""))]
5974 if ((reload_in_progress | reload_completed) == 0
5975 && !register_operand (operands[0], QImode)
5976 && !register_operand (operands[1], QImode)
5978 || (GET_CODE (operands[1]) != CONST_INT
5979 || INTVAL (operands[1]) != 0)))
5981 rtx temp = force_reg (QImode, operands[1]);
5982 emit_move_insn (operands[0], temp);
5987 ;; The difference between these two is whether or not ints are allowed
5988 ;; in FP registers (off by default, use -mdebugh to enable).
5990 (define_insn "movqi_internal"
5991 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,m,*d,*f,*f,*x,*d")
5992 (match_operand:QI 1 "general_operand" "d,IK,m,dJ,*f,*d,*f,*d,*x"))]
5994 && (register_operand (operands[0], QImode)
5995 || register_operand (operands[1], QImode)
5996 || (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))"
6007 [(set_attr "type" "move,arith,load,store,xfer,xfer,move,hilo,hilo")
6008 (set_attr "mode" "QI")
6009 (set_attr "length" "4,4,*,*,4,4,4,4,4")])
6012 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m,*d")
6013 (match_operand:QI 1 "general_operand" "d,d,y,K,N,m,d,*x"))]
6015 && (register_operand (operands[0], QImode)
6016 || register_operand (operands[1], QImode))"
6026 [(set_attr "type" "move,move,move,arith,arith,load,store,hilo")
6027 (set_attr "mode" "QI")
6028 (set_attr "length" "4,4,4,4,8,*,*,4")])
6030 ;; On the mips16, we can split lb $r,N($r) into an add and a load,
6031 ;; when the original load is a 4 byte instruction but the add and the
6032 ;; load are 2 2 byte instructions.
6035 [(set (match_operand:QI 0 "register_operand" "")
6036 (mem:QI (plus:SI (match_dup 0)
6037 (match_operand:SI 1 "const_int_operand" ""))))]
6038 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
6039 && GET_CODE (operands[0]) == REG
6040 && M16_REG_P (REGNO (operands[0]))
6041 && GET_CODE (operands[1]) == CONST_INT
6042 && ((INTVAL (operands[1]) < 0
6043 && INTVAL (operands[1]) >= -0x80)
6044 || (INTVAL (operands[1]) >= 32
6045 && INTVAL (operands[1]) <= 31 + 0x7f))"
6046 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
6047 (set (match_dup 0) (mem:QI (plus:SI (match_dup 0) (match_dup 2))))]
6050 HOST_WIDE_INT val = INTVAL (operands[1]);
6053 operands[2] = GEN_INT (0);
6056 operands[1] = GEN_INT (0x7f);
6057 operands[2] = GEN_INT (val - 0x7f);
6061 ;; 32-bit floating point moves
6063 (define_expand "movsf"
6064 [(set (match_operand:SF 0 "nonimmediate_operand" "")
6065 (match_operand:SF 1 "general_operand" ""))]
6069 if ((reload_in_progress | reload_completed) == 0
6070 && !register_operand (operands[0], SFmode)
6071 && !nonmemory_operand (operands[1], SFmode))
6072 operands[1] = force_reg (SFmode, operands[1]);
6075 (define_insn "movsf_internal1"
6076 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,f,m,*f,*d,*d,*d,*m")
6077 (match_operand:SF 1 "general_operand" "f,G,m,fG,*d,*f,*G*d,*m,*d"))]
6079 && (register_operand (operands[0], SFmode)
6080 || nonmemory_operand (operands[1], SFmode))"
6081 { return mips_output_move (operands[0], operands[1]); }
6082 [(set_attr "type" "move,xfer,load,store,xfer,xfer,move,load,store")
6083 (set_attr "mode" "SF")
6084 (set_attr "length" "4,4,*,*,4,4,4,*,*")])
6086 (define_insn "movsf_internal2"
6087 [(set (match_operand:SF 0 "nonimmediate_operand" "=d,d,m")
6088 (match_operand:SF 1 "general_operand" " Gd,m,d"))]
6089 "TARGET_SOFT_FLOAT && !TARGET_MIPS16
6090 && (register_operand (operands[0], SFmode)
6091 || nonmemory_operand (operands[1], SFmode))"
6092 { return mips_output_move (operands[0], operands[1]); }
6093 [(set_attr "type" "move,load,store")
6094 (set_attr "mode" "SF")
6095 (set_attr "length" "4,*,*")])
6098 [(set (match_operand:SF 0 "nonimmediate_operand" "=d,y,d,d,m")
6099 (match_operand:SF 1 "nonimmediate_operand" "d,d,y,m,d"))]
6101 && (register_operand (operands[0], SFmode)
6102 || register_operand (operands[1], SFmode))"
6103 { return mips_output_move (operands[0], operands[1]); }
6104 [(set_attr "type" "move,move,move,load,store")
6105 (set_attr "mode" "SF")
6106 (set_attr "length" "4,4,4,*,*")])
6109 ;; 64-bit floating point moves
6111 (define_expand "movdf"
6112 [(set (match_operand:DF 0 "nonimmediate_operand" "")
6113 (match_operand:DF 1 "general_operand" ""))]
6117 if ((reload_in_progress | reload_completed) == 0
6118 && !register_operand (operands[0], DFmode)
6119 && !nonmemory_operand (operands[1], DFmode))
6120 operands[1] = force_reg (DFmode, operands[1]);
6123 (define_insn "movdf_internal1a"
6124 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,m,*f,*d,*d,*d,*m")
6125 (match_operand:DF 1 "general_operand" "f,G,m,fG,*d,*f,*d*G,*m,*d"))]
6126 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_64BIT
6127 && (register_operand (operands[0], DFmode)
6128 || nonmemory_operand (operands[1], DFmode))"
6129 { return mips_output_move (operands[0], operands[1]); }
6130 [(set_attr "type" "move,xfer,load,store,xfer,xfer,move,load,store")
6131 (set_attr "mode" "DF")
6132 (set_attr "length" "4,4,*,*,4,4,4,*,*")])
6134 (define_insn "movdf_internal1b"
6135 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,m,*f,*d,*d,*d,*m")
6136 (match_operand:DF 1 "general_operand" "f,G,m,fG,*d,*f,*d*G,*m,*d"))]
6137 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT
6138 && (register_operand (operands[0], DFmode)
6139 || nonmemory_operand (operands[1], DFmode))"
6140 { return mips_output_move (operands[0], operands[1]); }
6141 [(set_attr "type" "move,xfer,load,store,xfer,xfer,move,load,store")
6142 (set_attr "mode" "DF")
6143 (set_attr "length" "4,8,*,*,8,8,8,*,*")])
6145 (define_insn "movdf_internal2"
6146 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,m,d,f,f")
6147 (match_operand:DF 1 "general_operand" "dG,m,dG,f,d,f"))]
6148 "(TARGET_SOFT_FLOAT || TARGET_SINGLE_FLOAT) && !TARGET_MIPS16
6149 && (register_operand (operands[0], DFmode)
6150 || nonmemory_operand (operands[1], DFmode))"
6151 { return mips_output_move (operands[0], operands[1]); }
6152 [(set_attr "type" "move,load,store,xfer,xfer,move")
6153 (set_attr "mode" "DF")
6154 (set_attr "length" "8,*,*,4,4,4")])
6157 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,y,d,d,m")
6158 (match_operand:DF 1 "nonimmediate_operand" "d,d,y,m,d"))]
6160 && (register_operand (operands[0], DFmode)
6161 || register_operand (operands[1], DFmode))"
6162 { return mips_output_move (operands[0], operands[1]); }
6163 [(set_attr "type" "move,move,move,load,store")
6164 (set_attr "mode" "DF")
6165 (set_attr "length" "8,8,8,*,*")])
6168 [(set (match_operand:DI 0 "nonimmediate_operand" "")
6169 (match_operand:DI 1 "general_operand" ""))]
6170 "reload_completed && !TARGET_64BIT
6171 && mips_split_64bit_move_p (operands[0], operands[1])"
6174 mips_split_64bit_move (operands[0], operands[1]);
6179 [(set (match_operand:DF 0 "nonimmediate_operand" "")
6180 (match_operand:DF 1 "general_operand" ""))]
6181 "reload_completed && !TARGET_64BIT
6182 && mips_split_64bit_move_p (operands[0], operands[1])"
6185 mips_split_64bit_move (operands[0], operands[1]);
6189 ;; Patterns for loading or storing part of a paired floating point
6190 ;; register. We need them because odd-numbered floating-point registers
6191 ;; are not fully independent: see mips_split_64bit_move.
6193 ;; Load the low word of operand 0 with operand 1.
6194 (define_insn "load_df_low"
6195 [(set (match_operand:DF 0 "register_operand" "=f,f")
6196 (unspec:DF [(match_operand:SI 1 "general_operand" "dJ,m")]
6197 UNSPEC_LOAD_DF_LOW))]
6198 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT"
6200 operands[0] = mips_subword (operands[0], 0);
6201 return mips_output_move (operands[0], operands[1]);
6203 [(set_attr "type" "xfer,load")
6204 (set_attr "mode" "SF")
6205 (set_attr "length" "4")])
6207 ;; Load the high word of operand 0 from operand 1, preserving the value
6209 (define_insn "load_df_high"
6210 [(set (match_operand:DF 0 "register_operand" "=f,f")
6211 (unspec:DF [(match_operand:SI 1 "general_operand" "dJ,m")
6212 (match_operand:DF 2 "register_operand" "0,0")]
6213 UNSPEC_LOAD_DF_HIGH))]
6214 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT"
6216 operands[0] = mips_subword (operands[0], 1);
6217 return mips_output_move (operands[0], operands[1]);
6219 [(set_attr "type" "xfer,load")
6220 (set_attr "mode" "SF")
6221 (set_attr "length" "4")])
6223 ;; Store the high word of operand 1 in operand 0. The corresponding
6224 ;; low-word move is done in the normal way.
6225 (define_insn "store_df_high"
6226 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,m")
6227 (unspec:SI [(match_operand:DF 1 "register_operand" "f,f")]
6228 UNSPEC_STORE_DF_HIGH))]
6229 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT"
6231 operands[1] = mips_subword (operands[1], 1);
6232 return mips_output_move (operands[0], operands[1]);
6234 [(set_attr "type" "xfer,store")
6235 (set_attr "mode" "SF")
6236 (set_attr "length" "4")])
6238 ;; Instructions to load the global pointer register.
6239 ;; This is volatile to make sure that the scheduler won't move any symbol_ref
6240 ;; uses in front of it. All symbol_refs implicitly use the gp reg.
6242 (define_insn "loadgp"
6244 (unspec_volatile:DI [(match_operand 0 "immediate_operand" "")
6245 (match_operand:DI 1 "register_operand" "")]
6247 (clobber (reg:DI 1))]
6249 "%[lui\\t$1,%%hi(%%neg(%%gp_rel(%0)))\\n\\taddiu\\t$1,$1,%%lo(%%neg(%%gp_rel(%0)))\\n\\tdaddu\\t$gp,$1,%1%]"
6250 [(set_attr "type" "move")
6251 (set_attr "mode" "DI")
6252 (set_attr "length" "12")])
6254 ;; Block moves, see mips.c for more details.
6255 ;; Argument 0 is the destination
6256 ;; Argument 1 is the source
6257 ;; Argument 2 is the length
6258 ;; Argument 3 is the alignment
6260 (define_expand "movstrsi"
6261 [(parallel [(set (match_operand:BLK 0 "general_operand" "")
6262 (match_operand:BLK 1 "general_operand" ""))
6263 (use (match_operand:SI 2 "arith32_operand" ""))
6264 (use (match_operand:SI 3 "immediate_operand" ""))])]
6268 if (operands[0]) /* avoid unused code messages */
6270 expand_block_move (operands);
6275 ;; Insn generated by block moves
6277 (define_insn "movstrsi_internal"
6278 [(set (match_operand:BLK 0 "memory_operand" "=o") ;; destination
6279 (match_operand:BLK 1 "memory_operand" "o")) ;; source
6280 (clobber (match_scratch:SI 4 "=&d")) ;; temp 1
6281 (clobber (match_scratch:SI 5 "=&d")) ;; temp 2
6282 (clobber (match_scratch:SI 6 "=&d")) ;; temp 3
6283 (clobber (match_scratch:SI 7 "=&d")) ;; temp 4
6284 (use (match_operand:SI 2 "small_int" "I")) ;; # bytes to move
6285 (use (match_operand:SI 3 "small_int" "I")) ;; alignment
6286 (use (const_int 0))] ;; normal block move
6288 "* return output_block_move (insn, operands, 4, BLOCK_MOVE_NORMAL);"
6289 [(set_attr "type" "store")
6290 (set_attr "mode" "none")
6291 (set_attr "length" "80")])
6293 ;; We need mips16 versions, because an offset from the stack pointer
6294 ;; is not offsettable, since the stack pointer can only handle 4 and 8
6298 [(set (match_operand:BLK 0 "memory_operand" "=o") ;; destination
6299 (match_operand:BLK 1 "memory_operand" "o")) ;; source
6300 (clobber (match_scratch:SI 4 "=&d")) ;; temp 1
6301 (clobber (match_scratch:SI 5 "=&d")) ;; temp 2
6302 (clobber (match_scratch:SI 6 "=&d")) ;; temp 3
6303 (clobber (match_scratch:SI 7 "=&d")) ;; temp 4
6304 (use (match_operand:SI 2 "small_int" "I")) ;; # bytes to move
6305 (use (match_operand:SI 3 "small_int" "I")) ;; alignment
6306 (use (const_int 0))] ;; normal block move
6308 "* return output_block_move (insn, operands, 4, BLOCK_MOVE_NORMAL);"
6309 [(set_attr "type" "multi")
6310 (set_attr "mode" "none")
6311 (set_attr "length" "80")])
6313 ;; Split a block move into 2 parts, the first part is everything
6314 ;; except for the last move, and the second part is just the last
6315 ;; store, which is exactly 1 instruction (ie, not a usw), so it can
6316 ;; fill a delay slot. This also prevents a bug in delayed branches
6317 ;; from showing up, which reuses one of the registers in our clobbers.
6319 ;; ??? Disabled because it doesn't preserve alias information for
6320 ;; operands 0 and 1. Also, the rtl for the second insn doesn't mention
6321 ;; that it uses the registers clobbered by the first.
6323 ;; It would probably be better to split the block into individual
6324 ;; instructions instead.
6326 [(set (mem:BLK (match_operand:SI 0 "register_operand" ""))
6327 (mem:BLK (match_operand:SI 1 "register_operand" "")))
6328 (clobber (match_operand:SI 4 "register_operand" ""))
6329 (clobber (match_operand:SI 5 "register_operand" ""))
6330 (clobber (match_operand:SI 6 "register_operand" ""))
6331 (clobber (match_operand:SI 7 "register_operand" ""))
6332 (use (match_operand:SI 2 "small_int" ""))
6333 (use (match_operand:SI 3 "small_int" ""))
6334 (use (const_int 0))]
6336 "reload_completed && 0 && INTVAL (operands[2]) > 0"
6338 ;; All but the last move
6339 [(parallel [(set (mem:BLK (match_dup 0))
6340 (mem:BLK (match_dup 1)))
6341 (clobber (match_dup 4))
6342 (clobber (match_dup 5))
6343 (clobber (match_dup 6))
6344 (clobber (match_dup 7))
6347 (use (const_int 1))])
6349 ;; The last store, so it can fill a delay slot
6350 (parallel [(set (mem:BLK (match_dup 0))
6351 (mem:BLK (match_dup 1)))
6352 (clobber (match_dup 4))
6353 (clobber (match_dup 5))
6354 (clobber (match_dup 6))
6355 (clobber (match_dup 7))
6358 (use (const_int 2))])]
6362 (define_insn "movstrsi_internal2"
6363 [(set (match_operand:BLK 0 "memory_operand" "=o") ;; destination
6364 (match_operand:BLK 1 "memory_operand" "o")) ;; source
6365 (clobber (match_scratch:SI 4 "=&d")) ;; temp 1
6366 (clobber (match_scratch:SI 5 "=&d")) ;; temp 2
6367 (clobber (match_scratch:SI 6 "=&d")) ;; temp 3
6368 (clobber (match_scratch:SI 7 "=&d")) ;; temp 4
6369 (use (match_operand:SI 2 "small_int" "I")) ;; # bytes to move
6370 (use (match_operand:SI 3 "small_int" "I")) ;; alignment
6371 (use (const_int 1))] ;; all but last store
6373 "* return output_block_move (insn, operands, 4, BLOCK_MOVE_NOT_LAST);"
6374 [(set_attr "type" "store")
6375 (set_attr "mode" "none")
6376 (set_attr "length" "80")])
6379 [(set (match_operand:BLK 0 "memory_operand" "=o") ;; destination
6380 (match_operand:BLK 1 "memory_operand" "o")) ;; source
6381 (clobber (match_scratch:SI 4 "=&d")) ;; temp 1
6382 (clobber (match_scratch:SI 5 "=&d")) ;; temp 2
6383 (clobber (match_scratch:SI 6 "=&d")) ;; temp 3
6384 (clobber (match_scratch:SI 7 "=&d")) ;; temp 4
6385 (use (match_operand:SI 2 "small_int" "I")) ;; # bytes to move
6386 (use (match_operand:SI 3 "small_int" "I")) ;; alignment
6387 (use (const_int 1))] ;; all but last store
6389 "* return output_block_move (insn, operands, 4, BLOCK_MOVE_NOT_LAST);"
6390 [(set_attr "type" "multi")
6391 (set_attr "mode" "none")
6392 (set_attr "length" "80")])
6394 (define_insn "movstrsi_internal3"
6395 [(set (match_operand:BLK 0 "memory_operand" "=m") ;; destination
6396 (match_operand:BLK 1 "memory_operand" "m")) ;; source
6397 (clobber (match_scratch:SI 4 "=&d")) ;; temp 1
6398 (clobber (match_scratch:SI 5 "=&d")) ;; temp 2
6399 (clobber (match_scratch:SI 6 "=&d")) ;; temp 3
6400 (clobber (match_scratch:SI 7 "=&d")) ;; temp 4
6401 (use (match_operand:SI 2 "small_int" "I")) ;; # bytes to move
6402 (use (match_operand:SI 3 "small_int" "I")) ;; alignment
6403 (use (const_int 2))] ;; just last store of block move
6405 "* return output_block_move (insn, operands, 4, BLOCK_MOVE_LAST);"
6406 [(set_attr "type" "store")
6407 (set_attr "mode" "none")])
6410 ;; ....................
6414 ;; ....................
6416 ;; Many of these instructions uses trivial define_expands, because we
6417 ;; want to use a different set of constraints when TARGET_MIPS16.
6419 (define_expand "ashlsi3"
6420 [(set (match_operand:SI 0 "register_operand" "=d")
6421 (ashift:SI (match_operand:SI 1 "register_operand" "d")
6422 (match_operand:SI 2 "arith_operand" "dI")))]
6426 /* On the mips16, a shift of more than 8 is a four byte instruction,
6427 so, for a shift between 8 and 16, it is just as fast to do two
6428 shifts of 8 or less. If there is a lot of shifting going on, we
6429 may win in CSE. Otherwise combine will put the shifts back
6430 together again. This can be called by function_arg, so we must
6431 be careful not to allocate a new register if we've reached the
6435 && GET_CODE (operands[2]) == CONST_INT
6436 && INTVAL (operands[2]) > 8
6437 && INTVAL (operands[2]) <= 16
6438 && ! reload_in_progress
6439 && ! reload_completed)
6441 rtx temp = gen_reg_rtx (SImode);
6443 emit_insn (gen_ashlsi3_internal2 (temp, operands[1], GEN_INT (8)));
6444 emit_insn (gen_ashlsi3_internal2 (operands[0], temp,
6445 GEN_INT (INTVAL (operands[2]) - 8)));
6450 (define_insn "ashlsi3_internal1"
6451 [(set (match_operand:SI 0 "register_operand" "=d")
6452 (ashift:SI (match_operand:SI 1 "register_operand" "d")
6453 (match_operand:SI 2 "arith_operand" "dI")))]
6457 if (GET_CODE (operands[2]) == CONST_INT)
6458 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
6460 return \"sll\\t%0,%1,%2\";
6462 [(set_attr "type" "arith")
6463 (set_attr "mode" "SI")])
6465 (define_insn "ashlsi3_internal1_extend"
6466 [(set (match_operand:DI 0 "register_operand" "=d")
6467 (sign_extend:DI (ashift:SI (match_operand:SI 1 "register_operand" "d")
6468 (match_operand:SI 2 "arith_operand" "dI"))))]
6469 "TARGET_64BIT && !TARGET_MIPS16"
6472 if (GET_CODE (operands[2]) == CONST_INT)
6473 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
6475 return \"sll\\t%0,%1,%2\";
6477 [(set_attr "type" "arith")
6478 (set_attr "mode" "DI")])
6481 (define_insn "ashlsi3_internal2"
6482 [(set (match_operand:SI 0 "register_operand" "=d,d")
6483 (ashift:SI (match_operand:SI 1 "register_operand" "0,d")
6484 (match_operand:SI 2 "arith_operand" "d,I")))]
6488 if (which_alternative == 0)
6489 return \"sll\\t%0,%2\";
6491 if (GET_CODE (operands[2]) == CONST_INT)
6492 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
6494 return \"sll\\t%0,%1,%2\";
6496 [(set_attr "type" "arith")
6497 (set_attr "mode" "SI")
6498 (set_attr_alternative "length"
6500 (if_then_else (match_operand:VOID 2 "m16_uimm3_b" "")
6504 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
6507 [(set (match_operand:SI 0 "register_operand" "")
6508 (ashift:SI (match_operand:SI 1 "register_operand" "")
6509 (match_operand:SI 2 "const_int_operand" "")))]
6510 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
6511 && GET_CODE (operands[2]) == CONST_INT
6512 && INTVAL (operands[2]) > 8
6513 && INTVAL (operands[2]) <= 16"
6514 [(set (match_dup 0) (ashift:SI (match_dup 1) (const_int 8)))
6515 (set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2)))]
6518 operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
6521 (define_expand "ashldi3"
6522 [(parallel [(set (match_operand:DI 0 "register_operand" "")
6523 (ashift:DI (match_operand:DI 1 "register_operand" "")
6524 (match_operand:SI 2 "arith_operand" "")))
6525 (clobber (match_dup 3))])]
6526 "TARGET_64BIT || (!TARGET_DEBUG_G_MODE && !TARGET_MIPS16)"
6531 /* On the mips16, a shift of more than 8 is a four byte
6532 instruction, so, for a shift between 8 and 16, it is just as
6533 fast to do two shifts of 8 or less. If there is a lot of
6534 shifting going on, we may win in CSE. Otherwise combine will
6535 put the shifts back together again. This can be called by
6536 function_arg, so we must be careful not to allocate a new
6537 register if we've reached the reload pass. */
6540 && GET_CODE (operands[2]) == CONST_INT
6541 && INTVAL (operands[2]) > 8
6542 && INTVAL (operands[2]) <= 16
6543 && ! reload_in_progress
6544 && ! reload_completed)
6546 rtx temp = gen_reg_rtx (DImode);
6548 emit_insn (gen_ashldi3_internal4 (temp, operands[1], GEN_INT (8)));
6549 emit_insn (gen_ashldi3_internal4 (operands[0], temp,
6550 GEN_INT (INTVAL (operands[2]) - 8)));
6554 emit_insn (gen_ashldi3_internal4 (operands[0], operands[1],
6559 operands[3] = gen_reg_rtx (SImode);
6563 (define_insn "ashldi3_internal"
6564 [(set (match_operand:DI 0 "register_operand" "=&d")
6565 (ashift:DI (match_operand:DI 1 "register_operand" "d")
6566 (match_operand:SI 2 "register_operand" "d")))
6567 (clobber (match_operand:SI 3 "register_operand" "=d"))]
6568 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16"
6571 operands[4] = const0_rtx;
6573 return \"sll\\t%3,%2,26\\n\\
6574 \\tbgez\\t%3,1f\\n\\
6575 \\tsll\\t%M0,%L1,%2\\n\\
6577 \\tmove\\t%L0,%z4%)\\n\\
6580 \\t%(beq\\t%3,%z4,2f\\n\\
6581 \\tsll\\t%M0,%M1,%2%)\\n\\
6583 \\tsubu\\t%3,%z4,%2\\n\\
6584 \\tsrl\\t%3,%L1,%3\\n\\
6585 \\tor\\t%M0,%M0,%3\\n\\
6587 \\tsll\\t%L0,%L1,%2\\n\\
6590 [(set_attr "type" "darith")
6591 (set_attr "mode" "SI")
6592 (set_attr "length" "48")])
6595 (define_insn "ashldi3_internal2"
6596 [(set (match_operand:DI 0 "register_operand" "=d")
6597 (ashift:DI (match_operand:DI 1 "register_operand" "d")
6598 (match_operand:SI 2 "small_int" "IJK")))
6599 (clobber (match_operand:SI 3 "register_operand" "=d"))]
6600 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
6601 && (INTVAL (operands[2]) & 32) != 0"
6604 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
6605 operands[4] = const0_rtx;
6606 return \"sll\\t%M0,%L1,%2\;move\\t%L0,%z4\";
6608 [(set_attr "type" "darith")
6609 (set_attr "mode" "DI")
6610 (set_attr "length" "8")])
6614 [(set (match_operand:DI 0 "register_operand" "")
6615 (ashift:DI (match_operand:DI 1 "register_operand" "")
6616 (match_operand:SI 2 "small_int" "")))
6617 (clobber (match_operand:SI 3 "register_operand" ""))]
6618 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
6619 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
6620 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
6621 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
6622 && (INTVAL (operands[2]) & 32) != 0"
6624 [(set (subreg:SI (match_dup 0) 4) (ashift:SI (subreg:SI (match_dup 1) 0) (match_dup 2)))
6625 (set (subreg:SI (match_dup 0) 0) (const_int 0))]
6627 "operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);")
6631 [(set (match_operand:DI 0 "register_operand" "")
6632 (ashift:DI (match_operand:DI 1 "register_operand" "")
6633 (match_operand:SI 2 "small_int" "")))
6634 (clobber (match_operand:SI 3 "register_operand" ""))]
6635 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
6636 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
6637 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
6638 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
6639 && (INTVAL (operands[2]) & 32) != 0"
6641 [(set (subreg:SI (match_dup 0) 0) (ashift:SI (subreg:SI (match_dup 1) 4) (match_dup 2)))
6642 (set (subreg:SI (match_dup 0) 4) (const_int 0))]
6644 "operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);")
6647 (define_insn "ashldi3_internal3"
6648 [(set (match_operand:DI 0 "register_operand" "=d")
6649 (ashift:DI (match_operand:DI 1 "register_operand" "d")
6650 (match_operand:SI 2 "small_int" "IJK")))
6651 (clobber (match_operand:SI 3 "register_operand" "=d"))]
6652 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
6653 && (INTVAL (operands[2]) & 63) < 32
6654 && (INTVAL (operands[2]) & 63) != 0"
6657 int amount = INTVAL (operands[2]);
6659 operands[2] = GEN_INT (amount & 31);
6660 operands[4] = const0_rtx;
6661 operands[5] = GEN_INT ((-amount) & 31);
6663 return \"sll\\t%M0,%M1,%2\;srl\\t%3,%L1,%5\;or\\t%M0,%M0,%3\;sll\\t%L0,%L1,%2\";
6665 [(set_attr "type" "darith")
6666 (set_attr "mode" "DI")
6667 (set_attr "length" "16")])
6671 [(set (match_operand:DI 0 "register_operand" "")
6672 (ashift:DI (match_operand:DI 1 "register_operand" "")
6673 (match_operand:SI 2 "small_int" "")))
6674 (clobber (match_operand:SI 3 "register_operand" ""))]
6675 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
6676 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
6677 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
6678 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
6679 && (INTVAL (operands[2]) & 63) < 32
6680 && (INTVAL (operands[2]) & 63) != 0"
6682 [(set (subreg:SI (match_dup 0) 4)
6683 (ashift:SI (subreg:SI (match_dup 1) 4)
6687 (lshiftrt:SI (subreg:SI (match_dup 1) 0)
6690 (set (subreg:SI (match_dup 0) 4)
6691 (ior:SI (subreg:SI (match_dup 0) 4)
6694 (set (subreg:SI (match_dup 0) 0)
6695 (ashift:SI (subreg:SI (match_dup 1) 0)
6699 int amount = INTVAL (operands[2]);
6700 operands[2] = GEN_INT (amount & 31);
6701 operands[4] = GEN_INT ((-amount) & 31);
6706 [(set (match_operand:DI 0 "register_operand" "")
6707 (ashift:DI (match_operand:DI 1 "register_operand" "")
6708 (match_operand:SI 2 "small_int" "")))
6709 (clobber (match_operand:SI 3 "register_operand" ""))]
6710 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
6711 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
6712 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
6713 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
6714 && (INTVAL (operands[2]) & 63) < 32
6715 && (INTVAL (operands[2]) & 63) != 0"
6717 [(set (subreg:SI (match_dup 0) 0)
6718 (ashift:SI (subreg:SI (match_dup 1) 0)
6722 (lshiftrt:SI (subreg:SI (match_dup 1) 4)
6725 (set (subreg:SI (match_dup 0) 0)
6726 (ior:SI (subreg:SI (match_dup 0) 0)
6729 (set (subreg:SI (match_dup 0) 4)
6730 (ashift:SI (subreg:SI (match_dup 1) 4)
6734 int amount = INTVAL (operands[2]);
6735 operands[2] = GEN_INT (amount & 31);
6736 operands[4] = GEN_INT ((-amount) & 31);
6740 (define_insn "ashldi3_internal4"
6741 [(set (match_operand:DI 0 "register_operand" "=d")
6742 (ashift:DI (match_operand:DI 1 "register_operand" "d")
6743 (match_operand:SI 2 "arith_operand" "dI")))]
6744 "TARGET_64BIT && !TARGET_MIPS16"
6747 if (GET_CODE (operands[2]) == CONST_INT)
6748 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
6750 return \"dsll\\t%0,%1,%2\";
6752 [(set_attr "type" "arith")
6753 (set_attr "mode" "DI")])
6756 [(set (match_operand:DI 0 "register_operand" "=d,d")
6757 (ashift:DI (match_operand:DI 1 "register_operand" "0,d")
6758 (match_operand:SI 2 "arith_operand" "d,I")))]
6759 "TARGET_64BIT && TARGET_MIPS16"
6762 if (which_alternative == 0)
6763 return \"dsll\\t%0,%2\";
6765 if (GET_CODE (operands[2]) == CONST_INT)
6766 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
6768 return \"dsll\\t%0,%1,%2\";
6770 [(set_attr "type" "arith")
6771 (set_attr "mode" "DI")
6772 (set_attr_alternative "length"
6774 (if_then_else (match_operand:VOID 2 "m16_uimm3_b" "")
6779 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
6782 [(set (match_operand:DI 0 "register_operand" "")
6783 (ashift:DI (match_operand:DI 1 "register_operand" "")
6784 (match_operand:SI 2 "const_int_operand" "")))]
6785 "TARGET_MIPS16 && TARGET_64BIT && !TARGET_DEBUG_D_MODE
6787 && GET_CODE (operands[2]) == CONST_INT
6788 && INTVAL (operands[2]) > 8
6789 && INTVAL (operands[2]) <= 16"
6790 [(set (match_dup 0) (ashift:DI (match_dup 1) (const_int 8)))
6791 (set (match_dup 0) (ashift:DI (match_dup 0) (match_dup 2)))]
6794 operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
6797 (define_expand "ashrsi3"
6798 [(set (match_operand:SI 0 "register_operand" "=d")
6799 (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
6800 (match_operand:SI 2 "arith_operand" "dI")))]
6804 /* On the mips16, a shift of more than 8 is a four byte instruction,
6805 so, for a shift between 8 and 16, it is just as fast to do two
6806 shifts of 8 or less. If there is a lot of shifting going on, we
6807 may win in CSE. Otherwise combine will put the shifts back
6811 && GET_CODE (operands[2]) == CONST_INT
6812 && INTVAL (operands[2]) > 8
6813 && INTVAL (operands[2]) <= 16)
6815 rtx temp = gen_reg_rtx (SImode);
6817 emit_insn (gen_ashrsi3_internal2 (temp, operands[1], GEN_INT (8)));
6818 emit_insn (gen_ashrsi3_internal2 (operands[0], temp,
6819 GEN_INT (INTVAL (operands[2]) - 8)));
6824 (define_insn "ashrsi3_internal1"
6825 [(set (match_operand:SI 0 "register_operand" "=d")
6826 (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
6827 (match_operand:SI 2 "arith_operand" "dI")))]
6831 if (GET_CODE (operands[2]) == CONST_INT)
6832 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
6834 return \"sra\\t%0,%1,%2\";
6836 [(set_attr "type" "arith")
6837 (set_attr "mode" "SI")])
6839 (define_insn "ashrsi3_internal2"
6840 [(set (match_operand:SI 0 "register_operand" "=d,d")
6841 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0,d")
6842 (match_operand:SI 2 "arith_operand" "d,I")))]
6846 if (which_alternative == 0)
6847 return \"sra\\t%0,%2\";
6849 if (GET_CODE (operands[2]) == CONST_INT)
6850 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
6852 return \"sra\\t%0,%1,%2\";
6854 [(set_attr "type" "arith")
6855 (set_attr "mode" "SI")
6856 (set_attr_alternative "length"
6858 (if_then_else (match_operand:VOID 2 "m16_uimm3_b" "")
6863 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
6866 [(set (match_operand:SI 0 "register_operand" "")
6867 (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
6868 (match_operand:SI 2 "const_int_operand" "")))]
6869 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
6870 && GET_CODE (operands[2]) == CONST_INT
6871 && INTVAL (operands[2]) > 8
6872 && INTVAL (operands[2]) <= 16"
6873 [(set (match_dup 0) (ashiftrt:SI (match_dup 1) (const_int 8)))
6874 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (match_dup 2)))]
6877 operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
6880 (define_expand "ashrdi3"
6881 [(parallel [(set (match_operand:DI 0 "register_operand" "")
6882 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
6883 (match_operand:SI 2 "arith_operand" "")))
6884 (clobber (match_dup 3))])]
6885 "TARGET_64BIT || (!TARGET_DEBUG_G_MODE && !TARGET_MIPS16)"
6890 /* On the mips16, a shift of more than 8 is a four byte
6891 instruction, so, for a shift between 8 and 16, it is just as
6892 fast to do two shifts of 8 or less. If there is a lot of
6893 shifting going on, we may win in CSE. Otherwise combine will
6894 put the shifts back together again. */
6897 && GET_CODE (operands[2]) == CONST_INT
6898 && INTVAL (operands[2]) > 8
6899 && INTVAL (operands[2]) <= 16)
6901 rtx temp = gen_reg_rtx (DImode);
6903 emit_insn (gen_ashrdi3_internal4 (temp, operands[1], GEN_INT (8)));
6904 emit_insn (gen_ashrdi3_internal4 (operands[0], temp,
6905 GEN_INT (INTVAL (operands[2]) - 8)));
6909 emit_insn (gen_ashrdi3_internal4 (operands[0], operands[1],
6914 operands[3] = gen_reg_rtx (SImode);
6918 (define_insn "ashrdi3_internal"
6919 [(set (match_operand:DI 0 "register_operand" "=&d")
6920 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
6921 (match_operand:SI 2 "register_operand" "d")))
6922 (clobber (match_operand:SI 3 "register_operand" "=d"))]
6923 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16"
6926 operands[4] = const0_rtx;
6928 return \"sll\\t%3,%2,26\\n\\
6929 \\tbgez\\t%3,1f\\n\\
6930 \\tsra\\t%L0,%M1,%2\\n\\
6932 \\tsra\\t%M0,%M1,31%)\\n\\
6935 \\t%(beq\\t%3,%z4,2f\\n\\
6936 \\tsrl\\t%L0,%L1,%2%)\\n\\
6938 \\tsubu\\t%3,%z4,%2\\n\\
6939 \\tsll\\t%3,%M1,%3\\n\\
6940 \\tor\\t%L0,%L0,%3\\n\\
6942 \\tsra\\t%M0,%M1,%2\\n\\
6945 [(set_attr "type" "darith")
6946 (set_attr "mode" "DI")
6947 (set_attr "length" "48")])
6950 (define_insn "ashrdi3_internal2"
6951 [(set (match_operand:DI 0 "register_operand" "=d")
6952 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
6953 (match_operand:SI 2 "small_int" "IJK")))
6954 (clobber (match_operand:SI 3 "register_operand" "=d"))]
6955 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && (INTVAL (operands[2]) & 32) != 0"
6958 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
6959 return \"sra\\t%L0,%M1,%2\;sra\\t%M0,%M1,31\";
6961 [(set_attr "type" "darith")
6962 (set_attr "mode" "DI")
6963 (set_attr "length" "8")])
6967 [(set (match_operand:DI 0 "register_operand" "")
6968 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
6969 (match_operand:SI 2 "small_int" "")))
6970 (clobber (match_operand:SI 3 "register_operand" ""))]
6971 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
6972 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
6973 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
6974 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
6975 && (INTVAL (operands[2]) & 32) != 0"
6977 [(set (subreg:SI (match_dup 0) 0) (ashiftrt:SI (subreg:SI (match_dup 1) 4) (match_dup 2)))
6978 (set (subreg:SI (match_dup 0) 4) (ashiftrt:SI (subreg:SI (match_dup 1) 4) (const_int 31)))]
6980 "operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);")
6984 [(set (match_operand:DI 0 "register_operand" "")
6985 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
6986 (match_operand:SI 2 "small_int" "")))
6987 (clobber (match_operand:SI 3 "register_operand" ""))]
6988 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
6989 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE
6990 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
6991 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
6992 && (INTVAL (operands[2]) & 32) != 0"
6994 [(set (subreg:SI (match_dup 0) 4) (ashiftrt:SI (subreg:SI (match_dup 1) 0) (match_dup 2)))
6995 (set (subreg:SI (match_dup 0) 0) (ashiftrt:SI (subreg:SI (match_dup 1) 0) (const_int 31)))]
6997 "operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);")
7000 (define_insn "ashrdi3_internal3"
7001 [(set (match_operand:DI 0 "register_operand" "=d")
7002 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
7003 (match_operand:SI 2 "small_int" "IJK")))
7004 (clobber (match_operand:SI 3 "register_operand" "=d"))]
7005 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
7006 && (INTVAL (operands[2]) & 63) < 32
7007 && (INTVAL (operands[2]) & 63) != 0"
7010 int amount = INTVAL (operands[2]);
7012 operands[2] = GEN_INT (amount & 31);
7013 operands[4] = GEN_INT ((-amount) & 31);
7015 return \"srl\\t%L0,%L1,%2\;sll\\t%3,%M1,%4\;or\\t%L0,%L0,%3\;sra\\t%M0,%M1,%2\";
7017 [(set_attr "type" "darith")
7018 (set_attr "mode" "DI")
7019 (set_attr "length" "16")])
7023 [(set (match_operand:DI 0 "register_operand" "")
7024 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
7025 (match_operand:SI 2 "small_int" "")))
7026 (clobber (match_operand:SI 3 "register_operand" ""))]
7027 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
7028 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
7029 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
7030 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
7031 && (INTVAL (operands[2]) & 63) < 32
7032 && (INTVAL (operands[2]) & 63) != 0"
7034 [(set (subreg:SI (match_dup 0) 0)
7035 (lshiftrt:SI (subreg:SI (match_dup 1) 0)
7039 (ashift:SI (subreg:SI (match_dup 1) 4)
7042 (set (subreg:SI (match_dup 0) 0)
7043 (ior:SI (subreg:SI (match_dup 0) 0)
7046 (set (subreg:SI (match_dup 0) 4)
7047 (ashiftrt:SI (subreg:SI (match_dup 1) 4)
7051 int amount = INTVAL (operands[2]);
7052 operands[2] = GEN_INT (amount & 31);
7053 operands[4] = GEN_INT ((-amount) & 31);
7058 [(set (match_operand:DI 0 "register_operand" "")
7059 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
7060 (match_operand:SI 2 "small_int" "")))
7061 (clobber (match_operand:SI 3 "register_operand" ""))]
7062 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
7063 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
7064 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
7065 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
7066 && (INTVAL (operands[2]) & 63) < 32
7067 && (INTVAL (operands[2]) & 63) != 0"
7069 [(set (subreg:SI (match_dup 0) 4)
7070 (lshiftrt:SI (subreg:SI (match_dup 1) 4)
7074 (ashift:SI (subreg:SI (match_dup 1) 0)
7077 (set (subreg:SI (match_dup 0) 4)
7078 (ior:SI (subreg:SI (match_dup 0) 4)
7081 (set (subreg:SI (match_dup 0) 0)
7082 (ashiftrt:SI (subreg:SI (match_dup 1) 0)
7086 int amount = INTVAL (operands[2]);
7087 operands[2] = GEN_INT (amount & 31);
7088 operands[4] = GEN_INT ((-amount) & 31);
7092 (define_insn "ashrdi3_internal4"
7093 [(set (match_operand:DI 0 "register_operand" "=d")
7094 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
7095 (match_operand:SI 2 "arith_operand" "dI")))]
7096 "TARGET_64BIT && !TARGET_MIPS16"
7099 if (GET_CODE (operands[2]) == CONST_INT)
7100 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
7102 return \"dsra\\t%0,%1,%2\";
7104 [(set_attr "type" "arith")
7105 (set_attr "mode" "DI")])
7108 [(set (match_operand:DI 0 "register_operand" "=d,d")
7109 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0,0")
7110 (match_operand:SI 2 "arith_operand" "d,I")))]
7111 "TARGET_64BIT && TARGET_MIPS16"
7114 if (GET_CODE (operands[2]) == CONST_INT)
7115 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
7117 return \"dsra\\t%0,%2\";
7119 [(set_attr "type" "arith")
7120 (set_attr "mode" "DI")
7121 (set_attr_alternative "length"
7123 (if_then_else (match_operand:VOID 2 "m16_uimm3_b" "")
7127 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
7130 [(set (match_operand:DI 0 "register_operand" "")
7131 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
7132 (match_operand:SI 2 "const_int_operand" "")))]
7133 "TARGET_MIPS16 && TARGET_64BIT && !TARGET_DEBUG_D_MODE
7135 && GET_CODE (operands[2]) == CONST_INT
7136 && INTVAL (operands[2]) > 8
7137 && INTVAL (operands[2]) <= 16"
7138 [(set (match_dup 0) (ashiftrt:DI (match_dup 1) (const_int 8)))
7139 (set (match_dup 0) (ashiftrt:DI (match_dup 0) (match_dup 2)))]
7142 operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
7145 (define_expand "lshrsi3"
7146 [(set (match_operand:SI 0 "register_operand" "=d")
7147 (lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
7148 (match_operand:SI 2 "arith_operand" "dI")))]
7152 /* On the mips16, a shift of more than 8 is a four byte instruction,
7153 so, for a shift between 8 and 16, it is just as fast to do two
7154 shifts of 8 or less. If there is a lot of shifting going on, we
7155 may win in CSE. Otherwise combine will put the shifts back
7159 && GET_CODE (operands[2]) == CONST_INT
7160 && INTVAL (operands[2]) > 8
7161 && INTVAL (operands[2]) <= 16)
7163 rtx temp = gen_reg_rtx (SImode);
7165 emit_insn (gen_lshrsi3_internal2 (temp, operands[1], GEN_INT (8)));
7166 emit_insn (gen_lshrsi3_internal2 (operands[0], temp,
7167 GEN_INT (INTVAL (operands[2]) - 8)));
7172 (define_insn "lshrsi3_internal1"
7173 [(set (match_operand:SI 0 "register_operand" "=d")
7174 (lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
7175 (match_operand:SI 2 "arith_operand" "dI")))]
7179 if (GET_CODE (operands[2]) == CONST_INT)
7180 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
7182 return \"srl\\t%0,%1,%2\";
7184 [(set_attr "type" "arith")
7185 (set_attr "mode" "SI")])
7187 (define_insn "lshrsi3_internal2"
7188 [(set (match_operand:SI 0 "register_operand" "=d,d")
7189 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0,d")
7190 (match_operand:SI 2 "arith_operand" "d,I")))]
7194 if (which_alternative == 0)
7195 return \"srl\\t%0,%2\";
7197 if (GET_CODE (operands[2]) == CONST_INT)
7198 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
7200 return \"srl\\t%0,%1,%2\";
7202 [(set_attr "type" "arith")
7203 (set_attr "mode" "SI")
7204 (set_attr_alternative "length"
7206 (if_then_else (match_operand:VOID 2 "m16_uimm3_b" "")
7211 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
7214 [(set (match_operand:SI 0 "register_operand" "")
7215 (lshiftrt:SI (match_operand:SI 1 "register_operand" "")
7216 (match_operand:SI 2 "const_int_operand" "")))]
7217 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
7218 && GET_CODE (operands[2]) == CONST_INT
7219 && INTVAL (operands[2]) > 8
7220 && INTVAL (operands[2]) <= 16"
7221 [(set (match_dup 0) (lshiftrt:SI (match_dup 1) (const_int 8)))
7222 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
7225 operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
7228 ;; If we load a byte on the mips16 as a bitfield, the resulting
7229 ;; sequence of instructions is too complicated for combine, because it
7230 ;; involves four instructions: a load, a shift, a constant load into a
7231 ;; register, and an and (the key problem here is that the mips16 does
7232 ;; not have and immediate). We recognize a shift of a load in order
7233 ;; to make it simple enough for combine to understand.
7235 ;; ??? FIXME: turn into a define_insn_and_split
7237 [(set (match_operand:SI 0 "register_operand" "=d")
7238 (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
7239 (match_operand:SI 2 "immediate_operand" "I")))]
7240 "0 && TARGET_MIPS16"
7241 "lw\\t%0,%1\;srl\\t%0,%2"
7242 [(set_attr "type" "load")
7243 (set_attr "mode" "SI")
7244 (set_attr_alternative "length"
7245 [(if_then_else (match_operand:VOID 2 "m16_uimm3_b" "")
7250 [(set (match_operand:SI 0 "register_operand" "")
7251 (lshiftrt:SI (match_operand:SI 1 "memory_operand" "")
7252 (match_operand:SI 2 "immediate_operand" "")))]
7253 "TARGET_MIPS16 && !TARGET_DEBUG_D_MODE"
7254 [(set (match_dup 0) (match_dup 1))
7255 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
7258 (define_expand "lshrdi3"
7259 [(parallel [(set (match_operand:DI 0 "register_operand" "")
7260 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
7261 (match_operand:SI 2 "arith_operand" "")))
7262 (clobber (match_dup 3))])]
7263 "TARGET_64BIT || (!TARGET_DEBUG_G_MODE && !TARGET_MIPS16)"
7268 /* On the mips16, a shift of more than 8 is a four byte
7269 instruction, so, for a shift between 8 and 16, it is just as
7270 fast to do two shifts of 8 or less. If there is a lot of
7271 shifting going on, we may win in CSE. Otherwise combine will
7272 put the shifts back together again. */
7275 && GET_CODE (operands[2]) == CONST_INT
7276 && INTVAL (operands[2]) > 8
7277 && INTVAL (operands[2]) <= 16)
7279 rtx temp = gen_reg_rtx (DImode);
7281 emit_insn (gen_lshrdi3_internal4 (temp, operands[1], GEN_INT (8)));
7282 emit_insn (gen_lshrdi3_internal4 (operands[0], temp,
7283 GEN_INT (INTVAL (operands[2]) - 8)));
7287 emit_insn (gen_lshrdi3_internal4 (operands[0], operands[1],
7292 operands[3] = gen_reg_rtx (SImode);
7296 (define_insn "lshrdi3_internal"
7297 [(set (match_operand:DI 0 "register_operand" "=&d")
7298 (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
7299 (match_operand:SI 2 "register_operand" "d")))
7300 (clobber (match_operand:SI 3 "register_operand" "=d"))]
7301 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16"
7304 operands[4] = const0_rtx;
7306 return \"sll\\t%3,%2,26\\n\\
7307 \\tbgez\\t%3,1f\\n\\
7308 \\tsrl\\t%L0,%M1,%2\\n\\
7310 \\tmove\\t%M0,%z4%)\\n\\
7313 \\t%(beq\\t%3,%z4,2f\\n\\
7314 \\tsrl\\t%L0,%L1,%2%)\\n\\
7316 \\tsubu\\t%3,%z4,%2\\n\\
7317 \\tsll\\t%3,%M1,%3\\n\\
7318 \\tor\\t%L0,%L0,%3\\n\\
7320 \\tsrl\\t%M0,%M1,%2\\n\\
7323 [(set_attr "type" "darith")
7324 (set_attr "mode" "DI")
7325 (set_attr "length" "48")])
7328 (define_insn "lshrdi3_internal2"
7329 [(set (match_operand:DI 0 "register_operand" "=d")
7330 (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
7331 (match_operand:SI 2 "small_int" "IJK")))
7332 (clobber (match_operand:SI 3 "register_operand" "=d"))]
7333 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
7334 && (INTVAL (operands[2]) & 32) != 0"
7337 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
7338 operands[4] = const0_rtx;
7339 return \"srl\\t%L0,%M1,%2\;move\\t%M0,%z4\";
7341 [(set_attr "type" "darith")
7342 (set_attr "mode" "DI")
7343 (set_attr "length" "8")])
7347 [(set (match_operand:DI 0 "register_operand" "")
7348 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
7349 (match_operand:SI 2 "small_int" "")))
7350 (clobber (match_operand:SI 3 "register_operand" ""))]
7351 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
7352 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
7353 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
7354 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
7355 && (INTVAL (operands[2]) & 32) != 0"
7357 [(set (subreg:SI (match_dup 0) 0) (lshiftrt:SI (subreg:SI (match_dup 1) 4) (match_dup 2)))
7358 (set (subreg:SI (match_dup 0) 4) (const_int 0))]
7360 "operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);")
7364 [(set (match_operand:DI 0 "register_operand" "")
7365 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
7366 (match_operand:SI 2 "small_int" "")))
7367 (clobber (match_operand:SI 3 "register_operand" ""))]
7368 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
7369 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
7370 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
7371 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
7372 && (INTVAL (operands[2]) & 32) != 0"
7374 [(set (subreg:SI (match_dup 0) 4) (lshiftrt:SI (subreg:SI (match_dup 1) 0) (match_dup 2)))
7375 (set (subreg:SI (match_dup 0) 0) (const_int 0))]
7377 "operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);")
7380 (define_insn "lshrdi3_internal3"
7381 [(set (match_operand:DI 0 "register_operand" "=d")
7382 (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
7383 (match_operand:SI 2 "small_int" "IJK")))
7384 (clobber (match_operand:SI 3 "register_operand" "=d"))]
7385 "!TARGET_64BIT && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
7386 && (INTVAL (operands[2]) & 63) < 32
7387 && (INTVAL (operands[2]) & 63) != 0"
7390 int amount = INTVAL (operands[2]);
7392 operands[2] = GEN_INT (amount & 31);
7393 operands[4] = GEN_INT ((-amount) & 31);
7395 return \"srl\\t%L0,%L1,%2\;sll\\t%3,%M1,%4\;or\\t%L0,%L0,%3\;srl\\t%M0,%M1,%2\";
7397 [(set_attr "type" "darith")
7398 (set_attr "mode" "DI")
7399 (set_attr "length" "16")])
7403 [(set (match_operand:DI 0 "register_operand" "")
7404 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
7405 (match_operand:SI 2 "small_int" "")))
7406 (clobber (match_operand:SI 3 "register_operand" ""))]
7407 "reload_completed && !WORDS_BIG_ENDIAN && !TARGET_64BIT
7408 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
7409 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
7410 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
7411 && (INTVAL (operands[2]) & 63) < 32
7412 && (INTVAL (operands[2]) & 63) != 0"
7414 [(set (subreg:SI (match_dup 0) 0)
7415 (lshiftrt:SI (subreg:SI (match_dup 1) 0)
7419 (ashift:SI (subreg:SI (match_dup 1) 4)
7422 (set (subreg:SI (match_dup 0) 0)
7423 (ior:SI (subreg:SI (match_dup 0) 0)
7426 (set (subreg:SI (match_dup 0) 4)
7427 (lshiftrt:SI (subreg:SI (match_dup 1) 4)
7431 int amount = INTVAL (operands[2]);
7432 operands[2] = GEN_INT (amount & 31);
7433 operands[4] = GEN_INT ((-amount) & 31);
7438 [(set (match_operand:DI 0 "register_operand" "")
7439 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
7440 (match_operand:SI 2 "small_int" "")))
7441 (clobber (match_operand:SI 3 "register_operand" ""))]
7442 "reload_completed && WORDS_BIG_ENDIAN && !TARGET_64BIT
7443 && !TARGET_DEBUG_D_MODE && !TARGET_DEBUG_G_MODE && !TARGET_MIPS16
7444 && GET_CODE (operands[0]) == REG && REGNO (operands[0]) < FIRST_PSEUDO_REGISTER
7445 && GET_CODE (operands[1]) == REG && REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
7446 && (INTVAL (operands[2]) & 63) < 32
7447 && (INTVAL (operands[2]) & 63) != 0"
7449 [(set (subreg:SI (match_dup 0) 4)
7450 (lshiftrt:SI (subreg:SI (match_dup 1) 4)
7454 (ashift:SI (subreg:SI (match_dup 1) 0)
7457 (set (subreg:SI (match_dup 0) 4)
7458 (ior:SI (subreg:SI (match_dup 0) 4)
7461 (set (subreg:SI (match_dup 0) 0)
7462 (lshiftrt:SI (subreg:SI (match_dup 1) 0)
7466 int amount = INTVAL (operands[2]);
7467 operands[2] = GEN_INT (amount & 31);
7468 operands[4] = GEN_INT ((-amount) & 31);
7472 (define_insn "lshrdi3_internal4"
7473 [(set (match_operand:DI 0 "register_operand" "=d")
7474 (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
7475 (match_operand:SI 2 "arith_operand" "dI")))]
7476 "TARGET_64BIT && !TARGET_MIPS16"
7479 if (GET_CODE (operands[2]) == CONST_INT)
7480 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
7482 return \"dsrl\\t%0,%1,%2\";
7484 [(set_attr "type" "arith")
7485 (set_attr "mode" "DI")])
7488 [(set (match_operand:DI 0 "register_operand" "=d,d")
7489 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0,0")
7490 (match_operand:SI 2 "arith_operand" "d,I")))]
7491 "TARGET_64BIT && TARGET_MIPS16"
7494 if (GET_CODE (operands[2]) == CONST_INT)
7495 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
7497 return \"dsrl\\t%0,%2\";
7499 [(set_attr "type" "arith")
7500 (set_attr "mode" "DI")
7501 (set_attr_alternative "length"
7503 (if_then_else (match_operand:VOID 2 "m16_uimm3_b" "")
7507 (define_insn "rotrsi3"
7508 [(set (match_operand:SI 0 "register_operand" "=d")
7509 (rotatert:SI (match_operand:SI 1 "register_operand" "d")
7510 (match_operand:SI 2 "arith_operand" "dn")))]
7514 if (TARGET_SR71K && GET_CODE (operands[2]) != CONST_INT)
7515 return \"rorv\\t%0,%1,%2\";
7517 if ((GET_CODE (operands[2]) == CONST_INT)
7518 && (INTVAL (operands[2]) < 0 || INTVAL (operands[2]) >= 32))
7521 return \"ror\\t%0,%1,%2\";
7523 [(set_attr "type" "arith")
7524 (set_attr "mode" "SI")])
7526 (define_insn "rotrdi3"
7527 [(set (match_operand:DI 0 "register_operand" "=d")
7528 (rotatert:DI (match_operand:DI 1 "register_operand" "d")
7529 (match_operand:DI 2 "arith_operand" "dn")))]
7535 if (GET_CODE (operands[2]) != CONST_INT)
7536 return \"drorv\\t%0,%1,%2\";
7538 if (INTVAL (operands[2]) >= 32 && INTVAL (operands[2]) <= 63)
7539 return \"dror32\\t%0,%1,%2\";
7542 if ((GET_CODE (operands[2]) == CONST_INT)
7543 && (INTVAL (operands[2]) < 0 || INTVAL (operands[2]) >= 64))
7546 return \"dror\\t%0,%1,%2\";
7548 [(set_attr "type" "arith")
7549 (set_attr "mode" "DI")])
7552 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
7555 [(set (match_operand:DI 0 "register_operand" "")
7556 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
7557 (match_operand:SI 2 "const_int_operand" "")))]
7558 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
7559 && GET_CODE (operands[2]) == CONST_INT
7560 && INTVAL (operands[2]) > 8
7561 && INTVAL (operands[2]) <= 16"
7562 [(set (match_dup 0) (lshiftrt:DI (match_dup 1) (const_int 8)))
7563 (set (match_dup 0) (lshiftrt:DI (match_dup 0) (match_dup 2)))]
7566 operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
7571 ;; ....................
7575 ;; ....................
7577 ;; Flow here is rather complex:
7579 ;; 1) The cmp{si,di,sf,df} routine is called. It deposits the
7580 ;; arguments into the branch_cmp array, and the type into
7581 ;; branch_type. No RTL is generated.
7583 ;; 2) The appropriate branch define_expand is called, which then
7584 ;; creates the appropriate RTL for the comparison and branch.
7585 ;; Different CC modes are used, based on what type of branch is
7586 ;; done, so that we can constrain things appropriately. There
7587 ;; are assumptions in the rest of GCC that break if we fold the
7588 ;; operands into the branchs for integer operations, and use cc0
7589 ;; for floating point, so we use the fp status register instead.
7590 ;; If needed, an appropriate temporary is created to hold the
7591 ;; of the integer compare.
7593 (define_expand "cmpsi"
7595 (compare:CC (match_operand:SI 0 "register_operand" "")
7596 (match_operand:SI 1 "arith_operand" "")))]
7600 if (operands[0]) /* avoid unused code message */
7602 branch_cmp[0] = operands[0];
7603 branch_cmp[1] = operands[1];
7604 branch_type = CMP_SI;
7609 (define_expand "tstsi"
7611 (match_operand:SI 0 "register_operand" ""))]
7615 if (operands[0]) /* avoid unused code message */
7617 branch_cmp[0] = operands[0];
7618 branch_cmp[1] = const0_rtx;
7619 branch_type = CMP_SI;
7624 (define_expand "cmpdi"
7626 (compare:CC (match_operand:DI 0 "register_operand" "")
7627 (match_operand:DI 1 "arith_operand" "")))]
7631 if (operands[0]) /* avoid unused code message */
7633 branch_cmp[0] = operands[0];
7634 branch_cmp[1] = operands[1];
7635 branch_type = CMP_DI;
7640 (define_expand "tstdi"
7642 (match_operand:DI 0 "register_operand" ""))]
7646 if (operands[0]) /* avoid unused code message */
7648 branch_cmp[0] = operands[0];
7649 branch_cmp[1] = const0_rtx;
7650 branch_type = CMP_DI;
7655 (define_expand "cmpdf"
7657 (compare:CC (match_operand:DF 0 "register_operand" "")
7658 (match_operand:DF 1 "register_operand" "")))]
7659 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
7662 if (operands[0]) /* avoid unused code message */
7664 branch_cmp[0] = operands[0];
7665 branch_cmp[1] = operands[1];
7666 branch_type = CMP_DF;
7671 (define_expand "cmpsf"
7673 (compare:CC (match_operand:SF 0 "register_operand" "")
7674 (match_operand:SF 1 "register_operand" "")))]
7678 if (operands[0]) /* avoid unused code message */
7680 branch_cmp[0] = operands[0];
7681 branch_cmp[1] = operands[1];
7682 branch_type = CMP_SF;
7689 ;; ....................
7691 ;; CONDITIONAL BRANCHES
7693 ;; ....................
7695 ;; Conditional branches on floating-point equality tests.
7697 (define_insn "branch_fp"
7700 (match_operator:CC 0 "cmp_op"
7701 [(match_operand:CC 2 "register_operand" "z")
7703 (label_ref (match_operand 1 "" ""))
7708 return mips_output_conditional_branch (insn,
7710 /*two_operands_p=*/0,
7713 get_attr_length (insn));
7715 [(set_attr "type" "branch")
7716 (set_attr "mode" "none")])
7718 (define_insn "branch_fp_inverted"
7721 (match_operator:CC 0 "cmp_op"
7722 [(match_operand:CC 2 "register_operand" "z")
7725 (label_ref (match_operand 1 "" ""))))]
7729 return mips_output_conditional_branch (insn,
7731 /*two_operands_p=*/0,
7734 get_attr_length (insn));
7736 [(set_attr "type" "branch")
7737 (set_attr "mode" "none")])
7739 ;; Conditional branches on comparisons with zero.
7741 (define_insn "branch_zero"
7744 (match_operator:SI 0 "cmp_op"
7745 [(match_operand:SI 2 "register_operand" "d")
7747 (label_ref (match_operand 1 "" ""))
7752 return mips_output_conditional_branch (insn,
7754 /*two_operands_p=*/0,
7757 get_attr_length (insn));
7759 [(set_attr "type" "branch")
7760 (set_attr "mode" "none")])
7762 (define_insn "branch_zero_inverted"
7765 (match_operator:SI 0 "cmp_op"
7766 [(match_operand:SI 2 "register_operand" "d")
7769 (label_ref (match_operand 1 "" ""))))]
7773 return mips_output_conditional_branch (insn,
7775 /*two_operands_p=*/0,
7778 get_attr_length (insn));
7780 [(set_attr "type" "branch")
7781 (set_attr "mode" "none")])
7783 (define_insn "branch_zero_di"
7786 (match_operator:DI 0 "cmp_op"
7787 [(match_operand:DI 2 "register_operand" "d")
7789 (label_ref (match_operand 1 "" ""))
7794 return mips_output_conditional_branch (insn,
7796 /*two_operands_p=*/0,
7799 get_attr_length (insn));
7801 [(set_attr "type" "branch")
7802 (set_attr "mode" "none")])
7804 (define_insn "branch_zero_di_inverted"
7807 (match_operator:DI 0 "cmp_op"
7808 [(match_operand:DI 2 "register_operand" "d")
7811 (label_ref (match_operand 1 "" ""))))]
7815 return mips_output_conditional_branch (insn,
7817 /*two_operands_p=*/0,
7820 get_attr_length (insn));
7822 [(set_attr "type" "branch")
7823 (set_attr "mode" "none")])
7825 ;; Conditional branch on equality comparision.
7827 (define_insn "branch_equality"
7830 (match_operator:SI 0 "equality_op"
7831 [(match_operand:SI 2 "register_operand" "d")
7832 (match_operand:SI 3 "register_operand" "d")])
7833 (label_ref (match_operand 1 "" ""))
7838 return mips_output_conditional_branch (insn,
7840 /*two_operands_p=*/1,
7843 get_attr_length (insn));
7845 [(set_attr "type" "branch")
7846 (set_attr "mode" "none")])
7848 (define_insn "branch_equality_di"
7851 (match_operator:DI 0 "equality_op"
7852 [(match_operand:DI 2 "register_operand" "d")
7853 (match_operand:DI 3 "register_operand" "d")])
7854 (label_ref (match_operand 1 "" ""))
7859 return mips_output_conditional_branch (insn,
7861 /*two_operands_p=*/1,
7864 get_attr_length (insn));
7866 [(set_attr "type" "branch")
7867 (set_attr "mode" "none")])
7869 (define_insn "branch_equality_inverted"
7872 (match_operator:SI 0 "equality_op"
7873 [(match_operand:SI 2 "register_operand" "d")
7874 (match_operand:SI 3 "register_operand" "d")])
7876 (label_ref (match_operand 1 "" ""))))]
7880 return mips_output_conditional_branch (insn,
7882 /*two_operands_p=*/1,
7885 get_attr_length (insn));
7887 [(set_attr "type" "branch")
7888 (set_attr "mode" "none")])
7890 (define_insn "branch_equality_di_inverted"
7893 (match_operator:DI 0 "equality_op"
7894 [(match_operand:DI 2 "register_operand" "d")
7895 (match_operand:DI 3 "register_operand" "d")])
7897 (label_ref (match_operand 1 "" ""))))]
7901 return mips_output_conditional_branch (insn,
7903 /*two_operands_p=*/1,
7906 get_attr_length (insn));
7908 [(set_attr "type" "branch")
7909 (set_attr "mode" "none")])
7915 (if_then_else (match_operator:SI 0 "equality_op"
7916 [(match_operand:SI 1 "register_operand" "d,t")
7918 (match_operand 2 "pc_or_label_operand" "")
7919 (match_operand 3 "pc_or_label_operand" "")))]
7923 if (operands[2] != pc_rtx)
7925 if (which_alternative == 0)
7926 return \"%*b%C0z\\t%1,%2\";
7928 return \"%*bt%C0z\\t%2\";
7932 if (which_alternative == 0)
7933 return \"%*b%N0z\\t%1,%3\";
7935 return \"%*bt%N0z\\t%3\";
7938 [(set_attr "type" "branch")
7939 (set_attr "mode" "none")
7940 (set_attr "length" "8")])
7944 (if_then_else (match_operator:DI 0 "equality_op"
7945 [(match_operand:DI 1 "register_operand" "d,t")
7947 (match_operand 2 "pc_or_label_operand" "")
7948 (match_operand 3 "pc_or_label_operand" "")))]
7952 if (operands[2] != pc_rtx)
7954 if (which_alternative == 0)
7955 return \"%*b%C0z\\t%1,%2\";
7957 return \"%*bt%C0z\\t%2\";
7961 if (which_alternative == 0)
7962 return \"%*b%N0z\\t%1,%3\";
7964 return \"%*bt%N0z\\t%3\";
7967 [(set_attr "type" "branch")
7968 (set_attr "mode" "none")
7969 (set_attr "length" "8")])
7971 (define_expand "bunordered"
7973 (if_then_else (unordered:CC (cc0)
7975 (label_ref (match_operand 0 "" ""))
7980 if (operands[0]) /* avoid unused code warning */
7982 gen_conditional_branch (operands, UNORDERED);
7987 (define_expand "bordered"
7989 (if_then_else (ordered:CC (cc0)
7991 (label_ref (match_operand 0 "" ""))
7996 if (operands[0]) /* avoid unused code warning */
7998 gen_conditional_branch (operands, ORDERED);
8003 (define_expand "bunlt"
8005 (if_then_else (unlt:CC (cc0)
8007 (label_ref (match_operand 0 "" ""))
8012 if (operands[0]) /* avoid unused code warning */
8014 gen_conditional_branch (operands, UNLT);
8019 (define_expand "bunge"
8021 (if_then_else (unge:CC (cc0)
8023 (label_ref (match_operand 0 "" ""))
8028 gen_conditional_branch (operands, UNGE);
8032 (define_expand "buneq"
8034 (if_then_else (uneq:CC (cc0)
8036 (label_ref (match_operand 0 "" ""))
8041 if (operands[0]) /* avoid unused code warning */
8043 gen_conditional_branch (operands, UNEQ);
8048 (define_expand "bltgt"
8050 (if_then_else (ltgt:CC (cc0)
8052 (label_ref (match_operand 0 "" ""))
8057 gen_conditional_branch (operands, LTGT);
8061 (define_expand "bunle"
8063 (if_then_else (unle:CC (cc0)
8065 (label_ref (match_operand 0 "" ""))
8070 if (operands[0]) /* avoid unused code warning */
8072 gen_conditional_branch (operands, UNLE);
8077 (define_expand "bungt"
8079 (if_then_else (ungt:CC (cc0)
8081 (label_ref (match_operand 0 "" ""))
8086 gen_conditional_branch (operands, UNGT);
8090 (define_expand "beq"
8092 (if_then_else (eq:CC (cc0)
8094 (label_ref (match_operand 0 "" ""))
8099 if (operands[0]) /* avoid unused code warning */
8101 gen_conditional_branch (operands, EQ);
8106 (define_expand "bne"
8108 (if_then_else (ne:CC (cc0)
8110 (label_ref (match_operand 0 "" ""))
8115 if (operands[0]) /* avoid unused code warning */
8117 gen_conditional_branch (operands, NE);
8122 (define_expand "bgt"
8124 (if_then_else (gt:CC (cc0)
8126 (label_ref (match_operand 0 "" ""))
8131 if (operands[0]) /* avoid unused code warning */
8133 gen_conditional_branch (operands, GT);
8138 (define_expand "bge"
8140 (if_then_else (ge:CC (cc0)
8142 (label_ref (match_operand 0 "" ""))
8147 if (operands[0]) /* avoid unused code warning */
8149 gen_conditional_branch (operands, GE);
8154 (define_expand "blt"
8156 (if_then_else (lt:CC (cc0)
8158 (label_ref (match_operand 0 "" ""))
8163 if (operands[0]) /* avoid unused code warning */
8165 gen_conditional_branch (operands, LT);
8170 (define_expand "ble"
8172 (if_then_else (le:CC (cc0)
8174 (label_ref (match_operand 0 "" ""))
8179 if (operands[0]) /* avoid unused code warning */
8181 gen_conditional_branch (operands, LE);
8186 (define_expand "bgtu"
8188 (if_then_else (gtu:CC (cc0)
8190 (label_ref (match_operand 0 "" ""))
8195 if (operands[0]) /* avoid unused code warning */
8197 gen_conditional_branch (operands, GTU);
8202 (define_expand "bgeu"
8204 (if_then_else (geu:CC (cc0)
8206 (label_ref (match_operand 0 "" ""))
8211 if (operands[0]) /* avoid unused code warning */
8213 gen_conditional_branch (operands, GEU);
8219 (define_expand "bltu"
8221 (if_then_else (ltu:CC (cc0)
8223 (label_ref (match_operand 0 "" ""))
8228 if (operands[0]) /* avoid unused code warning */
8230 gen_conditional_branch (operands, LTU);
8235 (define_expand "bleu"
8237 (if_then_else (leu:CC (cc0)
8239 (label_ref (match_operand 0 "" ""))
8244 if (operands[0]) /* avoid unused code warning */
8246 gen_conditional_branch (operands, LEU);
8253 ;; ....................
8255 ;; SETTING A REGISTER FROM A COMPARISON
8257 ;; ....................
8259 (define_expand "seq"
8260 [(set (match_operand:SI 0 "register_operand" "=d")
8261 (eq:SI (match_dup 1)
8266 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
8269 /* set up operands from compare. */
8270 operands[1] = branch_cmp[0];
8271 operands[2] = branch_cmp[1];
8273 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
8275 gen_int_relational (EQ, operands[0], operands[1], operands[2], (int *)0);
8279 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
8280 operands[2] = force_reg (SImode, operands[2]);
8282 /* fall through and generate default code */
8286 (define_insn "seq_si_zero"
8287 [(set (match_operand:SI 0 "register_operand" "=d")
8288 (eq:SI (match_operand:SI 1 "register_operand" "d")
8292 [(set_attr "type" "arith")
8293 (set_attr "mode" "SI")])
8296 [(set (match_operand:SI 0 "register_operand" "=t")
8297 (eq:SI (match_operand:SI 1 "register_operand" "d")
8301 [(set_attr "type" "arith")
8302 (set_attr "mode" "SI")])
8304 (define_insn "seq_di_zero"
8305 [(set (match_operand:DI 0 "register_operand" "=d")
8306 (eq:DI (match_operand:DI 1 "register_operand" "d")
8308 "TARGET_64BIT && !TARGET_MIPS16"
8310 [(set_attr "type" "arith")
8311 (set_attr "mode" "DI")])
8314 [(set (match_operand:DI 0 "register_operand" "=t")
8315 (eq:DI (match_operand:DI 1 "register_operand" "d")
8317 "TARGET_64BIT && TARGET_MIPS16"
8319 [(set_attr "type" "arith")
8320 (set_attr "mode" "DI")])
8322 (define_insn "seq_si"
8323 [(set (match_operand:SI 0 "register_operand" "=d,d")
8324 (eq:SI (match_operand:SI 1 "register_operand" "%d,d")
8325 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
8326 "TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
8328 xor\\t%0,%1,%2\;sltu\\t%0,%0,1
8329 xori\\t%0,%1,%2\;sltu\\t%0,%0,1"
8330 [(set_attr "type" "arith")
8331 (set_attr "mode" "SI")
8332 (set_attr "length" "8")])
8335 [(set (match_operand:SI 0 "register_operand" "")
8336 (eq:SI (match_operand:SI 1 "register_operand" "")
8337 (match_operand:SI 2 "uns_arith_operand" "")))]
8338 "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE && !TARGET_MIPS16
8339 && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)"
8341 (xor:SI (match_dup 1)
8344 (ltu:SI (match_dup 0)
8348 (define_insn "seq_di"
8349 [(set (match_operand:DI 0 "register_operand" "=d,d")
8350 (eq:DI (match_operand:DI 1 "register_operand" "%d,d")
8351 (match_operand:DI 2 "uns_arith_operand" "d,K")))]
8352 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
8354 xor\\t%0,%1,%2\;sltu\\t%0,%0,1
8355 xori\\t%0,%1,%2\;sltu\\t%0,%0,1"
8356 [(set_attr "type" "arith")
8357 (set_attr "mode" "DI")
8358 (set_attr "length" "8")])
8361 [(set (match_operand:DI 0 "register_operand" "")
8362 (eq:DI (match_operand:DI 1 "register_operand" "")
8363 (match_operand:DI 2 "uns_arith_operand" "")))]
8364 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
8366 && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)"
8368 (xor:DI (match_dup 1)
8371 (ltu:DI (match_dup 0)
8375 ;; On the mips16 the default code is better than using sltu.
8377 (define_expand "sne"
8378 [(set (match_operand:SI 0 "register_operand" "=d")
8379 (ne:SI (match_dup 1)
8384 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
8387 /* set up operands from compare. */
8388 operands[1] = branch_cmp[0];
8389 operands[2] = branch_cmp[1];
8391 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE)
8393 gen_int_relational (NE, operands[0], operands[1], operands[2], (int *)0);
8397 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
8398 operands[2] = force_reg (SImode, operands[2]);
8400 /* fall through and generate default code */
8403 (define_insn "sne_si_zero"
8404 [(set (match_operand:SI 0 "register_operand" "=d")
8405 (ne:SI (match_operand:SI 1 "register_operand" "d")
8409 [(set_attr "type" "arith")
8410 (set_attr "mode" "SI")])
8412 (define_insn "sne_di_zero"
8413 [(set (match_operand:DI 0 "register_operand" "=d")
8414 (ne:DI (match_operand:DI 1 "register_operand" "d")
8416 "TARGET_64BIT && !TARGET_MIPS16"
8418 [(set_attr "type" "arith")
8419 (set_attr "mode" "DI")])
8421 (define_insn "sne_si"
8422 [(set (match_operand:SI 0 "register_operand" "=d,d")
8423 (ne:SI (match_operand:SI 1 "register_operand" "%d,d")
8424 (match_operand:SI 2 "uns_arith_operand" "d,K")))]
8425 "TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
8427 xor\\t%0,%1,%2\;sltu\\t%0,%.,%0
8428 xori\\t%0,%1,%x2\;sltu\\t%0,%.,%0"
8429 [(set_attr "type" "arith")
8430 (set_attr "mode" "SI")
8431 (set_attr "length" "8")])
8434 [(set (match_operand:SI 0 "register_operand" "")
8435 (ne:SI (match_operand:SI 1 "register_operand" "")
8436 (match_operand:SI 2 "uns_arith_operand" "")))]
8437 "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE && !TARGET_MIPS16
8438 && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)"
8440 (xor:SI (match_dup 1)
8443 (gtu:SI (match_dup 0)
8447 (define_insn "sne_di"
8448 [(set (match_operand:DI 0 "register_operand" "=d,d")
8449 (ne:DI (match_operand:DI 1 "register_operand" "%d,d")
8450 (match_operand:DI 2 "uns_arith_operand" "d,K")))]
8451 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
8453 xor\\t%0,%1,%2\;sltu\\t%0,%.,%0
8454 xori\\t%0,%1,%x2\;sltu\\t%0,%.,%0"
8455 [(set_attr "type" "arith")
8456 (set_attr "mode" "DI")
8457 (set_attr "length" "8")])
8460 [(set (match_operand:DI 0 "register_operand" "")
8461 (ne:DI (match_operand:DI 1 "register_operand" "")
8462 (match_operand:DI 2 "uns_arith_operand" "")))]
8463 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
8465 && (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)"
8467 (xor:DI (match_dup 1)
8470 (gtu:DI (match_dup 0)
8474 (define_expand "sgt"
8475 [(set (match_operand:SI 0 "register_operand" "=d")
8476 (gt:SI (match_dup 1)
8481 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
8484 /* set up operands from compare. */
8485 operands[1] = branch_cmp[0];
8486 operands[2] = branch_cmp[1];
8488 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
8490 gen_int_relational (GT, operands[0], operands[1], operands[2], (int *)0);
8494 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) != 0)
8495 operands[2] = force_reg (SImode, operands[2]);
8497 /* fall through and generate default code */
8500 (define_insn "sgt_si"
8501 [(set (match_operand:SI 0 "register_operand" "=d")
8502 (gt:SI (match_operand:SI 1 "register_operand" "d")
8503 (match_operand:SI 2 "reg_or_0_operand" "dJ")))]
8506 [(set_attr "type" "arith")
8507 (set_attr "mode" "SI")])
8510 [(set (match_operand:SI 0 "register_operand" "=t")
8511 (gt:SI (match_operand:SI 1 "register_operand" "d")
8512 (match_operand:SI 2 "register_operand" "d")))]
8515 [(set_attr "type" "arith")
8516 (set_attr "mode" "SI")])
8518 (define_insn "sgt_di"
8519 [(set (match_operand:DI 0 "register_operand" "=d")
8520 (gt:DI (match_operand:DI 1 "register_operand" "d")
8521 (match_operand:DI 2 "reg_or_0_operand" "dJ")))]
8522 "TARGET_64BIT && !TARGET_MIPS16"
8524 [(set_attr "type" "arith")
8525 (set_attr "mode" "DI")])
8528 [(set (match_operand:DI 0 "register_operand" "=d")
8529 (gt:DI (match_operand:DI 1 "register_operand" "d")
8530 (match_operand:DI 2 "register_operand" "d")))]
8531 "TARGET_64BIT && TARGET_MIPS16"
8533 [(set_attr "type" "arith")
8534 (set_attr "mode" "DI")])
8536 (define_expand "sge"
8537 [(set (match_operand:SI 0 "register_operand" "=d")
8538 (ge:SI (match_dup 1)
8543 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
8546 /* set up operands from compare. */
8547 operands[1] = branch_cmp[0];
8548 operands[2] = branch_cmp[1];
8550 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
8552 gen_int_relational (GE, operands[0], operands[1], operands[2], (int *)0);
8556 /* fall through and generate default code */
8559 (define_insn "sge_si"
8560 [(set (match_operand:SI 0 "register_operand" "=d")
8561 (ge:SI (match_operand:SI 1 "register_operand" "d")
8562 (match_operand:SI 2 "arith_operand" "dI")))]
8563 "TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
8564 "slt\\t%0,%1,%2\;xori\\t%0,%0,0x0001"
8565 [(set_attr "type" "arith")
8566 (set_attr "mode" "SI")
8567 (set_attr "length" "8")])
8570 [(set (match_operand:SI 0 "register_operand" "")
8571 (ge:SI (match_operand:SI 1 "register_operand" "")
8572 (match_operand:SI 2 "arith_operand" "")))]
8573 "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE && !TARGET_MIPS16"
8575 (lt:SI (match_dup 1)
8578 (xor:SI (match_dup 0)
8582 (define_insn "sge_di"
8583 [(set (match_operand:DI 0 "register_operand" "=d")
8584 (ge:DI (match_operand:DI 1 "register_operand" "d")
8585 (match_operand:DI 2 "arith_operand" "dI")))]
8586 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
8587 "slt\\t%0,%1,%2\;xori\\t%0,%0,0x0001"
8588 [(set_attr "type" "arith")
8589 (set_attr "mode" "DI")
8590 (set_attr "length" "8")])
8593 [(set (match_operand:DI 0 "register_operand" "")
8594 (ge:DI (match_operand:DI 1 "register_operand" "")
8595 (match_operand:DI 2 "arith_operand" "")))]
8596 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
8599 (lt:DI (match_dup 1)
8602 (xor:DI (match_dup 0)
8606 (define_expand "slt"
8607 [(set (match_operand:SI 0 "register_operand" "=d")
8608 (lt:SI (match_dup 1)
8613 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
8616 /* set up operands from compare. */
8617 operands[1] = branch_cmp[0];
8618 operands[2] = branch_cmp[1];
8620 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
8622 gen_int_relational (LT, operands[0], operands[1], operands[2], (int *)0);
8626 /* fall through and generate default code */
8629 (define_insn "slt_si"
8630 [(set (match_operand:SI 0 "register_operand" "=d")
8631 (lt:SI (match_operand:SI 1 "register_operand" "d")
8632 (match_operand:SI 2 "arith_operand" "dI")))]
8635 [(set_attr "type" "arith")
8636 (set_attr "mode" "SI")])
8639 [(set (match_operand:SI 0 "register_operand" "=t,t")
8640 (lt:SI (match_operand:SI 1 "register_operand" "d,d")
8641 (match_operand:SI 2 "arith_operand" "d,I")))]
8644 [(set_attr "type" "arith")
8645 (set_attr "mode" "SI")
8646 (set_attr_alternative "length"
8648 (if_then_else (match_operand:VOID 2 "m16_uimm8_1" "")
8652 (define_insn "slt_di"
8653 [(set (match_operand:DI 0 "register_operand" "=d")
8654 (lt:DI (match_operand:DI 1 "register_operand" "d")
8655 (match_operand:DI 2 "arith_operand" "dI")))]
8656 "TARGET_64BIT && !TARGET_MIPS16"
8658 [(set_attr "type" "arith")
8659 (set_attr "mode" "DI")])
8662 [(set (match_operand:DI 0 "register_operand" "=t,t")
8663 (lt:DI (match_operand:DI 1 "register_operand" "d,d")
8664 (match_operand:DI 2 "arith_operand" "d,I")))]
8665 "TARGET_64BIT && TARGET_MIPS16"
8667 [(set_attr "type" "arith")
8668 (set_attr "mode" "DI")
8669 (set_attr_alternative "length"
8671 (if_then_else (match_operand:VOID 2 "m16_uimm8_1" "")
8675 (define_expand "sle"
8676 [(set (match_operand:SI 0 "register_operand" "=d")
8677 (le:SI (match_dup 1)
8682 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
8685 /* set up operands from compare. */
8686 operands[1] = branch_cmp[0];
8687 operands[2] = branch_cmp[1];
8689 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
8691 gen_int_relational (LE, operands[0], operands[1], operands[2], (int *)0);
8695 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 32767)
8696 operands[2] = force_reg (SImode, operands[2]);
8698 /* fall through and generate default code */
8701 (define_insn "sle_si_const"
8702 [(set (match_operand:SI 0 "register_operand" "=d")
8703 (le:SI (match_operand:SI 1 "register_operand" "d")
8704 (match_operand:SI 2 "small_int" "I")))]
8705 "!TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
8708 operands[2] = GEN_INT (INTVAL (operands[2])+1);
8709 return \"slt\\t%0,%1,%2\";
8711 [(set_attr "type" "arith")
8712 (set_attr "mode" "SI")])
8715 [(set (match_operand:SI 0 "register_operand" "=t")
8716 (le:SI (match_operand:SI 1 "register_operand" "d")
8717 (match_operand:SI 2 "small_int" "I")))]
8718 "TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
8721 operands[2] = GEN_INT (INTVAL (operands[2])+1);
8722 return \"slt\\t%1,%2\";
8724 [(set_attr "type" "arith")
8725 (set_attr "mode" "SI")
8726 (set (attr "length") (if_then_else (match_operand:VOID 2 "m16_uimm8_m1_1" "")
8730 (define_insn "sle_di_const"
8731 [(set (match_operand:DI 0 "register_operand" "=d")
8732 (le:DI (match_operand:DI 1 "register_operand" "d")
8733 (match_operand:DI 2 "small_int" "I")))]
8734 "TARGET_64BIT && !TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
8737 operands[2] = GEN_INT (INTVAL (operands[2])+1);
8738 return \"slt\\t%0,%1,%2\";
8740 [(set_attr "type" "arith")
8741 (set_attr "mode" "DI")])
8744 [(set (match_operand:DI 0 "register_operand" "=t")
8745 (le:DI (match_operand:DI 1 "register_operand" "d")
8746 (match_operand:DI 2 "small_int" "I")))]
8747 "TARGET_64BIT && TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
8750 operands[2] = GEN_INT (INTVAL (operands[2])+1);
8751 return \"slt\\t%1,%2\";
8753 [(set_attr "type" "arith")
8754 (set_attr "mode" "DI")
8755 (set (attr "length") (if_then_else (match_operand:VOID 2 "m16_uimm8_m1_1" "")
8759 (define_insn "sle_si_reg"
8760 [(set (match_operand:SI 0 "register_operand" "=d")
8761 (le:SI (match_operand:SI 1 "register_operand" "d")
8762 (match_operand:SI 2 "register_operand" "d")))]
8763 "TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
8764 "slt\\t%0,%z2,%1\;xori\\t%0,%0,0x0001"
8765 [(set_attr "type" "arith")
8766 (set_attr "mode" "SI")
8767 (set_attr "length" "8")])
8770 [(set (match_operand:SI 0 "register_operand" "")
8771 (le:SI (match_operand:SI 1 "register_operand" "")
8772 (match_operand:SI 2 "register_operand" "")))]
8773 "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE && !TARGET_MIPS16"
8775 (lt:SI (match_dup 2)
8778 (xor:SI (match_dup 0)
8782 (define_insn "sle_di_reg"
8783 [(set (match_operand:DI 0 "register_operand" "=d")
8784 (le:DI (match_operand:DI 1 "register_operand" "d")
8785 (match_operand:DI 2 "register_operand" "d")))]
8786 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
8787 "slt\\t%0,%z2,%1\;xori\\t%0,%0,0x0001"
8788 [(set_attr "type" "arith")
8789 (set_attr "mode" "DI")
8790 (set_attr "length" "8")])
8793 [(set (match_operand:DI 0 "register_operand" "")
8794 (le:DI (match_operand:DI 1 "register_operand" "")
8795 (match_operand:DI 2 "register_operand" "")))]
8796 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
8799 (lt:DI (match_dup 2)
8802 (xor:DI (match_dup 0)
8806 (define_expand "sgtu"
8807 [(set (match_operand:SI 0 "register_operand" "=d")
8808 (gtu:SI (match_dup 1)
8813 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
8816 /* set up operands from compare. */
8817 operands[1] = branch_cmp[0];
8818 operands[2] = branch_cmp[1];
8820 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
8822 gen_int_relational (GTU, operands[0], operands[1], operands[2], (int *)0);
8826 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) != 0)
8827 operands[2] = force_reg (SImode, operands[2]);
8829 /* fall through and generate default code */
8832 (define_insn "sgtu_si"
8833 [(set (match_operand:SI 0 "register_operand" "=d")
8834 (gtu:SI (match_operand:SI 1 "register_operand" "d")
8835 (match_operand:SI 2 "reg_or_0_operand" "dJ")))]
8838 [(set_attr "type" "arith")
8839 (set_attr "mode" "SI")])
8842 [(set (match_operand:SI 0 "register_operand" "=t")
8843 (gtu:SI (match_operand:SI 1 "register_operand" "d")
8844 (match_operand:SI 2 "register_operand" "d")))]
8847 [(set_attr "type" "arith")
8848 (set_attr "mode" "SI")])
8850 (define_insn "sgtu_di"
8851 [(set (match_operand:DI 0 "register_operand" "=d")
8852 (gtu:DI (match_operand:DI 1 "register_operand" "d")
8853 (match_operand:DI 2 "reg_or_0_operand" "dJ")))]
8854 "TARGET_64BIT && !TARGET_MIPS16"
8856 [(set_attr "type" "arith")
8857 (set_attr "mode" "DI")])
8860 [(set (match_operand:DI 0 "register_operand" "=t")
8861 (gtu:DI (match_operand:DI 1 "register_operand" "d")
8862 (match_operand:DI 2 "register_operand" "d")))]
8863 "TARGET_64BIT && TARGET_MIPS16"
8865 [(set_attr "type" "arith")
8866 (set_attr "mode" "DI")])
8868 (define_expand "sgeu"
8869 [(set (match_operand:SI 0 "register_operand" "=d")
8870 (geu:SI (match_dup 1)
8875 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
8878 /* set up operands from compare. */
8879 operands[1] = branch_cmp[0];
8880 operands[2] = branch_cmp[1];
8882 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
8884 gen_int_relational (GEU, operands[0], operands[1], operands[2], (int *)0);
8888 /* fall through and generate default code */
8891 (define_insn "sgeu_si"
8892 [(set (match_operand:SI 0 "register_operand" "=d")
8893 (geu:SI (match_operand:SI 1 "register_operand" "d")
8894 (match_operand:SI 2 "arith_operand" "dI")))]
8895 "TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
8896 "sltu\\t%0,%1,%2\;xori\\t%0,%0,0x0001"
8897 [(set_attr "type" "arith")
8898 (set_attr "mode" "SI")
8899 (set_attr "length" "8")])
8902 [(set (match_operand:SI 0 "register_operand" "")
8903 (geu:SI (match_operand:SI 1 "register_operand" "")
8904 (match_operand:SI 2 "arith_operand" "")))]
8905 "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE && !TARGET_MIPS16"
8907 (ltu:SI (match_dup 1)
8910 (xor:SI (match_dup 0)
8914 (define_insn "sgeu_di"
8915 [(set (match_operand:DI 0 "register_operand" "=d")
8916 (geu:DI (match_operand:DI 1 "register_operand" "d")
8917 (match_operand:DI 2 "arith_operand" "dI")))]
8918 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
8919 "sltu\\t%0,%1,%2\;xori\\t%0,%0,0x0001"
8920 [(set_attr "type" "arith")
8921 (set_attr "mode" "DI")
8922 (set_attr "length" "8")])
8925 [(set (match_operand:DI 0 "register_operand" "")
8926 (geu:DI (match_operand:DI 1 "register_operand" "")
8927 (match_operand:DI 2 "arith_operand" "")))]
8928 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
8931 (ltu:DI (match_dup 1)
8934 (xor:DI (match_dup 0)
8938 (define_expand "sltu"
8939 [(set (match_operand:SI 0 "register_operand" "=d")
8940 (ltu:SI (match_dup 1)
8945 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
8948 /* set up operands from compare. */
8949 operands[1] = branch_cmp[0];
8950 operands[2] = branch_cmp[1];
8952 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
8954 gen_int_relational (LTU, operands[0], operands[1], operands[2], (int *)0);
8958 /* fall through and generate default code */
8961 (define_insn "sltu_si"
8962 [(set (match_operand:SI 0 "register_operand" "=d")
8963 (ltu:SI (match_operand:SI 1 "register_operand" "d")
8964 (match_operand:SI 2 "arith_operand" "dI")))]
8967 [(set_attr "type" "arith")
8968 (set_attr "mode" "SI")])
8971 [(set (match_operand:SI 0 "register_operand" "=t,t")
8972 (ltu:SI (match_operand:SI 1 "register_operand" "d,d")
8973 (match_operand:SI 2 "arith_operand" "d,I")))]
8976 [(set_attr "type" "arith")
8977 (set_attr "mode" "SI")
8978 (set_attr_alternative "length"
8980 (if_then_else (match_operand:VOID 2 "m16_uimm8_1" "")
8984 (define_insn "sltu_di"
8985 [(set (match_operand:DI 0 "register_operand" "=d")
8986 (ltu:DI (match_operand:DI 1 "register_operand" "d")
8987 (match_operand:DI 2 "arith_operand" "dI")))]
8988 "TARGET_64BIT && !TARGET_MIPS16"
8990 [(set_attr "type" "arith")
8991 (set_attr "mode" "DI")])
8994 [(set (match_operand:DI 0 "register_operand" "=t,t")
8995 (ltu:DI (match_operand:DI 1 "register_operand" "d,d")
8996 (match_operand:DI 2 "arith_operand" "d,I")))]
8997 "TARGET_64BIT && TARGET_MIPS16"
8999 [(set_attr "type" "arith")
9000 (set_attr "mode" "DI")
9001 (set_attr_alternative "length"
9003 (if_then_else (match_operand:VOID 2 "m16_uimm8_1" "")
9007 (define_expand "sleu"
9008 [(set (match_operand:SI 0 "register_operand" "=d")
9009 (leu:SI (match_dup 1)
9014 if (branch_type != CMP_SI && (!TARGET_64BIT || branch_type != CMP_DI))
9017 /* set up operands from compare. */
9018 operands[1] = branch_cmp[0];
9019 operands[2] = branch_cmp[1];
9021 if (TARGET_64BIT || !TARGET_DEBUG_C_MODE || TARGET_MIPS16)
9023 gen_int_relational (LEU, operands[0], operands[1], operands[2], (int *)0);
9027 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 32767)
9028 operands[2] = force_reg (SImode, operands[2]);
9030 /* fall through and generate default code */
9033 (define_insn "sleu_si_const"
9034 [(set (match_operand:SI 0 "register_operand" "=d")
9035 (leu:SI (match_operand:SI 1 "register_operand" "d")
9036 (match_operand:SI 2 "small_int" "I")))]
9037 "!TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
9040 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
9041 return \"sltu\\t%0,%1,%2\";
9043 [(set_attr "type" "arith")
9044 (set_attr "mode" "SI")])
9047 [(set (match_operand:SI 0 "register_operand" "=t")
9048 (leu:SI (match_operand:SI 1 "register_operand" "d")
9049 (match_operand:SI 2 "small_int" "I")))]
9050 "TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
9053 operands[2] = GEN_INT (INTVAL (operands[2])+1);
9054 return \"sltu\\t%1,%2\";
9056 [(set_attr "type" "arith")
9057 (set_attr "mode" "SI")
9058 (set (attr "length") (if_then_else (match_operand:VOID 2 "m16_uimm8_m1_1" "")
9062 (define_insn "sleu_di_const"
9063 [(set (match_operand:DI 0 "register_operand" "=d")
9064 (leu:DI (match_operand:DI 1 "register_operand" "d")
9065 (match_operand:DI 2 "small_int" "I")))]
9066 "TARGET_64BIT && !TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
9069 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
9070 return \"sltu\\t%0,%1,%2\";
9072 [(set_attr "type" "arith")
9073 (set_attr "mode" "DI")])
9076 [(set (match_operand:DI 0 "register_operand" "=t")
9077 (leu:DI (match_operand:DI 1 "register_operand" "d")
9078 (match_operand:DI 2 "small_int" "I")))]
9079 "TARGET_64BIT && TARGET_MIPS16 && INTVAL (operands[2]) < 32767"
9082 operands[2] = GEN_INT (INTVAL (operands[2])+1);
9083 return \"sltu\\t%1,%2\";
9085 [(set_attr "type" "arith")
9086 (set_attr "mode" "DI")
9087 (set (attr "length") (if_then_else (match_operand:VOID 2 "m16_uimm8_m1_1" "")
9091 (define_insn "sleu_si_reg"
9092 [(set (match_operand:SI 0 "register_operand" "=d")
9093 (leu:SI (match_operand:SI 1 "register_operand" "d")
9094 (match_operand:SI 2 "register_operand" "d")))]
9095 "TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
9096 "sltu\\t%0,%z2,%1\;xori\\t%0,%0,0x0001"
9097 [(set_attr "type" "arith")
9098 (set_attr "mode" "SI")
9099 (set_attr "length" "8")])
9102 [(set (match_operand:SI 0 "register_operand" "")
9103 (leu:SI (match_operand:SI 1 "register_operand" "")
9104 (match_operand:SI 2 "register_operand" "")))]
9105 "TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE && !TARGET_MIPS16"
9107 (ltu:SI (match_dup 2)
9110 (xor:SI (match_dup 0)
9114 (define_insn "sleu_di_reg"
9115 [(set (match_operand:DI 0 "register_operand" "=d")
9116 (leu:DI (match_operand:DI 1 "register_operand" "d")
9117 (match_operand:DI 2 "register_operand" "d")))]
9118 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_MIPS16"
9119 "sltu\\t%0,%z2,%1\;xori\\t%0,%0,0x0001"
9120 [(set_attr "type" "arith")
9121 (set_attr "mode" "DI")
9122 (set_attr "length" "8")])
9125 [(set (match_operand:DI 0 "register_operand" "")
9126 (leu:DI (match_operand:DI 1 "register_operand" "")
9127 (match_operand:DI 2 "register_operand" "")))]
9128 "TARGET_64BIT && TARGET_DEBUG_C_MODE && !TARGET_DEBUG_D_MODE
9131 (ltu:DI (match_dup 2)
9134 (xor:DI (match_dup 0)
9140 ;; ....................
9142 ;; FLOATING POINT COMPARISONS
9144 ;; ....................
9146 (define_insn "sunordered_df"
9147 [(set (match_operand:CC 0 "register_operand" "=z")
9148 (unordered:CC (match_operand:DF 1 "register_operand" "f")
9149 (match_operand:DF 2 "register_operand" "f")))]
9150 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
9152 [(set_attr "type" "fcmp")
9153 (set_attr "mode" "FPSW")])
9155 (define_insn "sunlt_df"
9156 [(set (match_operand:CC 0 "register_operand" "=z")
9157 (unlt:CC (match_operand:DF 1 "register_operand" "f")
9158 (match_operand:DF 2 "register_operand" "f")))]
9159 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
9161 [(set_attr "type" "fcmp")
9162 (set_attr "mode" "FPSW")])
9164 (define_insn "suneq_df"
9165 [(set (match_operand:CC 0 "register_operand" "=z")
9166 (uneq:CC (match_operand:DF 1 "register_operand" "f")
9167 (match_operand:DF 2 "register_operand" "f")))]
9168 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
9170 [(set_attr "type" "fcmp")
9171 (set_attr "mode" "FPSW")])
9173 (define_insn "sunle_df"
9174 [(set (match_operand:CC 0 "register_operand" "=z")
9175 (unle:CC (match_operand:DF 1 "register_operand" "f")
9176 (match_operand:DF 2 "register_operand" "f")))]
9177 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
9179 [(set_attr "type" "fcmp")
9180 (set_attr "mode" "FPSW")])
9182 (define_insn "seq_df"
9183 [(set (match_operand:CC 0 "register_operand" "=z")
9184 (eq:CC (match_operand:DF 1 "register_operand" "f")
9185 (match_operand:DF 2 "register_operand" "f")))]
9186 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
9188 [(set_attr "type" "fcmp")
9189 (set_attr "mode" "FPSW")])
9191 (define_insn "slt_df"
9192 [(set (match_operand:CC 0 "register_operand" "=z")
9193 (lt:CC (match_operand:DF 1 "register_operand" "f")
9194 (match_operand:DF 2 "register_operand" "f")))]
9195 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
9197 [(set_attr "type" "fcmp")
9198 (set_attr "mode" "FPSW")])
9200 (define_insn "sle_df"
9201 [(set (match_operand:CC 0 "register_operand" "=z")
9202 (le:CC (match_operand:DF 1 "register_operand" "f")
9203 (match_operand:DF 2 "register_operand" "f")))]
9204 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
9206 [(set_attr "type" "fcmp")
9207 (set_attr "mode" "FPSW")])
9209 (define_insn "sgt_df"
9210 [(set (match_operand:CC 0 "register_operand" "=z")
9211 (gt:CC (match_operand:DF 1 "register_operand" "f")
9212 (match_operand:DF 2 "register_operand" "f")))]
9213 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
9215 [(set_attr "type" "fcmp")
9216 (set_attr "mode" "FPSW")])
9218 (define_insn "sge_df"
9219 [(set (match_operand:CC 0 "register_operand" "=z")
9220 (ge:CC (match_operand:DF 1 "register_operand" "f")
9221 (match_operand:DF 2 "register_operand" "f")))]
9222 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
9224 [(set_attr "type" "fcmp")
9225 (set_attr "mode" "FPSW")])
9227 (define_insn "sunordered_sf"
9228 [(set (match_operand:CC 0 "register_operand" "=z")
9229 (unordered:CC (match_operand:SF 1 "register_operand" "f")
9230 (match_operand:SF 2 "register_operand" "f")))]
9233 [(set_attr "type" "fcmp")
9234 (set_attr "mode" "FPSW")])
9236 (define_insn "sunlt_sf"
9237 [(set (match_operand:CC 0 "register_operand" "=z")
9238 (unlt:CC (match_operand:SF 1 "register_operand" "f")
9239 (match_operand:SF 2 "register_operand" "f")))]
9242 [(set_attr "type" "fcmp")
9243 (set_attr "mode" "FPSW")])
9245 (define_insn "suneq_sf"
9246 [(set (match_operand:CC 0 "register_operand" "=z")
9247 (uneq:CC (match_operand:SF 1 "register_operand" "f")
9248 (match_operand:SF 2 "register_operand" "f")))]
9251 [(set_attr "type" "fcmp")
9252 (set_attr "mode" "FPSW")])
9254 (define_insn "sunle_sf"
9255 [(set (match_operand:CC 0 "register_operand" "=z")
9256 (unle:CC (match_operand:SF 1 "register_operand" "f")
9257 (match_operand:SF 2 "register_operand" "f")))]
9260 [(set_attr "type" "fcmp")
9261 (set_attr "mode" "FPSW")])
9263 (define_insn "seq_sf"
9264 [(set (match_operand:CC 0 "register_operand" "=z")
9265 (eq:CC (match_operand:SF 1 "register_operand" "f")
9266 (match_operand:SF 2 "register_operand" "f")))]
9269 [(set_attr "type" "fcmp")
9270 (set_attr "mode" "FPSW")])
9272 (define_insn "slt_sf"
9273 [(set (match_operand:CC 0 "register_operand" "=z")
9274 (lt:CC (match_operand:SF 1 "register_operand" "f")
9275 (match_operand:SF 2 "register_operand" "f")))]
9278 [(set_attr "type" "fcmp")
9279 (set_attr "mode" "FPSW")])
9281 (define_insn "sle_sf"
9282 [(set (match_operand:CC 0 "register_operand" "=z")
9283 (le:CC (match_operand:SF 1 "register_operand" "f")
9284 (match_operand:SF 2 "register_operand" "f")))]
9287 [(set_attr "type" "fcmp")
9288 (set_attr "mode" "FPSW")])
9290 (define_insn "sgt_sf"
9291 [(set (match_operand:CC 0 "register_operand" "=z")
9292 (gt:CC (match_operand:SF 1 "register_operand" "f")
9293 (match_operand:SF 2 "register_operand" "f")))]
9296 [(set_attr "type" "fcmp")
9297 (set_attr "mode" "FPSW")])
9299 (define_insn "sge_sf"
9300 [(set (match_operand:CC 0 "register_operand" "=z")
9301 (ge:CC (match_operand:SF 1 "register_operand" "f")
9302 (match_operand:SF 2 "register_operand" "f")))]
9305 [(set_attr "type" "fcmp")
9306 (set_attr "mode" "FPSW")])
9310 ;; ....................
9312 ;; UNCONDITIONAL BRANCHES
9314 ;; ....................
9316 ;; Unconditional branches.
9320 (label_ref (match_operand 0 "" "")))]
9324 if (flag_pic && ! TARGET_EMBEDDED_PIC)
9326 if (get_attr_length (insn) <= 8)
9327 return \"%*b\\t%l0\";
9328 else if (Pmode == DImode)
9329 return \"%[dla\\t%@,%l0\;%*jr\\t%@%]\";
9331 return \"%[la\\t%@,%l0\;%*jr\\t%@%]\";
9334 return \"%*j\\t%l0\";
9336 [(set_attr "type" "jump")
9337 (set_attr "mode" "none")
9338 (set (attr "length")
9339 ;; we can't use `j' when emitting non-embedded PIC, so we emit
9340 ;; branch, if it's in range, or load the address of the branch
9341 ;; target into $at in a PIC-compatible way and then jump to it.
9343 (ior (eq (symbol_ref "flag_pic && ! TARGET_EMBEDDED_PIC")
9345 (lt (abs (minus (match_dup 0)
9346 (plus (pc) (const_int 4))))
9347 (const_int 131072)))
9348 (const_int 4) (const_int 16)))])
9350 ;; We need a different insn for the mips16, because a mips16 branch
9351 ;; does not have a delay slot.
9355 (label_ref (match_operand 0 "" "")))]
9358 [(set_attr "type" "branch")
9359 (set_attr "mode" "none")
9360 (set_attr "length" "8")])
9362 (define_expand "indirect_jump"
9363 [(set (pc) (match_operand 0 "register_operand" "d"))]
9369 if (operands[0]) /* eliminate unused code warnings */
9372 if (GET_CODE (dest) != REG || GET_MODE (dest) != Pmode)
9373 operands[0] = copy_to_mode_reg (Pmode, dest);
9375 if (!(Pmode == DImode))
9376 emit_jump_insn (gen_indirect_jump_internal1 (operands[0]));
9378 emit_jump_insn (gen_indirect_jump_internal2 (operands[0]));
9384 (define_insn "indirect_jump_internal1"
9385 [(set (pc) (match_operand:SI 0 "register_operand" "d"))]
9386 "!(Pmode == DImode)"
9388 [(set_attr "type" "jump")
9389 (set_attr "mode" "none")])
9391 (define_insn "indirect_jump_internal2"
9392 [(set (pc) (match_operand:DI 0 "register_operand" "d"))]
9395 [(set_attr "type" "jump")
9396 (set_attr "mode" "none")])
9398 (define_expand "tablejump"
9400 (match_operand 0 "register_operand" "d"))
9401 (use (label_ref (match_operand 1 "" "")))]
9405 if (operands[0]) /* eliminate unused code warnings */
9409 if (GET_MODE (operands[0]) != HImode)
9411 if (!(Pmode == DImode))
9412 emit_insn (gen_tablejump_mips161 (operands[0], operands[1]));
9414 emit_insn (gen_tablejump_mips162 (operands[0], operands[1]));
9418 if (GET_MODE (operands[0]) != ptr_mode)
9422 operands[0] = expand_binop (ptr_mode, add_optab, operands[0],
9423 pic_offset_table_rtx, 0, 0, OPTAB_WIDEN);
9425 if (Pmode == SImode)
9426 emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
9428 emit_jump_insn (gen_tablejump_internal2 (operands[0], operands[1]));
9433 (define_insn "tablejump_internal1"
9435 (match_operand:SI 0 "register_operand" "d"))
9436 (use (label_ref (match_operand 1 "" "")))]
9439 [(set_attr "type" "jump")
9440 (set_attr "mode" "none")])
9442 (define_insn "tablejump_internal2"
9444 (match_operand:DI 0 "register_operand" "d"))
9445 (use (label_ref (match_operand 1 "" "")))]
9448 [(set_attr "type" "jump")
9449 (set_attr "mode" "none")])
9451 (define_expand "tablejump_mips161"
9452 [(set (pc) (plus:SI (sign_extend:SI
9453 (match_operand:HI 0 "register_operand" "d"))
9454 (label_ref:SI (match_operand 1 "" ""))))]
9455 "TARGET_MIPS16 && !(Pmode == DImode)"
9458 if (operands[0]) /* eliminate unused code warnings. */
9462 t1 = gen_reg_rtx (SImode);
9463 t2 = gen_reg_rtx (SImode);
9464 t3 = gen_reg_rtx (SImode);
9465 emit_insn (gen_extendhisi2 (t1, operands[0]));
9466 emit_move_insn (t2, gen_rtx_LABEL_REF (SImode, operands[1]));
9467 emit_insn (gen_addsi3 (t3, t1, t2));
9468 emit_jump_insn (gen_tablejump_internal1 (t3, operands[1]));
9473 (define_expand "tablejump_mips162"
9474 [(set (pc) (plus:DI (sign_extend:DI
9475 (match_operand:HI 0 "register_operand" "d"))
9476 (label_ref:DI (match_operand 1 "" ""))))]
9477 "TARGET_MIPS16 && Pmode == DImode"
9480 if (operands[0]) /* eliminate unused code warnings. */
9484 t1 = gen_reg_rtx (DImode);
9485 t2 = gen_reg_rtx (DImode);
9486 t3 = gen_reg_rtx (DImode);
9487 emit_insn (gen_extendhidi2 (t1, operands[0]));
9488 emit_move_insn (t2, gen_rtx_LABEL_REF (DImode, operands[1]));
9489 emit_insn (gen_adddi3 (t3, t1, t2));
9490 emit_jump_insn (gen_tablejump_internal2 (t3, operands[1]));
9495 ;; Implement a switch statement when generating embedded PIC code.
9496 ;; Switches are implemented by `tablejump' when not using -membedded-pic.
9498 (define_expand "casesi"
9500 (minus:SI (match_operand:SI 0 "register_operand" "d")
9501 (match_operand:SI 1 "arith_operand" "dI")))
9503 (compare:CC (match_dup 5)
9504 (match_operand:SI 2 "arith_operand" "")))
9506 (if_then_else (gtu (cc0)
9508 (label_ref (match_operand 4 "" ""))
9512 (mem:SI (plus:SI (mult:SI (match_dup 5)
9514 (label_ref (match_operand 3 "" "")))))
9515 (clobber (match_scratch:SI 6 ""))
9516 (clobber (reg:SI 31))])]
9517 "TARGET_EMBEDDED_PIC"
9522 rtx reg = gen_reg_rtx (SImode);
9524 /* If the index is too large, go to the default label. */
9525 emit_insn (gen_subsi3 (reg, operands[0], operands[1]));
9526 emit_insn (gen_cmpsi (reg, operands[2]));
9527 emit_insn (gen_bgtu (operands[4]));
9529 /* Do the PIC jump. */
9530 if (Pmode != DImode)
9531 emit_jump_insn (gen_casesi_internal (reg, operands[3],
9532 gen_reg_rtx (SImode)));
9534 emit_jump_insn (gen_casesi_internal_di (reg, operands[3],
9535 gen_reg_rtx (DImode)));
9541 ;; An embedded PIC switch statement looks like this:
9543 ;; sll $reg,$index,2
9545 ;; addu $reg,$reg,$31
9546 ;; lw $reg,$L1-$LS1($reg)
9547 ;; addu $reg,$reg,$31
9554 (define_insn "casesi_internal"
9556 (mem:SI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "d")
9558 (label_ref (match_operand 1 "" "")))))
9559 (clobber (match_operand:SI 2 "register_operand" "=d"))
9560 (clobber (reg:SI 31))]
9561 "TARGET_EMBEDDED_PIC"
9562 "%(bal\\t%S1\;sll\\t%2,%0,2\\n%~%S1:\;addu\\t%2,%2,$31%)\;\\
9563 lw\\t%2,%1-%S1(%2)\;addu\\t%2,%2,$31\\n\\t%*j\\t%2"
9564 [(set_attr "type" "jump")
9565 (set_attr "mode" "none")
9566 (set_attr "length" "24")])
9568 ;; This code assumes that the table index will never be >= 29 bits wide,
9569 ;; which allows the 'sign extend' from SI to DI be a no-op.
9570 (define_insn "casesi_internal_di"
9572 (mem:DI (plus:DI (sign_extend:DI
9573 (mult:SI (match_operand:SI 0 "register_operand" "d")
9575 (label_ref (match_operand 1 "" "")))))
9576 (clobber (match_operand:DI 2 "register_operand" "=d"))
9577 (clobber (reg:DI 31))]
9578 "TARGET_EMBEDDED_PIC"
9579 "%(bal\\t%S1\;sll\\t%2,%0,3\\n%~%S1:\;daddu\\t%2,%2,$31%)\;\\
9580 ld\\t%2,%1-%S1(%2)\;daddu\\t%2,%2,$31\\n\\t%*j\\t%2"
9581 [(set_attr "type" "jump")
9582 (set_attr "mode" "none")
9583 (set_attr "length" "24")])
9585 ;; For o32/n32/n64, we save the gp in the jmp_buf as well. While it is
9586 ;; possible to either pull it off the stack (in the o32 case) or recalculate
9587 ;; it given t9 and our target label, it takes 3 or 4 insns to do so, and
9590 (define_expand "builtin_setjmp_setup"
9591 [(unspec [(match_operand 0 "register_operand" "r")] UNSPEC_SETJMP)]
9595 if (Pmode == DImode)
9596 emit_insn (gen_builtin_setjmp_setup_64 (operands[0]));
9598 emit_insn (gen_builtin_setjmp_setup_32 (operands[0]));
9602 (define_expand "builtin_setjmp_setup_32"
9603 [(set (mem:SI (plus:SI (match_operand:SI 0 "register_operand" "r")
9606 "TARGET_ABICALLS && ! (Pmode == DImode)"
9609 (define_expand "builtin_setjmp_setup_64"
9610 [(set (mem:DI (plus:DI (match_operand:DI 0 "register_operand" "r")
9613 "TARGET_ABICALLS && Pmode == DImode"
9616 ;; For o32/n32/n64, we need to arrange for longjmp to put the
9617 ;; target address in t9 so that we can use it for loading $gp.
9619 (define_expand "builtin_longjmp"
9620 [(unspec_volatile [(match_operand 0 "register_operand" "r")] UNSPEC_LONGJMP)]
9624 /* The elements of the buffer are, in order: */
9625 int W = (Pmode == DImode ? 8 : 4);
9626 rtx fp = gen_rtx_MEM (Pmode, operands[0]);
9627 rtx lab = gen_rtx_MEM (Pmode, plus_constant (operands[0], 1*W));
9628 rtx stack = gen_rtx_MEM (Pmode, plus_constant (operands[0], 2*W));
9629 rtx gpv = gen_rtx_MEM (Pmode, plus_constant (operands[0], 3*W));
9630 rtx pv = gen_rtx_REG (Pmode, 25);
9631 rtx gp = gen_rtx_REG (Pmode, 28);
9633 /* This bit is the same as expand_builtin_longjmp. */
9634 emit_move_insn (hard_frame_pointer_rtx, fp);
9635 emit_move_insn (pv, lab);
9636 emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
9637 emit_move_insn (gp, gpv);
9638 emit_insn (gen_rtx_USE (VOIDmode, hard_frame_pointer_rtx));
9639 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
9640 emit_insn (gen_rtx_USE (VOIDmode, gp));
9641 emit_indirect_jump (pv);
9646 ;; ....................
9648 ;; Function prologue/epilogue
9650 ;; ....................
9653 (define_expand "prologue"
9658 if (mips_isa >= 0) /* avoid unused code warnings */
9660 mips_expand_prologue ();
9665 ;; Block any insns from being moved before this point, since the
9666 ;; profiling call to mcount can use various registers that aren't
9667 ;; saved or used to pass arguments.
9669 (define_insn "blockage"
9670 [(unspec_volatile [(const_int 0)] UNSPEC_BLOCKAGE)]
9673 [(set_attr "type" "unknown")
9674 (set_attr "mode" "none")
9675 (set_attr "length" "0")])
9677 (define_expand "epilogue"
9681 mips_expand_epilogue (false);
9685 (define_expand "sibcall_epilogue"
9689 mips_expand_epilogue (true);
9693 ;; Trivial return. Make it look like a normal return insn as that
9694 ;; allows jump optimizations to work better .
9695 (define_insn "return"
9697 "mips_can_use_return_insn ()"
9699 [(set_attr "type" "jump")
9700 (set_attr "mode" "none")])
9704 (define_insn "return_internal"
9705 [(use (match_operand 0 "pmode_register_operand" ""))
9710 return \"%*j\\t%0\";
9712 [(set_attr "type" "jump")
9713 (set_attr "mode" "none")])
9715 ;; When generating embedded PIC code we need to get the address of the
9716 ;; current function. This specialized instruction does just that.
9718 (define_insn "get_fnaddr"
9719 [(set (match_operand 0 "register_operand" "=d")
9720 (unspec [(match_operand 1 "" "")] UNSPEC_GET_FNADDR))
9721 (clobber (reg:SI 31))]
9722 "TARGET_EMBEDDED_PIC
9723 && GET_CODE (operands[1]) == SYMBOL_REF"
9724 "%($LF%= = . + 8\;bal\\t$LF%=\;nop;la\\t%0,%1-$LF%=%)\;addu\\t%0,%0,$31"
9725 [(set_attr "type" "call")
9726 (set_attr "mode" "none")
9727 (set_attr "length" "20")])
9729 ;; This is used in compiling the unwind routines.
9730 (define_expand "eh_return"
9731 [(use (match_operand 0 "general_operand" ""))]
9735 enum machine_mode gpr_mode = TARGET_64BIT ? DImode : SImode;
9737 if (GET_MODE (operands[0]) != gpr_mode)
9738 operands[0] = convert_to_mode (gpr_mode, operands[0], 0);
9740 emit_insn (gen_eh_set_lr_di (operands[0]));
9742 emit_insn (gen_eh_set_lr_si (operands[0]));
9747 ;; Clobber the return address on the stack. We can't expand this
9748 ;; until we know where it will be put in the stack frame.
9750 (define_insn "eh_set_lr_si"
9751 [(unspec [(match_operand:SI 0 "register_operand" "d")] UNSPEC_EH_RETURN)
9752 (clobber (match_scratch:SI 1 "=&d"))]
9756 (define_insn "eh_set_lr_di"
9757 [(unspec [(match_operand:DI 0 "register_operand" "d")] UNSPEC_EH_RETURN)
9758 (clobber (match_scratch:DI 1 "=&d"))]
9763 [(unspec [(match_operand 0 "register_operand" "")] UNSPEC_EH_RETURN)
9764 (clobber (match_scratch 1 ""))]
9765 "reload_completed && !TARGET_DEBUG_D_MODE"
9769 mips_set_return_address (operands[0], operands[1]);
9773 (define_insn "exception_receiver"
9774 [(unspec_volatile [(const_int 0)] UNSPEC_EH_RECEIVER)]
9775 "TARGET_ABICALLS && (mips_abi == ABI_32 || mips_abi == ABI_O64)"
9776 { return mips_restore_gp (operands); }
9777 [(set_attr "type" "load")
9778 (set_attr "length" "8")])
9781 ;; ....................
9785 ;; ....................
9787 ;; Sibling calls. All these patterns use direct jumps.
9789 ;; call_insn_operand will only accepts constant addresses if a direct
9790 ;; jump is acceptable. Since the 'S' constraint is defined in terms of
9791 ;; call_insn_operand, the same is true of the contraints.
9793 ;; When we use an indirect jump, we need a register that will be
9794 ;; preserved by the epilogue. Since TARGET_ABICALLS forces us to
9795 ;; use $25 for this purpose -- and $25 is never clobbered by the
9796 ;; epilogue -- we might as well use it for !TARGET_ABICALLS as well.
9798 (define_expand "sibcall"
9799 [(parallel [(call (match_operand 0 "" "")
9800 (match_operand 1 "" ""))
9801 (use (match_operand 2 "" "")) ;; next_arg_reg
9802 (use (match_operand 3 "" ""))])] ;; struct_value_size_rtx
9805 mips_expand_call (0, XEXP (operands[0], 0), operands[1], operands[2], true);
9809 (define_insn "sibcall_internal"
9810 [(call (mem:SI (match_operand 0 "call_insn_operand" "j,S"))
9811 (match_operand 1 "" ""))]
9812 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
9816 [(set_attr "type" "call")])
9818 (define_expand "sibcall_value"
9819 [(parallel [(set (match_operand 0 "" "")
9820 (call (match_operand 1 "" "")
9821 (match_operand 2 "" "")))
9822 (use (match_operand 3 "" ""))])] ;; next_arg_reg
9825 mips_expand_call (operands[0], XEXP (operands[1], 0),
9826 operands[2], operands[3], true);
9830 (define_insn "sibcall_value_internal"
9831 [(set (match_operand 0 "register_operand" "=df,df")
9832 (call (mem:SI (match_operand 1 "call_insn_operand" "j,S"))
9833 (match_operand 2 "" "")))]
9834 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
9838 [(set_attr "type" "call")])
9840 (define_insn "sibcall_value_multiple_internal"
9841 [(set (match_operand 0 "register_operand" "=df,df")
9842 (call (mem:SI (match_operand 1 "call_insn_operand" "j,S"))
9843 (match_operand 2 "" "")))
9844 (set (match_operand 3 "register_operand" "=df,df")
9845 (call (mem:SI (match_dup 1))
9847 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
9851 [(set_attr "type" "call")])
9853 (define_expand "call"
9854 [(parallel [(call (match_operand 0 "" "")
9855 (match_operand 1 "" ""))
9856 (use (match_operand 2 "" "")) ;; next_arg_reg
9857 (use (match_operand 3 "" ""))])] ;; struct_value_size_rtx
9860 mips_expand_call (0, XEXP (operands[0], 0), operands[1], operands[2], false);
9864 (define_insn_and_split "call_internal"
9865 [(call (mem:SI (match_operand 0 "call_insn_operand" "c,S"))
9866 (match_operand 1 "" ""))
9867 (clobber (reg:SI 31))]
9870 "reload_completed && TARGET_SPLIT_CALLS"
9873 emit_call_insn (gen_call_split (operands[0], operands[1]));
9874 emit_insn (gen_exception_receiver ());
9877 [(set_attr "jal" "indirect,direct")
9878 (set_attr "extended_mips16" "no,yes")])
9880 (define_insn "call_split"
9881 [(call (mem:SI (match_operand 0 "call_insn_operand" "c"))
9882 (match_operand 1 "" ""))
9883 (clobber (reg:SI 31))
9885 "TARGET_SPLIT_CALLS"
9887 [(set_attr "type" "call")])
9889 (define_expand "call_value"
9890 [(parallel [(set (match_operand 0 "" "")
9891 (call (match_operand 1 "" "")
9892 (match_operand 2 "" "")))
9893 (use (match_operand 3 "" ""))])] ;; next_arg_reg
9896 mips_expand_call (operands[0], XEXP (operands[1], 0),
9897 operands[2], operands[3], false);
9901 (define_insn_and_split "call_value_internal"
9902 [(set (match_operand 0 "register_operand" "=df,df")
9903 (call (mem:SI (match_operand 1 "call_insn_operand" "c,S"))
9904 (match_operand 2 "" "")))
9905 (clobber (reg:SI 31))]
9908 "reload_completed && TARGET_SPLIT_CALLS"
9911 emit_call_insn (gen_call_value_split (operands[0], operands[1],
9913 emit_insn (gen_exception_receiver ());
9916 [(set_attr "jal" "indirect,direct")
9917 (set_attr "extended_mips16" "no,yes")])
9919 (define_insn "call_value_split"
9920 [(set (match_operand 0 "register_operand" "=df")
9921 (call (mem:SI (match_operand 1 "call_insn_operand" "c"))
9922 (match_operand 2 "" "")))
9923 (clobber (reg:SI 31))
9925 "TARGET_SPLIT_CALLS"
9927 [(set_attr "type" "call")])
9929 (define_insn_and_split "call_value_multiple_internal"
9930 [(set (match_operand 0 "register_operand" "=df,df")
9931 (call (mem:SI (match_operand 1 "call_insn_operand" "c,S"))
9932 (match_operand 2 "" "")))
9933 (set (match_operand 3 "register_operand" "=df,df")
9934 (call (mem:SI (match_dup 1))
9936 (clobber (reg:SI 31))]
9939 "reload_completed && TARGET_SPLIT_CALLS"
9942 emit_call_insn (gen_call_value_multiple_split (operands[0], operands[1],
9943 operands[2], operands[3]));
9944 emit_insn (gen_exception_receiver ());
9947 [(set_attr "jal" "indirect,direct")
9948 (set_attr "extended_mips16" "no,yes")])
9950 (define_insn "call_value_multiple_split"
9951 [(set (match_operand 0 "register_operand" "=df")
9952 (call (mem:SI (match_operand 1 "call_insn_operand" "c"))
9953 (match_operand 2 "" "")))
9954 (set (match_operand 3 "register_operand" "=df")
9955 (call (mem:SI (match_dup 1))
9957 (clobber (reg:SI 31))
9959 "TARGET_SPLIT_CALLS"
9961 [(set_attr "type" "call")])
9963 ;; Call subroutine returning any type.
9965 (define_expand "untyped_call"
9966 [(parallel [(call (match_operand 0 "" "")
9968 (match_operand 1 "" "")
9969 (match_operand 2 "" "")])]
9975 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
9977 for (i = 0; i < XVECLEN (operands[2], 0); i++)
9979 rtx set = XVECEXP (operands[2], 0, i);
9980 emit_move_insn (SET_DEST (set), SET_SRC (set));
9983 emit_insn (gen_blockage ());
9988 ;; ....................
9992 ;; ....................
9996 (define_expand "prefetch"
9997 [(prefetch (match_operand 0 "address_operand" "")
9998 (match_operand 1 "const_int_operand" "")
9999 (match_operand 2 "const_int_operand" ""))]
10002 if (symbolic_operand (operands[0], GET_MODE (operands[0])))
10003 operands[0] = force_reg (GET_MODE (operands[0]), operands[0]);
10006 (define_insn "prefetch_si_address"
10007 [(prefetch (plus:SI (match_operand:SI 0 "register_operand" "r")
10008 (match_operand:SI 3 "const_int_operand" "i"))
10009 (match_operand:SI 1 "const_int_operand" "n")
10010 (match_operand:SI 2 "const_int_operand" "n"))]
10011 "ISA_HAS_PREFETCH && Pmode == SImode"
10012 "* return mips_emit_prefetch (operands);"
10013 [(set_attr "type" "prefetch")])
10015 (define_insn "prefetch_si"
10016 [(prefetch (match_operand:SI 0 "register_operand" "r")
10017 (match_operand:SI 1 "const_int_operand" "n")
10018 (match_operand:SI 2 "const_int_operand" "n"))]
10019 "ISA_HAS_PREFETCH && Pmode == SImode"
10020 "* return mips_emit_prefetch (operands);"
10021 [(set_attr "type" "prefetch")])
10023 (define_insn "prefetch_di_address"
10024 [(prefetch (plus:DI (match_operand:DI 0 "register_operand" "r")
10025 (match_operand:DI 3 "const_int_operand" "i"))
10026 (match_operand:DI 1 "const_int_operand" "n")
10027 (match_operand:DI 2 "const_int_operand" "n"))]
10028 "ISA_HAS_PREFETCH && Pmode == DImode"
10029 "* return mips_emit_prefetch (operands);"
10030 [(set_attr "type" "prefetch")])
10032 (define_insn "prefetch_di"
10033 [(prefetch (match_operand:DI 0 "register_operand" "r")
10034 (match_operand:DI 1 "const_int_operand" "n")
10035 (match_operand:DI 2 "const_int_operand" "n"))]
10036 "ISA_HAS_PREFETCH && Pmode == DImode"
10037 "* return mips_emit_prefetch (operands);"
10038 [(set_attr "type" "prefetch")])
10044 [(set_attr "type" "nop")
10045 (set_attr "mode" "none")])
10047 ;; The MIPS chip does not seem to require stack probes.
10049 ;; (define_expand "probe"
10050 ;; [(set (match_dup 0)
10055 ;; operands[0] = gen_reg_rtx (SImode);
10056 ;; operands[1] = gen_rtx_MEM (SImode, stack_pointer_rtx);
10057 ;; MEM_VOLATILE_P (operands[1]) = TRUE;
10059 ;; /* fall through and generate default code */
10064 ;; MIPS4 Conditional move instructions.
10067 [(set (match_operand:SI 0 "register_operand" "=d,d")
10069 (match_operator 4 "equality_op"
10070 [(match_operand:SI 1 "register_operand" "d,d")
10072 (match_operand:SI 2 "reg_or_0_operand" "dJ,0")
10073 (match_operand:SI 3 "reg_or_0_operand" "0,dJ")))]
10074 "ISA_HAS_CONDMOVE || ISA_HAS_INT_CONDMOVE"
10077 mov%b4\\t%0,%z3,%1"
10078 [(set_attr "type" "move")
10079 (set_attr "mode" "SI")])
10082 [(set (match_operand:SI 0 "register_operand" "=d,d")
10084 (match_operator 4 "equality_op"
10085 [(match_operand:DI 1 "register_operand" "d,d")
10087 (match_operand:SI 2 "reg_or_0_operand" "dJ,0")
10088 (match_operand:SI 3 "reg_or_0_operand" "0,dJ")))]
10089 "ISA_HAS_CONDMOVE || ISA_HAS_INT_CONDMOVE"
10092 mov%b4\\t%0,%z3,%1"
10093 [(set_attr "type" "move")
10094 (set_attr "mode" "SI")])
10097 [(set (match_operand:SI 0 "register_operand" "=d,d")
10099 (match_operator 3 "equality_op" [(match_operand:CC 4
10103 (match_operand:SI 1 "reg_or_0_operand" "dJ,0")
10104 (match_operand:SI 2 "reg_or_0_operand" "0,dJ")))]
10105 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT"
10108 mov%t3\\t%0,%z2,%4"
10109 [(set_attr "type" "move")
10110 (set_attr "mode" "SI")])
10113 [(set (match_operand:DI 0 "register_operand" "=d,d")
10115 (match_operator 4 "equality_op"
10116 [(match_operand:SI 1 "register_operand" "d,d")
10118 (match_operand:DI 2 "reg_or_0_operand" "dJ,0")
10119 (match_operand:DI 3 "reg_or_0_operand" "0,dJ")))]
10120 "(ISA_HAS_CONDMOVE || ISA_HAS_INT_CONDMOVE) && TARGET_64BIT"
10123 mov%b4\\t%0,%z3,%1"
10124 [(set_attr "type" "move")
10125 (set_attr "mode" "DI")])
10128 [(set (match_operand:DI 0 "register_operand" "=d,d")
10130 (match_operator 4 "equality_op"
10131 [(match_operand:DI 1 "register_operand" "d,d")
10133 (match_operand:DI 2 "reg_or_0_operand" "dJ,0")
10134 (match_operand:DI 3 "reg_or_0_operand" "0,dJ")))]
10135 "(ISA_HAS_CONDMOVE || ISA_HAS_INT_CONDMOVE) && TARGET_64BIT"
10138 mov%b4\\t%0,%z3,%1"
10139 [(set_attr "type" "move")
10140 (set_attr "mode" "DI")])
10143 [(set (match_operand:DI 0 "register_operand" "=d,d")
10145 (match_operator 3 "equality_op" [(match_operand:CC 4
10149 (match_operand:DI 1 "reg_or_0_operand" "dJ,0")
10150 (match_operand:DI 2 "reg_or_0_operand" "0,dJ")))]
10151 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT && TARGET_64BIT"
10154 mov%t3\\t%0,%z2,%4"
10155 [(set_attr "type" "move")
10156 (set_attr "mode" "DI")])
10159 [(set (match_operand:SF 0 "register_operand" "=f,f")
10161 (match_operator 4 "equality_op"
10162 [(match_operand:SI 1 "register_operand" "d,d")
10164 (match_operand:SF 2 "register_operand" "f,0")
10165 (match_operand:SF 3 "register_operand" "0,f")))]
10166 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT"
10168 mov%B4.s\\t%0,%2,%1
10169 mov%b4.s\\t%0,%3,%1"
10170 [(set_attr "type" "move")
10171 (set_attr "mode" "SF")])
10174 [(set (match_operand:SF 0 "register_operand" "=f,f")
10176 (match_operator 4 "equality_op"
10177 [(match_operand:DI 1 "register_operand" "d,d")
10179 (match_operand:SF 2 "register_operand" "f,0")
10180 (match_operand:SF 3 "register_operand" "0,f")))]
10181 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT"
10183 mov%B4.s\\t%0,%2,%1
10184 mov%b4.s\\t%0,%3,%1"
10185 [(set_attr "type" "move")
10186 (set_attr "mode" "SF")])
10189 [(set (match_operand:SF 0 "register_operand" "=f,f")
10191 (match_operator 3 "equality_op" [(match_operand:CC 4
10195 (match_operand:SF 1 "register_operand" "f,0")
10196 (match_operand:SF 2 "register_operand" "0,f")))]
10197 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT"
10199 mov%T3.s\\t%0,%1,%4
10200 mov%t3.s\\t%0,%2,%4"
10201 [(set_attr "type" "move")
10202 (set_attr "mode" "SF")])
10205 [(set (match_operand:DF 0 "register_operand" "=f,f")
10207 (match_operator 4 "equality_op"
10208 [(match_operand:SI 1 "register_operand" "d,d")
10210 (match_operand:DF 2 "register_operand" "f,0")
10211 (match_operand:DF 3 "register_operand" "0,f")))]
10212 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
10214 mov%B4.d\\t%0,%2,%1
10215 mov%b4.d\\t%0,%3,%1"
10216 [(set_attr "type" "move")
10217 (set_attr "mode" "DF")])
10220 [(set (match_operand:DF 0 "register_operand" "=f,f")
10222 (match_operator 4 "equality_op"
10223 [(match_operand:DI 1 "register_operand" "d,d")
10225 (match_operand:DF 2 "register_operand" "f,0")
10226 (match_operand:DF 3 "register_operand" "0,f")))]
10227 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
10229 mov%B4.d\\t%0,%2,%1
10230 mov%b4.d\\t%0,%3,%1"
10231 [(set_attr "type" "move")
10232 (set_attr "mode" "DF")])
10235 [(set (match_operand:DF 0 "register_operand" "=f,f")
10237 (match_operator 3 "equality_op" [(match_operand:CC 4
10241 (match_operand:DF 1 "register_operand" "f,0")
10242 (match_operand:DF 2 "register_operand" "0,f")))]
10243 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
10245 mov%T3.d\\t%0,%1,%4
10246 mov%t3.d\\t%0,%2,%4"
10247 [(set_attr "type" "move")
10248 (set_attr "mode" "DF")])
10250 ;; These are the main define_expand's used to make conditional moves.
10252 (define_expand "movsicc"
10253 [(set (match_dup 4) (match_operand 1 "comparison_operator" ""))
10254 (set (match_operand:SI 0 "register_operand" "")
10255 (if_then_else:SI (match_dup 5)
10256 (match_operand:SI 2 "reg_or_0_operand" "")
10257 (match_operand:SI 3 "reg_or_0_operand" "")))]
10258 "ISA_HAS_CONDMOVE || ISA_HAS_INT_CONDMOVE"
10261 gen_conditional_move (operands);
10265 (define_expand "movdicc"
10266 [(set (match_dup 4) (match_operand 1 "comparison_operator" ""))
10267 (set (match_operand:DI 0 "register_operand" "")
10268 (if_then_else:DI (match_dup 5)
10269 (match_operand:DI 2 "reg_or_0_operand" "")
10270 (match_operand:DI 3 "reg_or_0_operand" "")))]
10271 "(ISA_HAS_CONDMOVE || ISA_HAS_INT_CONDMOVE) && TARGET_64BIT"
10274 gen_conditional_move (operands);
10278 (define_expand "movsfcc"
10279 [(set (match_dup 4) (match_operand 1 "comparison_operator" ""))
10280 (set (match_operand:SF 0 "register_operand" "")
10281 (if_then_else:SF (match_dup 5)
10282 (match_operand:SF 2 "register_operand" "")
10283 (match_operand:SF 3 "register_operand" "")))]
10284 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT"
10287 gen_conditional_move (operands);
10291 (define_expand "movdfcc"
10292 [(set (match_dup 4) (match_operand 1 "comparison_operator" ""))
10293 (set (match_operand:DF 0 "register_operand" "")
10294 (if_then_else:DF (match_dup 5)
10295 (match_operand:DF 2 "register_operand" "")
10296 (match_operand:DF 3 "register_operand" "")))]
10297 "ISA_HAS_CONDMOVE && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
10300 gen_conditional_move (operands);
10305 ;; ....................
10307 ;; mips16 inline constant tables
10309 ;; ....................
10312 (define_insn "consttable_qi"
10313 [(unspec_volatile [(match_operand:QI 0 "consttable_operand" "=g")]
10314 UNSPEC_CONSTTABLE_QI)]
10318 assemble_integer (operands[0], 1, BITS_PER_UNIT, 1);
10321 [(set_attr "type" "unknown")
10322 (set_attr "mode" "QI")
10323 (set_attr "length" "8")])
10325 (define_insn "consttable_hi"
10326 [(unspec_volatile [(match_operand:HI 0 "consttable_operand" "=g")]
10327 UNSPEC_CONSTTABLE_HI)]
10331 assemble_integer (operands[0], 2, BITS_PER_UNIT * 2, 1);
10334 [(set_attr "type" "unknown")
10335 (set_attr "mode" "HI")
10336 (set_attr "length" "8")])
10338 (define_insn "consttable_si"
10339 [(unspec_volatile [(match_operand:SI 0 "consttable_operand" "=g")]
10340 UNSPEC_CONSTTABLE_SI)]
10344 assemble_integer (operands[0], 4, BITS_PER_UNIT * 4, 1);
10347 [(set_attr "type" "unknown")
10348 (set_attr "mode" "SI")
10349 (set_attr "length" "8")])
10351 (define_insn "consttable_di"
10352 [(unspec_volatile [(match_operand:DI 0 "consttable_operand" "=g")]
10353 UNSPEC_CONSTTABLE_DI)]
10357 assemble_integer (operands[0], 8, BITS_PER_UNIT * 8, 1);
10360 [(set_attr "type" "unknown")
10361 (set_attr "mode" "DI")
10362 (set_attr "length" "16")])
10364 (define_insn "consttable_sf"
10365 [(unspec_volatile [(match_operand:SF 0 "consttable_operand" "=g")]
10366 UNSPEC_CONSTTABLE_SF)]
10372 if (GET_CODE (operands[0]) != CONST_DOUBLE)
10374 REAL_VALUE_FROM_CONST_DOUBLE (d, operands[0]);
10375 assemble_real (d, SFmode, GET_MODE_ALIGNMENT (SFmode));
10378 [(set_attr "type" "unknown")
10379 (set_attr "mode" "SF")
10380 (set_attr "length" "8")])
10382 (define_insn "consttable_df"
10383 [(unspec_volatile [(match_operand:DF 0 "consttable_operand" "=g")]
10384 UNSPEC_CONSTTABLE_DF)]
10390 if (GET_CODE (operands[0]) != CONST_DOUBLE)
10392 REAL_VALUE_FROM_CONST_DOUBLE (d, operands[0]);
10393 assemble_real (d, DFmode, GET_MODE_ALIGNMENT (DFmode));
10396 [(set_attr "type" "unknown")
10397 (set_attr "mode" "DF")
10398 (set_attr "length" "16")])
10400 (define_insn "align_2"
10401 [(unspec_volatile [(const_int 0)] UNSPEC_ALIGN_2)]
10404 [(set_attr "type" "unknown")
10405 (set_attr "mode" "HI")
10406 (set_attr "length" "8")])
10408 (define_insn "align_4"
10409 [(unspec_volatile [(const_int 0)] UNSPEC_ALIGN_4)]
10412 [(set_attr "type" "unknown")
10413 (set_attr "mode" "SI")
10414 (set_attr "length" "8")])
10416 (define_insn "align_8"
10417 [(unspec_volatile [(const_int 0)] UNSPEC_ALIGN_8)]
10420 [(set_attr "type" "unknown")
10421 (set_attr "mode" "DI")
10422 (set_attr "length" "12")])
10425 ;; ....................
10427 ;; mips16 peepholes
10429 ;; ....................
10432 ;; On the mips16, reload will sometimes decide that a pseudo register
10433 ;; should go into $24, and then later on have to reload that register.
10434 ;; When that happens, we get a load of a general register followed by
10435 ;; a move from the general register to $24 followed by a branch.
10436 ;; These peepholes catch the common case, and fix it to just use the
10437 ;; general register for the branch.
10440 [(set (match_operand:SI 0 "register_operand" "=t")
10441 (match_operand:SI 1 "register_operand" "d"))
10443 (if_then_else (match_operator:SI 2 "equality_op" [(match_dup 0)
10445 (match_operand 3 "pc_or_label_operand" "")
10446 (match_operand 4 "pc_or_label_operand" "")))]
10448 && GET_CODE (operands[0]) == REG
10449 && REGNO (operands[0]) == 24
10450 && dead_or_set_p (insn, operands[0])
10451 && GET_CODE (operands[1]) == REG
10452 && M16_REG_P (REGNO (operands[1]))"
10455 if (operands[3] != pc_rtx)
10456 return \"%*b%C2z\\t%1,%3\";
10458 return \"%*b%N2z\\t%1,%4\";
10460 [(set_attr "type" "branch")
10461 (set_attr "mode" "none")
10462 (set_attr "length" "8")])
10465 [(set (match_operand:DI 0 "register_operand" "=t")
10466 (match_operand:DI 1 "register_operand" "d"))
10468 (if_then_else (match_operator:DI 2 "equality_op" [(match_dup 0)
10470 (match_operand 3 "pc_or_label_operand" "")
10471 (match_operand 4 "pc_or_label_operand" "")))]
10472 "TARGET_MIPS16 && TARGET_64BIT
10473 && GET_CODE (operands[0]) == REG
10474 && REGNO (operands[0]) == 24
10475 && dead_or_set_p (insn, operands[0])
10476 && GET_CODE (operands[1]) == REG
10477 && M16_REG_P (REGNO (operands[1]))"
10480 if (operands[3] != pc_rtx)
10481 return \"%*b%C2z\\t%1,%3\";
10483 return \"%*b%N2z\\t%1,%4\";
10485 [(set_attr "type" "branch")
10486 (set_attr "mode" "none")
10487 (set_attr "length" "8")])
10489 ;; We can also have the reverse reload: reload will spill $24 into
10490 ;; another register, and then do a branch on that register when it
10491 ;; could have just stuck with $24.
10494 [(set (match_operand:SI 0 "register_operand" "=d")
10495 (match_operand:SI 1 "register_operand" "t"))
10497 (if_then_else (match_operator:SI 2 "equality_op" [(match_dup 0)
10499 (match_operand 3 "pc_or_label_operand" "")
10500 (match_operand 4 "pc_or_label_operand" "")))]
10502 && GET_CODE (operands[1]) == REG
10503 && REGNO (operands[1]) == 24
10504 && GET_CODE (operands[0]) == REG
10505 && M16_REG_P (REGNO (operands[0]))
10506 && dead_or_set_p (insn, operands[0])"
10509 if (operands[3] != pc_rtx)
10510 return \"%*bt%C2z\\t%3\";
10512 return \"%*bt%N2z\\t%4\";
10514 [(set_attr "type" "branch")
10515 (set_attr "mode" "none")
10516 (set_attr "length" "8")])
10519 [(set (match_operand:DI 0 "register_operand" "=d")
10520 (match_operand:DI 1 "register_operand" "t"))
10522 (if_then_else (match_operator:DI 2 "equality_op" [(match_dup 0)
10524 (match_operand 3 "pc_or_label_operand" "")
10525 (match_operand 4 "pc_or_label_operand" "")))]
10526 "TARGET_MIPS16 && TARGET_64BIT
10527 && GET_CODE (operands[1]) == REG
10528 && REGNO (operands[1]) == 24
10529 && GET_CODE (operands[0]) == REG
10530 && M16_REG_P (REGNO (operands[0]))
10531 && dead_or_set_p (insn, operands[0])"
10534 if (operands[3] != pc_rtx)
10535 return \"%*bt%C2z\\t%3\";
10537 return \"%*bt%N2z\\t%4\";
10539 [(set_attr "type" "branch")
10540 (set_attr "mode" "none")
10541 (set_attr "length" "8")])