1 ;; Mips.md Machine Description for MIPS based processors
2 ;; Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 ;; 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
4 ;; Free Software Foundation, Inc.
5 ;; Contributed by A. Lichnewsky, lich@inria.inria.fr
6 ;; Changes by Michael Meissner, meissner@osf.org
7 ;; 64-bit r4000 support by Ian Lance Taylor, ian@cygnus.com, and
8 ;; Brendan Eich, brendan@microunity.com.
10 ;; This file is part of GCC.
12 ;; GCC is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 3, or (at your option)
17 ;; GCC is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GCC; see the file COPYING3. If not see
24 ;; <http://www.gnu.org/licenses/>.
33 (UNSPEC_EH_RECEIVER 6)
35 (UNSPEC_CONSTTABLE_INT 8)
36 (UNSPEC_CONSTTABLE_FLOAT 9)
40 (UNSPEC_LOAD_RIGHT 19)
41 (UNSPEC_STORE_LEFT 20)
42 (UNSPEC_STORE_RIGHT 21)
49 (UNSPEC_TLS_GET_TP 28)
52 (UNSPEC_CLEAR_HAZARD 33)
56 (UNSPEC_COMPARE_AND_SWAP 37)
57 (UNSPEC_SYNC_OLD_OP 38)
58 (UNSPEC_SYNC_NEW_OP 39)
59 (UNSPEC_SYNC_EXCHANGE 40)
60 (UNSPEC_MEMORY_BARRIER 41)
62 (UNSPEC_ADDRESS_FIRST 100)
66 ;; For MIPS Paired-Singled Floating Point Instructions.
68 (UNSPEC_MOVE_TF_PS 200)
71 ;; MIPS64/MIPS32R2 alnv.ps
74 ;; MIPS-3D instructions
78 (UNSPEC_CVT_PW_PS 205)
79 (UNSPEC_CVT_PS_PW 206)
87 (UNSPEC_SINGLE_CC 213)
90 ;; MIPS DSP ASE Revision 0.98 3/24/2005
98 (UNSPEC_RADDU_W_QB 307)
100 (UNSPEC_PRECRQ_QB_PH 309)
101 (UNSPEC_PRECRQ_PH_W 310)
102 (UNSPEC_PRECRQ_RS_PH_W 311)
103 (UNSPEC_PRECRQU_S_QB_PH 312)
104 (UNSPEC_PRECEQ_W_PHL 313)
105 (UNSPEC_PRECEQ_W_PHR 314)
106 (UNSPEC_PRECEQU_PH_QBL 315)
107 (UNSPEC_PRECEQU_PH_QBR 316)
108 (UNSPEC_PRECEQU_PH_QBLA 317)
109 (UNSPEC_PRECEQU_PH_QBRA 318)
110 (UNSPEC_PRECEU_PH_QBL 319)
111 (UNSPEC_PRECEU_PH_QBR 320)
112 (UNSPEC_PRECEU_PH_QBLA 321)
113 (UNSPEC_PRECEU_PH_QBRA 322)
119 (UNSPEC_MULEU_S_PH_QBL 328)
120 (UNSPEC_MULEU_S_PH_QBR 329)
121 (UNSPEC_MULQ_RS_PH 330)
122 (UNSPEC_MULEQ_S_W_PHL 331)
123 (UNSPEC_MULEQ_S_W_PHR 332)
124 (UNSPEC_DPAU_H_QBL 333)
125 (UNSPEC_DPAU_H_QBR 334)
126 (UNSPEC_DPSU_H_QBL 335)
127 (UNSPEC_DPSU_H_QBR 336)
128 (UNSPEC_DPAQ_S_W_PH 337)
129 (UNSPEC_DPSQ_S_W_PH 338)
130 (UNSPEC_MULSAQ_S_W_PH 339)
131 (UNSPEC_DPAQ_SA_L_W 340)
132 (UNSPEC_DPSQ_SA_L_W 341)
133 (UNSPEC_MAQ_S_W_PHL 342)
134 (UNSPEC_MAQ_S_W_PHR 343)
135 (UNSPEC_MAQ_SA_W_PHL 344)
136 (UNSPEC_MAQ_SA_W_PHR 345)
144 (UNSPEC_CMPGU_EQ_QB 353)
145 (UNSPEC_CMPGU_LT_QB 354)
146 (UNSPEC_CMPGU_LE_QB 355)
148 (UNSPEC_PACKRL_PH 357)
150 (UNSPEC_EXTR_R_W 359)
151 (UNSPEC_EXTR_RS_W 360)
152 (UNSPEC_EXTR_S_H 361)
160 ;; MIPS DSP ASE REV 2 Revision 0.02 11/24/2006
161 (UNSPEC_ABSQ_S_QB 400)
163 (UNSPEC_ADDU_S_PH 402)
164 (UNSPEC_ADDUH_QB 403)
165 (UNSPEC_ADDUH_R_QB 404)
168 (UNSPEC_CMPGDU_EQ_QB 407)
169 (UNSPEC_CMPGDU_LT_QB 408)
170 (UNSPEC_CMPGDU_LE_QB 409)
171 (UNSPEC_DPA_W_PH 410)
172 (UNSPEC_DPS_W_PH 411)
178 (UNSPEC_MUL_S_PH 417)
179 (UNSPEC_MULQ_RS_W 418)
180 (UNSPEC_MULQ_S_PH 419)
181 (UNSPEC_MULQ_S_W 420)
182 (UNSPEC_MULSA_W_PH 421)
185 (UNSPEC_PRECR_QB_PH 424)
186 (UNSPEC_PRECR_SRA_PH_W 425)
187 (UNSPEC_PRECR_SRA_R_PH_W 426)
190 (UNSPEC_SHRA_R_QB 429)
193 (UNSPEC_SUBU_S_PH 432)
194 (UNSPEC_SUBUH_QB 433)
195 (UNSPEC_SUBUH_R_QB 434)
196 (UNSPEC_ADDQH_PH 435)
197 (UNSPEC_ADDQH_R_PH 436)
199 (UNSPEC_ADDQH_R_W 438)
200 (UNSPEC_SUBQH_PH 439)
201 (UNSPEC_SUBQH_R_PH 440)
203 (UNSPEC_SUBQH_R_W 442)
204 (UNSPEC_DPAX_W_PH 443)
205 (UNSPEC_DPSX_W_PH 444)
206 (UNSPEC_DPAQX_S_W_PH 445)
207 (UNSPEC_DPAQX_SA_W_PH 446)
208 (UNSPEC_DPSQX_S_W_PH 447)
209 (UNSPEC_DPSQX_SA_W_PH 448)
213 (include "predicates.md")
214 (include "constraints.md")
216 ;; ....................
220 ;; ....................
222 (define_attr "got" "unset,xgot_high,load"
223 (const_string "unset"))
225 ;; For jal instructions, this attribute is DIRECT when the target address
226 ;; is symbolic and INDIRECT when it is a register.
227 (define_attr "jal" "unset,direct,indirect"
228 (const_string "unset"))
230 ;; This attribute is YES if the instruction is a jal macro (not a
231 ;; real jal instruction).
233 ;; jal is always a macro for TARGET_CALL_CLOBBERED_GP because it includes
234 ;; an instruction to restore $gp. Direct jals are also macros for
235 ;; flag_pic && !TARGET_ABSOLUTE_ABICALLS because they first load
236 ;; the target address into a register.
237 (define_attr "jal_macro" "no,yes"
238 (cond [(eq_attr "jal" "direct")
239 (symbol_ref "TARGET_CALL_CLOBBERED_GP
240 || (flag_pic && !TARGET_ABSOLUTE_ABICALLS)")
241 (eq_attr "jal" "indirect")
242 (symbol_ref "TARGET_CALL_CLOBBERED_GP")]
243 (const_string "no")))
245 ;; Classification of each insn.
246 ;; branch conditional branch
247 ;; jump unconditional jump
248 ;; call unconditional call
249 ;; load load instruction(s)
250 ;; fpload floating point load
251 ;; fpidxload floating point indexed load
252 ;; store store instruction(s)
253 ;; fpstore floating point store
254 ;; fpidxstore floating point indexed store
255 ;; prefetch memory prefetch (register + offset)
256 ;; prefetchx memory indexed prefetch (register + register)
257 ;; condmove conditional moves
258 ;; mfc transfer from coprocessor
259 ;; mtc transfer to coprocessor
260 ;; mthilo transfer to hi/lo registers
261 ;; mfhilo transfer from hi/lo registers
262 ;; const load constant
263 ;; arith integer arithmetic instructions
264 ;; logical integer logical instructions
265 ;; shift integer shift instructions
266 ;; slt set less than instructions
267 ;; signext sign extend instructions
268 ;; clz the clz and clo instructions
269 ;; trap trap if instructions
270 ;; imul integer multiply 2 operands
271 ;; imul3 integer multiply 3 operands
272 ;; imadd integer multiply-add
273 ;; idiv integer divide
274 ;; move integer register move ({,D}ADD{,U} with rt = 0)
275 ;; fmove floating point register move
276 ;; fadd floating point add/subtract
277 ;; fmul floating point multiply
278 ;; fmadd floating point multiply-add
279 ;; fdiv floating point divide
280 ;; frdiv floating point reciprocal divide
281 ;; frdiv1 floating point reciprocal divide step 1
282 ;; frdiv2 floating point reciprocal divide step 2
283 ;; fabs floating point absolute value
284 ;; fneg floating point negation
285 ;; fcmp floating point compare
286 ;; fcvt floating point convert
287 ;; fsqrt floating point square root
288 ;; frsqrt floating point reciprocal square root
289 ;; frsqrt1 floating point reciprocal square root step1
290 ;; frsqrt2 floating point reciprocal square root step2
291 ;; multi multiword sequence (or user asm statements)
294 "unknown,branch,jump,call,load,fpload,fpidxload,store,fpstore,fpidxstore,prefetch,prefetchx,condmove,mfc,mtc,mthilo,mfhilo,const,arith,logical,shift,slt,signext,clz,trap,imul,imul3,imadd,idiv,move,fmove,fadd,fmul,fmadd,fdiv,frdiv,frdiv1,frdiv2,fabs,fneg,fcmp,fcvt,fsqrt,frsqrt,frsqrt1,frsqrt2,multi,nop"
295 (cond [(eq_attr "jal" "!unset") (const_string "call")
296 (eq_attr "got" "load") (const_string "load")]
297 (const_string "unknown")))
299 ;; Main data type used by the insn
300 (define_attr "mode" "unknown,none,QI,HI,SI,DI,SF,DF,FPSW"
301 (const_string "unknown"))
303 ;; Mode for conversion types (fcvt)
304 ;; I2S integer to float single (SI/DI to SF)
305 ;; I2D integer to float double (SI/DI to DF)
306 ;; S2I float to integer (SF to SI/DI)
307 ;; D2I float to integer (DF to SI/DI)
308 ;; D2S double to float single
309 ;; S2D float single to double
311 (define_attr "cnv_mode" "unknown,I2S,I2D,S2I,D2I,D2S,S2D"
312 (const_string "unknown"))
314 ;; Is this an extended instruction in mips16 mode?
315 (define_attr "extended_mips16" "no,yes"
318 ;; Length of instruction in bytes.
319 (define_attr "length" ""
320 (cond [;; Direct branch instructions have a range of [-0x40000,0x3fffc].
321 ;; If a branch is outside this range, we have a choice of two
322 ;; sequences. For PIC, an out-of-range branch like:
327 ;; becomes the equivalent of:
336 ;; where the load address can be up to three instructions long
339 ;; The non-PIC case is similar except that we use a direct
340 ;; jump instead of an la/jr pair. Since the target of this
341 ;; jump is an absolute 28-bit bit address (the other bits
342 ;; coming from the address of the delay slot) this form cannot
343 ;; cross a 256MB boundary. We could provide the option of
344 ;; using la/jr in this case too, but we do not do so at
347 ;; Note that this value does not account for the delay slot
348 ;; instruction, whose length is added separately. If the RTL
349 ;; pattern has no explicit delay slot, mips_adjust_insn_length
350 ;; will add the length of the implicit nop. The values for
351 ;; forward and backward branches will be different as well.
352 (eq_attr "type" "branch")
353 (cond [(and (le (minus (match_dup 1) (pc)) (const_int 131064))
354 (le (minus (pc) (match_dup 1)) (const_int 131068)))
356 (ne (symbol_ref "flag_pic") (const_int 0))
360 (eq_attr "got" "load")
362 (eq_attr "got" "xgot_high")
365 (eq_attr "type" "const")
366 (symbol_ref "mips_const_insns (operands[1]) * 4")
367 (eq_attr "type" "load,fpload")
368 (symbol_ref "mips_load_store_insns (operands[1], insn) * 4")
369 (eq_attr "type" "store,fpstore")
370 (symbol_ref "mips_load_store_insns (operands[0], insn) * 4")
372 ;; In the worst case, a call macro will take 8 instructions:
374 ;; lui $25,%call_hi(FOO)
376 ;; lw $25,%call_lo(FOO)($25)
382 (eq_attr "jal_macro" "yes")
385 (and (eq_attr "extended_mips16" "yes")
386 (ne (symbol_ref "TARGET_MIPS16") (const_int 0)))
389 ;; Various VR4120 errata require a nop to be inserted after a macc
390 ;; instruction. The assembler does this for us, so account for
391 ;; the worst-case length here.
392 (and (eq_attr "type" "imadd")
393 (ne (symbol_ref "TARGET_FIX_VR4120") (const_int 0)))
396 ;; VR4120 errata MD(4): if there are consecutive dmult instructions,
397 ;; the result of the second one is missed. The assembler should work
398 ;; around this by inserting a nop after the first dmult.
399 (and (eq_attr "type" "imul,imul3")
400 (and (eq_attr "mode" "DI")
401 (ne (symbol_ref "TARGET_FIX_VR4120") (const_int 0))))
404 (eq_attr "type" "idiv")
405 (symbol_ref "mips_idiv_insns () * 4")
408 ;; Attribute describing the processor. This attribute must match exactly
409 ;; with the processor_type enumeration in mips.h.
411 "r3000,4kc,4kp,5kc,5kf,20kc,24kc,24kf2_1,24kf1_1,74kc,74kf2_1,74kf1_1,74kf3_2,m4k,r3900,r6000,r4000,r4100,r4111,r4120,r4130,r4300,r4600,r4650,r5000,r5400,r5500,r7000,r8000,r9000,sb1,sb1a,sr71000"
412 (const (symbol_ref "mips_tune")))
414 ;; The type of hardware hazard associated with this instruction.
415 ;; DELAY means that the next instruction cannot read the result
416 ;; of this one. HILO means that the next two instructions cannot
417 ;; write to HI or LO.
418 (define_attr "hazard" "none,delay,hilo"
419 (cond [(and (eq_attr "type" "load,fpload,fpidxload")
420 (ne (symbol_ref "ISA_HAS_LOAD_DELAY") (const_int 0)))
421 (const_string "delay")
423 (and (eq_attr "type" "mfc,mtc")
424 (ne (symbol_ref "ISA_HAS_XFER_DELAY") (const_int 0)))
425 (const_string "delay")
427 (and (eq_attr "type" "fcmp")
428 (ne (symbol_ref "ISA_HAS_FCMP_DELAY") (const_int 0)))
429 (const_string "delay")
431 ;; The r4000 multiplication patterns include an mflo instruction.
432 (and (eq_attr "type" "imul")
433 (ne (symbol_ref "TARGET_FIX_R4000") (const_int 0)))
434 (const_string "hilo")
436 (and (eq_attr "type" "mfhilo")
437 (eq (symbol_ref "ISA_HAS_HILO_INTERLOCKS") (const_int 0)))
438 (const_string "hilo")]
439 (const_string "none")))
441 ;; Indicates which SET in an instruction pattern induces a hazard.
442 ;; Only meaningful when "hazard" is not "none". SINGLE means that
443 ;; the pattern has only one set while the other values are indexes
444 ;; into a PARALLEL vector.
446 ;; Hazardous instructions with multiple sets should generally put the
447 ;; hazardous set first. The only purpose of this attribute is to force
448 ;; each multi-set pattern to explicitly assert that this condition holds.
449 (define_attr "hazard_set" "single,0"
450 (const_string "single"))
452 ;; Is it a single instruction?
453 (define_attr "single_insn" "no,yes"
454 (symbol_ref "get_attr_length (insn) == (TARGET_MIPS16 ? 2 : 4)"))
456 ;; Can the instruction be put into a delay slot?
457 (define_attr "can_delay" "no,yes"
458 (if_then_else (and (eq_attr "type" "!branch,call,jump")
459 (and (eq_attr "hazard" "none")
460 (eq_attr "single_insn" "yes")))
462 (const_string "no")))
464 ;; Attribute defining whether or not we can use the branch-likely instructions
465 (define_attr "branch_likely" "no,yes"
467 (if_then_else (ne (symbol_ref "GENERATE_BRANCHLIKELY") (const_int 0))
469 (const_string "no"))))
471 ;; True if an instruction might assign to hi or lo when reloaded.
472 ;; This is used by the TUNE_MACC_CHAINS code.
473 (define_attr "may_clobber_hilo" "no,yes"
474 (if_then_else (eq_attr "type" "imul,imul3,imadd,idiv,mthilo")
476 (const_string "no")))
478 ;; Describe a user's asm statement.
479 (define_asm_attributes
480 [(set_attr "type" "multi")
481 (set_attr "can_delay" "no")])
483 ;; This mode iterator allows 32-bit and 64-bit GPR patterns to be generated
484 ;; from the same template.
485 (define_mode_iterator GPR [SI (DI "TARGET_64BIT")])
487 ;; This mode iterator allows :P to be used for patterns that operate on
488 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
489 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
491 ;; This mode iterator allows :MOVECC to be used anywhere that a
492 ;; conditional-move-type condition is needed.
493 (define_mode_iterator MOVECC [SI (DI "TARGET_64BIT") (CC "TARGET_HARD_FLOAT")])
495 ;; 64-bit modes for which we provide move patterns.
496 (define_mode_iterator MOVE64
497 [DI DF (V2SF "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT")])
499 ;; This mode iterator allows the QI and HI extension patterns to be
500 ;; defined from the same template.
501 (define_mode_iterator SHORT [QI HI])
503 ;; Likewise the 64-bit truncate-and-shift patterns.
504 (define_mode_iterator SUBDI [QI HI SI])
506 ;; This mode iterator allows :ANYF to be used wherever a scalar or vector
507 ;; floating-point mode is allowed.
508 (define_mode_iterator ANYF [(SF "TARGET_HARD_FLOAT")
509 (DF "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT")
510 (V2SF "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT")])
512 ;; Like ANYF, but only applies to scalar modes.
513 (define_mode_iterator SCALARF [(SF "TARGET_HARD_FLOAT")
514 (DF "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT")])
516 ;; A floating-point mode for which moves involving FPRs may need to be split.
517 (define_mode_iterator SPLITF
518 [(DF "!TARGET_64BIT && TARGET_DOUBLE_FLOAT")
519 (DI "!TARGET_64BIT && TARGET_DOUBLE_FLOAT")
520 (V2SF "!TARGET_64BIT && TARGET_PAIRED_SINGLE_FLOAT")
521 (TF "TARGET_64BIT && TARGET_FLOAT64")])
523 ;; In GPR templates, a string like "<d>subu" will expand to "subu" in the
524 ;; 32-bit version and "dsubu" in the 64-bit version.
525 (define_mode_attr d [(SI "") (DI "d")
526 (QQ "") (HQ "") (SQ "") (DQ "d")
527 (UQQ "") (UHQ "") (USQ "") (UDQ "d")
528 (HA "") (SA "") (DA "d")
529 (UHA "") (USA "") (UDA "d")])
531 ;; This attribute gives the length suffix for a sign- or zero-extension
533 (define_mode_attr size [(QI "b") (HI "h")])
535 ;; This attributes gives the mode mask of a SHORT.
536 (define_mode_attr mask [(QI "0x00ff") (HI "0xffff")])
538 ;; Mode attributes for GPR loads and stores.
539 (define_mode_attr load [(SI "lw") (DI "ld")])
540 (define_mode_attr store [(SI "sw") (DI "sd")])
542 ;; Similarly for MIPS IV indexed FPR loads and stores.
543 (define_mode_attr loadx [(SF "lwxc1") (DF "ldxc1") (V2SF "ldxc1")])
544 (define_mode_attr storex [(SF "swxc1") (DF "sdxc1") (V2SF "sdxc1")])
546 ;; The unextended ranges of the MIPS16 addiu and daddiu instructions
547 ;; are different. Some forms of unextended addiu have an 8-bit immediate
548 ;; field but the equivalent daddiu has only a 5-bit field.
549 (define_mode_attr si8_di5 [(SI "8") (DI "5")])
551 ;; This attribute gives the best constraint to use for registers of
553 (define_mode_attr reg [(SI "d") (DI "d") (CC "z")])
555 ;; This attribute gives the format suffix for floating-point operations.
556 (define_mode_attr fmt [(SF "s") (DF "d") (V2SF "ps")])
558 ;; This attribute gives the upper-case mode name for one unit of a
559 ;; floating-point mode.
560 (define_mode_attr UNITMODE [(SF "SF") (DF "DF") (V2SF "SF")])
562 ;; This attribute gives the integer mode that has the same size as a
564 (define_mode_attr IMODE [(QQ "QI") (HQ "HI") (SQ "SI") (DQ "DI")
565 (UQQ "QI") (UHQ "HI") (USQ "SI") (UDQ "DI")
566 (HA "HI") (SA "SI") (DA "DI")
567 (UHA "HI") (USA "SI") (UDA "DI")
568 (V4UQQ "SI") (V2UHQ "SI") (V2UHA "SI")
569 (V2HQ "SI") (V2HA "SI")])
571 ;; This attribute gives the integer mode that has half the size of
572 ;; the controlling mode.
573 (define_mode_attr HALFMODE [(DF "SI") (DI "SI") (V2SF "SI") (TF "DI")])
575 ;; This attribute works around the early SB-1 rev2 core "F2" erratum:
577 ;; In certain cases, div.s and div.ps may have a rounding error
578 ;; and/or wrong inexact flag.
580 ;; Therefore, we only allow div.s if not working around SB-1 rev2
581 ;; errata or if a slight loss of precision is OK.
582 (define_mode_attr divide_condition
583 [DF (SF "!TARGET_FIX_SB1 || flag_unsafe_math_optimizations")
584 (V2SF "TARGET_SB1 && (!TARGET_FIX_SB1 || flag_unsafe_math_optimizations)")])
586 ;; This attribute gives the conditions under which SQRT.fmt instructions
588 (define_mode_attr sqrt_condition
589 [(SF "!ISA_MIPS1") (DF "!ISA_MIPS1") (V2SF "TARGET_SB1")])
591 ;; This attribute gives the conditions under which RECIP.fmt and RSQRT.fmt
592 ;; instructions can be used. The MIPS32 and MIPS64 ISAs say that RECIP.D
593 ;; and RSQRT.D are unpredictable when doubles are stored in pairs of FPRs,
594 ;; so for safety's sake, we apply this restriction to all targets.
595 (define_mode_attr recip_condition
597 (DF "ISA_HAS_FP4 && TARGET_FLOAT64")
598 (V2SF "TARGET_SB1")])
600 ;; This code iterator allows all branch instructions to be generated from
601 ;; a single define_expand template.
602 (define_code_iterator any_cond [unordered ordered unlt unge uneq ltgt unle ungt
603 eq ne gt ge lt le gtu geu ltu leu])
605 ;; This code iterator allows signed and unsigned widening multiplications
606 ;; to use the same template.
607 (define_code_iterator any_extend [sign_extend zero_extend])
609 ;; This code iterator allows the three shift instructions to be generated
610 ;; from the same template.
611 (define_code_iterator any_shift [ashift ashiftrt lshiftrt])
613 ;; This code iterator allows all native floating-point comparisons to be
614 ;; generated from the same template.
615 (define_code_iterator fcond [unordered uneq unlt unle eq lt le])
617 ;; This code iterator is used for comparisons that can be implemented
618 ;; by swapping the operands.
619 (define_code_iterator swapped_fcond [ge gt unge ungt])
621 ;; <u> expands to an empty string when doing a signed operation and
622 ;; "u" when doing an unsigned operation.
623 (define_code_attr u [(sign_extend "") (zero_extend "u")])
625 ;; <su> is like <u>, but the signed form expands to "s" rather than "".
626 (define_code_attr su [(sign_extend "s") (zero_extend "u")])
628 ;; <optab> expands to the name of the optab for a particular code.
629 (define_code_attr optab [(ashift "ashl")
636 ;; <insn> expands to the name of the insn that implements a particular code.
637 (define_code_attr insn [(ashift "sll")
644 ;; <fcond> is the c.cond.fmt condition associated with a particular code.
645 (define_code_attr fcond [(unordered "un")
653 ;; Similar, but for swapped conditions.
654 (define_code_attr swapped_fcond [(ge "le")
659 ;; Atomic fetch bitwise operations.
660 (define_code_iterator fetchop_bit [ior xor and])
662 ;; <immediate_insn> expands to the name of the insn that implements
663 ;; a particular code to operate in immediate values.
664 (define_code_attr immediate_insn [(ior "ori") (xor "xori") (and "andi")])
667 ;; .........................
669 ;; Branch, call and jump delay slots
671 ;; .........................
673 (define_delay (and (eq_attr "type" "branch")
674 (eq (symbol_ref "TARGET_MIPS16") (const_int 0)))
675 [(eq_attr "can_delay" "yes")
677 (and (eq_attr "branch_likely" "yes")
678 (eq_attr "can_delay" "yes"))])
680 (define_delay (eq_attr "type" "jump")
681 [(eq_attr "can_delay" "yes")
685 (define_delay (and (eq_attr "type" "call")
686 (eq_attr "jal_macro" "no"))
687 [(eq_attr "can_delay" "yes")
691 ;; Pipeline descriptions.
693 ;; generic.md provides a fallback for processors without a specific
694 ;; pipeline description. It is derived from the old define_function_unit
695 ;; version and uses the "alu" and "imuldiv" units declared below.
697 ;; Some of the processor-specific files are also derived from old
698 ;; define_function_unit descriptions and simply override the parts of
699 ;; generic.md that don't apply. The other processor-specific files
700 ;; are self-contained.
701 (define_automaton "alu,imuldiv")
703 (define_cpu_unit "alu" "alu")
704 (define_cpu_unit "imuldiv" "imuldiv")
725 (include "generic.md")
728 ;; ....................
732 ;; ....................
736 [(trap_if (const_int 1) (const_int 0))]
739 if (ISA_HAS_COND_TRAP)
741 else if (TARGET_MIPS16)
746 [(set_attr "type" "trap")])
748 (define_expand "conditional_trap"
749 [(trap_if (match_operator 0 "comparison_operator"
750 [(match_dup 2) (match_dup 3)])
751 (match_operand 1 "const_int_operand"))]
754 if (GET_MODE_CLASS (GET_MODE (cmp_operands[0])) == MODE_INT
755 && operands[1] == const0_rtx)
757 mips_expand_conditional_trap (GET_CODE (operands[0]));
763 (define_insn "*conditional_trap<mode>"
764 [(trap_if (match_operator:GPR 0 "trap_comparison_operator"
765 [(match_operand:GPR 1 "reg_or_0_operand" "dJ")
766 (match_operand:GPR 2 "arith_operand" "dI")])
770 [(set_attr "type" "trap")])
773 ;; ....................
777 ;; ....................
780 (define_insn "add<mode>3"
781 [(set (match_operand:ANYF 0 "register_operand" "=f")
782 (plus:ANYF (match_operand:ANYF 1 "register_operand" "f")
783 (match_operand:ANYF 2 "register_operand" "f")))]
785 "add.<fmt>\t%0,%1,%2"
786 [(set_attr "type" "fadd")
787 (set_attr "mode" "<UNITMODE>")])
789 (define_expand "add<mode>3"
790 [(set (match_operand:GPR 0 "register_operand")
791 (plus:GPR (match_operand:GPR 1 "register_operand")
792 (match_operand:GPR 2 "arith_operand")))]
795 (define_insn "*add<mode>3"
796 [(set (match_operand:GPR 0 "register_operand" "=d,d")
797 (plus:GPR (match_operand:GPR 1 "register_operand" "d,d")
798 (match_operand:GPR 2 "arith_operand" "d,Q")))]
803 [(set_attr "type" "arith")
804 (set_attr "mode" "<MODE>")])
806 (define_insn "*add<mode>3_mips16"
807 [(set (match_operand:GPR 0 "register_operand" "=ks,d,d,d,d")
808 (plus:GPR (match_operand:GPR 1 "register_operand" "ks,ks,0,d,d")
809 (match_operand:GPR 2 "arith_operand" "Q,Q,Q,O,d")))]
817 [(set_attr "type" "arith")
818 (set_attr "mode" "<MODE>")
819 (set_attr_alternative "length"
820 [(if_then_else (match_operand 2 "m16_simm8_8")
823 (if_then_else (match_operand 2 "m16_uimm<si8_di5>_4")
826 (if_then_else (match_operand 2 "m16_simm<si8_di5>_1")
829 (if_then_else (match_operand 2 "m16_simm4_1")
834 ;; On the mips16, we can sometimes split an add of a constant which is
835 ;; a 4 byte instruction into two adds which are both 2 byte
836 ;; instructions. There are two cases: one where we are adding a
837 ;; constant plus a register to another register, and one where we are
838 ;; simply adding a constant to a register.
841 [(set (match_operand:SI 0 "register_operand")
842 (plus:SI (match_dup 0)
843 (match_operand:SI 1 "const_int_operand")))]
844 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
845 && REG_P (operands[0])
846 && M16_REG_P (REGNO (operands[0]))
847 && GET_CODE (operands[1]) == CONST_INT
848 && ((INTVAL (operands[1]) > 0x7f
849 && INTVAL (operands[1]) <= 0x7f + 0x7f)
850 || (INTVAL (operands[1]) < - 0x80
851 && INTVAL (operands[1]) >= - 0x80 - 0x80))"
852 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
853 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]
855 HOST_WIDE_INT val = INTVAL (operands[1]);
859 operands[1] = GEN_INT (0x7f);
860 operands[2] = GEN_INT (val - 0x7f);
864 operands[1] = GEN_INT (- 0x80);
865 operands[2] = GEN_INT (val + 0x80);
870 [(set (match_operand:SI 0 "register_operand")
871 (plus:SI (match_operand:SI 1 "register_operand")
872 (match_operand:SI 2 "const_int_operand")))]
873 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
874 && REG_P (operands[0])
875 && M16_REG_P (REGNO (operands[0]))
876 && REG_P (operands[1])
877 && M16_REG_P (REGNO (operands[1]))
878 && REGNO (operands[0]) != REGNO (operands[1])
879 && GET_CODE (operands[2]) == CONST_INT
880 && ((INTVAL (operands[2]) > 0x7
881 && INTVAL (operands[2]) <= 0x7 + 0x7f)
882 || (INTVAL (operands[2]) < - 0x8
883 && INTVAL (operands[2]) >= - 0x8 - 0x80))"
884 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))
885 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 3)))]
887 HOST_WIDE_INT val = INTVAL (operands[2]);
891 operands[2] = GEN_INT (0x7);
892 operands[3] = GEN_INT (val - 0x7);
896 operands[2] = GEN_INT (- 0x8);
897 operands[3] = GEN_INT (val + 0x8);
902 [(set (match_operand:DI 0 "register_operand")
903 (plus:DI (match_dup 0)
904 (match_operand:DI 1 "const_int_operand")))]
905 "TARGET_MIPS16 && TARGET_64BIT && reload_completed && !TARGET_DEBUG_D_MODE
906 && REG_P (operands[0])
907 && M16_REG_P (REGNO (operands[0]))
908 && GET_CODE (operands[1]) == CONST_INT
909 && ((INTVAL (operands[1]) > 0xf
910 && INTVAL (operands[1]) <= 0xf + 0xf)
911 || (INTVAL (operands[1]) < - 0x10
912 && INTVAL (operands[1]) >= - 0x10 - 0x10))"
913 [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1)))
914 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))]
916 HOST_WIDE_INT val = INTVAL (operands[1]);
920 operands[1] = GEN_INT (0xf);
921 operands[2] = GEN_INT (val - 0xf);
925 operands[1] = GEN_INT (- 0x10);
926 operands[2] = GEN_INT (val + 0x10);
931 [(set (match_operand:DI 0 "register_operand")
932 (plus:DI (match_operand:DI 1 "register_operand")
933 (match_operand:DI 2 "const_int_operand")))]
934 "TARGET_MIPS16 && TARGET_64BIT && reload_completed && !TARGET_DEBUG_D_MODE
935 && REG_P (operands[0])
936 && M16_REG_P (REGNO (operands[0]))
937 && REG_P (operands[1])
938 && M16_REG_P (REGNO (operands[1]))
939 && REGNO (operands[0]) != REGNO (operands[1])
940 && GET_CODE (operands[2]) == CONST_INT
941 && ((INTVAL (operands[2]) > 0x7
942 && INTVAL (operands[2]) <= 0x7 + 0xf)
943 || (INTVAL (operands[2]) < - 0x8
944 && INTVAL (operands[2]) >= - 0x8 - 0x10))"
945 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))
946 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
948 HOST_WIDE_INT val = INTVAL (operands[2]);
952 operands[2] = GEN_INT (0x7);
953 operands[3] = GEN_INT (val - 0x7);
957 operands[2] = GEN_INT (- 0x8);
958 operands[3] = GEN_INT (val + 0x8);
962 (define_insn "*addsi3_extended"
963 [(set (match_operand:DI 0 "register_operand" "=d,d")
965 (plus:SI (match_operand:SI 1 "register_operand" "d,d")
966 (match_operand:SI 2 "arith_operand" "d,Q"))))]
967 "TARGET_64BIT && !TARGET_MIPS16"
971 [(set_attr "type" "arith")
972 (set_attr "mode" "SI")])
974 ;; Split this insn so that the addiu splitters can have a crack at it.
975 ;; Use a conservative length estimate until the split.
976 (define_insn_and_split "*addsi3_extended_mips16"
977 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
979 (plus:SI (match_operand:SI 1 "register_operand" "0,d,d")
980 (match_operand:SI 2 "arith_operand" "Q,O,d"))))]
981 "TARGET_64BIT && TARGET_MIPS16"
983 "&& reload_completed"
984 [(set (match_dup 3) (plus:SI (match_dup 1) (match_dup 2)))]
985 { operands[3] = gen_lowpart (SImode, operands[0]); }
986 [(set_attr "type" "arith")
987 (set_attr "mode" "SI")
988 (set_attr "extended_mips16" "yes")])
991 ;; ....................
995 ;; ....................
998 (define_insn "sub<mode>3"
999 [(set (match_operand:ANYF 0 "register_operand" "=f")
1000 (minus:ANYF (match_operand:ANYF 1 "register_operand" "f")
1001 (match_operand:ANYF 2 "register_operand" "f")))]
1003 "sub.<fmt>\t%0,%1,%2"
1004 [(set_attr "type" "fadd")
1005 (set_attr "mode" "<UNITMODE>")])
1007 (define_insn "sub<mode>3"
1008 [(set (match_operand:GPR 0 "register_operand" "=d")
1009 (minus:GPR (match_operand:GPR 1 "register_operand" "d")
1010 (match_operand:GPR 2 "register_operand" "d")))]
1013 [(set_attr "type" "arith")
1014 (set_attr "mode" "<MODE>")])
1016 (define_insn "*subsi3_extended"
1017 [(set (match_operand:DI 0 "register_operand" "=d")
1019 (minus:SI (match_operand:SI 1 "register_operand" "d")
1020 (match_operand:SI 2 "register_operand" "d"))))]
1023 [(set_attr "type" "arith")
1024 (set_attr "mode" "DI")])
1027 ;; ....................
1031 ;; ....................
1034 (define_expand "mul<mode>3"
1035 [(set (match_operand:SCALARF 0 "register_operand")
1036 (mult:SCALARF (match_operand:SCALARF 1 "register_operand")
1037 (match_operand:SCALARF 2 "register_operand")))]
1041 (define_insn "*mul<mode>3"
1042 [(set (match_operand:SCALARF 0 "register_operand" "=f")
1043 (mult:SCALARF (match_operand:SCALARF 1 "register_operand" "f")
1044 (match_operand:SCALARF 2 "register_operand" "f")))]
1045 "!TARGET_4300_MUL_FIX"
1046 "mul.<fmt>\t%0,%1,%2"
1047 [(set_attr "type" "fmul")
1048 (set_attr "mode" "<MODE>")])
1050 ;; Early VR4300 silicon has a CPU bug where multiplies with certain
1051 ;; operands may corrupt immediately following multiplies. This is a
1052 ;; simple fix to insert NOPs.
1054 (define_insn "*mul<mode>3_r4300"
1055 [(set (match_operand:SCALARF 0 "register_operand" "=f")
1056 (mult:SCALARF (match_operand:SCALARF 1 "register_operand" "f")
1057 (match_operand:SCALARF 2 "register_operand" "f")))]
1058 "TARGET_4300_MUL_FIX"
1059 "mul.<fmt>\t%0,%1,%2\;nop"
1060 [(set_attr "type" "fmul")
1061 (set_attr "mode" "<MODE>")
1062 (set_attr "length" "8")])
1064 (define_insn "mulv2sf3"
1065 [(set (match_operand:V2SF 0 "register_operand" "=f")
1066 (mult:V2SF (match_operand:V2SF 1 "register_operand" "f")
1067 (match_operand:V2SF 2 "register_operand" "f")))]
1068 "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT"
1070 [(set_attr "type" "fmul")
1071 (set_attr "mode" "SF")])
1073 ;; The original R4000 has a cpu bug. If a double-word or a variable
1074 ;; shift executes while an integer multiplication is in progress, the
1075 ;; shift may give an incorrect result. Avoid this by keeping the mflo
1076 ;; with the mult on the R4000.
1078 ;; From "MIPS R4000PC/SC Errata, Processor Revision 2.2 and 3.0"
1079 ;; (also valid for MIPS R4000MC processors):
1081 ;; "16. R4000PC, R4000SC: Please refer to errata 28 for an update to
1082 ;; this errata description.
1083 ;; The following code sequence causes the R4000 to incorrectly
1084 ;; execute the Double Shift Right Arithmetic 32 (dsra32)
1085 ;; instruction. If the dsra32 instruction is executed during an
1086 ;; integer multiply, the dsra32 will only shift by the amount in
1087 ;; specified in the instruction rather than the amount plus 32
1089 ;; instruction 1: mult rs,rt integer multiply
1090 ;; instruction 2-12: dsra32 rd,rt,rs doubleword shift
1091 ;; right arithmetic + 32
1092 ;; Workaround: A dsra32 instruction placed after an integer
1093 ;; multiply should not be one of the 11 instructions after the
1094 ;; multiply instruction."
1098 ;; "28. R4000PC, R4000SC: The text from errata 16 should be replaced by
1099 ;; the following description.
1100 ;; All extended shifts (shift by n+32) and variable shifts (32 and
1101 ;; 64-bit versions) may produce incorrect results under the
1102 ;; following conditions:
1103 ;; 1) An integer multiply is currently executing
1104 ;; 2) These types of shift instructions are executed immediately
1105 ;; following an integer divide instruction.
1107 ;; 1) Make sure no integer multiply is running wihen these
1108 ;; instruction are executed. If this cannot be predicted at
1109 ;; compile time, then insert a "mfhi" to R0 instruction
1110 ;; immediately after the integer multiply instruction. This
1111 ;; will cause the integer multiply to complete before the shift
1113 ;; 2) Separate integer divide and these two classes of shift
1114 ;; instructions by another instruction or a noop."
1116 ;; These processors have PRId values of 0x00004220 and 0x00004300,
1119 (define_expand "mulsi3"
1120 [(set (match_operand:SI 0 "register_operand")
1121 (mult:SI (match_operand:SI 1 "register_operand")
1122 (match_operand:SI 2 "register_operand")))]
1126 emit_insn (gen_mulsi3_mult3 (operands[0], operands[1], operands[2]));
1127 else if (TARGET_FIX_R4000)
1128 emit_insn (gen_mulsi3_r4000 (operands[0], operands[1], operands[2]));
1130 emit_insn (gen_mulsi3_internal (operands[0], operands[1], operands[2]));
1134 (define_expand "muldi3"
1135 [(set (match_operand:DI 0 "register_operand")
1136 (mult:DI (match_operand:DI 1 "register_operand")
1137 (match_operand:DI 2 "register_operand")))]
1140 if (TARGET_FIX_R4000)
1141 emit_insn (gen_muldi3_r4000 (operands[0], operands[1], operands[2]));
1143 emit_insn (gen_muldi3_internal (operands[0], operands[1], operands[2]));
1147 (define_insn "mulsi3_mult3"
1148 [(set (match_operand:SI 0 "register_operand" "=d,l")
1149 (mult:SI (match_operand:SI 1 "register_operand" "d,d")
1150 (match_operand:SI 2 "register_operand" "d,d")))
1151 (clobber (match_scratch:SI 3 "=h,h"))
1152 (clobber (match_scratch:SI 4 "=l,X"))]
1155 if (which_alternative == 1)
1156 return "mult\t%1,%2";
1157 if (TARGET_MIPS3900)
1158 return "mult\t%0,%1,%2";
1159 return "mul\t%0,%1,%2";
1161 [(set_attr "type" "imul3,imul")
1162 (set_attr "mode" "SI")])
1164 ;; If a register gets allocated to LO, and we spill to memory, the reload
1165 ;; will include a move from LO to a GPR. Merge it into the multiplication
1166 ;; if it can set the GPR directly.
1169 ;; Operand 1: GPR (1st multiplication operand)
1170 ;; Operand 2: GPR (2nd multiplication operand)
1172 ;; Operand 4: GPR (destination)
1175 [(set (match_operand:SI 0 "register_operand")
1176 (mult:SI (match_operand:SI 1 "register_operand")
1177 (match_operand:SI 2 "register_operand")))
1178 (clobber (match_operand:SI 3 "register_operand"))
1179 (clobber (scratch:SI))])
1180 (set (match_operand:SI 4 "register_operand")
1181 (unspec [(match_dup 0) (match_dup 3)] UNSPEC_MFHILO))]
1182 "ISA_HAS_MUL3 && peep2_reg_dead_p (2, operands[0])"
1185 (mult:SI (match_dup 1)
1187 (clobber (match_dup 3))
1188 (clobber (match_dup 0))])])
1190 (define_insn "mul<mode>3_internal"
1191 [(set (match_operand:GPR 0 "register_operand" "=l")
1192 (mult:GPR (match_operand:GPR 1 "register_operand" "d")
1193 (match_operand:GPR 2 "register_operand" "d")))
1194 (clobber (match_scratch:GPR 3 "=h"))]
1197 [(set_attr "type" "imul")
1198 (set_attr "mode" "<MODE>")])
1200 (define_insn "mul<mode>3_r4000"
1201 [(set (match_operand:GPR 0 "register_operand" "=d")
1202 (mult:GPR (match_operand:GPR 1 "register_operand" "d")
1203 (match_operand:GPR 2 "register_operand" "d")))
1204 (clobber (match_scratch:GPR 3 "=h"))
1205 (clobber (match_scratch:GPR 4 "=l"))]
1207 "<d>mult\t%1,%2\;mflo\t%0"
1208 [(set_attr "type" "imul")
1209 (set_attr "mode" "<MODE>")
1210 (set_attr "length" "8")])
1212 ;; On the VR4120 and VR4130, it is better to use "mtlo $0; macc" instead
1213 ;; of "mult; mflo". They have the same latency, but the first form gives
1214 ;; us an extra cycle to compute the operands.
1217 ;; Operand 1: GPR (1st multiplication operand)
1218 ;; Operand 2: GPR (2nd multiplication operand)
1220 ;; Operand 4: GPR (destination)
1223 [(set (match_operand:SI 0 "register_operand")
1224 (mult:SI (match_operand:SI 1 "register_operand")
1225 (match_operand:SI 2 "register_operand")))
1226 (clobber (match_operand:SI 3 "register_operand"))])
1227 (set (match_operand:SI 4 "register_operand")
1228 (unspec:SI [(match_dup 0) (match_dup 3)] UNSPEC_MFHILO))]
1229 "ISA_HAS_MACC && !ISA_HAS_MUL3"
1234 (plus:SI (mult:SI (match_dup 1)
1238 (plus:SI (mult:SI (match_dup 1)
1241 (clobber (match_dup 3))])])
1243 ;; Multiply-accumulate patterns
1245 ;; For processors that can copy the output to a general register:
1247 ;; The all-d alternative is needed because the combiner will find this
1248 ;; pattern and then register alloc/reload will move registers around to
1249 ;; make them fit, and we don't want to trigger unnecessary loads to LO.
1251 ;; The last alternative should be made slightly less desirable, but adding
1252 ;; "?" to the constraint is too strong, and causes values to be loaded into
1253 ;; LO even when that's more costly. For now, using "*d" mostly does the
1255 (define_insn "*mul_acc_si"
1256 [(set (match_operand:SI 0 "register_operand" "=l,*d,*d")
1257 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d,d")
1258 (match_operand:SI 2 "register_operand" "d,d,d"))
1259 (match_operand:SI 3 "register_operand" "0,l,*d")))
1260 (clobber (match_scratch:SI 4 "=h,h,h"))
1261 (clobber (match_scratch:SI 5 "=X,3,l"))
1262 (clobber (match_scratch:SI 6 "=X,X,&d"))]
1264 || GENERATE_MADD_MSUB)
1267 static const char *const madd[] = { "madd\t%1,%2", "madd\t%0,%1,%2" };
1268 if (which_alternative == 2)
1270 if (GENERATE_MADD_MSUB && which_alternative != 0)
1272 return madd[which_alternative];
1274 [(set_attr "type" "imadd")
1275 (set_attr "mode" "SI")
1276 (set_attr "length" "4,4,8")])
1278 ;; Split the above insn if we failed to get LO allocated.
1280 [(set (match_operand:SI 0 "register_operand")
1281 (plus:SI (mult:SI (match_operand:SI 1 "register_operand")
1282 (match_operand:SI 2 "register_operand"))
1283 (match_operand:SI 3 "register_operand")))
1284 (clobber (match_scratch:SI 4))
1285 (clobber (match_scratch:SI 5))
1286 (clobber (match_scratch:SI 6))]
1287 "reload_completed && !TARGET_DEBUG_D_MODE
1288 && GP_REG_P (true_regnum (operands[0]))
1289 && GP_REG_P (true_regnum (operands[3]))"
1290 [(parallel [(set (match_dup 6)
1291 (mult:SI (match_dup 1) (match_dup 2)))
1292 (clobber (match_dup 4))
1293 (clobber (match_dup 5))])
1294 (set (match_dup 0) (plus:SI (match_dup 6) (match_dup 3)))]
1297 ;; Splitter to copy result of MADD to a general register
1299 [(set (match_operand:SI 0 "register_operand")
1300 (plus:SI (mult:SI (match_operand:SI 1 "register_operand")
1301 (match_operand:SI 2 "register_operand"))
1302 (match_operand:SI 3 "register_operand")))
1303 (clobber (match_scratch:SI 4))
1304 (clobber (match_scratch:SI 5))
1305 (clobber (match_scratch:SI 6))]
1306 "reload_completed && !TARGET_DEBUG_D_MODE
1307 && GP_REG_P (true_regnum (operands[0]))
1308 && true_regnum (operands[3]) == LO_REGNUM"
1309 [(parallel [(set (match_dup 3)
1310 (plus:SI (mult:SI (match_dup 1) (match_dup 2))
1312 (clobber (match_dup 4))
1313 (clobber (match_dup 5))
1314 (clobber (match_dup 6))])
1315 (set (match_dup 0) (unspec:SI [(match_dup 5) (match_dup 4)] UNSPEC_MFHILO))]
1318 (define_insn "*macc"
1319 [(set (match_operand:SI 0 "register_operand" "=l,d")
1320 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d")
1321 (match_operand:SI 2 "register_operand" "d,d"))
1322 (match_operand:SI 3 "register_operand" "0,l")))
1323 (clobber (match_scratch:SI 4 "=h,h"))
1324 (clobber (match_scratch:SI 5 "=X,3"))]
1327 if (which_alternative == 1)
1328 return "macc\t%0,%1,%2";
1329 else if (TARGET_MIPS5500)
1330 return "madd\t%1,%2";
1332 /* The VR4130 assumes that there is a two-cycle latency between a macc
1333 that "writes" to $0 and an instruction that reads from it. We avoid
1334 this by assigning to $1 instead. */
1335 return "%[macc\t%@,%1,%2%]";
1337 [(set_attr "type" "imadd")
1338 (set_attr "mode" "SI")])
1340 (define_insn "*msac"
1341 [(set (match_operand:SI 0 "register_operand" "=l,d")
1342 (minus:SI (match_operand:SI 1 "register_operand" "0,l")
1343 (mult:SI (match_operand:SI 2 "register_operand" "d,d")
1344 (match_operand:SI 3 "register_operand" "d,d"))))
1345 (clobber (match_scratch:SI 4 "=h,h"))
1346 (clobber (match_scratch:SI 5 "=X,1"))]
1349 if (which_alternative == 1)
1350 return "msac\t%0,%2,%3";
1351 else if (TARGET_MIPS5500)
1352 return "msub\t%2,%3";
1354 return "msac\t$0,%2,%3";
1356 [(set_attr "type" "imadd")
1357 (set_attr "mode" "SI")])
1359 ;; An msac-like instruction implemented using negation and a macc.
1360 (define_insn_and_split "*msac_using_macc"
1361 [(set (match_operand:SI 0 "register_operand" "=l,d")
1362 (minus:SI (match_operand:SI 1 "register_operand" "0,l")
1363 (mult:SI (match_operand:SI 2 "register_operand" "d,d")
1364 (match_operand:SI 3 "register_operand" "d,d"))))
1365 (clobber (match_scratch:SI 4 "=h,h"))
1366 (clobber (match_scratch:SI 5 "=X,1"))
1367 (clobber (match_scratch:SI 6 "=d,d"))]
1368 "ISA_HAS_MACC && !ISA_HAS_MSAC"
1370 "&& reload_completed"
1372 (neg:SI (match_dup 3)))
1375 (plus:SI (mult:SI (match_dup 2)
1378 (clobber (match_dup 4))
1379 (clobber (match_dup 5))])]
1381 [(set_attr "type" "imadd")
1382 (set_attr "length" "8")])
1384 ;; Patterns generated by the define_peephole2 below.
1386 (define_insn "*macc2"
1387 [(set (match_operand:SI 0 "register_operand" "=l")
1388 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d")
1389 (match_operand:SI 2 "register_operand" "d"))
1391 (set (match_operand:SI 3 "register_operand" "=d")
1392 (plus:SI (mult:SI (match_dup 1)
1395 (clobber (match_scratch:SI 4 "=h"))]
1396 "ISA_HAS_MACC && reload_completed"
1398 [(set_attr "type" "imadd")
1399 (set_attr "mode" "SI")])
1401 (define_insn "*msac2"
1402 [(set (match_operand:SI 0 "register_operand" "=l")
1403 (minus:SI (match_dup 0)
1404 (mult:SI (match_operand:SI 1 "register_operand" "d")
1405 (match_operand:SI 2 "register_operand" "d"))))
1406 (set (match_operand:SI 3 "register_operand" "=d")
1407 (minus:SI (match_dup 0)
1408 (mult:SI (match_dup 1)
1410 (clobber (match_scratch:SI 4 "=h"))]
1411 "ISA_HAS_MSAC && reload_completed"
1413 [(set_attr "type" "imadd")
1414 (set_attr "mode" "SI")])
1416 ;; Convert macc $0,<r1>,<r2> & mflo <r3> into macc <r3>,<r1>,<r2>
1420 ;; Operand 1: macc/msac
1422 ;; Operand 3: GPR (destination)
1425 [(set (match_operand:SI 0 "register_operand")
1426 (match_operand:SI 1 "macc_msac_operand"))
1427 (clobber (match_operand:SI 2 "register_operand"))
1428 (clobber (scratch:SI))])
1429 (set (match_operand:SI 3 "register_operand")
1430 (unspec:SI [(match_dup 0) (match_dup 2)] UNSPEC_MFHILO))]
1432 [(parallel [(set (match_dup 0)
1436 (clobber (match_dup 2))])]
1439 ;; When we have a three-address multiplication instruction, it should
1440 ;; be faster to do a separate multiply and add, rather than moving
1441 ;; something into LO in order to use a macc instruction.
1443 ;; This peephole needs a scratch register to cater for the case when one
1444 ;; of the multiplication operands is the same as the destination.
1446 ;; Operand 0: GPR (scratch)
1448 ;; Operand 2: GPR (addend)
1449 ;; Operand 3: GPR (destination)
1450 ;; Operand 4: macc/msac
1452 ;; Operand 6: new multiplication
1453 ;; Operand 7: new addition/subtraction
1455 [(match_scratch:SI 0 "d")
1456 (set (match_operand:SI 1 "register_operand")
1457 (match_operand:SI 2 "register_operand"))
1460 [(set (match_operand:SI 3 "register_operand")
1461 (match_operand:SI 4 "macc_msac_operand"))
1462 (clobber (match_operand:SI 5 "register_operand"))
1463 (clobber (match_dup 1))])]
1465 && true_regnum (operands[1]) == LO_REGNUM
1466 && peep2_reg_dead_p (2, operands[1])
1467 && GP_REG_P (true_regnum (operands[3]))"
1468 [(parallel [(set (match_dup 0)
1470 (clobber (match_dup 5))
1471 (clobber (match_dup 1))])
1475 operands[6] = XEXP (operands[4], GET_CODE (operands[4]) == PLUS ? 0 : 1);
1476 operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[4]), SImode,
1477 operands[2], operands[0]);
1480 ;; Same as above, except LO is the initial target of the macc.
1482 ;; Operand 0: GPR (scratch)
1484 ;; Operand 2: GPR (addend)
1485 ;; Operand 3: macc/msac
1487 ;; Operand 5: GPR (destination)
1488 ;; Operand 6: new multiplication
1489 ;; Operand 7: new addition/subtraction
1491 [(match_scratch:SI 0 "d")
1492 (set (match_operand:SI 1 "register_operand")
1493 (match_operand:SI 2 "register_operand"))
1497 (match_operand:SI 3 "macc_msac_operand"))
1498 (clobber (match_operand:SI 4 "register_operand"))
1499 (clobber (scratch:SI))])
1501 (set (match_operand:SI 5 "register_operand")
1502 (unspec:SI [(match_dup 1) (match_dup 4)] UNSPEC_MFHILO))]
1503 "ISA_HAS_MUL3 && peep2_reg_dead_p (3, operands[1])"
1504 [(parallel [(set (match_dup 0)
1506 (clobber (match_dup 4))
1507 (clobber (match_dup 1))])
1511 operands[6] = XEXP (operands[4], GET_CODE (operands[4]) == PLUS ? 0 : 1);
1512 operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[4]), SImode,
1513 operands[2], operands[0]);
1516 (define_insn "*mul_sub_si"
1517 [(set (match_operand:SI 0 "register_operand" "=l,*d,*d")
1518 (minus:SI (match_operand:SI 1 "register_operand" "0,l,*d")
1519 (mult:SI (match_operand:SI 2 "register_operand" "d,d,d")
1520 (match_operand:SI 3 "register_operand" "d,d,d"))))
1521 (clobber (match_scratch:SI 4 "=h,h,h"))
1522 (clobber (match_scratch:SI 5 "=X,1,l"))
1523 (clobber (match_scratch:SI 6 "=X,X,&d"))]
1524 "GENERATE_MADD_MSUB"
1529 [(set_attr "type" "imadd")
1530 (set_attr "mode" "SI")
1531 (set_attr "length" "4,8,8")])
1533 ;; Split the above insn if we failed to get LO allocated.
1535 [(set (match_operand:SI 0 "register_operand")
1536 (minus:SI (match_operand:SI 1 "register_operand")
1537 (mult:SI (match_operand:SI 2 "register_operand")
1538 (match_operand:SI 3 "register_operand"))))
1539 (clobber (match_scratch:SI 4))
1540 (clobber (match_scratch:SI 5))
1541 (clobber (match_scratch:SI 6))]
1542 "reload_completed && !TARGET_DEBUG_D_MODE
1543 && GP_REG_P (true_regnum (operands[0]))
1544 && GP_REG_P (true_regnum (operands[1]))"
1545 [(parallel [(set (match_dup 6)
1546 (mult:SI (match_dup 2) (match_dup 3)))
1547 (clobber (match_dup 4))
1548 (clobber (match_dup 5))])
1549 (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 6)))]
1552 ;; Splitter to copy result of MSUB to a general register
1554 [(set (match_operand:SI 0 "register_operand")
1555 (minus:SI (match_operand:SI 1 "register_operand")
1556 (mult:SI (match_operand:SI 2 "register_operand")
1557 (match_operand:SI 3 "register_operand"))))
1558 (clobber (match_scratch:SI 4))
1559 (clobber (match_scratch:SI 5))
1560 (clobber (match_scratch:SI 6))]
1561 "reload_completed && !TARGET_DEBUG_D_MODE
1562 && GP_REG_P (true_regnum (operands[0]))
1563 && true_regnum (operands[1]) == LO_REGNUM"
1564 [(parallel [(set (match_dup 1)
1565 (minus:SI (match_dup 1)
1566 (mult:SI (match_dup 2) (match_dup 3))))
1567 (clobber (match_dup 4))
1568 (clobber (match_dup 5))
1569 (clobber (match_dup 6))])
1570 (set (match_dup 0) (unspec:SI [(match_dup 5) (match_dup 4)] UNSPEC_MFHILO))]
1573 (define_insn "*muls"
1574 [(set (match_operand:SI 0 "register_operand" "=l,d")
1575 (neg:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d")
1576 (match_operand:SI 2 "register_operand" "d,d"))))
1577 (clobber (match_scratch:SI 3 "=h,h"))
1578 (clobber (match_scratch:SI 4 "=X,l"))]
1583 [(set_attr "type" "imul,imul3")
1584 (set_attr "mode" "SI")])
1586 ;; ??? We could define a mulditi3 pattern when TARGET_64BIT.
1588 (define_expand "<u>mulsidi3"
1590 [(set (match_operand:DI 0 "register_operand")
1591 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand"))
1592 (any_extend:DI (match_operand:SI 2 "register_operand"))))
1593 (clobber (scratch:DI))
1594 (clobber (scratch:DI))
1595 (clobber (scratch:DI))])]
1596 "!TARGET_64BIT || !TARGET_FIX_R4000"
1600 if (!TARGET_FIX_R4000)
1601 emit_insn (gen_<u>mulsidi3_32bit_internal (operands[0], operands[1],
1604 emit_insn (gen_<u>mulsidi3_32bit_r4000 (operands[0], operands[1],
1610 (define_insn "<u>mulsidi3_32bit_internal"
1611 [(set (match_operand:DI 0 "register_operand" "=x")
1612 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1613 (any_extend:DI (match_operand:SI 2 "register_operand" "d"))))]
1614 "!TARGET_64BIT && !TARGET_FIX_R4000 && !ISA_HAS_DSPR2"
1616 [(set_attr "type" "imul")
1617 (set_attr "mode" "SI")])
1619 (define_insn "<u>mulsidi3_32bit_r4000"
1620 [(set (match_operand:DI 0 "register_operand" "=d")
1621 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1622 (any_extend:DI (match_operand:SI 2 "register_operand" "d"))))
1623 (clobber (match_scratch:DI 3 "=x"))]
1624 "!TARGET_64BIT && TARGET_FIX_R4000"
1625 "mult<u>\t%1,%2\;mflo\t%L0;mfhi\t%M0"
1626 [(set_attr "type" "imul")
1627 (set_attr "mode" "SI")
1628 (set_attr "length" "12")])
1630 (define_insn_and_split "*<u>mulsidi3_64bit"
1631 [(set (match_operand:DI 0 "register_operand" "=d")
1632 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1633 (any_extend:DI (match_operand:SI 2 "register_operand" "d"))))
1634 (clobber (match_scratch:DI 3 "=l"))
1635 (clobber (match_scratch:DI 4 "=h"))
1636 (clobber (match_scratch:DI 5 "=d"))]
1637 "TARGET_64BIT && !TARGET_FIX_R4000"
1639 "&& reload_completed"
1643 (mult:SI (match_dup 1)
1647 (mult:DI (any_extend:DI (match_dup 1))
1648 (any_extend:DI (match_dup 2)))
1651 ;; OP5 <- LO, OP0 <- HI
1652 (set (match_dup 5) (unspec:DI [(match_dup 3) (match_dup 4)] UNSPEC_MFHILO))
1653 (set (match_dup 0) (unspec:DI [(match_dup 4) (match_dup 3)] UNSPEC_MFHILO))
1657 (ashift:DI (match_dup 5)
1660 (lshiftrt:DI (match_dup 5)
1663 ;; Shift OP0 into place.
1665 (ashift:DI (match_dup 0)
1668 ;; OR the two halves together
1670 (ior:DI (match_dup 0)
1673 [(set_attr "type" "imul")
1674 (set_attr "mode" "SI")
1675 (set_attr "length" "24")])
1677 (define_insn "*<u>mulsidi3_64bit_parts"
1678 [(set (match_operand:DI 0 "register_operand" "=l")
1680 (mult:SI (match_operand:SI 2 "register_operand" "d")
1681 (match_operand:SI 3 "register_operand" "d"))))
1682 (set (match_operand:DI 1 "register_operand" "=h")
1684 (mult:DI (any_extend:DI (match_dup 2))
1685 (any_extend:DI (match_dup 3)))
1687 "TARGET_64BIT && !TARGET_FIX_R4000"
1689 [(set_attr "type" "imul")
1690 (set_attr "mode" "SI")])
1692 ;; Widening multiply with negation.
1693 (define_insn "*muls<u>_di"
1694 [(set (match_operand:DI 0 "register_operand" "=x")
1697 (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1698 (any_extend:DI (match_operand:SI 2 "register_operand" "d")))))]
1699 "!TARGET_64BIT && ISA_HAS_MULS"
1701 [(set_attr "type" "imul")
1702 (set_attr "mode" "SI")])
1704 (define_insn "<u>msubsidi4"
1705 [(set (match_operand:DI 0 "register_operand" "=ka")
1707 (match_operand:DI 3 "register_operand" "0")
1709 (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1710 (any_extend:DI (match_operand:SI 2 "register_operand" "d")))))]
1711 "!TARGET_64BIT && (ISA_HAS_MSAC || GENERATE_MADD_MSUB || ISA_HAS_DSPR2)"
1714 return "msub<u>\t%q0,%1,%2";
1715 else if (TARGET_MIPS5500 || GENERATE_MADD_MSUB)
1716 return "msub<u>\t%1,%2";
1718 return "msac<u>\t$0,%1,%2";
1720 [(set_attr "type" "imadd")
1721 (set_attr "mode" "SI")])
1723 ;; _highpart patterns
1725 (define_expand "<su>mulsi3_highpart"
1726 [(set (match_operand:SI 0 "register_operand")
1729 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand"))
1730 (any_extend:DI (match_operand:SI 2 "register_operand")))
1732 "ISA_HAS_MULHI || !TARGET_FIX_R4000"
1735 emit_insn (gen_<su>mulsi3_highpart_mulhi_internal (operands[0],
1739 emit_insn (gen_<su>mulsi3_highpart_internal (operands[0], operands[1],
1744 (define_insn "<su>mulsi3_highpart_internal"
1745 [(set (match_operand:SI 0 "register_operand" "=h")
1748 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1749 (any_extend:DI (match_operand:SI 2 "register_operand" "d")))
1751 (clobber (match_scratch:SI 3 "=l"))]
1752 "!ISA_HAS_MULHI && !TARGET_FIX_R4000"
1754 [(set_attr "type" "imul")
1755 (set_attr "mode" "SI")])
1757 (define_insn "<su>mulsi3_highpart_mulhi_internal"
1758 [(set (match_operand:SI 0 "register_operand" "=h,d")
1762 (any_extend:DI (match_operand:SI 1 "register_operand" "d,d"))
1763 (any_extend:DI (match_operand:SI 2 "register_operand" "d,d")))
1765 (clobber (match_scratch:SI 3 "=l,l"))
1766 (clobber (match_scratch:SI 4 "=X,h"))]
1771 [(set_attr "type" "imul,imul3")
1772 (set_attr "mode" "SI")])
1774 (define_insn "*<su>mulsi3_highpart_neg_mulhi_internal"
1775 [(set (match_operand:SI 0 "register_operand" "=h,d")
1780 (any_extend:DI (match_operand:SI 1 "register_operand" "d,d"))
1781 (any_extend:DI (match_operand:SI 2 "register_operand" "d,d"))))
1783 (clobber (match_scratch:SI 3 "=l,l"))
1784 (clobber (match_scratch:SI 4 "=X,h"))]
1788 mulshi<u>\t%0,%1,%2"
1789 [(set_attr "type" "imul,imul3")
1790 (set_attr "mode" "SI")])
1792 ;; Disable unsigned multiplication for -mfix-vr4120. This is for VR4120
1793 ;; errata MD(0), which says that dmultu does not always produce the
1795 (define_insn "<su>muldi3_highpart"
1796 [(set (match_operand:DI 0 "register_operand" "=h")
1800 (any_extend:TI (match_operand:DI 1 "register_operand" "d"))
1801 (any_extend:TI (match_operand:DI 2 "register_operand" "d")))
1803 (clobber (match_scratch:DI 3 "=l"))]
1804 "TARGET_64BIT && !TARGET_FIX_R4000
1805 && !(<CODE> == ZERO_EXTEND && TARGET_FIX_VR4120)"
1807 [(set_attr "type" "imul")
1808 (set_attr "mode" "DI")])
1810 ;; The R4650 supports a 32-bit multiply/ 64-bit accumulate
1811 ;; instruction. The HI/LO registers are used as a 64-bit accumulator.
1813 (define_insn "madsi"
1814 [(set (match_operand:SI 0 "register_operand" "+l")
1815 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d")
1816 (match_operand:SI 2 "register_operand" "d"))
1818 (clobber (match_scratch:SI 3 "=h"))]
1821 [(set_attr "type" "imadd")
1822 (set_attr "mode" "SI")])
1824 (define_insn "<u>maddsidi4"
1825 [(set (match_operand:DI 0 "register_operand" "=ka")
1827 (mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d"))
1828 (any_extend:DI (match_operand:SI 2 "register_operand" "d")))
1829 (match_operand:DI 3 "register_operand" "0")))]
1830 "(TARGET_MAD || ISA_HAS_MACC || GENERATE_MADD_MSUB || ISA_HAS_DSPR2)
1834 return "mad<u>\t%1,%2";
1835 else if (ISA_HAS_DSPR2)
1836 return "madd<u>\t%q0,%1,%2";
1837 else if (GENERATE_MADD_MSUB || TARGET_MIPS5500)
1838 return "madd<u>\t%1,%2";
1840 /* See comment in *macc. */
1841 return "%[macc<u>\t%@,%1,%2%]";
1843 [(set_attr "type" "imadd")
1844 (set_attr "mode" "SI")])
1846 ;; Floating point multiply accumulate instructions.
1848 (define_insn "*madd<mode>"
1849 [(set (match_operand:ANYF 0 "register_operand" "=f")
1850 (plus:ANYF (mult:ANYF (match_operand:ANYF 1 "register_operand" "f")
1851 (match_operand:ANYF 2 "register_operand" "f"))
1852 (match_operand:ANYF 3 "register_operand" "f")))]
1853 "ISA_HAS_FP4 && TARGET_FUSED_MADD"
1854 "madd.<fmt>\t%0,%3,%1,%2"
1855 [(set_attr "type" "fmadd")
1856 (set_attr "mode" "<UNITMODE>")])
1858 (define_insn "*msub<mode>"
1859 [(set (match_operand:ANYF 0 "register_operand" "=f")
1860 (minus:ANYF (mult:ANYF (match_operand:ANYF 1 "register_operand" "f")
1861 (match_operand:ANYF 2 "register_operand" "f"))
1862 (match_operand:ANYF 3 "register_operand" "f")))]
1863 "ISA_HAS_FP4 && TARGET_FUSED_MADD"
1864 "msub.<fmt>\t%0,%3,%1,%2"
1865 [(set_attr "type" "fmadd")
1866 (set_attr "mode" "<UNITMODE>")])
1868 (define_insn "*nmadd<mode>"
1869 [(set (match_operand:ANYF 0 "register_operand" "=f")
1870 (neg:ANYF (plus:ANYF
1871 (mult:ANYF (match_operand:ANYF 1 "register_operand" "f")
1872 (match_operand:ANYF 2 "register_operand" "f"))
1873 (match_operand:ANYF 3 "register_operand" "f"))))]
1874 "ISA_HAS_NMADD_NMSUB (<MODE>mode)
1875 && TARGET_FUSED_MADD
1876 && HONOR_SIGNED_ZEROS (<MODE>mode)
1877 && !HONOR_NANS (<MODE>mode)"
1878 "nmadd.<fmt>\t%0,%3,%1,%2"
1879 [(set_attr "type" "fmadd")
1880 (set_attr "mode" "<UNITMODE>")])
1882 (define_insn "*nmadd<mode>_fastmath"
1883 [(set (match_operand:ANYF 0 "register_operand" "=f")
1885 (mult:ANYF (neg:ANYF (match_operand:ANYF 1 "register_operand" "f"))
1886 (match_operand:ANYF 2 "register_operand" "f"))
1887 (match_operand:ANYF 3 "register_operand" "f")))]
1888 "ISA_HAS_NMADD_NMSUB (<MODE>mode)
1889 && TARGET_FUSED_MADD
1890 && !HONOR_SIGNED_ZEROS (<MODE>mode)
1891 && !HONOR_NANS (<MODE>mode)"
1892 "nmadd.<fmt>\t%0,%3,%1,%2"
1893 [(set_attr "type" "fmadd")
1894 (set_attr "mode" "<UNITMODE>")])
1896 (define_insn "*nmsub<mode>"
1897 [(set (match_operand:ANYF 0 "register_operand" "=f")
1898 (neg:ANYF (minus:ANYF
1899 (mult:ANYF (match_operand:ANYF 2 "register_operand" "f")
1900 (match_operand:ANYF 3 "register_operand" "f"))
1901 (match_operand:ANYF 1 "register_operand" "f"))))]
1902 "ISA_HAS_NMADD_NMSUB (<MODE>mode)
1903 && TARGET_FUSED_MADD
1904 && HONOR_SIGNED_ZEROS (<MODE>mode)
1905 && !HONOR_NANS (<MODE>mode)"
1906 "nmsub.<fmt>\t%0,%1,%2,%3"
1907 [(set_attr "type" "fmadd")
1908 (set_attr "mode" "<UNITMODE>")])
1910 (define_insn "*nmsub<mode>_fastmath"
1911 [(set (match_operand:ANYF 0 "register_operand" "=f")
1913 (match_operand:ANYF 1 "register_operand" "f")
1914 (mult:ANYF (match_operand:ANYF 2 "register_operand" "f")
1915 (match_operand:ANYF 3 "register_operand" "f"))))]
1916 "ISA_HAS_NMADD_NMSUB (<MODE>mode)
1917 && TARGET_FUSED_MADD
1918 && !HONOR_SIGNED_ZEROS (<MODE>mode)
1919 && !HONOR_NANS (<MODE>mode)"
1920 "nmsub.<fmt>\t%0,%1,%2,%3"
1921 [(set_attr "type" "fmadd")
1922 (set_attr "mode" "<UNITMODE>")])
1925 ;; ....................
1927 ;; DIVISION and REMAINDER
1929 ;; ....................
1932 (define_expand "div<mode>3"
1933 [(set (match_operand:ANYF 0 "register_operand")
1934 (div:ANYF (match_operand:ANYF 1 "reg_or_1_operand")
1935 (match_operand:ANYF 2 "register_operand")))]
1936 "<divide_condition>"
1938 if (const_1_operand (operands[1], <MODE>mode))
1939 if (!(ISA_HAS_FP4 && flag_unsafe_math_optimizations))
1940 operands[1] = force_reg (<MODE>mode, operands[1]);
1943 ;; These patterns work around the early SB-1 rev2 core "F1" erratum:
1945 ;; If an mfc1 or dmfc1 happens to access the floating point register
1946 ;; file at the same time a long latency operation (div, sqrt, recip,
1947 ;; sqrt) iterates an intermediate result back through the floating
1948 ;; point register file bypass, then instead returning the correct
1949 ;; register value the mfc1 or dmfc1 operation returns the intermediate
1950 ;; result of the long latency operation.
1952 ;; The workaround is to insert an unconditional 'mov' from/to the
1953 ;; long latency op destination register.
1955 (define_insn "*div<mode>3"
1956 [(set (match_operand:ANYF 0 "register_operand" "=f")
1957 (div:ANYF (match_operand:ANYF 1 "register_operand" "f")
1958 (match_operand:ANYF 2 "register_operand" "f")))]
1959 "<divide_condition>"
1962 return "div.<fmt>\t%0,%1,%2\;mov.<fmt>\t%0,%0";
1964 return "div.<fmt>\t%0,%1,%2";
1966 [(set_attr "type" "fdiv")
1967 (set_attr "mode" "<UNITMODE>")
1968 (set (attr "length")
1969 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
1973 (define_insn "*recip<mode>3"
1974 [(set (match_operand:ANYF 0 "register_operand" "=f")
1975 (div:ANYF (match_operand:ANYF 1 "const_1_operand" "")
1976 (match_operand:ANYF 2 "register_operand" "f")))]
1977 "<recip_condition> && flag_unsafe_math_optimizations"
1980 return "recip.<fmt>\t%0,%2\;mov.<fmt>\t%0,%0";
1982 return "recip.<fmt>\t%0,%2";
1984 [(set_attr "type" "frdiv")
1985 (set_attr "mode" "<UNITMODE>")
1986 (set (attr "length")
1987 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
1991 ;; VR4120 errata MD(A1): signed division instructions do not work correctly
1992 ;; with negative operands. We use special libgcc functions instead.
1993 (define_insn "divmod<mode>4"
1994 [(set (match_operand:GPR 0 "register_operand" "=l")
1995 (div:GPR (match_operand:GPR 1 "register_operand" "d")
1996 (match_operand:GPR 2 "register_operand" "d")))
1997 (set (match_operand:GPR 3 "register_operand" "=h")
1998 (mod:GPR (match_dup 1)
2000 "!TARGET_FIX_VR4120"
2001 { return mips_output_division ("<d>div\t$0,%1,%2", operands); }
2002 [(set_attr "type" "idiv")
2003 (set_attr "mode" "<MODE>")])
2005 (define_insn "udivmod<mode>4"
2006 [(set (match_operand:GPR 0 "register_operand" "=l")
2007 (udiv:GPR (match_operand:GPR 1 "register_operand" "d")
2008 (match_operand:GPR 2 "register_operand" "d")))
2009 (set (match_operand:GPR 3 "register_operand" "=h")
2010 (umod:GPR (match_dup 1)
2013 { return mips_output_division ("<d>divu\t$0,%1,%2", operands); }
2014 [(set_attr "type" "idiv")
2015 (set_attr "mode" "<MODE>")])
2018 ;; ....................
2022 ;; ....................
2024 ;; These patterns work around the early SB-1 rev2 core "F1" erratum (see
2025 ;; "*div[sd]f3" comment for details).
2027 (define_insn "sqrt<mode>2"
2028 [(set (match_operand:ANYF 0 "register_operand" "=f")
2029 (sqrt:ANYF (match_operand:ANYF 1 "register_operand" "f")))]
2033 return "sqrt.<fmt>\t%0,%1\;mov.<fmt>\t%0,%0";
2035 return "sqrt.<fmt>\t%0,%1";
2037 [(set_attr "type" "fsqrt")
2038 (set_attr "mode" "<UNITMODE>")
2039 (set (attr "length")
2040 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
2044 (define_insn "*rsqrt<mode>a"
2045 [(set (match_operand:ANYF 0 "register_operand" "=f")
2046 (div:ANYF (match_operand:ANYF 1 "const_1_operand" "")
2047 (sqrt:ANYF (match_operand:ANYF 2 "register_operand" "f"))))]
2048 "<recip_condition> && flag_unsafe_math_optimizations"
2051 return "rsqrt.<fmt>\t%0,%2\;mov.<fmt>\t%0,%0";
2053 return "rsqrt.<fmt>\t%0,%2";
2055 [(set_attr "type" "frsqrt")
2056 (set_attr "mode" "<UNITMODE>")
2057 (set (attr "length")
2058 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
2062 (define_insn "*rsqrt<mode>b"
2063 [(set (match_operand:ANYF 0 "register_operand" "=f")
2064 (sqrt:ANYF (div:ANYF (match_operand:ANYF 1 "const_1_operand" "")
2065 (match_operand:ANYF 2 "register_operand" "f"))))]
2066 "<recip_condition> && flag_unsafe_math_optimizations"
2069 return "rsqrt.<fmt>\t%0,%2\;mov.<fmt>\t%0,%0";
2071 return "rsqrt.<fmt>\t%0,%2";
2073 [(set_attr "type" "frsqrt")
2074 (set_attr "mode" "<UNITMODE>")
2075 (set (attr "length")
2076 (if_then_else (ne (symbol_ref "TARGET_FIX_SB1") (const_int 0))
2081 ;; ....................
2085 ;; ....................
2087 ;; Do not use the integer abs macro instruction, since that signals an
2088 ;; exception on -2147483648 (sigh).
2090 ;; abs.fmt is an arithmetic instruction and treats all NaN inputs as
2091 ;; invalid; it does not clear their sign bits. We therefore can't use
2092 ;; abs.fmt if the signs of NaNs matter.
2094 (define_insn "abs<mode>2"
2095 [(set (match_operand:ANYF 0 "register_operand" "=f")
2096 (abs:ANYF (match_operand:ANYF 1 "register_operand" "f")))]
2097 "!HONOR_NANS (<MODE>mode)"
2099 [(set_attr "type" "fabs")
2100 (set_attr "mode" "<UNITMODE>")])
2103 ;; ...................
2105 ;; Count leading zeroes.
2107 ;; ...................
2110 (define_insn "clz<mode>2"
2111 [(set (match_operand:GPR 0 "register_operand" "=d")
2112 (clz:GPR (match_operand:GPR 1 "register_operand" "d")))]
2115 [(set_attr "type" "clz")
2116 (set_attr "mode" "<MODE>")])
2119 ;; ....................
2121 ;; NEGATION and ONE'S COMPLEMENT
2123 ;; ....................
2125 (define_insn "negsi2"
2126 [(set (match_operand:SI 0 "register_operand" "=d")
2127 (neg:SI (match_operand:SI 1 "register_operand" "d")))]
2131 return "neg\t%0,%1";
2133 return "subu\t%0,%.,%1";
2135 [(set_attr "type" "arith")
2136 (set_attr "mode" "SI")])
2138 (define_insn "negdi2"
2139 [(set (match_operand:DI 0 "register_operand" "=d")
2140 (neg:DI (match_operand:DI 1 "register_operand" "d")))]
2141 "TARGET_64BIT && !TARGET_MIPS16"
2143 [(set_attr "type" "arith")
2144 (set_attr "mode" "DI")])
2146 ;; neg.fmt is an arithmetic instruction and treats all NaN inputs as
2147 ;; invalid; it does not flip their sign bit. We therefore can't use
2148 ;; neg.fmt if the signs of NaNs matter.
2150 (define_insn "neg<mode>2"
2151 [(set (match_operand:ANYF 0 "register_operand" "=f")
2152 (neg:ANYF (match_operand:ANYF 1 "register_operand" "f")))]
2153 "!HONOR_NANS (<MODE>mode)"
2155 [(set_attr "type" "fneg")
2156 (set_attr "mode" "<UNITMODE>")])
2158 (define_insn "one_cmpl<mode>2"
2159 [(set (match_operand:GPR 0 "register_operand" "=d")
2160 (not:GPR (match_operand:GPR 1 "register_operand" "d")))]
2164 return "not\t%0,%1";
2166 return "nor\t%0,%.,%1";
2168 [(set_attr "type" "logical")
2169 (set_attr "mode" "<MODE>")])
2172 ;; ....................
2176 ;; ....................
2179 ;; Many of these instructions use trivial define_expands, because we
2180 ;; want to use a different set of constraints when TARGET_MIPS16.
2182 (define_expand "and<mode>3"
2183 [(set (match_operand:GPR 0 "register_operand")
2184 (and:GPR (match_operand:GPR 1 "register_operand")
2185 (match_operand:GPR 2 "uns_arith_operand")))]
2189 operands[2] = force_reg (<MODE>mode, operands[2]);
2192 (define_insn "*and<mode>3"
2193 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2194 (and:GPR (match_operand:GPR 1 "register_operand" "%d,d")
2195 (match_operand:GPR 2 "uns_arith_operand" "d,K")))]
2200 [(set_attr "type" "logical")
2201 (set_attr "mode" "<MODE>")])
2203 (define_insn "*and<mode>3_mips16"
2204 [(set (match_operand:GPR 0 "register_operand" "=d")
2205 (and:GPR (match_operand:GPR 1 "register_operand" "%0")
2206 (match_operand:GPR 2 "register_operand" "d")))]
2209 [(set_attr "type" "logical")
2210 (set_attr "mode" "<MODE>")])
2212 (define_expand "ior<mode>3"
2213 [(set (match_operand:GPR 0 "register_operand")
2214 (ior:GPR (match_operand:GPR 1 "register_operand")
2215 (match_operand:GPR 2 "uns_arith_operand")))]
2219 operands[2] = force_reg (<MODE>mode, operands[2]);
2222 (define_insn "*ior<mode>3"
2223 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2224 (ior:GPR (match_operand:GPR 1 "register_operand" "%d,d")
2225 (match_operand:GPR 2 "uns_arith_operand" "d,K")))]
2230 [(set_attr "type" "logical")
2231 (set_attr "mode" "<MODE>")])
2233 (define_insn "*ior<mode>3_mips16"
2234 [(set (match_operand:GPR 0 "register_operand" "=d")
2235 (ior:GPR (match_operand:GPR 1 "register_operand" "%0")
2236 (match_operand:GPR 2 "register_operand" "d")))]
2239 [(set_attr "type" "logical")
2240 (set_attr "mode" "<MODE>")])
2242 (define_expand "xor<mode>3"
2243 [(set (match_operand:GPR 0 "register_operand")
2244 (xor:GPR (match_operand:GPR 1 "register_operand")
2245 (match_operand:GPR 2 "uns_arith_operand")))]
2250 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2251 (xor:GPR (match_operand:GPR 1 "register_operand" "%d,d")
2252 (match_operand:GPR 2 "uns_arith_operand" "d,K")))]
2257 [(set_attr "type" "logical")
2258 (set_attr "mode" "<MODE>")])
2261 [(set (match_operand:GPR 0 "register_operand" "=d,t,t")
2262 (xor:GPR (match_operand:GPR 1 "register_operand" "%0,d,d")
2263 (match_operand:GPR 2 "uns_arith_operand" "d,K,d")))]
2269 [(set_attr "type" "logical,arith,arith")
2270 (set_attr "mode" "<MODE>")
2271 (set_attr_alternative "length"
2273 (if_then_else (match_operand:VOID 2 "m16_uimm8_1")
2278 (define_insn "*nor<mode>3"
2279 [(set (match_operand:GPR 0 "register_operand" "=d")
2280 (and:GPR (not:GPR (match_operand:GPR 1 "register_operand" "d"))
2281 (not:GPR (match_operand:GPR 2 "register_operand" "d"))))]
2284 [(set_attr "type" "logical")
2285 (set_attr "mode" "<MODE>")])
2288 ;; ....................
2292 ;; ....................
2296 (define_insn "truncdfsf2"
2297 [(set (match_operand:SF 0 "register_operand" "=f")
2298 (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
2299 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2301 [(set_attr "type" "fcvt")
2302 (set_attr "cnv_mode" "D2S")
2303 (set_attr "mode" "SF")])
2305 ;; Integer truncation patterns. Truncating SImode values to smaller
2306 ;; modes is a no-op, as it is for most other GCC ports. Truncating
2307 ;; DImode values to SImode is not a no-op for TARGET_64BIT since we
2308 ;; need to make sure that the lower 32 bits are properly sign-extended
2309 ;; (see TRULY_NOOP_TRUNCATION). Truncating DImode values into modes
2310 ;; smaller than SImode is equivalent to two separate truncations:
2313 ;; DI ---> HI == DI ---> SI ---> HI
2314 ;; DI ---> QI == DI ---> SI ---> QI
2316 ;; Step A needs a real instruction but step B does not.
2318 (define_insn "truncdisi2"
2319 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,m")
2320 (truncate:SI (match_operand:DI 1 "register_operand" "d,d")))]
2325 [(set_attr "type" "shift,store")
2326 (set_attr "mode" "SI")
2327 (set_attr "extended_mips16" "yes,*")])
2329 (define_insn "truncdihi2"
2330 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,m")
2331 (truncate:HI (match_operand:DI 1 "register_operand" "d,d")))]
2336 [(set_attr "type" "shift,store")
2337 (set_attr "mode" "SI")
2338 (set_attr "extended_mips16" "yes,*")])
2340 (define_insn "truncdiqi2"
2341 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,m")
2342 (truncate:QI (match_operand:DI 1 "register_operand" "d,d")))]
2347 [(set_attr "type" "shift,store")
2348 (set_attr "mode" "SI")
2349 (set_attr "extended_mips16" "yes,*")])
2351 ;; Combiner patterns to optimize shift/truncate combinations.
2354 [(set (match_operand:SUBDI 0 "register_operand" "=d")
2356 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
2357 (match_operand:DI 2 "const_arith_operand" ""))))]
2358 "TARGET_64BIT && !TARGET_MIPS16 && INTVAL (operands[2]) >= 32"
2360 [(set_attr "type" "shift")
2361 (set_attr "mode" "SI")])
2364 [(set (match_operand:SUBDI 0 "register_operand" "=d")
2366 (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
2368 "TARGET_64BIT && !TARGET_MIPS16"
2370 [(set_attr "type" "shift")
2371 (set_attr "mode" "SI")])
2374 ;; Combiner patterns for truncate/sign_extend combinations. The SI versions
2375 ;; use the shift/truncate patterns above.
2377 (define_insn_and_split "*extenddi_truncate<mode>"
2378 [(set (match_operand:DI 0 "register_operand" "=d")
2380 (truncate:SHORT (match_operand:DI 1 "register_operand" "d"))))]
2381 "TARGET_64BIT && !TARGET_MIPS16"
2383 "&& reload_completed"
2385 (ashift:DI (match_dup 1)
2388 (ashiftrt:DI (match_dup 2)
2391 operands[2] = gen_lowpart (DImode, operands[0]);
2392 operands[3] = GEN_INT (BITS_PER_WORD - GET_MODE_BITSIZE (<MODE>mode));
2395 (define_insn_and_split "*extendsi_truncate<mode>"
2396 [(set (match_operand:SI 0 "register_operand" "=d")
2398 (truncate:SHORT (match_operand:DI 1 "register_operand" "d"))))]
2399 "TARGET_64BIT && !TARGET_MIPS16"
2401 "&& reload_completed"
2403 (ashift:DI (match_dup 1)
2406 (truncate:SI (ashiftrt:DI (match_dup 2)
2409 operands[2] = gen_lowpart (DImode, operands[0]);
2410 operands[3] = GEN_INT (BITS_PER_WORD - GET_MODE_BITSIZE (<MODE>mode));
2413 ;; Combiner patterns to optimize truncate/zero_extend combinations.
2415 (define_insn "*zero_extend<mode>_trunchi"
2416 [(set (match_operand:GPR 0 "register_operand" "=d")
2418 (truncate:HI (match_operand:DI 1 "register_operand" "d"))))]
2419 "TARGET_64BIT && !TARGET_MIPS16"
2420 "andi\t%0,%1,0xffff"
2421 [(set_attr "type" "logical")
2422 (set_attr "mode" "<MODE>")])
2424 (define_insn "*zero_extend<mode>_truncqi"
2425 [(set (match_operand:GPR 0 "register_operand" "=d")
2427 (truncate:QI (match_operand:DI 1 "register_operand" "d"))))]
2428 "TARGET_64BIT && !TARGET_MIPS16"
2430 [(set_attr "type" "logical")
2431 (set_attr "mode" "<MODE>")])
2434 [(set (match_operand:HI 0 "register_operand" "=d")
2436 (truncate:QI (match_operand:DI 1 "register_operand" "d"))))]
2437 "TARGET_64BIT && !TARGET_MIPS16"
2439 [(set_attr "type" "logical")
2440 (set_attr "mode" "HI")])
2443 ;; ....................
2447 ;; ....................
2451 (define_insn_and_split "zero_extendsidi2"
2452 [(set (match_operand:DI 0 "register_operand" "=d,d")
2453 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,W")))]
2458 "&& reload_completed && REG_P (operands[1])"
2460 (ashift:DI (match_dup 1) (const_int 32)))
2462 (lshiftrt:DI (match_dup 0) (const_int 32)))]
2463 { operands[1] = gen_lowpart (DImode, operands[1]); }
2464 [(set_attr "type" "multi,load")
2465 (set_attr "mode" "DI")
2466 (set_attr "length" "8,*")])
2468 ;; Combine is not allowed to convert this insn into a zero_extendsidi2
2469 ;; because of TRULY_NOOP_TRUNCATION.
2471 (define_insn_and_split "*clear_upper32"
2472 [(set (match_operand:DI 0 "register_operand" "=d,d")
2473 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,W")
2474 (const_int 4294967295)))]
2477 if (which_alternative == 0)
2480 operands[1] = gen_lowpart (SImode, operands[1]);
2481 return "lwu\t%0,%1";
2483 "&& reload_completed && REG_P (operands[1])"
2485 (ashift:DI (match_dup 1) (const_int 32)))
2487 (lshiftrt:DI (match_dup 0) (const_int 32)))]
2489 [(set_attr "type" "multi,load")
2490 (set_attr "mode" "DI")
2491 (set_attr "length" "8,*")])
2493 (define_expand "zero_extend<SHORT:mode><GPR:mode>2"
2494 [(set (match_operand:GPR 0 "register_operand")
2495 (zero_extend:GPR (match_operand:SHORT 1 "nonimmediate_operand")))]
2498 if (TARGET_MIPS16 && !GENERATE_MIPS16E
2499 && !memory_operand (operands[1], <SHORT:MODE>mode))
2501 emit_insn (gen_and<GPR:mode>3 (operands[0],
2502 gen_lowpart (<GPR:MODE>mode, operands[1]),
2503 force_reg (<GPR:MODE>mode,
2504 GEN_INT (<SHORT:mask>))));
2509 (define_insn "*zero_extend<SHORT:mode><GPR:mode>2"
2510 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2512 (match_operand:SHORT 1 "nonimmediate_operand" "d,m")))]
2515 andi\t%0,%1,<SHORT:mask>
2516 l<SHORT:size>u\t%0,%1"
2517 [(set_attr "type" "logical,load")
2518 (set_attr "mode" "<GPR:MODE>")])
2520 (define_insn "*zero_extend<SHORT:mode><GPR:mode>2_mips16e"
2521 [(set (match_operand:GPR 0 "register_operand" "=d")
2522 (zero_extend:GPR (match_operand:SHORT 1 "register_operand" "0")))]
2524 "ze<SHORT:size>\t%0"
2525 [(set_attr "type" "arith")
2526 (set_attr "mode" "<GPR:MODE>")])
2528 (define_insn "*zero_extend<SHORT:mode><GPR:mode>2_mips16"
2529 [(set (match_operand:GPR 0 "register_operand" "=d")
2530 (zero_extend:GPR (match_operand:SHORT 1 "memory_operand" "m")))]
2532 "l<SHORT:size>u\t%0,%1"
2533 [(set_attr "type" "load")
2534 (set_attr "mode" "<GPR:MODE>")])
2536 (define_expand "zero_extendqihi2"
2537 [(set (match_operand:HI 0 "register_operand")
2538 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand")))]
2541 if (TARGET_MIPS16 && !memory_operand (operands[1], QImode))
2543 emit_insn (gen_zero_extendqisi2 (gen_lowpart (SImode, operands[0]),
2549 (define_insn "*zero_extendqihi2"
2550 [(set (match_operand:HI 0 "register_operand" "=d,d")
2551 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
2556 [(set_attr "type" "logical,load")
2557 (set_attr "mode" "HI")])
2559 (define_insn "*zero_extendqihi2_mips16"
2560 [(set (match_operand:HI 0 "register_operand" "=d")
2561 (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
2564 [(set_attr "type" "load")
2565 (set_attr "mode" "HI")])
2568 ;; ....................
2572 ;; ....................
2575 ;; Those for integer source operand are ordered widest source type first.
2577 ;; When TARGET_64BIT, all SImode integer registers should already be in
2578 ;; sign-extended form (see TRULY_NOOP_TRUNCATION and truncdisi2). We can
2579 ;; therefore get rid of register->register instructions if we constrain
2580 ;; the source to be in the same register as the destination.
2582 ;; The register alternative has type "arith" so that the pre-reload
2583 ;; scheduler will treat it as a move. This reflects what happens if
2584 ;; the register alternative needs a reload.
2585 (define_insn_and_split "extendsidi2"
2586 [(set (match_operand:DI 0 "register_operand" "=d,d")
2587 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "0,m")))]
2592 "&& reload_completed && register_operand (operands[1], VOIDmode)"
2595 emit_note (NOTE_INSN_DELETED);
2598 [(set_attr "type" "arith,load")
2599 (set_attr "mode" "DI")])
2601 (define_expand "extend<SHORT:mode><GPR:mode>2"
2602 [(set (match_operand:GPR 0 "register_operand")
2603 (sign_extend:GPR (match_operand:SHORT 1 "nonimmediate_operand")))]
2606 (define_insn "*extend<SHORT:mode><GPR:mode>2_mips16e"
2607 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2608 (sign_extend:GPR (match_operand:SHORT 1 "nonimmediate_operand" "0,m")))]
2612 l<SHORT:size>\t%0,%1"
2613 [(set_attr "type" "signext,load")
2614 (set_attr "mode" "<GPR:MODE>")])
2616 (define_insn_and_split "*extend<SHORT:mode><GPR:mode>2"
2617 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2619 (match_operand:SHORT 1 "nonimmediate_operand" "d,m")))]
2620 "!ISA_HAS_SEB_SEH && !GENERATE_MIPS16E"
2623 l<SHORT:size>\t%0,%1"
2624 "&& reload_completed && REG_P (operands[1])"
2625 [(set (match_dup 0) (ashift:GPR (match_dup 1) (match_dup 2)))
2626 (set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))]
2628 operands[1] = gen_lowpart (<GPR:MODE>mode, operands[1]);
2629 operands[2] = GEN_INT (GET_MODE_BITSIZE (<GPR:MODE>mode)
2630 - GET_MODE_BITSIZE (<SHORT:MODE>mode));
2632 [(set_attr "type" "arith,load")
2633 (set_attr "mode" "<GPR:MODE>")
2634 (set_attr "length" "8,*")])
2636 (define_insn "*extend<SHORT:mode><GPR:mode>2_se<SHORT:size>"
2637 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2639 (match_operand:SHORT 1 "nonimmediate_operand" "d,m")))]
2642 se<SHORT:size>\t%0,%1
2643 l<SHORT:size>\t%0,%1"
2644 [(set_attr "type" "signext,load")
2645 (set_attr "mode" "<GPR:MODE>")])
2647 (define_expand "extendqihi2"
2648 [(set (match_operand:HI 0 "register_operand")
2649 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand")))]
2652 (define_insn "*extendqihi2_mips16e"
2653 [(set (match_operand:HI 0 "register_operand" "=d,d")
2654 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0,m")))]
2659 [(set_attr "type" "signext,load")
2660 (set_attr "mode" "SI")])
2662 (define_insn_and_split "*extendqihi2"
2663 [(set (match_operand:HI 0 "register_operand" "=d,d")
2665 (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
2666 "!ISA_HAS_SEB_SEH && !GENERATE_MIPS16E"
2670 "&& reload_completed && REG_P (operands[1])"
2671 [(set (match_dup 0) (ashift:SI (match_dup 1) (match_dup 2)))
2672 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (match_dup 2)))]
2674 operands[0] = gen_lowpart (SImode, operands[0]);
2675 operands[1] = gen_lowpart (SImode, operands[1]);
2676 operands[2] = GEN_INT (GET_MODE_BITSIZE (SImode)
2677 - GET_MODE_BITSIZE (QImode));
2679 [(set_attr "type" "multi,load")
2680 (set_attr "mode" "SI")
2681 (set_attr "length" "8,*")])
2683 (define_insn "*extendqihi2_seb"
2684 [(set (match_operand:HI 0 "register_operand" "=d,d")
2686 (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
2691 [(set_attr "type" "signext,load")
2692 (set_attr "mode" "SI")])
2694 (define_insn "extendsfdf2"
2695 [(set (match_operand:DF 0 "register_operand" "=f")
2696 (float_extend:DF (match_operand:SF 1 "register_operand" "f")))]
2697 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2699 [(set_attr "type" "fcvt")
2700 (set_attr "cnv_mode" "S2D")
2701 (set_attr "mode" "DF")])
2704 ;; ....................
2708 ;; ....................
2710 (define_expand "fix_truncdfsi2"
2711 [(set (match_operand:SI 0 "register_operand")
2712 (fix:SI (match_operand:DF 1 "register_operand")))]
2713 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2715 if (!ISA_HAS_TRUNC_W)
2717 emit_insn (gen_fix_truncdfsi2_macro (operands[0], operands[1]));
2722 (define_insn "fix_truncdfsi2_insn"
2723 [(set (match_operand:SI 0 "register_operand" "=f")
2724 (fix:SI (match_operand:DF 1 "register_operand" "f")))]
2725 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && ISA_HAS_TRUNC_W"
2727 [(set_attr "type" "fcvt")
2728 (set_attr "mode" "DF")
2729 (set_attr "cnv_mode" "D2I")
2730 (set_attr "length" "4")])
2732 (define_insn "fix_truncdfsi2_macro"
2733 [(set (match_operand:SI 0 "register_operand" "=f")
2734 (fix:SI (match_operand:DF 1 "register_operand" "f")))
2735 (clobber (match_scratch:DF 2 "=d"))]
2736 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !ISA_HAS_TRUNC_W"
2739 return ".set\tmacro\;trunc.w.d %0,%1,%2\;.set\tnomacro";
2741 return "trunc.w.d %0,%1,%2";
2743 [(set_attr "type" "fcvt")
2744 (set_attr "mode" "DF")
2745 (set_attr "cnv_mode" "D2I")
2746 (set_attr "length" "36")])
2748 (define_expand "fix_truncsfsi2"
2749 [(set (match_operand:SI 0 "register_operand")
2750 (fix:SI (match_operand:SF 1 "register_operand")))]
2753 if (!ISA_HAS_TRUNC_W)
2755 emit_insn (gen_fix_truncsfsi2_macro (operands[0], operands[1]));
2760 (define_insn "fix_truncsfsi2_insn"
2761 [(set (match_operand:SI 0 "register_operand" "=f")
2762 (fix:SI (match_operand:SF 1 "register_operand" "f")))]
2763 "TARGET_HARD_FLOAT && ISA_HAS_TRUNC_W"
2765 [(set_attr "type" "fcvt")
2766 (set_attr "mode" "SF")
2767 (set_attr "cnv_mode" "S2I")
2768 (set_attr "length" "4")])
2770 (define_insn "fix_truncsfsi2_macro"
2771 [(set (match_operand:SI 0 "register_operand" "=f")
2772 (fix:SI (match_operand:SF 1 "register_operand" "f")))
2773 (clobber (match_scratch:SF 2 "=d"))]
2774 "TARGET_HARD_FLOAT && !ISA_HAS_TRUNC_W"
2777 return ".set\tmacro\;trunc.w.s %0,%1,%2\;.set\tnomacro";
2779 return "trunc.w.s %0,%1,%2";
2781 [(set_attr "type" "fcvt")
2782 (set_attr "mode" "SF")
2783 (set_attr "cnv_mode" "S2I")
2784 (set_attr "length" "36")])
2787 (define_insn "fix_truncdfdi2"
2788 [(set (match_operand:DI 0 "register_operand" "=f")
2789 (fix:DI (match_operand:DF 1 "register_operand" "f")))]
2790 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
2792 [(set_attr "type" "fcvt")
2793 (set_attr "mode" "DF")
2794 (set_attr "cnv_mode" "D2I")
2795 (set_attr "length" "4")])
2798 (define_insn "fix_truncsfdi2"
2799 [(set (match_operand:DI 0 "register_operand" "=f")
2800 (fix:DI (match_operand:SF 1 "register_operand" "f")))]
2801 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
2803 [(set_attr "type" "fcvt")
2804 (set_attr "mode" "SF")
2805 (set_attr "cnv_mode" "S2I")
2806 (set_attr "length" "4")])
2809 (define_insn "floatsidf2"
2810 [(set (match_operand:DF 0 "register_operand" "=f")
2811 (float:DF (match_operand:SI 1 "register_operand" "f")))]
2812 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2814 [(set_attr "type" "fcvt")
2815 (set_attr "mode" "DF")
2816 (set_attr "cnv_mode" "I2D")
2817 (set_attr "length" "4")])
2820 (define_insn "floatdidf2"
2821 [(set (match_operand:DF 0 "register_operand" "=f")
2822 (float:DF (match_operand:DI 1 "register_operand" "f")))]
2823 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
2825 [(set_attr "type" "fcvt")
2826 (set_attr "mode" "DF")
2827 (set_attr "cnv_mode" "I2D")
2828 (set_attr "length" "4")])
2831 (define_insn "floatsisf2"
2832 [(set (match_operand:SF 0 "register_operand" "=f")
2833 (float:SF (match_operand:SI 1 "register_operand" "f")))]
2836 [(set_attr "type" "fcvt")
2837 (set_attr "mode" "SF")
2838 (set_attr "cnv_mode" "I2S")
2839 (set_attr "length" "4")])
2842 (define_insn "floatdisf2"
2843 [(set (match_operand:SF 0 "register_operand" "=f")
2844 (float:SF (match_operand:DI 1 "register_operand" "f")))]
2845 "TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT"
2847 [(set_attr "type" "fcvt")
2848 (set_attr "mode" "SF")
2849 (set_attr "cnv_mode" "I2S")
2850 (set_attr "length" "4")])
2853 (define_expand "fixuns_truncdfsi2"
2854 [(set (match_operand:SI 0 "register_operand")
2855 (unsigned_fix:SI (match_operand:DF 1 "register_operand")))]
2856 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
2858 rtx reg1 = gen_reg_rtx (DFmode);
2859 rtx reg2 = gen_reg_rtx (DFmode);
2860 rtx reg3 = gen_reg_rtx (SImode);
2861 rtx label1 = gen_label_rtx ();
2862 rtx label2 = gen_label_rtx ();
2863 REAL_VALUE_TYPE offset;
2865 real_2expN (&offset, 31, DFmode);
2867 if (reg1) /* Turn off complaints about unreached code. */
2869 mips_emit_move (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, DFmode));
2870 do_pending_stack_adjust ();
2872 emit_insn (gen_cmpdf (operands[1], reg1));
2873 emit_jump_insn (gen_bge (label1));
2875 emit_insn (gen_fix_truncdfsi2 (operands[0], operands[1]));
2876 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
2877 gen_rtx_LABEL_REF (VOIDmode, label2)));
2880 emit_label (label1);
2881 mips_emit_move (reg2, gen_rtx_MINUS (DFmode, operands[1], reg1));
2882 mips_emit_move (reg3, GEN_INT (trunc_int_for_mode
2883 (BITMASK_HIGH, SImode)));
2885 emit_insn (gen_fix_truncdfsi2 (operands[0], reg2));
2886 emit_insn (gen_iorsi3 (operands[0], operands[0], reg3));
2888 emit_label (label2);
2890 /* Allow REG_NOTES to be set on last insn (labels don't have enough
2891 fields, and can't be used for REG_NOTES anyway). */
2892 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
2898 (define_expand "fixuns_truncdfdi2"
2899 [(set (match_operand:DI 0 "register_operand")
2900 (unsigned_fix:DI (match_operand:DF 1 "register_operand")))]
2901 "TARGET_HARD_FLOAT && TARGET_64BIT && TARGET_DOUBLE_FLOAT"
2903 rtx reg1 = gen_reg_rtx (DFmode);
2904 rtx reg2 = gen_reg_rtx (DFmode);
2905 rtx reg3 = gen_reg_rtx (DImode);
2906 rtx label1 = gen_label_rtx ();
2907 rtx label2 = gen_label_rtx ();
2908 REAL_VALUE_TYPE offset;
2910 real_2expN (&offset, 63, DFmode);
2912 mips_emit_move (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, DFmode));
2913 do_pending_stack_adjust ();
2915 emit_insn (gen_cmpdf (operands[1], reg1));
2916 emit_jump_insn (gen_bge (label1));
2918 emit_insn (gen_fix_truncdfdi2 (operands[0], operands[1]));
2919 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
2920 gen_rtx_LABEL_REF (VOIDmode, label2)));
2923 emit_label (label1);
2924 mips_emit_move (reg2, gen_rtx_MINUS (DFmode, operands[1], reg1));
2925 mips_emit_move (reg3, GEN_INT (BITMASK_HIGH));
2926 emit_insn (gen_ashldi3 (reg3, reg3, GEN_INT (32)));
2928 emit_insn (gen_fix_truncdfdi2 (operands[0], reg2));
2929 emit_insn (gen_iordi3 (operands[0], operands[0], reg3));
2931 emit_label (label2);
2933 /* Allow REG_NOTES to be set on last insn (labels don't have enough
2934 fields, and can't be used for REG_NOTES anyway). */
2935 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
2940 (define_expand "fixuns_truncsfsi2"
2941 [(set (match_operand:SI 0 "register_operand")
2942 (unsigned_fix:SI (match_operand:SF 1 "register_operand")))]
2945 rtx reg1 = gen_reg_rtx (SFmode);
2946 rtx reg2 = gen_reg_rtx (SFmode);
2947 rtx reg3 = gen_reg_rtx (SImode);
2948 rtx label1 = gen_label_rtx ();
2949 rtx label2 = gen_label_rtx ();
2950 REAL_VALUE_TYPE offset;
2952 real_2expN (&offset, 31, SFmode);
2954 mips_emit_move (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, SFmode));
2955 do_pending_stack_adjust ();
2957 emit_insn (gen_cmpsf (operands[1], reg1));
2958 emit_jump_insn (gen_bge (label1));
2960 emit_insn (gen_fix_truncsfsi2 (operands[0], operands[1]));
2961 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
2962 gen_rtx_LABEL_REF (VOIDmode, label2)));
2965 emit_label (label1);
2966 mips_emit_move (reg2, gen_rtx_MINUS (SFmode, operands[1], reg1));
2967 mips_emit_move (reg3, GEN_INT (trunc_int_for_mode
2968 (BITMASK_HIGH, SImode)));
2970 emit_insn (gen_fix_truncsfsi2 (operands[0], reg2));
2971 emit_insn (gen_iorsi3 (operands[0], operands[0], reg3));
2973 emit_label (label2);
2975 /* Allow REG_NOTES to be set on last insn (labels don't have enough
2976 fields, and can't be used for REG_NOTES anyway). */
2977 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
2982 (define_expand "fixuns_truncsfdi2"
2983 [(set (match_operand:DI 0 "register_operand")
2984 (unsigned_fix:DI (match_operand:SF 1 "register_operand")))]
2985 "TARGET_HARD_FLOAT && TARGET_64BIT && TARGET_DOUBLE_FLOAT"
2987 rtx reg1 = gen_reg_rtx (SFmode);
2988 rtx reg2 = gen_reg_rtx (SFmode);
2989 rtx reg3 = gen_reg_rtx (DImode);
2990 rtx label1 = gen_label_rtx ();
2991 rtx label2 = gen_label_rtx ();
2992 REAL_VALUE_TYPE offset;
2994 real_2expN (&offset, 63, SFmode);
2996 mips_emit_move (reg1, CONST_DOUBLE_FROM_REAL_VALUE (offset, SFmode));
2997 do_pending_stack_adjust ();
2999 emit_insn (gen_cmpsf (operands[1], reg1));
3000 emit_jump_insn (gen_bge (label1));
3002 emit_insn (gen_fix_truncsfdi2 (operands[0], operands[1]));
3003 emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
3004 gen_rtx_LABEL_REF (VOIDmode, label2)));
3007 emit_label (label1);
3008 mips_emit_move (reg2, gen_rtx_MINUS (SFmode, operands[1], reg1));
3009 mips_emit_move (reg3, GEN_INT (BITMASK_HIGH));
3010 emit_insn (gen_ashldi3 (reg3, reg3, GEN_INT (32)));
3012 emit_insn (gen_fix_truncsfdi2 (operands[0], reg2));
3013 emit_insn (gen_iordi3 (operands[0], operands[0], reg3));
3015 emit_label (label2);
3017 /* Allow REG_NOTES to be set on last insn (labels don't have enough
3018 fields, and can't be used for REG_NOTES anyway). */
3019 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
3024 ;; ....................
3028 ;; ....................
3030 ;; Bit field extract patterns which use lwl/lwr or ldl/ldr.
3032 (define_expand "extv"
3033 [(set (match_operand 0 "register_operand")
3034 (sign_extract (match_operand:QI 1 "memory_operand")
3035 (match_operand 2 "immediate_operand")
3036 (match_operand 3 "immediate_operand")))]
3039 if (mips_expand_ext_as_unaligned_load (operands[0], operands[1],
3040 INTVAL (operands[2]),
3041 INTVAL (operands[3])))
3047 (define_expand "extzv"
3048 [(set (match_operand 0 "register_operand")
3049 (zero_extract (match_operand 1 "nonimmediate_operand")
3050 (match_operand 2 "immediate_operand")
3051 (match_operand 3 "immediate_operand")))]
3054 if (mips_expand_ext_as_unaligned_load (operands[0], operands[1],
3055 INTVAL (operands[2]),
3056 INTVAL (operands[3])))
3058 else if (mips_use_ins_ext_p (operands[1], INTVAL (operands[2]),
3059 INTVAL (operands[3])))
3061 if (GET_MODE (operands[0]) == DImode)
3062 emit_insn (gen_extzvdi (operands[0], operands[1], operands[2],
3065 emit_insn (gen_extzvsi (operands[0], operands[1], operands[2],
3073 (define_insn "extzv<mode>"
3074 [(set (match_operand:GPR 0 "register_operand" "=d")
3075 (zero_extract:GPR (match_operand:GPR 1 "register_operand" "d")
3076 (match_operand:SI 2 "immediate_operand" "I")
3077 (match_operand:SI 3 "immediate_operand" "I")))]
3078 "mips_use_ins_ext_p (operands[1], INTVAL (operands[2]),
3079 INTVAL (operands[3]))"
3080 "<d>ext\t%0,%1,%3,%2"
3081 [(set_attr "type" "arith")
3082 (set_attr "mode" "<MODE>")])
3085 (define_expand "insv"
3086 [(set (zero_extract (match_operand 0 "nonimmediate_operand")
3087 (match_operand 1 "immediate_operand")
3088 (match_operand 2 "immediate_operand"))
3089 (match_operand 3 "reg_or_0_operand"))]
3092 if (mips_expand_ins_as_unaligned_store (operands[0], operands[3],
3093 INTVAL (operands[1]),
3094 INTVAL (operands[2])))
3096 else if (mips_use_ins_ext_p (operands[0], INTVAL (operands[1]),
3097 INTVAL (operands[2])))
3099 if (GET_MODE (operands[0]) == DImode)
3100 emit_insn (gen_insvdi (operands[0], operands[1], operands[2],
3103 emit_insn (gen_insvsi (operands[0], operands[1], operands[2],
3111 (define_insn "insv<mode>"
3112 [(set (zero_extract:GPR (match_operand:GPR 0 "register_operand" "+d")
3113 (match_operand:SI 1 "immediate_operand" "I")
3114 (match_operand:SI 2 "immediate_operand" "I"))
3115 (match_operand:GPR 3 "reg_or_0_operand" "dJ"))]
3116 "mips_use_ins_ext_p (operands[0], INTVAL (operands[1]),
3117 INTVAL (operands[2]))"
3118 "<d>ins\t%0,%z3,%2,%1"
3119 [(set_attr "type" "arith")
3120 (set_attr "mode" "<MODE>")])
3122 ;; Unaligned word moves generated by the bit field patterns.
3124 ;; As far as the rtl is concerned, both the left-part and right-part
3125 ;; instructions can access the whole field. However, the real operand
3126 ;; refers to just the first or the last byte (depending on endianness).
3127 ;; We therefore use two memory operands to each instruction, one to
3128 ;; describe the rtl effect and one to use in the assembly output.
3130 ;; Operands 0 and 1 are the rtl-level target and source respectively.
3131 ;; This allows us to use the standard length calculations for the "load"
3132 ;; and "store" type attributes.
3134 (define_insn "mov_<load>l"
3135 [(set (match_operand:GPR 0 "register_operand" "=d")
3136 (unspec:GPR [(match_operand:BLK 1 "memory_operand" "m")
3137 (match_operand:QI 2 "memory_operand" "m")]
3139 "!TARGET_MIPS16 && mips_mem_fits_mode_p (<MODE>mode, operands[1])"
3141 [(set_attr "type" "load")
3142 (set_attr "mode" "<MODE>")])
3144 (define_insn "mov_<load>r"
3145 [(set (match_operand:GPR 0 "register_operand" "=d")
3146 (unspec:GPR [(match_operand:BLK 1 "memory_operand" "m")
3147 (match_operand:QI 2 "memory_operand" "m")
3148 (match_operand:GPR 3 "register_operand" "0")]
3149 UNSPEC_LOAD_RIGHT))]
3150 "!TARGET_MIPS16 && mips_mem_fits_mode_p (<MODE>mode, operands[1])"
3152 [(set_attr "type" "load")
3153 (set_attr "mode" "<MODE>")])
3155 (define_insn "mov_<store>l"
3156 [(set (match_operand:BLK 0 "memory_operand" "=m")
3157 (unspec:BLK [(match_operand:GPR 1 "reg_or_0_operand" "dJ")
3158 (match_operand:QI 2 "memory_operand" "m")]
3159 UNSPEC_STORE_LEFT))]
3160 "!TARGET_MIPS16 && mips_mem_fits_mode_p (<MODE>mode, operands[0])"
3162 [(set_attr "type" "store")
3163 (set_attr "mode" "<MODE>")])
3165 (define_insn "mov_<store>r"
3166 [(set (match_operand:BLK 0 "memory_operand" "+m")
3167 (unspec:BLK [(match_operand:GPR 1 "reg_or_0_operand" "dJ")
3168 (match_operand:QI 2 "memory_operand" "m")
3170 UNSPEC_STORE_RIGHT))]
3171 "!TARGET_MIPS16 && mips_mem_fits_mode_p (<MODE>mode, operands[0])"
3173 [(set_attr "type" "store")
3174 (set_attr "mode" "<MODE>")])
3176 ;; An instruction to calculate the high part of a 64-bit SYMBOL_ABSOLUTE.
3177 ;; The required value is:
3179 ;; (%highest(op1) << 48) + (%higher(op1) << 32) + (%hi(op1) << 16)
3181 ;; which translates to:
3183 ;; lui op0,%highest(op1)
3184 ;; daddiu op0,op0,%higher(op1)
3186 ;; daddiu op0,op0,%hi(op1)
3189 ;; The split is deferred until after flow2 to allow the peephole2 below
3191 (define_insn_and_split "*lea_high64"
3192 [(set (match_operand:DI 0 "register_operand" "=d")
3193 (high:DI (match_operand:DI 1 "absolute_symbolic_operand" "")))]
3194 "TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS"
3196 "&& epilogue_completed"
3197 [(set (match_dup 0) (high:DI (match_dup 2)))
3198 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 2)))
3199 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 16)))
3200 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 3)))
3201 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 16)))]
3203 operands[2] = mips_unspec_address (operands[1], SYMBOL_64_HIGH);
3204 operands[3] = mips_unspec_address (operands[1], SYMBOL_64_MID);
3206 [(set_attr "length" "20")])
3208 ;; Use a scratch register to reduce the latency of the above pattern
3209 ;; on superscalar machines. The optimized sequence is:
3211 ;; lui op1,%highest(op2)
3213 ;; daddiu op1,op1,%higher(op2)
3215 ;; daddu op1,op1,op0
3217 [(set (match_operand:DI 1 "register_operand")
3218 (high:DI (match_operand:DI 2 "absolute_symbolic_operand")))
3219 (match_scratch:DI 0 "d")]
3220 "TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS"
3221 [(set (match_dup 1) (high:DI (match_dup 3)))
3222 (set (match_dup 0) (high:DI (match_dup 4)))
3223 (set (match_dup 1) (lo_sum:DI (match_dup 1) (match_dup 3)))
3224 (set (match_dup 1) (ashift:DI (match_dup 1) (const_int 32)))
3225 (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 0)))]
3227 operands[3] = mips_unspec_address (operands[2], SYMBOL_64_HIGH);
3228 operands[4] = mips_unspec_address (operands[2], SYMBOL_64_LOW);
3231 ;; On most targets, the expansion of (lo_sum (high X) X) for a 64-bit
3232 ;; SYMBOL_ABSOLUTE X will take 6 cycles. This next pattern allows combine
3233 ;; to merge the HIGH and LO_SUM parts of a move if the HIGH part is only
3234 ;; used once. We can then use the sequence:
3236 ;; lui op0,%highest(op1)
3238 ;; daddiu op0,op0,%higher(op1)
3239 ;; daddiu op2,op2,%lo(op1)
3241 ;; daddu op0,op0,op2
3243 ;; which takes 4 cycles on most superscalar targets.
3244 (define_insn_and_split "*lea64"
3245 [(set (match_operand:DI 0 "register_operand" "=d")
3246 (match_operand:DI 1 "absolute_symbolic_operand" ""))
3247 (clobber (match_scratch:DI 2 "=&d"))]
3248 "TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS && cse_not_expected"
3250 "&& reload_completed"
3251 [(set (match_dup 0) (high:DI (match_dup 3)))
3252 (set (match_dup 2) (high:DI (match_dup 4)))
3253 (set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 3)))
3254 (set (match_dup 2) (lo_sum:DI (match_dup 2) (match_dup 4)))
3255 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
3256 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))]
3258 operands[3] = mips_unspec_address (operands[1], SYMBOL_64_HIGH);
3259 operands[4] = mips_unspec_address (operands[1], SYMBOL_64_LOW);
3261 [(set_attr "length" "24")])
3263 ;; Split HIGHs into:
3268 ;; on MIPS16 targets.
3270 [(set (match_operand:SI 0 "register_operand" "=d")
3271 (high:SI (match_operand:SI 1 "absolute_symbolic_operand" "")))]
3272 "TARGET_MIPS16 && reload_completed"
3273 [(set (match_dup 0) (match_dup 2))
3274 (set (match_dup 0) (ashift:SI (match_dup 0) (const_int 16)))]
3276 operands[2] = mips_unspec_address (operands[1], SYMBOL_32_HIGH);
3279 ;; Insns to fetch a symbol from a big GOT.
3281 (define_insn_and_split "*xgot_hi<mode>"
3282 [(set (match_operand:P 0 "register_operand" "=d")
3283 (high:P (match_operand:P 1 "got_disp_operand" "")))]
3284 "TARGET_EXPLICIT_RELOCS && TARGET_XGOT"
3286 "&& reload_completed"
3287 [(set (match_dup 0) (high:P (match_dup 2)))
3288 (set (match_dup 0) (plus:P (match_dup 0) (match_dup 3)))]
3290 operands[2] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_DISP);
3291 operands[3] = pic_offset_table_rtx;
3293 [(set_attr "got" "xgot_high")
3294 (set_attr "mode" "<MODE>")])
3296 (define_insn_and_split "*xgot_lo<mode>"
3297 [(set (match_operand:P 0 "register_operand" "=d")
3298 (lo_sum:P (match_operand:P 1 "register_operand" "d")
3299 (match_operand:P 2 "got_disp_operand" "")))]
3300 "TARGET_EXPLICIT_RELOCS && TARGET_XGOT"
3302 "&& reload_completed"
3304 (unspec:P [(match_dup 1) (match_dup 3)] UNSPEC_LOAD_GOT))]
3305 { operands[3] = mips_unspec_address (operands[2], SYMBOL_GOTOFF_DISP); }
3306 [(set_attr "got" "load")
3307 (set_attr "mode" "<MODE>")])
3309 ;; Insns to fetch a symbol from a normal GOT.
3311 (define_insn_and_split "*got_disp<mode>"
3312 [(set (match_operand:P 0 "register_operand" "=d")
3313 (match_operand:P 1 "got_disp_operand" ""))]
3314 "TARGET_EXPLICIT_RELOCS && !TARGET_XGOT"
3316 "&& reload_completed"
3318 (unspec:P [(match_dup 2) (match_dup 3)] UNSPEC_LOAD_GOT))]
3320 operands[2] = pic_offset_table_rtx;
3321 operands[3] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_DISP);
3323 [(set_attr "got" "load")
3324 (set_attr "mode" "<MODE>")])
3326 ;; Insns for loading the "page" part of a page/ofst address from the GOT.
3328 (define_insn_and_split "*got_page<mode>"
3329 [(set (match_operand:P 0 "register_operand" "=d")
3330 (high:P (match_operand:P 1 "got_page_ofst_operand" "")))]
3331 "TARGET_EXPLICIT_RELOCS"
3333 "&& reload_completed"
3335 (unspec:P [(match_dup 2) (match_dup 3)] UNSPEC_LOAD_GOT))]
3337 operands[2] = pic_offset_table_rtx;
3338 operands[3] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_PAGE);
3340 [(set_attr "got" "load")
3341 (set_attr "mode" "<MODE>")])
3343 ;; Lower-level instructions for loading an address from the GOT.
3344 ;; We could use MEMs, but an unspec gives more optimization
3347 (define_insn "load_got<mode>"
3348 [(set (match_operand:P 0 "register_operand" "=d")
3349 (unspec:P [(match_operand:P 1 "register_operand" "d")
3350 (match_operand:P 2 "immediate_operand" "")]
3353 "<load>\t%0,%R2(%1)"
3354 [(set_attr "type" "load")
3355 (set_attr "mode" "<MODE>")
3356 (set_attr "length" "4")])
3358 ;; Instructions for adding the low 16 bits of an address to a register.
3359 ;; Operand 2 is the address: mips_print_operand works out which relocation
3360 ;; should be applied.
3362 (define_insn "*low<mode>"
3363 [(set (match_operand:P 0 "register_operand" "=d")
3364 (lo_sum:P (match_operand:P 1 "register_operand" "d")
3365 (match_operand:P 2 "immediate_operand" "")))]
3367 "<d>addiu\t%0,%1,%R2"
3368 [(set_attr "type" "arith")
3369 (set_attr "mode" "<MODE>")])
3371 (define_insn "*low<mode>_mips16"
3372 [(set (match_operand:P 0 "register_operand" "=d")
3373 (lo_sum:P (match_operand:P 1 "register_operand" "0")
3374 (match_operand:P 2 "immediate_operand" "")))]
3377 [(set_attr "type" "arith")
3378 (set_attr "mode" "<MODE>")
3379 (set_attr "length" "8")])
3381 ;; Allow combine to split complex const_int load sequences, using operand 2
3382 ;; to store the intermediate results. See move_operand for details.
3384 [(set (match_operand:GPR 0 "register_operand")
3385 (match_operand:GPR 1 "splittable_const_int_operand"))
3386 (clobber (match_operand:GPR 2 "register_operand"))]
3390 mips_move_integer (operands[2], operands[0], INTVAL (operands[1]));
3394 ;; Likewise, for symbolic operands.
3396 [(set (match_operand:P 0 "register_operand")
3397 (match_operand:P 1))
3398 (clobber (match_operand:P 2 "register_operand"))]
3399 "mips_split_symbol (operands[2], operands[1], MAX_MACHINE_MODE, NULL)"
3400 [(set (match_dup 0) (match_dup 3))]
3402 mips_split_symbol (operands[2], operands[1],
3403 MAX_MACHINE_MODE, &operands[3]);
3406 ;; 64-bit integer moves
3408 ;; Unlike most other insns, the move insns can't be split with
3409 ;; different predicates, because register spilling and other parts of
3410 ;; the compiler, have memoized the insn number already.
3412 (define_expand "movdi"
3413 [(set (match_operand:DI 0 "")
3414 (match_operand:DI 1 ""))]
3417 if (mips_legitimize_move (DImode, operands[0], operands[1]))
3421 ;; For mips16, we need a special case to handle storing $31 into
3422 ;; memory, since we don't have a constraint to match $31. This
3423 ;; instruction can be generated by save_restore_insns.
3425 (define_insn "*mov<mode>_ra"
3426 [(set (match_operand:GPR 0 "stack_operand" "=m")
3430 [(set_attr "type" "store")
3431 (set_attr "mode" "<MODE>")])
3433 (define_insn "*movdi_32bit"
3434 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,m,*a,*d,*B*C*D,*B*C*D,*d,*m")
3435 (match_operand:DI 1 "move_operand" "d,i,m,d,*J*d,*a,*d,*m,*B*C*D,*B*C*D"))]
3436 "!TARGET_64BIT && !TARGET_FLOAT64 && !TARGET_MIPS16
3437 && (register_operand (operands[0], DImode)
3438 || reg_or_0_operand (operands[1], DImode))"
3439 { return mips_output_move (operands[0], operands[1]); }
3440 [(set_attr "type" "multi,multi,load,store,mthilo,mfhilo,mtc,load,mfc,store")
3441 (set_attr "mode" "DI")
3442 (set_attr "length" "8,16,*,*,8,8,8,*,8,*")])
3444 (define_insn "*movdi_gp32_fp64"
3445 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,m,*a,*d,*f,*f,*d,*m")
3446 (match_operand:DI 1 "move_operand" "d,i,m,d,*J*d,*a,*J*d,*m,*f,*f"))]
3447 "!TARGET_64BIT && TARGET_FLOAT64 && !TARGET_MIPS16
3448 && (register_operand (operands[0], DImode)
3449 || reg_or_0_operand (operands[1], DImode))"
3450 { return mips_output_move (operands[0], operands[1]); }
3451 [(set_attr "type" "multi,multi,load,store,mthilo,mfhilo,mtc,fpload,mfc,fpstore")
3452 (set_attr "mode" "DI")
3453 (set_attr "length" "8,16,*,*,8,8,8,*,8,*")])
3455 (define_insn "*movdi_32bit_mips16"
3456 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m,*d")
3457 (match_operand:DI 1 "move_operand" "d,d,y,K,N,m,d,*x"))]
3458 "!TARGET_64BIT && TARGET_MIPS16
3459 && (register_operand (operands[0], DImode)
3460 || register_operand (operands[1], DImode))"
3461 { return mips_output_move (operands[0], operands[1]); }
3462 [(set_attr "type" "multi,multi,multi,multi,multi,load,store,mfhilo")
3463 (set_attr "mode" "DI")
3464 (set_attr "length" "8,8,8,8,12,*,*,8")])
3466 (define_insn "*movdi_64bit"
3467 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,e,d,m,*f,*f,*d,*m,*x,*B*C*D,*B*C*D,*d,*m")
3468 (match_operand:DI 1 "move_operand" "d,U,T,m,dJ,*d*J,*m,*f,*f,*J*d,*d,*m,*B*C*D,*B*C*D"))]
3469 "TARGET_64BIT && !TARGET_MIPS16
3470 && (register_operand (operands[0], DImode)
3471 || reg_or_0_operand (operands[1], DImode))"
3472 { return mips_output_move (operands[0], operands[1]); }
3473 [(set_attr "type" "move,const,const,load,store,mtc,fpload,mfc,fpstore,mthilo,mtc,load,mfc,store")
3474 (set_attr "mode" "DI")
3475 (set_attr "length" "4,*,*,*,*,4,*,4,*,4,8,*,8,*")])
3477 (define_insn "*movdi_64bit_mips16"
3478 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,y,d,d,d,d,d,d,m")
3479 (match_operand:DI 1 "move_operand" "d,d,y,K,N,kf,U,m,d"))]
3480 "TARGET_64BIT && TARGET_MIPS16
3481 && (register_operand (operands[0], DImode)
3482 || register_operand (operands[1], DImode))"
3483 { return mips_output_move (operands[0], operands[1]); }
3484 [(set_attr "type" "move,move,move,arith,arith,load,const,load,store")
3485 (set_attr "mode" "DI")
3486 (set_attr_alternative "length"
3490 (if_then_else (match_operand:VOID 1 "m16_uimm8_1")
3493 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1")
3499 (const_string "*")])])
3502 ;; On the mips16, we can split ld $r,N($r) into an add and a load,
3503 ;; when the original load is a 4 byte instruction but the add and the
3504 ;; load are 2 2 byte instructions.
3507 [(set (match_operand:DI 0 "register_operand")
3508 (mem:DI (plus:DI (match_dup 0)
3509 (match_operand:DI 1 "const_int_operand"))))]
3510 "TARGET_64BIT && TARGET_MIPS16 && reload_completed
3511 && !TARGET_DEBUG_D_MODE
3512 && REG_P (operands[0])
3513 && M16_REG_P (REGNO (operands[0]))
3514 && GET_CODE (operands[1]) == CONST_INT
3515 && ((INTVAL (operands[1]) < 0
3516 && INTVAL (operands[1]) >= -0x10)
3517 || (INTVAL (operands[1]) >= 32 * 8
3518 && INTVAL (operands[1]) <= 31 * 8 + 0x8)
3519 || (INTVAL (operands[1]) >= 0
3520 && INTVAL (operands[1]) < 32 * 8
3521 && (INTVAL (operands[1]) & 7) != 0))"
3522 [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1)))
3523 (set (match_dup 0) (mem:DI (plus:DI (match_dup 0) (match_dup 2))))]
3525 HOST_WIDE_INT val = INTVAL (operands[1]);
3528 operands[2] = const0_rtx;
3529 else if (val >= 32 * 8)
3533 operands[1] = GEN_INT (0x8 + off);
3534 operands[2] = GEN_INT (val - off - 0x8);
3540 operands[1] = GEN_INT (off);
3541 operands[2] = GEN_INT (val - off);
3545 ;; 32-bit Integer moves
3547 ;; Unlike most other insns, the move insns can't be split with
3548 ;; different predicates, because register spilling and other parts of
3549 ;; the compiler, have memoized the insn number already.
3551 (define_expand "movsi"
3552 [(set (match_operand:SI 0 "")
3553 (match_operand:SI 1 ""))]
3556 if (mips_legitimize_move (SImode, operands[0], operands[1]))
3560 ;; The difference between these two is whether or not ints are allowed
3561 ;; in FP registers (off by default, use -mdebugh to enable).
3563 (define_insn "*movsi_internal"
3564 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,e,d,m,*f,*f,*d,*m,*d,*z,*a,*d,*B*C*D,*B*C*D,*d,*m")
3565 (match_operand:SI 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"))]
3567 && (register_operand (operands[0], SImode)
3568 || reg_or_0_operand (operands[1], SImode))"
3569 { return mips_output_move (operands[0], operands[1]); }
3570 [(set_attr "type" "move,const,const,load,store,mtc,fpload,mfc,fpstore,mfc,mtc,mthilo,mfhilo,mtc,load,mfc,store")
3571 (set_attr "mode" "SI")
3572 (set_attr "length" "4,*,*,*,*,4,*,4,*,4,4,4,4,4,*,4,*")])
3574 (define_insn "*movsi_mips16"
3575 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,y,d,d,d,d,d,d,m")
3576 (match_operand:SI 1 "move_operand" "d,d,y,K,N,kf,U,m,d"))]
3578 && (register_operand (operands[0], SImode)
3579 || register_operand (operands[1], SImode))"
3580 { return mips_output_move (operands[0], operands[1]); }
3581 [(set_attr "type" "move,move,move,arith,arith,load,const,load,store")
3582 (set_attr "mode" "SI")
3583 (set_attr_alternative "length"
3587 (if_then_else (match_operand:VOID 1 "m16_uimm8_1")
3590 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1")
3596 (const_string "*")])])
3598 ;; On the mips16, we can split lw $r,N($r) into an add and a load,
3599 ;; when the original load is a 4 byte instruction but the add and the
3600 ;; load are 2 2 byte instructions.
3603 [(set (match_operand:SI 0 "register_operand")
3604 (mem:SI (plus:SI (match_dup 0)
3605 (match_operand:SI 1 "const_int_operand"))))]
3606 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
3607 && REG_P (operands[0])
3608 && M16_REG_P (REGNO (operands[0]))
3609 && GET_CODE (operands[1]) == CONST_INT
3610 && ((INTVAL (operands[1]) < 0
3611 && INTVAL (operands[1]) >= -0x80)
3612 || (INTVAL (operands[1]) >= 32 * 4
3613 && INTVAL (operands[1]) <= 31 * 4 + 0x7c)
3614 || (INTVAL (operands[1]) >= 0
3615 && INTVAL (operands[1]) < 32 * 4
3616 && (INTVAL (operands[1]) & 3) != 0))"
3617 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
3618 (set (match_dup 0) (mem:SI (plus:SI (match_dup 0) (match_dup 2))))]
3620 HOST_WIDE_INT val = INTVAL (operands[1]);
3623 operands[2] = const0_rtx;
3624 else if (val >= 32 * 4)
3628 operands[1] = GEN_INT (0x7c + off);
3629 operands[2] = GEN_INT (val - off - 0x7c);
3635 operands[1] = GEN_INT (off);
3636 operands[2] = GEN_INT (val - off);
3640 ;; On the mips16, we can split a load of certain constants into a load
3641 ;; and an add. This turns a 4 byte instruction into 2 2 byte
3645 [(set (match_operand:SI 0 "register_operand")
3646 (match_operand:SI 1 "const_int_operand"))]
3647 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
3648 && REG_P (operands[0])
3649 && M16_REG_P (REGNO (operands[0]))
3650 && GET_CODE (operands[1]) == CONST_INT
3651 && INTVAL (operands[1]) >= 0x100
3652 && INTVAL (operands[1]) <= 0xff + 0x7f"
3653 [(set (match_dup 0) (match_dup 1))
3654 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))]
3656 int val = INTVAL (operands[1]);
3658 operands[1] = GEN_INT (0xff);
3659 operands[2] = GEN_INT (val - 0xff);
3662 ;; This insn handles moving CCmode values. It's really just a
3663 ;; slightly simplified copy of movsi_internal2, with additional cases
3664 ;; to move a condition register to a general register and to move
3665 ;; between the general registers and the floating point registers.
3667 (define_insn "movcc"
3668 [(set (match_operand:CC 0 "nonimmediate_operand" "=d,*d,*d,*m,*d,*f,*f,*f,*m")
3669 (match_operand:CC 1 "general_operand" "z,*d,*m,*d,*f,*d,*f,*m,*f"))]
3670 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
3671 { return mips_output_move (operands[0], operands[1]); }
3672 [(set_attr "type" "multi,move,load,store,mfc,mtc,fmove,fpload,fpstore")
3673 (set_attr "mode" "SI")
3674 (set_attr "length" "8,4,*,*,4,4,4,*,*")])
3676 ;; Reload condition code registers. reload_incc and reload_outcc
3677 ;; both handle moves from arbitrary operands into condition code
3678 ;; registers. reload_incc handles the more common case in which
3679 ;; a source operand is constrained to be in a condition-code
3680 ;; register, but has not been allocated to one.
3682 ;; Sometimes, such as in movcc, we have a CCmode destination whose
3683 ;; constraints do not include 'z'. reload_outcc handles the case
3684 ;; when such an operand is allocated to a condition-code register.
3686 ;; Note that reloads from a condition code register to some
3687 ;; other location can be done using ordinary moves. Moving
3688 ;; into a GPR takes a single movcc, moving elsewhere takes
3689 ;; two. We can leave these cases to the generic reload code.
3690 (define_expand "reload_incc"
3691 [(set (match_operand:CC 0 "fcc_reload_operand" "=z")
3692 (match_operand:CC 1 "general_operand" ""))
3693 (clobber (match_operand:TF 2 "register_operand" "=&f"))]
3694 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
3696 mips_expand_fcc_reload (operands[0], operands[1], operands[2]);
3700 (define_expand "reload_outcc"
3701 [(set (match_operand:CC 0 "fcc_reload_operand" "=z")
3702 (match_operand:CC 1 "register_operand" ""))
3703 (clobber (match_operand:TF 2 "register_operand" "=&f"))]
3704 "ISA_HAS_8CC && TARGET_HARD_FLOAT"
3706 mips_expand_fcc_reload (operands[0], operands[1], operands[2]);
3710 ;; MIPS4 supports loading and storing a floating point register from
3711 ;; the sum of two general registers. We use two versions for each of
3712 ;; these four instructions: one where the two general registers are
3713 ;; SImode, and one where they are DImode. This is because general
3714 ;; registers will be in SImode when they hold 32-bit values, but,
3715 ;; since the 32-bit values are always sign extended, the [ls][wd]xc1
3716 ;; instructions will still work correctly.
3718 ;; ??? Perhaps it would be better to support these instructions by
3719 ;; modifying GO_IF_LEGITIMATE_ADDRESS and friends. However, since
3720 ;; these instructions can only be used to load and store floating
3721 ;; point registers, that would probably cause trouble in reload.
3723 (define_insn "*<ANYF:loadx>_<P:mode>"
3724 [(set (match_operand:ANYF 0 "register_operand" "=f")
3725 (mem:ANYF (plus:P (match_operand:P 1 "register_operand" "d")
3726 (match_operand:P 2 "register_operand" "d"))))]
3728 "<ANYF:loadx>\t%0,%1(%2)"
3729 [(set_attr "type" "fpidxload")
3730 (set_attr "mode" "<ANYF:UNITMODE>")])
3732 (define_insn "*<ANYF:storex>_<P:mode>"
3733 [(set (mem:ANYF (plus:P (match_operand:P 1 "register_operand" "d")
3734 (match_operand:P 2 "register_operand" "d")))
3735 (match_operand:ANYF 0 "register_operand" "f"))]
3737 "<ANYF:storex>\t%0,%1(%2)"
3738 [(set_attr "type" "fpidxstore")
3739 (set_attr "mode" "<ANYF:UNITMODE>")])
3741 ;; Scaled indexed address load.
3742 ;; Per md.texi, we only need to look for a pattern with multiply in the
3743 ;; address expression, not shift.
3745 (define_insn "*lwxs"
3746 [(set (match_operand:SI 0 "register_operand" "=d")
3747 (mem:SI (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d")
3749 (match_operand:SI 2 "register_operand" "d"))))]
3752 [(set_attr "type" "load")
3753 (set_attr "mode" "SI")
3754 (set_attr "length" "4")])
3756 ;; 16-bit Integer moves
3758 ;; Unlike most other insns, the move insns can't be split with
3759 ;; different predicates, because register spilling and other parts of
3760 ;; the compiler, have memoized the insn number already.
3761 ;; Unsigned loads are used because LOAD_EXTEND_OP returns ZERO_EXTEND.
3763 (define_expand "movhi"
3764 [(set (match_operand:HI 0 "")
3765 (match_operand:HI 1 ""))]
3768 if (mips_legitimize_move (HImode, operands[0], operands[1]))
3772 (define_insn "*movhi_internal"
3773 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,m,*x")
3774 (match_operand:HI 1 "move_operand" "d,I,m,dJ,*d"))]
3776 && (register_operand (operands[0], HImode)
3777 || reg_or_0_operand (operands[1], HImode))"
3784 [(set_attr "type" "move,arith,load,store,mthilo")
3785 (set_attr "mode" "HI")
3786 (set_attr "length" "4,4,*,*,4")])
3788 (define_insn "*movhi_mips16"
3789 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m")
3790 (match_operand:HI 1 "move_operand" "d,d,y,K,N,m,d"))]
3792 && (register_operand (operands[0], HImode)
3793 || register_operand (operands[1], HImode))"
3802 [(set_attr "type" "move,move,move,arith,arith,load,store")
3803 (set_attr "mode" "HI")
3804 (set_attr_alternative "length"
3808 (if_then_else (match_operand:VOID 1 "m16_uimm8_1")
3811 (if_then_else (match_operand:VOID 1 "m16_nuimm8_1")
3815 (const_string "*")])])
3818 ;; On the mips16, we can split lh $r,N($r) into an add and a load,
3819 ;; when the original load is a 4 byte instruction but the add and the
3820 ;; load are 2 2 byte instructions.
3823 [(set (match_operand:HI 0 "register_operand")
3824 (mem:HI (plus:SI (match_dup 0)
3825 (match_operand:SI 1 "const_int_operand"))))]
3826 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
3827 && REG_P (operands[0])
3828 && M16_REG_P (REGNO (operands[0]))
3829 && GET_CODE (operands[1]) == CONST_INT
3830 && ((INTVAL (operands[1]) < 0
3831 && INTVAL (operands[1]) >= -0x80)
3832 || (INTVAL (operands[1]) >= 32 * 2
3833 && INTVAL (operands[1]) <= 31 * 2 + 0x7e)
3834 || (INTVAL (operands[1]) >= 0
3835 && INTVAL (operands[1]) < 32 * 2
3836 && (INTVAL (operands[1]) & 1) != 0))"
3837 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
3838 (set (match_dup 0) (mem:HI (plus:SI (match_dup 0) (match_dup 2))))]
3840 HOST_WIDE_INT val = INTVAL (operands[1]);
3843 operands[2] = const0_rtx;
3844 else if (val >= 32 * 2)
3848 operands[1] = GEN_INT (0x7e + off);
3849 operands[2] = GEN_INT (val - off - 0x7e);
3855 operands[1] = GEN_INT (off);
3856 operands[2] = GEN_INT (val - off);
3860 ;; 8-bit Integer moves
3862 ;; Unlike most other insns, the move insns can't be split with
3863 ;; different predicates, because register spilling and other parts of
3864 ;; the compiler, have memoized the insn number already.
3865 ;; Unsigned loads are used because LOAD_EXTEND_OP returns ZERO_EXTEND.
3867 (define_expand "movqi"
3868 [(set (match_operand:QI 0 "")
3869 (match_operand:QI 1 ""))]
3872 if (mips_legitimize_move (QImode, operands[0], operands[1]))
3876 (define_insn "*movqi_internal"
3877 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,m,*x")
3878 (match_operand:QI 1 "move_operand" "d,I,m,dJ,*d"))]
3880 && (register_operand (operands[0], QImode)
3881 || reg_or_0_operand (operands[1], QImode))"
3888 [(set_attr "type" "move,arith,load,store,mthilo")
3889 (set_attr "mode" "QI")
3890 (set_attr "length" "4,4,*,*,4")])
3892 (define_insn "*movqi_mips16"
3893 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m")
3894 (match_operand:QI 1 "move_operand" "d,d,y,K,N,m,d"))]
3896 && (register_operand (operands[0], QImode)
3897 || register_operand (operands[1], QImode))"
3906 [(set_attr "type" "move,move,move,arith,arith,load,store")
3907 (set_attr "mode" "QI")
3908 (set_attr "length" "4,4,4,4,8,*,*")])
3910 ;; On the mips16, we can split lb $r,N($r) into an add and a load,
3911 ;; when the original load is a 4 byte instruction but the add and the
3912 ;; load are 2 2 byte instructions.
3915 [(set (match_operand:QI 0 "register_operand")
3916 (mem:QI (plus:SI (match_dup 0)
3917 (match_operand:SI 1 "const_int_operand"))))]
3918 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
3919 && REG_P (operands[0])
3920 && M16_REG_P (REGNO (operands[0]))
3921 && GET_CODE (operands[1]) == CONST_INT
3922 && ((INTVAL (operands[1]) < 0
3923 && INTVAL (operands[1]) >= -0x80)
3924 || (INTVAL (operands[1]) >= 32
3925 && INTVAL (operands[1]) <= 31 + 0x7f))"
3926 [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
3927 (set (match_dup 0) (mem:QI (plus:SI (match_dup 0) (match_dup 2))))]
3929 HOST_WIDE_INT val = INTVAL (operands[1]);
3932 operands[2] = const0_rtx;
3935 operands[1] = GEN_INT (0x7f);
3936 operands[2] = GEN_INT (val - 0x7f);
3940 ;; 32-bit floating point moves
3942 (define_expand "movsf"
3943 [(set (match_operand:SF 0 "")
3944 (match_operand:SF 1 ""))]
3947 if (mips_legitimize_move (SFmode, operands[0], operands[1]))
3951 (define_insn "*movsf_hardfloat"
3952 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m")
3953 (match_operand:SF 1 "move_operand" "f,G,m,f,G,*d,*f,*G*d,*m,*d"))]
3955 && (register_operand (operands[0], SFmode)
3956 || reg_or_0_operand (operands[1], SFmode))"
3957 { return mips_output_move (operands[0], operands[1]); }
3958 [(set_attr "type" "fmove,mtc,fpload,fpstore,store,mtc,mfc,move,load,store")
3959 (set_attr "mode" "SF")
3960 (set_attr "length" "4,4,*,*,*,4,4,4,*,*")])
3962 (define_insn "*movsf_softfloat"
3963 [(set (match_operand:SF 0 "nonimmediate_operand" "=d,d,m")
3964 (match_operand:SF 1 "move_operand" "Gd,m,d"))]
3965 "TARGET_SOFT_FLOAT && !TARGET_MIPS16
3966 && (register_operand (operands[0], SFmode)
3967 || reg_or_0_operand (operands[1], SFmode))"
3968 { return mips_output_move (operands[0], operands[1]); }
3969 [(set_attr "type" "move,load,store")
3970 (set_attr "mode" "SF")
3971 (set_attr "length" "4,*,*")])
3973 (define_insn "*movsf_mips16"
3974 [(set (match_operand:SF 0 "nonimmediate_operand" "=d,y,d,d,m")
3975 (match_operand:SF 1 "move_operand" "d,d,y,m,d"))]
3977 && (register_operand (operands[0], SFmode)
3978 || register_operand (operands[1], SFmode))"
3979 { return mips_output_move (operands[0], operands[1]); }
3980 [(set_attr "type" "move,move,move,load,store")
3981 (set_attr "mode" "SF")
3982 (set_attr "length" "4,4,4,*,*")])
3985 ;; 64-bit floating point moves
3987 (define_expand "movdf"
3988 [(set (match_operand:DF 0 "")
3989 (match_operand:DF 1 ""))]
3992 if (mips_legitimize_move (DFmode, operands[0], operands[1]))
3996 (define_insn "*movdf_hardfloat_64bit"
3997 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m")
3998 (match_operand:DF 1 "move_operand" "f,G,m,f,G,*d,*f,*d*G,*m,*d"))]
3999 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_64BIT
4000 && (register_operand (operands[0], DFmode)
4001 || reg_or_0_operand (operands[1], DFmode))"
4002 { return mips_output_move (operands[0], operands[1]); }
4003 [(set_attr "type" "fmove,mtc,fpload,fpstore,store,mtc,mfc,move,load,store")
4004 (set_attr "mode" "DF")
4005 (set_attr "length" "4,4,*,*,*,4,4,4,*,*")])
4007 ;; This pattern applies to both !TARGET_FLOAT64 and TARGET_FLOAT64.
4008 (define_insn "*movdf_hardfloat_32bit"
4009 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m")
4010 (match_operand:DF 1 "move_operand" "f,G,m,f,G,*d,*f,*d*G,*m,*d"))]
4011 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !TARGET_64BIT
4012 && (register_operand (operands[0], DFmode)
4013 || reg_or_0_operand (operands[1], DFmode))"
4014 { return mips_output_move (operands[0], operands[1]); }
4015 [(set_attr "type" "fmove,mtc,fpload,fpstore,store,mtc,mfc,move,load,store")
4016 (set_attr "mode" "DF")
4017 (set_attr "length" "4,8,*,*,*,8,8,8,*,*")])
4019 (define_insn "*movdf_softfloat"
4020 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,m,d,f,f")
4021 (match_operand:DF 1 "move_operand" "dG,m,dG,f,d,f"))]
4022 "(TARGET_SOFT_FLOAT || TARGET_SINGLE_FLOAT) && !TARGET_MIPS16
4023 && (register_operand (operands[0], DFmode)
4024 || reg_or_0_operand (operands[1], DFmode))"
4025 { return mips_output_move (operands[0], operands[1]); }
4026 [(set_attr "type" "multi,load,store,mfc,mtc,fmove")
4027 (set_attr "mode" "DF")
4028 (set_attr "length" "8,*,*,4,4,4")])
4030 (define_insn "*movdf_mips16"
4031 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,y,d,d,m")
4032 (match_operand:DF 1 "move_operand" "d,d,y,m,d"))]
4034 && (register_operand (operands[0], DFmode)
4035 || register_operand (operands[1], DFmode))"
4036 { return mips_output_move (operands[0], operands[1]); }
4037 [(set_attr "type" "multi,multi,multi,load,store")
4038 (set_attr "mode" "DF")
4039 (set_attr "length" "8,8,8,*,*")])
4041 ;; 128-bit floating point moves
4043 (define_expand "movtf"
4044 [(set (match_operand:TF 0 "")
4045 (match_operand:TF 1 ""))]
4048 if (mips_legitimize_move (TFmode, operands[0], operands[1]))
4052 ;; This pattern handles both hard- and soft-float cases.
4053 (define_insn_and_split "*movtf_internal"
4054 [(set (match_operand:TF 0 "nonimmediate_operand" "=d,R,f,dR")
4055 (match_operand:TF 1 "move_operand" "dGR,dG,dGR,f"))]
4058 "&& reload_completed"
4061 mips_split_doubleword_move (operands[0], operands[1]);
4064 [(set_attr "type" "multi")
4065 (set_attr "length" "16")])
4068 [(set (match_operand:MOVE64 0 "nonimmediate_operand")
4069 (match_operand:MOVE64 1 "move_operand"))]
4070 "reload_completed && !TARGET_64BIT
4071 && mips_split_64bit_move_p (operands[0], operands[1])"
4074 mips_split_doubleword_move (operands[0], operands[1]);
4078 ;; When generating mips16 code, split moves of negative constants into
4079 ;; a positive "li" followed by a negation.
4081 [(set (match_operand 0 "register_operand")
4082 (match_operand 1 "const_int_operand"))]
4083 "TARGET_MIPS16 && reload_completed && INTVAL (operands[1]) < 0"
4087 (neg:SI (match_dup 2)))]
4089 operands[2] = gen_lowpart (SImode, operands[0]);
4090 operands[3] = GEN_INT (-INTVAL (operands[1]));
4093 ;; 64-bit paired-single floating point moves
4095 (define_expand "movv2sf"
4096 [(set (match_operand:V2SF 0)
4097 (match_operand:V2SF 1))]
4098 "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT"
4100 if (mips_legitimize_move (V2SFmode, operands[0], operands[1]))
4104 (define_insn "movv2sf_hardfloat_64bit"
4105 [(set (match_operand:V2SF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m")
4106 (match_operand:V2SF 1 "move_operand" "f,YG,m,f,YG,*d,*f,*d*YG,*m,*d"))]
4108 && TARGET_PAIRED_SINGLE_FLOAT
4110 && (register_operand (operands[0], V2SFmode)
4111 || reg_or_0_operand (operands[1], V2SFmode))"
4112 { return mips_output_move (operands[0], operands[1]); }
4113 [(set_attr "type" "fmove,mtc,fpload,fpstore,store,mtc,mfc,move,load,store")
4114 (set_attr "mode" "SF")
4115 (set_attr "length" "4,4,*,*,*,4,4,4,*,*")])
4117 (define_insn "movv2sf_hardfloat_32bit"
4118 [(set (match_operand:V2SF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m")
4119 (match_operand:V2SF 1 "move_operand" "f,YG,m,f,YG,*d,*f,*d*YG,*m,*d"))]
4121 && TARGET_PAIRED_SINGLE_FLOAT
4123 && (register_operand (operands[0], V2SFmode)
4124 || reg_or_0_operand (operands[1], V2SFmode))"
4125 { return mips_output_move (operands[0], operands[1]); }
4126 [(set_attr "type" "fmove,mtc,fpload,fpstore,store,mtc,mfc,move,load,store")
4127 (set_attr "mode" "SF")
4128 (set_attr "length" "4,8,*,*,*,8,8,8,*,*")])
4130 ;; The HI and LO registers are not truly independent. If we move an mthi
4131 ;; instruction before an mflo instruction, it will make the result of the
4132 ;; mflo unpredictable. The same goes for mtlo and mfhi.
4134 ;; We cope with this by making the mflo and mfhi patterns use both HI and LO.
4135 ;; Operand 1 is the register we want, operand 2 is the other one.
4137 ;; When generating VR4120 or VR4130 code, we use macc{,hi} and
4138 ;; dmacc{,hi} instead of mfhi and mflo. This avoids both the normal
4139 ;; MIPS III hi/lo hazards and the errata related to -mfix-vr4130.
4141 (define_expand "mfhilo_<mode>"
4142 [(set (match_operand:GPR 0 "register_operand")
4143 (unspec:GPR [(match_operand:GPR 1 "register_operand")
4144 (match_operand:GPR 2 "register_operand")]
4147 (define_insn "*mfhilo_<mode>"
4148 [(set (match_operand:GPR 0 "register_operand" "=d,d")
4149 (unspec:GPR [(match_operand:GPR 1 "register_operand" "h,l")
4150 (match_operand:GPR 2 "register_operand" "l,h")]
4154 [(set_attr "type" "mfhilo")
4155 (set_attr "mode" "<MODE>")])
4157 (define_insn "*mfhilo_<mode>_macc"
4158 [(set (match_operand:GPR 0 "register_operand" "=d,d")
4159 (unspec:GPR [(match_operand:GPR 1 "register_operand" "h,l")
4160 (match_operand:GPR 2 "register_operand" "l,h")]
4166 [(set_attr "type" "mfhilo")
4167 (set_attr "mode" "<MODE>")])
4169 ;; Emit a doubleword move in which exactly one of the operands is
4170 ;; a floating-point register. We can't just emit two normal moves
4171 ;; because of the constraints imposed by the FPU register model;
4172 ;; see mips_cannot_change_mode_class for details. Instead, we keep
4173 ;; the FPR whole and use special patterns to refer to each word of
4174 ;; the other operand.
4176 (define_expand "move_doubleword_fpr<mode>"
4177 [(set (match_operand:SPLITF 0)
4178 (match_operand:SPLITF 1))]
4181 if (FP_REG_RTX_P (operands[0]))
4183 rtx low = mips_subword (operands[1], 0);
4184 rtx high = mips_subword (operands[1], 1);
4185 emit_insn (gen_load_low<mode> (operands[0], low));
4187 emit_insn (gen_mthc1<mode> (operands[0], high, operands[0]));
4189 emit_insn (gen_load_high<mode> (operands[0], high, operands[0]));
4193 rtx low = mips_subword (operands[0], 0);
4194 rtx high = mips_subword (operands[0], 1);
4195 emit_insn (gen_store_word<mode> (low, operands[1], const0_rtx));
4197 emit_insn (gen_mfhc1<mode> (high, operands[1]));
4199 emit_insn (gen_store_word<mode> (high, operands[1], const1_rtx));
4204 ;; Load the low word of operand 0 with operand 1.
4205 (define_insn "load_low<mode>"
4206 [(set (match_operand:SPLITF 0 "register_operand" "=f,f")
4207 (unspec:SPLITF [(match_operand:<HALFMODE> 1 "general_operand" "dJ,m")]
4211 operands[0] = mips_subword (operands[0], 0);
4212 return mips_output_move (operands[0], operands[1]);
4214 [(set_attr "type" "mtc,fpload")
4215 (set_attr "mode" "<HALFMODE>")])
4217 ;; Load the high word of operand 0 from operand 1, preserving the value
4219 (define_insn "load_high<mode>"
4220 [(set (match_operand:SPLITF 0 "register_operand" "=f,f")
4221 (unspec:SPLITF [(match_operand:<HALFMODE> 1 "general_operand" "dJ,m")
4222 (match_operand:SPLITF 2 "register_operand" "0,0")]
4226 operands[0] = mips_subword (operands[0], 1);
4227 return mips_output_move (operands[0], operands[1]);
4229 [(set_attr "type" "mtc,fpload")
4230 (set_attr "mode" "<HALFMODE>")])
4232 ;; Store one word of operand 1 in operand 0. Operand 2 is 1 to store the
4233 ;; high word and 0 to store the low word.
4234 (define_insn "store_word<mode>"
4235 [(set (match_operand:<HALFMODE> 0 "nonimmediate_operand" "=d,m")
4236 (unspec:<HALFMODE> [(match_operand:SPLITF 1 "register_operand" "f,f")
4237 (match_operand 2 "const_int_operand")]
4238 UNSPEC_STORE_WORD))]
4241 operands[1] = mips_subword (operands[1], INTVAL (operands[2]));
4242 return mips_output_move (operands[0], operands[1]);
4244 [(set_attr "type" "mfc,fpstore")
4245 (set_attr "mode" "<HALFMODE>")])
4247 ;; Move operand 1 to the high word of operand 0 using mthc1, preserving the
4248 ;; value in the low word.
4249 (define_insn "mthc1<mode>"
4250 [(set (match_operand:SPLITF 0 "register_operand" "=f")
4251 (unspec:SPLITF [(match_operand:<HALFMODE> 1 "general_operand" "dJ")
4252 (match_operand:SPLITF 2 "register_operand" "0")]
4254 "TARGET_HARD_FLOAT && ISA_HAS_MXHC1"
4256 [(set_attr "type" "mtc")
4257 (set_attr "mode" "<HALFMODE>")])
4259 ;; Move high word of operand 1 to operand 0 using mfhc1.
4260 (define_insn "mfhc1<mode>"
4261 [(set (match_operand:<HALFMODE> 0 "register_operand" "=d")
4262 (unspec:<HALFMODE> [(match_operand:SPLITF 1 "register_operand" "f")]
4264 "TARGET_HARD_FLOAT && ISA_HAS_MXHC1"
4266 [(set_attr "type" "mfc")
4267 (set_attr "mode" "<HALFMODE>")])
4269 ;; Move a constant that satisfies CONST_GP_P into operand 0.
4270 (define_expand "load_const_gp"
4271 [(set (match_operand 0 "register_operand" "=d")
4272 (const (unspec [(const_int 0)] UNSPEC_GP)))])
4274 ;; Insn to initialize $gp for n32/n64 abicalls. Operand 0 is the offset
4275 ;; of _gp from the start of this function. Operand 1 is the incoming
4276 ;; function address.
4277 (define_insn_and_split "loadgp_newabi_<mode>"
4278 [(set (match_operand:P 0 "register_operand" "=d")
4279 (unspec_volatile:P [(match_operand:P 1)
4280 (match_operand:P 2 "register_operand" "d")]
4282 "mips_current_loadgp_style () == LOADGP_NEWABI"
4285 [(set (match_dup 0) (match_dup 3))
4286 (set (match_dup 0) (match_dup 4))
4287 (set (match_dup 0) (match_dup 5))]
4289 operands[3] = gen_rtx_HIGH (Pmode, operands[1]);
4290 operands[4] = gen_rtx_PLUS (Pmode, operands[0], operands[2]);
4291 operands[5] = gen_rtx_LO_SUM (Pmode, operands[0], operands[1]);
4293 [(set_attr "length" "12")])
4295 ;; Likewise, for -mno-shared code. Operand 0 is the __gnu_local_gp symbol.
4296 (define_insn_and_split "loadgp_absolute_<mode>"
4297 [(set (match_operand:P 0 "register_operand" "=d")
4298 (unspec_volatile:P [(match_operand:P 1)] UNSPEC_LOADGP))]
4299 "mips_current_loadgp_style () == LOADGP_ABSOLUTE"
4304 mips_emit_move (operands[0], operands[1]);
4307 [(set_attr "length" "8")])
4309 ;; The use of gp is hidden when not using explicit relocations.
4310 ;; This blockage instruction prevents the gp load from being
4311 ;; scheduled after an implicit use of gp. It also prevents
4312 ;; the load from being deleted as dead.
4313 (define_insn "loadgp_blockage"
4314 [(unspec_volatile [(reg:DI 28)] UNSPEC_BLOCKAGE)]
4317 [(set_attr "type" "unknown")
4318 (set_attr "mode" "none")
4319 (set_attr "length" "0")])
4321 ;; Initialize $gp for RTP PIC. Operand 0 is the __GOTT_BASE__ symbol
4322 ;; and operand 1 is the __GOTT_INDEX__ symbol.
4323 (define_insn_and_split "loadgp_rtp_<mode>"
4324 [(set (match_operand:P 0 "register_operand" "=d")
4325 (unspec_volatile:P [(match_operand:P 1 "symbol_ref_operand")
4326 (match_operand:P 2 "symbol_ref_operand")]
4328 "mips_current_loadgp_style () == LOADGP_RTP"
4331 [(set (match_dup 0) (high:P (match_dup 3)))
4332 (set (match_dup 0) (unspec:P [(match_dup 0)
4333 (match_dup 3)] UNSPEC_LOAD_GOT))
4334 (set (match_dup 0) (unspec:P [(match_dup 0)
4335 (match_dup 4)] UNSPEC_LOAD_GOT))]
4337 operands[3] = mips_unspec_address (operands[1], SYMBOL_ABSOLUTE);
4338 operands[4] = mips_unspec_address (operands[2], SYMBOL_HALF);
4340 [(set_attr "length" "12")])
4342 ;; Emit a .cprestore directive, which normally expands to a single store
4343 ;; instruction. Note that we continue to use .cprestore for explicit reloc
4344 ;; code so that jals inside inline asms will work correctly.
4345 (define_insn "cprestore"
4346 [(unspec_volatile [(match_operand 0 "const_int_operand" "I,i")
4351 if (set_nomacro && which_alternative == 1)
4352 return ".set\tmacro\;.cprestore\t%0\;.set\tnomacro";
4354 return ".cprestore\t%0";
4356 [(set_attr "type" "store")
4357 (set_attr "length" "4,12")])
4359 ;; Expand in-line code to clear the instruction cache between operand[0] and
4361 (define_expand "clear_cache"
4362 [(match_operand 0 "pmode_register_operand")
4363 (match_operand 1 "pmode_register_operand")]
4369 mips_expand_synci_loop (operands[0], operands[1]);
4370 emit_insn (gen_sync ());
4371 emit_insn (gen_clear_hazard ());
4373 else if (mips_cache_flush_func && mips_cache_flush_func[0])
4375 rtx len = gen_reg_rtx (Pmode);
4376 emit_insn (gen_sub3_insn (len, operands[1], operands[0]));
4377 MIPS_ICACHE_SYNC (operands[0], len);
4383 [(unspec_volatile [(const_int 0)] UNSPEC_SYNC)]
4387 (define_insn "synci"
4388 [(unspec_volatile [(match_operand 0 "pmode_register_operand" "d")]
4393 (define_insn "rdhwr"
4394 [(set (match_operand:SI 0 "register_operand" "=d")
4395 (unspec_volatile [(match_operand:SI 1 "const_int_operand" "n")]
4400 (define_insn "clear_hazard"
4401 [(unspec_volatile [(const_int 0)] UNSPEC_CLEAR_HAZARD)
4402 (clobber (reg:SI 31))]
4405 return "%(%<bal\t1f\n"
4407 "1:\taddiu\t$31,$31,12\n"
4411 [(set_attr "length" "20")])
4413 ;; Atomic memory operations.
4415 (define_insn "memory_barrier"
4416 [(set (mem:BLK (scratch))
4417 (unspec:BLK [(const_int 0)] UNSPEC_MEMORY_BARRIER))]
4421 (define_insn "sync_compare_and_swap<mode>"
4422 [(set (match_operand:GPR 0 "register_operand" "=&d,&d")
4423 (match_operand:GPR 1 "memory_operand" "+R,R"))
4425 (unspec_volatile:GPR [(match_operand:GPR 2 "reg_or_0_operand" "dJ,dJ")
4426 (match_operand:GPR 3 "arith_operand" "I,d")]
4427 UNSPEC_COMPARE_AND_SWAP))]
4430 if (which_alternative == 0)
4431 return MIPS_COMPARE_AND_SWAP ("<d>", "li");
4433 return MIPS_COMPARE_AND_SWAP ("<d>", "move");
4435 [(set_attr "length" "32")])
4437 (define_insn "sync_add<mode>"
4438 [(set (match_operand:GPR 0 "memory_operand" "+R,R")
4439 (unspec_volatile:GPR
4440 [(plus:GPR (match_dup 0)
4441 (match_operand:GPR 1 "arith_operand" "I,d"))]
4442 UNSPEC_SYNC_OLD_OP))]
4445 if (which_alternative == 0)
4446 return MIPS_SYNC_OP ("<d>", "<d>addiu");
4448 return MIPS_SYNC_OP ("<d>", "<d>addu");
4450 [(set_attr "length" "28")])
4452 (define_insn "sync_sub<mode>"
4453 [(set (match_operand:GPR 0 "memory_operand" "+R")
4454 (unspec_volatile:GPR
4455 [(minus:GPR (match_dup 0)
4456 (match_operand:GPR 1 "register_operand" "d"))]
4457 UNSPEC_SYNC_OLD_OP))]
4460 return MIPS_SYNC_OP ("<d>", "<d>subu");
4462 [(set_attr "length" "28")])
4464 (define_insn "sync_old_add<mode>"
4465 [(set (match_operand:GPR 0 "register_operand" "=d,&d")
4466 (match_operand:GPR 1 "memory_operand" "+R,R"))
4468 (unspec_volatile:GPR
4469 [(plus:GPR (match_dup 1)
4470 (match_operand:GPR 2 "arith_operand" "I,d"))]
4471 UNSPEC_SYNC_OLD_OP))]
4474 if (which_alternative == 0)
4475 return MIPS_SYNC_OLD_OP ("<d>", "<d>addiu");
4477 return MIPS_SYNC_OLD_OP ("<d>", "<d>addu");
4479 [(set_attr "length" "28")])
4481 (define_insn "sync_old_sub<mode>"
4482 [(set (match_operand:GPR 0 "register_operand" "=&d")
4483 (match_operand:GPR 1 "memory_operand" "+R"))
4485 (unspec_volatile:GPR
4486 [(minus:GPR (match_dup 1)
4487 (match_operand:GPR 2 "register_operand" "d"))]
4488 UNSPEC_SYNC_OLD_OP))]
4491 return MIPS_SYNC_OLD_OP ("<d>", "<d>subu");
4493 [(set_attr "length" "28")])
4495 (define_insn "sync_new_add<mode>"
4496 [(set (match_operand:GPR 0 "register_operand" "=d,&d")
4497 (plus:GPR (match_operand:GPR 1 "memory_operand" "+R,R")
4498 (match_operand:GPR 2 "arith_operand" "I,d")))
4500 (unspec_volatile:GPR
4501 [(plus:GPR (match_dup 1) (match_dup 2))]
4502 UNSPEC_SYNC_NEW_OP))]
4505 if (which_alternative == 0)
4506 return MIPS_SYNC_NEW_OP ("<d>", "<d>addiu");
4508 return MIPS_SYNC_NEW_OP ("<d>", "<d>addu");
4510 [(set_attr "length" "28")])
4512 (define_insn "sync_new_sub<mode>"
4513 [(set (match_operand:GPR 0 "register_operand" "=&d")
4514 (minus:GPR (match_operand:GPR 1 "memory_operand" "+R")
4515 (match_operand:GPR 2 "register_operand" "d")))
4517 (unspec_volatile:GPR
4518 [(minus:GPR (match_dup 1) (match_dup 2))]
4519 UNSPEC_SYNC_NEW_OP))]
4522 return MIPS_SYNC_NEW_OP ("<d>", "<d>subu");
4524 [(set_attr "length" "28")])
4526 (define_insn "sync_<optab><mode>"
4527 [(set (match_operand:GPR 0 "memory_operand" "+R,R")
4528 (unspec_volatile:GPR
4529 [(fetchop_bit:GPR (match_operand:GPR 1 "uns_arith_operand" "K,d")
4531 UNSPEC_SYNC_OLD_OP))]
4534 if (which_alternative == 0)
4535 return MIPS_SYNC_OP ("<d>", "<immediate_insn>");
4537 return MIPS_SYNC_OP ("<d>", "<insn>");
4539 [(set_attr "length" "28")])
4541 (define_insn "sync_old_<optab><mode>"
4542 [(set (match_operand:GPR 0 "register_operand" "=d,&d")
4543 (match_operand:GPR 1 "memory_operand" "+R,R"))
4545 (unspec_volatile:GPR
4546 [(fetchop_bit:GPR (match_operand:GPR 2 "uns_arith_operand" "K,d")
4548 UNSPEC_SYNC_OLD_OP))]
4551 if (which_alternative == 0)
4552 return MIPS_SYNC_OLD_OP ("<d>", "<immediate_insn>");
4554 return MIPS_SYNC_OLD_OP ("<d>", "<insn>");
4556 [(set_attr "length" "28")])
4558 (define_insn "sync_new_<optab><mode>"
4559 [(set (match_operand:GPR 0 "register_operand" "=d,&d")
4560 (match_operand:GPR 1 "memory_operand" "+R,R"))
4562 (unspec_volatile:GPR
4563 [(fetchop_bit:GPR (match_operand:GPR 2 "uns_arith_operand" "K,d")
4565 UNSPEC_SYNC_NEW_OP))]
4568 if (which_alternative == 0)
4569 return MIPS_SYNC_NEW_OP ("<d>", "<immediate_insn>");
4571 return MIPS_SYNC_NEW_OP ("<d>", "<insn>");
4573 [(set_attr "length" "28")])
4575 (define_insn "sync_nand<mode>"
4576 [(set (match_operand:GPR 0 "memory_operand" "+R,R")
4577 (unspec_volatile:GPR [(match_operand:GPR 1 "uns_arith_operand" "K,d")]
4578 UNSPEC_SYNC_OLD_OP))]
4581 if (which_alternative == 0)
4582 return MIPS_SYNC_NAND ("<d>", "andi");
4584 return MIPS_SYNC_NAND ("<d>", "and");
4586 [(set_attr "length" "32")])
4588 (define_insn "sync_old_nand<mode>"
4589 [(set (match_operand:GPR 0 "register_operand" "=d,&d")
4590 (match_operand:GPR 1 "memory_operand" "+R,R"))
4592 (unspec_volatile:GPR [(match_operand:GPR 2 "uns_arith_operand" "K,d")]
4593 UNSPEC_SYNC_OLD_OP))]
4596 if (which_alternative == 0)
4597 return MIPS_SYNC_OLD_NAND ("<d>", "andi");
4599 return MIPS_SYNC_OLD_NAND ("<d>", "and");
4601 [(set_attr "length" "32")])
4603 (define_insn "sync_new_nand<mode>"
4604 [(set (match_operand:GPR 0 "register_operand" "=d,&d")
4605 (match_operand:GPR 1 "memory_operand" "+R,R"))
4607 (unspec_volatile:GPR [(match_operand:GPR 2 "uns_arith_operand" "K,d")]
4608 UNSPEC_SYNC_NEW_OP))]
4611 if (which_alternative == 0)
4612 return MIPS_SYNC_NEW_NAND ("<d>", "andi");
4614 return MIPS_SYNC_NEW_NAND ("<d>", "and");
4616 [(set_attr "length" "32")])
4618 (define_insn "sync_lock_test_and_set<mode>"
4619 [(set (match_operand:GPR 0 "register_operand" "=d,&d")
4620 (match_operand:GPR 1 "memory_operand" "+R,R"))
4622 (unspec_volatile:GPR [(match_operand:GPR 2 "arith_operand" "I,d")]
4623 UNSPEC_SYNC_EXCHANGE))]
4626 if (which_alternative == 0)
4627 return MIPS_SYNC_EXCHANGE ("<d>", "li");
4629 return MIPS_SYNC_EXCHANGE ("<d>", "move");
4631 [(set_attr "length" "24")])
4633 ;; Block moves, see mips.c for more details.
4634 ;; Argument 0 is the destination
4635 ;; Argument 1 is the source
4636 ;; Argument 2 is the length
4637 ;; Argument 3 is the alignment
4639 (define_expand "movmemsi"
4640 [(parallel [(set (match_operand:BLK 0 "general_operand")
4641 (match_operand:BLK 1 "general_operand"))
4642 (use (match_operand:SI 2 ""))
4643 (use (match_operand:SI 3 "const_int_operand"))])]
4644 "!TARGET_MIPS16 && !TARGET_MEMCPY"
4646 if (mips_expand_block_move (operands[0], operands[1], operands[2]))
4653 ;; ....................
4657 ;; ....................
4659 (define_expand "<optab><mode>3"
4660 [(set (match_operand:GPR 0 "register_operand")
4661 (any_shift:GPR (match_operand:GPR 1 "register_operand")
4662 (match_operand:SI 2 "arith_operand")))]
4665 /* On the mips16, a shift of more than 8 is a four byte instruction,
4666 so, for a shift between 8 and 16, it is just as fast to do two
4667 shifts of 8 or less. If there is a lot of shifting going on, we
4668 may win in CSE. Otherwise combine will put the shifts back
4669 together again. This can be called by mips_function_arg, so we must
4670 be careful not to allocate a new register if we've reached the
4674 && GET_CODE (operands[2]) == CONST_INT
4675 && INTVAL (operands[2]) > 8
4676 && INTVAL (operands[2]) <= 16
4677 && !reload_in_progress
4678 && !reload_completed)
4680 rtx temp = gen_reg_rtx (<MODE>mode);
4682 emit_insn (gen_<optab><mode>3 (temp, operands[1], GEN_INT (8)));
4683 emit_insn (gen_<optab><mode>3 (operands[0], temp,
4684 GEN_INT (INTVAL (operands[2]) - 8)));
4689 (define_insn "*<optab><mode>3"
4690 [(set (match_operand:GPR 0 "register_operand" "=d")
4691 (any_shift:GPR (match_operand:GPR 1 "register_operand" "d")
4692 (match_operand:SI 2 "arith_operand" "dI")))]
4695 if (GET_CODE (operands[2]) == CONST_INT)
4696 operands[2] = GEN_INT (INTVAL (operands[2])
4697 & (GET_MODE_BITSIZE (<MODE>mode) - 1));
4699 return "<d><insn>\t%0,%1,%2";
4701 [(set_attr "type" "shift")
4702 (set_attr "mode" "<MODE>")])
4704 (define_insn "*<optab>si3_extend"
4705 [(set (match_operand:DI 0 "register_operand" "=d")
4707 (any_shift:SI (match_operand:SI 1 "register_operand" "d")
4708 (match_operand:SI 2 "arith_operand" "dI"))))]
4709 "TARGET_64BIT && !TARGET_MIPS16"
4711 if (GET_CODE (operands[2]) == CONST_INT)
4712 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
4714 return "<insn>\t%0,%1,%2";
4716 [(set_attr "type" "shift")
4717 (set_attr "mode" "SI")])
4719 (define_insn "*<optab>si3_mips16"
4720 [(set (match_operand:SI 0 "register_operand" "=d,d")
4721 (any_shift:SI (match_operand:SI 1 "register_operand" "0,d")
4722 (match_operand:SI 2 "arith_operand" "d,I")))]
4725 if (which_alternative == 0)
4726 return "<insn>\t%0,%2";
4728 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
4729 return "<insn>\t%0,%1,%2";
4731 [(set_attr "type" "shift")
4732 (set_attr "mode" "SI")
4733 (set_attr_alternative "length"
4735 (if_then_else (match_operand 2 "m16_uimm3_b")
4739 ;; We need separate DImode MIPS16 patterns because of the irregularity
4741 (define_insn "*ashldi3_mips16"
4742 [(set (match_operand:DI 0 "register_operand" "=d,d")
4743 (ashift:DI (match_operand:DI 1 "register_operand" "0,d")
4744 (match_operand:SI 2 "arith_operand" "d,I")))]
4745 "TARGET_64BIT && TARGET_MIPS16"
4747 if (which_alternative == 0)
4748 return "dsll\t%0,%2";
4750 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
4751 return "dsll\t%0,%1,%2";
4753 [(set_attr "type" "shift")
4754 (set_attr "mode" "DI")
4755 (set_attr_alternative "length"
4757 (if_then_else (match_operand 2 "m16_uimm3_b")
4761 (define_insn "*ashrdi3_mips16"
4762 [(set (match_operand:DI 0 "register_operand" "=d,d")
4763 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0,0")
4764 (match_operand:SI 2 "arith_operand" "d,I")))]
4765 "TARGET_64BIT && TARGET_MIPS16"
4767 if (GET_CODE (operands[2]) == CONST_INT)
4768 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
4770 return "dsra\t%0,%2";
4772 [(set_attr "type" "shift")
4773 (set_attr "mode" "DI")
4774 (set_attr_alternative "length"
4776 (if_then_else (match_operand 2 "m16_uimm3_b")
4780 (define_insn "*lshrdi3_mips16"
4781 [(set (match_operand:DI 0 "register_operand" "=d,d")
4782 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0,0")
4783 (match_operand:SI 2 "arith_operand" "d,I")))]
4784 "TARGET_64BIT && TARGET_MIPS16"
4786 if (GET_CODE (operands[2]) == CONST_INT)
4787 operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
4789 return "dsrl\t%0,%2";
4791 [(set_attr "type" "shift")
4792 (set_attr "mode" "DI")
4793 (set_attr_alternative "length"
4795 (if_then_else (match_operand 2 "m16_uimm3_b")
4799 ;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts.
4802 [(set (match_operand:GPR 0 "register_operand")
4803 (any_shift:GPR (match_operand:GPR 1 "register_operand")
4804 (match_operand:GPR 2 "const_int_operand")))]
4805 "TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE
4806 && GET_CODE (operands[2]) == CONST_INT
4807 && INTVAL (operands[2]) > 8
4808 && INTVAL (operands[2]) <= 16"
4809 [(set (match_dup 0) (any_shift:GPR (match_dup 1) (const_int 8)))
4810 (set (match_dup 0) (any_shift:GPR (match_dup 0) (match_dup 2)))]
4811 { operands[2] = GEN_INT (INTVAL (operands[2]) - 8); })
4813 ;; If we load a byte on the mips16 as a bitfield, the resulting
4814 ;; sequence of instructions is too complicated for combine, because it
4815 ;; involves four instructions: a load, a shift, a constant load into a
4816 ;; register, and an and (the key problem here is that the mips16 does
4817 ;; not have and immediate). We recognize a shift of a load in order
4818 ;; to make it simple enough for combine to understand.
4820 ;; The length here is the worst case: the length of the split version
4821 ;; will be more accurate.
4822 (define_insn_and_split ""
4823 [(set (match_operand:SI 0 "register_operand" "=d")
4824 (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
4825 (match_operand:SI 2 "immediate_operand" "I")))]
4829 [(set (match_dup 0) (match_dup 1))
4830 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
4832 [(set_attr "type" "load")
4833 (set_attr "mode" "SI")
4834 (set_attr "length" "16")])
4836 (define_insn "rotr<mode>3"
4837 [(set (match_operand:GPR 0 "register_operand" "=d")
4838 (rotatert:GPR (match_operand:GPR 1 "register_operand" "d")
4839 (match_operand:SI 2 "arith_operand" "dI")))]
4842 if (GET_CODE (operands[2]) == CONST_INT)
4843 gcc_assert (INTVAL (operands[2]) >= 0
4844 && INTVAL (operands[2]) < GET_MODE_BITSIZE (<MODE>mode));
4846 return "<d>ror\t%0,%1,%2";
4848 [(set_attr "type" "shift")
4849 (set_attr "mode" "<MODE>")])
4852 ;; ....................
4856 ;; ....................
4858 ;; Flow here is rather complex:
4860 ;; 1) The cmp{si,di,sf,df} routine is called. It deposits the arguments
4861 ;; into cmp_operands[] but generates no RTL.
4863 ;; 2) The appropriate branch define_expand is called, which then
4864 ;; creates the appropriate RTL for the comparison and branch.
4865 ;; Different CC modes are used, based on what type of branch is
4866 ;; done, so that we can constrain things appropriately. There
4867 ;; are assumptions in the rest of GCC that break if we fold the
4868 ;; operands into the branches for integer operations, and use cc0
4869 ;; for floating point, so we use the fp status register instead.
4870 ;; If needed, an appropriate temporary is created to hold the
4871 ;; of the integer compare.
4873 (define_expand "cmp<mode>"
4875 (compare:CC (match_operand:GPR 0 "register_operand")
4876 (match_operand:GPR 1 "nonmemory_operand")))]
4879 cmp_operands[0] = operands[0];
4880 cmp_operands[1] = operands[1];
4884 (define_expand "cmp<mode>"
4886 (compare:CC (match_operand:SCALARF 0 "register_operand")
4887 (match_operand:SCALARF 1 "register_operand")))]
4890 cmp_operands[0] = operands[0];
4891 cmp_operands[1] = operands[1];
4896 ;; ....................
4898 ;; CONDITIONAL BRANCHES
4900 ;; ....................
4902 ;; Conditional branches on floating-point equality tests.
4904 (define_insn "*branch_fp"
4907 (match_operator 0 "equality_operator"
4908 [(match_operand:CC 2 "register_operand" "z")
4910 (label_ref (match_operand 1 "" ""))
4914 return mips_output_conditional_branch (insn, operands,
4915 MIPS_BRANCH ("b%F0", "%Z2%1"),
4916 MIPS_BRANCH ("b%W0", "%Z2%1"));
4918 [(set_attr "type" "branch")
4919 (set_attr "mode" "none")])
4921 (define_insn "*branch_fp_inverted"
4924 (match_operator 0 "equality_operator"
4925 [(match_operand:CC 2 "register_operand" "z")
4928 (label_ref (match_operand 1 "" ""))))]
4931 return mips_output_conditional_branch (insn, operands,
4932 MIPS_BRANCH ("b%W0", "%Z2%1"),
4933 MIPS_BRANCH ("b%F0", "%Z2%1"));
4935 [(set_attr "type" "branch")
4936 (set_attr "mode" "none")])
4938 ;; Conditional branches on ordered comparisons with zero.
4940 (define_insn "*branch_order<mode>"
4943 (match_operator 0 "order_operator"
4944 [(match_operand:GPR 2 "register_operand" "d")
4946 (label_ref (match_operand 1 "" ""))
4949 { return mips_output_order_conditional_branch (insn, operands, false); }
4950 [(set_attr "type" "branch")
4951 (set_attr "mode" "none")])
4953 (define_insn "*branch_order<mode>_inverted"
4956 (match_operator 0 "order_operator"
4957 [(match_operand:GPR 2 "register_operand" "d")
4960 (label_ref (match_operand 1 "" ""))))]
4962 { return mips_output_order_conditional_branch (insn, operands, true); }
4963 [(set_attr "type" "branch")
4964 (set_attr "mode" "none")])
4966 ;; Conditional branch on equality comparison.
4968 (define_insn "*branch_equality<mode>"
4971 (match_operator 0 "equality_operator"
4972 [(match_operand:GPR 2 "register_operand" "d")
4973 (match_operand:GPR 3 "reg_or_0_operand" "dJ")])
4974 (label_ref (match_operand 1 "" ""))
4978 return mips_output_conditional_branch (insn, operands,
4979 MIPS_BRANCH ("b%C0", "%2,%z3,%1"),
4980 MIPS_BRANCH ("b%N0", "%2,%z3,%1"));
4982 [(set_attr "type" "branch")
4983 (set_attr "mode" "none")])
4985 (define_insn "*branch_equality<mode>_inverted"
4988 (match_operator 0 "equality_operator"
4989 [(match_operand:GPR 2 "register_operand" "d")
4990 (match_operand:GPR 3 "reg_or_0_operand" "dJ")])
4992 (label_ref (match_operand 1 "" ""))))]
4995 return mips_output_conditional_branch (insn, operands,
4996 MIPS_BRANCH ("b%N0", "%2,%z3,%1"),
4997 MIPS_BRANCH ("b%C0", "%2,%z3,%1"));
4999 [(set_attr "type" "branch")
5000 (set_attr "mode" "none")])
5004 (define_insn "*branch_equality<mode>_mips16"
5007 (match_operator 0 "equality_operator"
5008 [(match_operand:GPR 1 "register_operand" "d,t")
5010 (match_operand 2 "pc_or_label_operand" "")
5011 (match_operand 3 "pc_or_label_operand" "")))]
5014 if (operands[2] != pc_rtx)
5016 if (which_alternative == 0)
5017 return "b%C0z\t%1,%2";
5019 return "bt%C0z\t%2";
5023 if (which_alternative == 0)
5024 return "b%N0z\t%1,%3";
5026 return "bt%N0z\t%3";
5029 [(set_attr "type" "branch")
5030 (set_attr "mode" "none")
5031 (set_attr "length" "8")])
5033 (define_expand "b<code>"
5035 (if_then_else (any_cond:CC (cc0)
5037 (label_ref (match_operand 0 ""))
5041 mips_expand_conditional_branch (operands, <CODE>);
5045 ;; Used to implement built-in functions.
5046 (define_expand "condjump"
5048 (if_then_else (match_operand 0)
5049 (label_ref (match_operand 1))
5053 ;; ....................
5055 ;; SETTING A REGISTER FROM A COMPARISON
5057 ;; ....................
5059 (define_expand "seq"
5060 [(set (match_operand:SI 0 "register_operand")
5061 (eq:SI (match_dup 1)
5064 { if (mips_expand_scc (EQ, operands[0])) DONE; else FAIL; })
5066 (define_insn "*seq_<mode>"
5067 [(set (match_operand:GPR 0 "register_operand" "=d")
5068 (eq:GPR (match_operand:GPR 1 "register_operand" "d")
5072 [(set_attr "type" "slt")
5073 (set_attr "mode" "<MODE>")])
5075 (define_insn "*seq_<mode>_mips16"
5076 [(set (match_operand:GPR 0 "register_operand" "=t")
5077 (eq:GPR (match_operand:GPR 1 "register_operand" "d")
5081 [(set_attr "type" "slt")
5082 (set_attr "mode" "<MODE>")])
5084 ;; "sne" uses sltu instructions in which the first operand is $0.
5085 ;; This isn't possible in mips16 code.
5087 (define_expand "sne"
5088 [(set (match_operand:SI 0 "register_operand")
5089 (ne:SI (match_dup 1)
5092 { if (mips_expand_scc (NE, operands[0])) DONE; else FAIL; })
5094 (define_insn "*sne_<mode>"
5095 [(set (match_operand:GPR 0 "register_operand" "=d")
5096 (ne:GPR (match_operand:GPR 1 "register_operand" "d")
5100 [(set_attr "type" "slt")
5101 (set_attr "mode" "<MODE>")])
5103 (define_expand "sgt"
5104 [(set (match_operand:SI 0 "register_operand")
5105 (gt:SI (match_dup 1)
5108 { if (mips_expand_scc (GT, operands[0])) DONE; else FAIL; })
5110 (define_insn "*sgt_<mode>"
5111 [(set (match_operand:GPR 0 "register_operand" "=d")
5112 (gt:GPR (match_operand:GPR 1 "register_operand" "d")
5113 (match_operand:GPR 2 "reg_or_0_operand" "dJ")))]
5116 [(set_attr "type" "slt")
5117 (set_attr "mode" "<MODE>")])
5119 (define_insn "*sgt_<mode>_mips16"
5120 [(set (match_operand:GPR 0 "register_operand" "=t")
5121 (gt:GPR (match_operand:GPR 1 "register_operand" "d")
5122 (match_operand:GPR 2 "register_operand" "d")))]
5125 [(set_attr "type" "slt")
5126 (set_attr "mode" "<MODE>")])
5128 (define_expand "sge"
5129 [(set (match_operand:SI 0 "register_operand")
5130 (ge:SI (match_dup 1)
5133 { if (mips_expand_scc (GE, operands[0])) DONE; else FAIL; })
5135 (define_insn "*sge_<mode>"
5136 [(set (match_operand:GPR 0 "register_operand" "=d")
5137 (ge:GPR (match_operand:GPR 1 "register_operand" "d")
5141 [(set_attr "type" "slt")
5142 (set_attr "mode" "<MODE>")])
5144 (define_expand "slt"
5145 [(set (match_operand:SI 0 "register_operand")
5146 (lt:SI (match_dup 1)
5149 { if (mips_expand_scc (LT, operands[0])) DONE; else FAIL; })
5151 (define_insn "*slt_<mode>"
5152 [(set (match_operand:GPR 0 "register_operand" "=d")
5153 (lt:GPR (match_operand:GPR 1 "register_operand" "d")
5154 (match_operand:GPR 2 "arith_operand" "dI")))]
5157 [(set_attr "type" "slt")
5158 (set_attr "mode" "<MODE>")])
5160 (define_insn "*slt_<mode>_mips16"
5161 [(set (match_operand:GPR 0 "register_operand" "=t,t")
5162 (lt:GPR (match_operand:GPR 1 "register_operand" "d,d")
5163 (match_operand:GPR 2 "arith_operand" "d,I")))]
5166 [(set_attr "type" "slt")
5167 (set_attr "mode" "<MODE>")
5168 (set_attr_alternative "length"
5170 (if_then_else (match_operand 2 "m16_uimm8_1")
5174 (define_expand "sle"
5175 [(set (match_operand:SI 0 "register_operand")
5176 (le:SI (match_dup 1)
5179 { if (mips_expand_scc (LE, operands[0])) DONE; else FAIL; })
5181 (define_insn "*sle_<mode>"
5182 [(set (match_operand:GPR 0 "register_operand" "=d")
5183 (le:GPR (match_operand:GPR 1 "register_operand" "d")
5184 (match_operand:GPR 2 "sle_operand" "")))]
5187 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
5188 return "slt\t%0,%1,%2";
5190 [(set_attr "type" "slt")
5191 (set_attr "mode" "<MODE>")])
5193 (define_insn "*sle_<mode>_mips16"
5194 [(set (match_operand:GPR 0 "register_operand" "=t")
5195 (le:GPR (match_operand:GPR 1 "register_operand" "d")
5196 (match_operand:GPR 2 "sle_operand" "")))]
5199 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
5200 return "slt\t%1,%2";
5202 [(set_attr "type" "slt")
5203 (set_attr "mode" "<MODE>")
5204 (set (attr "length") (if_then_else (match_operand 2 "m16_uimm8_m1_1")
5208 (define_expand "sgtu"
5209 [(set (match_operand:SI 0 "register_operand")
5210 (gtu:SI (match_dup 1)
5213 { if (mips_expand_scc (GTU, operands[0])) DONE; else FAIL; })
5215 (define_insn "*sgtu_<mode>"
5216 [(set (match_operand:GPR 0 "register_operand" "=d")
5217 (gtu:GPR (match_operand:GPR 1 "register_operand" "d")
5218 (match_operand:GPR 2 "reg_or_0_operand" "dJ")))]
5221 [(set_attr "type" "slt")
5222 (set_attr "mode" "<MODE>")])
5224 (define_insn "*sgtu_<mode>_mips16"
5225 [(set (match_operand:GPR 0 "register_operand" "=t")
5226 (gtu:GPR (match_operand:GPR 1 "register_operand" "d")
5227 (match_operand:GPR 2 "register_operand" "d")))]
5230 [(set_attr "type" "slt")
5231 (set_attr "mode" "<MODE>")])
5233 (define_expand "sgeu"
5234 [(set (match_operand:SI 0 "register_operand")
5235 (geu:SI (match_dup 1)
5238 { if (mips_expand_scc (GEU, operands[0])) DONE; else FAIL; })
5240 (define_insn "*sge_<mode>"
5241 [(set (match_operand:GPR 0 "register_operand" "=d")
5242 (geu:GPR (match_operand:GPR 1 "register_operand" "d")
5246 [(set_attr "type" "slt")
5247 (set_attr "mode" "<MODE>")])
5249 (define_expand "sltu"
5250 [(set (match_operand:SI 0 "register_operand")
5251 (ltu:SI (match_dup 1)
5254 { if (mips_expand_scc (LTU, operands[0])) DONE; else FAIL; })
5256 (define_insn "*sltu_<mode>"
5257 [(set (match_operand:GPR 0 "register_operand" "=d")
5258 (ltu:GPR (match_operand:GPR 1 "register_operand" "d")
5259 (match_operand:GPR 2 "arith_operand" "dI")))]
5262 [(set_attr "type" "slt")
5263 (set_attr "mode" "<MODE>")])
5265 (define_insn "*sltu_<mode>_mips16"
5266 [(set (match_operand:GPR 0 "register_operand" "=t,t")
5267 (ltu:GPR (match_operand:GPR 1 "register_operand" "d,d")
5268 (match_operand:GPR 2 "arith_operand" "d,I")))]
5271 [(set_attr "type" "slt")
5272 (set_attr "mode" "<MODE>")
5273 (set_attr_alternative "length"
5275 (if_then_else (match_operand 2 "m16_uimm8_1")
5279 (define_expand "sleu"
5280 [(set (match_operand:SI 0 "register_operand")
5281 (leu:SI (match_dup 1)
5284 { if (mips_expand_scc (LEU, operands[0])) DONE; else FAIL; })
5286 (define_insn "*sleu_<mode>"
5287 [(set (match_operand:GPR 0 "register_operand" "=d")
5288 (leu:GPR (match_operand:GPR 1 "register_operand" "d")
5289 (match_operand:GPR 2 "sleu_operand" "")))]
5292 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
5293 return "sltu\t%0,%1,%2";
5295 [(set_attr "type" "slt")
5296 (set_attr "mode" "<MODE>")])
5298 (define_insn "*sleu_<mode>_mips16"
5299 [(set (match_operand:GPR 0 "register_operand" "=t")
5300 (leu:GPR (match_operand:GPR 1 "register_operand" "d")
5301 (match_operand:GPR 2 "sleu_operand" "")))]
5304 operands[2] = GEN_INT (INTVAL (operands[2]) + 1);
5305 return "sltu\t%1,%2";
5307 [(set_attr "type" "slt")
5308 (set_attr "mode" "<MODE>")
5309 (set (attr "length") (if_then_else (match_operand 2 "m16_uimm8_m1_1")
5314 ;; ....................
5316 ;; FLOATING POINT COMPARISONS
5318 ;; ....................
5320 (define_insn "s<code>_<mode>"
5321 [(set (match_operand:CC 0 "register_operand" "=z")
5322 (fcond:CC (match_operand:SCALARF 1 "register_operand" "f")
5323 (match_operand:SCALARF 2 "register_operand" "f")))]
5325 "c.<fcond>.<fmt>\t%Z0%1,%2"
5326 [(set_attr "type" "fcmp")
5327 (set_attr "mode" "FPSW")])
5329 (define_insn "s<code>_<mode>"
5330 [(set (match_operand:CC 0 "register_operand" "=z")
5331 (swapped_fcond:CC (match_operand:SCALARF 1 "register_operand" "f")
5332 (match_operand:SCALARF 2 "register_operand" "f")))]
5334 "c.<swapped_fcond>.<fmt>\t%Z0%2,%1"
5335 [(set_attr "type" "fcmp")
5336 (set_attr "mode" "FPSW")])
5339 ;; ....................
5341 ;; UNCONDITIONAL BRANCHES
5343 ;; ....................
5345 ;; Unconditional branches.
5349 (label_ref (match_operand 0 "" "")))]
5354 if (get_attr_length (insn) <= 8)
5355 return "%*b\t%l0%/";
5358 output_asm_insn (mips_output_load_label (), operands);
5359 return "%*jr\t%@%/%]";
5363 return "%*j\t%l0%/";
5365 [(set_attr "type" "jump")
5366 (set_attr "mode" "none")
5367 (set (attr "length")
5368 ;; We can't use `j' when emitting PIC. Emit a branch if it's
5369 ;; in range, otherwise load the address of the branch target into
5370 ;; $at and then jump to it.
5372 (ior (eq (symbol_ref "flag_pic") (const_int 0))
5373 (lt (abs (minus (match_dup 0)
5374 (plus (pc) (const_int 4))))
5375 (const_int 131072)))
5376 (const_int 4) (const_int 16)))])
5378 ;; We need a different insn for the mips16, because a mips16 branch
5379 ;; does not have a delay slot.
5383 (label_ref (match_operand 0 "" "")))]
5386 [(set_attr "type" "branch")
5387 (set_attr "mode" "none")
5388 (set_attr "length" "8")])
5390 (define_expand "indirect_jump"
5391 [(set (pc) (match_operand 0 "register_operand"))]
5394 operands[0] = force_reg (Pmode, operands[0]);
5395 if (Pmode == SImode)
5396 emit_jump_insn (gen_indirect_jumpsi (operands[0]));
5398 emit_jump_insn (gen_indirect_jumpdi (operands[0]));
5402 (define_insn "indirect_jump<mode>"
5403 [(set (pc) (match_operand:P 0 "register_operand" "d"))]
5406 [(set_attr "type" "jump")
5407 (set_attr "mode" "none")])
5409 (define_expand "tablejump"
5411 (match_operand 0 "register_operand"))
5412 (use (label_ref (match_operand 1 "")))]
5415 if (TARGET_MIPS16_SHORT_JUMP_TABLES)
5416 operands[0] = expand_binop (Pmode, add_optab,
5417 convert_to_mode (Pmode, operands[0], false),
5418 gen_rtx_LABEL_REF (Pmode, operands[1]),
5420 else if (TARGET_GPWORD)
5421 operands[0] = expand_binop (Pmode, add_optab, operands[0],
5422 pic_offset_table_rtx, 0, 0, OPTAB_WIDEN);
5423 else if (TARGET_RTP_PIC)
5425 /* When generating RTP PIC, we use case table entries that are relative
5426 to the start of the function. Add the function's address to the
5428 rtx start = get_hard_reg_initial_val (Pmode, PIC_FUNCTION_ADDR_REGNUM);
5429 operands[0] = expand_binop (ptr_mode, add_optab, operands[0],
5430 start, 0, 0, OPTAB_WIDEN);
5433 if (Pmode == SImode)
5434 emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
5436 emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
5440 (define_insn "tablejump<mode>"
5442 (match_operand:P 0 "register_operand" "d"))
5443 (use (label_ref (match_operand 1 "" "")))]
5446 [(set_attr "type" "jump")
5447 (set_attr "mode" "none")])
5449 ;; For TARGET_USE_GOT, we save the gp in the jmp_buf as well.
5450 ;; While it is possible to either pull it off the stack (in the
5451 ;; o32 case) or recalculate it given t9 and our target label,
5452 ;; it takes 3 or 4 insns to do so.
5454 (define_expand "builtin_setjmp_setup"
5455 [(use (match_operand 0 "register_operand"))]
5460 addr = plus_constant (operands[0], GET_MODE_SIZE (Pmode) * 3);
5461 mips_emit_move (gen_rtx_MEM (Pmode, addr), pic_offset_table_rtx);
5465 ;; Restore the gp that we saved above. Despite the earlier comment, it seems
5466 ;; that older code did recalculate the gp from $25. Continue to jump through
5467 ;; $25 for compatibility (we lose nothing by doing so).
5469 (define_expand "builtin_longjmp"
5470 [(use (match_operand 0 "register_operand"))]
5473 /* The elements of the buffer are, in order: */
5474 int W = GET_MODE_SIZE (Pmode);
5475 rtx fp = gen_rtx_MEM (Pmode, operands[0]);
5476 rtx lab = gen_rtx_MEM (Pmode, plus_constant (operands[0], 1*W));
5477 rtx stack = gen_rtx_MEM (Pmode, plus_constant (operands[0], 2*W));
5478 rtx gpv = gen_rtx_MEM (Pmode, plus_constant (operands[0], 3*W));
5479 rtx pv = gen_rtx_REG (Pmode, PIC_FUNCTION_ADDR_REGNUM);
5480 /* Use gen_raw_REG to avoid being given pic_offset_table_rtx.
5481 The target is bound to be using $28 as the global pointer
5482 but the current function might not be. */
5483 rtx gp = gen_raw_REG (Pmode, GLOBAL_POINTER_REGNUM);
5485 /* This bit is similar to expand_builtin_longjmp except that it
5486 restores $gp as well. */
5487 mips_emit_move (hard_frame_pointer_rtx, fp);
5488 mips_emit_move (pv, lab);
5489 emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
5490 mips_emit_move (gp, gpv);
5491 emit_insn (gen_rtx_USE (VOIDmode, hard_frame_pointer_rtx));
5492 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
5493 emit_insn (gen_rtx_USE (VOIDmode, gp));
5494 emit_indirect_jump (pv);
5499 ;; ....................
5501 ;; Function prologue/epilogue
5503 ;; ....................
5506 (define_expand "prologue"
5510 mips_expand_prologue ();
5514 ;; Block any insns from being moved before this point, since the
5515 ;; profiling call to mcount can use various registers that aren't
5516 ;; saved or used to pass arguments.
5518 (define_insn "blockage"
5519 [(unspec_volatile [(const_int 0)] UNSPEC_BLOCKAGE)]
5522 [(set_attr "type" "unknown")
5523 (set_attr "mode" "none")
5524 (set_attr "length" "0")])
5526 (define_expand "epilogue"
5530 mips_expand_epilogue (false);
5534 (define_expand "sibcall_epilogue"
5538 mips_expand_epilogue (true);
5542 ;; Trivial return. Make it look like a normal return insn as that
5543 ;; allows jump optimizations to work better.
5545 (define_insn "return"
5547 "mips_can_use_return_insn ()"
5549 [(set_attr "type" "jump")
5550 (set_attr "mode" "none")])
5554 (define_insn "return_internal"
5556 (use (match_operand 0 "pmode_register_operand" ""))]
5559 [(set_attr "type" "jump")
5560 (set_attr "mode" "none")])
5562 ;; This is used in compiling the unwind routines.
5563 (define_expand "eh_return"
5564 [(use (match_operand 0 "general_operand"))]
5567 if (GET_MODE (operands[0]) != word_mode)
5568 operands[0] = convert_to_mode (word_mode, operands[0], 0);
5570 emit_insn (gen_eh_set_lr_di (operands[0]));
5572 emit_insn (gen_eh_set_lr_si (operands[0]));
5576 ;; Clobber the return address on the stack. We can't expand this
5577 ;; until we know where it will be put in the stack frame.
5579 (define_insn "eh_set_lr_si"
5580 [(unspec [(match_operand:SI 0 "register_operand" "d")] UNSPEC_EH_RETURN)
5581 (clobber (match_scratch:SI 1 "=&d"))]
5585 (define_insn "eh_set_lr_di"
5586 [(unspec [(match_operand:DI 0 "register_operand" "d")] UNSPEC_EH_RETURN)
5587 (clobber (match_scratch:DI 1 "=&d"))]
5592 [(unspec [(match_operand 0 "register_operand")] UNSPEC_EH_RETURN)
5593 (clobber (match_scratch 1))]
5594 "reload_completed && !TARGET_DEBUG_D_MODE"
5597 mips_set_return_address (operands[0], operands[1]);
5601 (define_insn_and_split "exception_receiver"
5603 (unspec_volatile:SI [(const_int 0)] UNSPEC_EH_RECEIVER))]
5604 "TARGET_CALL_CLOBBERED_GP"
5606 "&& reload_completed"
5612 [(set_attr "type" "load")
5613 (set_attr "length" "12")])
5616 ;; ....................
5620 ;; ....................
5622 ;; Instructions to load a call address from the GOT. The address might
5623 ;; point to a function or to a lazy binding stub. In the latter case,
5624 ;; the stub will use the dynamic linker to resolve the function, which
5625 ;; in turn will change the GOT entry to point to the function's real
5628 ;; This means that every call, even pure and constant ones, can
5629 ;; potentially modify the GOT entry. And once a stub has been called,
5630 ;; we must not call it again.
5632 ;; We represent this restriction using an imaginary fixed register that
5633 ;; is set by the GOT load and used by the call. By making this register
5634 ;; call-clobbered, and by making the GOT load the only way of setting
5635 ;; the register, we ensure that the load cannot be moved past a call.
5636 (define_insn "load_call<mode>"
5637 [(set (match_operand:P 0 "register_operand" "=d")
5638 (unspec:P [(match_operand:P 1 "register_operand" "r")
5639 (match_operand:P 2 "immediate_operand" "")]
5641 (set (reg:P FAKE_CALL_REGNO)
5642 (unspec:P [(match_dup 2)] UNSPEC_LOAD_CALL))]
5644 "<load>\t%0,%R2(%1)"
5645 [(set_attr "type" "load")
5646 (set_attr "mode" "<MODE>")
5647 (set_attr "hazard_set" "0")
5648 (set_attr "length" "4")])
5650 ;; Sibling calls. All these patterns use jump instructions.
5652 ;; If TARGET_SIBCALLS, call_insn_operand will only accept constant
5653 ;; addresses if a direct jump is acceptable. Since the 'S' constraint
5654 ;; is defined in terms of call_insn_operand, the same is true of the
5657 ;; When we use an indirect jump, we need a register that will be
5658 ;; preserved by the epilogue. Since TARGET_USE_PIC_FN_ADDR_REG forces
5659 ;; us to use $25 for this purpose -- and $25 is never clobbered by the
5660 ;; epilogue -- we might as well use it for !TARGET_USE_PIC_FN_ADDR_REG
5663 (define_expand "sibcall"
5664 [(parallel [(call (match_operand 0 "")
5665 (match_operand 1 ""))
5666 (use (match_operand 2 "")) ;; next_arg_reg
5667 (use (match_operand 3 ""))])] ;; struct_value_size_rtx
5670 mips_expand_call (0, XEXP (operands[0], 0), operands[1], operands[2], true);
5674 (define_insn "sibcall_internal"
5675 [(call (mem:SI (match_operand 0 "call_insn_operand" "j,S"))
5676 (match_operand 1 "" ""))]
5677 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
5678 { return MIPS_CALL ("j", operands, 0); }
5679 [(set_attr "type" "call")])
5681 (define_expand "sibcall_value"
5682 [(parallel [(set (match_operand 0 "")
5683 (call (match_operand 1 "")
5684 (match_operand 2 "")))
5685 (use (match_operand 3 ""))])] ;; next_arg_reg
5688 mips_expand_call (operands[0], XEXP (operands[1], 0),
5689 operands[2], operands[3], true);
5693 (define_insn "sibcall_value_internal"
5694 [(set (match_operand 0 "register_operand" "")
5695 (call (mem:SI (match_operand 1 "call_insn_operand" "j,S"))
5696 (match_operand 2 "" "")))]
5697 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
5698 { return MIPS_CALL ("j", operands, 1); }
5699 [(set_attr "type" "call")])
5701 (define_insn "sibcall_value_multiple_internal"
5702 [(set (match_operand 0 "register_operand" "")
5703 (call (mem:SI (match_operand 1 "call_insn_operand" "j,S"))
5704 (match_operand 2 "" "")))
5705 (set (match_operand 3 "register_operand" "")
5706 (call (mem:SI (match_dup 1))
5708 "TARGET_SIBCALLS && SIBLING_CALL_P (insn)"
5709 { return MIPS_CALL ("j", operands, 1); }
5710 [(set_attr "type" "call")])
5712 (define_expand "call"
5713 [(parallel [(call (match_operand 0 "")
5714 (match_operand 1 ""))
5715 (use (match_operand 2 "")) ;; next_arg_reg
5716 (use (match_operand 3 ""))])] ;; struct_value_size_rtx
5719 mips_expand_call (0, XEXP (operands[0], 0), operands[1], operands[2], false);
5723 ;; This instruction directly corresponds to an assembly-language "jal".
5724 ;; There are four cases:
5727 ;; Both symbolic and register destinations are OK. The pattern
5728 ;; always expands to a single mips instruction.
5730 ;; - -mabicalls/-mno-explicit-relocs:
5731 ;; Again, both symbolic and register destinations are OK.
5732 ;; The call is treated as a multi-instruction black box.
5734 ;; - -mabicalls/-mexplicit-relocs with n32 or n64:
5735 ;; Only "jal $25" is allowed. This expands to a single "jalr $25"
5738 ;; - -mabicalls/-mexplicit-relocs with o32 or o64:
5739 ;; Only "jal $25" is allowed. The call is actually two instructions:
5740 ;; "jalr $25" followed by an insn to reload $gp.
5742 ;; In the last case, we can generate the individual instructions with
5743 ;; a define_split. There are several things to be wary of:
5745 ;; - We can't expose the load of $gp before reload. If we did,
5746 ;; it might get removed as dead, but reload can introduce new
5747 ;; uses of $gp by rematerializing constants.
5749 ;; - We shouldn't restore $gp after calls that never return.
5750 ;; It isn't valid to insert instructions between a noreturn
5751 ;; call and the following barrier.
5753 ;; - The splitter deliberately changes the liveness of $gp. The unsplit
5754 ;; instruction preserves $gp and so have no effect on its liveness.
5755 ;; But once we generate the separate insns, it becomes obvious that
5756 ;; $gp is not live on entry to the call.
5758 ;; ??? The operands[2] = insn check is a hack to make the original insn
5759 ;; available to the splitter.
5760 (define_insn_and_split "call_internal"
5761 [(call (mem:SI (match_operand 0 "call_insn_operand" "c,S"))
5762 (match_operand 1 "" ""))
5763 (clobber (reg:SI 31))]
5765 { return TARGET_SPLIT_CALLS ? "#" : MIPS_CALL ("jal", operands, 0); }
5766 "reload_completed && TARGET_SPLIT_CALLS && (operands[2] = insn)"
5769 emit_call_insn (gen_call_split (operands[0], operands[1]));
5770 if (!find_reg_note (operands[2], REG_NORETURN, 0))
5774 [(set_attr "jal" "indirect,direct")
5775 (set_attr "extended_mips16" "no,yes")])
5777 ;; A pattern for calls that must be made directly. It is used for
5778 ;; MIPS16 calls that the linker may need to redirect to a hard-float
5779 ;; stub; the linker relies on the call relocation type to detect when
5780 ;; such redirection is needed.
5781 (define_insn "call_internal_direct"
5782 [(call (mem:SI (match_operand 0 "const_call_insn_operand"))
5785 (clobber (reg:SI 31))]
5787 { return MIPS_CALL ("jal", operands, 0); })
5789 (define_insn "call_split"
5790 [(call (mem:SI (match_operand 0 "call_insn_operand" "cS"))
5791 (match_operand 1 "" ""))
5792 (clobber (reg:SI 31))
5793 (clobber (reg:SI 28))]
5794 "TARGET_SPLIT_CALLS"
5795 { return MIPS_CALL ("jal", operands, 0); }
5796 [(set_attr "type" "call")])
5798 (define_expand "call_value"
5799 [(parallel [(set (match_operand 0 "")
5800 (call (match_operand 1 "")
5801 (match_operand 2 "")))
5802 (use (match_operand 3 ""))])] ;; next_arg_reg
5805 mips_expand_call (operands[0], XEXP (operands[1], 0),
5806 operands[2], operands[3], false);
5810 ;; See comment for call_internal.
5811 (define_insn_and_split "call_value_internal"
5812 [(set (match_operand 0 "register_operand" "")
5813 (call (mem:SI (match_operand 1 "call_insn_operand" "c,S"))
5814 (match_operand 2 "" "")))
5815 (clobber (reg:SI 31))]
5817 { return TARGET_SPLIT_CALLS ? "#" : MIPS_CALL ("jal", operands, 1); }
5818 "reload_completed && TARGET_SPLIT_CALLS && (operands[3] = insn)"
5821 emit_call_insn (gen_call_value_split (operands[0], operands[1],
5823 if (!find_reg_note (operands[3], REG_NORETURN, 0))
5827 [(set_attr "jal" "indirect,direct")
5828 (set_attr "extended_mips16" "no,yes")])
5830 (define_insn "call_value_split"
5831 [(set (match_operand 0 "register_operand" "")
5832 (call (mem:SI (match_operand 1 "call_insn_operand" "cS"))
5833 (match_operand 2 "" "")))
5834 (clobber (reg:SI 31))
5835 (clobber (reg:SI 28))]
5836 "TARGET_SPLIT_CALLS"
5837 { return MIPS_CALL ("jal", operands, 1); }
5838 [(set_attr "type" "call")])
5840 ;; See call_internal_direct.
5841 (define_insn "call_value_internal_direct"
5842 [(set (match_operand 0 "register_operand")
5843 (call (mem:SI (match_operand 1 "const_call_insn_operand"))
5846 (clobber (reg:SI 31))]
5848 { return MIPS_CALL ("jal", operands, 1); })
5850 ;; See comment for call_internal.
5851 (define_insn_and_split "call_value_multiple_internal"
5852 [(set (match_operand 0 "register_operand" "")
5853 (call (mem:SI (match_operand 1 "call_insn_operand" "c,S"))
5854 (match_operand 2 "" "")))
5855 (set (match_operand 3 "register_operand" "")
5856 (call (mem:SI (match_dup 1))
5858 (clobber (reg:SI 31))]
5860 { return TARGET_SPLIT_CALLS ? "#" : MIPS_CALL ("jal", operands, 1); }
5861 "reload_completed && TARGET_SPLIT_CALLS && (operands[4] = insn)"
5864 emit_call_insn (gen_call_value_multiple_split (operands[0], operands[1],
5865 operands[2], operands[3]));
5866 if (!find_reg_note (operands[4], REG_NORETURN, 0))
5870 [(set_attr "jal" "indirect,direct")
5871 (set_attr "extended_mips16" "no,yes")])
5873 (define_insn "call_value_multiple_split"
5874 [(set (match_operand 0 "register_operand" "")
5875 (call (mem:SI (match_operand 1 "call_insn_operand" "cS"))
5876 (match_operand 2 "" "")))
5877 (set (match_operand 3 "register_operand" "")
5878 (call (mem:SI (match_dup 1))
5880 (clobber (reg:SI 31))
5881 (clobber (reg:SI 28))]
5882 "TARGET_SPLIT_CALLS"
5883 { return MIPS_CALL ("jal", operands, 1); }
5884 [(set_attr "type" "call")])
5886 ;; Call subroutine returning any type.
5888 (define_expand "untyped_call"
5889 [(parallel [(call (match_operand 0 "")
5891 (match_operand 1 "")
5892 (match_operand 2 "")])]
5897 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
5899 for (i = 0; i < XVECLEN (operands[2], 0); i++)
5901 rtx set = XVECEXP (operands[2], 0, i);
5902 mips_emit_move (SET_DEST (set), SET_SRC (set));
5905 emit_insn (gen_blockage ());
5910 ;; ....................
5914 ;; ....................
5918 (define_insn "prefetch"
5919 [(prefetch (match_operand:QI 0 "address_operand" "p")
5920 (match_operand 1 "const_int_operand" "n")
5921 (match_operand 2 "const_int_operand" "n"))]
5922 "ISA_HAS_PREFETCH && TARGET_EXPLICIT_RELOCS"
5924 operands[1] = mips_prefetch_cookie (operands[1], operands[2]);
5925 return "pref\t%1,%a0";
5927 [(set_attr "type" "prefetch")])
5929 (define_insn "*prefetch_indexed_<mode>"
5930 [(prefetch (plus:P (match_operand:P 0 "register_operand" "d")
5931 (match_operand:P 1 "register_operand" "d"))
5932 (match_operand 2 "const_int_operand" "n")
5933 (match_operand 3 "const_int_operand" "n"))]
5934 "ISA_HAS_PREFETCHX && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
5936 operands[2] = mips_prefetch_cookie (operands[2], operands[3]);
5937 return "prefx\t%2,%1(%0)";
5939 [(set_attr "type" "prefetchx")])
5945 [(set_attr "type" "nop")
5946 (set_attr "mode" "none")])
5948 ;; Like nop, but commented out when outside a .set noreorder block.
5949 (define_insn "hazard_nop"
5958 [(set_attr "type" "nop")])
5960 ;; MIPS4 Conditional move instructions.
5962 (define_insn "*mov<GPR:mode>_on_<MOVECC:mode>"
5963 [(set (match_operand:GPR 0 "register_operand" "=d,d")
5965 (match_operator:MOVECC 4 "equality_operator"
5966 [(match_operand:MOVECC 1 "register_operand" "<MOVECC:reg>,<MOVECC:reg>")
5968 (match_operand:GPR 2 "reg_or_0_operand" "dJ,0")
5969 (match_operand:GPR 3 "reg_or_0_operand" "0,dJ")))]
5974 [(set_attr "type" "condmove")
5975 (set_attr "mode" "<GPR:MODE>")])
5977 (define_insn "*mov<SCALARF:mode>_on_<MOVECC:mode>"
5978 [(set (match_operand:SCALARF 0 "register_operand" "=f,f")
5979 (if_then_else:SCALARF
5980 (match_operator:MOVECC 4 "equality_operator"
5981 [(match_operand:MOVECC 1 "register_operand" "<MOVECC:reg>,<MOVECC:reg>")
5983 (match_operand:SCALARF 2 "register_operand" "f,0")
5984 (match_operand:SCALARF 3 "register_operand" "0,f")))]
5987 mov%T4.<fmt>\t%0,%2,%1
5988 mov%t4.<fmt>\t%0,%3,%1"
5989 [(set_attr "type" "condmove")
5990 (set_attr "mode" "<SCALARF:MODE>")])
5992 ;; These are the main define_expand's used to make conditional moves.
5994 (define_expand "mov<mode>cc"
5995 [(set (match_dup 4) (match_operand 1 "comparison_operator"))
5996 (set (match_operand:GPR 0 "register_operand")
5997 (if_then_else:GPR (match_dup 5)
5998 (match_operand:GPR 2 "reg_or_0_operand")
5999 (match_operand:GPR 3 "reg_or_0_operand")))]
6002 mips_expand_conditional_move (operands);
6006 (define_expand "mov<mode>cc"
6007 [(set (match_dup 4) (match_operand 1 "comparison_operator"))
6008 (set (match_operand:SCALARF 0 "register_operand")
6009 (if_then_else:SCALARF (match_dup 5)
6010 (match_operand:SCALARF 2 "register_operand")
6011 (match_operand:SCALARF 3 "register_operand")))]
6014 mips_expand_conditional_move (operands);
6019 ;; ....................
6021 ;; mips16 inline constant tables
6023 ;; ....................
6026 (define_insn "consttable_int"
6027 [(unspec_volatile [(match_operand 0 "consttable_operand" "")
6028 (match_operand 1 "const_int_operand" "")]
6029 UNSPEC_CONSTTABLE_INT)]
6032 assemble_integer (operands[0], INTVAL (operands[1]),
6033 BITS_PER_UNIT * INTVAL (operands[1]), 1);
6036 [(set (attr "length") (symbol_ref "INTVAL (operands[1])"))])
6038 (define_insn "consttable_float"
6039 [(unspec_volatile [(match_operand 0 "consttable_operand" "")]
6040 UNSPEC_CONSTTABLE_FLOAT)]
6045 gcc_assert (GET_CODE (operands[0]) == CONST_DOUBLE);
6046 REAL_VALUE_FROM_CONST_DOUBLE (d, operands[0]);
6047 assemble_real (d, GET_MODE (operands[0]),
6048 GET_MODE_BITSIZE (GET_MODE (operands[0])));
6051 [(set (attr "length")
6052 (symbol_ref "GET_MODE_SIZE (GET_MODE (operands[0]))"))])
6054 (define_insn "align"
6055 [(unspec_volatile [(match_operand 0 "const_int_operand" "")] UNSPEC_ALIGN)]
6058 [(set (attr "length") (symbol_ref "(1 << INTVAL (operands[0])) - 1"))])
6061 [(match_operand 0 "small_data_pattern")]
6064 { operands[0] = mips_rewrite_small_data (operands[0]); })
6067 ;; ....................
6069 ;; MIPS16e Save/Restore
6071 ;; ....................
6074 (define_insn "*mips16e_save_restore"
6075 [(match_parallel 0 ""
6076 [(set (match_operand:SI 1 "register_operand")
6077 (plus:SI (match_dup 1)
6078 (match_operand:SI 2 "const_int_operand")))])]
6079 "operands[1] == stack_pointer_rtx
6080 && mips16e_save_restore_pattern_p (operands[0], INTVAL (operands[2]), NULL)"
6081 { return mips16e_output_save_restore (operands[0], INTVAL (operands[2])); }
6082 [(set_attr "type" "arith")
6083 (set_attr "extended_mips16" "yes")])
6085 ; Thread-Local Storage
6087 ; The TLS base pointer is accessed via "rdhwr $v1, $29". No current
6088 ; MIPS architecture defines this register, and no current
6089 ; implementation provides it; instead, any OS which supports TLS is
6090 ; expected to trap and emulate this instruction. rdhwr is part of the
6091 ; MIPS 32r2 specification, but we use it on any architecture because
6092 ; we expect it to be emulated. Use .set to force the assembler to
6095 (define_insn "tls_get_tp_<mode>"
6096 [(set (match_operand:P 0 "register_operand" "=v")
6097 (unspec:P [(const_int 0)]
6098 UNSPEC_TLS_GET_TP))]
6099 "HAVE_AS_TLS && !TARGET_MIPS16"
6100 ".set\tpush\;.set\tmips32r2\t\;rdhwr\t%0,$29\;.set\tpop"
6101 [(set_attr "type" "unknown")
6102 ; Since rdhwr always generates a trap for now, putting it in a delay
6103 ; slot would make the kernel's emulation of it much slower.
6104 (set_attr "can_delay" "no")
6105 (set_attr "mode" "<MODE>")])
6107 ; The MIPS Paired-Single Floating Point and MIPS-3D Instructions.
6109 (include "mips-ps-3d.md")
6111 ; The MIPS DSP Instructions.
6113 (include "mips-dsp.md")
6115 ; The MIPS DSP REV 2 Instructions.
6117 (include "mips-dspr2.md")
6119 ; MIPS fixed-point instructions.
6120 (include "mips-fixed.md")