1 ;; Mips.md Machine Description for MIPS based processors
2 ;; Copyright (C) 1989-2013 Free Software Foundation, Inc.
3 ;; Contributed by A. Lichnewsky, lich@inria.inria.fr
4 ;; Changes by Michael Meissner, meissner@osf.org
5 ;; 64-bit r4000 support by Ian Lance Taylor, ian@cygnus.com, and
6 ;; Brendan Eich, brendan@microunity.com.
8 ;; This file is part of GCC.
10 ;; GCC is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 3, or (at your option)
15 ;; GCC is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GCC; see the file COPYING3. If not see
22 ;; <http://www.gnu.org/licenses/>.
24 (define_enum "processor" [
69 (define_c_enum "unspec" [
70 ;; Unaligned accesses.
76 ;; Integer operations that are too cumbersome to describe directly.
81 ;; Floating-point moves.
97 UNSPEC_POTENTIAL_CPRESTORE
102 UNSPEC_SET_GOT_VERSION
103 UNSPEC_UPDATE_GOT_VERSION
105 ;; Symbolic accesses.
110 UNSPEC_UNSHIFTED_HIGH
112 ;; MIPS16 constant pools.
114 UNSPEC_CONSTTABLE_INT
115 UNSPEC_CONSTTABLE_FLOAT
117 ;; Blockage and synchronisation.
124 ;; Cache manipulation.
126 UNSPEC_R10K_CACHE_BARRIER
128 ;; Interrupt handling.
136 ;; Used in a call expression in place of args_size. It's present for PIC
137 ;; indirect calls where it contains args_size and the function symbol.
140 ;; MIPS16 casesi jump table dispatch.
141 UNSPEC_CASESI_DISPATCH
144 UNSPEC_PROBE_STACK_RANGE
148 [(TLS_GET_TP_REGNUM 3)
150 (PIC_FUNCTION_ADDR_REGNUM 25)
151 (RETURN_ADDR_REGNUM 31)
152 (CPRESTORE_SLOT_REGNUM 76)
153 (GOT_VERSION_REGNUM 79)
155 ;; PIC long branch sequences are never longer than 100 bytes.
156 (MAX_PIC_BRANCH_LENGTH 100)
160 (include "predicates.md")
161 (include "constraints.md")
163 ;; ....................
167 ;; ....................
169 (define_attr "got" "unset,xgot_high,load"
170 (const_string "unset"))
172 ;; For jal instructions, this attribute is DIRECT when the target address
173 ;; is symbolic and INDIRECT when it is a register.
174 (define_attr "jal" "unset,direct,indirect"
175 (const_string "unset"))
177 ;; This attribute is YES if the instruction is a jal macro (not a
178 ;; real jal instruction).
180 ;; jal is always a macro for TARGET_CALL_CLOBBERED_GP because it includes
181 ;; an instruction to restore $gp. Direct jals are also macros for
182 ;; !TARGET_ABSOLUTE_JUMPS because they first load the target address
184 (define_attr "jal_macro" "no,yes"
185 (cond [(eq_attr "jal" "direct")
186 (symbol_ref "(TARGET_CALL_CLOBBERED_GP || !TARGET_ABSOLUTE_JUMPS
187 ? JAL_MACRO_YES : JAL_MACRO_NO)")
188 (eq_attr "jal" "indirect")
189 (symbol_ref "(TARGET_CALL_CLOBBERED_GP
190 ? JAL_MACRO_YES : JAL_MACRO_NO)")]
191 (const_string "no")))
193 ;; Classification of moves, extensions and truncations. Most values
194 ;; are as for "type" (see below) but there are also the following
195 ;; move-specific values:
197 ;; constN move an N-constraint integer into a MIPS16 register
198 ;; sll0 "sll DEST,SRC,0", which on 64-bit targets is guaranteed
199 ;; to produce a sign-extended DEST, even if SRC is not
200 ;; properly sign-extended
201 ;; ext_ins EXT, DEXT, INS or DINS instruction
202 ;; andi a single ANDI instruction
203 ;; loadpool move a constant into a MIPS16 register by loading it
205 ;; shift_shift a shift left followed by a shift right
207 ;; This attribute is used to determine the instruction's length and
208 ;; scheduling type. For doubleword moves, the attribute always describes
209 ;; the split instructions; in some cases, it is more appropriate for the
210 ;; scheduling type to be "multi" instead.
211 (define_attr "move_type"
212 "unknown,load,fpload,store,fpstore,mtc,mfc,mtlo,mflo,imul,move,fmove,
213 const,constN,signext,ext_ins,logical,arith,sll0,andi,loadpool,
215 (const_string "unknown"))
217 (define_attr "alu_type" "unknown,add,sub,not,nor,and,or,xor"
218 (const_string "unknown"))
220 ;; Main data type used by the insn
221 (define_attr "mode" "unknown,none,QI,HI,SI,DI,TI,SF,DF,TF,FPSW"
222 (const_string "unknown"))
224 ;; True if the main data type is twice the size of a word.
225 (define_attr "dword_mode" "no,yes"
226 (cond [(and (eq_attr "mode" "DI,DF")
227 (not (match_test "TARGET_64BIT")))
230 (and (eq_attr "mode" "TI,TF")
231 (match_test "TARGET_64BIT"))
232 (const_string "yes")]
233 (const_string "no")))
235 ;; Attributes describing a sync loop. These loops have the form:
237 ;; if (RELEASE_BARRIER == YES) sync
239 ;; if ((OLDVAL & INCLUSIVE_MASK) != REQUIRED_OLDVAL) goto 2
240 ;; CMP = 0 [delay slot]
241 ;; $TMP1 = OLDVAL & EXCLUSIVE_MASK
242 ;; $TMP2 = INSN1 (OLDVAL, INSN1_OP2)
243 ;; $TMP3 = INSN2 ($TMP2, INCLUSIVE_MASK)
244 ;; $AT |= $TMP1 | $TMP3
245 ;; if (!commit (*MEM = $AT)) goto 1.
246 ;; if (INSN1 != MOVE && INSN1 != LI) NEWVAL = $TMP3 [delay slot]
248 ;; if (ACQUIRE_BARRIER == YES) sync
251 ;; where "$" values are temporaries and where the other values are
252 ;; specified by the attributes below. Values are specified as operand
253 ;; numbers and insns are specified as enums. If no operand number is
254 ;; specified, the following values are used instead:
259 ;; - INCLUSIVE_MASK: -1
260 ;; - REQUIRED_OLDVAL: OLDVAL & INCLUSIVE_MASK
261 ;; - EXCLUSIVE_MASK: 0
263 ;; MEM and INSN1_OP2 are required.
265 ;; Ideally, the operand attributes would be integers, with -1 meaning "none",
266 ;; but the gen* programs don't yet support that.
267 (define_attr "sync_mem" "none,0,1,2,3,4,5" (const_string "none"))
268 (define_attr "sync_oldval" "none,0,1,2,3,4,5" (const_string "none"))
269 (define_attr "sync_cmp" "none,0,1,2,3,4,5" (const_string "none"))
270 (define_attr "sync_newval" "none,0,1,2,3,4,5" (const_string "none"))
271 (define_attr "sync_inclusive_mask" "none,0,1,2,3,4,5" (const_string "none"))
272 (define_attr "sync_exclusive_mask" "none,0,1,2,3,4,5" (const_string "none"))
273 (define_attr "sync_required_oldval" "none,0,1,2,3,4,5" (const_string "none"))
274 (define_attr "sync_insn1_op2" "none,0,1,2,3,4,5" (const_string "none"))
275 (define_attr "sync_insn1" "move,li,addu,addiu,subu,and,andi,or,ori,xor,xori"
276 (const_string "move"))
277 (define_attr "sync_insn2" "nop,and,xor,not"
278 (const_string "nop"))
279 ;; Memory model specifier.
280 ;; "0"-"9" values specify the operand that stores the memory model value.
281 ;; "10" specifies MEMMODEL_ACQ_REL,
282 ;; "11" specifies MEMMODEL_ACQUIRE.
283 (define_attr "sync_memmodel" "" (const_int 10))
285 ;; Accumulator operand for madd patterns.
286 (define_attr "accum_in" "none,0,1,2,3,4,5" (const_string "none"))
288 ;; Classification of each insn.
289 ;; branch conditional branch
290 ;; jump unconditional jump
291 ;; call unconditional call
292 ;; load load instruction(s)
293 ;; fpload floating point load
294 ;; fpidxload floating point indexed load
295 ;; store store instruction(s)
296 ;; fpstore floating point store
297 ;; fpidxstore floating point indexed store
298 ;; prefetch memory prefetch (register + offset)
299 ;; prefetchx memory indexed prefetch (register + register)
300 ;; condmove conditional moves
301 ;; mtc transfer to coprocessor
302 ;; mfc transfer from coprocessor
303 ;; mthi transfer to a hi register
304 ;; mtlo transfer to a lo register
305 ;; mfhi transfer from a hi register
306 ;; mflo transfer from a lo register
307 ;; const load constant
308 ;; arith integer arithmetic instructions
309 ;; logical integer logical instructions
310 ;; shift integer shift instructions
311 ;; slt set less than instructions
312 ;; signext sign extend instructions
313 ;; clz the clz and clo instructions
314 ;; pop the pop instruction
315 ;; trap trap if instructions
316 ;; imul integer multiply 2 operands
317 ;; imul3 integer multiply 3 operands
318 ;; imul3nc integer multiply 3 operands without clobbering HI/LO
319 ;; imadd integer multiply-add
320 ;; idiv integer divide 2 operands
321 ;; idiv3 integer divide 3 operands
322 ;; move integer register move ({,D}ADD{,U} with rt = 0)
323 ;; fmove floating point register move
324 ;; fadd floating point add/subtract
325 ;; fmul floating point multiply
326 ;; fmadd floating point multiply-add
327 ;; fdiv floating point divide
328 ;; frdiv floating point reciprocal divide
329 ;; frdiv1 floating point reciprocal divide step 1
330 ;; frdiv2 floating point reciprocal divide step 2
331 ;; fabs floating point absolute value
332 ;; fneg floating point negation
333 ;; fcmp floating point compare
334 ;; fcvt floating point convert
335 ;; fsqrt floating point square root
336 ;; frsqrt floating point reciprocal square root
337 ;; frsqrt1 floating point reciprocal square root step1
338 ;; frsqrt2 floating point reciprocal square root step2
339 ;; dspmac DSP MAC instructions not saturating the accumulator
340 ;; dspmacsat DSP MAC instructions that saturate the accumulator
341 ;; accext DSP accumulator extract instructions
342 ;; accmod DSP accumulator modify instructions
343 ;; dspalu DSP ALU instructions not saturating the result
344 ;; dspalusat DSP ALU instructions that saturate the result
345 ;; multi multiword sequence (or user asm statements)
346 ;; atomic atomic memory update instruction
347 ;; syncloop memory atomic operation implemented as a sync loop
349 ;; ghost an instruction that produces no real code
351 "unknown,branch,jump,call,load,fpload,fpidxload,store,fpstore,fpidxstore,
352 prefetch,prefetchx,condmove,mtc,mfc,mthi,mtlo,mfhi,mflo,const,arith,logical,
353 shift,slt,signext,clz,pop,trap,imul,imul3,imul3nc,imadd,idiv,idiv3,move,
354 fmove,fadd,fmul,fmadd,fdiv,frdiv,frdiv1,frdiv2,fabs,fneg,fcmp,fcvt,fsqrt,
355 frsqrt,frsqrt1,frsqrt2,dspmac,dspmacsat,accext,accmod,dspalu,dspalusat,
356 multi,atomic,syncloop,nop,ghost"
357 (cond [(eq_attr "jal" "!unset") (const_string "call")
358 (eq_attr "got" "load") (const_string "load")
360 (eq_attr "alu_type" "add,sub") (const_string "arith")
362 (eq_attr "alu_type" "not,nor,and,or,xor") (const_string "logical")
364 ;; If a doubleword move uses these expensive instructions,
365 ;; it is usually better to schedule them in the same way
366 ;; as the singleword form, rather than as "multi".
367 (eq_attr "move_type" "load") (const_string "load")
368 (eq_attr "move_type" "fpload") (const_string "fpload")
369 (eq_attr "move_type" "store") (const_string "store")
370 (eq_attr "move_type" "fpstore") (const_string "fpstore")
371 (eq_attr "move_type" "mtc") (const_string "mtc")
372 (eq_attr "move_type" "mfc") (const_string "mfc")
373 (eq_attr "move_type" "mtlo") (const_string "mtlo")
374 (eq_attr "move_type" "mflo") (const_string "mflo")
376 ;; These types of move are always single insns.
377 (eq_attr "move_type" "imul") (const_string "imul")
378 (eq_attr "move_type" "fmove") (const_string "fmove")
379 (eq_attr "move_type" "loadpool") (const_string "load")
380 (eq_attr "move_type" "signext") (const_string "signext")
381 (eq_attr "move_type" "ext_ins") (const_string "arith")
382 (eq_attr "move_type" "arith") (const_string "arith")
383 (eq_attr "move_type" "logical") (const_string "logical")
384 (eq_attr "move_type" "sll0") (const_string "shift")
385 (eq_attr "move_type" "andi") (const_string "logical")
387 ;; These types of move are always split.
388 (eq_attr "move_type" "constN,shift_shift")
389 (const_string "multi")
391 ;; These types of move are split for doubleword modes only.
392 (and (eq_attr "move_type" "move,const")
393 (eq_attr "dword_mode" "yes"))
394 (const_string "multi")
395 (eq_attr "move_type" "move") (const_string "move")
396 (eq_attr "move_type" "const") (const_string "const")
397 (eq_attr "sync_mem" "!none") (const_string "syncloop")]
398 (const_string "unknown")))
400 ;; Mode for conversion types (fcvt)
401 ;; I2S integer to float single (SI/DI to SF)
402 ;; I2D integer to float double (SI/DI to DF)
403 ;; S2I float to integer (SF to SI/DI)
404 ;; D2I float to integer (DF to SI/DI)
405 ;; D2S double to float single
406 ;; S2D float single to double
408 (define_attr "cnv_mode" "unknown,I2S,I2D,S2I,D2I,D2S,S2D"
409 (const_string "unknown"))
411 ;; Is this an extended instruction in mips16 mode?
412 (define_attr "extended_mips16" "no,yes"
413 (if_then_else (ior (eq_attr "move_type" "sll0")
414 (eq_attr "type" "branch")
415 (eq_attr "jal" "direct"))
417 (const_string "no")))
419 ;; Length of instruction in bytes.
420 (define_attr "length" ""
421 (cond [;; Direct branch instructions have a range of [-0x20000,0x1fffc],
422 ;; relative to the address of the delay slot. If a branch is
423 ;; outside this range, we have a choice of two sequences.
424 ;; For PIC, an out-of-range branch like:
429 ;; becomes the equivalent of:
438 ;; The non-PIC case is similar except that we use a direct
439 ;; jump instead of an la/jr pair. Since the target of this
440 ;; jump is an absolute 28-bit bit address (the other bits
441 ;; coming from the address of the delay slot) this form cannot
442 ;; cross a 256MB boundary. We could provide the option of
443 ;; using la/jr in this case too, but we do not do so at
446 ;; The value we specify here does not account for the delay slot
447 ;; instruction, whose length is added separately. If the RTL
448 ;; pattern has no explicit delay slot, mips_adjust_insn_length
449 ;; will add the length of the implicit nop. The range of
450 ;; [-0x20000, 0x1fffc] from the address of the delay slot
451 ;; therefore translates to a range of:
453 ;; [-(0x20000 - sizeof (branch)), 0x1fffc - sizeof (slot)]
454 ;; == [-0x1fffc, 0x1fff8]
456 ;; from the shorten_branches reference address.
457 (and (eq_attr "type" "branch")
458 (not (match_test "TARGET_MIPS16")))
459 (cond [(and (le (minus (match_dup 0) (pc)) (const_int 131064))
460 (le (minus (pc) (match_dup 0)) (const_int 131068)))
463 ;; The non-PIC case: branch, first delay slot, and J.
464 (match_test "TARGET_ABSOLUTE_JUMPS")
467 ;; Use MAX_PIC_BRANCH_LENGTH as a (gross) overestimate.
468 ;; mips_adjust_insn_length substitutes the correct length.
470 ;; Note that we can't simply use (symbol_ref ...) here
471 ;; because genattrtab needs to know the maximum length
473 (const_int MAX_PIC_BRANCH_LENGTH))
475 ;; An unextended MIPS16 branch has a range of [-0x100, 0xfe]
476 ;; from the address of the following instruction, which leads
479 ;; [-(0x100 - sizeof (branch)), 0xfe]
482 ;; from the shorten_branches reference address. Extended branches
483 ;; likewise have a range of [-0x10000, 0xfffe] from the address
484 ;; of the following instruction, which leads to a range of:
486 ;; [-(0x10000 - sizeof (branch)), 0xfffe]
487 ;; == [-0xfffc, 0xfffe]
489 ;; from the reference address.
491 ;; When a branch is out of range, mips_reorg splits it into a form
492 ;; that uses in-range branches. There are four basic sequences:
494 ;; (1) Absolute addressing with a readable text segment
495 ;; (32-bit addresses):
498 ;; move $1,$2 2 bytes
499 ;; lw $2,label 2 bytes
501 ;; move $2,$1 2 bytes
502 ;; .align 2 0 or 2 bytes
504 ;; .word target 4 bytes
506 ;; (16 bytes in the worst case)
508 ;; (2) Absolute addressing with a readable text segment
509 ;; (64-bit addresses):
512 ;; move $1,$2 2 bytes
513 ;; ld $2,label 2 bytes
515 ;; move $2,$1 2 bytes
516 ;; .align 3 0 to 6 bytes
518 ;; .dword target 8 bytes
520 ;; (24 bytes in the worst case)
522 ;; (3) Absolute addressing without a readable text segment
523 ;; (which requires 32-bit addresses at present):
526 ;; move $1,$2 2 bytes
527 ;; lui $2,%hi(target) 4 bytes
530 ;; addiu $2,%lo(target) 4 bytes
532 ;; move $2,$1 2 bytes
536 ;; (4) PIC addressing (which requires 32-bit addresses at present):
539 ;; move $1,$2 2 bytes
540 ;; lw $2,cprestore 0, 2 or 4 bytes
541 ;; lw $2,%got(target)($2) 4 bytes
542 ;; addiu $2,%lo(target) 4 bytes
544 ;; move $2,$1 2 bytes
546 ;; (20 bytes in the worst case)
548 ;; Note that the conditions test adjusted lengths, whereas the
549 ;; result is an unadjusted length, and is thus twice the true value.
550 (and (eq_attr "type" "branch")
551 (match_test "TARGET_MIPS16"))
552 (cond [(and (le (minus (match_dup 0) (pc)) (const_int 254))
553 (le (minus (pc) (match_dup 0)) (const_int 254)))
555 (and (le (minus (match_dup 0) (pc)) (const_int 65534))
556 (le (minus (pc) (match_dup 0)) (const_int 65532)))
558 (and (match_test "TARGET_ABICALLS")
559 (not (match_test "TARGET_ABSOLUTE_ABICALLS")))
561 (match_test "Pmode == SImode")
565 (and (eq_attr "extended_mips16" "yes")
566 (match_test "TARGET_MIPS16"))
569 ;; "Ghost" instructions occupy no space.
570 (eq_attr "type" "ghost")
573 (eq_attr "got" "load")
574 (if_then_else (match_test "TARGET_MIPS16")
577 (eq_attr "got" "xgot_high")
580 ;; In general, constant-pool loads are extended instructions.
581 (eq_attr "move_type" "loadpool")
584 ;; SHIFT_SHIFTs are decomposed into two separate instructions.
585 ;; They are extended instructions on MIPS16 targets.
586 (eq_attr "move_type" "shift_shift")
587 (if_then_else (match_test "TARGET_MIPS16")
591 ;; Check for doubleword moves that are decomposed into two
593 (and (eq_attr "move_type" "mtc,mfc,mtlo,mflo,move")
594 (eq_attr "dword_mode" "yes"))
597 ;; Doubleword CONST{,N} moves are split into two word
599 (and (eq_attr "move_type" "const,constN")
600 (eq_attr "dword_mode" "yes"))
601 (symbol_ref "mips_split_const_insns (operands[1]) * 4")
603 ;; Otherwise, constants, loads and stores are handled by external
605 (eq_attr "move_type" "const,constN")
606 (symbol_ref "mips_const_insns (operands[1]) * 4")
607 (eq_attr "move_type" "load,fpload")
608 (symbol_ref "mips_load_store_insns (operands[1], insn) * 4")
609 (eq_attr "move_type" "store,fpstore")
610 (cond [(not (match_test "TARGET_FIX_24K"))
611 (symbol_ref "mips_load_store_insns (operands[0], insn) * 4")]
612 (symbol_ref "mips_load_store_insns (operands[0], insn) * 4 + 4"))
614 ;; In the worst case, a call macro will take 8 instructions:
616 ;; lui $25,%call_hi(FOO)
618 ;; lw $25,%call_lo(FOO)($25)
624 (eq_attr "jal_macro" "yes")
627 ;; Various VR4120 errata require a nop to be inserted after a macc
628 ;; instruction. The assembler does this for us, so account for
629 ;; the worst-case length here.
630 (and (eq_attr "type" "imadd")
631 (match_test "TARGET_FIX_VR4120"))
634 ;; VR4120 errata MD(4): if there are consecutive dmult instructions,
635 ;; the result of the second one is missed. The assembler should work
636 ;; around this by inserting a nop after the first dmult.
637 (and (eq_attr "type" "imul,imul3")
638 (and (eq_attr "mode" "DI")
639 (match_test "TARGET_FIX_VR4120")))
642 (eq_attr "type" "idiv,idiv3")
643 (symbol_ref "mips_idiv_insns () * 4")
645 (not (eq_attr "sync_mem" "none"))
646 (symbol_ref "mips_sync_loop_insns (insn, operands) * 4")
649 ;; Attribute describing the processor.
650 (define_enum_attr "cpu" "processor"
651 (const (symbol_ref "mips_tune")))
653 ;; The type of hardware hazard associated with this instruction.
654 ;; DELAY means that the next instruction cannot read the result
655 ;; of this one. HILO means that the next two instructions cannot
656 ;; write to HI or LO.
657 (define_attr "hazard" "none,delay,hilo"
658 (cond [(and (eq_attr "type" "load,fpload,fpidxload")
659 (match_test "ISA_HAS_LOAD_DELAY"))
660 (const_string "delay")
662 (and (eq_attr "type" "mfc,mtc")
663 (match_test "ISA_HAS_XFER_DELAY"))
664 (const_string "delay")
666 (and (eq_attr "type" "fcmp")
667 (match_test "ISA_HAS_FCMP_DELAY"))
668 (const_string "delay")
670 ;; The r4000 multiplication patterns include an mflo instruction.
671 (and (eq_attr "type" "imul")
672 (match_test "TARGET_FIX_R4000"))
673 (const_string "hilo")
675 (and (eq_attr "type" "mfhi,mflo")
676 (not (match_test "ISA_HAS_HILO_INTERLOCKS")))
677 (const_string "hilo")]
678 (const_string "none")))
680 ;; Is it a single instruction?
681 (define_attr "single_insn" "no,yes"
682 (symbol_ref "(get_attr_length (insn) == (TARGET_MIPS16 ? 2 : 4)
683 ? SINGLE_INSN_YES : SINGLE_INSN_NO)"))
685 ;; Can the instruction be put into a delay slot?
686 (define_attr "can_delay" "no,yes"
687 (if_then_else (and (eq_attr "type" "!branch,call,jump")
688 (and (eq_attr "hazard" "none")
689 (eq_attr "single_insn" "yes")))
691 (const_string "no")))
693 ;; Attribute defining whether or not we can use the branch-likely
695 (define_attr "branch_likely" "no,yes"
696 (if_then_else (match_test "GENERATE_BRANCHLIKELY")
698 (const_string "no")))
700 ;; True if an instruction might assign to hi or lo when reloaded.
701 ;; This is used by the TUNE_MACC_CHAINS code.
702 (define_attr "may_clobber_hilo" "no,yes"
703 (if_then_else (eq_attr "type" "imul,imul3,imadd,idiv,mthi,mtlo")
705 (const_string "no")))
707 ;; Describe a user's asm statement.
708 (define_asm_attributes
709 [(set_attr "type" "multi")
710 (set_attr "can_delay" "no")])
712 ;; This mode iterator allows 32-bit and 64-bit GPR patterns to be generated
713 ;; from the same template.
714 (define_mode_iterator GPR [SI (DI "TARGET_64BIT")])
716 ;; A copy of GPR that can be used when a pattern has two independent
718 (define_mode_iterator GPR2 [SI (DI "TARGET_64BIT")])
720 ;; This mode iterator allows :HILO to be used as the mode of the
721 ;; concatenated HI and LO registers.
722 (define_mode_iterator HILO [(DI "!TARGET_64BIT") (TI "TARGET_64BIT")])
724 ;; This mode iterator allows :P to be used for patterns that operate on
725 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
726 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
728 ;; This mode iterator allows :MOVECC to be used anywhere that a
729 ;; conditional-move-type condition is needed.
730 (define_mode_iterator MOVECC [SI (DI "TARGET_64BIT")
731 (CC "TARGET_HARD_FLOAT && !TARGET_LOONGSON_2EF")])
733 ;; 32-bit integer moves for which we provide move patterns.
734 (define_mode_iterator IMOVE32
743 (V4UQQ "TARGET_DSP")])
745 ;; 64-bit modes for which we provide move patterns.
746 (define_mode_iterator MOVE64
748 (V2SF "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT")
749 (V2SI "TARGET_HARD_FLOAT && TARGET_LOONGSON_VECTORS")
750 (V4HI "TARGET_HARD_FLOAT && TARGET_LOONGSON_VECTORS")
751 (V8QI "TARGET_HARD_FLOAT && TARGET_LOONGSON_VECTORS")])
753 ;; 128-bit modes for which we provide move patterns on 64-bit targets.
754 (define_mode_iterator MOVE128 [TI TF])
756 ;; This mode iterator allows the QI and HI extension patterns to be
757 ;; defined from the same template.
758 (define_mode_iterator SHORT [QI HI])
760 ;; Likewise the 64-bit truncate-and-shift patterns.
761 (define_mode_iterator SUBDI [QI HI SI])
763 ;; This mode iterator allows :ANYF to be used wherever a scalar or vector
764 ;; floating-point mode is allowed.
765 (define_mode_iterator ANYF [(SF "TARGET_HARD_FLOAT")
766 (DF "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT")
767 (V2SF "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT")])
769 ;; Like ANYF, but only applies to scalar modes.
770 (define_mode_iterator SCALARF [(SF "TARGET_HARD_FLOAT")
771 (DF "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT")])
773 ;; A floating-point mode for which moves involving FPRs may need to be split.
774 (define_mode_iterator SPLITF
775 [(DF "!TARGET_64BIT && TARGET_DOUBLE_FLOAT")
776 (DI "!TARGET_64BIT && TARGET_DOUBLE_FLOAT")
777 (V2SF "!TARGET_64BIT && TARGET_PAIRED_SINGLE_FLOAT")
778 (V2SI "!TARGET_64BIT && TARGET_LOONGSON_VECTORS")
779 (V4HI "!TARGET_64BIT && TARGET_LOONGSON_VECTORS")
780 (V8QI "!TARGET_64BIT && TARGET_LOONGSON_VECTORS")
781 (TF "TARGET_64BIT && TARGET_FLOAT64")])
783 ;; In GPR templates, a string like "<d>subu" will expand to "subu" in the
784 ;; 32-bit version and "dsubu" in the 64-bit version.
785 (define_mode_attr d [(SI "") (DI "d")
786 (QQ "") (HQ "") (SQ "") (DQ "d")
787 (UQQ "") (UHQ "") (USQ "") (UDQ "d")
788 (HA "") (SA "") (DA "d")
789 (UHA "") (USA "") (UDA "d")])
791 ;; Same as d but upper-case.
792 (define_mode_attr D [(SI "") (DI "D")
793 (QQ "") (HQ "") (SQ "") (DQ "D")
794 (UQQ "") (UHQ "") (USQ "") (UDQ "D")
795 (HA "") (SA "") (DA "D")
796 (UHA "") (USA "") (UDA "D")])
798 ;; This attribute gives the length suffix for a load or store instruction.
799 ;; The same suffixes work for zero and sign extensions.
800 (define_mode_attr size [(QI "b") (HI "h") (SI "w") (DI "d")])
801 (define_mode_attr SIZE [(QI "B") (HI "H") (SI "W") (DI "D")])
803 ;; This attributes gives the mode mask of a SHORT.
804 (define_mode_attr mask [(QI "0x00ff") (HI "0xffff")])
806 ;; Mode attributes for GPR loads.
807 (define_mode_attr load [(SI "lw") (DI "ld")])
808 ;; Instruction names for stores.
809 (define_mode_attr store [(QI "sb") (HI "sh") (SI "sw") (DI "sd")])
811 ;; Similarly for MIPS IV indexed FPR loads and stores.
812 (define_mode_attr loadx [(SF "lwxc1") (DF "ldxc1") (V2SF "ldxc1")])
813 (define_mode_attr storex [(SF "swxc1") (DF "sdxc1") (V2SF "sdxc1")])
815 ;; The unextended ranges of the MIPS16 addiu and daddiu instructions
816 ;; are different. Some forms of unextended addiu have an 8-bit immediate
817 ;; field but the equivalent daddiu has only a 5-bit field.
818 (define_mode_attr si8_di5 [(SI "8") (DI "5")])
820 ;; This attribute gives the best constraint to use for registers of
822 (define_mode_attr reg [(SI "d") (DI "d") (CC "z")])
824 ;; This attribute gives the format suffix for floating-point operations.
825 (define_mode_attr fmt [(SF "s") (DF "d") (V2SF "ps")])
827 ;; This attribute gives the upper-case mode name for one unit of a
828 ;; floating-point mode.
829 (define_mode_attr UNITMODE [(SF "SF") (DF "DF") (V2SF "SF")])
831 ;; This attribute gives the integer mode that has the same size as a
833 (define_mode_attr IMODE [(QQ "QI") (HQ "HI") (SQ "SI") (DQ "DI")
834 (UQQ "QI") (UHQ "HI") (USQ "SI") (UDQ "DI")
835 (HA "HI") (SA "SI") (DA "DI")
836 (UHA "HI") (USA "SI") (UDA "DI")
837 (V4UQQ "SI") (V2UHQ "SI") (V2UHA "SI")
838 (V2HQ "SI") (V2HA "SI")])
840 ;; This attribute gives the integer mode that has half the size of
841 ;; the controlling mode.
842 (define_mode_attr HALFMODE [(DF "SI") (DI "SI") (V2SF "SI")
843 (V2SI "SI") (V4HI "SI") (V8QI "SI")
846 ;; This attribute works around the early SB-1 rev2 core "F2" erratum:
848 ;; In certain cases, div.s and div.ps may have a rounding error
849 ;; and/or wrong inexact flag.
851 ;; Therefore, we only allow div.s if not working around SB-1 rev2
852 ;; errata or if a slight loss of precision is OK.
853 (define_mode_attr divide_condition
854 [DF (SF "!TARGET_FIX_SB1 || flag_unsafe_math_optimizations")
855 (V2SF "TARGET_SB1 && (!TARGET_FIX_SB1 || flag_unsafe_math_optimizations)")])
857 ;; This attribute gives the conditions under which SQRT.fmt instructions
859 (define_mode_attr sqrt_condition
860 [(SF "!ISA_MIPS1") (DF "!ISA_MIPS1") (V2SF "TARGET_SB1")])
862 ;; This attribute gives the conditions under which RECIP.fmt and RSQRT.fmt
863 ;; instructions can be used. The MIPS32 and MIPS64 ISAs say that RECIP.D
864 ;; and RSQRT.D are unpredictable when doubles are stored in pairs of FPRs,
865 ;; so for safety's sake, we apply this restriction to all targets.
866 (define_mode_attr recip_condition
868 (DF "ISA_HAS_FP4 && TARGET_FLOAT64")
869 (V2SF "TARGET_SB1")])
871 ;; This code iterator allows signed and unsigned widening multiplications
872 ;; to use the same template.
873 (define_code_iterator any_extend [sign_extend zero_extend])
875 ;; This code iterator allows the two right shift instructions to be
876 ;; generated from the same template.
877 (define_code_iterator any_shiftrt [ashiftrt lshiftrt])
879 ;; This code iterator allows the three shift instructions to be generated
880 ;; from the same template.
881 (define_code_iterator any_shift [ashift ashiftrt lshiftrt])
883 ;; This code iterator allows unsigned and signed division to be generated
884 ;; from the same template.
885 (define_code_iterator any_div [div udiv])
887 ;; This code iterator allows unsigned and signed modulus to be generated
888 ;; from the same template.
889 (define_code_iterator any_mod [mod umod])
891 ;; This code iterator allows all native floating-point comparisons to be
892 ;; generated from the same template.
893 (define_code_iterator fcond [unordered uneq unlt unle eq lt le])
895 ;; This code iterator is used for comparisons that can be implemented
896 ;; by swapping the operands.
897 (define_code_iterator swapped_fcond [ge gt unge ungt])
899 ;; Equality operators.
900 (define_code_iterator equality_op [eq ne])
902 ;; These code iterators allow the signed and unsigned scc operations to use
903 ;; the same template.
904 (define_code_iterator any_gt [gt gtu])
905 (define_code_iterator any_ge [ge geu])
906 (define_code_iterator any_lt [lt ltu])
907 (define_code_iterator any_le [le leu])
909 (define_code_iterator any_return [return simple_return])
911 ;; <u> expands to an empty string when doing a signed operation and
912 ;; "u" when doing an unsigned operation.
913 (define_code_attr u [(sign_extend "") (zero_extend "u")
921 ;; <U> is like <u> except uppercase.
922 (define_code_attr U [(sign_extend "") (zero_extend "U")])
924 ;; <su> is like <u>, but the signed form expands to "s" rather than "".
925 (define_code_attr su [(sign_extend "s") (zero_extend "u")])
927 ;; <optab> expands to the name of the optab for a particular code.
928 (define_code_attr optab [(ashift "ashl")
937 (simple_return "simple_return")])
939 ;; <insn> expands to the name of the insn that implements a particular code.
940 (define_code_attr insn [(ashift "sll")
949 ;; <immediate_insn> expands to the name of the insn that implements
950 ;; a particular code to operate on immediate values.
951 (define_code_attr immediate_insn [(ior "ori")
955 ;; <fcond> is the c.cond.fmt condition associated with a particular code.
956 (define_code_attr fcond [(unordered "un")
964 ;; Similar, but for swapped conditions.
965 (define_code_attr swapped_fcond [(ge "le")
970 ;; The value of the bit when the branch is taken for branch_bit patterns.
971 ;; Comparison is always against zero so this depends on the operator.
972 (define_code_attr bbv [(eq "0") (ne "1")])
974 ;; This is the inverse value of bbv.
975 (define_code_attr bbinv [(eq "1") (ne "0")])
977 ;; .........................
979 ;; Branch, call and jump delay slots
981 ;; .........................
983 (define_delay (and (eq_attr "type" "branch")
984 (not (match_test "TARGET_MIPS16"))
985 (eq_attr "branch_likely" "yes"))
986 [(eq_attr "can_delay" "yes")
988 (eq_attr "can_delay" "yes")])
990 ;; Branches that don't have likely variants do not annul on false.
991 (define_delay (and (eq_attr "type" "branch")
992 (not (match_test "TARGET_MIPS16"))
993 (eq_attr "branch_likely" "no"))
994 [(eq_attr "can_delay" "yes")
998 (define_delay (eq_attr "type" "jump")
999 [(eq_attr "can_delay" "yes")
1003 (define_delay (and (eq_attr "type" "call")
1004 (eq_attr "jal_macro" "no"))
1005 [(eq_attr "can_delay" "yes")
1009 ;; Pipeline descriptions.
1011 ;; generic.md provides a fallback for processors without a specific
1012 ;; pipeline description. It is derived from the old define_function_unit
1013 ;; version and uses the "alu" and "imuldiv" units declared below.
1015 ;; Some of the processor-specific files are also derived from old
1016 ;; define_function_unit descriptions and simply override the parts of
1017 ;; generic.md that don't apply. The other processor-specific files
1018 ;; are self-contained.
1019 (define_automaton "alu,imuldiv")
1021 (define_cpu_unit "alu" "alu")
1022 (define_cpu_unit "imuldiv" "imuldiv")
1024 ;; Ghost instructions produce no real code and introduce no hazards.
1025 ;; They exist purely to express an effect on dataflow.
1026 (define_insn_reservation "ghost" 0
1027 (eq_attr "type" "ghost")
1047 (include "10000.md")
1048 (include "loongson2ef.md")
1049 (include "loongson3a.md")
1050 (include "octeon.md")
1052 (include "sr71k.md")
1055 (include "generic.md")
1058 ;; ....................
1060 ;; CONDITIONAL TRAPS
1062 ;; ....................
1066 [(trap_if (const_int 1) (const_int 0))]
1069 if (ISA_HAS_COND_TRAP)
1070 return "teq\t$0,$0";
1071 else if (TARGET_MIPS16)
1076 [(set_attr "type" "trap")])
1078 (define_expand "ctrap<mode>4"
1079 [(trap_if (match_operator 0 "comparison_operator"
1080 [(match_operand:GPR 1 "reg_or_0_operand")
1081 (match_operand:GPR 2 "arith_operand")])
1082 (match_operand 3 "const_0_operand"))]
1085 mips_expand_conditional_trap (operands[0]);
1089 (define_insn "*conditional_trap<mode>"
1090 [(trap_if (match_operator:GPR 0 "trap_comparison_operator"
1091 [(match_operand:GPR 1 "reg_or_0_operand" "dJ")
1092 (match_operand:GPR 2 "arith_operand" "dI")])
1096 [(set_attr "type" "trap")])
1099 ;; ....................
1103 ;; ....................
1106 (define_insn "add<mode>3"
1107 [(set (match_operand:ANYF 0 "register_operand" "=f")
1108 (plus:ANYF (match_operand:ANYF 1 "register_operand" "f")
1109 (match_operand:ANYF 2 "register_operand" "f")))]
1111 "add.<fmt>\t%0,%1,%2"
1112 [(set_attr "type" "fadd")
1113 (set_attr "mode" "<UNITMODE>")])
1115 (define_expand "add<mode>3"
1116 [(set (match_operand:GPR 0 "register_operand")
1117 (plus:GPR (match_operand:GPR 1 "register_operand")
1118 (match_operand:GPR 2 "arith_operand")))]
1121 (define_insn "*add<mode>3"
1122 [(set (match_operand:GPR 0 "register_operand" "=d,d")
1123 (plus:GPR (match_operand:GPR 1 "register_operand" "d,d")
1124 (match_operand:GPR 2 "arith_operand" "d,Q")))]
1129 [(set_attr "alu_type" "add")
1130 (set_attr "mode" "<MODE>")])
1132 (define_insn "*add<mode>3_mips16"
1133 [(set (match_operand:GPR 0 "register_operand" "=ks,d,d,d,d")
1134 (plus:GPR (match_operand:GPR 1 "register_operand" "ks,ks,0,d,d")
1135 (match_operand:GPR 2 "arith_operand" "Q,Q,Q,O,d")))]
1143 [(set_attr "alu_type" "add")
1144 (set_attr "mode" "<MODE>")
1145 (set_attr_alternative "length"
1146 [(if_then_else (match_operand 2 "m16_simm8_8")
1149 (if_then_else (match_operand 2 "m16_uimm<si8_di5>_4")
1152 (if_then_else (match_operand 2 "m16_simm<si8_di5>_1")
1155 (if_then_else (match_operand 2 "m16_simm4_1")
1160 ;; On the mips16, we can sometimes split an add of a constant which is
1161 ;; a 4 byte instruction into two adds which are both 2 byte
1162 ;; instructions. There are two cases: one where we are adding a
1163 ;; constant plus a register to another register, and one where we are
1164 ;; simply adding a constant to a register.
1167 [(set (match_operand:SI 0 "d_operand")
1168 (plus:SI (match_dup 0)
1169 (match_operand:SI 1 "const_int_operand")))]
1170 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
1171 && ((INTVAL (operands[1]) > 0x7f
1172 && INTVAL (operands[1]) <= 0x7f + 0x7f)
1173 || (INTVAL (operands[1]) < - 0x80
1174 && INTVAL (operands[1]) >= - 0x80 - 0x80))"
1175 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
1176 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]
1178 HOST_WIDE_INT val = INTVAL (operands[1]);
1182 operands[1] = GEN_INT (0x7f);
1183 operands[2] = GEN_INT (val - 0x7f);
1187 operands[1] = GEN_INT (- 0x80);
1188 operands[2] = GEN_INT (val + 0x80);
1193 [(set (match_operand:SI 0 "d_operand")
1194 (plus:SI (match_operand:SI 1 "d_operand")
1195 (match_operand:SI 2 "const_int_operand")))]
1196 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
1197 && REGNO (operands[0]) != REGNO (operands[1])
1198 && ((INTVAL (operands[2]) > 0x7
1199 && INTVAL (operands[2]) <= 0x7 + 0x7f)
1200 || (INTVAL (operands[2]) < - 0x8
1201 && INTVAL (operands[2]) >= - 0x8 - 0x80))"
1202 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))
1203 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 3)))]
1205 HOST_WIDE_INT val = INTVAL (operands[2]);
1209 operands[2] = GEN_INT (0x7);
1210 operands[3] = GEN_INT (val - 0x7);
1214 operands[2] = GEN_INT (- 0x8);
1215 operands[3] = GEN_INT (val + 0x8);
1220 [(set (match_operand:DI 0 "d_operand")
1221 (plus:DI (match_dup 0)
1222 (match_operand:DI 1 "const_int_operand")))]
1223 "TARGET_MIPS16 && TARGET_64BIT && reload_completed && !TARGET_DEBUG_D_MODE
1224 && ((INTVAL (operands[1]) > 0xf
1225 && INTVAL (operands[1]) <= 0xf + 0xf)
1226 || (INTVAL (operands[1]) < - 0x10
1227 && INTVAL (operands[1]) >= - 0x10 - 0x10))"
1228 [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1)))
1229 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))]
1231 HOST_WIDE_INT val = INTVAL (operands[1]);
1235 operands[1] = GEN_INT (0xf);
1236 operands[2] = GEN_INT (val - 0xf);
1240 operands[1] = GEN_INT (- 0x10);
1241 operands[2] = GEN_INT (val + 0x10);
1246 [(set (match_operand:DI 0 "d_operand")
1247 (plus:DI (match_operand:DI 1 "d_operand")
1248 (match_operand:DI 2 "const_int_operand")))]
1249 "TARGET_MIPS16 && TARGET_64BIT && reload_completed && !TARGET_DEBUG_D_MODE
1250 && REGNO (operands[0]) != REGNO (operands[1])
1251 && ((INTVAL (operands[2]) > 0x7
1252 && INTVAL (operands[2]) <= 0x7 + 0xf)
1253 || (INTVAL (operands[2]) < - 0x8
1254 && INTVAL (operands[2]) >= - 0x8 - 0x10))"
1255 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))
1256 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
1258 HOST_WIDE_INT val = INTVAL (operands[2]);
1262 operands[2] = GEN_INT (0x7);
1263 operands[3] = GEN_INT (val - 0x7);
1267 operands[2] = GEN_INT (- 0x8);
1268 operands[3] = GEN_INT (val + 0x8);
1272 (define_insn "*addsi3_extended"
1273 [(set (match_operand:DI 0 "register_operand" "=d,d")
1275 (plus:SI (match_operand:SI 1 "register_operand" "d,d")
1276 (match_operand:SI 2 "arith_operand" "d,Q"))))]
1277 "TARGET_64BIT && !TARGET_MIPS16"
1281 [(set_attr "alu_type" "add")
1282 (set_attr "mode" "SI")])
1284 ;; Split this insn so that the addiu splitters can have a crack at it.
1285 ;; Use a conservative length estimate until the split.
1286 (define_insn_and_split "*addsi3_extended_mips16"
1287 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1289 (plus:SI (match_operand:SI 1 "register_operand" "0,d,d")
1290 (match_operand:SI 2 "arith_operand" "Q,O,d"))))]
1291 "TARGET_64BIT && TARGET_MIPS16"
1293 "&& reload_completed"
1294 [(set (match_dup 3) (plus:SI (match_dup 1) (match_dup 2)))]
1295 { operands[3] = gen_lowpart (SImode, operands[0]); }
1296 [(set_attr "alu_type" "add")
1297 (set_attr "mode" "SI")
1298 (set_attr "extended_mips16" "yes")])
1300 ;; Combiner patterns for unsigned byte-add.
1302 (define_insn "*baddu_si_eb"
1303 [(set (match_operand:SI 0 "register_operand" "=d")
1306 (plus:SI (match_operand:SI 1 "register_operand" "d")
1307 (match_operand:SI 2 "register_operand" "d")) 3)))]
1308 "ISA_HAS_BADDU && BYTES_BIG_ENDIAN"
1310 [(set_attr "alu_type" "add")])
1312 (define_insn "*baddu_si_el"
1313 [(set (match_operand:SI 0 "register_operand" "=d")
1316 (plus:SI (match_operand:SI 1 "register_operand" "d")
1317 (match_operand:SI 2 "register_operand" "d")) 0)))]
1318 "ISA_HAS_BADDU && !BYTES_BIG_ENDIAN"
1320 [(set_attr "alu_type" "add")])
1322 (define_insn "*baddu_di<mode>"
1323 [(set (match_operand:GPR 0 "register_operand" "=d")
1326 (plus:DI (match_operand:DI 1 "register_operand" "d")
1327 (match_operand:DI 2 "register_operand" "d")))))]
1328 "ISA_HAS_BADDU && TARGET_64BIT"
1330 [(set_attr "alu_type" "add")])
1333 ;; ....................
1337 ;; ....................
1340 (define_insn "sub<mode>3"
1341 [(set (match_operand:ANYF 0 "register_operand" "=f")
1342 (minus:ANYF (match_operand:ANYF 1 "register_operand" "f")
1343 (match_operand:ANYF 2 "register_operand" "f")))]
1345 "sub.<fmt>\t%0,%1,%2"
1346 [(set_attr "type" "fadd")
1347 (set_attr "mode" "<UNITMODE>")])
1349 (define_insn "sub<mode>3"
1350 [(set (match_operand:GPR 0 "register_operand" "=d")
1351 (minus:GPR (match_operand:GPR 1 "register_operand" "d")
1352 (match_operand:GPR 2 "register_operand" "d")))]
1355 [(set_attr "alu_type" "sub")
1356 (set_attr "mode" "<MODE>")])
1358 (define_insn "*subsi3_extended"
1359 [(set (match_operand:DI 0 "register_operand" "=d")
1361 (minus:SI (match_operand:SI 1 "register_operand" "d")
1362 (match_operand:SI 2 "register_operand" "d"))))]
1365 [(set_attr "alu_type" "sub")
1366 (set_attr "mode" "DI")])
1369 ;; ....................
1373 ;; ....................
1376 (define_expand "mul<mode>3"
1377 [(set (match_operand:SCALARF 0 "register_operand")
1378 (mult:SCALARF (match_operand:SCALARF 1 "register_operand")
1379 (match_operand:SCALARF 2 "register_operand")))]
1383 (define_insn "*mul<mode>3"
1384 [(set (match_operand:SCALARF 0 "register_operand" "=f")
1385 (mult:SCALARF (match_operand:SCALARF 1 "register_operand" "f")
1386 (match_operand:SCALARF 2 "register_operand" "f")))]
1387 "!TARGET_4300_MUL_FIX"
1388 "mul.<fmt>\t%0,%1,%2"
1389 [(set_attr "type" "fmul")
1390 (set_attr "mode" "<MODE>")])
1392 ;; Early VR4300 silicon has a CPU bug where multiplies with certain
1393 ;; operands may corrupt immediately following multiplies. This is a
1394 ;; simple fix to insert NOPs.
1396 (define_insn "*mul<mode>3_r4300"
1397 [(set (match_operand:SCALARF 0 "register_operand" "=f")
1398 (mult:SCALARF (match_operand:SCALARF 1 "register_operand" "f")
1399 (match_operand:SCALARF 2 "register_operand" "f")))]
1400 "TARGET_4300_MUL_FIX"
1401 "mul.<fmt>\t%0,%1,%2\;nop"
1402 [(set_attr "type" "fmul")
1403 (set_attr "mode" "<MODE>")
1404 (set_attr "length" "8")])
1406 (define_insn "mulv2sf3"
1407 [(set (match_operand:V2SF 0 "register_operand" "=f")
1408 (mult:V2SF (match_operand:V2SF 1 "register_operand" "f")
1409 (match_operand:V2SF 2 "register_operand" "f")))]
1410 "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT"
1412 [(set_attr "type" "fmul")
1413 (set_attr "mode" "SF")])
1415 ;; The original R4000 has a cpu bug. If a double-word or a variable
1416 ;; shift executes while an integer multiplication is in progress, the
1417 ;; shift may give an incorrect result. Avoid this by keeping the mflo
1418 ;; with the mult on the R4000.
1420 ;; From "MIPS R4000PC/SC Errata, Processor Revision 2.2 and 3.0"
1421 ;; (also valid for MIPS R4000MC processors):
1423 ;; "16. R4000PC, R4000SC: Please refer to errata 28 for an update to
1424 ;; this errata description.
1425 ;; The following code sequence causes the R4000 to incorrectly
1426 ;; execute the Double Shift Right Arithmetic 32 (dsra32)
1427 ;; instruction. If the dsra32 instruction is executed during an
1428 ;; integer multiply, the dsra32 will only shift by the amount in
1429 ;; specified in the instruction rather than the amount plus 32
1431 ;; instruction 1: mult rs,rt integer multiply
1432 ;; instruction 2-12: dsra32 rd,rt,rs doubleword shift
1433 ;; right arithmetic + 32
1434 ;; Workaround: A dsra32 instruction placed after an integer
1435 ;; multiply should not be one of the 11 instructions after the
1436 ;; multiply instruction."
1440 ;; "28. R4000PC, R4000SC: The text from errata 16 should be replaced by
1441 ;; the following description.
1442 ;; All extended shifts (shift by n+32) and variable shifts (32 and
1443 ;; 64-bit versions) may produce incorrect results under the
1444 ;; following conditions:
1445 ;; 1) An integer multiply is currently executing
1446 ;; 2) These types of shift instructions are executed immediately
1447 ;; following an integer divide instruction.
1449 ;; 1) Make sure no integer multiply is running wihen these
1450 ;; instruction are executed. If this cannot be predicted at
1451 ;; compile time, then insert a "mfhi" to R0 instruction
1452 ;; immediately after the integer multiply instruction. This
1453 ;; will cause the integer multiply to complete before the shift
1455 ;; 2) Separate integer divide and these two classes of shift
1456 ;; instructions by another instruction or a noop."
1458 ;; These processors have PRId values of 0x00004220 and 0x00004300,
1461 (define_expand "mul<mode>3"
1462 [(set (match_operand:GPR 0 "register_operand")
1463 (mult:GPR (match_operand:GPR 1 "register_operand")
1464 (match_operand:GPR 2 "register_operand")))]
1469 if (TARGET_LOONGSON_2EF || TARGET_LOONGSON_3A)
1470 emit_insn (gen_mul<mode>3_mul3_loongson (operands[0], operands[1],
1472 else if (ISA_HAS_<D>MUL3)
1473 emit_insn (gen_mul<mode>3_mul3 (operands[0], operands[1], operands[2]));
1474 else if (TARGET_MIPS16)
1476 lo = gen_rtx_REG (<MODE>mode, LO_REGNUM);
1477 emit_insn (gen_mul<mode>3_internal (lo, operands[1], operands[2]));
1478 emit_move_insn (operands[0], lo);
1480 else if (TARGET_FIX_R4000)
1481 emit_insn (gen_mul<mode>3_r4000 (operands[0], operands[1], operands[2]));
1484 (gen_mul<mode>3_internal (operands[0], operands[1], operands[2]));
1488 (define_insn "mul<mode>3_mul3_loongson"
1489 [(set (match_operand:GPR 0 "register_operand" "=d")
1490 (mult:GPR (match_operand:GPR 1 "register_operand" "d")
1491 (match_operand:GPR 2 "register_operand" "d")))]
1492 "TARGET_LOONGSON_2EF || TARGET_LOONGSON_3A"
1494 if (TARGET_LOONGSON_2EF)
1495 return "<d>multu.g\t%0,%1,%2";
1497 return "gs<d>multu\t%0,%1,%2";
1499 [(set_attr "type" "imul3nc")
1500 (set_attr "mode" "<MODE>")])
1502 (define_insn "mul<mode>3_mul3"
1503 [(set (match_operand:GPR 0 "register_operand" "=d,l")
1504 (mult:GPR (match_operand:GPR 1 "register_operand" "d,d")
1505 (match_operand:GPR 2 "register_operand" "d,d")))
1506 (clobber (match_scratch:GPR 3 "=l,X"))]
1509 if (which_alternative == 1)
1510 return "<d>mult\t%1,%2";
1511 if (<MODE>mode == SImode && TARGET_MIPS3900)
1512 return "mult\t%0,%1,%2";
1513 return "<d>mul\t%0,%1,%2";
1515 [(set_attr "type" "imul3,imul")
1516 (set_attr "mode" "<MODE>")])
1518 ;; If a register gets allocated to LO, and we spill to memory, the reload
1519 ;; will include a move from LO to a GPR. Merge it into the multiplication
1520 ;; if it can set the GPR directly.
1523 ;; Operand 1: GPR (1st multiplication operand)
1524 ;; Operand 2: GPR (2nd multiplication operand)
1525 ;; Operand 3: GPR (destination)
1528 [(set (match_operand:SI 0 "lo_operand")
1529 (mult:SI (match_operand:SI 1 "d_operand")
1530 (match_operand:SI 2 "d_operand")))
1531 (clobber (scratch:SI))])
1532 (set (match_operand:SI 3 "d_operand")
1534 "ISA_HAS_MUL3 && peep2_reg_dead_p (2, operands[0])"
1537 (mult:SI (match_dup 1)
1539 (clobber (match_dup 0))])])
1541 (define_insn "mul<mode>3_internal"
1542 [(set (match_operand:GPR 0 "muldiv_target_operand" "=l")
1543 (mult:GPR (match_operand:GPR 1 "register_operand" "d")
1544 (match_operand:GPR 2 "register_operand" "d")))]
1547 [(set_attr "type" "imul")
1548 (set_attr "mode" "<MODE>")])
1550 (define_insn "mul<mode>3_r4000"
1551 [(set (match_operand:GPR 0 "register_operand" "=d")
1552 (mult:GPR (match_operand:GPR 1 "register_operand" "d")
1553 (match_operand:GPR 2 "register_operand" "d")))
1554 (clobber (match_scratch:GPR 3 "=l"))]
1556 "<d>mult\t%1,%2\;mflo\t%0"
1557 [(set_attr "type" "imul")
1558 (set_attr "mode" "<MODE>")
1559 (set_attr "length" "8")])
1561 ;; On the VR4120 and VR4130, it is better to use "mtlo $0; macc" instead
1562 ;; of "mult; mflo". They have the same latency, but the first form gives
1563 ;; us an extra cycle to compute the operands.
1566 ;; Operand 1: GPR (1st multiplication operand)
1567 ;; Operand 2: GPR (2nd multiplication operand)
1568 ;; Operand 3: GPR (destination)
1570 [(set (match_operand:SI 0 "lo_operand")
1571 (mult:SI (match_operand:SI 1 "d_operand")
1572 (match_operand:SI 2 "d_operand")))
1573 (set (match_operand:SI 3 "d_operand")
1575 "ISA_HAS_MACC && !ISA_HAS_MUL3"
1580 (plus:SI (mult:SI (match_dup 1)
1584 (plus:SI (mult:SI (match_dup 1)
1588 ;; Multiply-accumulate patterns
1590 ;; This pattern is first matched by combine, which tries to use the
1591 ;; pattern wherever it can. We don't know until later whether it
1592 ;; is actually profitable to use MADD over a "MUL; ADDIU" sequence,
1593 ;; so we need to keep both options open.
1595 ;; The second alternative has a "?" marker because it is generally
1596 ;; one instruction more costly than the first alternative. This "?"
1597 ;; marker is enough to convey the relative costs to the register
1600 ;; However, reload counts reloads of operands 4 and 5 in the same way as
1601 ;; reloads of the other operands, even though operands 4 and 5 need no
1602 ;; copy instructions. Reload therefore thinks that the second alternative
1603 ;; is two reloads more costly than the first. We add "*?*?" to the first
1604 ;; alternative as a counterweight.
1605 (define_insn "*mul_acc_si"
1606 [(set (match_operand:SI 0 "register_operand" "=l*?*?,d?")
1607 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d")
1608 (match_operand:SI 2 "register_operand" "d,d"))
1609 (match_operand:SI 3 "register_operand" "0,d")))
1610 (clobber (match_scratch:SI 4 "=X,l"))
1611 (clobber (match_scratch:SI 5 "=X,&d"))]
1612 "GENERATE_MADD_MSUB && !TARGET_MIPS16"
1616 [(set_attr "type" "imadd")
1617 (set_attr "accum_in" "3")
1618 (set_attr "mode" "SI")
1619 (set_attr "length" "4,8")])
1621 ;; The same idea applies here. The middle alternative needs one less
1622 ;; clobber than the final alternative, so we add "*?" as a counterweight.
1623 (define_insn "*mul_acc_si_r3900"
1624 [(set (match_operand:SI 0 "register_operand" "=l*?*?,d*?,d?")
1625 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d,d")
1626 (match_operand:SI 2 "register_operand" "d,d,d"))
1627 (match_operand:SI 3 "register_operand" "0,l,d")))
1628 (clobber (match_scratch:SI 4 "=X,3,l"))
1629 (clobber (match_scratch:SI 5 "=X,X,&d"))]
1630 "TARGET_MIPS3900 && !TARGET_MIPS16"
1635 [(set_attr "type" "imadd")
1636 (set_attr "accum_in" "3")
1637 (set_attr "mode" "SI")
1638 (set_attr "length" "4,4,8")])
1640 ;; Split *mul_acc_si if both the source and destination accumulator
1643 [(set (match_operand:SI 0 "d_operand")
1644 (plus:SI (mult:SI (match_operand:SI 1 "d_operand")
1645 (match_operand:SI 2 "d_operand"))
1646 (match_operand:SI 3 "d_operand")))
1647 (clobber (match_operand:SI 4 "lo_operand"))
1648 (clobber (match_operand:SI 5 "d_operand"))]
1650 [(parallel [(set (match_dup 5)
1651 (mult:SI (match_dup 1) (match_dup 2)))
1652 (clobber (match_dup 4))])
1653 (set (match_dup 0) (plus:SI (match_dup 5) (match_dup 3)))]
1656 (define_insn "*macc"
1657 [(set (match_operand:SI 0 "register_operand" "=l,d")
1658 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d")
1659 (match_operand:SI 2 "register_operand" "d,d"))
1660 (match_operand:SI 3 "register_operand" "0,l")))
1661 (clobber (match_scratch:SI 4 "=X,3"))]
1664 if (which_alternative == 1)
1665 return "macc\t%0,%1,%2";
1666 else if (TARGET_MIPS5500)
1667 return "madd\t%1,%2";
1669 /* The VR4130 assumes that there is a two-cycle latency between a macc
1670 that "writes" to $0 and an instruction that reads from it. We avoid
1671 this by assigning to $1 instead. */
1672 return "%[macc\t%@,%1,%2%]";
1674 [(set_attr "type" "imadd")
1675 (set_attr "accum_in" "3")
1676 (set_attr "mode" "SI")])
1678 (define_insn "*msac"
1679 [(set (match_operand:SI 0 "register_operand" "=l,d")
1680 (minus:SI (match_operand:SI 1 "register_operand" "0,l")
1681 (mult:SI (match_operand:SI 2 "register_operand" "d,d")
1682 (match_operand:SI 3 "register_operand" "d,d"))))
1683 (clobber (match_scratch:SI 4 "=X,1"))]
1686 if (which_alternative == 1)
1687 return "msac\t%0,%2,%3";
1688 else if (TARGET_MIPS5500)
1689 return "msub\t%2,%3";
1691 return "msac\t$0,%2,%3";
1693 [(set_attr "type" "imadd")
1694 (set_attr "accum_in" "1")
1695 (set_attr "mode" "SI")])
1697 ;; An msac-like instruction implemented using negation and a macc.
1698 (define_insn_and_split "*msac_using_macc"
1699 [(set (match_operand:SI 0 "register_operand" "=l,d")
1700 (minus:SI (match_operand:SI 1 "register_operand" "0,l")
1701 (mult:SI (match_operand:SI 2 "register_operand" "d,d")
1702 (match_operand:SI 3 "register_operand" "d,d"))))
1703 (clobber (match_scratch:SI 4 "=X,1"))
1704 (clobber (match_scratch:SI 5 "=d,d"))]
1705 "ISA_HAS_MACC && !ISA_HAS_MSAC"
1707 "&& reload_completed"
1709 (neg:SI (match_dup 3)))
1712 (plus:SI (mult:SI (match_dup 2)
1715 (clobber (match_dup 4))])]
1717 [(set_attr "type" "imadd")
1718 (set_attr "accum_in" "1")
1719 (set_attr "length" "8")])
1721 ;; Patterns generated by the define_peephole2 below.
1723 (define_insn "*macc2"
1724 [(set (match_operand:SI 0 "muldiv_target_operand" "=l")
1725 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d")
1726 (match_operand:SI 2 "register_operand" "d"))
1728 (set (match_operand:SI 3 "register_operand" "=d")
1729 (plus:SI (mult:SI (match_dup 1)
1732 "ISA_HAS_MACC && reload_completed"
1734 [(set_attr "type" "imadd")
1735 (set_attr "accum_in" "0")
1736 (set_attr "mode" "SI")])
1738 (define_insn "*msac2"
1739 [(set (match_operand:SI 0 "muldiv_target_operand" "=l")
1740 (minus:SI (match_dup 0)
1741 (mult:SI (match_operand:SI 1 "register_operand" "d")
1742 (match_operand:SI 2 "register_operand" "d"))))
1743 (set (match_operand:SI 3 "register_operand" "=d")
1744 (minus:SI (match_dup 0)
1745 (mult:SI (match_dup 1)
1747 "ISA_HAS_MSAC && reload_completed"
1749 [(set_attr "type" "imadd")
1750 (set_attr "accum_in" "0")
1751 (set_attr "mode" "SI")])
1753 ;; Convert macc $0,<r1>,<r2> & mflo <r3> into macc <r3>,<r1>,<r2>
1757 ;; Operand 1: macc/msac
1758 ;; Operand 2: GPR (destination)
1761 [(set (match_operand:SI 0 "lo_operand")
1762 (match_operand:SI 1 "macc_msac_operand"))
1763 (clobber (scratch:SI))])
1764 (set (match_operand:SI 2 "d_operand")
1767 [(parallel [(set (match_dup 0)
1772 ;; When we have a three-address multiplication instruction, it should
1773 ;; be faster to do a separate multiply and add, rather than moving
1774 ;; something into LO in order to use a macc instruction.
1776 ;; This peephole needs a scratch register to cater for the case when one
1777 ;; of the multiplication operands is the same as the destination.
1779 ;; Operand 0: GPR (scratch)
1781 ;; Operand 2: GPR (addend)
1782 ;; Operand 3: GPR (destination)
1783 ;; Operand 4: macc/msac
1784 ;; Operand 5: new multiplication
1785 ;; Operand 6: new addition/subtraction
1787 [(match_scratch:SI 0 "d")
1788 (set (match_operand:SI 1 "lo_operand")
1789 (match_operand:SI 2 "d_operand"))
1792 [(set (match_operand:SI 3 "d_operand")
1793 (match_operand:SI 4 "macc_msac_operand"))
1794 (clobber (match_dup 1))])]
1795 "ISA_HAS_MUL3 && peep2_reg_dead_p (2, operands[1])"
1796 [(parallel [(set (match_dup 0)
1798 (clobber (match_dup 1))])
1802 operands[5] = XEXP (operands[4], GET_CODE (operands[4]) == PLUS ? 0 : 1);
1803 operands[6] = gen_rtx_fmt_ee (GET_CODE (operands[4]), SImode,
1804 operands[2], operands[0]);
1807 ;; Same as above, except LO is the initial target of the macc.
1809 ;; Operand 0: GPR (scratch)
1811 ;; Operand 2: GPR (addend)
1812 ;; Operand 3: macc/msac
1813 ;; Operand 4: GPR (destination)
1814 ;; Operand 5: new multiplication
1815 ;; Operand 6: new addition/subtraction
1817 [(match_scratch:SI 0 "d")
1818 (set (match_operand:SI 1 "lo_operand")
1819 (match_operand:SI 2 "d_operand"))
1823 (match_operand:SI 3 "macc_msac_operand"))
1824 (clobber (scratch:SI))])
1826 (set (match_operand:SI 4 "d_operand")
1828 "ISA_HAS_MUL3 && peep2_reg_dead_p (3, operands[1])"
1829 [(parallel [(set (match_dup 0)
1831 (clobber (match_dup 1))])
1835 operands[5] = XEXP (operands[3], GET_CODE (operands[3]) == PLUS ? 0 : 1);
1836 operands[6] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
1837 operands[2], operands[0]);
1840 ;; See the comment above *mul_add_si for details.
1841 (define_insn "*mul_sub_si"
1842 [(set (match_operand:SI 0 "register_operand" "=l*?*?,d?")
1843 (minus:SI (match_operand:SI 1 "register_operand" "0,d")
1844 (mult:SI (match_operand:SI 2 "register_operand" "d,d")
1845 (match_operand:SI 3 "register_operand" "d,d"))))
1846 (clobber (match_scratch:SI 4 "=X,l"))
1847 (clobber (match_scratch:SI 5 "=X,&d"))]
1848 "GENERATE_MADD_MSUB"
1852 [(set_attr "type" "imadd")
1853 (set_attr "accum_in" "1")
1854 (set_attr "mode" "SI")
1855 (set_attr "length" "4,8")])
1857 ;; Split *mul_sub_si if both the source and destination accumulator
1860 [(set (match_operand:SI 0 "d_operand")
1861 (minus:SI (match_operand:SI 1 "d_operand")
1862 (mult:SI (match_operand:SI 2 "d_operand")
1863 (match_operand:SI 3 "d_operand"))))
1864 (clobber (match_operand:SI 4 "lo_operand"))
1865 (clobber (match_operand:SI 5 "d_operand"))]
1867 [(parallel [(set (match_dup 5)
1868 (mult:SI (match_dup 2) (match_dup 3)))
1869 (clobber (match_dup 4))])
1870 (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 5)))]
1873 (define_insn "*muls"
1874 [(set (match_operand:SI 0 "register_operand" "=l,d")
1875 (neg:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d")
1876 (match_operand:SI 2 "register_operand" "d,d"))))
1877 (clobber (match_scratch:SI 3 "=X,l"))]
1882 [(set_attr "type" "imul,imul3")
1883 (set_attr "mode" "SI")])
1885 (define_expand "<u>mulsidi3"
1886 [(set (match_operand:DI 0 "register_operand")
1887 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand"))
1888 (any_extend:DI (match_operand:SI 2 "register_operand"))))]
1889 "mips_mulsidi3_gen_fn (<CODE>) != NULL"
1891 mulsidi3_gen_fn fn = mips_mulsidi3_gen_fn (<CODE>);
1892 emit_insn (fn (operands[0], operands[1], operands[2]));
1896 (define_expand "<u>mulsidi3_32bit_mips16"
1897 [(set (match_operand:DI 0 "register_operand")
1898 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand"))
1899 (any_extend:DI (match_operand:SI 2 "register_operand"))))]
1900 "!TARGET_64BIT && TARGET_MIPS16"
1904 hilo = gen_rtx_REG (DImode, MD_REG_FIRST);
1905 emit_insn (gen_<u>mulsidi3_32bit (hilo, operands[1], operands[2]));
1906 emit_move_insn (operands[0], hilo);
1910 ;; As well as being named patterns, these instructions are used by the
1911 ;; __builtin_mips_mult<u>() functions. We must always make those functions
1912 ;; available if !TARGET_64BIT && ISA_HAS_DSP.
1913 (define_insn "<u>mulsidi3_32bit"
1914 [(set (match_operand:DI 0 "muldiv_target_operand" "=ka")
1915 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1916 (any_extend:DI (match_operand:SI 2 "register_operand" "d"))))]
1917 "!TARGET_64BIT && (!TARGET_FIX_R4000 || ISA_HAS_DSP)"
1919 if (ISA_HAS_DSP_MULT)
1920 return "mult<u>\t%q0,%1,%2";
1922 return "mult<u>\t%1,%2";
1924 [(set_attr "type" "imul")
1925 (set_attr "mode" "SI")])
1927 (define_insn "<u>mulsidi3_32bit_r4000"
1928 [(set (match_operand:DI 0 "register_operand" "=d")
1929 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1930 (any_extend:DI (match_operand:SI 2 "register_operand" "d"))))
1931 (clobber (match_scratch:DI 3 "=x"))]
1932 "!TARGET_64BIT && TARGET_FIX_R4000 && !ISA_HAS_DSP"
1933 "mult<u>\t%1,%2\;mflo\t%L0\;mfhi\t%M0"
1934 [(set_attr "type" "imul")
1935 (set_attr "mode" "SI")
1936 (set_attr "length" "12")])
1938 (define_insn_and_split "<u>mulsidi3_64bit"
1939 [(set (match_operand:DI 0 "register_operand" "=d")
1940 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1941 (any_extend:DI (match_operand:SI 2 "register_operand" "d"))))
1942 (clobber (match_scratch:TI 3 "=x"))
1943 (clobber (match_scratch:DI 4 "=d"))]
1944 "TARGET_64BIT && !TARGET_FIX_R4000 && !ISA_HAS_DMUL3 && !TARGET_MIPS16"
1946 "&& reload_completed"
1949 emit_insn (gen_<u>mulsidi3_64bit_split (operands[0], operands[1],
1950 operands[2], operands[4]));
1953 [(set_attr "type" "imul")
1954 (set_attr "mode" "SI")
1955 (set (attr "length")
1956 (if_then_else (match_test "ISA_HAS_EXT_INS")
1960 (define_expand "<u>mulsidi3_64bit_mips16"
1961 [(set (match_operand:DI 0 "register_operand")
1962 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand"))
1963 (any_extend:DI (match_operand:SI 2 "register_operand"))))]
1964 "TARGET_64BIT && TARGET_MIPS16"
1966 emit_insn (gen_<u>mulsidi3_64bit_split (operands[0], operands[1],
1967 operands[2], gen_reg_rtx (DImode)));
1971 (define_expand "<u>mulsidi3_64bit_split"
1972 [(set (match_operand:DI 0 "register_operand")
1973 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand"))
1974 (any_extend:DI (match_operand:SI 2 "register_operand"))))
1975 (clobber (match_operand:DI 3 "register_operand"))]
1980 hilo = gen_rtx_REG (TImode, MD_REG_FIRST);
1981 emit_insn (gen_<u>mulsidi3_64bit_hilo (hilo, operands[1], operands[2]));
1983 emit_move_insn (operands[0], gen_rtx_REG (DImode, LO_REGNUM));
1984 emit_insn (gen_mfhidi_ti (operands[3], hilo));
1986 if (ISA_HAS_EXT_INS)
1987 emit_insn (gen_insvdi (operands[0], GEN_INT (32), GEN_INT (32),
1991 /* Zero-extend the low part. */
1992 mips_emit_binary (ASHIFT, operands[0], operands[0], GEN_INT (32));
1993 mips_emit_binary (LSHIFTRT, operands[0], operands[0], GEN_INT (32));
1995 /* Shift the high part into place. */
1996 mips_emit_binary (ASHIFT, operands[3], operands[3], GEN_INT (32));
1998 /* OR the two halves together. */
1999 mips_emit_binary (IOR, operands[0], operands[0], operands[3]);
2004 (define_insn "<u>mulsidi3_64bit_hilo"
2005 [(set (match_operand:TI 0 "muldiv_target_operand" "=x")
2008 (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
2009 (any_extend:DI (match_operand:SI 2 "register_operand" "d")))]
2011 "TARGET_64BIT && !TARGET_FIX_R4000"
2013 [(set_attr "type" "imul")
2014 (set_attr "mode" "SI")])
2016 ;; See comment before the ISA_HAS_DMUL3 case in mips_mulsidi3_gen_fn.
2017 (define_insn "mulsidi3_64bit_dmul"
2018 [(set (match_operand:DI 0 "register_operand" "=d")
2019 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
2020 (sign_extend:DI (match_operand:SI 2 "register_operand" "d"))))
2021 (clobber (match_scratch:DI 3 "=l"))]
2022 "TARGET_64BIT && ISA_HAS_DMUL3"
2024 [(set_attr "type" "imul3")
2025 (set_attr "mode" "DI")])
2027 ;; Widening multiply with negation.
2028 (define_insn "*muls<u>_di"
2029 [(set (match_operand:DI 0 "muldiv_target_operand" "=x")
2032 (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
2033 (any_extend:DI (match_operand:SI 2 "register_operand" "d")))))]
2034 "!TARGET_64BIT && ISA_HAS_MULS"
2036 [(set_attr "type" "imul")
2037 (set_attr "mode" "SI")])
2039 ;; As well as being named patterns, these instructions are used by the
2040 ;; __builtin_mips_msub<u>() functions. We must always make those functions
2041 ;; available if !TARGET_64BIT && ISA_HAS_DSP.
2043 ;; This leads to a slight inconsistency. We honor any tuning overrides
2044 ;; in GENERATE_MADD_MSUB for -mno-dsp, but always ignore them for -mdsp,
2045 ;; even if !ISA_HAS_DSP_MULT.
2046 (define_insn "<u>msubsidi4"
2047 [(set (match_operand:DI 0 "muldiv_target_operand" "=ka")
2049 (match_operand:DI 3 "muldiv_target_operand" "0")
2051 (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
2052 (any_extend:DI (match_operand:SI 2 "register_operand" "d")))))]
2053 "!TARGET_64BIT && (ISA_HAS_MSAC || GENERATE_MADD_MSUB || ISA_HAS_DSP)"
2055 if (ISA_HAS_DSP_MULT)
2056 return "msub<u>\t%q0,%1,%2";
2057 else if (TARGET_MIPS5500 || GENERATE_MADD_MSUB)
2058 return "msub<u>\t%1,%2";
2060 return "msac<u>\t$0,%1,%2";
2062 [(set_attr "type" "imadd")
2063 (set_attr "accum_in" "3")
2064 (set_attr "mode" "SI")])
2066 ;; _highpart patterns
2068 (define_expand "<su>mulsi3_highpart"
2069 [(set (match_operand:SI 0 "register_operand")
2072 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand"))
2073 (any_extend:DI (match_operand:SI 2 "register_operand")))
2078 emit_insn (gen_<su>mulsi3_highpart_mulhi_internal (operands[0],
2081 else if (TARGET_MIPS16)
2082 emit_insn (gen_<su>mulsi3_highpart_split (operands[0], operands[1],
2085 emit_insn (gen_<su>mulsi3_highpart_internal (operands[0], operands[1],
2090 (define_insn_and_split "<su>mulsi3_highpart_internal"
2091 [(set (match_operand:SI 0 "register_operand" "=d")
2094 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
2095 (any_extend:DI (match_operand:SI 2 "register_operand" "d")))
2097 (clobber (match_scratch:SI 3 "=l"))]
2098 "!ISA_HAS_MULHI && !TARGET_MIPS16"
2099 { return TARGET_FIX_R4000 ? "mult<u>\t%1,%2\n\tmfhi\t%0" : "#"; }
2100 "&& reload_completed && !TARGET_FIX_R4000"
2103 emit_insn (gen_<su>mulsi3_highpart_split (operands[0], operands[1],
2107 [(set_attr "type" "imul")
2108 (set_attr "mode" "SI")
2109 (set_attr "length" "8")])
2111 (define_expand "<su>mulsi3_highpart_split"
2112 [(set (match_operand:SI 0 "register_operand")
2115 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand"))
2116 (any_extend:DI (match_operand:SI 2 "register_operand")))
2124 hilo = gen_rtx_REG (TImode, MD_REG_FIRST);
2125 emit_insn (gen_<u>mulsidi3_64bit_hilo (hilo, operands[1], operands[2]));
2126 emit_insn (gen_mfhisi_ti (operands[0], hilo));
2130 hilo = gen_rtx_REG (DImode, MD_REG_FIRST);
2131 emit_insn (gen_<u>mulsidi3_32bit (hilo, operands[1], operands[2]));
2132 emit_insn (gen_mfhisi_di (operands[0], hilo));
2137 (define_insn "<su>mulsi3_highpart_mulhi_internal"
2138 [(set (match_operand:SI 0 "register_operand" "=d")
2142 (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
2143 (any_extend:DI (match_operand:SI 2 "register_operand" "d")))
2145 (clobber (match_scratch:SI 3 "=l"))]
2147 "mulhi<u>\t%0,%1,%2"
2148 [(set_attr "type" "imul3")
2149 (set_attr "mode" "SI")])
2151 (define_insn "*<su>mulsi3_highpart_neg_mulhi_internal"
2152 [(set (match_operand:SI 0 "register_operand" "=d")
2157 (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
2158 (any_extend:DI (match_operand:SI 2 "register_operand" "d"))))
2160 (clobber (match_scratch:SI 3 "=l"))]
2162 "mulshi<u>\t%0,%1,%2"
2163 [(set_attr "type" "imul3")
2164 (set_attr "mode" "SI")])
2166 ;; Disable unsigned multiplication for -mfix-vr4120. This is for VR4120
2167 ;; errata MD(0), which says that dmultu does not always produce the
2169 (define_expand "<su>muldi3_highpart"
2170 [(set (match_operand:DI 0 "register_operand")
2173 (mult:TI (any_extend:TI (match_operand:DI 1 "register_operand"))
2174 (any_extend:TI (match_operand:DI 2 "register_operand")))
2176 "TARGET_64BIT && !(<CODE> == ZERO_EXTEND && TARGET_FIX_VR4120)"
2179 emit_insn (gen_<su>muldi3_highpart_split (operands[0], operands[1],
2182 emit_insn (gen_<su>muldi3_highpart_internal (operands[0], operands[1],
2187 (define_insn_and_split "<su>muldi3_highpart_internal"
2188 [(set (match_operand:DI 0 "register_operand" "=d")
2191 (mult:TI (any_extend:TI (match_operand:DI 1 "register_operand" "d"))
2192 (any_extend:TI (match_operand:DI 2 "register_operand" "d")))
2194 (clobber (match_scratch:DI 3 "=l"))]
2197 && !(<CODE> == ZERO_EXTEND && TARGET_FIX_VR4120)"
2198 { return TARGET_FIX_R4000 ? "dmult<u>\t%1,%2\n\tmfhi\t%0" : "#"; }
2199 "&& reload_completed && !TARGET_FIX_R4000"
2202 emit_insn (gen_<su>muldi3_highpart_split (operands[0], operands[1],
2206 [(set_attr "type" "imul")
2207 (set_attr "mode" "DI")
2208 (set_attr "length" "8")])
2210 (define_expand "<su>muldi3_highpart_split"
2211 [(set (match_operand:DI 0 "register_operand")
2214 (mult:TI (any_extend:TI (match_operand:DI 1 "register_operand"))
2215 (any_extend:TI (match_operand:DI 2 "register_operand")))
2221 hilo = gen_rtx_REG (TImode, MD_REG_FIRST);
2222 emit_insn (gen_<u>mulditi3_internal (hilo, operands[1], operands[2]));
2223 emit_insn (gen_mfhidi_ti (operands[0], hilo));
2227 (define_expand "<u>mulditi3"
2228 [(set (match_operand:TI 0 "register_operand")
2229 (mult:TI (any_extend:TI (match_operand:DI 1 "register_operand"))
2230 (any_extend:TI (match_operand:DI 2 "register_operand"))))]
2231 "TARGET_64BIT && !(<CODE> == ZERO_EXTEND && TARGET_FIX_VR4120)"
2237 hilo = gen_rtx_REG (TImode, MD_REG_FIRST);
2238 emit_insn (gen_<u>mulditi3_internal (hilo, operands[1], operands[2]));
2239 emit_move_insn (operands[0], hilo);
2241 else if (TARGET_FIX_R4000)
2242 emit_insn (gen_<u>mulditi3_r4000 (operands[0], operands[1], operands[2]));
2244 emit_insn (gen_<u>mulditi3_internal (operands[0], operands[1],
2249 (define_insn "<u>mulditi3_internal"
2250 [(set (match_operand:TI 0 "muldiv_target_operand" "=x")
2251 (mult:TI (any_extend:TI (match_operand:DI 1 "register_operand" "d"))
2252 (any_extend:TI (match_operand:DI 2 "register_operand" "d"))))]
2254 && !TARGET_FIX_R4000
2255 && !(<CODE> == ZERO_EXTEND && TARGET_FIX_VR4120)"
2257 [(set_attr "type" "imul")
2258 (set_attr "mode" "DI")])
2260 (define_insn "<u>mulditi3_r4000"
2261 [(set (match_operand:TI 0 "register_operand" "=d")
2262 (mult:TI (any_extend:TI (match_operand:DI 1 "register_operand" "d"))
2263 (any_extend:TI (match_operand:DI 2 "register_operand" "d"))))
2264 (clobber (match_scratch:TI 3 "=x"))]
2267 && !(<CODE> == ZERO_EXTEND && TARGET_FIX_VR4120)"
2268 "dmult<u>\t%1,%2\;mflo\t%L0\;mfhi\t%M0"
2269 [(set_attr "type" "imul")
2270 (set_attr "mode" "DI")
2271 (set_attr "length" "12")])
2273 ;; The R4650 supports a 32-bit multiply/ 64-bit accumulate
2274 ;; instruction. The HI/LO registers are used as a 64-bit accumulator.
2276 (define_insn "madsi"
2277 [(set (match_operand:SI 0 "register_operand" "+l")
2278 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d")
2279 (match_operand:SI 2 "register_operand" "d"))
2283 [(set_attr "type" "imadd")
2284 (set_attr "accum_in" "0")
2285 (set_attr "mode" "SI")])
2287 ;; See the comment above <u>msubsidi4 for the relationship between
2288 ;; ISA_HAS_DSP and ISA_HAS_DSP_MULT.
2289 (define_insn "<u>maddsidi4"
2290 [(set (match_operand:DI 0 "muldiv_target_operand" "=ka")
2292 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
2293 (any_extend:DI (match_operand:SI 2 "register_operand" "d")))
2294 (match_operand:DI 3 "muldiv_target_operand" "0")))]
2295 "(TARGET_MAD || ISA_HAS_MACC || GENERATE_MADD_MSUB || ISA_HAS_DSP)
2299 return "mad<u>\t%1,%2";
2300 else if (ISA_HAS_DSP_MULT)
2301 return "madd<u>\t%q0,%1,%2";
2302 else if (GENERATE_MADD_MSUB || TARGET_MIPS5500)
2303 return "madd<u>\t%1,%2";
2305 /* See comment in *macc. */
2306 return "%[macc<u>\t%@,%1,%2%]";
2308 [(set_attr "type" "imadd")
2309 (set_attr "accum_in" "3")
2310 (set_attr "mode" "SI")])
2312 ;; Floating point multiply accumulate instructions.
2314 (define_insn "*madd4<mode>"
2315 [(set (match_operand:ANYF 0 "register_operand" "=f")
2316 (plus:ANYF (mult:ANYF (match_operand:ANYF 1 "register_operand" "f")
2317 (match_operand:ANYF 2 "register_operand" "f"))
2318 (match_operand:ANYF 3 "register_operand" "f")))]
2319 "ISA_HAS_FP_MADD4_MSUB4 && TARGET_FUSED_MADD"
2320 "madd.<fmt>\t%0,%3,%1,%2"
2321 [(set_attr "type" "fmadd")
2322 (set_attr "accum_in" "3")
2323 (set_attr "mode" "<UNITMODE>")])
2325 (define_insn "*madd3<mode>"
2326 [(set (match_operand:ANYF 0 "register_operand" "=f")
2327 (plus:ANYF (mult:ANYF (match_operand:ANYF 1 "register_operand" "f")
2328 (match_operand:ANYF 2 "register_operand" "f"))
2329 (match_operand:ANYF 3 "register_operand" "0")))]
2330 "ISA_HAS_FP_MADD3_MSUB3 && TARGET_FUSED_MADD"
2331 "madd.<fmt>\t%0,%1,%2"
2332 [(set_attr "type" "fmadd")
2333 (set_attr "accum_in" "3")
2334 (set_attr "mode" "<UNITMODE>")])
2336 (define_insn "*msub4<mode>"
2337 [(set (match_operand:ANYF 0 "register_operand" "=f")
2338 (minus:ANYF (mult:ANYF (match_operand:ANYF 1 "register_operand" "f")
2339 (match_operand:ANYF 2 "register_operand" "f"))
2340 (match_operand:ANYF 3 "register_operand" "f")))]
2341 "ISA_HAS_FP_MADD4_MSUB4 && TARGET_FUSED_MADD"
2342 "msub.<fmt>\t%0,%3,%1,%2"
2343 [(set_attr "type" "fmadd")
2344 (set_attr "accum_in" "3")
2345 (set_attr "mode" "<UNITMODE>")])
2347 (define_insn "*msub3<mode>"
2348 [(set (match_operand:ANYF 0 "register_operand" "=f")
2349 (minus:ANYF (mult:ANYF (match_operand:ANYF 1 "register_operand" "f")
2350 (match_operand:ANYF 2 "register_operand" "f"))
2351 (match_operand:ANYF 3 "register_operand" "0")))]
2352 "ISA_HAS_FP_MADD3_MSUB3 && TARGET_FUSED_MADD"
2353 "msub.<fmt>\t%0,%1,%2"
2354 [(set_attr "type" "fmadd")
2355 (set_attr "accum_in" "3")
2356 (set_attr "mode" "<UNITMODE>")])
2358 (define_insn "*nmadd4<mode>"
2359 [(set (match_operand:ANYF 0 "register_operand" "=f")
2360 (neg:ANYF (plus:ANYF
2361 (mult:ANYF (match_operand:ANYF 1 "register_operand" "f")
2362 (match_operand:ANYF 2 "register_operand" "f"))
2363 (match_operand:ANYF 3 "register_operand" "f"))))]
2364 "ISA_HAS_NMADD4_NMSUB4 (<MODE>mode)
2365 && TARGET_FUSED_MADD
2366 && HONOR_SIGNED_ZEROS (<MODE>mode)
2367 && !HONOR_NANS (<MODE>mode)"
2368 "nmadd.<fmt>\t%0,%3,%1,%2"
2369 [(set_attr "type" "fmadd")
2370 (set_attr "accum_in" "3")
2371 (set_attr "mode" "<UNITMODE>")])
2373 (define_insn "*nmadd3<mode>"
2374 [(set (match_operand:ANYF 0 "register_operand" "=f")
2375 (neg:ANYF (plus:ANYF
2376 (mult:ANYF (match_operand:ANYF 1 "register_operand" "f")
2377 (match_operand:ANYF 2 "register_operand" "f"))
2378 (match_operand:ANYF 3 "register_operand" "0"))))]
2379 "ISA_HAS_NMADD3_NMSUB3 (<MODE>mode)
2380 && TARGET_FUSED_MADD
2381 && HONOR_SIGNED_ZEROS (<MODE>mode)
2382 && !HONOR_NANS (<MODE>mode)"
2383 "nmadd.<fmt>\t%0,%1,%2"
2384 [(set_attr "type" "fmadd")
2385 (set_attr "accum_in" "3")
2386 (set_attr "mode" "<UNITMODE>")])
2388 (define_insn "*nmadd4<mode>_fastmath"
2389 [(set (match_operand:ANYF 0 "register_operand" "=f")
2391 (mult:ANYF (neg:ANYF (match_operand:ANYF 1 "register_operand" "f"))
2392 (match_operand:ANYF 2 "register_operand" "f"))
2393 (match_operand:ANYF 3 "register_operand" "f")))]
2394 "ISA_HAS_NMADD4_NMSUB4 (<MODE>mode)
2395 && TARGET_FUSED_MADD
2396 && !HONOR_SIGNED_ZEROS (<MODE>mode)
2397 && !HONOR_NANS (<MODE>mode)"
2398 "nmadd.<fmt>\t%0,%3,%1,%2"
2399 [(set_attr "type" "fmadd")
2400 (set_attr "accum_in" "3")
2401 (set_attr "mode" "<UNITMODE>")])
2403 (define_insn "*nmadd3<mode>_fastmath"
2404 [(set (match_operand:ANYF 0 "register_operand" "=f")
2406 (mult:ANYF (neg:ANYF (match_operand:ANYF 1 "register_operand" "f"))
2407 (match_operand:ANYF 2 "register_operand" "f"))
2408 (match_operand:ANYF 3 "register_operand" "0")))]
2409 "ISA_HAS_NMADD3_NMSUB3 (<MODE>mode)
2410 && TARGET_FUSED_MADD
2411 && !HONOR_SIGNED_ZEROS (<MODE>mode)
2412 && !HONOR_NANS (<MODE>mode)"
2413 "nmadd.<fmt>\t%0,%1,%2"
2414 [(set_attr "type" "fmadd")
2415 (set_attr "accum_in" "3")
2416 (set_attr "mode" "<UNITMODE>")])
2418 (define_insn "*nmsub4<mode>"
2419 [(set (match_operand:ANYF 0 "register_operand" "=f")
2420 (neg:ANYF (minus:ANYF
2421 (mult:ANYF (match_operand:ANYF 2 "register_operand" "f")
2422 (match_operand:ANYF 3 "register_operand" "f"))
2423 (match_operand:ANYF 1 "register_operand" "f"))))]
2424 "ISA_HAS_NMADD4_NMSUB4 (<MODE>mode)
2425 && TARGET_FUSED_MADD
2426 && HONOR_SIGNED_ZEROS (<MODE>mode)
2427 && !HONOR_NANS (<MODE>mode)"
2428 "nmsub.<fmt>\t%0,%1,%2,%3"
2429 [(set_attr "type" "fmadd")
2430 (set_attr "accum_in" "1")
2431 (set_attr "mode" "<UNITMODE>")])
2433 (define_insn "*nmsub3<mode>"
2434 [(set (match_operand:ANYF 0 "register_operand" "=f")
2435 (neg:ANYF (minus:ANYF
2436 (mult:ANYF (match_operand:ANYF 2 "register_operand" "f")
2437 (match_operand:ANYF 3 "register_operand" "f"))
2438 (match_operand:ANYF 1 "register_operand" "0"))))]
2439 "ISA_HAS_NMADD3_NMSUB3 (<MODE>mode)
2440 && TARGET_FUSED_MADD
2441 && HONOR_SIGNED_ZEROS (<MODE>mode)
2442 && !HONOR_NANS (<MODE>mode)"
2443 "nmsub.<fmt>\t%0,%1,%2"
2444 [(set_attr "type" "fmadd")
2445 (set_attr "accum_in" "1")
2446 (set_attr "mode" "<UNITMODE>")])
2448 (define_insn "*nmsub4<mode>_fastmath"
2449 [(set (match_operand:ANYF 0 "register_operand" "=f")
2451 (match_operand:ANYF 1 "register_operand" "f")
2452 (mult:ANYF (match_operand:ANYF 2 "register_operand" "f")
2453 (match_operand:ANYF 3 "register_operand" "f"))))]
2454 "ISA_HAS_NMADD4_NMSUB4 (<MODE>mode)
2455 && TARGET_FUSED_MADD
2456 && !HONOR_SIGNED_ZEROS (<MODE>mode)
2457 && !HONOR_NANS (<MODE>mode)"
2458 "nmsub.<fmt>\t%0,%1,%2,%3"
2459 [(set_attr "type" "fmadd")
2460 (set_attr "accum_in" "1")
2461 (set_attr "mode" "<UNITMODE>")])
2463 (define_insn "*nmsub3<mode>_fastmath"
2464 [(set (match_operand:ANYF 0 "register_operand" "=f")
2466 (match_operand:ANYF 1 "register_operand" "f")
2467 (mult:ANYF (match_operand:ANYF 2 "register_operand" "f")
2468 (match_operand:ANYF 3 "register_operand" "0"))))]
2469 "ISA_HAS_NMADD3_NMSUB3 (<MODE>mode)
2470 && TARGET_FUSED_MADD
2471 && !HONOR_SIGNED_ZEROS (<MODE>mode)
2472 && !HONOR_NANS (<MODE>mode)"
2473 "nmsub.<fmt>\t%0,%1,%2"
2474 [(set_attr "type" "fmadd")
2475 (set_attr "accum_in" "1")
2476 (set_attr "mode" "<UNITMODE>")])
2479 ;; ....................
2481 ;; DIVISION and REMAINDER
2483 ;; ....................
2486 (define_expand "div<mode>3"
2487 [(set (match_operand:ANYF 0 "register_operand")
2488 (div:ANYF (match_operand:ANYF 1 "reg_or_1_operand")
2489 (match_operand:ANYF 2 "register_operand")))]
2490 "<divide_condition>"
2492 if (const_1_operand (operands[1], <MODE>mode))
2493 if (!(<recip_condition> && flag_unsafe_math_optimizations))
2494 operands[1] = force_reg (<MODE>mode, operands[1]);
2497 ;; These patterns work around the early SB-1 rev2 core "F1" erratum:
2499 ;; If an mfc1 or dmfc1 happens to access the floating point register
2500 ;; file at the same time a long latency operation (div, sqrt, recip,
2501 ;; sqrt) iterates an intermediate result back through the floating
2502 ;; point register file bypass, then instead returning the correct
2503 ;; register value the mfc1 or dmfc1 operation returns the intermediate
2504 ;; result of the long latency operation.
2506 ;; The workaround is to insert an unconditional 'mov' from/to the
2507 ;; long latency op destination register.
2509 (define_insn "*div<mode>3"
2510 [(set (match_operand:ANYF 0 "register_operand" "=f")
2511 (div:ANYF (match_operand:ANYF 1 "register_operand" "f")
2512 (match_operand:ANYF 2 "register_operand" "f")))]
2513 "<divide_condition>"
2516 return "div.<fmt>\t%0,%1,%2\;mov.<fmt>\t%0,%0";
2518 return "div.<fmt>\t%0,%1,%2";
2520 [(set_attr "type" "fdiv")
2521 (set_attr "mode" "<UNITMODE>")
2522 (set (attr "length")
2523 (if_then_else (match_test "TARGET_FIX_SB1")
2527 (define_insn "*recip<mode>3"
2528 [(set (match_operand:ANYF 0 "register_operand" "=f")
2529 (div:ANYF (match_operand:ANYF 1 "const_1_operand" "")
2530 (match_operand:ANYF 2 "register_operand" "f")))]
2531 "<recip_condition> && flag_unsafe_math_optimizations"
2534 return "recip.<fmt>\t%0,%2\;mov.<fmt>\t%0,%0";
2536 return "recip.<fmt>\t%0,%2";
2538 [(set_attr "type" "frdiv")
2539 (set_attr "mode" "<UNITMODE>")
2540 (set (attr "length")
2541 (if_then_else (match_test "TARGET_FIX_SB1")
2545 ;; VR4120 errata MD(A1): signed division instructions do not work correctly
2546 ;; with negative operands. We use special libgcc functions instead.
2547 (define_expand "divmod<mode>4"
2548 [(set (match_operand:GPR 0 "register_operand")
2549 (div:GPR (match_operand:GPR 1 "register_operand")
2550 (match_operand:GPR 2 "register_operand")))
2551 (set (match_operand:GPR 3 "register_operand")
2552 (mod:GPR (match_dup 1)
2554 "!TARGET_FIX_VR4120"
2558 emit_insn (gen_divmod<mode>4_split (operands[3], operands[1],
2560 emit_move_insn (operands[0], gen_rtx_REG (<MODE>mode, LO_REGNUM));
2563 emit_insn (gen_divmod<mode>4_internal (operands[0], operands[1],
2564 operands[2], operands[3]));
2568 (define_insn_and_split "divmod<mode>4_internal"
2569 [(set (match_operand:GPR 0 "muldiv_target_operand" "=l")
2570 (div:GPR (match_operand:GPR 1 "register_operand" "d")
2571 (match_operand:GPR 2 "register_operand" "d")))
2572 (set (match_operand:GPR 3 "register_operand" "=d")
2573 (mod:GPR (match_dup 1)
2575 "!TARGET_FIX_VR4120 && !TARGET_MIPS16"
2577 "&& reload_completed"
2580 emit_insn (gen_divmod<mode>4_split (operands[3], operands[1], operands[2]));
2583 [(set_attr "type" "idiv")
2584 (set_attr "mode" "<MODE>")
2585 (set_attr "length" "8")])
2587 (define_expand "udivmod<mode>4"
2588 [(set (match_operand:GPR 0 "register_operand")
2589 (udiv:GPR (match_operand:GPR 1 "register_operand")
2590 (match_operand:GPR 2 "register_operand")))
2591 (set (match_operand:GPR 3 "register_operand")
2592 (umod:GPR (match_dup 1)
2598 emit_insn (gen_udivmod<mode>4_split (operands[3], operands[1],
2600 emit_move_insn (operands[0], gen_rtx_REG (<MODE>mode, LO_REGNUM));
2603 emit_insn (gen_udivmod<mode>4_internal (operands[0], operands[1],
2604 operands[2], operands[3]));
2608 (define_insn_and_split "udivmod<mode>4_internal"
2609 [(set (match_operand:GPR 0 "muldiv_target_operand" "=l")
2610 (udiv:GPR (match_operand:GPR 1 "register_operand" "d")
2611 (match_operand:GPR 2 "register_operand" "d")))
2612 (set (match_operand:GPR 3 "register_operand" "=d")
2613 (umod:GPR (match_dup 1)
2620 emit_insn (gen_udivmod<mode>4_split (operands[3], operands[1], operands[2]));
2623 [(set_attr "type" "idiv")
2624 (set_attr "mode" "<MODE>")
2625 (set_attr "length" "8")])
2627 (define_expand "<u>divmod<mode>4_split"
2628 [(set (match_operand:GPR 0 "register_operand")
2629 (any_mod:GPR (match_operand:GPR 1 "register_operand")
2630 (match_operand:GPR 2 "register_operand")))]
2637 hilo = gen_rtx_REG (TImode, MD_REG_FIRST);
2638 emit_insn (gen_<u>divmod<mode>4_hilo_ti (hilo, operands[1],
2640 emit_insn (gen_mfhi<mode>_ti (operands[0], hilo));
2644 hilo = gen_rtx_REG (DImode, MD_REG_FIRST);
2645 emit_insn (gen_<u>divmod<mode>4_hilo_di (hilo, operands[1],
2647 emit_insn (gen_mfhi<mode>_di (operands[0], hilo));
2652 (define_insn "<u>divmod<GPR:mode>4_hilo_<HILO:mode>"
2653 [(set (match_operand:HILO 0 "muldiv_target_operand" "=x")
2655 [(any_div:GPR (match_operand:GPR 1 "register_operand" "d")
2656 (match_operand:GPR 2 "register_operand" "d"))]
2659 { return mips_output_division ("<GPR:d>div<u>\t%.,%1,%2", operands); }
2660 [(set_attr "type" "idiv")
2661 (set_attr "mode" "<GPR:MODE>")])
2664 ;; ....................
2668 ;; ....................
2670 ;; These patterns work around the early SB-1 rev2 core "F1" erratum (see
2671 ;; "*div[sd]f3" comment for details).
2673 (define_insn "sqrt<mode>2"
2674 [(set (match_operand:ANYF 0 "register_operand" "=f")
2675 (sqrt:ANYF (match_operand:ANYF 1 "register_operand" "f")))]
2679 return "sqrt.<fmt>\t%0,%1\;mov.<fmt>\t%0,%0";
2681 return "sqrt.<fmt>\t%0,%1";
2683 [(set_attr "type" "fsqrt")
2684 (set_attr "mode" "<UNITMODE>")
2685 (set (attr "length")
2686 (if_then_else (match_test "TARGET_FIX_SB1")
2690 (define_insn "*rsqrt<mode>a"
2691 [(set (match_operand:ANYF 0 "register_operand" "=f")
2692 (div:ANYF (match_operand:ANYF 1 "const_1_operand" "")
2693 (sqrt:ANYF (match_operand:ANYF 2 "register_operand" "f"))))]
2694 "<recip_condition> && flag_unsafe_math_optimizations"
2697 return "rsqrt.<fmt>\t%0,%2\;mov.<fmt>\t%0,%0";
2699 return "rsqrt.<fmt>\t%0,%2";
2701 [(set_attr "type" "frsqrt")
2702 (set_attr "mode" "<UNITMODE>")
2703 (set (attr "length")
2704 (if_then_else (match_test "TARGET_FIX_SB1")
2708 (define_insn "*rsqrt<mode>b"
2709 [(set (match_operand:ANYF 0 "register_operand" "=f")
2710 (sqrt:ANYF (div:ANYF (match_operand:ANYF 1 "const_1_operand" "")
2711 (match_operand:ANYF 2 "register_operand" "f"))))]
2712 "<recip_condition> && flag_unsafe_math_optimizations"
2715 return "rsqrt.<fmt>\t%0,%2\;mov.<fmt>\t%0,%0";
2717 return "rsqrt.<fmt>\t%0,%2";
2719 [(set_attr "type" "frsqrt")
2720 (set_attr "mode" "<UNITMODE>")
2721 (set (attr "length")
2722 (if_then_else (match_test "TARGET_FIX_SB1")
2727 ;; ....................
2731 ;; ....................
2733 ;; Do not use the integer abs macro instruction, since that signals an
2734 ;; exception on -2147483648 (sigh).
2736 ;; abs.fmt is an arithmetic instruction and treats all NaN inputs as
2737 ;; invalid; it does not clear their sign bits. We therefore can't use
2738 ;; abs.fmt if the signs of NaNs matter.
2740 (define_insn "abs<mode>2"
2741 [(set (match_operand:ANYF 0 "register_operand" "=f")
2742 (abs:ANYF (match_operand:ANYF 1 "register_operand" "f")))]
2743 "!HONOR_NANS (<MODE>mode)"
2745 [(set_attr "type" "fabs")
2746 (set_attr "mode" "<UNITMODE>")])
2749 ;; ...................
2751 ;; Count leading zeroes.
2753 ;; ...................
2756 (define_insn "clz<mode>2"
2757 [(set (match_operand:GPR 0 "register_operand" "=d")
2758 (clz:GPR (match_operand:GPR 1 "register_operand" "d")))]
2761 [(set_attr "type" "clz")
2762 (set_attr "mode" "<MODE>")])
2765 ;; ...................
2767 ;; Count number of set bits.
2769 ;; ...................
2772 (define_insn "popcount<mode>2"
2773 [(set (match_operand:GPR 0 "register_operand" "=d")
2774 (popcount:GPR (match_operand:GPR 1 "register_operand" "d")))]
2777 [(set_attr "type" "pop")
2778 (set_attr "mode" "<MODE>")])
2780 ;; The POP instruction is special as it does not take into account the upper
2781 ;; 32bits and is documented that way.
2782 (define_insn "*popcountdi2_trunc"
2783 [(set (match_operand:SI 0 "register_operand" "=d")
2784 (popcount:SI (truncate:SI (match_operand:DI 1 "register_operand" "d"))))]
2785 "ISA_HAS_POP && TARGET_64BIT"
2787 [(set_attr "type" "pop")
2788 (set_attr "mode" "SI")])
2791 ;; ....................
2793 ;; NEGATION and ONE'S COMPLEMENT
2795 ;; ....................
2797 (define_insn "negsi2"
2798 [(set (match_operand:SI 0 "register_operand" "=d")
2799 (neg:SI (match_operand:SI 1 "register_operand" "d")))]
2803 return "neg\t%0,%1";
2805 return "subu\t%0,%.,%1";
2807 [(set_attr "alu_type" "sub")
2808 (set_attr "mode" "SI")])
2810 (define_insn "negdi2"
2811 [(set (match_operand:DI 0 "register_operand" "=d")
2812 (neg:DI (match_operand:DI 1 "register_operand" "d")))]
2813 "TARGET_64BIT && !TARGET_MIPS16"
2815 [(set_attr "alu_type" "sub")
2816 (set_attr "mode" "DI")])
2818 ;; neg.fmt is an arithmetic instruction and treats all NaN inputs as
2819 ;; invalid; it does not flip their sign bit. We therefore can't use
2820 ;; neg.fmt if the signs of NaNs matter.
2822 (define_insn "neg<mode>2"
2823 [(set (match_operand:ANYF 0 "register_operand" "=f")
2824 (neg:ANYF (match_operand:ANYF 1 "register_operand" "f")))]
2825 "!HONOR_NANS (<MODE>mode)"
2827 [(set_attr "type" "fneg")
2828 (set_attr "mode" "<UNITMODE>")])
2830 (define_insn "one_cmpl<mode>2"
2831 [(set (match_operand:GPR 0 "register_operand" "=d")
2832 (not:GPR (match_operand:GPR 1 "register_operand" "d")))]
2836 return "not\t%0,%1";
2838 return "nor\t%0,%.,%1";
2840 [(set_attr "alu_type" "not")
2841 (set_attr "mode" "<MODE>")])
2844 ;; ....................
2848 ;; ....................
2851 ;; Many of these instructions use trivial define_expands, because we
2852 ;; want to use a different set of constraints when TARGET_MIPS16.
2854 (define_expand "and<mode>3"
2855 [(set (match_operand:GPR 0 "register_operand")
2856 (and:GPR (match_operand:GPR 1 "register_operand")
2857 (match_operand:GPR 2 "and_reg_operand")))])
2859 ;; The middle-end is not allowed to convert ANDing with 0xffff_ffff into a
2860 ;; zero_extendsidi2 because of TRULY_NOOP_TRUNCATION, so handle these here.
2861 ;; Note that this variant does not trigger for SI mode because we require
2862 ;; a 64-bit HOST_WIDE_INT and 0xffff_ffff wouldn't be a canonical
2863 ;; sign-extended SImode value.
2865 ;; These are possible combinations for operand 1 and 2. The table
2866 ;; includes both MIPS and MIPS16 cases. (r=register, mem=memory,
2867 ;; 16=MIPS16, x=match, S=split):
2869 ;; \ op1 r/EXT r/!EXT mem r/16 mem/16
2875 ;; 0xffff_ffff x S x S x
2880 (define_insn "*and<mode>3"
2881 [(set (match_operand:GPR 0 "register_operand" "=d,d,d,d,d,d,d")
2882 (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "o,o,W,d,d,d,d")
2883 (match_operand:GPR 2 "and_operand" "Yb,Yh,Yw,K,Yx,Yw,d")))]
2884 "!TARGET_MIPS16 && and_operands_ok (<MODE>mode, operands[1], operands[2])"
2888 switch (which_alternative)
2891 operands[1] = gen_lowpart (QImode, operands[1]);
2892 return "lbu\t%0,%1";
2894 operands[1] = gen_lowpart (HImode, operands[1]);
2895 return "lhu\t%0,%1";
2897 operands[1] = gen_lowpart (SImode, operands[1]);
2898 return "lwu\t%0,%1";
2900 return "andi\t%0,%1,%x2";
2902 len = low_bitmask_len (<MODE>mode, INTVAL (operands[2]));
2903 operands[2] = GEN_INT (len);
2904 return "<d>ext\t%0,%1,0,%2";
2908 return "and\t%0,%1,%2";
2913 [(set_attr "move_type" "load,load,load,andi,ext_ins,shift_shift,logical")
2914 (set_attr "mode" "<MODE>")])
2916 (define_insn "*and<mode>3_mips16"
2917 [(set (match_operand:GPR 0 "register_operand" "=d,d,d,d,d")
2918 (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "%W,W,W,d,0")
2919 (match_operand:GPR 2 "and_operand" "Yb,Yh,Yw,Yw,d")))]
2920 "TARGET_MIPS16 && and_operands_ok (<MODE>mode, operands[1], operands[2])"
2922 switch (which_alternative)
2925 operands[1] = gen_lowpart (QImode, operands[1]);
2926 return "lbu\t%0,%1";
2928 operands[1] = gen_lowpart (HImode, operands[1]);
2929 return "lhu\t%0,%1";
2931 operands[1] = gen_lowpart (SImode, operands[1]);
2932 return "lwu\t%0,%1";
2936 return "and\t%0,%2";
2941 [(set_attr "move_type" "load,load,load,shift_shift,logical")
2942 (set_attr "mode" "<MODE>")])
2944 (define_expand "ior<mode>3"
2945 [(set (match_operand:GPR 0 "register_operand")
2946 (ior:GPR (match_operand:GPR 1 "register_operand")
2947 (match_operand:GPR 2 "uns_arith_operand")))]
2951 operands[2] = force_reg (<MODE>mode, operands[2]);
2954 (define_insn "*ior<mode>3"
2955 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2956 (ior:GPR (match_operand:GPR 1 "register_operand" "%d,d")
2957 (match_operand:GPR 2 "uns_arith_operand" "d,K")))]
2962 [(set_attr "alu_type" "or")
2963 (set_attr "mode" "<MODE>")])
2965 (define_insn "*ior<mode>3_mips16"
2966 [(set (match_operand:GPR 0 "register_operand" "=d")
2967 (ior:GPR (match_operand:GPR 1 "register_operand" "%0")
2968 (match_operand:GPR 2 "register_operand" "d")))]
2971 [(set_attr "alu_type" "or")
2972 (set_attr "mode" "<MODE>")])
2974 (define_expand "xor<mode>3"
2975 [(set (match_operand:GPR 0 "register_operand")
2976 (xor:GPR (match_operand:GPR 1 "register_operand")
2977 (match_operand:GPR 2 "uns_arith_operand")))]
2982 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2983 (xor:GPR (match_operand:GPR 1 "register_operand" "%d,d")
2984 (match_operand:GPR 2 "uns_arith_operand" "d,K")))]
2989 [(set_attr "alu_type" "xor")
2990 (set_attr "mode" "<MODE>")])
2993 [(set (match_operand:GPR 0 "register_operand" "=d,t,t")
2994 (xor:GPR (match_operand:GPR 1 "register_operand" "%0,d,d")
2995 (match_operand:GPR 2 "uns_arith_operand" "d,K,d")))]
3001 [(set_attr "alu_type" "xor")
3002 (set_attr "mode" "<MODE>")
3003 (set_attr_alternative "length"
3005 (if_then_else (match_operand:VOID 2 "m16_uimm8_1")
3010 (define_insn "*nor<mode>3"
3011 [(set (match_operand:GPR 0 "register_operand" "=d")
3012 (and:GPR (not:GPR (match_operand:GPR 1 "register_operand" "d"))
3013 (not:GPR (match_operand:GPR 2 "register_operand" "d"))))]
3016 [(set_attr "alu_type" "nor")
3017 (set_attr "mode" "<MODE>")])
3020 ;; ....................
3024 ;; ....................
3028 (define_insn "truncdfsf2"
3029 [(set (match_operand:SF 0 "register_operand" "=f")
3030 (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
3031 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
3033 [(set_attr "type" "fcvt")
3034 (set_attr "cnv_mode" "D2S")
3035 (set_attr "mode" "SF")])
3037 ;; Integer truncation patterns. Truncating SImode values to smaller
3038 ;; modes is a no-op, as it is for most other GCC ports. Truncating
3039 ;; DImode values to SImode is not a no-op for TARGET_64BIT since we
3040 ;; need to make sure that the lower 32 bits are properly sign-extended
3041 ;; (see TRULY_NOOP_TRUNCATION). Truncating DImode values into modes
3042 ;; smaller than SImode is equivalent to two separate truncations:
3045 ;; DI ---> HI == DI ---> SI ---> HI
3046 ;; DI ---> QI == DI ---> SI ---> QI
3048 ;; Step A needs a real instruction but step B does not.
3050 (define_insn "truncdi<mode>2"
3051 [(set (match_operand:SUBDI 0 "nonimmediate_operand" "=d,m")
3052 (truncate:SUBDI (match_operand:DI 1 "register_operand" "d,d")))]
3057 [(set_attr "move_type" "sll0,store")
3058 (set_attr "mode" "SI")])
3060 ;; Combiner patterns to optimize shift/truncate combinations.
3062 (define_insn "*ashr_trunc<mode>"
3063 [(set (match_operand:SUBDI 0 "register_operand" "=d")
3065 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
3066 (match_operand:DI 2 "const_arith_operand" ""))))]
3067 "TARGET_64BIT && !TARGET_MIPS16 && IN_RANGE (INTVAL (operands[2]), 32, 63)"
3069 [(set_attr "type" "shift")
3070 (set_attr "mode" "<MODE>")])
3072 (define_insn "*lshr32_trunc<mode>"
3073 [(set (match_operand:SUBDI 0 "register_operand" "=d")
3075 (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
3077 "TARGET_64BIT && !TARGET_MIPS16"
3079 [(set_attr "type" "shift")
3080 (set_attr "mode" "<MODE>")])
3082 ;; Logical shift by more than 32 results in proper SI values so truncation is
3083 ;; removed by the middle end. Note that a logical shift by 32 is handled by
3084 ;; the previous pattern.
3085 (define_insn "*<optab>_trunc<mode>_exts"
3086 [(set (match_operand:SUBDI 0 "register_operand" "=d")
3088 (any_shiftrt:DI (match_operand:DI 1 "register_operand" "d")
3089 (match_operand:DI 2 "const_arith_operand" ""))))]
3090 "ISA_HAS_EXTS && TARGET_64BIT && UINTVAL (operands[2]) < 32"
3092 [(set_attr "type" "arith")
3093 (set_attr "mode" "<MODE>")])
3096 ;; ....................
3100 ;; ....................
3104 (define_expand "zero_extendsidi2"
3105 [(set (match_operand:DI 0 "register_operand")
3106 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand")))]
3109 (define_insn_and_split "*zero_extendsidi2"
3110 [(set (match_operand:DI 0 "register_operand" "=d,d")
3111 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,W")))]
3112 "TARGET_64BIT && !ISA_HAS_EXT_INS"
3116 "&& reload_completed && REG_P (operands[1])"
3118 (ashift:DI (match_dup 1) (const_int 32)))
3120 (lshiftrt:DI (match_dup 0) (const_int 32)))]
3121 { operands[1] = gen_lowpart (DImode, operands[1]); }
3122 [(set_attr "move_type" "shift_shift,load")
3123 (set_attr "mode" "DI")])
3125 (define_insn "*zero_extendsidi2_dext"
3126 [(set (match_operand:DI 0 "register_operand" "=d,d")
3127 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,W")))]
3128 "TARGET_64BIT && ISA_HAS_EXT_INS"
3132 [(set_attr "move_type" "arith,load")
3133 (set_attr "mode" "DI")])
3135 ;; See the comment before the *and<mode>3 pattern why this is generated by
3139 [(set (match_operand:DI 0 "register_operand")
3140 (and:DI (match_operand:DI 1 "register_operand")
3141 (const_int 4294967295)))]
3142 "TARGET_64BIT && !ISA_HAS_EXT_INS && reload_completed"
3144 (ashift:DI (match_dup 1) (const_int 32)))
3146 (lshiftrt:DI (match_dup 0) (const_int 32)))])
3148 (define_expand "zero_extend<SHORT:mode><GPR:mode>2"
3149 [(set (match_operand:GPR 0 "register_operand")
3150 (zero_extend:GPR (match_operand:SHORT 1 "nonimmediate_operand")))]
3153 if (TARGET_MIPS16 && !GENERATE_MIPS16E
3154 && !memory_operand (operands[1], <SHORT:MODE>mode))
3156 emit_insn (gen_and<GPR:mode>3 (operands[0],
3157 gen_lowpart (<GPR:MODE>mode, operands[1]),
3158 force_reg (<GPR:MODE>mode,
3159 GEN_INT (<SHORT:mask>))));
3164 (define_insn "*zero_extend<SHORT:mode><GPR:mode>2"
3165 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3167 (match_operand:SHORT 1 "nonimmediate_operand" "d,m")))]
3170 andi\t%0,%1,<SHORT:mask>
3171 l<SHORT:size>u\t%0,%1"
3172 [(set_attr "move_type" "andi,load")
3173 (set_attr "mode" "<GPR:MODE>")])
3175 (define_insn "*zero_extend<SHORT:mode><GPR:mode>2_mips16e"
3176 [(set (match_operand:GPR 0 "register_operand" "=d")
3177 (zero_extend:GPR (match_operand:SHORT 1 "register_operand" "0")))]
3179 "ze<SHORT:size>\t%0"
3180 ;; This instruction is effectively a special encoding of ANDI.
3181 [(set_attr "move_type" "andi")
3182 (set_attr "mode" "<GPR:MODE>")])
3184 (define_insn "*zero_extend<SHORT:mode><GPR:mode>2_mips16"
3185 [(set (match_operand:GPR 0 "register_operand" "=d")
3186 (zero_extend:GPR (match_operand:SHORT 1 "memory_operand" "m")))]
3188 "l<SHORT:size>u\t%0,%1"
3189 [(set_attr "move_type" "load")
3190 (set_attr "mode" "<GPR:MODE>")])
3192 (define_expand "zero_extendqihi2"
3193 [(set (match_operand:HI 0 "register_operand")
3194 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand")))]
3197 if (TARGET_MIPS16 && !memory_operand (operands[1], QImode))
3199 emit_insn (gen_zero_extendqisi2 (gen_lowpart (SImode, operands[0]),
3205 (define_insn "*zero_extendqihi2"
3206 [(set (match_operand:HI 0 "register_operand" "=d,d")
3207 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
3212 [(set_attr "move_type" "andi,load")
3213 (set_attr "mode" "HI")])
3215 (define_insn "*zero_extendqihi2_mips16"
3216 [(set (match_operand:HI 0 "register_operand" "=d")
3217 (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
3220 [(set_attr "move_type" "load")
3221 (set_attr "mode" "HI")])
3223 ;; Combiner patterns to optimize truncate/zero_extend combinations.
3225 (define_insn "*zero_extend<GPR:mode>_trunc<SHORT:mode>"
3226 [(set (match_operand:GPR 0 "register_operand" "=d")
3228 (truncate:SHORT (match_operand:DI 1 "register_operand" "d"))))]
3229 "TARGET_64BIT && !TARGET_MIPS16"
3231 operands[2] = GEN_INT (GET_MODE_MASK (<SHORT:MODE>mode));
3232 return "andi\t%0,%1,%x2";
3234 [(set_attr "alu_type" "and")
3235 (set_attr "mode" "<GPR:MODE>")])
3237 (define_insn "*zero_extendhi_truncqi"
3238 [(set (match_operand:HI 0 "register_operand" "=d")
3240 (truncate:QI (match_operand:DI 1 "register_operand" "d"))))]
3241 "TARGET_64BIT && !TARGET_MIPS16"
3243 [(set_attr "alu_type" "and")
3244 (set_attr "mode" "HI")])
3247 ;; ....................
3251 ;; ....................
3254 ;; Those for integer source operand are ordered widest source type first.
3256 ;; When TARGET_64BIT, all SImode integer and accumulator registers
3257 ;; should already be in sign-extended form (see TRULY_NOOP_TRUNCATION
3258 ;; and truncdisi2). We can therefore get rid of register->register
3259 ;; instructions if we constrain the source to be in the same register as
3262 ;; Only the pre-reload scheduler sees the type of the register alternatives;
3263 ;; we split them into nothing before the post-reload scheduler runs.
3264 ;; These alternatives therefore have type "move" in order to reflect
3265 ;; what happens if the two pre-reload operands cannot be tied, and are
3266 ;; instead allocated two separate GPRs. We don't distinguish between
3267 ;; the GPR and LO cases because we don't usually know during pre-reload
3268 ;; scheduling whether an operand will be LO or not.
3269 (define_insn_and_split "extendsidi2"
3270 [(set (match_operand:DI 0 "register_operand" "=d,l,d")
3271 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "0,0,m")))]
3277 "&& reload_completed && register_operand (operands[1], VOIDmode)"
3280 emit_note (NOTE_INSN_DELETED);
3283 [(set_attr "move_type" "move,move,load")
3284 (set_attr "mode" "DI")])
3286 (define_expand "extend<SHORT:mode><GPR:mode>2"
3287 [(set (match_operand:GPR 0 "register_operand")
3288 (sign_extend:GPR (match_operand:SHORT 1 "nonimmediate_operand")))]
3291 (define_insn "*extend<SHORT:mode><GPR:mode>2_mips16e"
3292 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3293 (sign_extend:GPR (match_operand:SHORT 1 "nonimmediate_operand" "0,m")))]
3297 l<SHORT:size>\t%0,%1"
3298 [(set_attr "move_type" "signext,load")
3299 (set_attr "mode" "<GPR:MODE>")])
3301 (define_insn_and_split "*extend<SHORT:mode><GPR:mode>2"
3302 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3304 (match_operand:SHORT 1 "nonimmediate_operand" "d,m")))]
3305 "!ISA_HAS_SEB_SEH && !GENERATE_MIPS16E"
3308 l<SHORT:size>\t%0,%1"
3309 "&& reload_completed && REG_P (operands[1])"
3310 [(set (match_dup 0) (ashift:GPR (match_dup 1) (match_dup 2)))
3311 (set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))]
3313 operands[1] = gen_lowpart (<GPR:MODE>mode, operands[1]);
3314 operands[2] = GEN_INT (GET_MODE_BITSIZE (<GPR:MODE>mode)
3315 - GET_MODE_BITSIZE (<SHORT:MODE>mode));
3317 [(set_attr "move_type" "shift_shift,load")
3318 (set_attr "mode" "<GPR:MODE>")])
3320 (define_insn "*extend<SHORT:mode><GPR:mode>2_se<SHORT:size>"
3321 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3323 (match_operand:SHORT 1 "nonimmediate_operand" "d,m")))]
3326 se<SHORT:size>\t%0,%1
3327 l<SHORT:size>\t%0,%1"
3328 [(set_attr "move_type" "signext,load")
3329 (set_attr "mode" "<GPR:MODE>")])
3331 (define_expand "extendqihi2"
3332 [(set (match_operand:HI 0 "register_operand")
3333 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand")))]
3336 (define_insn "*extendqihi2_mips16e"
3337 [(set (match_operand:HI 0 "register_operand" "=d,d")
3338 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0,m")))]
3343 [(set_attr "move_type" "signext,load")
3344 (set_attr "mode" "SI")])
3346 (define_insn_and_split "*extendqihi2"
3347 [(set (match_operand:HI 0 "register_operand" "=d,d")
3349 (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
3350 "!ISA_HAS_SEB_SEH && !GENERATE_MIPS16E"
3354 "&& reload_completed && REG_P (operands[1])"
3355 [(set (match_dup 0) (ashift:SI (match_dup 1) (match_dup 2)))
3356 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (match_dup 2)))]
3358 operands[0] = gen_lowpart (SImode, operands[0]);
3359 operands[1] = gen_lowpart (SImode, operands[1]);
3360 operands[2] = GEN_INT (GET_MODE_BITSIZE (SImode)
3361 - GET_MODE_BITSIZE (QImode));
3363 [(set_attr "move_type" "shift_shift,load")
3364 (set_attr "mode" "SI")])
3366 (define_insn "*extendqihi2_seb"
3367 [(set (match_operand:HI 0 "register_operand" "=d,d")
3369 (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
3374 [(set_attr "move_type" "signext,load")
3375 (set_attr "mode" "SI")])
3377 ;; Combiner patterns for truncate/sign_extend combinations. The SI versions
3378 ;; use the shift/truncate patterns.
3380 (define_insn_and_split "*extenddi_truncate<mode>"
3381 [(set (match_operand:DI 0 "register_operand" "=d")
3383 (truncate:SHORT (match_operand:DI 1 "register_operand" "d"))))]
3384 "TARGET_64BIT && !TARGET_MIPS16 && !ISA_HAS_EXTS"
3386 "&& reload_completed"
3388 (ashift:DI (match_dup 1)
3391 (ashiftrt:DI (match_dup 2)
3394 operands[2] = gen_lowpart (DImode, operands[0]);
3395 operands[3] = GEN_INT (BITS_PER_WORD - GET_MODE_BITSIZE (<MODE>mode));
3397 [(set_attr "move_type" "shift_shift")
3398 (set_attr "mode" "DI")])
3400 (define_insn_and_split "*extendsi_truncate<mode>"
3401 [(set (match_operand:SI 0 "register_operand" "=d")
3403 (truncate:SHORT (match_operand:DI 1 "register_operand" "d"))))]
3404 "TARGET_64BIT && !TARGET_MIPS16 && !ISA_HAS_EXTS"
3406 "&& reload_completed"
3408 (ashift:DI (match_dup 1)
3411 (truncate:SI (ashiftrt:DI (match_dup 2)
3414 operands[2] = gen_lowpart (DImode, operands[0]);
3415 operands[3] = GEN_INT (BITS_PER_WORD - GET_MODE_BITSIZE (<MODE>mode));
3417 [(set_attr "move_type" "shift_shift")
3418 (set_attr "mode" "SI")])
3420 (define_insn_and_split "*extendhi_truncateqi"
3421 [(set (match_operand:HI 0 "register_operand" "=d")
3423 (truncate:QI (match_operand:DI 1 "register_operand" "d"))))]
3424 "TARGET_64BIT && !TARGET_MIPS16 && !ISA_HAS_EXTS"
3426 "&& reload_completed"
3428 (ashift:DI (match_dup 1)
3431 (truncate:HI (ashiftrt:DI (match_dup 2)
3434 operands[2] = gen_lowpart (DImode, operands[0]);
3436 [(set_attr "move_type" "shift_shift")
3437 (set_attr "mode" "SI")])
3439 (define_insn "*extend<GPR:mode>_truncate<SHORT:mode>_exts"
3440 [(set (match_operand:GPR 0 "register_operand" "=d")
3442 (truncate:SHORT (match_operand:DI 1 "register_operand" "d"))))]
3443 "TARGET_64BIT && !TARGET_MIPS16 && ISA_HAS_EXTS"
3445 operands[2] = GEN_INT (GET_MODE_BITSIZE (<SHORT:MODE>mode));
3446 return "exts\t%0,%1,0,%m2";
3448 [(set_attr "type" "arith")
3449 (set_attr "mode" "<GPR:MODE>")])
3451 (define_insn "*extendhi_truncateqi_exts"
3452 [(set (match_operand:HI 0 "register_operand" "=d")
3454 (truncate:QI (match_operand:DI 1 "register_operand" "d"))))]
3455 "TARGET_64BIT && !TARGET_MIPS16 && ISA_HAS_EXTS"
3457 [(set_attr "type" "arith")
3458 (set_attr "mode" "SI")])
3460 (define_insn "extendsfdf2"
3461 [(set (match_operand:DF 0 "register_operand" "=f")
3462 (float_extend:DF (match_operand:SF 1 "register_operand" "f")))]
3463 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
3465 [(set_attr "type" "fcvt")
3466 (set_attr "cnv_mode" "S2D")
3467 (set_attr "mode" "DF")])
3470 ;; ....................
3474 ;; ....................
3476 (define_expand "fix_truncdfsi2"
3477 [(set (match_operand:SI 0 "register_operand")
3478 (fix:SI (match_operand:DF 1 "register_operand")))]
3479 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
3481 if (!ISA_HAS_TRUNC_W)
3483 emit_insn (gen_fix_truncdfsi2_macro (operands[0], operands[1]));
3488 (define_insn "fix_truncdfsi2_insn"
3489 [(set (match_operand:SI 0 "register_operand" "=f")
3490 (fix:SI (match_operand:DF 1 "register_operand" "f")))]
3491 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && ISA_HAS_TRUNC_W"
3493 [(set_attr "type" "fcvt")
3494 (set_attr "mode" "DF")
3495 (set_attr "cnv_mode" "D2I")])
3497 (define_insn "fix_truncdfsi2_macro"
3498 [(set (match_operand:SI 0 "register_operand" "=f")
3499 (fix:SI (match_operand:DF 1 "register_operand" "f")))
3500 (clobber (match_scratch:DF 2 "=d"))]
3501 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !ISA_HAS_TRUNC_W"
3503 if (mips_nomacro.nesting_level > 0)
3504 return ".set\tmacro\;trunc.w.d %0,%1,%2\;.set\tnomacro";
3506 return "trunc.w.d %0,%1,%2";
3508 [(set_attr "type" "fcvt")
3509 (set_attr "mode" "DF")
3510 (set_attr "cnv_mode" "D2I")
3511 (set_attr "length" "36")])
3513 (define_expand "fix_truncsfsi2"
3514 [(set (match_operand:SI 0 "register_operand")
3515 (fix:SI (match_operand:SF 1 "register_operand")))]
3518 if (!ISA_HAS_TRUNC_W)
3520 emit_insn (gen_fix_truncsfsi2_macro (operands[0], operands[1]));
3525 (define_insn "fix_truncsfsi2_insn"
3526 [(set (match_operand:SI 0 "register_operand" "=f")
3527 (fix:SI (match_operand:SF 1 "register_operand" "f")))]
3528 "TARGET_HARD_FLOAT && ISA_HAS_TRUNC_W"
3530 [(set_attr "type" "fcvt")
3531 (set_attr "mode" "SF")
3532 (set_attr "cnv_mode" "S2I")])
3534 (define_insn "fix_truncsfsi2_macro"
3535 [(set (match_operand:SI 0 "register_operand" "=f")
3536 (fix:SI (match_operand:SF 1 "register_operand" "f")))
3537 (clobber (match_scratch:SF 2 "=d"))]
3538 "TARGET_HARD_FLOAT && !ISA_HAS_TRUNC_W"
3540 if (mips_nomacro.nesting_level > 0)
3541 return ".set\tmacro\;trunc.w.s %0,%1,%2\;.set\tnomacro";
3543 return "trunc.w.s %0,%1,%2";
3545 [(set_attr "type" "fcvt")
3546 (set_attr "mode" "SF")
3547 (set_attr "cnv_mode" "S2I")
3548 (set_attr "length" "36")])
3551 (define_insn "fix_truncdfdi2"
3552 [(set (match_operand:DI 0 "register_operand" "=f")
3553 (fix:DI (match_operand:DF 1 "register_operand" "f")))]
3554 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
3556 [(set_attr "type" "fcvt")
3557 (set_attr "mode" "DF")
3558 (set_attr "cnv_mode" "D2I")])
3561 (define_insn "fix_truncsfdi2"
3562 [(set (match_operand:DI 0 "register_operand" "=f")
3563 (fix:DI (match_operand:SF 1 "register_operand" "f")))]
3564 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
3566 [(set_attr "type" "fcvt")
3567 (set_attr "mode" "SF")
3568 (set_attr "cnv_mode" "S2I")])
3571 (define_insn "floatsidf2"
3572 [(set (match_operand:DF 0 "register_operand" "=f")
3573 (float:DF (match_operand:SI 1 "register_operand" "f")))]
3574 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
3576 [(set_attr "type" "fcvt")
3577 (set_attr "mode" "DF")
3578 (set_attr "cnv_mode" "I2D")])
3581 (define_insn "floatdidf2"
3582 [(set (match_operand:DF 0 "register_operand" "=f")
3583 (float:DF (match_operand:DI 1 "register_operand" "f")))]
3584 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
3586 [(set_attr "type" "fcvt")
3587 (set_attr "mode" "DF")
3588 (set_attr "cnv_mode" "I2D")])
3591 (define_insn "floatsisf2"
3592 [(set (match_operand:SF 0 "register_operand" "=f")
3593 (float:SF (match_operand:SI 1 "register_operand" "f")))]
3596 [(set_attr "type" "fcvt")
3597 (set_attr "mode" "SF")
3598 (set_attr "cnv_mode" "I2S")])
3601 (define_insn "floatdisf2"
3602 [(set (match_operand:SF 0 "register_operand" "=f")
3603 (float:SF (match_operand:DI 1 "register_operand" "f")))]
3604 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
3606 [(set_attr "type" "fcvt")
3607 (set_attr "mode" "SF")
3608 (set_attr "cnv_mode" "I2S")])
3611 (define_expand "fixuns_truncdfsi2"
3612 [(set (match_operand:SI 0 "register_operand")
3613 (unsigned_fix:SI (match_operand:DF 1 "register_operand")))]
3614 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
3616 rtx reg1 = gen_reg_rtx (DFmode);
3617 rtx reg2 = gen_reg_rtx (DFmode);
3618 rtx reg3 = gen_reg_rtx (SImode);
3619 rtx label1 = gen_label_rtx ();
3620 rtx label2 = gen_label_rtx ();
3622 REAL_VALUE_TYPE offset;
3624 real_2expN (&offset, 31, DFmode);
3626 if (reg1) /* Turn off complaints about unreached code. */
3628 mips_emit_move (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, DFmode));
3629 do_pending_stack_adjust ();
3631 test = gen_rtx_GE (VOIDmode, operands[1], reg1);
3632 emit_jump_insn (gen_cbranchdf4 (test, operands[1], reg1, label1));
3634 emit_insn (gen_fix_truncdfsi2 (operands[0], operands[1]));
3635 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
3636 gen_rtx_LABEL_REF (VOIDmode, label2)));
3639 emit_label (label1);
3640 mips_emit_move (reg2, gen_rtx_MINUS (DFmode, operands[1], reg1));
3641 mips_emit_move (reg3, GEN_INT (trunc_int_for_mode
3642 (BITMASK_HIGH, SImode)));
3644 emit_insn (gen_fix_truncdfsi2 (operands[0], reg2));
3645 emit_insn (gen_iorsi3 (operands[0], operands[0], reg3));
3647 emit_label (label2);
3649 /* Allow REG_NOTES to be set on last insn (labels don't have enough
3650 fields, and can't be used for REG_NOTES anyway). */
3651 emit_use (stack_pointer_rtx);
3657 (define_expand "fixuns_truncdfdi2"
3658 [(set (match_operand:DI 0 "register_operand")
3659 (unsigned_fix:DI (match_operand:DF 1 "register_operand")))]
3660 "TARGET_HARD_FLOAT && TARGET_64BIT && TARGET_DOUBLE_FLOAT"
3662 rtx reg1 = gen_reg_rtx (DFmode);
3663 rtx reg2 = gen_reg_rtx (DFmode);
3664 rtx reg3 = gen_reg_rtx (DImode);
3665 rtx label1 = gen_label_rtx ();
3666 rtx label2 = gen_label_rtx ();
3668 REAL_VALUE_TYPE offset;
3670 real_2expN (&offset, 63, DFmode);
3672 mips_emit_move (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, DFmode));
3673 do_pending_stack_adjust ();
3675 test = gen_rtx_GE (VOIDmode, operands[1], reg1);
3676 emit_jump_insn (gen_cbranchdf4 (test, operands[1], reg1, label1));
3678 emit_insn (gen_fix_truncdfdi2 (operands[0], operands[1]));
3679 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
3680 gen_rtx_LABEL_REF (VOIDmode, label2)));
3683 emit_label (label1);
3684 mips_emit_move (reg2, gen_rtx_MINUS (DFmode, operands[1], reg1));
3685 mips_emit_move (reg3, GEN_INT (BITMASK_HIGH));
3686 emit_insn (gen_ashldi3 (reg3, reg3, GEN_INT (32)));
3688 emit_insn (gen_fix_truncdfdi2 (operands[0], reg2));
3689 emit_insn (gen_iordi3 (operands[0], operands[0], reg3));
3691 emit_label (label2);
3693 /* Allow REG_NOTES to be set on last insn (labels don't have enough
3694 fields, and can't be used for REG_NOTES anyway). */
3695 emit_use (stack_pointer_rtx);
3700 (define_expand "fixuns_truncsfsi2"
3701 [(set (match_operand:SI 0 "register_operand")
3702 (unsigned_fix:SI (match_operand:SF 1 "register_operand")))]
3705 rtx reg1 = gen_reg_rtx (SFmode);
3706 rtx reg2 = gen_reg_rtx (SFmode);
3707 rtx reg3 = gen_reg_rtx (SImode);
3708 rtx label1 = gen_label_rtx ();
3709 rtx label2 = gen_label_rtx ();
3711 REAL_VALUE_TYPE offset;
3713 real_2expN (&offset, 31, SFmode);
3715 mips_emit_move (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, SFmode));
3716 do_pending_stack_adjust ();
3718 test = gen_rtx_GE (VOIDmode, operands[1], reg1);
3719 emit_jump_insn (gen_cbranchsf4 (test, operands[1], reg1, label1));
3721 emit_insn (gen_fix_truncsfsi2 (operands[0], operands[1]));
3722 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
3723 gen_rtx_LABEL_REF (VOIDmode, label2)));
3726 emit_label (label1);
3727 mips_emit_move (reg2, gen_rtx_MINUS (SFmode, operands[1], reg1));
3728 mips_emit_move (reg3, GEN_INT (trunc_int_for_mode
3729 (BITMASK_HIGH, SImode)));
3731 emit_insn (gen_fix_truncsfsi2 (operands[0], reg2));
3732 emit_insn (gen_iorsi3 (operands[0], operands[0], reg3));
3734 emit_label (label2);
3736 /* Allow REG_NOTES to be set on last insn (labels don't have enough
3737 fields, and can't be used for REG_NOTES anyway). */
3738 emit_use (stack_pointer_rtx);
3743 (define_expand "fixuns_truncsfdi2"
3744 [(set (match_operand:DI 0 "register_operand")
3745 (unsigned_fix:DI (match_operand:SF 1 "register_operand")))]
3746 "TARGET_HARD_FLOAT && TARGET_64BIT && TARGET_DOUBLE_FLOAT"
3748 rtx reg1 = gen_reg_rtx (SFmode);
3749 rtx reg2 = gen_reg_rtx (SFmode);
3750 rtx reg3 = gen_reg_rtx (DImode);
3751 rtx label1 = gen_label_rtx ();
3752 rtx label2 = gen_label_rtx ();
3754 REAL_VALUE_TYPE offset;
3756 real_2expN (&offset, 63, SFmode);
3758 mips_emit_move (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, SFmode));
3759 do_pending_stack_adjust ();
3761 test = gen_rtx_GE (VOIDmode, operands[1], reg1);
3762 emit_jump_insn (gen_cbranchsf4 (test, operands[1], reg1, label1));
3764 emit_insn (gen_fix_truncsfdi2 (operands[0], operands[1]));
3765 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
3766 gen_rtx_LABEL_REF (VOIDmode, label2)));
3769 emit_label (label1);
3770 mips_emit_move (reg2, gen_rtx_MINUS (SFmode, operands[1], reg1));
3771 mips_emit_move (reg3, GEN_INT (BITMASK_HIGH));
3772 emit_insn (gen_ashldi3 (reg3, reg3, GEN_INT (32)));
3774 emit_insn (gen_fix_truncsfdi2 (operands[0], reg2));
3775 emit_insn (gen_iordi3 (operands[0], operands[0], reg3));
3777 emit_label (label2);
3779 /* Allow REG_NOTES to be set on last insn (labels don't have enough
3780 fields, and can't be used for REG_NOTES anyway). */
3781 emit_use (stack_pointer_rtx);
3786 ;; ....................
3790 ;; ....................
3792 ;; Bit field extract patterns which use lwl/lwr or ldl/ldr.
3794 (define_expand "extvmisalign<mode>"
3795 [(set (match_operand:GPR 0 "register_operand")
3796 (sign_extract:GPR (match_operand:BLK 1 "memory_operand")
3797 (match_operand 2 "const_int_operand")
3798 (match_operand 3 "const_int_operand")))]
3801 if (mips_expand_ext_as_unaligned_load (operands[0], operands[1],
3802 INTVAL (operands[2]),
3803 INTVAL (operands[3]),
3804 /*unsigned=*/ false))
3810 (define_expand "extv<mode>"
3811 [(set (match_operand:GPR 0 "register_operand")
3812 (sign_extract:GPR (match_operand:GPR 1 "register_operand")
3813 (match_operand 2 "const_int_operand")
3814 (match_operand 3 "const_int_operand")))]
3817 if (UINTVAL (operands[2]) > 32)
3821 (define_insn "*extv<mode>"
3822 [(set (match_operand:GPR 0 "register_operand" "=d")
3823 (sign_extract:GPR (match_operand:GPR 1 "register_operand" "d")
3824 (match_operand 2 "const_int_operand" "")
3825 (match_operand 3 "const_int_operand" "")))]
3826 "ISA_HAS_EXTS && UINTVAL (operands[2]) <= 32"
3827 "exts\t%0,%1,%3,%m2"
3828 [(set_attr "type" "arith")
3829 (set_attr "mode" "<MODE>")])
3831 (define_expand "extzvmisalign<mode>"
3832 [(set (match_operand:GPR 0 "register_operand")
3833 (zero_extract:GPR (match_operand:BLK 1 "memory_operand")
3834 (match_operand 2 "const_int_operand")
3835 (match_operand 3 "const_int_operand")))]
3838 if (mips_expand_ext_as_unaligned_load (operands[0], operands[1],
3839 INTVAL (operands[2]),
3840 INTVAL (operands[3]),
3841 /*unsigned=*/ true))
3847 (define_expand "extzv<mode>"
3848 [(set (match_operand:GPR 0 "register_operand")
3849 (zero_extract:GPR (match_operand:GPR 1 "register_operand")
3850 (match_operand 2 "const_int_operand")
3851 (match_operand 3 "const_int_operand")))]
3854 if (!mips_use_ins_ext_p (operands[1], INTVAL (operands[2]),
3855 INTVAL (operands[3])))
3859 (define_insn "*extzv<mode>"
3860 [(set (match_operand:GPR 0 "register_operand" "=d")
3861 (zero_extract:GPR (match_operand:GPR 1 "register_operand" "d")
3862 (match_operand 2 "const_int_operand" "")
3863 (match_operand 3 "const_int_operand" "")))]
3864 "mips_use_ins_ext_p (operands[1], INTVAL (operands[2]),
3865 INTVAL (operands[3]))"
3866 "<d>ext\t%0,%1,%3,%2"
3867 [(set_attr "type" "arith")
3868 (set_attr "mode" "<MODE>")])
3870 (define_insn "*extzv_truncsi_exts"
3871 [(set (match_operand:SI 0 "register_operand" "=d")
3873 (zero_extract:DI (match_operand:DI 1 "register_operand" "d")
3874 (match_operand 2 "const_int_operand" "")
3875 (match_operand 3 "const_int_operand" ""))))]
3876 "ISA_HAS_EXTS && TARGET_64BIT && IN_RANGE (INTVAL (operands[2]), 32, 63)"
3878 [(set_attr "type" "arith")
3879 (set_attr "mode" "SI")])
3882 (define_expand "insvmisalign<mode>"
3883 [(set (zero_extract:GPR (match_operand:BLK 0 "memory_operand")
3884 (match_operand 1 "const_int_operand")
3885 (match_operand 2 "const_int_operand"))
3886 (match_operand:GPR 3 "reg_or_0_operand"))]
3889 if (mips_expand_ins_as_unaligned_store (operands[0], operands[3],
3890 INTVAL (operands[1]),
3891 INTVAL (operands[2])))
3897 (define_expand "insv<mode>"
3898 [(set (zero_extract:GPR (match_operand:GPR 0 "register_operand")
3899 (match_operand 1 "const_int_operand")
3900 (match_operand 2 "const_int_operand"))
3901 (match_operand:GPR 3 "reg_or_0_operand"))]
3904 if (!mips_use_ins_ext_p (operands[0], INTVAL (operands[1]),
3905 INTVAL (operands[2])))
3909 (define_insn "*insv<mode>"
3910 [(set (zero_extract:GPR (match_operand:GPR 0 "register_operand" "+d")
3911 (match_operand:SI 1 "const_int_operand" "")
3912 (match_operand:SI 2 "const_int_operand" ""))
3913 (match_operand:GPR 3 "reg_or_0_operand" "dJ"))]
3914 "mips_use_ins_ext_p (operands[0], INTVAL (operands[1]),
3915 INTVAL (operands[2]))"
3916 "<d>ins\t%0,%z3,%2,%1"
3917 [(set_attr "type" "arith")
3918 (set_attr "mode" "<MODE>")])
3920 ;; Combiner pattern for cins (clear and insert bit field). We can
3921 ;; implement mask-and-shift-left operation with this. Note that if
3922 ;; the upper bit of the mask is set in an SImode operation, the mask
3923 ;; itself will be sign-extended. mask_low_and_shift_len will
3924 ;; therefore be greater than our threshold of 32.
3926 (define_insn "*cins<mode>"
3927 [(set (match_operand:GPR 0 "register_operand" "=d")
3929 (ashift:GPR (match_operand:GPR 1 "register_operand" "d")
3930 (match_operand:GPR 2 "const_int_operand" ""))
3931 (match_operand:GPR 3 "const_int_operand" "")))]
3933 && mask_low_and_shift_p (<MODE>mode, operands[3], operands[2], 32)"
3936 GEN_INT (mask_low_and_shift_len (<MODE>mode, operands[3], operands[2]));
3937 return "cins\t%0,%1,%2,%m3";
3939 [(set_attr "type" "shift")
3940 (set_attr "mode" "<MODE>")])
3942 ;; Unaligned word moves generated by the bit field patterns.
3944 ;; As far as the rtl is concerned, both the left-part and right-part
3945 ;; instructions can access the whole field. However, the real operand
3946 ;; refers to just the first or the last byte (depending on endianness).
3947 ;; We therefore use two memory operands to each instruction, one to
3948 ;; describe the rtl effect and one to use in the assembly output.
3950 ;; Operands 0 and 1 are the rtl-level target and source respectively.
3951 ;; This allows us to use the standard length calculations for the "load"
3952 ;; and "store" type attributes.
3954 (define_insn "mov_<load>l"
3955 [(set (match_operand:GPR 0 "register_operand" "=d")
3956 (unspec:GPR [(match_operand:BLK 1 "memory_operand" "m")
3957 (match_operand:QI 2 "memory_operand" "m")]
3959 "!TARGET_MIPS16 && mips_mem_fits_mode_p (<MODE>mode, operands[1])"
3961 [(set_attr "move_type" "load")
3962 (set_attr "mode" "<MODE>")])
3964 (define_insn "mov_<load>r"
3965 [(set (match_operand:GPR 0 "register_operand" "=d")
3966 (unspec:GPR [(match_operand:BLK 1 "memory_operand" "m")
3967 (match_operand:QI 2 "memory_operand" "m")
3968 (match_operand:GPR 3 "register_operand" "0")]
3969 UNSPEC_LOAD_RIGHT))]
3970 "!TARGET_MIPS16 && mips_mem_fits_mode_p (<MODE>mode, operands[1])"
3972 [(set_attr "move_type" "load")
3973 (set_attr "mode" "<MODE>")])
3975 (define_insn "mov_<store>l"
3976 [(set (match_operand:BLK 0 "memory_operand" "=m")
3977 (unspec:BLK [(match_operand:GPR 1 "reg_or_0_operand" "dJ")
3978 (match_operand:QI 2 "memory_operand" "m")]
3979 UNSPEC_STORE_LEFT))]
3980 "!TARGET_MIPS16 && mips_mem_fits_mode_p (<MODE>mode, operands[0])"
3982 [(set_attr "move_type" "store")
3983 (set_attr "mode" "<MODE>")])
3985 (define_insn "mov_<store>r"
3986 [(set (match_operand:BLK 0 "memory_operand" "+m")
3987 (unspec:BLK [(match_operand:GPR 1 "reg_or_0_operand" "dJ")
3988 (match_operand:QI 2 "memory_operand" "m")
3990 UNSPEC_STORE_RIGHT))]
3991 "!TARGET_MIPS16 && mips_mem_fits_mode_p (<MODE>mode, operands[0])"
3993 [(set_attr "move_type" "store")
3994 (set_attr "mode" "<MODE>")])
3996 ;; An instruction to calculate the high part of a 64-bit SYMBOL_ABSOLUTE.
3997 ;; The required value is:
3999 ;; (%highest(op1) << 48) + (%higher(op1) << 32) + (%hi(op1) << 16)
4001 ;; which translates to:
4003 ;; lui op0,%highest(op1)
4004 ;; daddiu op0,op0,%higher(op1)
4006 ;; daddiu op0,op0,%hi(op1)
4009 ;; The split is deferred until after flow2 to allow the peephole2 below
4011 (define_insn_and_split "*lea_high64"
4012 [(set (match_operand:DI 0 "register_operand" "=d")
4013 (high:DI (match_operand:DI 1 "absolute_symbolic_operand" "")))]
4014 "TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS"
4016 "&& epilogue_completed"
4017 [(set (match_dup 0) (high:DI (match_dup 2)))
4018 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 2)))
4019 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 16)))
4020 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 3)))
4021 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 16)))]
4023 operands[2] = mips_unspec_address (operands[1], SYMBOL_64_HIGH);
4024 operands[3] = mips_unspec_address (operands[1], SYMBOL_64_MID);
4026 [(set_attr "length" "20")])
4028 ;; Use a scratch register to reduce the latency of the above pattern
4029 ;; on superscalar machines. The optimized sequence is:
4031 ;; lui op1,%highest(op2)
4033 ;; daddiu op1,op1,%higher(op2)
4035 ;; daddu op1,op1,op0
4037 [(set (match_operand:DI 1 "d_operand")
4038 (high:DI (match_operand:DI 2 "absolute_symbolic_operand")))
4039 (match_scratch:DI 0 "d")]
4040 "TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS"
4041 [(set (match_dup 1) (high:DI (match_dup 3)))
4042 (set (match_dup 0) (high:DI (match_dup 4)))
4043 (set (match_dup 1) (lo_sum:DI (match_dup 1) (match_dup 3)))
4044 (set (match_dup 1) (ashift:DI (match_dup 1) (const_int 32)))
4045 (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 0)))]
4047 operands[3] = mips_unspec_address (operands[2], SYMBOL_64_HIGH);
4048 operands[4] = mips_unspec_address (operands[2], SYMBOL_64_LOW);
4051 ;; On most targets, the expansion of (lo_sum (high X) X) for a 64-bit
4052 ;; SYMBOL_ABSOLUTE X will take 6 cycles. This next pattern allows combine
4053 ;; to merge the HIGH and LO_SUM parts of a move if the HIGH part is only
4054 ;; used once. We can then use the sequence:
4056 ;; lui op0,%highest(op1)
4058 ;; daddiu op0,op0,%higher(op1)
4059 ;; daddiu op2,op2,%lo(op1)
4061 ;; daddu op0,op0,op2
4063 ;; which takes 4 cycles on most superscalar targets.
4064 (define_insn_and_split "*lea64"
4065 [(set (match_operand:DI 0 "register_operand" "=d")
4066 (match_operand:DI 1 "absolute_symbolic_operand" ""))
4067 (clobber (match_scratch:DI 2 "=&d"))]
4068 "TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS && cse_not_expected"
4070 "&& reload_completed"
4071 [(set (match_dup 0) (high:DI (match_dup 3)))
4072 (set (match_dup 2) (high:DI (match_dup 4)))
4073 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 3)))
4074 (set (match_dup 2) (lo_sum:DI (match_dup 2) (match_dup 4)))
4075 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
4076 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))]
4078 operands[3] = mips_unspec_address (operands[1], SYMBOL_64_HIGH);
4079 operands[4] = mips_unspec_address (operands[1], SYMBOL_64_LOW);
4081 [(set_attr "length" "24")])
4083 ;; Split HIGHs into:
4088 ;; on MIPS16 targets.
4090 [(set (match_operand:P 0 "d_operand")
4091 (high:P (match_operand:P 1 "symbolic_operand_with_high")))]
4092 "TARGET_MIPS16 && reload_completed"
4093 [(set (match_dup 0) (unspec:P [(match_dup 1)] UNSPEC_UNSHIFTED_HIGH))
4094 (set (match_dup 0) (ashift:P (match_dup 0) (const_int 16)))])
4096 (define_insn "*unshifted_high"
4097 [(set (match_operand:P 0 "d_operand" "=d")
4098 (unspec:P [(match_operand:P 1 "symbolic_operand_with_high")]
4099 UNSPEC_UNSHIFTED_HIGH))]
4102 [(set_attr "extended_mips16" "yes")])
4104 ;; Insns to fetch a symbol from a big GOT.
4106 (define_insn_and_split "*xgot_hi<mode>"
4107 [(set (match_operand:P 0 "register_operand" "=d")
4108 (high:P (match_operand:P 1 "got_disp_operand" "")))]
4109 "TARGET_EXPLICIT_RELOCS && TARGET_XGOT"
4111 "&& reload_completed"
4112 [(set (match_dup 0) (high:P (match_dup 2)))
4113 (set (match_dup 0) (plus:P (match_dup 0) (match_dup 3)))]
4115 operands[2] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_DISP);
4116 operands[3] = pic_offset_table_rtx;
4118 [(set_attr "got" "xgot_high")
4119 (set_attr "mode" "<MODE>")])
4121 (define_insn_and_split "*xgot_lo<mode>"
4122 [(set (match_operand:P 0 "register_operand" "=d")
4123 (lo_sum:P (match_operand:P 1 "register_operand" "d")
4124 (match_operand:P 2 "got_disp_operand" "")))]
4125 "TARGET_EXPLICIT_RELOCS && TARGET_XGOT"
4127 "&& reload_completed"
4129 (unspec:P [(match_dup 1) (match_dup 3)] UNSPEC_LOAD_GOT))]
4130 { operands[3] = mips_unspec_address (operands[2], SYMBOL_GOTOFF_DISP); }
4131 [(set_attr "got" "load")
4132 (set_attr "mode" "<MODE>")])
4134 ;; Insns to fetch a symbol from a normal GOT.
4136 (define_insn_and_split "*got_disp<mode>"
4137 [(set (match_operand:P 0 "register_operand" "=d")
4138 (match_operand:P 1 "got_disp_operand" ""))]
4139 "TARGET_EXPLICIT_RELOCS && !mips_split_p[SYMBOL_GOT_DISP]"
4141 "&& reload_completed"
4142 [(set (match_dup 0) (match_dup 2))]
4143 { operands[2] = mips_got_load (NULL, operands[1], SYMBOL_GOTOFF_DISP); }
4144 [(set_attr "got" "load")
4145 (set_attr "mode" "<MODE>")])
4147 ;; Insns for loading the "page" part of a page/ofst address from the GOT.
4149 (define_insn_and_split "*got_page<mode>"
4150 [(set (match_operand:P 0 "register_operand" "=d")
4151 (high:P (match_operand:P 1 "got_page_ofst_operand" "")))]
4152 "TARGET_EXPLICIT_RELOCS && !mips_split_hi_p[SYMBOL_GOT_PAGE_OFST]"
4154 "&& reload_completed"
4155 [(set (match_dup 0) (match_dup 2))]
4156 { operands[2] = mips_got_load (NULL, operands[1], SYMBOL_GOTOFF_PAGE); }
4157 [(set_attr "got" "load")
4158 (set_attr "mode" "<MODE>")])
4160 ;; Convenience expander that generates the rhs of a load_got<mode> insn.
4161 (define_expand "unspec_got_<mode>"
4162 [(unspec:P [(match_operand:P 0)
4163 (match_operand:P 1)] UNSPEC_LOAD_GOT)])
4165 ;; Lower-level instructions for loading an address from the GOT.
4166 ;; We could use MEMs, but an unspec gives more optimization
4169 (define_insn "load_got<mode>"
4170 [(set (match_operand:P 0 "register_operand" "=d")
4171 (unspec:P [(match_operand:P 1 "register_operand" "d")
4172 (match_operand:P 2 "immediate_operand" "")]
4175 "<load>\t%0,%R2(%1)"
4176 [(set_attr "got" "load")
4177 (set_attr "mode" "<MODE>")])
4179 ;; Instructions for adding the low 16 bits of an address to a register.
4180 ;; Operand 2 is the address: mips_print_operand works out which relocation
4181 ;; should be applied.
4183 (define_insn "*low<mode>"
4184 [(set (match_operand:P 0 "register_operand" "=d")
4185 (lo_sum:P (match_operand:P 1 "register_operand" "d")
4186 (match_operand:P 2 "immediate_operand" "")))]
4188 "<d>addiu\t%0,%1,%R2"
4189 [(set_attr "alu_type" "add")
4190 (set_attr "mode" "<MODE>")])
4192 (define_insn "*low<mode>_mips16"
4193 [(set (match_operand:P 0 "register_operand" "=d")
4194 (lo_sum:P (match_operand:P 1 "register_operand" "0")
4195 (match_operand:P 2 "immediate_operand" "")))]
4198 [(set_attr "alu_type" "add")
4199 (set_attr "mode" "<MODE>")
4200 (set_attr "extended_mips16" "yes")])
4202 ;; Expose MIPS16 uses of the global pointer after reload if the function
4203 ;; is responsible for setting up the register itself.
4205 [(set (match_operand:GPR 0 "d_operand")
4206 (const:GPR (unspec:GPR [(const_int 0)] UNSPEC_GP)))]
4207 "TARGET_MIPS16 && TARGET_USE_GOT && reload_completed"
4208 [(set (match_dup 0) (match_dup 1))]
4209 { operands[1] = pic_offset_table_rtx; })
4211 ;; Allow combine to split complex const_int load sequences, using operand 2
4212 ;; to store the intermediate results. See move_operand for details.
4214 [(set (match_operand:GPR 0 "register_operand")
4215 (match_operand:GPR 1 "splittable_const_int_operand"))
4216 (clobber (match_operand:GPR 2 "register_operand"))]
4220 mips_move_integer (operands[2], operands[0], INTVAL (operands[1]));
4224 ;; Likewise, for symbolic operands.
4226 [(set (match_operand:P 0 "register_operand")
4227 (match_operand:P 1))
4228 (clobber (match_operand:P 2 "register_operand"))]
4229 "mips_split_symbol (operands[2], operands[1], MAX_MACHINE_MODE, NULL)"
4230 [(set (match_dup 0) (match_dup 3))]
4232 mips_split_symbol (operands[2], operands[1],
4233 MAX_MACHINE_MODE, &operands[3]);
4236 ;; 64-bit integer moves
4238 ;; Unlike most other insns, the move insns can't be split with
4239 ;; different predicates, because register spilling and other parts of
4240 ;; the compiler, have memoized the insn number already.
4242 (define_expand "movdi"
4243 [(set (match_operand:DI 0 "")
4244 (match_operand:DI 1 ""))]
4247 if (mips_legitimize_move (DImode, operands[0], operands[1]))
4251 ;; For mips16, we need a special case to handle storing $31 into
4252 ;; memory, since we don't have a constraint to match $31. This
4253 ;; instruction can be generated by save_restore_insns.
4255 (define_insn "*mov<mode>_ra"
4256 [(set (match_operand:GPR 0 "stack_operand" "=m")
4257 (reg:GPR RETURN_ADDR_REGNUM))]
4260 [(set_attr "move_type" "store")
4261 (set_attr "mode" "<MODE>")])
4263 (define_insn "*movdi_32bit"
4264 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,m,*a,*a,*d,*f,*f,*d,*m,*B*C*D,*B*C*D,*d,*m")
4265 (match_operand:DI 1 "move_operand" "d,i,m,d,*J,*d,*a,*J*d,*m,*f,*f,*d,*m,*B*C*D,*B*C*D"))]
4266 "!TARGET_64BIT && !TARGET_MIPS16
4267 && (register_operand (operands[0], DImode)
4268 || reg_or_0_operand (operands[1], DImode))"
4269 { return mips_output_move (operands[0], operands[1]); }
4270 [(set_attr "move_type" "move,const,load,store,imul,mtlo,mflo,mtc,fpload,mfc,fpstore,mtc,fpload,mfc,fpstore")
4272 (if_then_else (eq_attr "move_type" "imul")
4274 (const_string "DI")))])
4276 (define_insn "*movdi_32bit_mips16"
4277 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m,*d")
4278 (match_operand:DI 1 "move_operand" "d,d,y,K,N,m,d,*x"))]
4279 "!TARGET_64BIT && TARGET_MIPS16
4280 && (register_operand (operands[0], DImode)
4281 || register_operand (operands[1], DImode))"
4282 { return mips_output_move (operands[0], operands[1]); }
4283 [(set_attr "move_type" "move,move,move,const,constN,load,store,mflo")
4284 (set_attr "mode" "DI")])
4286 (define_insn "*movdi_64bit"
4287 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,e,d,m,*f,*f,*d,*m,*a,*d,*B*C*D,*B*C*D,*d,*m")
4288 (match_operand:DI 1 "move_operand" "d,U,T,m,dJ,*d*J,*m,*f,*f,*J*d,*a,*d,*m,*B*C*D,*B*C*D"))]
4289 "TARGET_64BIT && !TARGET_MIPS16
4290 && (register_operand (operands[0], DImode)
4291 || reg_or_0_operand (operands[1], DImode))"
4292 { return mips_output_move (operands[0], operands[1]); }
4293 [(set_attr "move_type" "move,const,const,load,store,mtc,fpload,mfc,fpstore,mtlo,mflo,mtc,fpload,mfc,fpstore")
4294 (set_attr "mode" "DI")])
4296 (define_insn "*movdi_64bit_mips16"
4297 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,y,d,d,d,d,d,d,m,*d")
4298 (match_operand:DI 1 "move_operand" "d,d,y,K,N,U,kf,m,d,*a"))]
4299 "TARGET_64BIT && TARGET_MIPS16
4300 && (register_operand (operands[0], DImode)
4301 || register_operand (operands[1], DImode))"
4302 { return mips_output_move (operands[0], operands[1]); }
4303 [(set_attr "move_type" "move,move,move,const,constN,const,loadpool,load,store,mflo")
4304 (set_attr "mode" "DI")])
4306 ;; On the mips16, we can split ld $r,N($r) into an add and a load,
4307 ;; when the original load is a 4 byte instruction but the add and the
4308 ;; load are 2 2 byte instructions.
4311 [(set (match_operand:DI 0 "d_operand")
4312 (mem:DI (plus:DI (match_dup 0)
4313 (match_operand:DI 1 "const_int_operand"))))]
4314 "TARGET_64BIT && TARGET_MIPS16 && reload_completed
4315 && !TARGET_DEBUG_D_MODE
4316 && ((INTVAL (operands[1]) < 0
4317 && INTVAL (operands[1]) >= -0x10)
4318 || (INTVAL (operands[1]) >= 32 * 8
4319 && INTVAL (operands[1]) <= 31 * 8 + 0x8)
4320 || (INTVAL (operands[1]) >= 0
4321 && INTVAL (operands[1]) < 32 * 8
4322 && (INTVAL (operands[1]) & 7) != 0))"
4323 [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1)))
4324 (set (match_dup 0) (mem:DI (plus:DI (match_dup 0) (match_dup 2))))]
4326 HOST_WIDE_INT val = INTVAL (operands[1]);
4329 operands[2] = const0_rtx;
4330 else if (val >= 32 * 8)
4334 operands[1] = GEN_INT (0x8 + off);
4335 operands[2] = GEN_INT (val - off - 0x8);
4341 operands[1] = GEN_INT (off);
4342 operands[2] = GEN_INT (val - off);
4346 ;; 32-bit Integer moves
4348 ;; Unlike most other insns, the move insns can't be split with
4349 ;; different predicates, because register spilling and other parts of
4350 ;; the compiler, have memoized the insn number already.
4352 (define_expand "mov<mode>"
4353 [(set (match_operand:IMOVE32 0 "")
4354 (match_operand:IMOVE32 1 ""))]
4357 if (mips_legitimize_move (<MODE>mode, operands[0], operands[1]))
4361 ;; The difference between these two is whether or not ints are allowed
4362 ;; in FP registers (off by default, use -mdebugh to enable).
4364 (define_insn "*mov<mode>_internal"
4365 [(set (match_operand:IMOVE32 0 "nonimmediate_operand" "=d,d,e,d,m,*f,*f,*d,*m,*d,*z,*a,*d,*B*C*D,*B*C*D,*d,*m")
4366 (match_operand:IMOVE32 1 "move_operand" "d,U,T,m,dJ,*d*J,*m,*f,*f,*z,*d,*J*d,*a,*d,*m,*B*C*D,*B*C*D"))]
4368 && (register_operand (operands[0], <MODE>mode)
4369 || reg_or_0_operand (operands[1], <MODE>mode))"
4370 { return mips_output_move (operands[0], operands[1]); }
4371 [(set_attr "move_type" "move,const,const,load,store,mtc,fpload,mfc,fpstore,mfc,mtc,mtlo,mflo,mtc,fpload,mfc,fpstore")
4372 (set_attr "mode" "SI")])
4374 (define_insn "*mov<mode>_mips16"
4375 [(set (match_operand:IMOVE32 0 "nonimmediate_operand" "=d,y,d,d,d,d,d,d,m,*d")
4376 (match_operand:IMOVE32 1 "move_operand" "d,d,y,K,N,U,kf,m,d,*a"))]
4378 && (register_operand (operands[0], <MODE>mode)
4379 || register_operand (operands[1], <MODE>mode))"
4380 { return mips_output_move (operands[0], operands[1]); }
4381 [(set_attr "move_type" "move,move,move,const,constN,const,loadpool,load,store,mflo")
4382 (set_attr "mode" "SI")])
4384 ;; On the mips16, we can split lw $r,N($r) into an add and a load,
4385 ;; when the original load is a 4 byte instruction but the add and the
4386 ;; load are 2 2 byte instructions.
4389 [(set (match_operand:SI 0 "d_operand")
4390 (mem:SI (plus:SI (match_dup 0)
4391 (match_operand:SI 1 "const_int_operand"))))]
4392 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
4393 && ((INTVAL (operands[1]) < 0
4394 && INTVAL (operands[1]) >= -0x80)
4395 || (INTVAL (operands[1]) >= 32 * 4
4396 && INTVAL (operands[1]) <= 31 * 4 + 0x7c)
4397 || (INTVAL (operands[1]) >= 0
4398 && INTVAL (operands[1]) < 32 * 4
4399 && (INTVAL (operands[1]) & 3) != 0))"
4400 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
4401 (set (match_dup 0) (mem:SI (plus:SI (match_dup 0) (match_dup 2))))]
4403 HOST_WIDE_INT val = INTVAL (operands[1]);
4406 operands[2] = const0_rtx;
4407 else if (val >= 32 * 4)
4411 operands[1] = GEN_INT (0x7c + off);
4412 operands[2] = GEN_INT (val - off - 0x7c);
4418 operands[1] = GEN_INT (off);
4419 operands[2] = GEN_INT (val - off);
4423 ;; On the mips16, we can split a load of certain constants into a load
4424 ;; and an add. This turns a 4 byte instruction into 2 2 byte
4428 [(set (match_operand:SI 0 "d_operand")
4429 (match_operand:SI 1 "const_int_operand"))]
4430 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
4431 && INTVAL (operands[1]) >= 0x100
4432 && INTVAL (operands[1]) <= 0xff + 0x7f"
4433 [(set (match_dup 0) (match_dup 1))
4434 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]
4436 int val = INTVAL (operands[1]);
4438 operands[1] = GEN_INT (0xff);
4439 operands[2] = GEN_INT (val - 0xff);
4442 ;; MIPS4 supports loading and storing a floating point register from
4443 ;; the sum of two general registers. We use two versions for each of
4444 ;; these four instructions: one where the two general registers are
4445 ;; SImode, and one where they are DImode. This is because general
4446 ;; registers will be in SImode when they hold 32-bit values, but,
4447 ;; since the 32-bit values are always sign extended, the [ls][wd]xc1
4448 ;; instructions will still work correctly.
4450 ;; ??? Perhaps it would be better to support these instructions by
4451 ;; modifying TARGET_LEGITIMATE_ADDRESS_P and friends. However, since
4452 ;; these instructions can only be used to load and store floating
4453 ;; point registers, that would probably cause trouble in reload.
4455 (define_insn "*<ANYF:loadx>_<P:mode>"
4456 [(set (match_operand:ANYF 0 "register_operand" "=f")
4457 (mem:ANYF (plus:P (match_operand:P 1 "register_operand" "d")
4458 (match_operand:P 2 "register_operand" "d"))))]
4460 "<ANYF:loadx>\t%0,%1(%2)"
4461 [(set_attr "type" "fpidxload")
4462 (set_attr "mode" "<ANYF:UNITMODE>")])
4464 (define_insn "*<ANYF:storex>_<P:mode>"
4465 [(set (mem:ANYF (plus:P (match_operand:P 1 "register_operand" "d")
4466 (match_operand:P 2 "register_operand" "d")))
4467 (match_operand:ANYF 0 "register_operand" "f"))]
4469 "<ANYF:storex>\t%0,%1(%2)"
4470 [(set_attr "type" "fpidxstore")
4471 (set_attr "mode" "<ANYF:UNITMODE>")])
4473 ;; Scaled indexed address load.
4474 ;; Per md.texi, we only need to look for a pattern with multiply in the
4475 ;; address expression, not shift.
4477 (define_insn "*lwxs"
4478 [(set (match_operand:IMOVE32 0 "register_operand" "=d")
4480 (plus:P (mult:P (match_operand:P 1 "register_operand" "d")
4482 (match_operand:P 2 "register_operand" "d"))))]
4485 [(set_attr "type" "load")
4486 (set_attr "mode" "SI")])
4488 ;; 16-bit Integer moves
4490 ;; Unlike most other insns, the move insns can't be split with
4491 ;; different predicates, because register spilling and other parts of
4492 ;; the compiler, have memoized the insn number already.
4493 ;; Unsigned loads are used because LOAD_EXTEND_OP returns ZERO_EXTEND.
4495 (define_expand "movhi"
4496 [(set (match_operand:HI 0 "")
4497 (match_operand:HI 1 ""))]
4500 if (mips_legitimize_move (HImode, operands[0], operands[1]))
4504 (define_insn "*movhi_internal"
4505 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,m,*a,*d")
4506 (match_operand:HI 1 "move_operand" "d,I,m,dJ,*d*J,*a"))]
4508 && (register_operand (operands[0], HImode)
4509 || reg_or_0_operand (operands[1], HImode))"
4510 { return mips_output_move (operands[0], operands[1]); }
4511 [(set_attr "move_type" "move,const,load,store,mtlo,mflo")
4512 (set_attr "mode" "HI")])
4514 (define_insn "*movhi_mips16"
4515 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m,*d")
4516 (match_operand:HI 1 "move_operand" "d,d,y,K,N,m,d,*a"))]
4518 && (register_operand (operands[0], HImode)
4519 || register_operand (operands[1], HImode))"
4520 { return mips_output_move (operands[0], operands[1]); }
4521 [(set_attr "move_type" "move,move,move,const,constN,load,store,mflo")
4522 (set_attr "mode" "HI")])
4524 ;; On the mips16, we can split lh $r,N($r) into an add and a load,
4525 ;; when the original load is a 4 byte instruction but the add and the
4526 ;; load are 2 2 byte instructions.
4529 [(set (match_operand:HI 0 "d_operand")
4530 (mem:HI (plus:SI (match_dup 0)
4531 (match_operand:SI 1 "const_int_operand"))))]
4532 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
4533 && ((INTVAL (operands[1]) < 0
4534 && INTVAL (operands[1]) >= -0x80)
4535 || (INTVAL (operands[1]) >= 32 * 2
4536 && INTVAL (operands[1]) <= 31 * 2 + 0x7e)
4537 || (INTVAL (operands[1]) >= 0
4538 && INTVAL (operands[1]) < 32 * 2
4539 && (INTVAL (operands[1]) & 1) != 0))"
4540 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
4541 (set (match_dup 0) (mem:HI (plus:SI (match_dup 0) (match_dup 2))))]
4543 HOST_WIDE_INT val = INTVAL (operands[1]);
4546 operands[2] = const0_rtx;
4547 else if (val >= 32 * 2)
4551 operands[1] = GEN_INT (0x7e + off);
4552 operands[2] = GEN_INT (val - off - 0x7e);
4558 operands[1] = GEN_INT (off);
4559 operands[2] = GEN_INT (val - off);
4563 ;; 8-bit Integer moves
4565 ;; Unlike most other insns, the move insns can't be split with
4566 ;; different predicates, because register spilling and other parts of
4567 ;; the compiler, have memoized the insn number already.
4568 ;; Unsigned loads are used because LOAD_EXTEND_OP returns ZERO_EXTEND.
4570 (define_expand "movqi"
4571 [(set (match_operand:QI 0 "")
4572 (match_operand:QI 1 ""))]
4575 if (mips_legitimize_move (QImode, operands[0], operands[1]))
4579 (define_insn "*movqi_internal"
4580 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,m,*a,*d")
4581 (match_operand:QI 1 "move_operand" "d,I,m,dJ,*d*J,*a"))]
4583 && (register_operand (operands[0], QImode)
4584 || reg_or_0_operand (operands[1], QImode))"
4585 { return mips_output_move (operands[0], operands[1]); }
4586 [(set_attr "move_type" "move,const,load,store,mtlo,mflo")
4587 (set_attr "mode" "QI")])
4589 (define_insn "*movqi_mips16"
4590 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m,*d")
4591 (match_operand:QI 1 "move_operand" "d,d,y,K,N,m,d,*a"))]
4593 && (register_operand (operands[0], QImode)
4594 || register_operand (operands[1], QImode))"
4595 { return mips_output_move (operands[0], operands[1]); }
4596 [(set_attr "move_type" "move,move,move,const,constN,load,store,mflo")
4597 (set_attr "mode" "QI")])
4599 ;; On the mips16, we can split lb $r,N($r) into an add and a load,
4600 ;; when the original load is a 4 byte instruction but the add and the
4601 ;; load are 2 2 byte instructions.
4604 [(set (match_operand:QI 0 "d_operand")
4605 (mem:QI (plus:SI (match_dup 0)
4606 (match_operand:SI 1 "const_int_operand"))))]
4607 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
4608 && ((INTVAL (operands[1]) < 0
4609 && INTVAL (operands[1]) >= -0x80)
4610 || (INTVAL (operands[1]) >= 32
4611 && INTVAL (operands[1]) <= 31 + 0x7f))"
4612 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
4613 (set (match_dup 0) (mem:QI (plus:SI (match_dup 0) (match_dup 2))))]
4615 HOST_WIDE_INT val = INTVAL (operands[1]);
4618 operands[2] = const0_rtx;
4621 operands[1] = GEN_INT (0x7f);
4622 operands[2] = GEN_INT (val - 0x7f);
4626 ;; 32-bit floating point moves
4628 (define_expand "movsf"
4629 [(set (match_operand:SF 0 "")
4630 (match_operand:SF 1 ""))]
4633 if (mips_legitimize_move (SFmode, operands[0], operands[1]))
4637 (define_insn "*movsf_hardfloat"
4638 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m")
4639 (match_operand:SF 1 "move_operand" "f,G,m,f,G,*d,*f,*G*d,*m,*d"))]
4641 && (register_operand (operands[0], SFmode)
4642 || reg_or_0_operand (operands[1], SFmode))"
4643 { return mips_output_move (operands[0], operands[1]); }
4644 [(set_attr "move_type" "fmove,mtc,fpload,fpstore,store,mtc,mfc,move,load,store")
4645 (set_attr "mode" "SF")])
4647 (define_insn "*movsf_softfloat"
4648 [(set (match_operand:SF 0 "nonimmediate_operand" "=d,d,m")
4649 (match_operand:SF 1 "move_operand" "Gd,m,d"))]
4650 "TARGET_SOFT_FLOAT && !TARGET_MIPS16
4651 && (register_operand (operands[0], SFmode)
4652 || reg_or_0_operand (operands[1], SFmode))"
4653 { return mips_output_move (operands[0], operands[1]); }
4654 [(set_attr "move_type" "move,load,store")
4655 (set_attr "mode" "SF")])
4657 (define_insn "*movsf_mips16"
4658 [(set (match_operand:SF 0 "nonimmediate_operand" "=d,y,d,d,m")
4659 (match_operand:SF 1 "move_operand" "d,d,y,m,d"))]
4661 && (register_operand (operands[0], SFmode)
4662 || register_operand (operands[1], SFmode))"
4663 { return mips_output_move (operands[0], operands[1]); }
4664 [(set_attr "move_type" "move,move,move,load,store")
4665 (set_attr "mode" "SF")])
4667 ;; 64-bit floating point moves
4669 (define_expand "movdf"
4670 [(set (match_operand:DF 0 "")
4671 (match_operand:DF 1 ""))]
4674 if (mips_legitimize_move (DFmode, operands[0], operands[1]))
4678 (define_insn "*movdf_hardfloat"
4679 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m")
4680 (match_operand:DF 1 "move_operand" "f,G,m,f,G,*d,*f,*d*G,*m,*d"))]
4681 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT
4682 && (register_operand (operands[0], DFmode)
4683 || reg_or_0_operand (operands[1], DFmode))"
4684 { return mips_output_move (operands[0], operands[1]); }
4685 [(set_attr "move_type" "fmove,mtc,fpload,fpstore,store,mtc,mfc,move,load,store")
4686 (set_attr "mode" "DF")])
4688 (define_insn "*movdf_softfloat"
4689 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,m")
4690 (match_operand:DF 1 "move_operand" "dG,m,dG"))]
4691 "(TARGET_SOFT_FLOAT || TARGET_SINGLE_FLOAT) && !TARGET_MIPS16
4692 && (register_operand (operands[0], DFmode)
4693 || reg_or_0_operand (operands[1], DFmode))"
4694 { return mips_output_move (operands[0], operands[1]); }
4695 [(set_attr "move_type" "move,load,store")
4696 (set_attr "mode" "DF")])
4698 (define_insn "*movdf_mips16"
4699 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,y,d,d,m")
4700 (match_operand:DF 1 "move_operand" "d,d,y,m,d"))]
4702 && (register_operand (operands[0], DFmode)
4703 || register_operand (operands[1], DFmode))"
4704 { return mips_output_move (operands[0], operands[1]); }
4705 [(set_attr "move_type" "move,move,move,load,store")
4706 (set_attr "mode" "DF")])
4708 ;; 128-bit integer moves
4710 (define_expand "movti"
4711 [(set (match_operand:TI 0)
4712 (match_operand:TI 1))]
4715 if (mips_legitimize_move (TImode, operands[0], operands[1]))
4719 (define_insn "*movti"
4720 [(set (match_operand:TI 0 "nonimmediate_operand" "=d,d,d,m,*a,*a,*d")
4721 (match_operand:TI 1 "move_operand" "d,i,m,dJ,*J,*d,*a"))]
4724 && (register_operand (operands[0], TImode)
4725 || reg_or_0_operand (operands[1], TImode))"
4726 { return mips_output_move (operands[0], operands[1]); }
4727 [(set_attr "move_type" "move,const,load,store,imul,mtlo,mflo")
4729 (if_then_else (eq_attr "move_type" "imul")
4731 (const_string "TI")))])
4733 (define_insn "*movti_mips16"
4734 [(set (match_operand:TI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m,*d")
4735 (match_operand:TI 1 "move_operand" "d,d,y,K,N,m,d,*a"))]
4738 && (register_operand (operands[0], TImode)
4739 || register_operand (operands[1], TImode))"
4741 [(set_attr "move_type" "move,move,move,const,constN,load,store,mflo")
4742 (set_attr "mode" "TI")])
4744 ;; 128-bit floating point moves
4746 (define_expand "movtf"
4747 [(set (match_operand:TF 0)
4748 (match_operand:TF 1))]
4751 if (mips_legitimize_move (TFmode, operands[0], operands[1]))
4755 ;; This pattern handles both hard- and soft-float cases.
4756 (define_insn "*movtf"
4757 [(set (match_operand:TF 0 "nonimmediate_operand" "=d,d,m,f,d,f,m")
4758 (match_operand:TF 1 "move_operand" "dG,m,dG,dG,f,m,f"))]
4761 && (register_operand (operands[0], TFmode)
4762 || reg_or_0_operand (operands[1], TFmode))"
4764 [(set_attr "move_type" "move,load,store,mtc,mfc,fpload,fpstore")
4765 (set_attr "mode" "TF")])
4767 (define_insn "*movtf_mips16"
4768 [(set (match_operand:TF 0 "nonimmediate_operand" "=d,y,d,d,m")
4769 (match_operand:TF 1 "move_operand" "d,d,y,m,d"))]
4772 && (register_operand (operands[0], TFmode)
4773 || register_operand (operands[1], TFmode))"
4775 [(set_attr "move_type" "move,move,move,load,store")
4776 (set_attr "mode" "TF")])
4779 [(set (match_operand:MOVE64 0 "nonimmediate_operand")
4780 (match_operand:MOVE64 1 "move_operand"))]
4781 "reload_completed && mips_split_move_insn_p (operands[0], operands[1], insn)"
4784 mips_split_move_insn (operands[0], operands[1], curr_insn);
4789 [(set (match_operand:MOVE128 0 "nonimmediate_operand")
4790 (match_operand:MOVE128 1 "move_operand"))]
4791 "reload_completed && mips_split_move_insn_p (operands[0], operands[1], insn)"
4794 mips_split_move_insn (operands[0], operands[1], curr_insn);
4798 ;; When generating mips16 code, split moves of negative constants into
4799 ;; a positive "li" followed by a negation.
4801 [(set (match_operand 0 "d_operand")
4802 (match_operand 1 "const_int_operand"))]
4803 "TARGET_MIPS16 && reload_completed && INTVAL (operands[1]) < 0"
4807 (neg:SI (match_dup 2)))]
4809 operands[2] = gen_lowpart (SImode, operands[0]);
4810 operands[3] = GEN_INT (-INTVAL (operands[1]));
4813 ;; 64-bit paired-single floating point moves
4815 (define_expand "movv2sf"
4816 [(set (match_operand:V2SF 0)
4817 (match_operand:V2SF 1))]
4818 "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT"
4820 if (mips_legitimize_move (V2SFmode, operands[0], operands[1]))
4824 (define_insn "*movv2sf"
4825 [(set (match_operand:V2SF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m")
4826 (match_operand:V2SF 1 "move_operand" "f,YG,m,f,YG,*d,*f,*d*YG,*m,*d"))]
4828 && TARGET_PAIRED_SINGLE_FLOAT
4829 && (register_operand (operands[0], V2SFmode)
4830 || reg_or_0_operand (operands[1], V2SFmode))"
4831 { return mips_output_move (operands[0], operands[1]); }
4832 [(set_attr "move_type" "fmove,mtc,fpload,fpstore,store,mtc,mfc,move,load,store")
4833 (set_attr "mode" "DF")])
4835 ;; Extract the high part of a HI/LO value. See mips_hard_regno_mode_ok_p
4836 ;; for the reason why we can't just use (reg:GPR HI_REGNUM).
4838 ;; When generating VR4120 or VR4130 code, we use MACCHI and DMACCHI
4839 ;; instead of MFHI. This avoids both the normal MIPS III hi/lo hazards
4840 ;; and the errata related to -mfix-vr4130.
4841 (define_insn "mfhi<GPR:mode>_<HILO:mode>"
4842 [(set (match_operand:GPR 0 "register_operand" "=d")
4843 (unspec:GPR [(match_operand:HILO 1 "hilo_operand" "x")]
4846 { return ISA_HAS_MACCHI ? "<GPR:d>macchi\t%0,%.,%." : "mfhi\t%0"; }
4847 [(set_attr "type" "mfhi")
4848 (set_attr "mode" "<GPR:MODE>")])
4850 ;; Set the high part of a HI/LO value, given that the low part has
4851 ;; already been set. See mips_hard_regno_mode_ok_p for the reason
4852 ;; why we can't just use (reg:GPR HI_REGNUM).
4853 (define_insn "mthi<GPR:mode>_<HILO:mode>"
4854 [(set (match_operand:HILO 0 "register_operand" "=x")
4855 (unspec:HILO [(match_operand:GPR 1 "reg_or_0_operand" "dJ")
4856 (match_operand:GPR 2 "register_operand" "l")]
4860 [(set_attr "type" "mthi")
4861 (set_attr "mode" "SI")])
4863 ;; Emit a doubleword move in which exactly one of the operands is
4864 ;; a floating-point register. We can't just emit two normal moves
4865 ;; because of the constraints imposed by the FPU register model;
4866 ;; see mips_cannot_change_mode_class for details. Instead, we keep
4867 ;; the FPR whole and use special patterns to refer to each word of
4868 ;; the other operand.
4870 (define_expand "move_doubleword_fpr<mode>"
4871 [(set (match_operand:SPLITF 0)
4872 (match_operand:SPLITF 1))]
4875 if (FP_REG_RTX_P (operands[0]))
4877 rtx low = mips_subword (operands[1], 0);
4878 rtx high = mips_subword (operands[1], 1);
4879 emit_insn (gen_load_low<mode> (operands[0], low));
4880 if (TARGET_FLOAT64 && !TARGET_64BIT)
4881 emit_insn (gen_mthc1<mode> (operands[0], high, operands[0]));
4883 emit_insn (gen_load_high<mode> (operands[0], high, operands[0]));
4887 rtx low = mips_subword (operands[0], 0);
4888 rtx high = mips_subword (operands[0], 1);
4889 emit_insn (gen_store_word<mode> (low, operands[1], const0_rtx));
4890 if (TARGET_FLOAT64 && !TARGET_64BIT)
4891 emit_insn (gen_mfhc1<mode> (high, operands[1]));
4893 emit_insn (gen_store_word<mode> (high, operands[1], const1_rtx));
4898 ;; Load the low word of operand 0 with operand 1.
4899 (define_insn "load_low<mode>"
4900 [(set (match_operand:SPLITF 0 "register_operand" "=f,f")
4901 (unspec:SPLITF [(match_operand:<HALFMODE> 1 "general_operand" "dJ,m")]
4905 operands[0] = mips_subword (operands[0], 0);
4906 return mips_output_move (operands[0], operands[1]);
4908 [(set_attr "move_type" "mtc,fpload")
4909 (set_attr "mode" "<HALFMODE>")])
4911 ;; Load the high word of operand 0 from operand 1, preserving the value
4913 (define_insn "load_high<mode>"
4914 [(set (match_operand:SPLITF 0 "register_operand" "=f,f")
4915 (unspec:SPLITF [(match_operand:<HALFMODE> 1 "general_operand" "dJ,m")
4916 (match_operand:SPLITF 2 "register_operand" "0,0")]
4920 operands[0] = mips_subword (operands[0], 1);
4921 return mips_output_move (operands[0], operands[1]);
4923 [(set_attr "move_type" "mtc,fpload")
4924 (set_attr "mode" "<HALFMODE>")])
4926 ;; Store one word of operand 1 in operand 0. Operand 2 is 1 to store the
4927 ;; high word and 0 to store the low word.
4928 (define_insn "store_word<mode>"
4929 [(set (match_operand:<HALFMODE> 0 "nonimmediate_operand" "=d,m")
4930 (unspec:<HALFMODE> [(match_operand:SPLITF 1 "register_operand" "f,f")
4931 (match_operand 2 "const_int_operand")]
4932 UNSPEC_STORE_WORD))]
4935 operands[1] = mips_subword (operands[1], INTVAL (operands[2]));
4936 return mips_output_move (operands[0], operands[1]);
4938 [(set_attr "move_type" "mfc,fpstore")
4939 (set_attr "mode" "<HALFMODE>")])
4941 ;; Move operand 1 to the high word of operand 0 using mthc1, preserving the
4942 ;; value in the low word.
4943 (define_insn "mthc1<mode>"
4944 [(set (match_operand:SPLITF 0 "register_operand" "=f")
4945 (unspec:SPLITF [(match_operand:<HALFMODE> 1 "reg_or_0_operand" "dJ")
4946 (match_operand:SPLITF 2 "register_operand" "0")]
4948 "TARGET_HARD_FLOAT && ISA_HAS_MXHC1"
4950 [(set_attr "move_type" "mtc")
4951 (set_attr "mode" "<HALFMODE>")])
4953 ;; Move high word of operand 1 to operand 0 using mfhc1.
4954 (define_insn "mfhc1<mode>"
4955 [(set (match_operand:<HALFMODE> 0 "register_operand" "=d")
4956 (unspec:<HALFMODE> [(match_operand:SPLITF 1 "register_operand" "f")]
4958 "TARGET_HARD_FLOAT && ISA_HAS_MXHC1"
4960 [(set_attr "move_type" "mfc")
4961 (set_attr "mode" "<HALFMODE>")])
4963 ;; Move a constant that satisfies CONST_GP_P into operand 0.
4964 (define_expand "load_const_gp_<mode>"
4965 [(set (match_operand:P 0 "register_operand" "=d")
4966 (const:P (unspec:P [(const_int 0)] UNSPEC_GP)))])
4968 ;; Insn to initialize $gp for n32/n64 abicalls. Operand 0 is the offset
4969 ;; of _gp from the start of this function. Operand 1 is the incoming
4970 ;; function address.
4971 (define_insn_and_split "loadgp_newabi_<mode>"
4972 [(set (match_operand:P 0 "register_operand" "=&d")
4973 (unspec:P [(match_operand:P 1)
4974 (match_operand:P 2 "register_operand" "d")]
4976 "mips_current_loadgp_style () == LOADGP_NEWABI"
4977 { return mips_must_initialize_gp_p () ? "#" : ""; }
4978 "&& mips_must_initialize_gp_p ()"
4979 [(set (match_dup 0) (match_dup 3))
4980 (set (match_dup 0) (match_dup 4))
4981 (set (match_dup 0) (match_dup 5))]
4983 operands[3] = gen_rtx_HIGH (Pmode, operands[1]);
4984 operands[4] = gen_rtx_PLUS (Pmode, operands[0], operands[2]);
4985 operands[5] = gen_rtx_LO_SUM (Pmode, operands[0], operands[1]);
4987 [(set_attr "type" "ghost")])
4989 ;; Likewise, for -mno-shared code. Operand 0 is the __gnu_local_gp symbol.
4990 (define_insn_and_split "loadgp_absolute_<mode>"
4991 [(set (match_operand:P 0 "register_operand" "=d")
4992 (unspec:P [(match_operand:P 1)] UNSPEC_LOADGP))]
4993 "mips_current_loadgp_style () == LOADGP_ABSOLUTE"
4994 { return mips_must_initialize_gp_p () ? "#" : ""; }
4995 "&& mips_must_initialize_gp_p ()"
4998 mips_emit_move (operands[0], operands[1]);
5001 [(set_attr "type" "ghost")])
5003 ;; This blockage instruction prevents the gp load from being
5004 ;; scheduled after an implicit use of gp. It also prevents
5005 ;; the load from being deleted as dead.
5006 (define_insn "loadgp_blockage"
5007 [(unspec_volatile [(reg:SI 28)] UNSPEC_BLOCKAGE)]
5010 [(set_attr "type" "ghost")])
5012 ;; Initialize $gp for RTP PIC. Operand 0 is the __GOTT_BASE__ symbol
5013 ;; and operand 1 is the __GOTT_INDEX__ symbol.
5014 (define_insn_and_split "loadgp_rtp_<mode>"
5015 [(set (match_operand:P 0 "register_operand" "=d")
5016 (unspec:P [(match_operand:P 1 "symbol_ref_operand")
5017 (match_operand:P 2 "symbol_ref_operand")]
5019 "mips_current_loadgp_style () == LOADGP_RTP"
5020 { return mips_must_initialize_gp_p () ? "#" : ""; }
5021 "&& mips_must_initialize_gp_p ()"
5022 [(set (match_dup 0) (high:P (match_dup 3)))
5023 (set (match_dup 0) (unspec:P [(match_dup 0)
5024 (match_dup 3)] UNSPEC_LOAD_GOT))
5025 (set (match_dup 0) (unspec:P [(match_dup 0)
5026 (match_dup 4)] UNSPEC_LOAD_GOT))]
5028 operands[3] = mips_unspec_address (operands[1], SYMBOL_ABSOLUTE);
5029 operands[4] = mips_unspec_address (operands[2], SYMBOL_HALF);
5031 [(set_attr "type" "ghost")])
5033 ;; Initialize the global pointer for MIPS16 code. Operand 0 is the
5034 ;; global pointer and operand 1 is the MIPS16 register that holds
5035 ;; the required value.
5036 (define_insn_and_split "copygp_mips16_<mode>"
5037 [(set (match_operand:P 0 "register_operand" "=y")
5038 (unspec:P [(match_operand:P 1 "register_operand" "d")]
5041 { return mips_must_initialize_gp_p () ? "#" : ""; }
5042 "&& mips_must_initialize_gp_p ()"
5043 [(set (match_dup 0) (match_dup 1))]
5045 [(set_attr "type" "ghost")])
5047 ;; A placeholder for where the cprestore instruction should go,
5048 ;; if we decide we need one. Operand 0 and operand 1 are as for
5049 ;; "cprestore". Operand 2 is a register that holds the gp value.
5051 ;; The "cprestore" pattern requires operand 2 to be pic_offset_table_rtx,
5052 ;; otherwise any register that holds the correct value will do.
5053 (define_insn_and_split "potential_cprestore_<mode>"
5054 [(set (match_operand:P 0 "cprestore_save_slot_operand" "=X,X")
5055 (unspec:P [(match_operand:P 1 "const_int_operand" "I,i")
5056 (match_operand:P 2 "register_operand" "d,d")]
5057 UNSPEC_POTENTIAL_CPRESTORE))
5058 (clobber (match_operand:P 3 "scratch_operand" "=X,&d"))]
5059 "!TARGET_CPRESTORE_DIRECTIVE || operands[2] == pic_offset_table_rtx"
5060 { return mips_must_initialize_gp_p () ? "#" : ""; }
5061 "mips_must_initialize_gp_p ()"
5064 mips_save_gp_to_cprestore_slot (operands[0], operands[1],
5065 operands[2], operands[3]);
5068 [(set_attr "type" "ghost")])
5070 ;; Emit a .cprestore directive, which normally expands to a single store
5071 ;; instruction. Operand 0 is a (possibly illegitimate) sp-based MEM
5072 ;; for the cprestore slot. Operand 1 is the offset of the slot from
5073 ;; the stack pointer. (This is redundant with operand 0, but it makes
5074 ;; things a little simpler.)
5075 (define_insn "cprestore_<mode>"
5076 [(set (match_operand:P 0 "cprestore_save_slot_operand" "=X,X")
5077 (unspec:P [(match_operand:P 1 "const_int_operand" "I,i")
5080 "TARGET_CPRESTORE_DIRECTIVE"
5082 if (mips_nomacro.nesting_level > 0 && which_alternative == 1)
5083 return ".set\tmacro\;.cprestore\t%1\;.set\tnomacro";
5085 return ".cprestore\t%1";
5087 [(set_attr "type" "store")
5088 (set_attr "length" "4,12")])
5090 (define_insn "use_cprestore_<mode>"
5091 [(set (reg:P CPRESTORE_SLOT_REGNUM)
5092 (match_operand:P 0 "cprestore_load_slot_operand"))]
5095 [(set_attr "type" "ghost")])
5097 ;; Expand in-line code to clear the instruction cache between operand[0] and
5099 (define_expand "clear_cache"
5100 [(match_operand 0 "pmode_register_operand")
5101 (match_operand 1 "pmode_register_operand")]
5107 mips_expand_synci_loop (operands[0], operands[1]);
5108 emit_insn (gen_sync ());
5109 emit_insn (PMODE_INSN (gen_clear_hazard, ()));
5111 else if (mips_cache_flush_func && mips_cache_flush_func[0])
5113 rtx len = gen_reg_rtx (Pmode);
5114 emit_insn (gen_sub3_insn (len, operands[1], operands[0]));
5115 MIPS_ICACHE_SYNC (operands[0], len);
5121 [(unspec_volatile [(const_int 0)] UNSPEC_SYNC)]
5123 { return mips_output_sync (); })
5125 (define_insn "synci"
5126 [(unspec_volatile [(match_operand 0 "pmode_register_operand" "d")]
5131 (define_insn "rdhwr_synci_step_<mode>"
5132 [(set (match_operand:P 0 "register_operand" "=d")
5133 (unspec_volatile [(const_int 1)]
5138 (define_insn "clear_hazard_<mode>"
5139 [(unspec_volatile [(const_int 0)] UNSPEC_CLEAR_HAZARD)
5140 (clobber (reg:P RETURN_ADDR_REGNUM))]
5143 return "%(%<bal\t1f\n"
5145 "1:\t<d>addiu\t$31,$31,12\n"
5149 [(set_attr "length" "20")])
5151 ;; Cache operations for R4000-style caches.
5152 (define_insn "mips_cache"
5153 [(set (mem:BLK (scratch))
5154 (unspec:BLK [(match_operand:SI 0 "const_int_operand")
5155 (match_operand:QI 1 "address_operand" "p")]
5156 UNSPEC_MIPS_CACHE))]
5160 ;; Similar, but with the operands hard-coded to an R10K cache barrier
5161 ;; operation. We keep the pattern distinct so that we can identify
5162 ;; cache operations inserted by -mr10k-cache-barrier=, and so that
5163 ;; the operation is never inserted into a delay slot.
5164 (define_insn "r10k_cache_barrier"
5165 [(set (mem:BLK (scratch))
5166 (unspec:BLK [(const_int 0)] UNSPEC_R10K_CACHE_BARRIER))]
5169 [(set_attr "can_delay" "no")])
5171 ;; Block moves, see mips.c for more details.
5172 ;; Argument 0 is the destination
5173 ;; Argument 1 is the source
5174 ;; Argument 2 is the length
5175 ;; Argument 3 is the alignment
5177 (define_expand "movmemsi"
5178 [(parallel [(set (match_operand:BLK 0 "general_operand")
5179 (match_operand:BLK 1 "general_operand"))
5180 (use (match_operand:SI 2 ""))
5181 (use (match_operand:SI 3 "const_int_operand"))])]
5182 "!TARGET_MIPS16 && !TARGET_MEMCPY"
5184 if (mips_expand_block_move (operands[0], operands[1], operands[2]))
5191 ;; ....................
5195 ;; ....................
5197 (define_expand "<optab><mode>3"
5198 [(set (match_operand:GPR 0 "register_operand")
5199 (any_shift:GPR (match_operand:GPR 1 "register_operand")
5200 (match_operand:SI 2 "arith_operand")))]
5203 /* On the mips16, a shift of more than 8 is a four byte instruction,
5204 so, for a shift between 8 and 16, it is just as fast to do two
5205 shifts of 8 or less. If there is a lot of shifting going on, we
5206 may win in CSE. Otherwise combine will put the shifts back
5207 together again. This can be called by mips_function_arg, so we must
5208 be careful not to allocate a new register if we've reached the
5212 && CONST_INT_P (operands[2])
5213 && INTVAL (operands[2]) > 8
5214 && INTVAL (operands[2]) <= 16
5215 && !reload_in_progress
5216 && !reload_completed)
5218 rtx temp = gen_reg_rtx (<MODE>mode);
5220 emit_insn (gen_<optab><mode>3 (temp, operands[1], GEN_INT (8)));
5221 emit_insn (gen_<optab><mode>3 (operands[0], temp,
5222 GEN_INT (INTVAL (operands[2]) - 8)));
5227 (define_insn "*<optab><mode>3"
5228 [(set (match_operand:GPR 0 "register_operand" "=d")
5229 (any_shift:GPR (match_operand:GPR 1 "register_operand" "d")
5230 (match_operand:SI 2 "arith_operand" "dI")))]
5233 if (CONST_INT_P (operands[2]))
5234 operands[2] = GEN_INT (INTVAL (operands[2])
5235 & (GET_MODE_BITSIZE (<MODE>mode) - 1));
5237 return "<d><insn>\t%0,%1,%2";
5239 [(set_attr "type" "shift")
5240 (set_attr "mode" "<MODE>")])
5242 (define_insn "*<optab>si3_extend"
5243 [(set (match_operand:DI 0 "register_operand" "=d")
5245 (any_shift:SI (match_operand:SI 1 "register_operand" "d")
5246 (match_operand:SI 2 "arith_operand" "dI"))))]
5247 "TARGET_64BIT && !TARGET_MIPS16"
5249 if (CONST_INT_P (operands[2]))
5250 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
5252 return "<insn>\t%0,%1,%2";
5254 [(set_attr "type" "shift")
5255 (set_attr "mode" "SI")])
5257 (define_insn "*<optab>si3_mips16"
5258 [(set (match_operand:SI 0 "register_operand" "=d,d")
5259 (any_shift:SI (match_operand:SI 1 "register_operand" "0,d")
5260 (match_operand:SI 2 "arith_operand" "d,I")))]
5263 if (which_alternative == 0)
5264 return "<insn>\t%0,%2";
5266 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
5267 return "<insn>\t%0,%1,%2";
5269 [(set_attr "type" "shift")
5270 (set_attr "mode" "SI")
5271 (set_attr_alternative "length"
5273 (if_then_else (match_operand 2 "m16_uimm3_b")
5277 ;; We need separate DImode MIPS16 patterns because of the irregularity
5279 (define_insn "*ashldi3_mips16"
5280 [(set (match_operand:DI 0 "register_operand" "=d,d")
5281 (ashift:DI (match_operand:DI 1 "register_operand" "0,d")
5282 (match_operand:SI 2 "arith_operand" "d,I")))]
5283 "TARGET_64BIT && TARGET_MIPS16"
5285 if (which_alternative == 0)
5286 return "dsll\t%0,%2";
5288 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
5289 return "dsll\t%0,%1,%2";
5291 [(set_attr "type" "shift")
5292 (set_attr "mode" "DI")
5293 (set_attr_alternative "length"
5295 (if_then_else (match_operand 2 "m16_uimm3_b")
5299 (define_insn "*ashrdi3_mips16"
5300 [(set (match_operand:DI 0 "register_operand" "=d,d")
5301 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0,0")
5302 (match_operand:SI 2 "arith_operand" "d,I")))]
5303 "TARGET_64BIT && TARGET_MIPS16"
5305 if (CONST_INT_P (operands[2]))
5306 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
5308 return "dsra\t%0,%2";
5310 [(set_attr "type" "shift")
5311 (set_attr "mode" "DI")
5312 (set_attr_alternative "length"
5314 (if_then_else (match_operand 2 "m16_uimm3_b")
5318 (define_insn "*lshrdi3_mips16"
5319 [(set (match_operand:DI 0 "register_operand" "=d,d")
5320 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0,0")
5321 (match_operand:SI 2 "arith_operand" "d,I")))]
5322 "TARGET_64BIT && TARGET_MIPS16"
5324 if (CONST_INT_P (operands[2]))
5325 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
5327 return "dsrl\t%0,%2";
5329 [(set_attr "type" "shift")
5330 (set_attr "mode" "DI")
5331 (set_attr_alternative "length"
5333 (if_then_else (match_operand 2 "m16_uimm3_b")
5337 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
5340 [(set (match_operand:GPR 0 "d_operand")
5341 (any_shift:GPR (match_operand:GPR 1 "d_operand")
5342 (match_operand:GPR 2 "const_int_operand")))]
5343 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
5344 && INTVAL (operands[2]) > 8
5345 && INTVAL (operands[2]) <= 16"
5346 [(set (match_dup 0) (any_shift:GPR (match_dup 1) (const_int 8)))
5347 (set (match_dup 0) (any_shift:GPR (match_dup 0) (match_dup 2)))]
5348 { operands[2] = GEN_INT (INTVAL (operands[2]) - 8); })
5350 ;; If we load a byte on the mips16 as a bitfield, the resulting
5351 ;; sequence of instructions is too complicated for combine, because it
5352 ;; involves four instructions: a load, a shift, a constant load into a
5353 ;; register, and an and (the key problem here is that the mips16 does
5354 ;; not have and immediate). We recognize a shift of a load in order
5355 ;; to make it simple enough for combine to understand.
5357 ;; The length here is the worst case: the length of the split version
5358 ;; will be more accurate.
5359 (define_insn_and_split ""
5360 [(set (match_operand:SI 0 "register_operand" "=d")
5361 (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
5362 (match_operand:SI 2 "immediate_operand" "I")))]
5366 [(set (match_dup 0) (match_dup 1))
5367 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
5369 [(set_attr "type" "load")
5370 (set_attr "mode" "SI")
5371 (set_attr "length" "16")])
5373 (define_insn "rotr<mode>3"
5374 [(set (match_operand:GPR 0 "register_operand" "=d")
5375 (rotatert:GPR (match_operand:GPR 1 "register_operand" "d")
5376 (match_operand:SI 2 "arith_operand" "dI")))]
5379 if (CONST_INT_P (operands[2]))
5380 gcc_assert (INTVAL (operands[2]) >= 0
5381 && INTVAL (operands[2]) < GET_MODE_BITSIZE (<MODE>mode));
5383 return "<d>ror\t%0,%1,%2";
5385 [(set_attr "type" "shift")
5386 (set_attr "mode" "<MODE>")])
5388 (define_insn "bswaphi2"
5389 [(set (match_operand:HI 0 "register_operand" "=d")
5390 (bswap:HI (match_operand:HI 1 "register_operand" "d")))]
5393 [(set_attr "type" "shift")])
5395 (define_insn_and_split "bswapsi2"
5396 [(set (match_operand:SI 0 "register_operand" "=d")
5397 (bswap:SI (match_operand:SI 1 "register_operand" "d")))]
5398 "ISA_HAS_WSBH && ISA_HAS_ROR"
5401 [(set (match_dup 0) (unspec:SI [(match_dup 1)] UNSPEC_WSBH))
5402 (set (match_dup 0) (rotatert:SI (match_dup 0) (const_int 16)))]
5404 [(set_attr "length" "8")])
5406 (define_insn_and_split "bswapdi2"
5407 [(set (match_operand:DI 0 "register_operand" "=d")
5408 (bswap:DI (match_operand:DI 1 "register_operand" "d")))]
5409 "TARGET_64BIT && ISA_HAS_WSBH"
5412 [(set (match_dup 0) (unspec:DI [(match_dup 1)] UNSPEC_DSBH))
5413 (set (match_dup 0) (unspec:DI [(match_dup 0)] UNSPEC_DSHD))]
5415 [(set_attr "length" "8")])
5418 [(set (match_operand:SI 0 "register_operand" "=d")
5419 (unspec:SI [(match_operand:SI 1 "register_operand" "d")] UNSPEC_WSBH))]
5422 [(set_attr "type" "shift")])
5425 [(set (match_operand:DI 0 "register_operand" "=d")
5426 (unspec:DI [(match_operand:DI 1 "register_operand" "d")] UNSPEC_DSBH))]
5427 "TARGET_64BIT && ISA_HAS_WSBH"
5429 [(set_attr "type" "shift")])
5432 [(set (match_operand:DI 0 "register_operand" "=d")
5433 (unspec:DI [(match_operand:DI 1 "register_operand" "d")] UNSPEC_DSHD))]
5434 "TARGET_64BIT && ISA_HAS_WSBH"
5436 [(set_attr "type" "shift")])
5439 ;; ....................
5441 ;; CONDITIONAL BRANCHES
5443 ;; ....................
5445 ;; Conditional branches on floating-point equality tests.
5447 (define_insn "*branch_fp"
5450 (match_operator 1 "equality_operator"
5451 [(match_operand:CC 2 "register_operand" "z")
5453 (label_ref (match_operand 0 "" ""))
5457 return mips_output_conditional_branch (insn, operands,
5458 MIPS_BRANCH ("b%F1", "%Z2%0"),
5459 MIPS_BRANCH ("b%W1", "%Z2%0"));
5461 [(set_attr "type" "branch")])
5463 (define_insn "*branch_fp_inverted"
5466 (match_operator 1 "equality_operator"
5467 [(match_operand:CC 2 "register_operand" "z")
5470 (label_ref (match_operand 0 "" ""))))]
5473 return mips_output_conditional_branch (insn, operands,
5474 MIPS_BRANCH ("b%W1", "%Z2%0"),
5475 MIPS_BRANCH ("b%F1", "%Z2%0"));
5477 [(set_attr "type" "branch")])
5479 ;; Conditional branches on ordered comparisons with zero.
5481 (define_insn "*branch_order<mode>"
5484 (match_operator 1 "order_operator"
5485 [(match_operand:GPR 2 "register_operand" "d")
5487 (label_ref (match_operand 0 "" ""))
5490 { return mips_output_order_conditional_branch (insn, operands, false); }
5491 [(set_attr "type" "branch")])
5493 (define_insn "*branch_order<mode>_inverted"
5496 (match_operator 1 "order_operator"
5497 [(match_operand:GPR 2 "register_operand" "d")
5500 (label_ref (match_operand 0 "" ""))))]
5502 { return mips_output_order_conditional_branch (insn, operands, true); }
5503 [(set_attr "type" "branch")])
5505 ;; Conditional branch on equality comparison.
5507 (define_insn "*branch_equality<mode>"
5510 (match_operator 1 "equality_operator"
5511 [(match_operand:GPR 2 "register_operand" "d")
5512 (match_operand:GPR 3 "reg_or_0_operand" "dJ")])
5513 (label_ref (match_operand 0 "" ""))
5517 return mips_output_conditional_branch (insn, operands,
5518 MIPS_BRANCH ("b%C1", "%2,%z3,%0"),
5519 MIPS_BRANCH ("b%N1", "%2,%z3,%0"));
5521 [(set_attr "type" "branch")])
5523 (define_insn "*branch_equality<mode>_inverted"
5526 (match_operator 1 "equality_operator"
5527 [(match_operand:GPR 2 "register_operand" "d")
5528 (match_operand:GPR 3 "reg_or_0_operand" "dJ")])
5530 (label_ref (match_operand 0 "" ""))))]
5533 return mips_output_conditional_branch (insn, operands,
5534 MIPS_BRANCH ("b%N1", "%2,%z3,%0"),
5535 MIPS_BRANCH ("b%C1", "%2,%z3,%0"));
5537 [(set_attr "type" "branch")])
5541 (define_insn "*branch_equality<mode>_mips16"
5544 (match_operator 1 "equality_operator"
5545 [(match_operand:GPR 2 "register_operand" "d,t")
5547 (label_ref (match_operand 0 "" ""))
5553 [(set_attr "type" "branch")])
5555 (define_insn "*branch_equality<mode>_mips16_inverted"
5558 (match_operator 1 "equality_operator"
5559 [(match_operand:GPR 2 "register_operand" "d,t")
5562 (label_ref (match_operand 0 "" ""))))]
5567 [(set_attr "type" "branch")])
5569 (define_expand "cbranch<mode>4"
5571 (if_then_else (match_operator 0 "comparison_operator"
5572 [(match_operand:GPR 1 "register_operand")
5573 (match_operand:GPR 2 "nonmemory_operand")])
5574 (label_ref (match_operand 3 ""))
5578 mips_expand_conditional_branch (operands);
5582 (define_expand "cbranch<mode>4"
5584 (if_then_else (match_operator 0 "comparison_operator"
5585 [(match_operand:SCALARF 1 "register_operand")
5586 (match_operand:SCALARF 2 "register_operand")])
5587 (label_ref (match_operand 3 ""))
5591 mips_expand_conditional_branch (operands);
5595 ;; Used to implement built-in functions.
5596 (define_expand "condjump"
5598 (if_then_else (match_operand 0)
5599 (label_ref (match_operand 1))
5602 ;; Branch if bit is set/clear.
5604 (define_insn "*branch_bit<bbv><mode>"
5607 (equality_op (zero_extract:GPR
5608 (match_operand:GPR 1 "register_operand" "d")
5610 (match_operand 2 "const_int_operand" ""))
5612 (label_ref (match_operand 0 ""))
5614 "ISA_HAS_BBIT && UINTVAL (operands[2]) < GET_MODE_BITSIZE (<MODE>mode)"
5617 mips_output_conditional_branch (insn, operands,
5618 MIPS_BRANCH ("bbit<bbv>", "%1,%2,%0"),
5619 MIPS_BRANCH ("bbit<bbinv>", "%1,%2,%0"));
5621 [(set_attr "type" "branch")
5622 (set_attr "branch_likely" "no")])
5624 (define_insn "*branch_bit<bbv><mode>_inverted"
5627 (equality_op (zero_extract:GPR
5628 (match_operand:GPR 1 "register_operand" "d")
5630 (match_operand 2 "const_int_operand" ""))
5633 (label_ref (match_operand 0 ""))))]
5634 "ISA_HAS_BBIT && UINTVAL (operands[2]) < GET_MODE_BITSIZE (<MODE>mode)"
5637 mips_output_conditional_branch (insn, operands,
5638 MIPS_BRANCH ("bbit<bbinv>", "%1,%2,%0"),
5639 MIPS_BRANCH ("bbit<bbv>", "%1,%2,%0"));
5641 [(set_attr "type" "branch")
5642 (set_attr "branch_likely" "no")])
5645 ;; ....................
5647 ;; SETTING A REGISTER FROM A COMPARISON
5649 ;; ....................
5651 ;; Destination is always set in SI mode.
5653 (define_expand "cstore<mode>4"
5654 [(set (match_operand:SI 0 "register_operand")
5655 (match_operator:SI 1 "mips_cstore_operator"
5656 [(match_operand:GPR 2 "register_operand")
5657 (match_operand:GPR 3 "nonmemory_operand")]))]
5660 mips_expand_scc (operands);
5664 (define_insn "*seq_zero_<GPR:mode><GPR2:mode>"
5665 [(set (match_operand:GPR2 0 "register_operand" "=d")
5666 (eq:GPR2 (match_operand:GPR 1 "register_operand" "d")
5668 "!TARGET_MIPS16 && !ISA_HAS_SEQ_SNE"
5670 [(set_attr "type" "slt")
5671 (set_attr "mode" "<GPR:MODE>")])
5673 (define_insn "*seq_zero_<GPR:mode><GPR2:mode>_mips16"
5674 [(set (match_operand:GPR2 0 "register_operand" "=t")
5675 (eq:GPR2 (match_operand:GPR 1 "register_operand" "d")
5677 "TARGET_MIPS16 && !ISA_HAS_SEQ_SNE"
5679 [(set_attr "type" "slt")
5680 (set_attr "mode" "<GPR:MODE>")])
5682 ;; Generate sltiu unless using seq results in better code.
5683 (define_insn "*seq_<GPR:mode><GPR2:mode>_seq"
5684 [(set (match_operand:GPR2 0 "register_operand" "=d,d,d")
5685 (eq:GPR2 (match_operand:GPR 1 "register_operand" "%d,d,d")
5686 (match_operand:GPR 2 "reg_imm10_operand" "d,J,YB")))]
5692 [(set_attr "type" "slt")
5693 (set_attr "mode" "<GPR:MODE>")])
5695 (define_insn "*sne_zero_<GPR:mode><GPR2:mode>"
5696 [(set (match_operand:GPR2 0 "register_operand" "=d")
5697 (ne:GPR2 (match_operand:GPR 1 "register_operand" "d")
5699 "!TARGET_MIPS16 && !ISA_HAS_SEQ_SNE"
5701 [(set_attr "type" "slt")
5702 (set_attr "mode" "<GPR:MODE>")])
5704 ;; Generate sltu unless using sne results in better code.
5705 (define_insn "*sne_<GPR:mode><GPR2:mode>_sne"
5706 [(set (match_operand:GPR2 0 "register_operand" "=d,d,d")
5707 (ne:GPR2 (match_operand:GPR 1 "register_operand" "%d,d,d")
5708 (match_operand:GPR 2 "reg_imm10_operand" "d,J,YB")))]
5714 [(set_attr "type" "slt")
5715 (set_attr "mode" "<GPR:MODE>")])
5717 (define_insn "*sgt<u>_<GPR:mode><GPR2:mode>"
5718 [(set (match_operand:GPR2 0 "register_operand" "=d")
5719 (any_gt:GPR2 (match_operand:GPR 1 "register_operand" "d")
5720 (match_operand:GPR 2 "reg_or_0_operand" "dJ")))]
5723 [(set_attr "type" "slt")
5724 (set_attr "mode" "<GPR:MODE>")])
5726 (define_insn "*sgt<u>_<GPR:mode><GPR2:mode>_mips16"
5727 [(set (match_operand:GPR2 0 "register_operand" "=t")
5728 (any_gt:GPR2 (match_operand:GPR 1 "register_operand" "d")
5729 (match_operand:GPR 2 "register_operand" "d")))]
5732 [(set_attr "type" "slt")
5733 (set_attr "mode" "<GPR:MODE>")])
5735 (define_insn "*sge<u>_<GPR:mode><GPR2:mode>"
5736 [(set (match_operand:GPR2 0 "register_operand" "=d")
5737 (any_ge:GPR2 (match_operand:GPR 1 "register_operand" "d")
5741 [(set_attr "type" "slt")
5742 (set_attr "mode" "<GPR:MODE>")])
5744 (define_insn "*slt<u>_<GPR:mode><GPR2:mode>"
5745 [(set (match_operand:GPR2 0 "register_operand" "=d")
5746 (any_lt:GPR2 (match_operand:GPR 1 "register_operand" "d")
5747 (match_operand:GPR 2 "arith_operand" "dI")))]
5750 [(set_attr "type" "slt")
5751 (set_attr "mode" "<GPR:MODE>")])
5753 (define_insn "*slt<u>_<GPR:mode><GPR2:mode>_mips16"
5754 [(set (match_operand:GPR2 0 "register_operand" "=t,t")
5755 (any_lt:GPR2 (match_operand:GPR 1 "register_operand" "d,d")
5756 (match_operand:GPR 2 "arith_operand" "d,I")))]
5759 [(set_attr "type" "slt")
5760 (set_attr "mode" "<GPR:MODE>")
5761 (set_attr_alternative "length"
5763 (if_then_else (match_operand 2 "m16_uimm8_1")
5767 (define_insn "*sle<u>_<GPR:mode><GPR2:mode>"
5768 [(set (match_operand:GPR2 0 "register_operand" "=d")
5769 (any_le:GPR2 (match_operand:GPR 1 "register_operand" "d")
5770 (match_operand:GPR 2 "sle_operand" "")))]
5773 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
5774 return "slt<u>\t%0,%1,%2";
5776 [(set_attr "type" "slt")
5777 (set_attr "mode" "<GPR:MODE>")])
5779 (define_insn "*sle<u>_<GPR:mode><GPR2:mode>_mips16"
5780 [(set (match_operand:GPR2 0 "register_operand" "=t")
5781 (any_le:GPR2 (match_operand:GPR 1 "register_operand" "d")
5782 (match_operand:GPR 2 "sle_operand" "")))]
5785 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
5786 return "slt<u>\t%1,%2";
5788 [(set_attr "type" "slt")
5789 (set_attr "mode" "<GPR:MODE>")
5790 (set (attr "length") (if_then_else (match_operand 2 "m16_uimm8_m1_1")
5795 ;; ....................
5797 ;; FLOATING POINT COMPARISONS
5799 ;; ....................
5801 (define_insn "s<code>_<mode>"
5802 [(set (match_operand:CC 0 "register_operand" "=z")
5803 (fcond:CC (match_operand:SCALARF 1 "register_operand" "f")
5804 (match_operand:SCALARF 2 "register_operand" "f")))]
5806 "c.<fcond>.<fmt>\t%Z0%1,%2"
5807 [(set_attr "type" "fcmp")
5808 (set_attr "mode" "FPSW")])
5810 (define_insn "s<code>_<mode>"
5811 [(set (match_operand:CC 0 "register_operand" "=z")
5812 (swapped_fcond:CC (match_operand:SCALARF 1 "register_operand" "f")
5813 (match_operand:SCALARF 2 "register_operand" "f")))]
5815 "c.<swapped_fcond>.<fmt>\t%Z0%2,%1"
5816 [(set_attr "type" "fcmp")
5817 (set_attr "mode" "FPSW")])
5820 ;; ....................
5822 ;; UNCONDITIONAL BRANCHES
5824 ;; ....................
5826 ;; Unconditional branches.
5828 (define_expand "jump"
5830 (label_ref (match_operand 0)))])
5832 (define_insn "*jump_absolute"
5834 (label_ref (match_operand 0)))]
5835 "!TARGET_MIPS16 && TARGET_ABSOLUTE_JUMPS"
5836 { return MIPS_ABSOLUTE_JUMP ("%*j\t%l0%/"); }
5837 [(set_attr "type" "jump")])
5839 (define_insn "*jump_pic"
5841 (label_ref (match_operand 0)))]
5842 "!TARGET_MIPS16 && !TARGET_ABSOLUTE_JUMPS"
5844 if (get_attr_length (insn) <= 8)
5845 return "%*b\t%l0%/";
5848 mips_output_load_label (operands[0]);
5849 return "%*jr\t%@%/%]";
5852 [(set_attr "type" "branch")])
5854 ;; We need a different insn for the mips16, because a mips16 branch
5855 ;; does not have a delay slot.
5857 (define_insn "*jump_mips16"
5859 (label_ref (match_operand 0 "" "")))]
5862 [(set_attr "type" "branch")
5863 (set (attr "length")
5864 ;; This calculation is like the normal branch one, but the
5865 ;; range of the unextended instruction is [-0x800, 0x7fe] rather
5866 ;; than [-0x100, 0xfe]. This translates to a range of:
5868 ;; [-(0x800 - sizeof (branch)), 0x7fe]
5869 ;; == [-0x7fe, 0x7fe]
5871 ;; from the shorten_branches reference address. Long-branch
5872 ;; sequences will replace this one, so the minimum length
5873 ;; is one instruction shorter than for conditional branches.
5874 (cond [(and (le (minus (match_dup 0) (pc)) (const_int 2046))
5875 (le (minus (pc) (match_dup 0)) (const_int 2046)))
5877 (and (le (minus (match_dup 0) (pc)) (const_int 65534))
5878 (le (minus (pc) (match_dup 0)) (const_int 65532)))
5880 (and (match_test "TARGET_ABICALLS")
5881 (not (match_test "TARGET_ABSOLUTE_ABICALLS")))
5883 (match_test "Pmode == SImode")
5885 ] (const_int 44)))])
5887 (define_expand "indirect_jump"
5888 [(set (pc) (match_operand 0 "register_operand"))]
5891 operands[0] = force_reg (Pmode, operands[0]);
5892 emit_jump_insn (PMODE_INSN (gen_indirect_jump, (operands[0])));
5896 (define_insn "indirect_jump_<mode>"
5897 [(set (pc) (match_operand:P 0 "register_operand" "d"))]
5900 [(set_attr "type" "jump")
5901 (set_attr "mode" "none")])
5903 ;; A combined jump-and-move instruction, used for MIPS16 long-branch
5904 ;; sequences. Having a dedicated pattern is more convenient than
5905 ;; creating a SEQUENCE for this special case.
5906 (define_insn "indirect_jump_and_restore_<mode>"
5907 [(set (pc) (match_operand:P 1 "register_operand" "d"))
5908 (set (match_operand:P 0 "register_operand" "=d")
5909 (match_operand:P 2 "register_operand" "y"))]
5911 "%(%<jr\t%1\;move\t%0,%2%>%)"
5912 [(set_attr "type" "multi")
5913 (set_attr "extended_mips16" "yes")])
5915 (define_expand "tablejump"
5917 (match_operand 0 "register_operand"))
5918 (use (label_ref (match_operand 1 "")))]
5919 "!TARGET_MIPS16_SHORT_JUMP_TABLES"
5922 operands[0] = expand_binop (Pmode, add_optab, operands[0],
5923 pic_offset_table_rtx, 0, 0, OPTAB_WIDEN);
5924 else if (TARGET_RTP_PIC)
5926 /* When generating RTP PIC, we use case table entries that are relative
5927 to the start of the function. Add the function's address to the
5929 rtx start = get_hard_reg_initial_val (Pmode, PIC_FUNCTION_ADDR_REGNUM);
5930 operands[0] = expand_binop (ptr_mode, add_optab, operands[0],
5931 start, 0, 0, OPTAB_WIDEN);
5934 emit_jump_insn (PMODE_INSN (gen_tablejump, (operands[0], operands[1])));
5938 (define_insn "tablejump_<mode>"
5940 (match_operand:P 0 "register_operand" "d"))
5941 (use (label_ref (match_operand 1 "" "")))]
5944 [(set_attr "type" "jump")
5945 (set_attr "mode" "none")])
5947 ;; For MIPS16, we don't know whether a given jump table will use short or
5948 ;; word-sized offsets until late in compilation, when we are able to determine
5949 ;; the sizes of the insns which comprise the containing function. This
5950 ;; necessitates the use of the casesi rather than the tablejump pattern, since
5951 ;; the latter tries to calculate the index of the offset to jump through early
5952 ;; in compilation, i.e. at expand time, when nothing is known about the
5953 ;; eventual function layout.
5955 (define_expand "casesi"
5956 [(match_operand:SI 0 "register_operand" "") ; index to jump on
5957 (match_operand:SI 1 "const_int_operand" "") ; lower bound
5958 (match_operand:SI 2 "const_int_operand" "") ; total range
5959 (match_operand 3 "" "") ; table label
5960 (match_operand 4 "" "")] ; out of range label
5961 "TARGET_MIPS16_SHORT_JUMP_TABLES"
5963 if (operands[1] != const0_rtx)
5965 rtx reg = gen_reg_rtx (SImode);
5966 rtx offset = gen_int_mode (-INTVAL (operands[1]), SImode);
5968 if (!arith_operand (offset, SImode))
5969 offset = force_reg (SImode, offset);
5971 emit_insn (gen_addsi3 (reg, operands[0], offset));
5975 if (!arith_operand (operands[0], SImode))
5976 operands[0] = force_reg (SImode, operands[0]);
5978 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
5980 emit_jump_insn (PMODE_INSN (gen_casesi_internal_mips16,
5981 (operands[0], operands[2],
5982 operands[3], operands[4])));
5987 (define_insn "casesi_internal_mips16_<mode>"
5990 (leu (match_operand:SI 0 "register_operand" "d")
5991 (match_operand:SI 1 "arith_operand" "dI"))
5994 (label_ref (match_operand 2 "" ""))]
5995 UNSPEC_CASESI_DISPATCH)
5996 (label_ref (match_operand 3 "" ""))))
5997 (clobber (match_scratch:P 4 "=d"))
5998 (clobber (match_scratch:P 5 "=d"))
5999 (clobber (reg:SI MIPS16_T_REGNUM))]
6000 "TARGET_MIPS16_SHORT_JUMP_TABLES"
6002 rtx diff_vec = PATTERN (next_real_insn (operands[2]));
6004 gcc_assert (GET_CODE (diff_vec) == ADDR_DIFF_VEC);
6006 output_asm_insn ("sltu\t%0, %1", operands);
6007 output_asm_insn ("bteqz\t%3", operands);
6009 switch (GET_MODE (diff_vec))
6012 output_asm_insn ("sll\t%5, %0, 1", operands);
6013 output_asm_insn ("la\t%4, %2", operands);
6014 output_asm_insn ("<d>addu\t%5, %4, %5", operands);
6015 output_asm_insn ("lh\t%5, 0(%5)", operands);
6019 output_asm_insn ("sll\t%5, %0, 2", operands);
6020 output_asm_insn ("la\t%4, %2", operands);
6021 output_asm_insn ("<d>addu\t%5, %4, %5", operands);
6022 output_asm_insn ("lw\t%5, 0(%5)", operands);
6029 output_asm_insn ("addu\t%4, %4, %5", operands);
6033 [(set_attr "length" "32")])
6035 ;; For TARGET_USE_GOT, we save the gp in the jmp_buf as well.
6036 ;; While it is possible to either pull it off the stack (in the
6037 ;; o32 case) or recalculate it given t9 and our target label,
6038 ;; it takes 3 or 4 insns to do so.
6040 (define_expand "builtin_setjmp_setup"
6041 [(use (match_operand 0 "register_operand"))]
6046 addr = plus_constant (Pmode, operands[0], GET_MODE_SIZE (Pmode) * 3);
6047 mips_emit_move (gen_rtx_MEM (Pmode, addr), pic_offset_table_rtx);
6051 ;; Restore the gp that we saved above. Despite the earlier comment, it seems
6052 ;; that older code did recalculate the gp from $25. Continue to jump through
6053 ;; $25 for compatibility (we lose nothing by doing so).
6055 (define_expand "builtin_longjmp"
6056 [(use (match_operand 0 "register_operand"))]
6059 /* The elements of the buffer are, in order: */
6060 int W = GET_MODE_SIZE (Pmode);
6061 rtx fp = gen_rtx_MEM (Pmode, operands[0]);
6062 rtx lab = gen_rtx_MEM (Pmode, plus_constant (Pmode, operands[0], 1*W));
6063 rtx stack = gen_rtx_MEM (Pmode, plus_constant (Pmode, operands[0], 2*W));
6064 rtx gpv = gen_rtx_MEM (Pmode, plus_constant (Pmode, operands[0], 3*W));
6065 rtx pv = gen_rtx_REG (Pmode, PIC_FUNCTION_ADDR_REGNUM);
6066 /* Use gen_raw_REG to avoid being given pic_offset_table_rtx.
6067 The target is bound to be using $28 as the global pointer
6068 but the current function might not be. */
6069 rtx gp = gen_raw_REG (Pmode, GLOBAL_POINTER_REGNUM);
6071 /* This bit is similar to expand_builtin_longjmp except that it
6072 restores $gp as well. */
6073 mips_emit_move (hard_frame_pointer_rtx, fp);
6074 mips_emit_move (pv, lab);
6075 emit_stack_restore (SAVE_NONLOCAL, stack);
6076 mips_emit_move (gp, gpv);
6077 emit_use (hard_frame_pointer_rtx);
6078 emit_use (stack_pointer_rtx);
6080 emit_indirect_jump (pv);
6085 ;; ....................
6087 ;; Function prologue/epilogue
6089 ;; ....................
6092 (define_expand "prologue"
6096 mips_expand_prologue ();
6100 ;; Block any insns from being moved before this point, since the
6101 ;; profiling call to mcount can use various registers that aren't
6102 ;; saved or used to pass arguments.
6104 (define_insn "blockage"
6105 [(unspec_volatile [(const_int 0)] UNSPEC_BLOCKAGE)]
6108 [(set_attr "type" "ghost")
6109 (set_attr "mode" "none")])
6111 (define_insn "probe_stack_range_<P:mode>"
6112 [(set (match_operand:P 0 "register_operand" "=d")
6113 (unspec_volatile:P [(match_operand:P 1 "register_operand" "0")
6114 (match_operand:P 2 "register_operand" "d")]
6115 UNSPEC_PROBE_STACK_RANGE))]
6117 { return mips_output_probe_stack_range (operands[0], operands[2]); }
6118 [(set_attr "type" "unknown")
6119 (set_attr "can_delay" "no")
6120 (set_attr "mode" "<MODE>")])
6122 (define_expand "epilogue"
6126 mips_expand_epilogue (false);
6130 (define_expand "sibcall_epilogue"
6134 mips_expand_epilogue (true);
6138 ;; Trivial return. Make it look like a normal return insn as that
6139 ;; allows jump optimizations to work better.
6141 (define_expand "return"
6143 "mips_can_use_return_insn ()"
6144 { mips_expand_before_return (); })
6146 (define_expand "simple_return"
6149 { mips_expand_before_return (); })
6151 (define_insn "*<optab>"
6155 [(set_attr "type" "jump")
6156 (set_attr "mode" "none")])
6160 (define_insn "<optab>_internal"
6162 (use (match_operand 0 "pmode_register_operand" ""))]
6165 [(set_attr "type" "jump")
6166 (set_attr "mode" "none")])
6168 ;; Exception return.
6169 (define_insn "mips_eret"
6171 (unspec_volatile [(const_int 0)] UNSPEC_ERET)]
6174 [(set_attr "type" "trap")
6175 (set_attr "mode" "none")])
6177 ;; Debug exception return.
6178 (define_insn "mips_deret"
6180 (unspec_volatile [(const_int 0)] UNSPEC_DERET)]
6183 [(set_attr "type" "trap")
6184 (set_attr "mode" "none")])
6186 ;; Disable interrupts.
6187 (define_insn "mips_di"
6188 [(unspec_volatile [(const_int 0)] UNSPEC_DI)]
6191 [(set_attr "type" "trap")
6192 (set_attr "mode" "none")])
6194 ;; Execution hazard barrier.
6195 (define_insn "mips_ehb"
6196 [(unspec_volatile [(const_int 0)] UNSPEC_EHB)]
6199 [(set_attr "type" "trap")
6200 (set_attr "mode" "none")])
6202 ;; Read GPR from previous shadow register set.
6203 (define_insn "mips_rdpgpr"
6204 [(set (match_operand:SI 0 "register_operand" "=d")
6205 (unspec_volatile:SI [(match_operand:SI 1 "register_operand" "d")]
6209 [(set_attr "type" "move")
6210 (set_attr "mode" "SI")])
6212 ;; Move involving COP0 registers.
6213 (define_insn "cop0_move"
6214 [(set (match_operand:SI 0 "register_operand" "=B,d")
6215 (unspec_volatile:SI [(match_operand:SI 1 "register_operand" "d,B")]
6218 { return mips_output_move (operands[0], operands[1]); }
6219 [(set_attr "type" "mtc,mfc")
6220 (set_attr "mode" "SI")])
6222 ;; This is used in compiling the unwind routines.
6223 (define_expand "eh_return"
6224 [(use (match_operand 0 "general_operand"))]
6227 if (GET_MODE (operands[0]) != word_mode)
6228 operands[0] = convert_to_mode (word_mode, operands[0], 0);
6230 emit_insn (gen_eh_set_lr_di (operands[0]));
6232 emit_insn (gen_eh_set_lr_si (operands[0]));
6236 ;; Clobber the return address on the stack. We can't expand this
6237 ;; until we know where it will be put in the stack frame.
6239 (define_insn "eh_set_lr_si"
6240 [(unspec [(match_operand:SI 0 "register_operand" "d")] UNSPEC_EH_RETURN)
6241 (clobber (match_scratch:SI 1 "=&d"))]
6245 (define_insn "eh_set_lr_di"
6246 [(unspec [(match_operand:DI 0 "register_operand" "d")] UNSPEC_EH_RETURN)
6247 (clobber (match_scratch:DI 1 "=&d"))]
6252 [(unspec [(match_operand 0 "register_operand")] UNSPEC_EH_RETURN)
6253 (clobber (match_scratch 1))]
6257 mips_set_return_address (operands[0], operands[1]);
6261 (define_expand "exception_receiver"
6265 /* See the comment above load_call<mode> for details. */
6266 emit_insn (gen_set_got_version ());
6268 /* If we have a call-clobbered $gp, restore it from its save slot. */
6269 if (HAVE_restore_gp_si)
6270 emit_insn (gen_restore_gp_si ());
6271 else if (HAVE_restore_gp_di)
6272 emit_insn (gen_restore_gp_di ());
6276 (define_expand "nonlocal_goto_receiver"
6280 /* See the comment above load_call<mode> for details. */
6281 emit_insn (gen_set_got_version ());
6285 ;; Restore $gp from its .cprestore stack slot. The instruction remains
6286 ;; volatile until all uses of $28 are exposed.
6287 (define_insn_and_split "restore_gp_<mode>"
6289 (unspec_volatile:P [(const_int 0)] UNSPEC_RESTORE_GP))
6290 (clobber (match_scratch:P 0 "=&d"))]
6291 "TARGET_CALL_CLOBBERED_GP"
6293 "&& epilogue_completed"
6296 mips_restore_gp_from_cprestore_slot (operands[0]);
6299 [(set_attr "type" "ghost")])
6301 ;; Move between $gp and its register save slot.
6302 (define_insn_and_split "move_gp<mode>"
6303 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,m")
6304 (unspec:GPR [(match_operand:GPR 1 "move_operand" "m,d")]
6307 { return mips_must_initialize_gp_p () ? "#" : ""; }
6308 "mips_must_initialize_gp_p ()"
6311 mips_emit_move (operands[0], operands[1]);
6314 [(set_attr "type" "ghost")])
6317 ;; ....................
6321 ;; ....................
6323 ;; Instructions to load a call address from the GOT. The address might
6324 ;; point to a function or to a lazy binding stub. In the latter case,
6325 ;; the stub will use the dynamic linker to resolve the function, which
6326 ;; in turn will change the GOT entry to point to the function's real
6329 ;; This means that every call, even pure and constant ones, can
6330 ;; potentially modify the GOT entry. And once a stub has been called,
6331 ;; we must not call it again.
6333 ;; We represent this restriction using an imaginary, fixed, call-saved
6334 ;; register called GOT_VERSION_REGNUM. The idea is to make the register
6335 ;; live throughout the function and to change its value after every
6336 ;; potential call site. This stops any rtx value that uses the register
6337 ;; from being computed before an earlier call. To do this, we:
6339 ;; - Ensure that the register is live on entry to the function,
6340 ;; so that it is never thought to be used uninitalized.
6342 ;; - Ensure that the register is live on exit from the function,
6343 ;; so that it is live throughout.
6345 ;; - Make each call (lazily-bound or not) use the current value
6346 ;; of GOT_VERSION_REGNUM, so that updates of the register are
6347 ;; not moved across call boundaries.
6349 ;; - Add "ghost" definitions of the register to the beginning of
6350 ;; blocks reached by EH and ABNORMAL_CALL edges, because those
6351 ;; edges may involve calls that normal paths don't. (E.g. the
6352 ;; unwinding code that handles a non-call exception may change
6353 ;; lazily-bound GOT entries.) We do this by making the
6354 ;; exception_receiver and nonlocal_goto_receiver expanders emit
6355 ;; a set_got_version instruction.
6357 ;; - After each call (lazily-bound or not), use a "ghost"
6358 ;; update_got_version instruction to change the register's value.
6359 ;; This instruction mimics the _possible_ effect of the dynamic
6360 ;; resolver during the call and it remains live even if the call
6361 ;; itself becomes dead.
6363 ;; - Leave GOT_VERSION_REGNUM out of all register classes.
6364 ;; The register is therefore not a valid register_operand
6365 ;; and cannot be moved to or from other registers.
6367 (define_insn "load_call<mode>"
6368 [(set (match_operand:P 0 "register_operand" "=d")
6369 (unspec:P [(match_operand:P 1 "register_operand" "d")
6370 (match_operand:P 2 "immediate_operand" "")
6371 (reg:SI GOT_VERSION_REGNUM)] UNSPEC_LOAD_CALL))]
6373 "<load>\t%0,%R2(%1)"
6374 [(set_attr "got" "load")
6375 (set_attr "mode" "<MODE>")])
6377 (define_insn "set_got_version"
6378 [(set (reg:SI GOT_VERSION_REGNUM)
6379 (unspec_volatile:SI [(const_int 0)] UNSPEC_SET_GOT_VERSION))]
6382 [(set_attr "type" "ghost")])
6384 (define_insn "update_got_version"
6385 [(set (reg:SI GOT_VERSION_REGNUM)
6386 (unspec:SI [(reg:SI GOT_VERSION_REGNUM)] UNSPEC_UPDATE_GOT_VERSION))]
6389 [(set_attr "type" "ghost")])
6391 ;; Sibling calls. All these patterns use jump instructions.
6393 ;; If TARGET_SIBCALLS, call_insn_operand will only accept constant
6394 ;; addresses if a direct jump is acceptable. Since the 'S' constraint
6395 ;; is defined in terms of call_insn_operand, the same is true of the
6398 ;; When we use an indirect jump, we need a register that will be
6399 ;; preserved by the epilogue. Since TARGET_USE_PIC_FN_ADDR_REG forces
6400 ;; us to use $25 for this purpose -- and $25 is never clobbered by the
6401 ;; epilogue -- we might as well use it for !TARGET_USE_PIC_FN_ADDR_REG
6404 (define_expand "sibcall"
6405 [(parallel [(call (match_operand 0 "")
6406 (match_operand 1 ""))
6407 (use (match_operand 2 "")) ;; next_arg_reg
6408 (use (match_operand 3 ""))])] ;; struct_value_size_rtx
6411 mips_expand_call (MIPS_CALL_SIBCALL, NULL_RTX, XEXP (operands[0], 0),
6412 operands[1], operands[2], false);
6416 (define_insn "sibcall_internal"
6417 [(call (mem:SI (match_operand 0 "call_insn_operand" "j,S"))
6418 (match_operand 1 "" ""))]
6419 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
6420 { return MIPS_CALL ("j", operands, 0, 1); }
6421 [(set_attr "jal" "indirect,direct")
6422 (set_attr "jal_macro" "no")])
6424 (define_expand "sibcall_value"
6425 [(parallel [(set (match_operand 0 "")
6426 (call (match_operand 1 "")
6427 (match_operand 2 "")))
6428 (use (match_operand 3 ""))])] ;; next_arg_reg
6431 mips_expand_call (MIPS_CALL_SIBCALL, operands[0], XEXP (operands[1], 0),
6432 operands[2], operands[3], false);
6436 (define_insn "sibcall_value_internal"
6437 [(set (match_operand 0 "register_operand" "")
6438 (call (mem:SI (match_operand 1 "call_insn_operand" "j,S"))
6439 (match_operand 2 "" "")))]
6440 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
6441 { return MIPS_CALL ("j", operands, 1, 2); }
6442 [(set_attr "jal" "indirect,direct")
6443 (set_attr "jal_macro" "no")])
6445 (define_insn "sibcall_value_multiple_internal"
6446 [(set (match_operand 0 "register_operand" "")
6447 (call (mem:SI (match_operand 1 "call_insn_operand" "j,S"))
6448 (match_operand 2 "" "")))
6449 (set (match_operand 3 "register_operand" "")
6450 (call (mem:SI (match_dup 1))
6452 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
6453 { return MIPS_CALL ("j", operands, 1, 2); }
6454 [(set_attr "jal" "indirect,direct")
6455 (set_attr "jal_macro" "no")])
6457 (define_expand "call"
6458 [(parallel [(call (match_operand 0 "")
6459 (match_operand 1 ""))
6460 (use (match_operand 2 "")) ;; next_arg_reg
6461 (use (match_operand 3 ""))])] ;; struct_value_size_rtx
6464 mips_expand_call (MIPS_CALL_NORMAL, NULL_RTX, XEXP (operands[0], 0),
6465 operands[1], operands[2], false);
6469 ;; This instruction directly corresponds to an assembly-language "jal".
6470 ;; There are four cases:
6473 ;; Both symbolic and register destinations are OK. The pattern
6474 ;; always expands to a single mips instruction.
6476 ;; - -mabicalls/-mno-explicit-relocs:
6477 ;; Again, both symbolic and register destinations are OK.
6478 ;; The call is treated as a multi-instruction black box.
6480 ;; - -mabicalls/-mexplicit-relocs with n32 or n64:
6481 ;; Only "jal $25" is allowed. This expands to a single "jalr $25"
6484 ;; - -mabicalls/-mexplicit-relocs with o32 or o64:
6485 ;; Only "jal $25" is allowed. The call is actually two instructions:
6486 ;; "jalr $25" followed by an insn to reload $gp.
6488 ;; In the last case, we can generate the individual instructions with
6489 ;; a define_split. There are several things to be wary of:
6491 ;; - We can't expose the load of $gp before reload. If we did,
6492 ;; it might get removed as dead, but reload can introduce new
6493 ;; uses of $gp by rematerializing constants.
6495 ;; - We shouldn't restore $gp after calls that never return.
6496 ;; It isn't valid to insert instructions between a noreturn
6497 ;; call and the following barrier.
6499 ;; - The splitter deliberately changes the liveness of $gp. The unsplit
6500 ;; instruction preserves $gp and so have no effect on its liveness.
6501 ;; But once we generate the separate insns, it becomes obvious that
6502 ;; $gp is not live on entry to the call.
6504 (define_insn_and_split "call_internal"
6505 [(call (mem:SI (match_operand 0 "call_insn_operand" "c,S"))
6506 (match_operand 1 "" ""))
6507 (clobber (reg:SI RETURN_ADDR_REGNUM))]
6509 { return TARGET_SPLIT_CALLS ? "#" : MIPS_CALL ("jal", operands, 0, 1); }
6510 "reload_completed && TARGET_SPLIT_CALLS"
6513 mips_split_call (curr_insn, gen_call_split (operands[0], operands[1]));
6516 [(set_attr "jal" "indirect,direct")])
6518 (define_insn "call_split"
6519 [(call (mem:SI (match_operand 0 "call_insn_operand" "c,S"))
6520 (match_operand 1 "" ""))
6521 (clobber (reg:SI RETURN_ADDR_REGNUM))
6522 (clobber (reg:SI 28))]
6523 "TARGET_SPLIT_CALLS"
6524 { return MIPS_CALL ("jal", operands, 0, 1); }
6525 [(set_attr "jal" "indirect,direct")
6526 (set_attr "jal_macro" "no")])
6528 ;; A pattern for calls that must be made directly. It is used for
6529 ;; MIPS16 calls that the linker may need to redirect to a hard-float
6530 ;; stub; the linker relies on the call relocation type to detect when
6531 ;; such redirection is needed.
6532 (define_insn_and_split "call_internal_direct"
6533 [(call (mem:SI (match_operand 0 "const_call_insn_operand"))
6536 (clobber (reg:SI RETURN_ADDR_REGNUM))]
6538 { return TARGET_SPLIT_CALLS ? "#" : MIPS_CALL ("jal", operands, 0, -1); }
6539 "reload_completed && TARGET_SPLIT_CALLS"
6542 mips_split_call (curr_insn,
6543 gen_call_direct_split (operands[0], operands[1]));
6546 [(set_attr "jal" "direct")])
6548 (define_insn "call_direct_split"
6549 [(call (mem:SI (match_operand 0 "const_call_insn_operand"))
6552 (clobber (reg:SI RETURN_ADDR_REGNUM))
6553 (clobber (reg:SI 28))]
6554 "TARGET_SPLIT_CALLS"
6555 { return MIPS_CALL ("jal", operands, 0, -1); }
6556 [(set_attr "jal" "direct")
6557 (set_attr "jal_macro" "no")])
6559 (define_expand "call_value"
6560 [(parallel [(set (match_operand 0 "")
6561 (call (match_operand 1 "")
6562 (match_operand 2 "")))
6563 (use (match_operand 3 ""))])] ;; next_arg_reg
6566 mips_expand_call (MIPS_CALL_NORMAL, operands[0], XEXP (operands[1], 0),
6567 operands[2], operands[3], false);
6571 ;; See comment for call_internal.
6572 (define_insn_and_split "call_value_internal"
6573 [(set (match_operand 0 "register_operand" "")
6574 (call (mem:SI (match_operand 1 "call_insn_operand" "c,S"))
6575 (match_operand 2 "" "")))
6576 (clobber (reg:SI RETURN_ADDR_REGNUM))]
6578 { return TARGET_SPLIT_CALLS ? "#" : MIPS_CALL ("jal", operands, 1, 2); }
6579 "reload_completed && TARGET_SPLIT_CALLS"
6582 mips_split_call (curr_insn,
6583 gen_call_value_split (operands[0], operands[1],
6587 [(set_attr "jal" "indirect,direct")])
6589 (define_insn "call_value_split"
6590 [(set (match_operand 0 "register_operand" "")
6591 (call (mem:SI (match_operand 1 "call_insn_operand" "c,S"))
6592 (match_operand 2 "" "")))
6593 (clobber (reg:SI RETURN_ADDR_REGNUM))
6594 (clobber (reg:SI 28))]
6595 "TARGET_SPLIT_CALLS"
6596 { return MIPS_CALL ("jal", operands, 1, 2); }
6597 [(set_attr "jal" "indirect,direct")
6598 (set_attr "jal_macro" "no")])
6600 ;; See call_internal_direct.
6601 (define_insn_and_split "call_value_internal_direct"
6602 [(set (match_operand 0 "register_operand")
6603 (call (mem:SI (match_operand 1 "const_call_insn_operand"))
6606 (clobber (reg:SI RETURN_ADDR_REGNUM))]
6608 { return TARGET_SPLIT_CALLS ? "#" : MIPS_CALL ("jal", operands, 1, -1); }
6609 "reload_completed && TARGET_SPLIT_CALLS"
6612 mips_split_call (curr_insn,
6613 gen_call_value_direct_split (operands[0], operands[1],
6617 [(set_attr "jal" "direct")])
6619 (define_insn "call_value_direct_split"
6620 [(set (match_operand 0 "register_operand")
6621 (call (mem:SI (match_operand 1 "const_call_insn_operand"))
6624 (clobber (reg:SI RETURN_ADDR_REGNUM))
6625 (clobber (reg:SI 28))]
6626 "TARGET_SPLIT_CALLS"
6627 { return MIPS_CALL ("jal", operands, 1, -1); }
6628 [(set_attr "jal" "direct")
6629 (set_attr "jal_macro" "no")])
6631 ;; See comment for call_internal.
6632 (define_insn_and_split "call_value_multiple_internal"
6633 [(set (match_operand 0 "register_operand" "")
6634 (call (mem:SI (match_operand 1 "call_insn_operand" "c,S"))
6635 (match_operand 2 "" "")))
6636 (set (match_operand 3 "register_operand" "")
6637 (call (mem:SI (match_dup 1))
6639 (clobber (reg:SI RETURN_ADDR_REGNUM))]
6641 { return TARGET_SPLIT_CALLS ? "#" : MIPS_CALL ("jal", operands, 1, 2); }
6642 "reload_completed && TARGET_SPLIT_CALLS"
6645 mips_split_call (curr_insn,
6646 gen_call_value_multiple_split (operands[0], operands[1],
6647 operands[2], operands[3]));
6650 [(set_attr "jal" "indirect,direct")])
6652 (define_insn "call_value_multiple_split"
6653 [(set (match_operand 0 "register_operand" "")
6654 (call (mem:SI (match_operand 1 "call_insn_operand" "c,S"))
6655 (match_operand 2 "" "")))
6656 (set (match_operand 3 "register_operand" "")
6657 (call (mem:SI (match_dup 1))
6659 (clobber (reg:SI RETURN_ADDR_REGNUM))
6660 (clobber (reg:SI 28))]
6661 "TARGET_SPLIT_CALLS"
6662 { return MIPS_CALL ("jal", operands, 1, 2); }
6663 [(set_attr "jal" "indirect,direct")
6664 (set_attr "jal_macro" "no")])
6666 ;; Call subroutine returning any type.
6668 (define_expand "untyped_call"
6669 [(parallel [(call (match_operand 0 "")
6671 (match_operand 1 "")
6672 (match_operand 2 "")])]
6677 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
6679 for (i = 0; i < XVECLEN (operands[2], 0); i++)
6681 rtx set = XVECEXP (operands[2], 0, i);
6682 mips_emit_move (SET_DEST (set), SET_SRC (set));
6685 emit_insn (gen_blockage ());
6690 ;; ....................
6694 ;; ....................
6698 (define_insn "prefetch"
6699 [(prefetch (match_operand:QI 0 "address_operand" "p")
6700 (match_operand 1 "const_int_operand" "n")
6701 (match_operand 2 "const_int_operand" "n"))]
6702 "ISA_HAS_PREFETCH && TARGET_EXPLICIT_RELOCS"
6704 if (TARGET_LOONGSON_2EF || TARGET_LOONGSON_3A)
6705 /* Loongson 2[ef] and Loongson 3a use load to $0 to perform prefetching. */
6706 return "ld\t$0,%a0";
6707 operands[1] = mips_prefetch_cookie (operands[1], operands[2]);
6708 return "pref\t%1,%a0";
6710 [(set_attr "type" "prefetch")])
6712 (define_insn "*prefetch_indexed_<mode>"
6713 [(prefetch (plus:P (match_operand:P 0 "register_operand" "d")
6714 (match_operand:P 1 "register_operand" "d"))
6715 (match_operand 2 "const_int_operand" "n")
6716 (match_operand 3 "const_int_operand" "n"))]
6717 "ISA_HAS_PREFETCHX && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
6719 operands[2] = mips_prefetch_cookie (operands[2], operands[3]);
6720 return "prefx\t%2,%1(%0)";
6722 [(set_attr "type" "prefetchx")])
6728 [(set_attr "type" "nop")
6729 (set_attr "mode" "none")])
6731 ;; Like nop, but commented out when outside a .set noreorder block.
6732 (define_insn "hazard_nop"
6736 if (mips_noreorder.nesting_level > 0)
6741 [(set_attr "type" "nop")])
6743 ;; MIPS4 Conditional move instructions.
6745 (define_insn "*mov<GPR:mode>_on_<MOVECC:mode>"
6746 [(set (match_operand:GPR 0 "register_operand" "=d,d")
6748 (match_operator:MOVECC 4 "equality_operator"
6749 [(match_operand:MOVECC 1 "register_operand" "<MOVECC:reg>,<MOVECC:reg>")
6751 (match_operand:GPR 2 "reg_or_0_operand" "dJ,0")
6752 (match_operand:GPR 3 "reg_or_0_operand" "0,dJ")))]
6757 [(set_attr "type" "condmove")
6758 (set_attr "mode" "<GPR:MODE>")])
6760 (define_insn "*mov<SCALARF:mode>_on_<MOVECC:mode>"
6761 [(set (match_operand:SCALARF 0 "register_operand" "=f,f")
6762 (if_then_else:SCALARF
6763 (match_operator:MOVECC 4 "equality_operator"
6764 [(match_operand:MOVECC 1 "register_operand" "<MOVECC:reg>,<MOVECC:reg>")
6766 (match_operand:SCALARF 2 "register_operand" "f,0")
6767 (match_operand:SCALARF 3 "register_operand" "0,f")))]
6768 "ISA_HAS_FP_CONDMOVE"
6770 mov%T4.<fmt>\t%0,%2,%1
6771 mov%t4.<fmt>\t%0,%3,%1"
6772 [(set_attr "type" "condmove")
6773 (set_attr "mode" "<SCALARF:MODE>")])
6775 ;; These are the main define_expand's used to make conditional moves.
6777 (define_expand "mov<mode>cc"
6778 [(set (match_dup 4) (match_operand 1 "comparison_operator"))
6779 (set (match_operand:GPR 0 "register_operand")
6780 (if_then_else:GPR (match_dup 5)
6781 (match_operand:GPR 2 "reg_or_0_operand")
6782 (match_operand:GPR 3 "reg_or_0_operand")))]
6785 mips_expand_conditional_move (operands);
6789 (define_expand "mov<mode>cc"
6790 [(set (match_dup 4) (match_operand 1 "comparison_operator"))
6791 (set (match_operand:SCALARF 0 "register_operand")
6792 (if_then_else:SCALARF (match_dup 5)
6793 (match_operand:SCALARF 2 "register_operand")
6794 (match_operand:SCALARF 3 "register_operand")))]
6795 "ISA_HAS_FP_CONDMOVE"
6797 mips_expand_conditional_move (operands);
6802 ;; ....................
6804 ;; mips16 inline constant tables
6806 ;; ....................
6809 (define_insn "consttable_tls_reloc"
6810 [(unspec_volatile [(match_operand 0 "tls_reloc_operand" "")
6811 (match_operand 1 "const_int_operand" "")]
6812 UNSPEC_CONSTTABLE_INT)]
6813 "TARGET_MIPS16_PCREL_LOADS"
6814 { return mips_output_tls_reloc_directive (&operands[0]); }
6815 [(set (attr "length") (symbol_ref "INTVAL (operands[1])"))])
6817 (define_insn "consttable_int"
6818 [(unspec_volatile [(match_operand 0 "consttable_operand" "")
6819 (match_operand 1 "const_int_operand" "")]
6820 UNSPEC_CONSTTABLE_INT)]
6823 assemble_integer (mips_strip_unspec_address (operands[0]),
6824 INTVAL (operands[1]),
6825 BITS_PER_UNIT * INTVAL (operands[1]), 1);
6828 [(set (attr "length") (symbol_ref "INTVAL (operands[1])"))])
6830 (define_insn "consttable_float"
6831 [(unspec_volatile [(match_operand 0 "consttable_operand" "")]
6832 UNSPEC_CONSTTABLE_FLOAT)]
6837 gcc_assert (GET_CODE (operands[0]) == CONST_DOUBLE);
6838 REAL_VALUE_FROM_CONST_DOUBLE (d, operands[0]);
6839 assemble_real (d, GET_MODE (operands[0]),
6840 GET_MODE_BITSIZE (GET_MODE (operands[0])));
6843 [(set (attr "length")
6844 (symbol_ref "GET_MODE_SIZE (GET_MODE (operands[0]))"))])
6846 (define_insn "align"
6847 [(unspec_volatile [(match_operand 0 "const_int_operand" "")] UNSPEC_ALIGN)]
6850 [(set (attr "length") (symbol_ref "(1 << INTVAL (operands[0])) - 1"))])
6853 [(match_operand 0 "small_data_pattern")]
6856 { operands[0] = mips_rewrite_small_data (operands[0]); })
6859 ;; ....................
6861 ;; MIPS16e Save/Restore
6863 ;; ....................
6866 (define_insn "*mips16e_save_restore"
6867 [(match_parallel 0 ""
6868 [(set (match_operand:SI 1 "register_operand")
6869 (plus:SI (match_dup 1)
6870 (match_operand:SI 2 "const_int_operand")))])]
6871 "operands[1] == stack_pointer_rtx
6872 && mips16e_save_restore_pattern_p (operands[0], INTVAL (operands[2]), NULL)"
6873 { return mips16e_output_save_restore (operands[0], INTVAL (operands[2])); }
6874 [(set_attr "type" "arith")
6875 (set_attr "extended_mips16" "yes")])
6877 ;; Thread-Local Storage
6879 ;; The TLS base pointer is accessed via "rdhwr $3, $29". No current
6880 ;; MIPS architecture defines this register, and no current
6881 ;; implementation provides it; instead, any OS which supports TLS is
6882 ;; expected to trap and emulate this instruction. rdhwr is part of the
6883 ;; MIPS 32r2 specification, but we use it on any architecture because
6884 ;; we expect it to be emulated. Use .set to force the assembler to
6887 ;; We do not use a constraint to force the destination to be $3
6888 ;; because $3 can appear explicitly as a function return value.
6889 ;; If we leave the use of $3 implicit in the constraints until
6890 ;; reload, we may end up making a $3 return value live across
6891 ;; the instruction, leading to a spill failure when reloading it.
6892 (define_insn_and_split "tls_get_tp_<mode>"
6893 [(set (match_operand:P 0 "register_operand" "=d")
6894 (unspec:P [(const_int 0)] UNSPEC_TLS_GET_TP))
6895 (clobber (reg:P TLS_GET_TP_REGNUM))]
6896 "HAVE_AS_TLS && !TARGET_MIPS16"
6898 "&& reload_completed"
6899 [(set (reg:P TLS_GET_TP_REGNUM)
6900 (unspec:P [(const_int 0)] UNSPEC_TLS_GET_TP))
6901 (set (match_dup 0) (reg:P TLS_GET_TP_REGNUM))]
6903 [(set_attr "type" "unknown")
6904 ; Since rdhwr always generates a trap for now, putting it in a delay
6905 ; slot would make the kernel's emulation of it much slower.
6906 (set_attr "can_delay" "no")
6907 (set_attr "mode" "<MODE>")
6908 (set_attr "length" "8")])
6910 (define_insn "*tls_get_tp_<mode>_split"
6911 [(set (reg:P TLS_GET_TP_REGNUM)
6912 (unspec:P [(const_int 0)] UNSPEC_TLS_GET_TP))]
6913 "HAVE_AS_TLS && !TARGET_MIPS16"
6914 ".set\tpush\;.set\tmips32r2\t\;rdhwr\t$3,$29\;.set\tpop"
6915 [(set_attr "type" "unknown")
6916 ; See tls_get_tp_<mode>
6917 (set_attr "can_delay" "no")
6918 (set_attr "mode" "<MODE>")])
6920 ;; In MIPS16 mode, the TLS base pointer is accessed by a
6921 ;; libgcc helper function __mips16_rdhwr(), as 'rdhwr' is not
6922 ;; accessible in MIPS16.
6924 ;; This is not represented as a call insn, to avoid the
6925 ;; unnecesarry clobbering of caller-save registers by a
6926 ;; function consisting only of: "rdhwr $3,$29; j $31; nop;"
6928 ;; A $25 clobber is added to cater for a $25 load stub added by the
6929 ;; linker to __mips16_rdhwr when the call is made from non-PIC code.
6931 (define_insn_and_split "tls_get_tp_mips16_<mode>"
6932 [(set (match_operand:P 0 "register_operand" "=d")
6933 (unspec:P [(match_operand:P 1 "call_insn_operand" "dS")]
6935 (clobber (reg:P TLS_GET_TP_REGNUM))
6936 (clobber (reg:P PIC_FUNCTION_ADDR_REGNUM))
6937 (clobber (reg:P RETURN_ADDR_REGNUM))]
6938 "HAVE_AS_TLS && TARGET_MIPS16"
6940 "&& reload_completed"
6941 [(parallel [(set (reg:P TLS_GET_TP_REGNUM)
6942 (unspec:P [(match_dup 1)] UNSPEC_TLS_GET_TP))
6943 (clobber (reg:P PIC_FUNCTION_ADDR_REGNUM))
6944 (clobber (reg:P RETURN_ADDR_REGNUM))])
6945 (set (match_dup 0) (reg:P TLS_GET_TP_REGNUM))]
6947 [(set_attr "type" "multi")
6948 (set_attr "length" "16")
6949 (set_attr "mode" "<MODE>")])
6951 (define_insn "*tls_get_tp_mips16_call_<mode>"
6952 [(set (reg:P TLS_GET_TP_REGNUM)
6953 (unspec:P [(match_operand:P 0 "call_insn_operand" "dS")]
6955 (clobber (reg:P PIC_FUNCTION_ADDR_REGNUM))
6956 (clobber (reg:P RETURN_ADDR_REGNUM))]
6957 "HAVE_AS_TLS && TARGET_MIPS16"
6958 { return MIPS_CALL ("jal", operands, 0, -1); }
6959 [(set_attr "type" "call")
6960 (set_attr "length" "12")
6961 (set_attr "mode" "<MODE>")])
6963 ;; Named pattern for expanding thread pointer reference.
6964 (define_expand "get_thread_pointer<mode>"
6965 [(match_operand:P 0 "register_operand" "=d")]
6968 mips_expand_thread_pointer (operands[0]);
6973 ;; Synchronization instructions.
6977 ; The MIPS Paired-Single Floating Point and MIPS-3D Instructions.
6979 (include "mips-ps-3d.md")
6981 ; The MIPS DSP Instructions.
6983 (include "mips-dsp.md")
6985 ; The MIPS DSP REV 2 Instructions.
6987 (include "mips-dspr2.md")
6989 ; MIPS fixed-point instructions.
6990 (include "mips-fixed.md")
6992 ; ST-Microelectronics Loongson-2E/2F-specific patterns.
6993 (include "loongson.md")
6995 (define_c_enum "unspec" [
6996 UNSPEC_ADDRESS_FIRST