| 1 |
;; Mips.md Machine Description for MIPS based processors |
| 2 |
;; Copyright (C) 1989-2025 Free Software Foundation, Inc. |
| 3 |
;; Contributed by A. Lichnewsky, [email protected] |
| 4 |
;; Changes by Michael Meissner, [email protected] |
| 5 |
;; 64-bit r4000 support by Ian Lance Taylor, [email protected], and |
| 6 |
;; Brendan Eich, [email protected]. |
| 7 |
|
| 8 |
;; This file is part of GCC. |
| 9 |
|
| 10 |
;; GCC is free software; you can redistribute it and/or modify |
| 11 |
;; it under the terms of the GNU General Public License as published by |
| 12 |
;; the Free Software Foundation; either version 3, or (at your option) |
| 13 |
;; any later version. |
| 14 |
|
| 15 |
;; GCC is distributed in the hope that it will be useful, |
| 16 |
;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
;; GNU General Public License for more details. |
| 19 |
|
| 20 |
;; You should have received a copy of the GNU General Public License |
| 21 |
;; along with GCC; see the file COPYING3. If not see |
| 22 |
;; <http://www.gnu.org/licenses/>. |
| 23 |
|
| 24 |
(define_enum "processor" [ |
| 25 |
r3000 |
| 26 |
4kc |
| 27 |
4kp |
| 28 |
5kc |
| 29 |
5kf |
| 30 |
20kc |
| 31 |
24kc |
| 32 |
24kf2_1 |
| 33 |
24kf1_1 |
| 34 |
74kc |
| 35 |
74kf2_1 |
| 36 |
74kf1_1 |
| 37 |
74kf3_2 |
| 38 |
loongson_2e |
| 39 |
loongson_2f |
| 40 |
gs464 |
| 41 |
gs464e |
| 42 |
gs264e |
| 43 |
m4k |
| 44 |
octeon |
| 45 |
octeon2 |
| 46 |
octeon3 |
| 47 |
r3900 |
| 48 |
r6000 |
| 49 |
r4000 |
| 50 |
r4100 |
| 51 |
r4111 |
| 52 |
r4120 |
| 53 |
r4130 |
| 54 |
r4300 |
| 55 |
r4600 |
| 56 |
r4650 |
| 57 |
r4700 |
| 58 |
r5000 |
| 59 |
r5400 |
| 60 |
r5500 |
| 61 |
r5900 |
| 62 |
r7000 |
| 63 |
r8000 |
| 64 |
r9000 |
| 65 |
r10000 |
| 66 |
sb1 |
| 67 |
sb1a |
| 68 |
sr71000 |
| 69 |
xlr |
| 70 |
xlp |
| 71 |
p5600 |
| 72 |
m5100 |
| 73 |
i6400 |
| 74 |
p6600 |
| 75 |
]) |
| 76 |
|
| 77 |
(define_c_enum "unspec" [ |
| 78 |
;; Unaligned accesses. |
| 79 |
UNSPEC_LOAD_LEFT |
| 80 |
UNSPEC_LOAD_RIGHT |
| 81 |
UNSPEC_STORE_LEFT |
| 82 |
UNSPEC_STORE_RIGHT |
| 83 |
|
| 84 |
;; Integer operations that are too cumbersome to describe directly. |
| 85 |
UNSPEC_WSBH |
| 86 |
UNSPEC_DSBH |
| 87 |
UNSPEC_DSHD |
| 88 |
|
| 89 |
;; Floating-point moves. |
| 90 |
UNSPEC_LOAD_LOW |
| 91 |
UNSPEC_LOAD_HIGH |
| 92 |
UNSPEC_STORE_WORD |
| 93 |
UNSPEC_MFHC1 |
| 94 |
UNSPEC_MTHC1 |
| 95 |
|
| 96 |
;; Floating-point environment. |
| 97 |
UNSPEC_GET_FCSR |
| 98 |
UNSPEC_SET_FCSR |
| 99 |
|
| 100 |
;; Floating-point unspecs. |
| 101 |
UNSPEC_FMIN |
| 102 |
UNSPEC_FMAX |
| 103 |
UNSPEC_FRINT |
| 104 |
UNSPEC_FCLASS |
| 105 |
|
| 106 |
;; HI/LO moves. |
| 107 |
UNSPEC_MFHI |
| 108 |
UNSPEC_MTHI |
| 109 |
UNSPEC_SET_HILO |
| 110 |
|
| 111 |
;; GP manipulation. |
| 112 |
UNSPEC_LOADGP |
| 113 |
UNSPEC_COPYGP |
| 114 |
UNSPEC_MOVE_GP |
| 115 |
UNSPEC_POTENTIAL_CPRESTORE |
| 116 |
UNSPEC_CPRESTORE |
| 117 |
UNSPEC_RESTORE_GP |
| 118 |
UNSPEC_EH_RETURN |
| 119 |
UNSPEC_GP |
| 120 |
UNSPEC_SET_GOT_VERSION |
| 121 |
UNSPEC_UPDATE_GOT_VERSION |
| 122 |
|
| 123 |
;; Symbolic accesses. |
| 124 |
UNSPEC_LOAD_CALL |
| 125 |
UNSPEC_LOAD_GOT |
| 126 |
UNSPEC_TLS_LDM |
| 127 |
UNSPEC_TLS_GET_TP |
| 128 |
UNSPEC_UNSHIFTED_HIGH |
| 129 |
|
| 130 |
;; MIPS16 constant pools. |
| 131 |
UNSPEC_ALIGN |
| 132 |
UNSPEC_CONSTTABLE |
| 133 |
UNSPEC_CONSTTABLE_END |
| 134 |
UNSPEC_CONSTTABLE_INT |
| 135 |
UNSPEC_CONSTTABLE_FLOAT |
| 136 |
|
| 137 |
;; Blockage and synchronisation. |
| 138 |
UNSPEC_BLOCKAGE |
| 139 |
UNSPEC_CLEAR_HAZARD |
| 140 |
UNSPEC_RDHWR |
| 141 |
UNSPEC_SYNCI |
| 142 |
UNSPEC_SYNC |
| 143 |
|
| 144 |
;; Cache manipulation. |
| 145 |
UNSPEC_MIPS_CACHE |
| 146 |
UNSPEC_R10K_CACHE_BARRIER |
| 147 |
|
| 148 |
;; Interrupt handling. |
| 149 |
UNSPEC_ERET |
| 150 |
UNSPEC_DERET |
| 151 |
UNSPEC_DI |
| 152 |
UNSPEC_EHB |
| 153 |
UNSPEC_RDPGPR |
| 154 |
UNSPEC_COP0 |
| 155 |
|
| 156 |
;; Used in a call expression in place of args_size. It's present for PIC |
| 157 |
;; indirect calls where it contains args_size and the function symbol. |
| 158 |
UNSPEC_CALL_ATTR |
| 159 |
|
| 160 |
;; MIPS16 casesi jump table dispatch. |
| 161 |
UNSPEC_CASESI_DISPATCH |
| 162 |
|
| 163 |
;; Stack checking. |
| 164 |
UNSPEC_PROBE_STACK_RANGE |
| 165 |
|
| 166 |
;; The `.insn' pseudo-op. |
| 167 |
UNSPEC_INSN_PSEUDO |
| 168 |
UNSPEC_JRHB |
| 169 |
|
| 170 |
VUNSPEC_SPECULATION_BARRIER |
| 171 |
]) |
| 172 |
|
| 173 |
(define_constants |
| 174 |
[(TLS_GET_TP_REGNUM 3) |
| 175 |
(GET_FCSR_REGNUM 2) |
| 176 |
(SET_FCSR_REGNUM 4) |
| 177 |
(PIC_FUNCTION_ADDR_REGNUM 25) |
| 178 |
(GLOBAL_POINTER_REGNUM 28) |
| 179 |
(RETURN_ADDR_REGNUM 31) |
| 180 |
(CPRESTORE_SLOT_REGNUM 76) |
| 181 |
(GOT_VERSION_REGNUM 79) |
| 182 |
|
| 183 |
;; PIC long branch sequences are never longer than 100 bytes. |
| 184 |
(MAX_PIC_BRANCH_LENGTH 100) |
| 185 |
] |
| 186 |
) |
| 187 |
|
| 188 |
(include "predicates.md") |
| 189 |
(include "constraints.md") |
| 190 |
|
| 191 |
;; .................... |
| 192 |
;; |
| 193 |
;; Attributes |
| 194 |
;; |
| 195 |
;; .................... |
| 196 |
|
| 197 |
(define_attr "got" "unset,xgot_high,load" |
| 198 |
(const_string "unset")) |
| 199 |
|
| 200 |
;; For jal instructions, this attribute is DIRECT when the target address |
| 201 |
;; is symbolic and INDIRECT when it is a register. |
| 202 |
(define_attr "jal" "unset,direct,indirect" |
| 203 |
(const_string "unset")) |
| 204 |
|
| 205 |
;; This attribute is YES if the instruction is a jal macro (not a |
| 206 |
;; real jal instruction). |
| 207 |
;; |
| 208 |
;; jal is always a macro for TARGET_CALL_CLOBBERED_GP because it includes |
| 209 |
;; an instruction to restore $gp. Direct jals are also macros for |
| 210 |
;; !TARGET_ABSOLUTE_JUMPS because they first load the target address |
| 211 |
;; into a register. |
| 212 |
(define_attr "jal_macro" "no,yes" |
| 213 |
(cond [(eq_attr "jal" "direct") |
| 214 |
(symbol_ref "(TARGET_CALL_CLOBBERED_GP || !TARGET_ABSOLUTE_JUMPS |
| 215 |
? JAL_MACRO_YES : JAL_MACRO_NO)") |
| 216 |
(eq_attr "jal" "indirect") |
| 217 |
(symbol_ref "(TARGET_CALL_CLOBBERED_GP |
| 218 |
? JAL_MACRO_YES : JAL_MACRO_NO)")] |
| 219 |
(const_string "no"))) |
| 220 |
|
| 221 |
;; Classification of moves, extensions and truncations. Most values |
| 222 |
;; are as for "type" (see below) but there are also the following |
| 223 |
;; move-specific values: |
| 224 |
;; |
| 225 |
;; constN move an N-constraint integer into a MIPS16 register |
| 226 |
;; sll0 "sll DEST,SRC,0", which on 64-bit targets is guaranteed |
| 227 |
;; to produce a sign-extended DEST, even if SRC is not |
| 228 |
;; properly sign-extended |
| 229 |
;; ext_ins EXT, DEXT, INS or DINS instruction |
| 230 |
;; andi a single ANDI instruction |
| 231 |
;; loadpool move a constant into a MIPS16 register by loading it |
| 232 |
;; from the pool |
| 233 |
;; shift_shift a shift left followed by a shift right |
| 234 |
;; |
| 235 |
;; This attribute is used to determine the instruction's length and |
| 236 |
;; scheduling type. For doubleword moves, the attribute always describes |
| 237 |
;; the split instructions; in some cases, it is more appropriate for the |
| 238 |
;; scheduling type to be "multi" instead. |
| 239 |
(define_attr "move_type" |
| 240 |
"unknown,load,fpload,store,fpstore,mtc,mfc,mtlo,mflo,imul,move,fmove, |
| 241 |
const,constN,signext,ext_ins,logical,arith,sll0,andi,loadpool, |
| 242 |
shift_shift" |
| 243 |
(const_string "unknown")) |
| 244 |
|
| 245 |
(define_attr "alu_type" "unknown,add,sub,not,nor,and,or,xor,simd_add" |
| 246 |
(const_string "unknown")) |
| 247 |
|
| 248 |
;; Main data type used by the insn |
| 249 |
(define_attr "mode" "unknown,none,QI,HI,SI,DI,TI,SF,DF,TF,FPSW, |
| 250 |
V2DI,V4SI,V8HI,V16QI,V2DF,V4SF" |
| 251 |
(const_string "unknown")) |
| 252 |
|
| 253 |
;; True if the main data type is twice the size of a word. |
| 254 |
(define_attr "dword_mode" "no,yes" |
| 255 |
(cond [(and (eq_attr "mode" "DI,DF") |
| 256 |
(not (match_test "TARGET_64BIT"))) |
| 257 |
(const_string "yes") |
| 258 |
|
| 259 |
(and (eq_attr "mode" "TI,TF") |
| 260 |
(match_test "TARGET_64BIT")) |
| 261 |
(const_string "yes")] |
| 262 |
(const_string "no"))) |
| 263 |
|
| 264 |
;; True if the main data type is four times of the size of a word. |
| 265 |
(define_attr "qword_mode" "no,yes" |
| 266 |
(cond [(and (eq_attr "mode" "TI,TF") |
| 267 |
(not (match_test "TARGET_64BIT"))) |
| 268 |
(const_string "yes")] |
| 269 |
(const_string "no"))) |
| 270 |
|
| 271 |
;; Attributes describing a sync loop. These loops have the form: |
| 272 |
;; |
| 273 |
;; if (RELEASE_BARRIER == YES) sync |
| 274 |
;; 1: OLDVAL = *MEM |
| 275 |
;; if ((OLDVAL & INCLUSIVE_MASK) != REQUIRED_OLDVAL) goto 2 |
| 276 |
;; CMP = 0 [delay slot] |
| 277 |
;; $TMP1 = OLDVAL & EXCLUSIVE_MASK |
| 278 |
;; $TMP2 = INSN1 (OLDVAL, INSN1_OP2) |
| 279 |
;; $TMP3 = INSN2 ($TMP2, INCLUSIVE_MASK) |
| 280 |
;; $AT |= $TMP1 | $TMP3 |
| 281 |
;; if (!commit (*MEM = $AT)) goto 1. |
| 282 |
;; if (INSN1 != MOVE && INSN1 != LI) NEWVAL = $TMP3 [delay slot] |
| 283 |
;; CMP = 1 |
| 284 |
;; if (ACQUIRE_BARRIER == YES) sync |
| 285 |
;; 2: |
| 286 |
;; |
| 287 |
;; where "$" values are temporaries and where the other values are |
| 288 |
;; specified by the attributes below. Values are specified as operand |
| 289 |
;; numbers and insns are specified as enums. If no operand number is |
| 290 |
;; specified, the following values are used instead: |
| 291 |
;; |
| 292 |
;; - OLDVAL: $AT |
| 293 |
;; - CMP: NONE |
| 294 |
;; - NEWVAL: $AT |
| 295 |
;; - INCLUSIVE_MASK: -1 |
| 296 |
;; - REQUIRED_OLDVAL: OLDVAL & INCLUSIVE_MASK |
| 297 |
;; - EXCLUSIVE_MASK: 0 |
| 298 |
;; |
| 299 |
;; MEM and INSN1_OP2 are required. |
| 300 |
;; |
| 301 |
;; Ideally, the operand attributes would be integers, with -1 meaning "none", |
| 302 |
;; but the gen* programs don't yet support that. |
| 303 |
(define_attr "sync_mem" "none,0,1,2,3,4,5" (const_string "none")) |
| 304 |
(define_attr "sync_oldval" "none,0,1,2,3,4,5" (const_string "none")) |
| 305 |
(define_attr "sync_cmp" "none,0,1,2,3,4,5" (const_string "none")) |
| 306 |
(define_attr "sync_newval" "none,0,1,2,3,4,5" (const_string "none")) |
| 307 |
(define_attr "sync_inclusive_mask" "none,0,1,2,3,4,5" (const_string "none")) |
| 308 |
(define_attr "sync_exclusive_mask" "none,0,1,2,3,4,5" (const_string "none")) |
| 309 |
(define_attr "sync_required_oldval" "none,0,1,2,3,4,5" (const_string "none")) |
| 310 |
(define_attr "sync_insn1_op2" "none,0,1,2,3,4,5" (const_string "none")) |
| 311 |
(define_attr "sync_insn1" "move,li,addu,addiu,subu,and,andi,or,ori,xor,xori" |
| 312 |
(const_string "move")) |
| 313 |
(define_attr "sync_insn2" "nop,and,xor,not" |
| 314 |
(const_string "nop")) |
| 315 |
;; Memory model specifier. |
| 316 |
;; "0"-"9" values specify the operand that stores the memory model value. |
| 317 |
;; "10" specifies MEMMODEL_ACQ_REL, |
| 318 |
;; "11" specifies MEMMODEL_ACQUIRE. |
| 319 |
(define_attr "sync_memmodel" "" (const_int 10)) |
| 320 |
|
| 321 |
;; Performance ratio. Add this attr to the slow INSNs. |
| 322 |
;; Used by mips_insn_cost. |
| 323 |
(define_attr "perf_ratio" "" (const_int 0)) |
| 324 |
|
| 325 |
;; Accumulator operand for madd patterns. |
| 326 |
(define_attr "accum_in" "none,0,1,2,3,4,5" (const_string "none")) |
| 327 |
|
| 328 |
;; Classification of each insn. |
| 329 |
;; branch conditional branch |
| 330 |
;; jump unconditional jump |
| 331 |
;; call unconditional call |
| 332 |
;; load load instruction(s) |
| 333 |
;; fpload floating point load |
| 334 |
;; fpidxload floating point indexed load |
| 335 |
;; store store instruction(s) |
| 336 |
;; fpstore floating point store |
| 337 |
;; fpidxstore floating point indexed store |
| 338 |
;; prefetch memory prefetch (register + offset) |
| 339 |
;; prefetchx memory indexed prefetch (register + register) |
| 340 |
;; condmove conditional moves |
| 341 |
;; mtc transfer to coprocessor |
| 342 |
;; mfc transfer from coprocessor |
| 343 |
;; mthi transfer to a hi register |
| 344 |
;; mtlo transfer to a lo register |
| 345 |
;; mfhi transfer from a hi register |
| 346 |
;; mflo transfer from a lo register |
| 347 |
;; const load constant |
| 348 |
;; arith integer arithmetic instructions |
| 349 |
;; logical integer logical instructions |
| 350 |
;; shift integer shift instructions |
| 351 |
;; slt set less than instructions |
| 352 |
;; signext sign extend instructions |
| 353 |
;; clz the clz and clo instructions |
| 354 |
;; pop the pop instruction |
| 355 |
;; trap trap if instructions |
| 356 |
;; imul integer multiply 2 operands |
| 357 |
;; imul3 integer multiply 3 operands |
| 358 |
;; imul3nc integer multiply 3 operands without clobbering HI/LO |
| 359 |
;; imadd integer multiply-add |
| 360 |
;; idiv integer divide 2 operands |
| 361 |
;; idiv3 integer divide 3 operands |
| 362 |
;; move integer register move ({,D}ADD{,U} with rt = 0) |
| 363 |
;; fmove floating point register move |
| 364 |
;; fadd floating point add/subtract |
| 365 |
;; fmul floating point multiply |
| 366 |
;; fmadd floating point multiply-add |
| 367 |
;; fdiv floating point divide |
| 368 |
;; frdiv floating point reciprocal divide |
| 369 |
;; frdiv1 floating point reciprocal divide step 1 |
| 370 |
;; frdiv2 floating point reciprocal divide step 2 |
| 371 |
;; fabs floating point absolute value |
| 372 |
;; fneg floating point negation |
| 373 |
;; fcmp floating point compare |
| 374 |
;; fcvt floating point convert |
| 375 |
;; fsqrt floating point square root |
| 376 |
;; frsqrt floating point reciprocal square root |
| 377 |
;; frsqrt1 floating point reciprocal square root step1 |
| 378 |
;; frsqrt2 floating point reciprocal square root step2 |
| 379 |
;; fminmax floating point min/max |
| 380 |
;; frint floating point round to integral |
| 381 |
;; fclass floating point class mask |
| 382 |
;; dspmac DSP MAC instructions not saturating the accumulator |
| 383 |
;; dspmacsat DSP MAC instructions that saturate the accumulator |
| 384 |
;; accext DSP accumulator extract instructions |
| 385 |
;; accmod DSP accumulator modify instructions |
| 386 |
;; dspalu DSP ALU instructions not saturating the result |
| 387 |
;; dspalusat DSP ALU instructions that saturate the result |
| 388 |
;; multi multiword sequence (or user asm statements) |
| 389 |
;; atomic atomic memory update instruction |
| 390 |
;; syncloop memory atomic operation implemented as a sync loop |
| 391 |
;; nop no operation |
| 392 |
;; ghost an instruction that produces no real code |
| 393 |
;; multimem microMIPS multiword load and store |
| 394 |
(define_attr "type" |
| 395 |
"unknown,branch,jump,call,load,fpload,fpidxload,store,fpstore,fpidxstore, |
| 396 |
prefetch,prefetchx,condmove,mtc,mfc,mthi,mtlo,mfhi,mflo,const,arith,logical, |
| 397 |
shift,slt,signext,clz,pop,trap,imul,imul3,imul3nc,imadd,idiv,idiv3,move, |
| 398 |
fmove,fadd,fmul,fmadd,fdiv,frdiv,frdiv1,frdiv2,fabs,fneg,fcmp,fcvt,fsqrt, |
| 399 |
frsqrt,frsqrt1,frsqrt2,fminmax,frint,fclass,dspmac,dspmacsat,accext, |
| 400 |
accmod,dspalu,dspalusat,multi,atomic,syncloop,nop,ghost,multimem, |
| 401 |
simd_div,simd_fclass,simd_flog2,simd_fadd,simd_fcvt,simd_fmul,simd_fmadd, |
| 402 |
simd_fdiv,simd_bitins,simd_bitmov,simd_insert,simd_sld,simd_mul,simd_fcmp, |
| 403 |
simd_fexp2,simd_int_arith,simd_bit,simd_shift,simd_splat,simd_fill, |
| 404 |
simd_permute,simd_shf,simd_sat,simd_pcnt,simd_copy,simd_branch,simd_cmsa, |
| 405 |
simd_fminmax,simd_logic,simd_move,simd_load,simd_store" |
| 406 |
(cond [(eq_attr "jal" "!unset") (const_string "call") |
| 407 |
(eq_attr "got" "load") (const_string "load") |
| 408 |
|
| 409 |
(eq_attr "alu_type" "add,sub") (const_string "arith") |
| 410 |
|
| 411 |
(eq_attr "alu_type" "not,nor,and,or,xor") (const_string "logical") |
| 412 |
|
| 413 |
;; If a doubleword move uses these expensive instructions, |
| 414 |
;; it is usually better to schedule them in the same way |
| 415 |
;; as the singleword form, rather than as "multi". |
| 416 |
(eq_attr "move_type" "load") (const_string "load") |
| 417 |
(eq_attr "move_type" "fpload") (const_string "fpload") |
| 418 |
(eq_attr "move_type" "store") (const_string "store") |
| 419 |
(eq_attr "move_type" "fpstore") (const_string "fpstore") |
| 420 |
(eq_attr "move_type" "mtc") (const_string "mtc") |
| 421 |
(eq_attr "move_type" "mfc") (const_string "mfc") |
| 422 |
(eq_attr "move_type" "mtlo") (const_string "mtlo") |
| 423 |
(eq_attr "move_type" "mflo") (const_string "mflo") |
| 424 |
|
| 425 |
;; These types of move are always single insns. |
| 426 |
(eq_attr "move_type" "imul") (const_string "imul") |
| 427 |
(eq_attr "move_type" "fmove") (const_string "fmove") |
| 428 |
(eq_attr "move_type" "loadpool") (const_string "load") |
| 429 |
(eq_attr "move_type" "signext") (const_string "signext") |
| 430 |
(eq_attr "move_type" "ext_ins") (const_string "arith") |
| 431 |
(eq_attr "move_type" "arith") (const_string "arith") |
| 432 |
(eq_attr "move_type" "logical") (const_string "logical") |
| 433 |
(eq_attr "move_type" "sll0") (const_string "shift") |
| 434 |
(eq_attr "move_type" "andi") (const_string "logical") |
| 435 |
|
| 436 |
;; These types of move are always split. |
| 437 |
(eq_attr "move_type" "constN,shift_shift") |
| 438 |
(const_string "multi") |
| 439 |
|
| 440 |
;; These types of move are split for quadword modes only. |
| 441 |
(and (eq_attr "move_type" "move,const") |
| 442 |
(eq_attr "qword_mode" "yes")) |
| 443 |
(const_string "multi") |
| 444 |
|
| 445 |
;; These types of move are split for doubleword modes only. |
| 446 |
(and (eq_attr "move_type" "move,const") |
| 447 |
(eq_attr "dword_mode" "yes")) |
| 448 |
(const_string "multi") |
| 449 |
(eq_attr "move_type" "move") (const_string "move") |
| 450 |
(eq_attr "move_type" "const") (const_string "const") |
| 451 |
(eq_attr "sync_mem" "!none") (const_string "syncloop")] |
| 452 |
(const_string "unknown"))) |
| 453 |
|
| 454 |
(define_attr "compact_form" "always,maybe,never" |
| 455 |
(cond [(eq_attr "jal" "direct") |
| 456 |
(const_string "always") |
| 457 |
(eq_attr "jal" "indirect") |
| 458 |
(const_string "maybe") |
| 459 |
(eq_attr "type" "jump") |
| 460 |
(const_string "maybe")] |
| 461 |
(const_string "never"))) |
| 462 |
|
| 463 |
;; Mode for conversion types (fcvt) |
| 464 |
;; I2S integer to float single (SI/DI to SF) |
| 465 |
;; I2D integer to float double (SI/DI to DF) |
| 466 |
;; S2I float to integer (SF to SI/DI) |
| 467 |
;; D2I float to integer (DF to SI/DI) |
| 468 |
;; D2S double to float single |
| 469 |
;; S2D float single to double |
| 470 |
|
| 471 |
(define_attr "cnv_mode" "unknown,I2S,I2D,S2I,D2I,D2S,S2D" |
| 472 |
(const_string "unknown")) |
| 473 |
|
| 474 |
;; Is this an extended instruction in mips16 mode? |
| 475 |
(define_attr "extended_mips16" "no,yes" |
| 476 |
(if_then_else (ior ;; In general, constant-pool loads are extended |
| 477 |
;; instructions. We don't yet optimize for 16-bit |
| 478 |
;; PC-relative references. |
| 479 |
(eq_attr "move_type" "sll0,loadpool,ext_ins") |
| 480 |
(eq_attr "jal" "direct") |
| 481 |
(eq_attr "got" "load")) |
| 482 |
(const_string "yes") |
| 483 |
(const_string "no"))) |
| 484 |
|
| 485 |
(define_attr "compression" "none,all,micromips32,micromips" |
| 486 |
(const_string "none")) |
| 487 |
|
| 488 |
(define_attr "enabled" "no,yes" |
| 489 |
(cond [;; The o32 FPXX and FP64A ABI extensions prohibit direct moves between |
| 490 |
;; GR_REG and FR_REG for 64-bit values. |
| 491 |
(and (eq_attr "move_type" "mtc,mfc") |
| 492 |
(match_test "(TARGET_FLOATXX && !ISA_HAS_MXHC1) |
| 493 |
|| TARGET_O32_FP64A_ABI") |
| 494 |
(eq_attr "dword_mode" "yes")) |
| 495 |
(const_string "no") |
| 496 |
(and (eq_attr "compression" "micromips32,micromips") |
| 497 |
(match_test "!TARGET_MICROMIPS")) |
| 498 |
(const_string "no")] |
| 499 |
(const_string "yes"))) |
| 500 |
|
| 501 |
;; The number of individual instructions that a non-branch pattern generates, |
| 502 |
;; using units of BASE_INSN_LENGTH. |
| 503 |
(define_attr "insn_count" "" |
| 504 |
(cond [;; "Ghost" instructions occupy no space. |
| 505 |
(eq_attr "type" "ghost") |
| 506 |
(const_int 0) |
| 507 |
|
| 508 |
;; Extended instructions count as 2. |
| 509 |
(and (eq_attr "extended_mips16" "yes") |
| 510 |
(match_test "TARGET_MIPS16")) |
| 511 |
(const_int 2) |
| 512 |
|
| 513 |
;; A GOT load followed by an add of $gp. This is not used for MIPS16. |
| 514 |
(eq_attr "got" "xgot_high") |
| 515 |
(const_int 2) |
| 516 |
|
| 517 |
;; SHIFT_SHIFTs are decomposed into two separate instructions. |
| 518 |
;; They are extended instructions on MIPS16 targets. |
| 519 |
(eq_attr "move_type" "shift_shift") |
| 520 |
(if_then_else (match_test "TARGET_MIPS16") |
| 521 |
(const_int 4) |
| 522 |
(const_int 2)) |
| 523 |
|
| 524 |
;; Check for doubleword moves that are decomposed into two |
| 525 |
;; instructions. The individual instructions are unextended |
| 526 |
;; MIPS16 ones. |
| 527 |
(and (eq_attr "move_type" "mtc,mfc,mtlo,mflo,move") |
| 528 |
(eq_attr "dword_mode" "yes")) |
| 529 |
(const_int 2) |
| 530 |
|
| 531 |
;; Check for quadword moves that are decomposed into four |
| 532 |
;; instructions. |
| 533 |
(and (eq_attr "move_type" "mtc,mfc,move") |
| 534 |
(eq_attr "qword_mode" "yes")) |
| 535 |
(const_int 4) |
| 536 |
|
| 537 |
;; Constants, loads and stores are handled by external routines. |
| 538 |
(and (eq_attr "move_type" "const,constN") |
| 539 |
(eq_attr "dword_mode" "yes")) |
| 540 |
(symbol_ref "mips_split_const_insns (operands[1])") |
| 541 |
(eq_attr "move_type" "const,constN") |
| 542 |
(symbol_ref "mips_const_insns (operands[1])") |
| 543 |
(eq_attr "move_type" "load,fpload") |
| 544 |
(symbol_ref "mips_load_store_insns (operands[1], insn)") |
| 545 |
(eq_attr "move_type" "store,fpstore") |
| 546 |
(symbol_ref "mips_load_store_insns (operands[0], insn) |
| 547 |
+ (TARGET_FIX_24K ? 1 : 0)") |
| 548 |
|
| 549 |
;; In the worst case, a call macro will take 8 instructions: |
| 550 |
;; |
| 551 |
;; lui $25,%call_hi(FOO) |
| 552 |
;; addu $25,$25,$28 |
| 553 |
;; lw $25,%call_lo(FOO)($25) |
| 554 |
;; nop |
| 555 |
;; jalr $25 |
| 556 |
;; nop |
| 557 |
;; lw $gp,X($sp) |
| 558 |
;; nop |
| 559 |
(eq_attr "jal_macro" "yes") |
| 560 |
(const_int 8) |
| 561 |
|
| 562 |
;; Various VR4120 errata require a nop to be inserted after a macc |
| 563 |
;; instruction. The assembler does this for us, so account for |
| 564 |
;; the worst-case length here. |
| 565 |
(and (eq_attr "type" "imadd") |
| 566 |
(match_test "TARGET_FIX_VR4120")) |
| 567 |
(const_int 2) |
| 568 |
|
| 569 |
;; VR4120 errata MD(4): if there are consecutive dmult instructions, |
| 570 |
;; the result of the second one is missed. The assembler should work |
| 571 |
;; around this by inserting a nop after the first dmult. |
| 572 |
(and (eq_attr "type" "imul,imul3") |
| 573 |
(eq_attr "mode" "DI") |
| 574 |
(match_test "TARGET_FIX_VR4120")) |
| 575 |
(const_int 2) |
| 576 |
|
| 577 |
(eq_attr "type" "idiv,idiv3") |
| 578 |
(symbol_ref "mips_idiv_insns (GET_MODE (PATTERN (insn)))") |
| 579 |
|
| 580 |
;; simd div have 3 instruction if TARGET_CHECK_ZERO_DIV is true. |
| 581 |
(eq_attr "type" "simd_div") |
| 582 |
(if_then_else (match_test "TARGET_CHECK_ZERO_DIV") |
| 583 |
(const_int 3) |
| 584 |
(const_int 1)) |
| 585 |
|
| 586 |
(not (eq_attr "sync_mem" "none")) |
| 587 |
(symbol_ref "mips_sync_loop_insns (insn, operands)")] |
| 588 |
(const_int 1))) |
| 589 |
|
| 590 |
;; Length of instruction in bytes. The default is derived from "insn_count", |
| 591 |
;; but there are special cases for branches (which must be handled here) |
| 592 |
;; and for compressed single instructions. |
| 593 |
(define_attr "length" "" |
| 594 |
(cond [(and (ior (eq_attr "compression" "micromips,all") |
| 595 |
(and (eq_attr "compression" "micromips32") |
| 596 |
(eq_attr "mode" "SI,SF"))) |
| 597 |
(eq_attr "dword_mode" "no") |
| 598 |
(match_test "TARGET_MICROMIPS")) |
| 599 |
(const_int 2) |
| 600 |
|
| 601 |
;; Direct microMIPS branch instructions have a range of |
| 602 |
;; [-0x10000,0xfffe], otherwise the range is [-0x20000,0x1fffc]. |
| 603 |
;; If a branch is outside this range, we have a choice of two |
| 604 |
;; sequences. |
| 605 |
;; |
| 606 |
;; For PIC, an out-of-range branch like: |
| 607 |
;; |
| 608 |
;; bne r1,r2,target |
| 609 |
;; dslot |
| 610 |
;; |
| 611 |
;; becomes the equivalent of: |
| 612 |
;; |
| 613 |
;; beq r1,r2,1f |
| 614 |
;; dslot |
| 615 |
;; la $at,target |
| 616 |
;; jr $at |
| 617 |
;; nop |
| 618 |
;; 1: |
| 619 |
;; |
| 620 |
;; The non-PIC case is similar except that we use a direct |
| 621 |
;; jump instead of an la/jr pair. Since the target of this |
| 622 |
;; jump is an absolute 28-bit bit address (the other bits |
| 623 |
;; coming from the address of the delay slot) this form cannot |
| 624 |
;; cross a 256MB boundary. We could provide the option of |
| 625 |
;; using la/jr in this case too, but we do not do so at |
| 626 |
;; present. |
| 627 |
;; |
| 628 |
;; The value we specify here does not account for the delay slot |
| 629 |
;; instruction, whose length is added separately. If the RTL |
| 630 |
;; pattern has no explicit delay slot, mips_adjust_insn_length |
| 631 |
;; will add the length of the implicit nop. The range of |
| 632 |
;; [-0x20000, 0x1fffc] from the address of the delay slot |
| 633 |
;; therefore translates to a range of: |
| 634 |
;; |
| 635 |
;; [-(0x20000 - sizeof (branch)), 0x1fffc - sizeof (slot)] |
| 636 |
;; == [-0x1fffc, 0x1fff8] |
| 637 |
;; |
| 638 |
;; from the shorten_branches reference address. |
| 639 |
(and (eq_attr "type" "branch") |
| 640 |
(not (match_test "TARGET_MIPS16"))) |
| 641 |
(cond [;; Any variant can handle the 17-bit range. |
| 642 |
(and (le (minus (match_dup 0) (pc)) (const_int 65532)) |
| 643 |
(le (minus (pc) (match_dup 0)) (const_int 65534))) |
| 644 |
(const_int 4) |
| 645 |
|
| 646 |
;; The 18-bit range is OK other than for microMIPS. |
| 647 |
(and (not (match_test "TARGET_MICROMIPS")) |
| 648 |
(and (le (minus (match_dup 0) (pc)) (const_int 131064)) |
| 649 |
(le (minus (pc) (match_dup 0)) (const_int 131068)))) |
| 650 |
(const_int 4) |
| 651 |
|
| 652 |
;; The non-PIC case: branch, first delay slot, and J. |
| 653 |
(match_test "TARGET_ABSOLUTE_JUMPS") |
| 654 |
(const_int 12)] |
| 655 |
|
| 656 |
;; Use MAX_PIC_BRANCH_LENGTH as a (gross) overestimate. |
| 657 |
;; mips_adjust_insn_length substitutes the correct length. |
| 658 |
;; |
| 659 |
;; Note that we can't simply use (symbol_ref ...) here |
| 660 |
;; because genattrtab needs to know the maximum length |
| 661 |
;; of an insn. |
| 662 |
(const_int MAX_PIC_BRANCH_LENGTH)) |
| 663 |
|
| 664 |
;; An unextended MIPS16 branch has a range of [-0x100, 0xfe] |
| 665 |
;; from the address of the following instruction, which leads |
| 666 |
;; to a range of: |
| 667 |
;; |
| 668 |
;; [-(0x100 - sizeof (branch)), 0xfe] |
| 669 |
;; == [-0xfe, 0xfe] |
| 670 |
;; |
| 671 |
;; from the shorten_branches reference address. Extended branches |
| 672 |
;; likewise have a range of [-0x10000, 0xfffe] from the address |
| 673 |
;; of the following instruction, which leads to a range of: |
| 674 |
;; |
| 675 |
;; [-(0x10000 - sizeof (branch)), 0xfffe] |
| 676 |
;; == [-0xfffc, 0xfffe] |
| 677 |
;; |
| 678 |
;; from the reference address. |
| 679 |
;; |
| 680 |
;; When a branch is out of range, mips_reorg splits it into a form |
| 681 |
;; that uses in-range branches. There are four basic sequences: |
| 682 |
;; |
| 683 |
;; (1) Absolute addressing with a readable text segment |
| 684 |
;; (32-bit addresses): |
| 685 |
;; |
| 686 |
;; b... foo 2 bytes |
| 687 |
;; move $1,$2 2 bytes |
| 688 |
;; lw $2,label 2 bytes |
| 689 |
;; jr $2 2 bytes |
| 690 |
;; move $2,$1 2 bytes |
| 691 |
;; .align 2 0 or 2 bytes |
| 692 |
;; label: |
| 693 |
;; .word target 4 bytes |
| 694 |
;; foo: |
| 695 |
;; (16 bytes in the worst case) |
| 696 |
;; |
| 697 |
;; (2) Absolute addressing with a readable text segment |
| 698 |
;; (64-bit addresses): |
| 699 |
;; |
| 700 |
;; b... foo 2 bytes |
| 701 |
;; move $1,$2 2 bytes |
| 702 |
;; ld $2,label 2 bytes |
| 703 |
;; jr $2 2 bytes |
| 704 |
;; move $2,$1 2 bytes |
| 705 |
;; .align 3 0 to 6 bytes |
| 706 |
;; label: |
| 707 |
;; .dword target 8 bytes |
| 708 |
;; foo: |
| 709 |
;; (24 bytes in the worst case) |
| 710 |
;; |
| 711 |
;; (3) Absolute addressing without a readable text segment |
| 712 |
;; (which requires 32-bit addresses at present): |
| 713 |
;; |
| 714 |
;; b... foo 2 bytes |
| 715 |
;; move $1,$2 2 bytes |
| 716 |
;; lui $2,%hi(target) 4 bytes |
| 717 |
;; sll $2,8 2 bytes |
| 718 |
;; sll $2,8 2 bytes |
| 719 |
;; addiu $2,%lo(target) 4 bytes |
| 720 |
;; jr $2 2 bytes |
| 721 |
;; move $2,$1 2 bytes |
| 722 |
;; foo: |
| 723 |
;; (20 bytes) |
| 724 |
;; |
| 725 |
;; (4) PIC addressing (which requires 32-bit addresses at present): |
| 726 |
;; |
| 727 |
;; b... foo 2 bytes |
| 728 |
;; move $1,$2 2 bytes |
| 729 |
;; lw $2,cprestore 0, 2 or 4 bytes |
| 730 |
;; lw $2,%got(target)($2) 4 bytes |
| 731 |
;; addiu $2,%lo(target) 4 bytes |
| 732 |
;; jr $2 2 bytes |
| 733 |
;; move $2,$1 2 bytes |
| 734 |
;; foo: |
| 735 |
;; (20 bytes in the worst case) |
| 736 |
(and (eq_attr "type" "branch") |
| 737 |
(match_test "TARGET_MIPS16")) |
| 738 |
(cond [(and (le (minus (match_dup 0) (pc)) (const_int 254)) |
| 739 |
(le (minus (pc) (match_dup 0)) (const_int 254))) |
| 740 |
(const_int 2) |
| 741 |
(and (le (minus (match_dup 0) (pc)) (const_int 65534)) |
| 742 |
(le (minus (pc) (match_dup 0)) (const_int 65532))) |
| 743 |
(const_int 4) |
| 744 |
(and (match_test "TARGET_ABICALLS") |
| 745 |
(not (match_test "TARGET_ABSOLUTE_ABICALLS"))) |
| 746 |
(const_int 20) |
| 747 |
(match_test "Pmode == SImode") |
| 748 |
(const_int 16) |
| 749 |
] (const_int 24))] |
| 750 |
(symbol_ref "get_attr_insn_count (insn) * BASE_INSN_LENGTH"))) |
| 751 |
|
| 752 |
;; Attribute describing the processor. |
| 753 |
(define_enum_attr "cpu" "processor" |
| 754 |
(const (symbol_ref "mips_tune"))) |
| 755 |
|
| 756 |
;; The type of hardware hazard associated with this instruction. |
| 757 |
;; DELAY means that the next instruction cannot read the result |
| 758 |
;; of this one. HILO means that the next two instructions cannot |
| 759 |
;; write to HI or LO. |
| 760 |
(define_attr "hazard" "none,delay,hilo,forbidden_slot" |
| 761 |
(cond [(and (eq_attr "type" "load,fpload,fpidxload") |
| 762 |
(match_test "ISA_HAS_LOAD_DELAY")) |
| 763 |
(const_string "delay") |
| 764 |
|
| 765 |
(and (eq_attr "type" "mfc,mtc") |
| 766 |
(match_test "ISA_HAS_XFER_DELAY")) |
| 767 |
(const_string "delay") |
| 768 |
|
| 769 |
(and (eq_attr "type" "fcmp") |
| 770 |
(match_test "ISA_HAS_FCMP_DELAY")) |
| 771 |
(const_string "delay") |
| 772 |
|
| 773 |
;; The r4000 multiplication patterns include an mflo instruction. |
| 774 |
(and (eq_attr "type" "imul") |
| 775 |
(match_test "TARGET_FIX_R4000")) |
| 776 |
(const_string "hilo") |
| 777 |
|
| 778 |
(and (eq_attr "type" "mfhi,mflo") |
| 779 |
(not (match_test "ISA_HAS_HILO_INTERLOCKS"))) |
| 780 |
(const_string "hilo")] |
| 781 |
(const_string "none"))) |
| 782 |
|
| 783 |
;; Can the instruction be put into a delay slot? |
| 784 |
(define_attr "can_delay" "no,yes" |
| 785 |
(if_then_else (and (eq_attr "type" "!branch,call,jump,simd_branch") |
| 786 |
(eq_attr "hazard" "none") |
| 787 |
(match_test "get_attr_insn_count (insn) == 1")) |
| 788 |
(const_string "yes") |
| 789 |
(const_string "no"))) |
| 790 |
|
| 791 |
;; Attribute defining whether or not we can use the branch-likely |
| 792 |
;; instructions. |
| 793 |
(define_attr "branch_likely" "no,yes" |
| 794 |
(if_then_else (match_test "GENERATE_BRANCHLIKELY") |
| 795 |
(const_string "yes") |
| 796 |
(const_string "no"))) |
| 797 |
|
| 798 |
;; True if an instruction might assign to hi or lo when reloaded. |
| 799 |
;; This is used by the TUNE_MACC_CHAINS code. |
| 800 |
(define_attr "may_clobber_hilo" "no,yes" |
| 801 |
(if_then_else (eq_attr "type" "imul,imul3,imadd,idiv,mthi,mtlo") |
| 802 |
(const_string "yes") |
| 803 |
(const_string "no"))) |
| 804 |
|
| 805 |
;; Describe a user's asm statement. |
| 806 |
(define_asm_attributes |
| 807 |
[(set_attr "type" "multi") |
| 808 |
(set_attr "can_delay" "no")]) |
| 809 |
|
| 810 |
;; This mode iterator allows 32-bit and 64-bit GPR patterns to be generated |
| 811 |
;; from the same template. |
| 812 |
(define_mode_iterator GPR [SI (DI "TARGET_64BIT")]) |
| 813 |
|
| 814 |
;; A copy of GPR that can be used when a pattern has two independent |
| 815 |
;; modes. |
| 816 |
(define_mode_iterator GPR2 [SI (DI "TARGET_64BIT")]) |
| 817 |
|
| 818 |
(define_mode_iterator MOVEP1 [SI SF]) |
| 819 |
(define_mode_iterator MOVEP2 [SI SF]) |
| 820 |
(define_mode_iterator JOIN_MODE [HI |
| 821 |
SI |
| 822 |
(SF "TARGET_HARD_FLOAT") |
| 823 |
(DF "TARGET_HARD_FLOAT |
| 824 |
&& TARGET_DOUBLE_FLOAT")]) |
| 825 |
|
| 826 |
;; This mode iterator allows :HILO to be used as the mode of the |
| 827 |
;; concatenated HI and LO registers. |
| 828 |
(define_mode_iterator HILO [(DI "!TARGET_64BIT") (TI "TARGET_64BIT")]) |
| 829 |
|
| 830 |
;; This mode iterator allows :P to be used for patterns that operate on |
| 831 |
;; pointer-sized quantities. Exactly one of the two alternatives will match. |
| 832 |
(define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")]) |
| 833 |
|
| 834 |
;; This mode iterator allows :MOVECC to be used anywhere that a |
| 835 |
;; conditional-move-type condition is needed. |
| 836 |
(define_mode_iterator MOVECC [SI (DI "TARGET_64BIT") |
| 837 |
(CC "TARGET_HARD_FLOAT |
| 838 |
&& !TARGET_LOONGSON_2EF |
| 839 |
&& !TARGET_MIPS5900") |
| 840 |
(CCE "TARGET_HARD_FLOAT |
| 841 |
&& !TARGET_LOONGSON_2EF |
| 842 |
&& !TARGET_MIPS5900")]) |
| 843 |
|
| 844 |
;; This mode iterator allows :FPCC to be used anywhere that an FP condition |
| 845 |
;; is needed. |
| 846 |
(define_mode_iterator FPCC [(CC "!ISA_HAS_CCF") (CCE "!ISA_HAS_CCF") |
| 847 |
(CCF "ISA_HAS_CCF")]) |
| 848 |
|
| 849 |
;; 32-bit integer moves for which we provide move patterns. |
| 850 |
(define_mode_iterator IMOVE32 |
| 851 |
[SI |
| 852 |
(V2HI "TARGET_DSP") |
| 853 |
(V4QI "TARGET_DSP") |
| 854 |
(V2HQ "TARGET_DSP") |
| 855 |
(V2UHQ "TARGET_DSP") |
| 856 |
(V2HA "TARGET_DSP") |
| 857 |
(V2UHA "TARGET_DSP") |
| 858 |
(V4QQ "TARGET_DSP") |
| 859 |
(V4UQQ "TARGET_DSP")]) |
| 860 |
|
| 861 |
;; 64-bit modes for which we provide move patterns. |
| 862 |
(define_mode_iterator MOVE64 |
| 863 |
[DI DF |
| 864 |
(V2SF "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT") |
| 865 |
(V2SI "TARGET_HARD_FLOAT && TARGET_LOONGSON_MMI") |
| 866 |
(V4HI "TARGET_HARD_FLOAT && TARGET_LOONGSON_MMI") |
| 867 |
(V8QI "TARGET_HARD_FLOAT && TARGET_LOONGSON_MMI")]) |
| 868 |
|
| 869 |
;; 128-bit modes for which we provide move patterns on 64-bit targets. |
| 870 |
(define_mode_iterator MOVE128 [TI TF]) |
| 871 |
|
| 872 |
;; This mode iterator allows the QI and HI extension patterns to be |
| 873 |
;; defined from the same template. |
| 874 |
(define_mode_iterator SHORT [QI HI]) |
| 875 |
|
| 876 |
;; Likewise the 64-bit truncate-and-shift patterns. |
| 877 |
(define_mode_iterator SUBDI [QI HI SI]) |
| 878 |
|
| 879 |
;; This mode iterator allows :ANYF to be used wherever a scalar or vector |
| 880 |
;; floating-point mode is allowed. |
| 881 |
(define_mode_iterator ANYF [(SF "TARGET_HARD_FLOAT") |
| 882 |
(DF "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT") |
| 883 |
(V2SF "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT")]) |
| 884 |
|
| 885 |
;; Like ANYF, but only applies to scalar modes. |
| 886 |
(define_mode_iterator SCALARF [(SF "TARGET_HARD_FLOAT") |
| 887 |
(DF "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT")]) |
| 888 |
|
| 889 |
;; A floating-point mode for which moves involving FPRs may need to be split. |
| 890 |
(define_mode_iterator SPLITF |
| 891 |
[(DF "!TARGET_64BIT && TARGET_DOUBLE_FLOAT") |
| 892 |
(DI "!TARGET_64BIT && TARGET_DOUBLE_FLOAT") |
| 893 |
(V2SF "!TARGET_64BIT && TARGET_PAIRED_SINGLE_FLOAT") |
| 894 |
(V2SI "!TARGET_64BIT && TARGET_LOONGSON_MMI") |
| 895 |
(V4HI "!TARGET_64BIT && TARGET_LOONGSON_MMI") |
| 896 |
(V8QI "!TARGET_64BIT && TARGET_LOONGSON_MMI") |
| 897 |
(TF "TARGET_64BIT && TARGET_FLOAT64")]) |
| 898 |
|
| 899 |
;; In GPR templates, a string like "<d>subu" will expand to "subu" in the |
| 900 |
;; 32-bit version and "dsubu" in the 64-bit version. |
| 901 |
(define_mode_attr d [(SI "") (DI "d") |
| 902 |
(QQ "") (HQ "") (SQ "") (DQ "d") |
| 903 |
(UQQ "") (UHQ "") (USQ "") (UDQ "d") |
| 904 |
(HA "") (SA "") (DA "d") |
| 905 |
(UHA "") (USA "") (UDA "d")]) |
| 906 |
|
| 907 |
;; Same as d but upper-case. |
| 908 |
(define_mode_attr D [(SI "") (DI "D") |
| 909 |
(QQ "") (HQ "") (SQ "") (DQ "D") |
| 910 |
(UQQ "") (UHQ "") (USQ "") (UDQ "D") |
| 911 |
(HA "") (SA "") (DA "D") |
| 912 |
(UHA "") (USA "") (UDA "D")]) |
| 913 |
|
| 914 |
;; This attribute gives the length suffix for a load or store instruction. |
| 915 |
;; The same suffixes work for zero and sign extensions. |
| 916 |
(define_mode_attr size [(QI "b") (HI "h") (SI "w") (DI "d")]) |
| 917 |
(define_mode_attr SIZE [(QI "B") (HI "H") (SI "W") (DI "D")]) |
| 918 |
|
| 919 |
;; This attributes gives the mode mask of a SHORT. |
| 920 |
(define_mode_attr mask [(QI "0x00ff") (HI "0xffff")]) |
| 921 |
|
| 922 |
;; Mode attributes for GPR loads. |
| 923 |
(define_mode_attr load [(SI "lw") (DI "ld")]) |
| 924 |
;; Instruction names for stores. |
| 925 |
(define_mode_attr store [(QI "sb") (HI "sh") (SI "sw") (DI "sd")]) |
| 926 |
|
| 927 |
;; Similarly for MIPS IV indexed FPR loads and stores. |
| 928 |
(define_mode_attr loadx [(SF "lwxc1") (DF "ldxc1") (V2SF "ldxc1")]) |
| 929 |
(define_mode_attr storex [(SF "swxc1") (DF "sdxc1") (V2SF "sdxc1")]) |
| 930 |
|
| 931 |
;; The unextended ranges of the MIPS16 addiu and daddiu instructions |
| 932 |
;; are different. Some forms of unextended addiu have an 8-bit immediate |
| 933 |
;; field but the equivalent daddiu has only a 5-bit field. |
| 934 |
(define_mode_attr si8_di5 [(SI "8") (DI "5")]) |
| 935 |
|
| 936 |
;; This attribute gives the best constraint to use for registers of |
| 937 |
;; a given mode. |
| 938 |
(define_mode_attr reg [(SI "d") (DI "d") (CC "z") (CCE "z") (CCF "f")]) |
| 939 |
|
| 940 |
;; This attribute gives the format suffix for floating-point operations. |
| 941 |
(define_mode_attr fmt [(SF "s") (DF "d") (V2SF "ps")]) |
| 942 |
|
| 943 |
;; This attribute gives the upper-case mode name for one unit of a |
| 944 |
;; floating-point mode or vector mode. |
| 945 |
(define_mode_attr UNITMODE [(SF "SF") (DF "DF") (V2SF "SF") (V4SF "SF") |
| 946 |
(V16QI "QI") (V8HI "HI") (V4SI "SI") (V2DI "DI") |
| 947 |
(V2DF "DF")]) |
| 948 |
|
| 949 |
;; As above, but in lower case. |
| 950 |
(define_mode_attr unitmode [(SF "sf") (DF "df") (V2SF "sf") (V4SF "sf") |
| 951 |
(V16QI "qi") (V8QI "qi") (V8HI "hi") (V4HI "hi") |
| 952 |
(V4SI "si") (V2SI "si") (V2DI "di") (V2DF "df")]) |
| 953 |
|
| 954 |
;; This attribute gives the integer mode that has the same size as a |
| 955 |
;; fixed-point mode. |
| 956 |
(define_mode_attr IMODE [(QQ "QI") (HQ "HI") (SQ "SI") (DQ "DI") |
| 957 |
(UQQ "QI") (UHQ "HI") (USQ "SI") (UDQ "DI") |
| 958 |
(HA "HI") (SA "SI") (DA "DI") |
| 959 |
(UHA "HI") (USA "SI") (UDA "DI") |
| 960 |
(V4UQQ "SI") (V2UHQ "SI") (V2UHA "SI") |
| 961 |
(V2HQ "SI") (V2HA "SI")]) |
| 962 |
|
| 963 |
;; This attribute gives the integer mode that has half the size of |
| 964 |
;; the controlling mode. |
| 965 |
(define_mode_attr HALFMODE [(DF "SI") (DI "SI") (V2SF "SI") |
| 966 |
(V2SI "SI") (V4HI "SI") (V8QI "SI") |
| 967 |
(TF "DI")]) |
| 968 |
|
| 969 |
;; This attribute works around the early SB-1 rev2 core "F2" erratum: |
| 970 |
;; |
| 971 |
;; In certain cases, div.s and div.ps may have a rounding error |
| 972 |
;; and/or wrong inexact flag. |
| 973 |
;; |
| 974 |
;; Therefore, we only allow div.s if not working around SB-1 rev2 |
| 975 |
;; errata or if a slight loss of precision is OK. |
| 976 |
(define_mode_attr divide_condition |
| 977 |
[DF (SF "!TARGET_FIX_SB1 || flag_unsafe_math_optimizations") |
| 978 |
(V2SF "TARGET_SB1 && (!TARGET_FIX_SB1 || flag_unsafe_math_optimizations)")]) |
| 979 |
|
| 980 |
;; This attribute gives the conditions under which SQRT.fmt instructions |
| 981 |
;; can be used. |
| 982 |
(define_mode_attr sqrt_condition |
| 983 |
[(SF "!ISA_MIPS1") (DF "!ISA_MIPS1") (V2SF "TARGET_SB1")]) |
| 984 |
|
| 985 |
;; This attribute provides the correct mnemonic for each FP condition mode. |
| 986 |
(define_mode_attr fpcmp [(CC "c") (CCE "c") (CCF "cmp")]) |
| 987 |
|
| 988 |
;; This code iterator allows signed and unsigned widening multiplications |
| 989 |
;; to use the same template. |
| 990 |
(define_code_iterator any_extend [sign_extend zero_extend]) |
| 991 |
|
| 992 |
;; This code iterator allows the two right shift instructions to be |
| 993 |
;; generated from the same template. |
| 994 |
(define_code_iterator any_shiftrt [ashiftrt lshiftrt]) |
| 995 |
|
| 996 |
;; This code iterator allows the three shift instructions to be generated |
| 997 |
;; from the same template. |
| 998 |
(define_code_iterator any_shift [ashift ashiftrt lshiftrt]) |
| 999 |
|
| 1000 |
;; This code iterator allows the three bitwise instructions to be generated |
| 1001 |
;; from the same template. |
| 1002 |
(define_code_iterator any_bitwise [and ior xor]) |
| 1003 |
|
| 1004 |
;; This code iterator allows unsigned and signed division to be generated |
| 1005 |
;; from the same template. |
| 1006 |
(define_code_iterator any_div [div udiv]) |
| 1007 |
|
| 1008 |
;; This code iterator allows unsigned and signed modulus to be generated |
| 1009 |
;; from the same template. |
| 1010 |
(define_code_iterator any_mod [mod umod]) |
| 1011 |
|
| 1012 |
;; This code iterator allows addition and subtraction to be generated |
| 1013 |
;; from the same template. |
| 1014 |
(define_code_iterator addsub [plus minus]) |
| 1015 |
|
| 1016 |
;; This code iterator allows all native floating-point comparisons to be |
| 1017 |
;; generated from the same template. |
| 1018 |
(define_code_iterator fcond [unordered uneq unlt unle eq lt le |
| 1019 |
(ordered "ISA_HAS_CCF") |
| 1020 |
(ltgt "ISA_HAS_CCF") |
| 1021 |
(ne "ISA_HAS_CCF")]) |
| 1022 |
|
| 1023 |
;; This code iterator is used for comparisons that can be implemented |
| 1024 |
;; by swapping the operands. |
| 1025 |
(define_code_iterator swapped_fcond [ge gt unge ungt]) |
| 1026 |
|
| 1027 |
;; Equality operators. |
| 1028 |
(define_code_iterator equality_op [eq ne]) |
| 1029 |
|
| 1030 |
;; These code iterators allow the signed and unsigned scc operations to use |
| 1031 |
;; the same template. |
| 1032 |
(define_code_iterator any_gt [gt gtu]) |
| 1033 |
(define_code_iterator any_ge [ge geu]) |
| 1034 |
(define_code_iterator any_lt [lt ltu]) |
| 1035 |
(define_code_iterator any_le [le leu]) |
| 1036 |
|
| 1037 |
(define_code_iterator any_return [return simple_return]) |
| 1038 |
|
| 1039 |
;; <u> expands to an empty string when doing a signed operation and |
| 1040 |
;; "u" when doing an unsigned operation. |
| 1041 |
(define_code_attr u [(sign_extend "") (zero_extend "u") |
| 1042 |
(div "") (udiv "u") |
| 1043 |
(mod "") (umod "u") |
| 1044 |
(gt "") (gtu "u") |
| 1045 |
(ge "") (geu "u") |
| 1046 |
(lt "") (ltu "u") |
| 1047 |
(le "") (leu "u")]) |
| 1048 |
|
| 1049 |
;; <U> is like <u> except uppercase. |
| 1050 |
(define_code_attr U [(sign_extend "") (zero_extend "U")]) |
| 1051 |
|
| 1052 |
;; <su> is like <u>, but the signed form expands to "s" rather than "". |
| 1053 |
(define_code_attr su [(sign_extend "s") (zero_extend "u")]) |
| 1054 |
|
| 1055 |
;; <optab> expands to the name of the optab for a particular code. |
| 1056 |
(define_code_attr optab [(ashift "ashl") |
| 1057 |
(ashiftrt "ashr") |
| 1058 |
(lshiftrt "lshr") |
| 1059 |
(ior "ior") |
| 1060 |
(xor "xor") |
| 1061 |
(and "and") |
| 1062 |
(plus "add") |
| 1063 |
(minus "sub") |
| 1064 |
(return "return") |
| 1065 |
(simple_return "simple_return")]) |
| 1066 |
|
| 1067 |
;; <insn> expands to the name of the insn that implements a particular code. |
| 1068 |
(define_code_attr insn [(ashift "sll") |
| 1069 |
(ashiftrt "sra") |
| 1070 |
(lshiftrt "srl") |
| 1071 |
(ior "or") |
| 1072 |
(xor "xor") |
| 1073 |
(and "and") |
| 1074 |
(plus "addu") |
| 1075 |
(minus "subu")]) |
| 1076 |
|
| 1077 |
;; <immediate_insn> expands to the name of the insn that implements |
| 1078 |
;; a particular code to operate on immediate values. |
| 1079 |
(define_code_attr immediate_insn [(ior "ori") |
| 1080 |
(xor "xori") |
| 1081 |
(and "andi")]) |
| 1082 |
|
| 1083 |
(define_code_attr shift_compression [(ashift "micromips32") |
| 1084 |
(lshiftrt "micromips32") |
| 1085 |
(ashiftrt "none")]) |
| 1086 |
|
| 1087 |
;; <fcond> is the c.cond.fmt condition associated with a particular code. |
| 1088 |
(define_code_attr fcond [(unordered "un") |
| 1089 |
(uneq "ueq") |
| 1090 |
(unlt "ult") |
| 1091 |
(unle "ule") |
| 1092 |
(eq "eq") |
| 1093 |
(lt "lt") |
| 1094 |
(le "le") |
| 1095 |
(ordered "or") |
| 1096 |
(ltgt "sne") |
| 1097 |
(ne "une")]) |
| 1098 |
|
| 1099 |
;; Similar, but for swapped conditions. |
| 1100 |
(define_code_attr swapped_fcond [(ge "le") |
| 1101 |
(gt "lt") |
| 1102 |
(unge "ule") |
| 1103 |
(ungt "ult")]) |
| 1104 |
|
| 1105 |
;; The value of the bit when the branch is taken for branch_bit patterns. |
| 1106 |
;; Comparison is always against zero so this depends on the operator. |
| 1107 |
(define_code_attr bbv [(eq "0") (ne "1")]) |
| 1108 |
|
| 1109 |
;; This is the inverse value of bbv. |
| 1110 |
(define_code_attr bbinv [(eq "1") (ne "0")]) |
| 1111 |
|
| 1112 |
;; The sel mnemonic to use depending on the condition test. |
| 1113 |
(define_code_attr sel [(eq "seleqz") (ne "selnez")]) |
| 1114 |
(define_code_attr selinv [(eq "selnez") (ne "seleqz")]) |
| 1115 |
|
| 1116 |
;; ......................... |
| 1117 |
;; |
| 1118 |
;; Branch, call and jump delay slots |
| 1119 |
;; |
| 1120 |
;; ......................... |
| 1121 |
|
| 1122 |
(define_delay (and (eq_attr "type" "branch") |
| 1123 |
(not (match_test "TARGET_MIPS16")) |
| 1124 |
(eq_attr "branch_likely" "yes")) |
| 1125 |
[(eq_attr "can_delay" "yes") |
| 1126 |
(nil) |
| 1127 |
(eq_attr "can_delay" "yes")]) |
| 1128 |
|
| 1129 |
;; Branches that have delay slots and don't have likely variants do |
| 1130 |
;; not annul on false. |
| 1131 |
(define_delay (and (eq_attr "type" "branch,simd_branch") |
| 1132 |
(not (match_test "TARGET_MIPS16")) |
| 1133 |
(ior (match_test "TARGET_CB_NEVER") |
| 1134 |
(and (eq_attr "compact_form" "maybe") |
| 1135 |
(not (match_test "TARGET_CB_ALWAYS"))) |
| 1136 |
(eq_attr "compact_form" "never")) |
| 1137 |
(eq_attr "branch_likely" "no")) |
| 1138 |
[(eq_attr "can_delay" "yes") |
| 1139 |
(nil) |
| 1140 |
(nil)]) |
| 1141 |
|
| 1142 |
(define_delay (and (eq_attr "type" "jump") |
| 1143 |
(ior (match_test "TARGET_CB_NEVER") |
| 1144 |
(and (eq_attr "compact_form" "maybe") |
| 1145 |
(not (match_test "TARGET_CB_ALWAYS"))) |
| 1146 |
(eq_attr "compact_form" "never"))) |
| 1147 |
[(eq_attr "can_delay" "yes") |
| 1148 |
(nil) |
| 1149 |
(nil)]) |
| 1150 |
|
| 1151 |
;; Call type instructions should never have a compact form as the |
| 1152 |
;; type is only used for MIPS16 patterns. For safety put the compact |
| 1153 |
;; branch detection condition in anyway. |
| 1154 |
(define_delay (and (eq_attr "type" "call") |
| 1155 |
(eq_attr "jal_macro" "no") |
| 1156 |
(ior (match_test "TARGET_CB_NEVER") |
| 1157 |
(and (eq_attr "compact_form" "maybe") |
| 1158 |
(not (match_test "TARGET_CB_ALWAYS"))) |
| 1159 |
(eq_attr "compact_form" "never"))) |
| 1160 |
[(eq_attr "can_delay" "yes") |
| 1161 |
(nil) |
| 1162 |
(nil)]) |
| 1163 |
|
| 1164 |
;; Pipeline descriptions. |
| 1165 |
;; |
| 1166 |
;; generic.md provides a fallback for processors without a specific |
| 1167 |
;; pipeline description. It is derived from the old define_function_unit |
| 1168 |
;; version and uses the "alu" and "imuldiv" units declared below. |
| 1169 |
;; |
| 1170 |
;; Some of the processor-specific files are also derived from old |
| 1171 |
;; define_function_unit descriptions and simply override the parts of |
| 1172 |
;; generic.md that don't apply. The other processor-specific files |
| 1173 |
;; are self-contained. |
| 1174 |
(define_automaton "alu,imuldiv") |
| 1175 |
|
| 1176 |
(define_cpu_unit "alu" "alu") |
| 1177 |
(define_cpu_unit "imuldiv" "imuldiv") |
| 1178 |
|
| 1179 |
;; Ghost instructions produce no real code and introduce no hazards. |
| 1180 |
;; They exist purely to express an effect on dataflow. |
| 1181 |
(define_insn_reservation "ghost" 0 |
| 1182 |
(eq_attr "type" "ghost") |
| 1183 |
"nothing") |
| 1184 |
|
| 1185 |
(include "i6400.md") |
| 1186 |
(include "p5600.md") |
| 1187 |
(include "m5100.md") |
| 1188 |
(include "p6600.md") |
| 1189 |
(include "4k.md") |
| 1190 |
(include "5k.md") |
| 1191 |
(include "20kc.md") |
| 1192 |
(include "24k.md") |
| 1193 |
(include "74k.md") |
| 1194 |
(include "3000.md") |
| 1195 |
(include "4000.md") |
| 1196 |
(include "4100.md") |
| 1197 |
(include "4130.md") |
| 1198 |
(include "4300.md") |
| 1199 |
(include "4600.md") |
| 1200 |
(include "5000.md") |
| 1201 |
(include "5400.md") |
| 1202 |
(include "5500.md") |
| 1203 |
(include "6000.md") |
| 1204 |
(include "7000.md") |
| 1205 |
(include "9000.md") |
| 1206 |
(include "10000.md") |
| 1207 |
(include "loongson2ef.md") |
| 1208 |
(include "gs464.md") |
| 1209 |
(include "gs464e.md") |
| 1210 |
(include "gs264e.md") |
| 1211 |
(include "octeon.md") |
| 1212 |
(include "sb1.md") |
| 1213 |
(include "sr71k.md") |
| 1214 |
(include "xlr.md") |
| 1215 |
(include "xlp.md") |
| 1216 |
(include "generic.md") |
| 1217 |
|
| 1218 |
;; |
| 1219 |
;; .................... |
| 1220 |
;; |
| 1221 |
;; CONDITIONAL TRAPS |
| 1222 |
;; |
| 1223 |
;; .................... |
| 1224 |
;; |
| 1225 |
|
| 1226 |
(define_insn "trap" |
| 1227 |
[(trap_if (const_int 1) (const_int 0))] |
| 1228 |
"" |
| 1229 |
{ |
| 1230 |
if (ISA_HAS_COND_TRAP) |
| 1231 |
return "teq\t$0,$0"; |
| 1232 |
else if (TARGET_MIPS16) |
| 1233 |
return "break 0"; |
| 1234 |
else |
| 1235 |
return "break"; |
| 1236 |
} |
| 1237 |
[(set_attr "type" "trap")]) |
| 1238 |
|
| 1239 |
(define_expand "ctrap<mode>4" |
| 1240 |
[(trap_if (match_operator 0 "comparison_operator" |
| 1241 |
[(match_operand:GPR 1 "reg_or_0_operand") |
| 1242 |
(match_operand:GPR 2 "arith_operand")]) |
| 1243 |
(match_operand 3 "const_0_operand"))] |
| 1244 |
"ISA_HAS_COND_TRAPI || ISA_HAS_COND_TRAP" |
| 1245 |
{ |
| 1246 |
mips_expand_conditional_trap (operands[0]); |
| 1247 |
DONE; |
| 1248 |
}) |
| 1249 |
|
| 1250 |
(define_insn "*conditional_trap_reg<mode>" |
| 1251 |
[(trap_if (match_operator:GPR 0 "trap_comparison_operator" |
| 1252 |
[(match_operand:GPR 1 "reg_or_0_operand" "dJ") |
| 1253 |
(match_operand:GPR 2 "reg_or_0_operand" "dJ")]) |
| 1254 |
(const_int 0))] |
| 1255 |
"ISA_HAS_COND_TRAP && !ISA_HAS_COND_TRAPI" |
| 1256 |
"t%C0\t%z1,%z2" |
| 1257 |
[(set_attr "type" "trap")]) |
| 1258 |
|
| 1259 |
(define_insn "*conditional_trap<mode>" |
| 1260 |
[(trap_if (match_operator:GPR 0 "trap_comparison_operator" |
| 1261 |
[(match_operand:GPR 1 "reg_or_0_operand" "dJ") |
| 1262 |
(match_operand:GPR 2 "arith_operand" "dI")]) |
| 1263 |
(const_int 0))] |
| 1264 |
"ISA_HAS_COND_TRAPI" |
| 1265 |
"t%C0\t%z1,%2" |
| 1266 |
[(set_attr "type" "trap")]) |
| 1267 |
|
| 1268 |
;; |
| 1269 |
;; .................... |
| 1270 |
;; |
| 1271 |
;; ADDITION |
| 1272 |
;; |
| 1273 |
;; .................... |
| 1274 |
;; |
| 1275 |
|
| 1276 |
(define_insn "add<mode>3" |
| 1277 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 1278 |
(plus:ANYF (match_operand:ANYF 1 "register_operand" "f") |
| 1279 |
(match_operand:ANYF 2 "register_operand" "f")))] |
| 1280 |
"" |
| 1281 |
"add.<fmt>\t%0,%1,%2" |
| 1282 |
[(set_attr "type" "fadd") |
| 1283 |
(set_attr "mode" "<UNITMODE>")]) |
| 1284 |
|
| 1285 |
(define_expand "add<mode>3" |
| 1286 |
[(set (match_operand:GPR 0 "register_operand") |
| 1287 |
(plus:GPR (match_operand:GPR 1 "register_operand") |
| 1288 |
(match_operand:GPR 2 "arith_operand")))] |
| 1289 |
"") |
| 1290 |
|
| 1291 |
(define_insn "*add<mode>3" |
| 1292 |
[(set (match_operand:GPR 0 "register_operand" "=!u,d,!u,!u,!ks,!d,d") |
| 1293 |
(plus:GPR (match_operand:GPR 1 "register_operand" "!u,d,!u,!ks,!ks,0,d") |
| 1294 |
(match_operand:GPR 2 "arith_operand" "!u,d,Uead,Uuw6,Uesp,Usb4,Q")))] |
| 1295 |
"!TARGET_MIPS16" |
| 1296 |
{ |
| 1297 |
if (which_alternative == 0 |
| 1298 |
|| which_alternative == 1) |
| 1299 |
return "<d>addu\t%0,%1,%2"; |
| 1300 |
else |
| 1301 |
return "<d>addiu\t%0,%1,%2"; |
| 1302 |
} |
| 1303 |
[(set_attr "alu_type" "add") |
| 1304 |
(set_attr "compression" "micromips32,*,micromips32,micromips32,micromips32,micromips32,*") |
| 1305 |
(set_attr "mode" "<MODE>")]) |
| 1306 |
|
| 1307 |
(define_insn "*add<mode>3_mips16" |
| 1308 |
[(set (match_operand:GPR 0 "register_operand" "=ks,ks,d,d,d,d,d,d,d") |
| 1309 |
(plus:GPR (match_operand:GPR 1 "register_operand" "ks,ks,ks,ks,0,0,d,d,d") |
| 1310 |
(match_operand:GPR 2 "arith_operand" "Usd8,Q,Uuw<si8_di5>,Q,Usb<si8_di5>,Q,Usb4,O,d")))] |
| 1311 |
"TARGET_MIPS16" |
| 1312 |
"@ |
| 1313 |
<d>addiu\t%0,%2 |
| 1314 |
<d>addiu\t%0,%2 |
| 1315 |
<d>addiu\t%0,%1,%2 |
| 1316 |
<d>addiu\t%0,%1,%2 |
| 1317 |
<d>addiu\t%0,%2 |
| 1318 |
<d>addiu\t%0,%2 |
| 1319 |
<d>addiu\t%0,%1,%2 |
| 1320 |
<d>addiu\t%0,%1,%2 |
| 1321 |
<d>addu\t%0,%1,%2" |
| 1322 |
[(set_attr "alu_type" "add") |
| 1323 |
(set_attr "mode" "<MODE>") |
| 1324 |
(set_attr "extended_mips16" "no,yes,no,yes,no,yes,no,yes,no")]) |
| 1325 |
|
| 1326 |
;; On the mips16, we can sometimes split an add of a constant which is |
| 1327 |
;; a 4 byte instruction into two adds which are both 2 byte |
| 1328 |
;; instructions. There are two cases: one where we are adding a |
| 1329 |
;; constant plus a register to another register, and one where we are |
| 1330 |
;; simply adding a constant to a register. |
| 1331 |
|
| 1332 |
(define_split |
| 1333 |
[(set (match_operand:SI 0 "d_operand") |
| 1334 |
(plus:SI (match_dup 0) |
| 1335 |
(match_operand:SI 1 "const_int_operand")))] |
| 1336 |
"TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE |
| 1337 |
&& ((INTVAL (operands[1]) > 0x7f |
| 1338 |
&& INTVAL (operands[1]) <= 0x7f + 0x7f) |
| 1339 |
|| (INTVAL (operands[1]) < - 0x80 |
| 1340 |
&& INTVAL (operands[1]) >= - 0x80 - 0x80))" |
| 1341 |
[(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1))) |
| 1342 |
(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))] |
| 1343 |
{ |
| 1344 |
HOST_WIDE_INT val = INTVAL (operands[1]); |
| 1345 |
|
| 1346 |
if (val >= 0) |
| 1347 |
{ |
| 1348 |
operands[1] = GEN_INT (0x7f); |
| 1349 |
operands[2] = GEN_INT (val - 0x7f); |
| 1350 |
} |
| 1351 |
else |
| 1352 |
{ |
| 1353 |
operands[1] = GEN_INT (- 0x80); |
| 1354 |
operands[2] = GEN_INT (val + 0x80); |
| 1355 |
} |
| 1356 |
}) |
| 1357 |
|
| 1358 |
(define_split |
| 1359 |
[(set (match_operand:SI 0 "d_operand") |
| 1360 |
(plus:SI (match_operand:SI 1 "d_operand") |
| 1361 |
(match_operand:SI 2 "const_int_operand")))] |
| 1362 |
"TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE |
| 1363 |
&& REGNO (operands[0]) != REGNO (operands[1]) |
| 1364 |
&& ((INTVAL (operands[2]) > 0x7 |
| 1365 |
&& INTVAL (operands[2]) <= 0x7 + 0x7f) |
| 1366 |
|| (INTVAL (operands[2]) < - 0x8 |
| 1367 |
&& INTVAL (operands[2]) >= - 0x8 - 0x80))" |
| 1368 |
[(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2))) |
| 1369 |
(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 3)))] |
| 1370 |
{ |
| 1371 |
HOST_WIDE_INT val = INTVAL (operands[2]); |
| 1372 |
|
| 1373 |
if (val >= 0) |
| 1374 |
{ |
| 1375 |
operands[2] = GEN_INT (0x7); |
| 1376 |
operands[3] = GEN_INT (val - 0x7); |
| 1377 |
} |
| 1378 |
else |
| 1379 |
{ |
| 1380 |
operands[2] = GEN_INT (- 0x8); |
| 1381 |
operands[3] = GEN_INT (val + 0x8); |
| 1382 |
} |
| 1383 |
}) |
| 1384 |
|
| 1385 |
(define_split |
| 1386 |
[(set (match_operand:DI 0 "d_operand") |
| 1387 |
(plus:DI (match_dup 0) |
| 1388 |
(match_operand:DI 1 "const_int_operand")))] |
| 1389 |
"TARGET_MIPS16 && TARGET_64BIT && reload_completed && !TARGET_DEBUG_D_MODE |
| 1390 |
&& ((INTVAL (operands[1]) > 0xf |
| 1391 |
&& INTVAL (operands[1]) <= 0xf + 0xf) |
| 1392 |
|| (INTVAL (operands[1]) < - 0x10 |
| 1393 |
&& INTVAL (operands[1]) >= - 0x10 - 0x10))" |
| 1394 |
[(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1))) |
| 1395 |
(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))] |
| 1396 |
{ |
| 1397 |
HOST_WIDE_INT val = INTVAL (operands[1]); |
| 1398 |
|
| 1399 |
if (val >= 0) |
| 1400 |
{ |
| 1401 |
operands[1] = GEN_INT (0xf); |
| 1402 |
operands[2] = GEN_INT (val - 0xf); |
| 1403 |
} |
| 1404 |
else |
| 1405 |
{ |
| 1406 |
operands[1] = GEN_INT (- 0x10); |
| 1407 |
operands[2] = GEN_INT (val + 0x10); |
| 1408 |
} |
| 1409 |
}) |
| 1410 |
|
| 1411 |
(define_split |
| 1412 |
[(set (match_operand:DI 0 "d_operand") |
| 1413 |
(plus:DI (match_operand:DI 1 "d_operand") |
| 1414 |
(match_operand:DI 2 "const_int_operand")))] |
| 1415 |
"TARGET_MIPS16 && TARGET_64BIT && reload_completed && !TARGET_DEBUG_D_MODE |
| 1416 |
&& REGNO (operands[0]) != REGNO (operands[1]) |
| 1417 |
&& ((INTVAL (operands[2]) > 0x7 |
| 1418 |
&& INTVAL (operands[2]) <= 0x7 + 0xf) |
| 1419 |
|| (INTVAL (operands[2]) < - 0x8 |
| 1420 |
&& INTVAL (operands[2]) >= - 0x8 - 0x10))" |
| 1421 |
[(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2))) |
| 1422 |
(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))] |
| 1423 |
{ |
| 1424 |
HOST_WIDE_INT val = INTVAL (operands[2]); |
| 1425 |
|
| 1426 |
if (val >= 0) |
| 1427 |
{ |
| 1428 |
operands[2] = GEN_INT (0x7); |
| 1429 |
operands[3] = GEN_INT (val - 0x7); |
| 1430 |
} |
| 1431 |
else |
| 1432 |
{ |
| 1433 |
operands[2] = GEN_INT (- 0x8); |
| 1434 |
operands[3] = GEN_INT (val + 0x8); |
| 1435 |
} |
| 1436 |
}) |
| 1437 |
|
| 1438 |
(define_insn "*addsi3_extended" |
| 1439 |
[(set (match_operand:DI 0 "register_operand" "=d,d") |
| 1440 |
(sign_extend:DI |
| 1441 |
(plus:SI (match_operand:SI 1 "register_operand" "d,d") |
| 1442 |
(match_operand:SI 2 "arith_operand" "d,Q"))))] |
| 1443 |
"TARGET_64BIT && !TARGET_MIPS16" |
| 1444 |
"@ |
| 1445 |
addu\t%0,%1,%2 |
| 1446 |
addiu\t%0,%1,%2" |
| 1447 |
[(set_attr "alu_type" "add") |
| 1448 |
(set_attr "mode" "SI")]) |
| 1449 |
|
| 1450 |
;; Split this insn so that the addiu splitters can have a crack at it. |
| 1451 |
;; Use a conservative length estimate until the split. |
| 1452 |
(define_insn_and_split "*addsi3_extended_mips16" |
| 1453 |
[(set (match_operand:DI 0 "register_operand" "=d,d,d") |
| 1454 |
(sign_extend:DI |
| 1455 |
(plus:SI (match_operand:SI 1 "register_operand" "0,d,d") |
| 1456 |
(match_operand:SI 2 "arith_operand" "Q,O,d"))))] |
| 1457 |
"TARGET_64BIT && TARGET_MIPS16" |
| 1458 |
"#" |
| 1459 |
"&& reload_completed" |
| 1460 |
[(set (match_dup 3) (plus:SI (match_dup 1) (match_dup 2)))] |
| 1461 |
{ operands[3] = gen_lowpart (SImode, operands[0]); } |
| 1462 |
[(set_attr "alu_type" "add") |
| 1463 |
(set_attr "mode" "SI") |
| 1464 |
(set_attr "extended_mips16" "yes")]) |
| 1465 |
|
| 1466 |
;; Combiner patterns for unsigned byte-add. |
| 1467 |
|
| 1468 |
(define_insn "*baddu_si_eb" |
| 1469 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 1470 |
(zero_extend:SI |
| 1471 |
(subreg:QI |
| 1472 |
(plus:SI (match_operand:SI 1 "register_operand" "d") |
| 1473 |
(match_operand:SI 2 "register_operand" "d")) 3)))] |
| 1474 |
"ISA_HAS_BADDU && BYTES_BIG_ENDIAN" |
| 1475 |
"baddu\\t%0,%1,%2" |
| 1476 |
[(set_attr "alu_type" "add")]) |
| 1477 |
|
| 1478 |
(define_insn "*baddu_si_el" |
| 1479 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 1480 |
(zero_extend:SI |
| 1481 |
(subreg:QI |
| 1482 |
(plus:SI (match_operand:SI 1 "register_operand" "d") |
| 1483 |
(match_operand:SI 2 "register_operand" "d")) 0)))] |
| 1484 |
"ISA_HAS_BADDU && !BYTES_BIG_ENDIAN" |
| 1485 |
"baddu\\t%0,%1,%2" |
| 1486 |
[(set_attr "alu_type" "add")]) |
| 1487 |
|
| 1488 |
(define_insn "*baddu_di<mode>" |
| 1489 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 1490 |
(zero_extend:GPR |
| 1491 |
(truncate:QI |
| 1492 |
(plus:DI (match_operand:DI 1 "register_operand" "d") |
| 1493 |
(match_operand:DI 2 "register_operand" "d")))))] |
| 1494 |
"ISA_HAS_BADDU && TARGET_64BIT" |
| 1495 |
"baddu\\t%0,%1,%2" |
| 1496 |
[(set_attr "alu_type" "add")]) |
| 1497 |
|
| 1498 |
;; |
| 1499 |
;; .................... |
| 1500 |
;; |
| 1501 |
;; SUBTRACTION |
| 1502 |
;; |
| 1503 |
;; .................... |
| 1504 |
;; |
| 1505 |
|
| 1506 |
(define_insn "sub<mode>3" |
| 1507 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 1508 |
(minus:ANYF (match_operand:ANYF 1 "register_operand" "f") |
| 1509 |
(match_operand:ANYF 2 "register_operand" "f")))] |
| 1510 |
"" |
| 1511 |
"sub.<fmt>\t%0,%1,%2" |
| 1512 |
[(set_attr "type" "fadd") |
| 1513 |
(set_attr "mode" "<UNITMODE>")]) |
| 1514 |
|
| 1515 |
(define_insn "sub<mode>3" |
| 1516 |
[(set (match_operand:GPR 0 "register_operand" "=!u,d") |
| 1517 |
(minus:GPR (match_operand:GPR 1 "register_operand" "!u,d") |
| 1518 |
(match_operand:GPR 2 "register_operand" "!u,d")))] |
| 1519 |
"" |
| 1520 |
"<d>subu\t%0,%1,%2" |
| 1521 |
[(set_attr "alu_type" "sub") |
| 1522 |
(set_attr "compression" "micromips32,*") |
| 1523 |
(set_attr "mode" "<MODE>")]) |
| 1524 |
|
| 1525 |
(define_insn "*subsi3_extended" |
| 1526 |
[(set (match_operand:DI 0 "register_operand" "=d") |
| 1527 |
(sign_extend:DI |
| 1528 |
(minus:SI (match_operand:SI 1 "register_operand" "d") |
| 1529 |
(match_operand:SI 2 "register_operand" "d"))))] |
| 1530 |
"TARGET_64BIT" |
| 1531 |
"subu\t%0,%1,%2" |
| 1532 |
[(set_attr "alu_type" "sub") |
| 1533 |
(set_attr "mode" "DI")]) |
| 1534 |
|
| 1535 |
;; |
| 1536 |
;; .................... |
| 1537 |
;; |
| 1538 |
;; MULTIPLICATION |
| 1539 |
;; |
| 1540 |
;; .................... |
| 1541 |
;; |
| 1542 |
|
| 1543 |
(define_expand "mul<mode>3" |
| 1544 |
[(set (match_operand:SCALARF 0 "register_operand") |
| 1545 |
(mult:SCALARF (match_operand:SCALARF 1 "register_operand") |
| 1546 |
(match_operand:SCALARF 2 "register_operand")))] |
| 1547 |
"" |
| 1548 |
"") |
| 1549 |
|
| 1550 |
(define_insn "*mul<mode>3" |
| 1551 |
[(set (match_operand:SCALARF 0 "register_operand" "=f") |
| 1552 |
(mult:SCALARF (match_operand:SCALARF 1 "register_operand" "f") |
| 1553 |
(match_operand:SCALARF 2 "register_operand" "f")))] |
| 1554 |
"!TARGET_4300_MUL_FIX" |
| 1555 |
"mul.<fmt>\t%0,%1,%2" |
| 1556 |
[(set_attr "type" "fmul") |
| 1557 |
(set_attr "mode" "<MODE>")]) |
| 1558 |
|
| 1559 |
;; Early VR4300 silicon has a CPU bug where multiplies with certain |
| 1560 |
;; operands may corrupt immediately following multiplies. This is a |
| 1561 |
;; simple fix to insert NOPs. |
| 1562 |
|
| 1563 |
(define_insn "*mul<mode>3_r4300" |
| 1564 |
[(set (match_operand:SCALARF 0 "register_operand" "=f") |
| 1565 |
(mult:SCALARF (match_operand:SCALARF 1 "register_operand" "f") |
| 1566 |
(match_operand:SCALARF 2 "register_operand" "f")))] |
| 1567 |
"TARGET_4300_MUL_FIX" |
| 1568 |
"mul.<fmt>\t%0,%1,%2\;nop" |
| 1569 |
[(set_attr "type" "fmul") |
| 1570 |
(set_attr "mode" "<MODE>") |
| 1571 |
(set_attr "insn_count" "2")]) |
| 1572 |
|
| 1573 |
(define_insn "mulv2sf3" |
| 1574 |
[(set (match_operand:V2SF 0 "register_operand" "=f") |
| 1575 |
(mult:V2SF (match_operand:V2SF 1 "register_operand" "f") |
| 1576 |
(match_operand:V2SF 2 "register_operand" "f")))] |
| 1577 |
"TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT" |
| 1578 |
"mul.ps\t%0,%1,%2" |
| 1579 |
[(set_attr "type" "fmul") |
| 1580 |
(set_attr "mode" "SF")]) |
| 1581 |
|
| 1582 |
;; The original R4000 has a cpu bug. If a double-word or a variable |
| 1583 |
;; shift executes while an integer multiplication is in progress, the |
| 1584 |
;; shift may give an incorrect result. Avoid this by keeping the mflo |
| 1585 |
;; with the mult on the R4000. |
| 1586 |
;; |
| 1587 |
;; From "MIPS R4000PC/SC Errata, Processor Revision 2.2 and 3.0" |
| 1588 |
;; (also valid for MIPS R4000MC processors): |
| 1589 |
;; |
| 1590 |
;; "16. R4000PC, R4000SC: Please refer to errata 28 for an update to |
| 1591 |
;; this errata description. |
| 1592 |
;; The following code sequence causes the R4000 to incorrectly |
| 1593 |
;; execute the Double Shift Right Arithmetic 32 (dsra32) |
| 1594 |
;; instruction. If the dsra32 instruction is executed during an |
| 1595 |
;; integer multiply, the dsra32 will only shift by the amount in |
| 1596 |
;; specified in the instruction rather than the amount plus 32 |
| 1597 |
;; bits. |
| 1598 |
;; instruction 1: mult rs,rt integer multiply |
| 1599 |
;; instruction 2-12: dsra32 rd,rt,rs doubleword shift |
| 1600 |
;; right arithmetic + 32 |
| 1601 |
;; Workaround: A dsra32 instruction placed after an integer |
| 1602 |
;; multiply should not be one of the 11 instructions after the |
| 1603 |
;; multiply instruction." |
| 1604 |
;; |
| 1605 |
;; and: |
| 1606 |
;; |
| 1607 |
;; "28. R4000PC, R4000SC: The text from errata 16 should be replaced by |
| 1608 |
;; the following description. |
| 1609 |
;; All extended shifts (shift by n+32) and variable shifts (32 and |
| 1610 |
;; 64-bit versions) may produce incorrect results under the |
| 1611 |
;; following conditions: |
| 1612 |
;; 1) An integer multiply is currently executing |
| 1613 |
;; 2) These types of shift instructions are executed immediately |
| 1614 |
;; following an integer divide instruction. |
| 1615 |
;; Workaround: |
| 1616 |
;; 1) Make sure no integer multiply is running wihen these |
| 1617 |
;; instruction are executed. If this cannot be predicted at |
| 1618 |
;; compile time, then insert a "mfhi" to R0 instruction |
| 1619 |
;; immediately after the integer multiply instruction. This |
| 1620 |
;; will cause the integer multiply to complete before the shift |
| 1621 |
;; is executed. |
| 1622 |
;; 2) Separate integer divide and these two classes of shift |
| 1623 |
;; instructions by another instruction or a noop." |
| 1624 |
;; |
| 1625 |
;; These processors have PRId values of 0x00004220 and 0x00004300, |
| 1626 |
;; respectively. |
| 1627 |
|
| 1628 |
(define_expand "mul<mode>3" |
| 1629 |
[(set (match_operand:GPR 0 "register_operand") |
| 1630 |
(mult:GPR (match_operand:GPR 1 "register_operand") |
| 1631 |
(match_operand:GPR 2 "register_operand")))] |
| 1632 |
"ISA_HAS_<D>MULT || ISA_HAS_R6<D>MUL" |
| 1633 |
{ |
| 1634 |
rtx lo; |
| 1635 |
|
| 1636 |
if (TARGET_LOONGSON_2EF || TARGET_LOONGSON_EXT || ISA_HAS_R6<D>MUL) |
| 1637 |
emit_insn (gen_mul<mode>3_mul3_nohilo (operands[0], operands[1], |
| 1638 |
operands[2])); |
| 1639 |
else if (ISA_HAS_<D>MUL3) |
| 1640 |
emit_insn (gen_mul<mode>3_mul3 (operands[0], operands[1], operands[2])); |
| 1641 |
else if (TARGET_MIPS16) |
| 1642 |
{ |
| 1643 |
lo = gen_rtx_REG (<MODE>mode, LO_REGNUM); |
| 1644 |
emit_insn (gen_mul<mode>3_internal (lo, operands[1], operands[2])); |
| 1645 |
emit_move_insn (operands[0], lo); |
| 1646 |
} |
| 1647 |
else if (TARGET_FIX_R4000) |
| 1648 |
emit_insn (gen_mul<mode>3_r4000 (operands[0], operands[1], operands[2])); |
| 1649 |
else |
| 1650 |
emit_insn |
| 1651 |
(gen_mul<mode>3_internal (operands[0], operands[1], operands[2])); |
| 1652 |
DONE; |
| 1653 |
}) |
| 1654 |
|
| 1655 |
(define_insn "mul<mode>3_mul3_nohilo" |
| 1656 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 1657 |
(mult:GPR (match_operand:GPR 1 "register_operand" "d") |
| 1658 |
(match_operand:GPR 2 "register_operand" "d")))] |
| 1659 |
"TARGET_LOONGSON_2EF || TARGET_LOONGSON_EXT || ISA_HAS_R6<D>MUL" |
| 1660 |
{ |
| 1661 |
if (TARGET_LOONGSON_2EF) |
| 1662 |
return "<d>multu.g\t%0,%1,%2"; |
| 1663 |
else if (TARGET_LOONGSON_EXT) |
| 1664 |
return "gs<d>multu\t%0,%1,%2"; |
| 1665 |
else |
| 1666 |
return "<d>mul\t%0,%1,%2"; |
| 1667 |
} |
| 1668 |
[(set_attr "type" "imul3nc") |
| 1669 |
(set_attr "mode" "<MODE>")]) |
| 1670 |
|
| 1671 |
(define_insn "mul<mode>3_mul3" |
| 1672 |
[(set (match_operand:GPR 0 "register_operand" "=d,l") |
| 1673 |
(mult:GPR (match_operand:GPR 1 "register_operand" "d,d") |
| 1674 |
(match_operand:GPR 2 "register_operand" "d,d"))) |
| 1675 |
(clobber (match_scratch:GPR 3 "=l,X"))] |
| 1676 |
"ISA_HAS_<D>MUL3" |
| 1677 |
{ |
| 1678 |
if (which_alternative == 1) |
| 1679 |
return "<d>mult\t%1,%2"; |
| 1680 |
if (<MODE>mode == SImode && (TARGET_MIPS3900 || TARGET_MIPS5900)) |
| 1681 |
return "mult\t%0,%1,%2"; |
| 1682 |
return "<d>mul\t%0,%1,%2"; |
| 1683 |
} |
| 1684 |
[(set_attr "type" "imul3,imul") |
| 1685 |
(set_attr "mode" "<MODE>")]) |
| 1686 |
|
| 1687 |
;; If a register gets allocated to LO, and we spill to memory, the reload |
| 1688 |
;; will include a move from LO to a GPR. Merge it into the multiplication |
| 1689 |
;; if it can set the GPR directly. |
| 1690 |
;; |
| 1691 |
;; Operand 0: LO |
| 1692 |
;; Operand 1: GPR (1st multiplication operand) |
| 1693 |
;; Operand 2: GPR (2nd multiplication operand) |
| 1694 |
;; Operand 3: GPR (destination) |
| 1695 |
(define_peephole2 |
| 1696 |
[(parallel |
| 1697 |
[(set (match_operand:SI 0 "lo_operand") |
| 1698 |
(mult:SI (match_operand:SI 1 "d_operand") |
| 1699 |
(match_operand:SI 2 "d_operand"))) |
| 1700 |
(clobber (scratch:SI))]) |
| 1701 |
(set (match_operand:SI 3 "d_operand") |
| 1702 |
(match_dup 0))] |
| 1703 |
"ISA_HAS_MUL3 && peep2_reg_dead_p (2, operands[0])" |
| 1704 |
[(parallel |
| 1705 |
[(set (match_dup 3) |
| 1706 |
(mult:SI (match_dup 1) |
| 1707 |
(match_dup 2))) |
| 1708 |
(clobber (match_dup 0))])]) |
| 1709 |
|
| 1710 |
(define_insn "mul<mode>3_internal" |
| 1711 |
[(set (match_operand:GPR 0 "muldiv_target_operand" "=l") |
| 1712 |
(mult:GPR (match_operand:GPR 1 "register_operand" "d") |
| 1713 |
(match_operand:GPR 2 "register_operand" "d")))] |
| 1714 |
"ISA_HAS_<D>MULT && !TARGET_FIX_R4000" |
| 1715 |
"<d>mult\t%1,%2" |
| 1716 |
[(set_attr "type" "imul") |
| 1717 |
(set_attr "mode" "<MODE>")]) |
| 1718 |
|
| 1719 |
(define_insn "mul<mode>3_r4000" |
| 1720 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 1721 |
(mult:GPR (match_operand:GPR 1 "register_operand" "d") |
| 1722 |
(match_operand:GPR 2 "register_operand" "d"))) |
| 1723 |
(clobber (match_scratch:GPR 3 "=l"))] |
| 1724 |
"ISA_HAS_<D>MULT && TARGET_FIX_R4000" |
| 1725 |
"<d>mult\t%1,%2\;mflo\t%0" |
| 1726 |
[(set_attr "type" "imul") |
| 1727 |
(set_attr "mode" "<MODE>") |
| 1728 |
(set_attr "insn_count" "2")]) |
| 1729 |
|
| 1730 |
;; On the VR4120 and VR4130, it is better to use "mtlo $0; macc" instead |
| 1731 |
;; of "mult; mflo". They have the same latency, but the first form gives |
| 1732 |
;; us an extra cycle to compute the operands. |
| 1733 |
|
| 1734 |
;; Operand 0: LO |
| 1735 |
;; Operand 1: GPR (1st multiplication operand) |
| 1736 |
;; Operand 2: GPR (2nd multiplication operand) |
| 1737 |
;; Operand 3: GPR (destination) |
| 1738 |
(define_peephole2 |
| 1739 |
[(set (match_operand:SI 0 "lo_operand") |
| 1740 |
(mult:SI (match_operand:SI 1 "d_operand") |
| 1741 |
(match_operand:SI 2 "d_operand"))) |
| 1742 |
(set (match_operand:SI 3 "d_operand") |
| 1743 |
(match_dup 0))] |
| 1744 |
"ISA_HAS_MACC && !ISA_HAS_MUL3" |
| 1745 |
[(set (match_dup 0) |
| 1746 |
(const_int 0)) |
| 1747 |
(parallel |
| 1748 |
[(set (match_dup 0) |
| 1749 |
(plus:SI (mult:SI (match_dup 1) |
| 1750 |
(match_dup 2)) |
| 1751 |
(match_dup 0))) |
| 1752 |
(set (match_dup 3) |
| 1753 |
(plus:SI (mult:SI (match_dup 1) |
| 1754 |
(match_dup 2)) |
| 1755 |
(match_dup 0)))])]) |
| 1756 |
|
| 1757 |
;; Multiply-accumulate patterns |
| 1758 |
|
| 1759 |
;; This pattern is first matched by combine, which tries to use the |
| 1760 |
;; pattern wherever it can. We don't know until later whether it |
| 1761 |
;; is actually profitable to use MADD over a "MUL; ADDIU" sequence, |
| 1762 |
;; so we need to keep both options open. |
| 1763 |
;; |
| 1764 |
;; The second alternative has a "?" marker because it is generally |
| 1765 |
;; one instruction more costly than the first alternative. This "?" |
| 1766 |
;; marker is enough to convey the relative costs to the register |
| 1767 |
;; allocator. |
| 1768 |
;; |
| 1769 |
;; However, reload counts reloads of operands 4 and 5 in the same way as |
| 1770 |
;; reloads of the other operands, even though operands 4 and 5 need no |
| 1771 |
;; copy instructions. Reload therefore thinks that the second alternative |
| 1772 |
;; is two reloads more costly than the first. We add "*?*?" to the first |
| 1773 |
;; alternative as a counterweight. |
| 1774 |
;; |
| 1775 |
;; LRA simulates reload but the cost of reloading scratches is lower |
| 1776 |
;; than of the classic reload. For the time being, removing the counterweight |
| 1777 |
;; for LRA is more profitable. |
| 1778 |
(define_insn "*mul_acc_si" |
| 1779 |
[(set (match_operand:SI 0 "register_operand" "=l*?*?,l,d?") |
| 1780 |
(plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d,d") |
| 1781 |
(match_operand:SI 2 "register_operand" "d,d,d")) |
| 1782 |
(match_operand:SI 3 "register_operand" "l,l,d"))) |
| 1783 |
(clobber (match_scratch:SI 4 "=X,X,l")) |
| 1784 |
(clobber (match_scratch:SI 5 "=X,X,&d"))] |
| 1785 |
"GENERATE_MADD_MSUB && !TARGET_MIPS16" |
| 1786 |
"@ |
| 1787 |
madd\t%1,%2 |
| 1788 |
madd\t%1,%2 |
| 1789 |
#" |
| 1790 |
[(set_attr "type" "imadd") |
| 1791 |
(set_attr "accum_in" "3") |
| 1792 |
(set_attr "mode" "SI") |
| 1793 |
(set_attr "insn_count" "1,1,2") |
| 1794 |
(set (attr "enabled") |
| 1795 |
(cond [(eq_attr "alternative" "1,2") |
| 1796 |
(const_string "yes")] |
| 1797 |
(const_string "no")))]) |
| 1798 |
|
| 1799 |
;; The same idea applies here. The middle alternative needs one less |
| 1800 |
;; clobber than the final alternative, so we add "*?" as a counterweight. |
| 1801 |
(define_insn "*mul_acc_si_r3900" |
| 1802 |
[(set (match_operand:SI 0 "register_operand" "=l*?*?,l,d*?,d?") |
| 1803 |
(plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d,d,d") |
| 1804 |
(match_operand:SI 2 "register_operand" "d,d,d,d")) |
| 1805 |
(match_operand:SI 3 "register_operand" "l,l,l,d"))) |
| 1806 |
(clobber (match_scratch:SI 4 "=X,X,3,l")) |
| 1807 |
(clobber (match_scratch:SI 5 "=X,X,X,&d"))] |
| 1808 |
"TARGET_MIPS3900 && !TARGET_MIPS16" |
| 1809 |
"@ |
| 1810 |
madd\t%1,%2 |
| 1811 |
madd\t%1,%2 |
| 1812 |
madd\t%0,%1,%2 |
| 1813 |
#" |
| 1814 |
[(set_attr "type" "imadd") |
| 1815 |
(set_attr "accum_in" "3") |
| 1816 |
(set_attr "mode" "SI") |
| 1817 |
(set_attr "insn_count" "1,1,1,2") |
| 1818 |
(set (attr "enabled") |
| 1819 |
(cond [(eq_attr "alternative" "1,2,3") |
| 1820 |
(const_string "yes")] |
| 1821 |
(const_string "no")))]) |
| 1822 |
|
| 1823 |
;; Split *mul_acc_si if both the source and destination accumulator |
| 1824 |
;; values are GPRs. |
| 1825 |
(define_split |
| 1826 |
[(set (match_operand:SI 0 "d_operand") |
| 1827 |
(plus:SI (mult:SI (match_operand:SI 1 "d_operand") |
| 1828 |
(match_operand:SI 2 "d_operand")) |
| 1829 |
(match_operand:SI 3 "d_operand"))) |
| 1830 |
(clobber (match_operand:SI 4 "lo_operand")) |
| 1831 |
(clobber (match_operand:SI 5 "d_operand"))] |
| 1832 |
"reload_completed" |
| 1833 |
[(parallel [(set (match_dup 5) |
| 1834 |
(mult:SI (match_dup 1) (match_dup 2))) |
| 1835 |
(clobber (match_dup 4))]) |
| 1836 |
(set (match_dup 0) (plus:SI (match_dup 5) (match_dup 3)))] |
| 1837 |
"") |
| 1838 |
|
| 1839 |
(define_insn "*macc" |
| 1840 |
[(set (match_operand:SI 0 "register_operand" "=l,d") |
| 1841 |
(plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d") |
| 1842 |
(match_operand:SI 2 "register_operand" "d,d")) |
| 1843 |
(match_operand:SI 3 "register_operand" "l,l"))) |
| 1844 |
(clobber (match_scratch:SI 4 "=X,3"))] |
| 1845 |
"ISA_HAS_MACC" |
| 1846 |
{ |
| 1847 |
if (which_alternative == 1) |
| 1848 |
return "macc\t%0,%1,%2"; |
| 1849 |
else if (TARGET_MIPS5500) |
| 1850 |
return "madd\t%1,%2"; |
| 1851 |
else |
| 1852 |
/* The VR4130 assumes that there is a two-cycle latency between a macc |
| 1853 |
that "writes" to $0 and an instruction that reads from it. We avoid |
| 1854 |
this by assigning to $1 instead. */ |
| 1855 |
return "%[macc\t%@,%1,%2%]"; |
| 1856 |
} |
| 1857 |
[(set_attr "type" "imadd") |
| 1858 |
(set_attr "accum_in" "3") |
| 1859 |
(set_attr "mode" "SI")]) |
| 1860 |
|
| 1861 |
(define_insn "*msac" |
| 1862 |
[(set (match_operand:SI 0 "register_operand" "=l,d") |
| 1863 |
(minus:SI (match_operand:SI 1 "register_operand" "l,l") |
| 1864 |
(mult:SI (match_operand:SI 2 "register_operand" "d,d") |
| 1865 |
(match_operand:SI 3 "register_operand" "d,d")))) |
| 1866 |
(clobber (match_scratch:SI 4 "=X,1"))] |
| 1867 |
"ISA_HAS_MSAC" |
| 1868 |
{ |
| 1869 |
if (which_alternative == 1) |
| 1870 |
return "msac\t%0,%2,%3"; |
| 1871 |
else if (TARGET_MIPS5500) |
| 1872 |
return "msub\t%2,%3"; |
| 1873 |
else |
| 1874 |
return "msac\t$0,%2,%3"; |
| 1875 |
} |
| 1876 |
[(set_attr "type" "imadd") |
| 1877 |
(set_attr "accum_in" "1") |
| 1878 |
(set_attr "mode" "SI")]) |
| 1879 |
|
| 1880 |
;; An msac-like instruction implemented using negation and a macc. |
| 1881 |
(define_insn_and_split "*msac_using_macc" |
| 1882 |
[(set (match_operand:SI 0 "register_operand" "=l,d") |
| 1883 |
(minus:SI (match_operand:SI 1 "register_operand" "l,l") |
| 1884 |
(mult:SI (match_operand:SI 2 "register_operand" "d,d") |
| 1885 |
(match_operand:SI 3 "register_operand" "d,d")))) |
| 1886 |
(clobber (match_scratch:SI 4 "=X,1")) |
| 1887 |
(clobber (match_scratch:SI 5 "=d,d"))] |
| 1888 |
"ISA_HAS_MACC && !ISA_HAS_MSAC" |
| 1889 |
"#" |
| 1890 |
"&& reload_completed" |
| 1891 |
[(set (match_dup 5) |
| 1892 |
(neg:SI (match_dup 3))) |
| 1893 |
(parallel |
| 1894 |
[(set (match_dup 0) |
| 1895 |
(plus:SI (mult:SI (match_dup 2) |
| 1896 |
(match_dup 5)) |
| 1897 |
(match_dup 1))) |
| 1898 |
(clobber (match_dup 4))])] |
| 1899 |
"" |
| 1900 |
[(set_attr "type" "imadd") |
| 1901 |
(set_attr "accum_in" "1") |
| 1902 |
(set_attr "insn_count" "2")]) |
| 1903 |
|
| 1904 |
;; Patterns generated by the define_peephole2 below. |
| 1905 |
|
| 1906 |
(define_insn "*macc2" |
| 1907 |
[(set (match_operand:SI 0 "muldiv_target_operand" "=l") |
| 1908 |
(plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d") |
| 1909 |
(match_operand:SI 2 "register_operand" "d")) |
| 1910 |
(match_dup 0))) |
| 1911 |
(set (match_operand:SI 3 "register_operand" "=d") |
| 1912 |
(plus:SI (mult:SI (match_dup 1) |
| 1913 |
(match_dup 2)) |
| 1914 |
(match_dup 0)))] |
| 1915 |
"ISA_HAS_MACC && reload_completed" |
| 1916 |
"macc\t%3,%1,%2" |
| 1917 |
[(set_attr "type" "imadd") |
| 1918 |
(set_attr "accum_in" "0") |
| 1919 |
(set_attr "mode" "SI")]) |
| 1920 |
|
| 1921 |
(define_insn "*msac2" |
| 1922 |
[(set (match_operand:SI 0 "muldiv_target_operand" "=l") |
| 1923 |
(minus:SI (match_dup 0) |
| 1924 |
(mult:SI (match_operand:SI 1 "register_operand" "d") |
| 1925 |
(match_operand:SI 2 "register_operand" "d")))) |
| 1926 |
(set (match_operand:SI 3 "register_operand" "=d") |
| 1927 |
(minus:SI (match_dup 0) |
| 1928 |
(mult:SI (match_dup 1) |
| 1929 |
(match_dup 2))))] |
| 1930 |
"ISA_HAS_MSAC && reload_completed" |
| 1931 |
"msac\t%3,%1,%2" |
| 1932 |
[(set_attr "type" "imadd") |
| 1933 |
(set_attr "accum_in" "0") |
| 1934 |
(set_attr "mode" "SI")]) |
| 1935 |
|
| 1936 |
;; Convert macc $0,<r1>,<r2> & mflo <r3> into macc <r3>,<r1>,<r2> |
| 1937 |
;; Similarly msac. |
| 1938 |
;; |
| 1939 |
;; Operand 0: LO |
| 1940 |
;; Operand 1: macc/msac |
| 1941 |
;; Operand 2: GPR (destination) |
| 1942 |
(define_peephole2 |
| 1943 |
[(parallel |
| 1944 |
[(set (match_operand:SI 0 "lo_operand") |
| 1945 |
(match_operand:SI 1 "macc_msac_operand")) |
| 1946 |
(clobber (scratch:SI))]) |
| 1947 |
(set (match_operand:SI 2 "d_operand") |
| 1948 |
(match_dup 0))] |
| 1949 |
"" |
| 1950 |
[(parallel [(set (match_dup 0) |
| 1951 |
(match_dup 1)) |
| 1952 |
(set (match_dup 2) |
| 1953 |
(match_dup 1))])]) |
| 1954 |
|
| 1955 |
;; When we have a three-address multiplication instruction, it should |
| 1956 |
;; be faster to do a separate multiply and add, rather than moving |
| 1957 |
;; something into LO in order to use a macc instruction. |
| 1958 |
;; |
| 1959 |
;; This peephole needs a scratch register to cater for the case when one |
| 1960 |
;; of the multiplication operands is the same as the destination. |
| 1961 |
;; |
| 1962 |
;; Operand 0: GPR (scratch) |
| 1963 |
;; Operand 1: LO |
| 1964 |
;; Operand 2: GPR (addend) |
| 1965 |
;; Operand 3: GPR (destination) |
| 1966 |
;; Operand 4: macc/msac |
| 1967 |
;; Operand 5: new multiplication |
| 1968 |
;; Operand 6: new addition/subtraction |
| 1969 |
(define_peephole2 |
| 1970 |
[(match_scratch:SI 0 "d") |
| 1971 |
(set (match_operand:SI 1 "lo_operand") |
| 1972 |
(match_operand:SI 2 "d_operand")) |
| 1973 |
(match_dup 0) |
| 1974 |
(parallel |
| 1975 |
[(set (match_operand:SI 3 "d_operand") |
| 1976 |
(match_operand:SI 4 "macc_msac_operand")) |
| 1977 |
(clobber (match_dup 1))])] |
| 1978 |
"ISA_HAS_MUL3 && peep2_reg_dead_p (2, operands[1])" |
| 1979 |
[(parallel [(set (match_dup 0) |
| 1980 |
(match_dup 5)) |
| 1981 |
(clobber (match_dup 1))]) |
| 1982 |
(set (match_dup 3) |
| 1983 |
(match_dup 6))] |
| 1984 |
{ |
| 1985 |
operands[5] = XEXP (operands[4], GET_CODE (operands[4]) == PLUS ? 0 : 1); |
| 1986 |
operands[6] = gen_rtx_fmt_ee (GET_CODE (operands[4]), SImode, |
| 1987 |
operands[2], operands[0]); |
| 1988 |
}) |
| 1989 |
|
| 1990 |
;; Same as above, except LO is the initial target of the macc. |
| 1991 |
;; |
| 1992 |
;; Operand 0: GPR (scratch) |
| 1993 |
;; Operand 1: LO |
| 1994 |
;; Operand 2: GPR (addend) |
| 1995 |
;; Operand 3: macc/msac |
| 1996 |
;; Operand 4: GPR (destination) |
| 1997 |
;; Operand 5: new multiplication |
| 1998 |
;; Operand 6: new addition/subtraction |
| 1999 |
(define_peephole2 |
| 2000 |
[(match_scratch:SI 0 "d") |
| 2001 |
(set (match_operand:SI 1 "lo_operand") |
| 2002 |
(match_operand:SI 2 "d_operand")) |
| 2003 |
(match_dup 0) |
| 2004 |
(parallel |
| 2005 |
[(set (match_dup 1) |
| 2006 |
(match_operand:SI 3 "macc_msac_operand")) |
| 2007 |
(clobber (scratch:SI))]) |
| 2008 |
(match_dup 0) |
| 2009 |
(set (match_operand:SI 4 "d_operand") |
| 2010 |
(match_dup 1))] |
| 2011 |
"ISA_HAS_MUL3 && peep2_reg_dead_p (3, operands[1])" |
| 2012 |
[(parallel [(set (match_dup 0) |
| 2013 |
(match_dup 5)) |
| 2014 |
(clobber (match_dup 1))]) |
| 2015 |
(set (match_dup 4) |
| 2016 |
(match_dup 6))] |
| 2017 |
{ |
| 2018 |
operands[5] = XEXP (operands[3], GET_CODE (operands[3]) == PLUS ? 0 : 1); |
| 2019 |
operands[6] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode, |
| 2020 |
operands[2], operands[0]); |
| 2021 |
}) |
| 2022 |
|
| 2023 |
;; See the comment above *mul_add_si for details. |
| 2024 |
(define_insn "*mul_sub_si" |
| 2025 |
[(set (match_operand:SI 0 "register_operand" "=l*?*?,l,d?") |
| 2026 |
(minus:SI (match_operand:SI 1 "register_operand" "l,l,d") |
| 2027 |
(mult:SI (match_operand:SI 2 "register_operand" "d,d,d") |
| 2028 |
(match_operand:SI 3 "register_operand" "d,d,d")))) |
| 2029 |
(clobber (match_scratch:SI 4 "=X,X,l")) |
| 2030 |
(clobber (match_scratch:SI 5 "=X,X,&d"))] |
| 2031 |
"GENERATE_MADD_MSUB" |
| 2032 |
"@ |
| 2033 |
msub\t%2,%3 |
| 2034 |
msub\t%2,%3 |
| 2035 |
#" |
| 2036 |
[(set_attr "type" "imadd") |
| 2037 |
(set_attr "accum_in" "1") |
| 2038 |
(set_attr "mode" "SI") |
| 2039 |
(set_attr "insn_count" "1,1,2") |
| 2040 |
(set (attr "enabled") |
| 2041 |
(cond [(eq_attr "alternative" "1,2") |
| 2042 |
(const_string "yes")] |
| 2043 |
(const_string "no")))]) |
| 2044 |
|
| 2045 |
;; Split *mul_sub_si if both the source and destination accumulator |
| 2046 |
;; values are GPRs. |
| 2047 |
(define_split |
| 2048 |
[(set (match_operand:SI 0 "d_operand") |
| 2049 |
(minus:SI (match_operand:SI 1 "d_operand") |
| 2050 |
(mult:SI (match_operand:SI 2 "d_operand") |
| 2051 |
(match_operand:SI 3 "d_operand")))) |
| 2052 |
(clobber (match_operand:SI 4 "lo_operand")) |
| 2053 |
(clobber (match_operand:SI 5 "d_operand"))] |
| 2054 |
"reload_completed" |
| 2055 |
[(parallel [(set (match_dup 5) |
| 2056 |
(mult:SI (match_dup 2) (match_dup 3))) |
| 2057 |
(clobber (match_dup 4))]) |
| 2058 |
(set (match_dup 0) (minus:SI (match_dup 1) (match_dup 5)))] |
| 2059 |
"") |
| 2060 |
|
| 2061 |
(define_insn "*muls" |
| 2062 |
[(set (match_operand:SI 0 "register_operand" "=l,d") |
| 2063 |
(neg:SI (mult:SI (match_operand:SI 1 "register_operand" "d,d") |
| 2064 |
(match_operand:SI 2 "register_operand" "d,d")))) |
| 2065 |
(clobber (match_scratch:SI 3 "=X,l"))] |
| 2066 |
"ISA_HAS_MULS" |
| 2067 |
"@ |
| 2068 |
muls\t$0,%1,%2 |
| 2069 |
muls\t%0,%1,%2" |
| 2070 |
[(set_attr "type" "imul,imul3") |
| 2071 |
(set_attr "mode" "SI")]) |
| 2072 |
|
| 2073 |
(define_expand "<u>mulsidi3" |
| 2074 |
[(set (match_operand:DI 0 "register_operand") |
| 2075 |
(mult:DI (any_extend:DI (match_operand:SI 1 "register_operand")) |
| 2076 |
(any_extend:DI (match_operand:SI 2 "register_operand"))))] |
| 2077 |
"mips_mulsidi3_gen_fn (<CODE>) != NULL" |
| 2078 |
{ |
| 2079 |
mulsidi3_gen_fn fn = mips_mulsidi3_gen_fn (<CODE>); |
| 2080 |
emit_insn (fn (operands[0], operands[1], operands[2])); |
| 2081 |
DONE; |
| 2082 |
}) |
| 2083 |
|
| 2084 |
(define_expand "<u>mulsidi3_32bit_r6" |
| 2085 |
[(set (match_operand:DI 0 "register_operand") |
| 2086 |
(mult:DI (any_extend:DI (match_operand:SI 1 "register_operand")) |
| 2087 |
(any_extend:DI (match_operand:SI 2 "register_operand"))))] |
| 2088 |
"!TARGET_64BIT && ISA_HAS_R6MUL" |
| 2089 |
{ |
| 2090 |
rtx dest = gen_reg_rtx (DImode); |
| 2091 |
rtx low = mips_subword (dest, 0); |
| 2092 |
rtx high = mips_subword (dest, 1); |
| 2093 |
|
| 2094 |
emit_insn (gen_mulsi3_mul3_nohilo (low, operands[1], operands[2])); |
| 2095 |
emit_insn (gen_<su>mulsi3_highpart_r6 (high, operands[1], operands[2])); |
| 2096 |
|
| 2097 |
emit_move_insn (mips_subword (operands[0], 0), low); |
| 2098 |
emit_move_insn (mips_subword (operands[0], 1), high); |
| 2099 |
DONE; |
| 2100 |
}) |
| 2101 |
|
| 2102 |
(define_expand "<u>mulsidi3_32bit_mips16" |
| 2103 |
[(set (match_operand:DI 0 "register_operand") |
| 2104 |
(mult:DI (any_extend:DI (match_operand:SI 1 "register_operand")) |
| 2105 |
(any_extend:DI (match_operand:SI 2 "register_operand"))))] |
| 2106 |
"!TARGET_64BIT && TARGET_MIPS16" |
| 2107 |
{ |
| 2108 |
rtx hilo; |
| 2109 |
|
| 2110 |
hilo = gen_rtx_REG (DImode, MD_REG_FIRST); |
| 2111 |
emit_insn (gen_<u>mulsidi3_32bit (hilo, operands[1], operands[2])); |
| 2112 |
emit_move_insn (operands[0], hilo); |
| 2113 |
DONE; |
| 2114 |
}) |
| 2115 |
|
| 2116 |
;; As well as being named patterns, these instructions are used by the |
| 2117 |
;; __builtin_mips_mult<u>() functions. We must always make those functions |
| 2118 |
;; available if !TARGET_64BIT && ISA_HAS_DSP. |
| 2119 |
(define_insn "<u>mulsidi3_32bit" |
| 2120 |
[(set (match_operand:DI 0 "muldiv_target_operand" "=ka") |
| 2121 |
(mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d")) |
| 2122 |
(any_extend:DI (match_operand:SI 2 "register_operand" "d"))))] |
| 2123 |
"!TARGET_64BIT && (!TARGET_FIX_R4000 || ISA_HAS_DSP) && ISA_HAS_MULT" |
| 2124 |
{ |
| 2125 |
if (ISA_HAS_DSP_MULT) |
| 2126 |
return "mult<u>\t%q0,%1,%2"; |
| 2127 |
else |
| 2128 |
return "mult<u>\t%1,%2"; |
| 2129 |
} |
| 2130 |
[(set_attr "type" "imul") |
| 2131 |
(set_attr "mode" "SI")]) |
| 2132 |
|
| 2133 |
(define_insn "<u>mulsidi3_32bit_r4000" |
| 2134 |
[(set (match_operand:DI 0 "register_operand" "=d") |
| 2135 |
(mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d")) |
| 2136 |
(any_extend:DI (match_operand:SI 2 "register_operand" "d")))) |
| 2137 |
(clobber (match_scratch:DI 3 "=x"))] |
| 2138 |
"!TARGET_64BIT && TARGET_FIX_R4000 && !ISA_HAS_DSP && ISA_HAS_MULT" |
| 2139 |
"mult<u>\t%1,%2\;mflo\t%L0\;mfhi\t%M0" |
| 2140 |
[(set_attr "type" "imul") |
| 2141 |
(set_attr "mode" "SI") |
| 2142 |
(set_attr "insn_count" "3")]) |
| 2143 |
|
| 2144 |
(define_insn_and_split "<u>mulsidi3_64bit" |
| 2145 |
[(set (match_operand:DI 0 "register_operand" "=d") |
| 2146 |
(mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d")) |
| 2147 |
(any_extend:DI (match_operand:SI 2 "register_operand" "d")))) |
| 2148 |
(clobber (match_scratch:TI 3 "=x")) |
| 2149 |
(clobber (match_scratch:DI 4 "=d"))] |
| 2150 |
"TARGET_64BIT && !TARGET_FIX_R4000 && !ISA_HAS_DMUL3 |
| 2151 |
&& !TARGET_MIPS16 && ISA_HAS_MULT" |
| 2152 |
"#" |
| 2153 |
"&& reload_completed" |
| 2154 |
[(const_int 0)] |
| 2155 |
{ |
| 2156 |
emit_insn (gen_<u>mulsidi3_64bit_split (operands[0], operands[1], |
| 2157 |
operands[2], operands[4])); |
| 2158 |
DONE; |
| 2159 |
} |
| 2160 |
[(set_attr "type" "imul") |
| 2161 |
(set_attr "mode" "SI") |
| 2162 |
(set (attr "insn_count") |
| 2163 |
(if_then_else (match_test "ISA_HAS_EXT_INS") |
| 2164 |
(const_int 4) |
| 2165 |
(const_int 7)))]) |
| 2166 |
|
| 2167 |
(define_expand "<u>mulsidi3_64bit_mips16" |
| 2168 |
[(set (match_operand:DI 0 "register_operand") |
| 2169 |
(mult:DI (any_extend:DI (match_operand:SI 1 "register_operand")) |
| 2170 |
(any_extend:DI (match_operand:SI 2 "register_operand"))))] |
| 2171 |
"TARGET_64BIT && TARGET_MIPS16" |
| 2172 |
{ |
| 2173 |
emit_insn (gen_<u>mulsidi3_64bit_split (operands[0], operands[1], |
| 2174 |
operands[2], gen_reg_rtx (DImode))); |
| 2175 |
DONE; |
| 2176 |
}) |
| 2177 |
|
| 2178 |
(define_expand "<u>mulsidi3_64bit_split" |
| 2179 |
[(set (match_operand:DI 0 "register_operand") |
| 2180 |
(mult:DI (any_extend:DI (match_operand:SI 1 "register_operand")) |
| 2181 |
(any_extend:DI (match_operand:SI 2 "register_operand")))) |
| 2182 |
(clobber (match_operand:DI 3 "register_operand"))] |
| 2183 |
"" |
| 2184 |
{ |
| 2185 |
rtx hilo; |
| 2186 |
|
| 2187 |
hilo = gen_rtx_REG (TImode, MD_REG_FIRST); |
| 2188 |
emit_insn (gen_<u>mulsidi3_64bit_hilo (hilo, operands[1], operands[2])); |
| 2189 |
|
| 2190 |
emit_move_insn (operands[0], gen_rtx_REG (DImode, LO_REGNUM)); |
| 2191 |
emit_insn (gen_mfhidi_ti (operands[3], hilo)); |
| 2192 |
|
| 2193 |
if (ISA_HAS_EXT_INS) |
| 2194 |
emit_insn (gen_insvdi (operands[0], GEN_INT (32), GEN_INT (32), |
| 2195 |
operands[3])); |
| 2196 |
else |
| 2197 |
{ |
| 2198 |
/* Zero-extend the low part. */ |
| 2199 |
mips_emit_binary (ASHIFT, operands[0], operands[0], GEN_INT (32)); |
| 2200 |
mips_emit_binary (LSHIFTRT, operands[0], operands[0], GEN_INT (32)); |
| 2201 |
|
| 2202 |
/* Shift the high part into place. */ |
| 2203 |
mips_emit_binary (ASHIFT, operands[3], operands[3], GEN_INT (32)); |
| 2204 |
|
| 2205 |
/* OR the two halves together. */ |
| 2206 |
mips_emit_binary (IOR, operands[0], operands[0], operands[3]); |
| 2207 |
} |
| 2208 |
DONE; |
| 2209 |
}) |
| 2210 |
|
| 2211 |
(define_insn "<u>mulsidi3_64bit_hilo" |
| 2212 |
[(set (match_operand:TI 0 "muldiv_target_operand" "=x") |
| 2213 |
(unspec:TI |
| 2214 |
[(mult:DI |
| 2215 |
(any_extend:DI (match_operand:SI 1 "register_operand" "d")) |
| 2216 |
(any_extend:DI (match_operand:SI 2 "register_operand" "d")))] |
| 2217 |
UNSPEC_SET_HILO))] |
| 2218 |
"TARGET_64BIT && !TARGET_FIX_R4000" |
| 2219 |
"mult<u>\t%1,%2" |
| 2220 |
[(set_attr "type" "imul") |
| 2221 |
(set_attr "mode" "SI")]) |
| 2222 |
|
| 2223 |
;; See comment before the ISA_HAS_DMUL3 case in mips_mulsidi3_gen_fn. |
| 2224 |
(define_insn "mulsidi3_64bit_dmul" |
| 2225 |
[(set (match_operand:DI 0 "register_operand" "=d") |
| 2226 |
(mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d")) |
| 2227 |
(sign_extend:DI (match_operand:SI 2 "register_operand" "d")))) |
| 2228 |
(clobber (match_scratch:DI 3 "=l"))] |
| 2229 |
"ISA_HAS_DMUL3" |
| 2230 |
"dmul\t%0,%1,%2" |
| 2231 |
[(set_attr "type" "imul3") |
| 2232 |
(set_attr "mode" "DI")]) |
| 2233 |
|
| 2234 |
(define_insn "mulsidi3_64bit_r6dmul" |
| 2235 |
[(set (match_operand:DI 0 "register_operand" "=d") |
| 2236 |
(mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d")) |
| 2237 |
(sign_extend:DI (match_operand:SI 2 "register_operand" "d"))))] |
| 2238 |
"ISA_HAS_R6DMUL" |
| 2239 |
"dmul\t%0,%1,%2" |
| 2240 |
[(set_attr "type" "imul3nc") |
| 2241 |
(set_attr "mode" "DI")]) |
| 2242 |
|
| 2243 |
;; Widening multiply with negation. |
| 2244 |
(define_insn "*muls<u>_di" |
| 2245 |
[(set (match_operand:DI 0 "muldiv_target_operand" "=x") |
| 2246 |
(neg:DI |
| 2247 |
(mult:DI |
| 2248 |
(any_extend:DI (match_operand:SI 1 "register_operand" "d")) |
| 2249 |
(any_extend:DI (match_operand:SI 2 "register_operand" "d")))))] |
| 2250 |
"!TARGET_64BIT && ISA_HAS_MULS" |
| 2251 |
"muls<u>\t$0,%1,%2" |
| 2252 |
[(set_attr "type" "imul") |
| 2253 |
(set_attr "mode" "SI")]) |
| 2254 |
|
| 2255 |
;; As well as being named patterns, these instructions are used by the |
| 2256 |
;; __builtin_mips_msub<u>() functions. We must always make those functions |
| 2257 |
;; available if !TARGET_64BIT && ISA_HAS_DSP. |
| 2258 |
;; |
| 2259 |
;; This leads to a slight inconsistency. We honor any tuning overrides |
| 2260 |
;; in GENERATE_MADD_MSUB for -mno-dsp, but always ignore them for -mdsp, |
| 2261 |
;; even if !ISA_HAS_DSP_MULT. |
| 2262 |
(define_insn "<u>msubsidi4" |
| 2263 |
[(set (match_operand:DI 0 "muldiv_target_operand" "=ka") |
| 2264 |
(minus:DI |
| 2265 |
(match_operand:DI 3 "muldiv_target_operand" "0") |
| 2266 |
(mult:DI |
| 2267 |
(any_extend:DI (match_operand:SI 1 "register_operand" "d")) |
| 2268 |
(any_extend:DI (match_operand:SI 2 "register_operand" "d")))))] |
| 2269 |
"!TARGET_64BIT && (ISA_HAS_MSAC || GENERATE_MADD_MSUB || ISA_HAS_DSP)" |
| 2270 |
{ |
| 2271 |
if (ISA_HAS_DSP_MULT) |
| 2272 |
return "msub<u>\t%q0,%1,%2"; |
| 2273 |
else if (TARGET_MIPS5500 || GENERATE_MADD_MSUB) |
| 2274 |
return "msub<u>\t%1,%2"; |
| 2275 |
else |
| 2276 |
return "msac<u>\t$0,%1,%2"; |
| 2277 |
} |
| 2278 |
[(set_attr "type" "imadd") |
| 2279 |
(set_attr "accum_in" "3") |
| 2280 |
(set_attr "mode" "SI")]) |
| 2281 |
|
| 2282 |
;; _highpart patterns |
| 2283 |
|
| 2284 |
(define_expand "<su>mulsi3_highpart" |
| 2285 |
[(set (match_operand:SI 0 "register_operand") |
| 2286 |
(truncate:SI |
| 2287 |
(lshiftrt:DI |
| 2288 |
(mult:DI (any_extend:DI (match_operand:SI 1 "register_operand")) |
| 2289 |
(any_extend:DI (match_operand:SI 2 "register_operand"))) |
| 2290 |
(const_int 32))))] |
| 2291 |
"" |
| 2292 |
{ |
| 2293 |
if (ISA_HAS_MULHI) |
| 2294 |
emit_insn (gen_<su>mulsi3_highpart_mulhi_internal (operands[0], |
| 2295 |
operands[1], |
| 2296 |
operands[2])); |
| 2297 |
else if (TARGET_MIPS16) |
| 2298 |
emit_insn (gen_<su>mulsi3_highpart_split (operands[0], operands[1], |
| 2299 |
operands[2])); |
| 2300 |
else if (ISA_HAS_R6MUL) |
| 2301 |
emit_insn (gen_<su>mulsi3_highpart_r6 (operands[0], operands[1], |
| 2302 |
operands[2])); |
| 2303 |
else |
| 2304 |
emit_insn (gen_<su>mulsi3_highpart_internal (operands[0], operands[1], |
| 2305 |
operands[2])); |
| 2306 |
DONE; |
| 2307 |
}) |
| 2308 |
|
| 2309 |
(define_insn "<su>mulsi3_highpart_r6" |
| 2310 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 2311 |
(truncate:SI |
| 2312 |
(lshiftrt:DI |
| 2313 |
(mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d")) |
| 2314 |
(any_extend:DI (match_operand:SI 2 "register_operand" "d"))) |
| 2315 |
(const_int 32))))] |
| 2316 |
"ISA_HAS_R6MUL" |
| 2317 |
"muh<u>\t%0,%1,%2" |
| 2318 |
[(set_attr "type" "imul3nc") |
| 2319 |
(set_attr "mode" "SI")]) |
| 2320 |
|
| 2321 |
(define_insn_and_split "<su>mulsi3_highpart_internal" |
| 2322 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 2323 |
(truncate:SI |
| 2324 |
(lshiftrt:DI |
| 2325 |
(mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d")) |
| 2326 |
(any_extend:DI (match_operand:SI 2 "register_operand" "d"))) |
| 2327 |
(const_int 32)))) |
| 2328 |
(clobber (match_scratch:SI 3 "=l"))] |
| 2329 |
"ISA_HAS_MULT && !ISA_HAS_MULHI && !TARGET_MIPS16" |
| 2330 |
{ return TARGET_FIX_R4000 ? "mult<u>\t%1,%2\n\tmfhi\t%0" : "#"; } |
| 2331 |
"&& reload_completed && !TARGET_FIX_R4000" |
| 2332 |
[(const_int 0)] |
| 2333 |
{ |
| 2334 |
emit_insn (gen_<su>mulsi3_highpart_split (operands[0], operands[1], |
| 2335 |
operands[2])); |
| 2336 |
DONE; |
| 2337 |
} |
| 2338 |
[(set_attr "type" "imul") |
| 2339 |
(set_attr "mode" "SI") |
| 2340 |
(set_attr "insn_count" "2")]) |
| 2341 |
|
| 2342 |
(define_expand "<su>mulsi3_highpart_split" |
| 2343 |
[(set (match_operand:SI 0 "register_operand") |
| 2344 |
(truncate:SI |
| 2345 |
(lshiftrt:DI |
| 2346 |
(mult:DI (any_extend:DI (match_operand:SI 1 "register_operand")) |
| 2347 |
(any_extend:DI (match_operand:SI 2 "register_operand"))) |
| 2348 |
(const_int 32))))] |
| 2349 |
"" |
| 2350 |
{ |
| 2351 |
rtx hilo; |
| 2352 |
|
| 2353 |
if (TARGET_64BIT) |
| 2354 |
{ |
| 2355 |
hilo = gen_rtx_REG (TImode, MD_REG_FIRST); |
| 2356 |
emit_insn (gen_<u>mulsidi3_64bit_hilo (hilo, operands[1], operands[2])); |
| 2357 |
emit_insn (gen_mfhisi_ti (operands[0], hilo)); |
| 2358 |
} |
| 2359 |
else |
| 2360 |
{ |
| 2361 |
hilo = gen_rtx_REG (DImode, MD_REG_FIRST); |
| 2362 |
emit_insn (gen_<u>mulsidi3_32bit (hilo, operands[1], operands[2])); |
| 2363 |
emit_insn (gen_mfhisi_di (operands[0], hilo)); |
| 2364 |
} |
| 2365 |
DONE; |
| 2366 |
}) |
| 2367 |
|
| 2368 |
(define_insn "<su>mulsi3_highpart_mulhi_internal" |
| 2369 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 2370 |
(truncate:SI |
| 2371 |
(lshiftrt:DI |
| 2372 |
(mult:DI |
| 2373 |
(any_extend:DI (match_operand:SI 1 "register_operand" "d")) |
| 2374 |
(any_extend:DI (match_operand:SI 2 "register_operand" "d"))) |
| 2375 |
(const_int 32)))) |
| 2376 |
(clobber (match_scratch:SI 3 "=l"))] |
| 2377 |
"ISA_HAS_MULHI" |
| 2378 |
"mulhi<u>\t%0,%1,%2" |
| 2379 |
[(set_attr "type" "imul3") |
| 2380 |
(set_attr "mode" "SI")]) |
| 2381 |
|
| 2382 |
(define_insn "*<su>mulsi3_highpart_neg_mulhi_internal" |
| 2383 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 2384 |
(truncate:SI |
| 2385 |
(lshiftrt:DI |
| 2386 |
(neg:DI |
| 2387 |
(mult:DI |
| 2388 |
(any_extend:DI (match_operand:SI 1 "register_operand" "d")) |
| 2389 |
(any_extend:DI (match_operand:SI 2 "register_operand" "d")))) |
| 2390 |
(const_int 32)))) |
| 2391 |
(clobber (match_scratch:SI 3 "=l"))] |
| 2392 |
"ISA_HAS_MULHI" |
| 2393 |
"mulshi<u>\t%0,%1,%2" |
| 2394 |
[(set_attr "type" "imul3") |
| 2395 |
(set_attr "mode" "SI")]) |
| 2396 |
|
| 2397 |
;; Disable unsigned multiplication for -mfix-vr4120. This is for VR4120 |
| 2398 |
;; errata MD(0), which says that dmultu does not always produce the |
| 2399 |
;; correct result. |
| 2400 |
(define_expand "<su>muldi3_highpart" |
| 2401 |
[(set (match_operand:DI 0 "register_operand") |
| 2402 |
(truncate:DI |
| 2403 |
(lshiftrt:TI |
| 2404 |
(mult:TI (any_extend:TI (match_operand:DI 1 "register_operand")) |
| 2405 |
(any_extend:TI (match_operand:DI 2 "register_operand"))) |
| 2406 |
(const_int 64))))] |
| 2407 |
"ISA_HAS_R6DMUL |
| 2408 |
|| (ISA_HAS_DMULT |
| 2409 |
&& !(<CODE> == ZERO_EXTEND && TARGET_FIX_VR4120))" |
| 2410 |
{ |
| 2411 |
if (TARGET_MIPS16) |
| 2412 |
emit_insn (gen_<su>muldi3_highpart_split (operands[0], operands[1], |
| 2413 |
operands[2])); |
| 2414 |
else if (ISA_HAS_R6DMUL) |
| 2415 |
emit_insn (gen_<su>muldi3_highpart_r6 (operands[0], operands[1], |
| 2416 |
operands[2])); |
| 2417 |
else |
| 2418 |
emit_insn (gen_<su>muldi3_highpart_internal (operands[0], operands[1], |
| 2419 |
operands[2])); |
| 2420 |
DONE; |
| 2421 |
}) |
| 2422 |
|
| 2423 |
(define_insn "<su>muldi3_highpart_r6" |
| 2424 |
[(set (match_operand:DI 0 "register_operand" "=d") |
| 2425 |
(truncate:DI |
| 2426 |
(lshiftrt:TI |
| 2427 |
(mult:TI (any_extend:TI (match_operand:DI 1 "register_operand" "d")) |
| 2428 |
(any_extend:TI (match_operand:DI 2 "register_operand" "d"))) |
| 2429 |
(const_int 64))))] |
| 2430 |
"ISA_HAS_R6DMUL" |
| 2431 |
"dmuh<u>\t%0,%1,%2" |
| 2432 |
[(set_attr "type" "imul3nc") |
| 2433 |
(set_attr "mode" "DI")]) |
| 2434 |
|
| 2435 |
(define_insn_and_split "<su>muldi3_highpart_internal" |
| 2436 |
[(set (match_operand:DI 0 "register_operand" "=d") |
| 2437 |
(truncate:DI |
| 2438 |
(lshiftrt:TI |
| 2439 |
(mult:TI (any_extend:TI (match_operand:DI 1 "register_operand" "d")) |
| 2440 |
(any_extend:TI (match_operand:DI 2 "register_operand" "d"))) |
| 2441 |
(const_int 64)))) |
| 2442 |
(clobber (match_scratch:DI 3 "=l"))] |
| 2443 |
"ISA_HAS_DMULT |
| 2444 |
&& !TARGET_MIPS16 |
| 2445 |
&& !(<CODE> == ZERO_EXTEND && TARGET_FIX_VR4120)" |
| 2446 |
{ return TARGET_FIX_R4000 ? "dmult<u>\t%1,%2\n\tmfhi\t%0" : "#"; } |
| 2447 |
"&& reload_completed && !TARGET_FIX_R4000" |
| 2448 |
[(const_int 0)] |
| 2449 |
{ |
| 2450 |
emit_insn (gen_<su>muldi3_highpart_split (operands[0], operands[1], |
| 2451 |
operands[2])); |
| 2452 |
DONE; |
| 2453 |
} |
| 2454 |
[(set_attr "type" "imul") |
| 2455 |
(set_attr "mode" "DI") |
| 2456 |
(set_attr "insn_count" "2")]) |
| 2457 |
|
| 2458 |
(define_expand "<su>muldi3_highpart_split" |
| 2459 |
[(set (match_operand:DI 0 "register_operand") |
| 2460 |
(truncate:DI |
| 2461 |
(lshiftrt:TI |
| 2462 |
(mult:TI (any_extend:TI (match_operand:DI 1 "register_operand")) |
| 2463 |
(any_extend:TI (match_operand:DI 2 "register_operand"))) |
| 2464 |
(const_int 64))))] |
| 2465 |
"" |
| 2466 |
{ |
| 2467 |
rtx hilo; |
| 2468 |
|
| 2469 |
hilo = gen_rtx_REG (TImode, MD_REG_FIRST); |
| 2470 |
emit_insn (gen_<u>mulditi3_internal (hilo, operands[1], operands[2])); |
| 2471 |
emit_insn (gen_mfhidi_ti (operands[0], hilo)); |
| 2472 |
DONE; |
| 2473 |
}) |
| 2474 |
|
| 2475 |
(define_expand "<u>mulditi3" |
| 2476 |
[(set (match_operand:TI 0 "register_operand") |
| 2477 |
(mult:TI (any_extend:TI (match_operand:DI 1 "register_operand")) |
| 2478 |
(any_extend:TI (match_operand:DI 2 "register_operand"))))] |
| 2479 |
"ISA_HAS_R6DMUL |
| 2480 |
|| (ISA_HAS_DMULT |
| 2481 |
&& !(<CODE> == ZERO_EXTEND && TARGET_FIX_VR4120))" |
| 2482 |
{ |
| 2483 |
rtx hilo, hi, lo; |
| 2484 |
|
| 2485 |
if (TARGET_MIPS16) |
| 2486 |
{ |
| 2487 |
hilo = gen_rtx_REG (TImode, MD_REG_FIRST); |
| 2488 |
emit_insn (gen_<u>mulditi3_internal (hilo, operands[1], operands[2])); |
| 2489 |
emit_move_insn (operands[0], hilo); |
| 2490 |
} |
| 2491 |
else if (TARGET_FIX_R4000) |
| 2492 |
emit_insn (gen_<u>mulditi3_r4000 (operands[0], operands[1], operands[2])); |
| 2493 |
else if (ISA_HAS_DMULT) |
| 2494 |
emit_insn (gen_<u>mulditi3_internal (operands[0], operands[1], |
| 2495 |
operands[2])); |
| 2496 |
else |
| 2497 |
{ |
| 2498 |
hi = mips_subword (operands[0], 1); |
| 2499 |
lo = mips_subword (operands[0], 0); |
| 2500 |
emit_insn (gen_muldi3_mul3_nohilo (lo, operands[1], operands[2])); |
| 2501 |
emit_insn (gen_<su>muldi3_highpart_r6 (hi, operands[1], operands[2])); |
| 2502 |
} |
| 2503 |
DONE; |
| 2504 |
}) |
| 2505 |
|
| 2506 |
(define_insn "<u>mulditi3_internal" |
| 2507 |
[(set (match_operand:TI 0 "muldiv_target_operand" "=x") |
| 2508 |
(mult:TI (any_extend:TI (match_operand:DI 1 "register_operand" "d")) |
| 2509 |
(any_extend:TI (match_operand:DI 2 "register_operand" "d"))))] |
| 2510 |
"ISA_HAS_DMULT |
| 2511 |
&& !TARGET_FIX_R4000 |
| 2512 |
&& !(<CODE> == ZERO_EXTEND && TARGET_FIX_VR4120)" |
| 2513 |
"dmult<u>\t%1,%2" |
| 2514 |
[(set_attr "type" "imul") |
| 2515 |
(set_attr "mode" "DI")]) |
| 2516 |
|
| 2517 |
(define_insn "<u>mulditi3_r4000" |
| 2518 |
[(set (match_operand:TI 0 "register_operand" "=d") |
| 2519 |
(mult:TI (any_extend:TI (match_operand:DI 1 "register_operand" "d")) |
| 2520 |
(any_extend:TI (match_operand:DI 2 "register_operand" "d")))) |
| 2521 |
(clobber (match_scratch:TI 3 "=x"))] |
| 2522 |
"ISA_HAS_DMULT |
| 2523 |
&& TARGET_FIX_R4000 |
| 2524 |
&& !(<CODE> == ZERO_EXTEND && TARGET_FIX_VR4120)" |
| 2525 |
"dmult<u>\t%1,%2\;mflo\t%L0\;mfhi\t%M0" |
| 2526 |
[(set_attr "type" "imul") |
| 2527 |
(set_attr "mode" "DI") |
| 2528 |
(set_attr "insn_count" "3")]) |
| 2529 |
|
| 2530 |
;; The R4650 supports a 32-bit multiply/ 64-bit accumulate |
| 2531 |
;; instruction. The HI/LO registers are used as a 64-bit accumulator. |
| 2532 |
|
| 2533 |
(define_insn "madsi" |
| 2534 |
[(set (match_operand:SI 0 "register_operand" "+l") |
| 2535 |
(plus:SI (mult:SI (match_operand:SI 1 "register_operand" "d") |
| 2536 |
(match_operand:SI 2 "register_operand" "d")) |
| 2537 |
(match_dup 0)))] |
| 2538 |
"TARGET_MAD" |
| 2539 |
"mad\t%1,%2" |
| 2540 |
[(set_attr "type" "imadd") |
| 2541 |
(set_attr "accum_in" "0") |
| 2542 |
(set_attr "mode" "SI")]) |
| 2543 |
|
| 2544 |
;; See the comment above <u>msubsidi4 for the relationship between |
| 2545 |
;; ISA_HAS_DSP and ISA_HAS_DSP_MULT. |
| 2546 |
(define_insn "<u>maddsidi4" |
| 2547 |
[(set (match_operand:DI 0 "muldiv_target_operand" "=ka") |
| 2548 |
(plus:DI |
| 2549 |
(mult:DI (any_extend:DI (match_operand:SI 1 "register_operand" "d")) |
| 2550 |
(any_extend:DI (match_operand:SI 2 "register_operand" "d"))) |
| 2551 |
(match_operand:DI 3 "muldiv_target_operand" "0")))] |
| 2552 |
"(TARGET_MAD || ISA_HAS_MACC || GENERATE_MADD_MSUB || ISA_HAS_DSP) |
| 2553 |
&& !TARGET_64BIT" |
| 2554 |
{ |
| 2555 |
if (TARGET_MAD) |
| 2556 |
return "mad<u>\t%1,%2"; |
| 2557 |
else if (ISA_HAS_DSP_MULT) |
| 2558 |
return "madd<u>\t%q0,%1,%2"; |
| 2559 |
else if (GENERATE_MADD_MSUB || TARGET_MIPS5500) |
| 2560 |
return "madd<u>\t%1,%2"; |
| 2561 |
else |
| 2562 |
/* See comment in *macc. */ |
| 2563 |
return "%[macc<u>\t%@,%1,%2%]"; |
| 2564 |
} |
| 2565 |
[(set_attr "type" "imadd") |
| 2566 |
(set_attr "accum_in" "3") |
| 2567 |
(set_attr "mode" "SI")]) |
| 2568 |
|
| 2569 |
;; Floating point multiply accumulate instructions. |
| 2570 |
|
| 2571 |
(define_expand "fma<mode>4" |
| 2572 |
[(set (match_operand:ANYF 0 "register_operand") |
| 2573 |
(fma:ANYF (match_operand:ANYF 1 "register_operand") |
| 2574 |
(match_operand:ANYF 2 "register_operand") |
| 2575 |
(match_operand:ANYF 3 "register_operand")))] |
| 2576 |
"ISA_HAS_FUSED_MADDF || ISA_HAS_FUSED_MADD3 || ISA_HAS_FUSED_MADD4") |
| 2577 |
|
| 2578 |
(define_insn "*fma<mode>4_madd3" |
| 2579 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 2580 |
(fma:ANYF (match_operand:ANYF 1 "register_operand" "f") |
| 2581 |
(match_operand:ANYF 2 "register_operand" "f") |
| 2582 |
(match_operand:ANYF 3 "register_operand" "0")))] |
| 2583 |
"ISA_HAS_FUSED_MADD3" |
| 2584 |
"madd.<fmt>\t%0,%1,%2" |
| 2585 |
[(set_attr "type" "fmadd") |
| 2586 |
(set_attr "mode" "<UNITMODE>")]) |
| 2587 |
|
| 2588 |
(define_insn "*fma<mode>4_madd4" |
| 2589 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 2590 |
(fma:ANYF (match_operand:ANYF 1 "register_operand" "f") |
| 2591 |
(match_operand:ANYF 2 "register_operand" "f") |
| 2592 |
(match_operand:ANYF 3 "register_operand" "f")))] |
| 2593 |
"ISA_HAS_FUSED_MADD4" |
| 2594 |
"madd.<fmt>\t%0,%3,%1,%2" |
| 2595 |
[(set_attr "type" "fmadd") |
| 2596 |
(set_attr "mode" "<UNITMODE>")]) |
| 2597 |
|
| 2598 |
(define_insn "*fma<mode>4_maddf" |
| 2599 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 2600 |
(fma:ANYF (match_operand:ANYF 1 "register_operand" "f") |
| 2601 |
(match_operand:ANYF 2 "register_operand" "f") |
| 2602 |
(match_operand:ANYF 3 "register_operand" "0")))] |
| 2603 |
"ISA_HAS_FUSED_MADDF" |
| 2604 |
"maddf.<fmt>\t%0,%1,%2" |
| 2605 |
[(set_attr "type" "fmadd") |
| 2606 |
(set_attr "mode" "<UNITMODE>")]) |
| 2607 |
|
| 2608 |
;; The fms, fnma, and fnms instructions can be used even when HONOR_NANS |
| 2609 |
;; is true because while IEEE 754-2008 requires the negate operation to |
| 2610 |
;; negate the sign of a NAN and the MIPS neg instruction does not do this, |
| 2611 |
;; the fma part of the instruction has no requirement on how the sign of |
| 2612 |
;; a NAN is handled and so the final sign bit of the entire operation is |
| 2613 |
;; undefined. |
| 2614 |
|
| 2615 |
(define_expand "fms<mode>4" |
| 2616 |
[(set (match_operand:ANYF 0 "register_operand") |
| 2617 |
(fma:ANYF (match_operand:ANYF 1 "register_operand") |
| 2618 |
(match_operand:ANYF 2 "register_operand") |
| 2619 |
(neg:ANYF (match_operand:ANYF 3 "register_operand"))))] |
| 2620 |
"(ISA_HAS_FUSED_MADD3 || ISA_HAS_FUSED_MADD4)") |
| 2621 |
|
| 2622 |
(define_insn "*fms<mode>4_msub3" |
| 2623 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 2624 |
(fma:ANYF (match_operand:ANYF 1 "register_operand" "f") |
| 2625 |
(match_operand:ANYF 2 "register_operand" "f") |
| 2626 |
(neg:ANYF (match_operand:ANYF 3 "register_operand" "0"))))] |
| 2627 |
"ISA_HAS_FUSED_MADD3" |
| 2628 |
"msub.<fmt>\t%0,%1,%2" |
| 2629 |
[(set_attr "type" "fmadd") |
| 2630 |
(set_attr "mode" "<UNITMODE>")]) |
| 2631 |
|
| 2632 |
(define_insn "*fms<mode>4_msub4" |
| 2633 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 2634 |
(fma:ANYF (match_operand:ANYF 1 "register_operand" "f") |
| 2635 |
(match_operand:ANYF 2 "register_operand" "f") |
| 2636 |
(neg:ANYF (match_operand:ANYF 3 "register_operand" "f"))))] |
| 2637 |
"ISA_HAS_FUSED_MADD4" |
| 2638 |
"msub.<fmt>\t%0,%3,%1,%2" |
| 2639 |
[(set_attr "type" "fmadd") |
| 2640 |
(set_attr "mode" "<UNITMODE>")]) |
| 2641 |
|
| 2642 |
;; fnma is defined in GCC as (fma (neg op1) op2 op3) |
| 2643 |
;; (-op1 * op2) + op3 ==> -(op1 * op2) + op3 ==> -((op1 * op2) - op3) |
| 2644 |
;; The mips nmsub instructions implement -((op1 * op2) - op3) |
| 2645 |
;; This transformation means we may return the wrong signed zero |
| 2646 |
;; so we check HONOR_SIGNED_ZEROS. |
| 2647 |
|
| 2648 |
(define_expand "fnma<mode>4" |
| 2649 |
[(set (match_operand:ANYF 0 "register_operand") |
| 2650 |
(fma:ANYF (neg:ANYF (match_operand:ANYF 1 "register_operand")) |
| 2651 |
(match_operand:ANYF 2 "register_operand") |
| 2652 |
(match_operand:ANYF 3 "register_operand")))] |
| 2653 |
"(ISA_HAS_FUSED_MADD3 || ISA_HAS_FUSED_MADD4) |
| 2654 |
&& !HONOR_SIGNED_ZEROS (<MODE>mode)") |
| 2655 |
|
| 2656 |
(define_insn "*fnma<mode>4_nmsub3" |
| 2657 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 2658 |
(fma:ANYF (neg:ANYF (match_operand:ANYF 1 "register_operand" "f")) |
| 2659 |
(match_operand:ANYF 2 "register_operand" "f") |
| 2660 |
(match_operand:ANYF 3 "register_operand" "0")))] |
| 2661 |
"ISA_HAS_FUSED_MADD3 && !HONOR_SIGNED_ZEROS (<MODE>mode)" |
| 2662 |
"nmsub.<fmt>\t%0,%1,%2" |
| 2663 |
[(set_attr "type" "fmadd") |
| 2664 |
(set_attr "mode" "<UNITMODE>")]) |
| 2665 |
|
| 2666 |
(define_insn "*fnma<mode>4_nmsub4" |
| 2667 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 2668 |
(fma:ANYF (neg:ANYF (match_operand:ANYF 1 "register_operand" "f")) |
| 2669 |
(match_operand:ANYF 2 "register_operand" "f") |
| 2670 |
(match_operand:ANYF 3 "register_operand" "f")))] |
| 2671 |
"ISA_HAS_FUSED_MADD4 && !HONOR_SIGNED_ZEROS (<MODE>mode)" |
| 2672 |
"nmsub.<fmt>\t%0,%3,%1,%2" |
| 2673 |
[(set_attr "type" "fmadd") |
| 2674 |
(set_attr "mode" "<UNITMODE>")]) |
| 2675 |
|
| 2676 |
;; fnms is defined as: (fma (neg op1) op2 (neg op3)) |
| 2677 |
;; ((-op1) * op2) - op3 ==> -(op1 * op2) - op3 ==> -((op1 * op2) + op3) |
| 2678 |
;; The mips nmadd instructions implement -((op1 * op2) + op3) |
| 2679 |
;; This transformation means we may return the wrong signed zero |
| 2680 |
;; so we check HONOR_SIGNED_ZEROS. |
| 2681 |
|
| 2682 |
(define_expand "fnms<mode>4" |
| 2683 |
[(set (match_operand:ANYF 0 "register_operand") |
| 2684 |
(fma:ANYF |
| 2685 |
(neg:ANYF (match_operand:ANYF 1 "register_operand")) |
| 2686 |
(match_operand:ANYF 2 "register_operand") |
| 2687 |
(neg:ANYF (match_operand:ANYF 3 "register_operand"))))] |
| 2688 |
"(ISA_HAS_FUSED_MADD3 || ISA_HAS_FUSED_MADD4) |
| 2689 |
&& !HONOR_SIGNED_ZEROS (<MODE>mode)") |
| 2690 |
|
| 2691 |
(define_insn "*fnms<mode>4_nmadd3" |
| 2692 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 2693 |
(fma:ANYF |
| 2694 |
(neg:ANYF (match_operand:ANYF 1 "register_operand" "f")) |
| 2695 |
(match_operand:ANYF 2 "register_operand" "f") |
| 2696 |
(neg:ANYF (match_operand:ANYF 3 "register_operand" "0"))))] |
| 2697 |
"ISA_HAS_FUSED_MADD3 && !HONOR_SIGNED_ZEROS (<MODE>mode)" |
| 2698 |
"nmadd.<fmt>\t%0,%1,%2" |
| 2699 |
[(set_attr "type" "fmadd") |
| 2700 |
(set_attr "mode" "<UNITMODE>")]) |
| 2701 |
|
| 2702 |
(define_insn "*fnms<mode>4_nmadd4" |
| 2703 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 2704 |
(fma:ANYF |
| 2705 |
(neg:ANYF (match_operand:ANYF 1 "register_operand" "f")) |
| 2706 |
(match_operand:ANYF 2 "register_operand" "f") |
| 2707 |
(neg:ANYF (match_operand:ANYF 3 "register_operand" "f"))))] |
| 2708 |
"ISA_HAS_FUSED_MADD4 && !HONOR_SIGNED_ZEROS (<MODE>mode)" |
| 2709 |
"nmadd.<fmt>\t%0,%3,%1,%2" |
| 2710 |
[(set_attr "type" "fmadd") |
| 2711 |
(set_attr "mode" "<UNITMODE>")]) |
| 2712 |
|
| 2713 |
;; Non-fused Floating point multiply accumulate instructions. |
| 2714 |
|
| 2715 |
;; These instructions are not fused and round in between the multiply |
| 2716 |
;; and the add (or subtract) so they are equivalent to the separate |
| 2717 |
;; multiply and add/sub instructions. |
| 2718 |
|
| 2719 |
(define_insn "*madd4<mode>" |
| 2720 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 2721 |
(plus:ANYF (mult:ANYF (match_operand:ANYF 1 "register_operand" "f") |
| 2722 |
(match_operand:ANYF 2 "register_operand" "f")) |
| 2723 |
(match_operand:ANYF 3 "register_operand" "f")))] |
| 2724 |
"ISA_HAS_UNFUSED_MADD4" |
| 2725 |
"madd.<fmt>\t%0,%3,%1,%2" |
| 2726 |
[(set_attr "type" "fmadd") |
| 2727 |
(set_attr "mode" "<UNITMODE>")]) |
| 2728 |
|
| 2729 |
(define_insn "*msub4<mode>" |
| 2730 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 2731 |
(minus:ANYF (mult:ANYF (match_operand:ANYF 1 "register_operand" "f") |
| 2732 |
(match_operand:ANYF 2 "register_operand" "f")) |
| 2733 |
(match_operand:ANYF 3 "register_operand" "f")))] |
| 2734 |
"ISA_HAS_UNFUSED_MADD4" |
| 2735 |
"msub.<fmt>\t%0,%3,%1,%2" |
| 2736 |
[(set_attr "type" "fmadd") |
| 2737 |
(set_attr "mode" "<UNITMODE>")]) |
| 2738 |
|
| 2739 |
;; Like with the fused fms, fnma, and fnms instructions, these unfused |
| 2740 |
;; instructions can be used even if HONOR_NANS is set because while |
| 2741 |
;; IEEE 754-2008 requires the negate operation to negate the sign of a |
| 2742 |
;; NAN and the MIPS neg instruction does not do this, the multiply and |
| 2743 |
;; add (or subtract) part of the instruction has no requirement on how |
| 2744 |
;; the sign of a NAN is handled and so the final sign bit of the entire |
| 2745 |
;; operation is undefined. |
| 2746 |
|
| 2747 |
(define_insn "*nmadd4<mode>" |
| 2748 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 2749 |
(neg:ANYF (plus:ANYF |
| 2750 |
(mult:ANYF (match_operand:ANYF 1 "register_operand" "f") |
| 2751 |
(match_operand:ANYF 2 "register_operand" "f")) |
| 2752 |
(match_operand:ANYF 3 "register_operand" "f"))))] |
| 2753 |
"ISA_HAS_UNFUSED_MADD4" |
| 2754 |
"nmadd.<fmt>\t%0,%3,%1,%2" |
| 2755 |
[(set_attr "type" "fmadd") |
| 2756 |
(set_attr "mode" "<UNITMODE>")]) |
| 2757 |
|
| 2758 |
(define_insn "*nmsub4<mode>" |
| 2759 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 2760 |
(neg:ANYF (minus:ANYF |
| 2761 |
(mult:ANYF (match_operand:ANYF 1 "register_operand" "f") |
| 2762 |
(match_operand:ANYF 2 "register_operand" "f")) |
| 2763 |
(match_operand:ANYF 3 "register_operand" "f"))))] |
| 2764 |
"ISA_HAS_UNFUSED_MADD4" |
| 2765 |
"nmsub.<fmt>\t%0,%3,%1,%2" |
| 2766 |
[(set_attr "type" "fmadd") |
| 2767 |
(set_attr "mode" "<UNITMODE>")]) |
| 2768 |
|
| 2769 |
;; Fast-math Non-fused Floating point multiply accumulate instructions. |
| 2770 |
|
| 2771 |
;; These instructions are not fused but the expressions they match are |
| 2772 |
;; not exactly what the instruction implements in the sense that they |
| 2773 |
;; may not generate the properly signed zeros. |
| 2774 |
|
| 2775 |
;; This instruction recognizes ((-op1) * op2) - op3 and generates an |
| 2776 |
;; nmadd which is really -((op1 * op2) + op3). They are equivalent |
| 2777 |
;; except for the sign bit when the result is zero or NaN. |
| 2778 |
|
| 2779 |
(define_insn "*nmadd4<mode>_fastmath" |
| 2780 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 2781 |
(minus:ANYF |
| 2782 |
(mult:ANYF (neg:ANYF (match_operand:ANYF 1 "register_operand" "f")) |
| 2783 |
(match_operand:ANYF 2 "register_operand" "f")) |
| 2784 |
(match_operand:ANYF 3 "register_operand" "f")))] |
| 2785 |
"ISA_HAS_UNFUSED_MADD4 |
| 2786 |
&& !HONOR_SIGNED_ZEROS (<MODE>mode)" |
| 2787 |
"nmadd.<fmt>\t%0,%3,%1,%2" |
| 2788 |
[(set_attr "type" "fmadd") |
| 2789 |
(set_attr "mode" "<UNITMODE>")]) |
| 2790 |
|
| 2791 |
;; This instruction recognizes (op1 - (op2 * op3) and generates an |
| 2792 |
;; nmsub which is really -((op2 * op3) - op1). They are equivalent |
| 2793 |
;; except for the sign bit when the result is zero or NaN. |
| 2794 |
|
| 2795 |
(define_insn "*nmsub4<mode>_fastmath" |
| 2796 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 2797 |
(minus:ANYF |
| 2798 |
(match_operand:ANYF 1 "register_operand" "f") |
| 2799 |
(mult:ANYF (match_operand:ANYF 2 "register_operand" "f") |
| 2800 |
(match_operand:ANYF 3 "register_operand" "f"))))] |
| 2801 |
"ISA_HAS_UNFUSED_MADD4 |
| 2802 |
&& !HONOR_SIGNED_ZEROS (<MODE>mode)" |
| 2803 |
"nmsub.<fmt>\t%0,%1,%2,%3" |
| 2804 |
[(set_attr "type" "fmadd") |
| 2805 |
(set_attr "mode" "<UNITMODE>")]) |
| 2806 |
|
| 2807 |
;; |
| 2808 |
;; .................... |
| 2809 |
;; |
| 2810 |
;; DIVISION and REMAINDER |
| 2811 |
;; |
| 2812 |
;; .................... |
| 2813 |
;; |
| 2814 |
|
| 2815 |
(define_expand "div<mode>3" |
| 2816 |
[(set (match_operand:ANYF 0 "register_operand") |
| 2817 |
(div:ANYF (match_operand:ANYF 1 "reg_or_1_operand") |
| 2818 |
(match_operand:ANYF 2 "register_operand")))] |
| 2819 |
"<divide_condition>" |
| 2820 |
{ |
| 2821 |
if (const_1_operand (operands[1], <MODE>mode)) |
| 2822 |
if (!(ISA_HAS_FP_RECIP_RSQRT (<MODE>mode) |
| 2823 |
&& flag_unsafe_math_optimizations)) |
| 2824 |
operands[1] = force_reg (<MODE>mode, operands[1]); |
| 2825 |
}) |
| 2826 |
|
| 2827 |
;; These patterns work around the early SB-1 rev2 core "F1" erratum: |
| 2828 |
;; |
| 2829 |
;; If an mfc1 or dmfc1 happens to access the floating point register |
| 2830 |
;; file at the same time a long latency operation (div, sqrt, recip, |
| 2831 |
;; sqrt) iterates an intermediate result back through the floating |
| 2832 |
;; point register file bypass, then instead returning the correct |
| 2833 |
;; register value the mfc1 or dmfc1 operation returns the intermediate |
| 2834 |
;; result of the long latency operation. |
| 2835 |
;; |
| 2836 |
;; The workaround is to insert an unconditional 'mov' from/to the |
| 2837 |
;; long latency op destination register. |
| 2838 |
|
| 2839 |
(define_insn "*div<mode>3" |
| 2840 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 2841 |
(div:ANYF (match_operand:ANYF 1 "register_operand" "f") |
| 2842 |
(match_operand:ANYF 2 "register_operand" "f")))] |
| 2843 |
"<divide_condition>" |
| 2844 |
{ |
| 2845 |
if (TARGET_FIX_SB1) |
| 2846 |
return "div.<fmt>\t%0,%1,%2\;mov.<fmt>\t%0,%0"; |
| 2847 |
else |
| 2848 |
return "div.<fmt>\t%0,%1,%2"; |
| 2849 |
} |
| 2850 |
[(set_attr "type" "fdiv") |
| 2851 |
(set_attr "mode" "<UNITMODE>") |
| 2852 |
(set (attr "insn_count") |
| 2853 |
(if_then_else (match_test "TARGET_FIX_SB1") |
| 2854 |
(const_int 2) |
| 2855 |
(const_int 1)))]) |
| 2856 |
|
| 2857 |
(define_insn "*recip<mode>3" |
| 2858 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 2859 |
(div:ANYF (match_operand:ANYF 1 "const_1_operand" "") |
| 2860 |
(match_operand:ANYF 2 "register_operand" "f")))] |
| 2861 |
"ISA_HAS_FP_RECIP_RSQRT (<MODE>mode) && flag_unsafe_math_optimizations" |
| 2862 |
{ |
| 2863 |
if (TARGET_FIX_SB1) |
| 2864 |
return "recip.<fmt>\t%0,%2\;mov.<fmt>\t%0,%0"; |
| 2865 |
else |
| 2866 |
return "recip.<fmt>\t%0,%2"; |
| 2867 |
} |
| 2868 |
[(set_attr "type" "frdiv") |
| 2869 |
(set_attr "mode" "<UNITMODE>") |
| 2870 |
(set (attr "insn_count") |
| 2871 |
(if_then_else (match_test "TARGET_FIX_SB1") |
| 2872 |
(const_int 2) |
| 2873 |
(const_int 1)))]) |
| 2874 |
|
| 2875 |
;; VR4120 errata MD(A1): signed division instructions do not work correctly |
| 2876 |
;; with negative operands. We use special libgcc functions instead. |
| 2877 |
(define_expand "divmod<mode>4" |
| 2878 |
[(parallel |
| 2879 |
[(set (match_operand:GPR 0 "register_operand") |
| 2880 |
(div:GPR (match_operand:GPR 1 "register_operand") |
| 2881 |
(match_operand:GPR 2 "register_operand"))) |
| 2882 |
(set (match_operand:GPR 3 "register_operand") |
| 2883 |
(mod:GPR (match_dup 1) |
| 2884 |
(match_dup 2)))])] |
| 2885 |
"ISA_HAS_<D>DIV && !TARGET_FIX_VR4120" |
| 2886 |
{ |
| 2887 |
if (TARGET_MIPS16) |
| 2888 |
{ |
| 2889 |
rtx lo = gen_rtx_REG (<MODE>mode, LO_REGNUM); |
| 2890 |
emit_insn (gen_divmod<mode>4_mips16 (operands[0], operands[1], |
| 2891 |
operands[2], operands[3], lo)); |
| 2892 |
DONE; |
| 2893 |
} |
| 2894 |
}) |
| 2895 |
|
| 2896 |
(define_insn_and_split "*divmod<mode>4" |
| 2897 |
[(set (match_operand:GPR 0 "register_operand" "=l") |
| 2898 |
(div:GPR (match_operand:GPR 1 "register_operand" "d") |
| 2899 |
(match_operand:GPR 2 "register_operand" "d"))) |
| 2900 |
(set (match_operand:GPR 3 "register_operand" "=d") |
| 2901 |
(mod:GPR (match_dup 1) |
| 2902 |
(match_dup 2)))] |
| 2903 |
"ISA_HAS_<D>DIV && !TARGET_FIX_VR4120 && !TARGET_MIPS16" |
| 2904 |
"#" |
| 2905 |
"&& reload_completed" |
| 2906 |
[(const_int 0)] |
| 2907 |
{ |
| 2908 |
emit_insn (gen_divmod<mode>4_split (operands[3], operands[1], operands[2])); |
| 2909 |
DONE; |
| 2910 |
} |
| 2911 |
[(set_attr "type" "idiv") |
| 2912 |
(set_attr "mode" "<MODE>") |
| 2913 |
(set_attr "insn_count" "2")]) |
| 2914 |
|
| 2915 |
;; Expand generates divmod instructions for individual division and modulus |
| 2916 |
;; operations. We then rely on CSE to reuse earlier divmods where possible. |
| 2917 |
;; This means that, when generating MIPS16 code, it is better not to expose |
| 2918 |
;; the fixed LO register until after CSE has finished. However, it's still |
| 2919 |
;; better to split before register allocation, so that we don't allocate |
| 2920 |
;; one of the scarce MIPS16 registers to an unused result. |
| 2921 |
(define_insn_and_split "divmod<mode>4_mips16" |
| 2922 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 2923 |
(div:GPR (match_operand:GPR 1 "register_operand" "d") |
| 2924 |
(match_operand:GPR 2 "register_operand" "d"))) |
| 2925 |
(set (match_operand:GPR 3 "register_operand" "=d") |
| 2926 |
(mod:GPR (match_dup 1) |
| 2927 |
(match_dup 2))) |
| 2928 |
(clobber (match_operand:GPR 4 "lo_operand" "=l"))] |
| 2929 |
"ISA_HAS_<D>DIV && !TARGET_FIX_VR4120 && TARGET_MIPS16" |
| 2930 |
"#" |
| 2931 |
"&& cse_not_expected" |
| 2932 |
[(const_int 0)] |
| 2933 |
{ |
| 2934 |
emit_insn (gen_divmod<mode>4_split (operands[3], operands[1], operands[2])); |
| 2935 |
emit_move_insn (operands[0], operands[4]); |
| 2936 |
DONE; |
| 2937 |
} |
| 2938 |
[(set_attr "type" "idiv") |
| 2939 |
(set_attr "mode" "<MODE>") |
| 2940 |
(set_attr "insn_count" "3")]) |
| 2941 |
|
| 2942 |
(define_expand "udivmod<mode>4" |
| 2943 |
[(parallel |
| 2944 |
[(set (match_operand:GPR 0 "register_operand") |
| 2945 |
(udiv:GPR (match_operand:GPR 1 "register_operand") |
| 2946 |
(match_operand:GPR 2 "register_operand"))) |
| 2947 |
(set (match_operand:GPR 3 "register_operand") |
| 2948 |
(umod:GPR (match_dup 1) |
| 2949 |
(match_dup 2)))])] |
| 2950 |
"ISA_HAS_<D>DIV && !TARGET_FIX_VR4120" |
| 2951 |
{ |
| 2952 |
if (TARGET_MIPS16) |
| 2953 |
{ |
| 2954 |
rtx lo = gen_rtx_REG (<MODE>mode, LO_REGNUM); |
| 2955 |
emit_insn (gen_udivmod<mode>4_mips16 (operands[0], operands[1], |
| 2956 |
operands[2], operands[3], lo)); |
| 2957 |
DONE; |
| 2958 |
} |
| 2959 |
}) |
| 2960 |
|
| 2961 |
(define_insn_and_split "*udivmod<mode>4" |
| 2962 |
[(set (match_operand:GPR 0 "register_operand" "=l") |
| 2963 |
(udiv:GPR (match_operand:GPR 1 "register_operand" "d") |
| 2964 |
(match_operand:GPR 2 "register_operand" "d"))) |
| 2965 |
(set (match_operand:GPR 3 "register_operand" "=d") |
| 2966 |
(umod:GPR (match_dup 1) |
| 2967 |
(match_dup 2)))] |
| 2968 |
"ISA_HAS_<D>DIV && !TARGET_MIPS16" |
| 2969 |
"#" |
| 2970 |
"reload_completed" |
| 2971 |
[(const_int 0)] |
| 2972 |
{ |
| 2973 |
emit_insn (gen_udivmod<mode>4_split (operands[3], operands[1], operands[2])); |
| 2974 |
DONE; |
| 2975 |
} |
| 2976 |
[(set_attr "type" "idiv") |
| 2977 |
(set_attr "mode" "<MODE>") |
| 2978 |
(set_attr "insn_count" "2")]) |
| 2979 |
|
| 2980 |
;; See the comment above "divmod<mode>4_mips16" for the split timing. |
| 2981 |
(define_insn_and_split "udivmod<mode>4_mips16" |
| 2982 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 2983 |
(udiv:GPR (match_operand:GPR 1 "register_operand" "d") |
| 2984 |
(match_operand:GPR 2 "register_operand" "d"))) |
| 2985 |
(set (match_operand:GPR 3 "register_operand" "=d") |
| 2986 |
(umod:GPR (match_dup 1) |
| 2987 |
(match_dup 2))) |
| 2988 |
(clobber (match_operand:GPR 4 "lo_operand" "=l"))] |
| 2989 |
"ISA_HAS_<D>DIV && TARGET_MIPS16" |
| 2990 |
"#" |
| 2991 |
"cse_not_expected" |
| 2992 |
[(const_int 0)] |
| 2993 |
{ |
| 2994 |
emit_insn (gen_udivmod<mode>4_split (operands[3], operands[1], operands[2])); |
| 2995 |
emit_move_insn (operands[0], operands[4]); |
| 2996 |
DONE; |
| 2997 |
} |
| 2998 |
[(set_attr "type" "idiv") |
| 2999 |
(set_attr "mode" "<MODE>") |
| 3000 |
(set_attr "insn_count" "3")]) |
| 3001 |
|
| 3002 |
(define_expand "<u>divmod<mode>4_split" |
| 3003 |
[(set (match_operand:GPR 0 "register_operand") |
| 3004 |
(any_mod:GPR (match_operand:GPR 1 "register_operand") |
| 3005 |
(match_operand:GPR 2 "register_operand")))] |
| 3006 |
"" |
| 3007 |
{ |
| 3008 |
rtx hilo; |
| 3009 |
|
| 3010 |
if (TARGET_64BIT) |
| 3011 |
{ |
| 3012 |
hilo = gen_rtx_REG (TImode, MD_REG_FIRST); |
| 3013 |
emit_insn (gen_<u>divmod<mode>4_hilo_ti (hilo, operands[1], |
| 3014 |
operands[2])); |
| 3015 |
emit_insn (gen_mfhi<mode>_ti (operands[0], hilo)); |
| 3016 |
} |
| 3017 |
else |
| 3018 |
{ |
| 3019 |
hilo = gen_rtx_REG (DImode, MD_REG_FIRST); |
| 3020 |
emit_insn (gen_<u>divmod<mode>4_hilo_di (hilo, operands[1], |
| 3021 |
operands[2])); |
| 3022 |
emit_insn (gen_mfhi<mode>_di (operands[0], hilo)); |
| 3023 |
} |
| 3024 |
DONE; |
| 3025 |
}) |
| 3026 |
|
| 3027 |
(define_insn "<u>divmod<GPR:mode>4_hilo_<HILO:mode>" |
| 3028 |
[(set (match_operand:HILO 0 "muldiv_target_operand" "=x") |
| 3029 |
(unspec:HILO |
| 3030 |
[(any_div:GPR (match_operand:GPR 1 "register_operand" "d") |
| 3031 |
(match_operand:GPR 2 "register_operand" "d"))] |
| 3032 |
UNSPEC_SET_HILO))] |
| 3033 |
"ISA_HAS_<GPR:D>DIV" |
| 3034 |
{ return mips_output_division ("<GPR:d>div<u>\t%.,%1,%2", operands); } |
| 3035 |
[(set_attr "type" "idiv") |
| 3036 |
(set_attr "mode" "<GPR:MODE>")]) |
| 3037 |
|
| 3038 |
;; Integer division and modulus. |
| 3039 |
|
| 3040 |
(define_insn "<u>div<mode>3" |
| 3041 |
[(set (match_operand:GPR 0 "register_operand" "=&d") |
| 3042 |
(any_div:GPR (match_operand:GPR 1 "register_operand" "d") |
| 3043 |
(match_operand:GPR 2 "register_operand" "d")))] |
| 3044 |
"TARGET_LOONGSON_2EF || TARGET_LOONGSON_EXT || ISA_HAS_R6<D>DIV" |
| 3045 |
{ |
| 3046 |
if (TARGET_LOONGSON_2EF) |
| 3047 |
return mips_output_division ("<d>div<u>.g\t%0,%1,%2", operands); |
| 3048 |
else if (TARGET_LOONGSON_EXT) |
| 3049 |
return mips_output_division ("gs<d>div<u>\t%0,%1,%2", operands); |
| 3050 |
else |
| 3051 |
return mips_output_division ("<d>div<u>\t%0,%1,%2", operands); |
| 3052 |
} |
| 3053 |
[(set_attr "type" "idiv3") |
| 3054 |
(set_attr "mode" "<MODE>")]) |
| 3055 |
|
| 3056 |
(define_insn "<u>mod<mode>3" |
| 3057 |
[(set (match_operand:GPR 0 "register_operand" "=&d") |
| 3058 |
(any_mod:GPR (match_operand:GPR 1 "register_operand" "d") |
| 3059 |
(match_operand:GPR 2 "register_operand" "d")))] |
| 3060 |
"TARGET_LOONGSON_2EF || TARGET_LOONGSON_EXT || ISA_HAS_R6<D>DIV" |
| 3061 |
{ |
| 3062 |
if (TARGET_LOONGSON_2EF) |
| 3063 |
return mips_output_division ("<d>mod<u>.g\t%0,%1,%2", operands); |
| 3064 |
else if (TARGET_LOONGSON_EXT) |
| 3065 |
return mips_output_division ("gs<d>mod<u>\t%0,%1,%2", operands); |
| 3066 |
else |
| 3067 |
return mips_output_division ("<d>mod<u>\t%0,%1,%2", operands); |
| 3068 |
} |
| 3069 |
[(set_attr "type" "idiv3") |
| 3070 |
(set_attr "mode" "<MODE>")]) |
| 3071 |
|
| 3072 |
;; |
| 3073 |
;; .................... |
| 3074 |
;; |
| 3075 |
;; SQUARE ROOT |
| 3076 |
;; |
| 3077 |
;; .................... |
| 3078 |
|
| 3079 |
;; These patterns work around the early SB-1 rev2 core "F1" erratum (see |
| 3080 |
;; "*div[sd]f3" comment for details). |
| 3081 |
|
| 3082 |
(define_insn "sqrt<mode>2" |
| 3083 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 3084 |
(sqrt:ANYF (match_operand:ANYF 1 "register_operand" "f")))] |
| 3085 |
"<sqrt_condition>" |
| 3086 |
{ |
| 3087 |
if (TARGET_FIX_SB1) |
| 3088 |
return "sqrt.<fmt>\t%0,%1\;mov.<fmt>\t%0,%0"; |
| 3089 |
else |
| 3090 |
return "sqrt.<fmt>\t%0,%1"; |
| 3091 |
} |
| 3092 |
[(set_attr "type" "fsqrt") |
| 3093 |
(set_attr "mode" "<UNITMODE>") |
| 3094 |
(set (attr "insn_count") |
| 3095 |
(if_then_else (match_test "TARGET_FIX_SB1") |
| 3096 |
(const_int 2) |
| 3097 |
(const_int 1)))]) |
| 3098 |
|
| 3099 |
(define_insn "*rsqrt<mode>a" |
| 3100 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 3101 |
(div:ANYF (match_operand:ANYF 1 "const_1_operand" "") |
| 3102 |
(sqrt:ANYF (match_operand:ANYF 2 "register_operand" "f"))))] |
| 3103 |
"ISA_HAS_FP_RECIP_RSQRT (<MODE>mode) && flag_unsafe_math_optimizations" |
| 3104 |
{ |
| 3105 |
if (TARGET_FIX_SB1) |
| 3106 |
return "rsqrt.<fmt>\t%0,%2\;mov.<fmt>\t%0,%0"; |
| 3107 |
else |
| 3108 |
return "rsqrt.<fmt>\t%0,%2"; |
| 3109 |
} |
| 3110 |
[(set_attr "type" "frsqrt") |
| 3111 |
(set_attr "mode" "<UNITMODE>") |
| 3112 |
(set (attr "insn_count") |
| 3113 |
(if_then_else (match_test "TARGET_FIX_SB1") |
| 3114 |
(const_int 2) |
| 3115 |
(const_int 1)))]) |
| 3116 |
|
| 3117 |
(define_insn "*rsqrt<mode>b" |
| 3118 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 3119 |
(sqrt:ANYF (div:ANYF (match_operand:ANYF 1 "const_1_operand" "") |
| 3120 |
(match_operand:ANYF 2 "register_operand" "f"))))] |
| 3121 |
"ISA_HAS_FP_RECIP_RSQRT (<MODE>mode) && flag_unsafe_math_optimizations" |
| 3122 |
{ |
| 3123 |
if (TARGET_FIX_SB1) |
| 3124 |
return "rsqrt.<fmt>\t%0,%2\;mov.<fmt>\t%0,%0"; |
| 3125 |
else |
| 3126 |
return "rsqrt.<fmt>\t%0,%2"; |
| 3127 |
} |
| 3128 |
[(set_attr "type" "frsqrt") |
| 3129 |
(set_attr "mode" "<UNITMODE>") |
| 3130 |
(set (attr "insn_count") |
| 3131 |
(if_then_else (match_test "TARGET_FIX_SB1") |
| 3132 |
(const_int 2) |
| 3133 |
(const_int 1)))]) |
| 3134 |
|
| 3135 |
;; |
| 3136 |
;; .................... |
| 3137 |
;; |
| 3138 |
;; ABSOLUTE VALUE |
| 3139 |
;; |
| 3140 |
;; .................... |
| 3141 |
|
| 3142 |
;; Do not use the integer abs macro instruction, since that signals an |
| 3143 |
;; exception on -2147483648 (sigh). |
| 3144 |
|
| 3145 |
;; The "legacy" (as opposed to "2008") form of ABS.fmt is an arithmetic |
| 3146 |
;; instruction that treats all NaN inputs as invalid; it does not clear |
| 3147 |
;; their sign bit. We therefore can't use that form if the signs of |
| 3148 |
;; NaNs matter. |
| 3149 |
|
| 3150 |
(define_insn "abs<mode>2" |
| 3151 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 3152 |
(abs:ANYF (match_operand:ANYF 1 "register_operand" "f")))] |
| 3153 |
"mips_abs == MIPS_IEEE_754_2008 || !HONOR_NANS (<MODE>mode)" |
| 3154 |
"abs.<fmt>\t%0,%1" |
| 3155 |
[(set_attr "type" "fabs") |
| 3156 |
(set_attr "mode" "<UNITMODE>")]) |
| 3157 |
|
| 3158 |
;; |
| 3159 |
;; ................... |
| 3160 |
;; |
| 3161 |
;; Count leading zeroes. |
| 3162 |
;; |
| 3163 |
;; ................... |
| 3164 |
;; |
| 3165 |
|
| 3166 |
(define_insn "clz<mode>2" |
| 3167 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 3168 |
(clz:GPR (match_operand:GPR 1 "register_operand" "d")))] |
| 3169 |
"ISA_HAS_CLZ_CLO" |
| 3170 |
"<d>clz\t%0,%1" |
| 3171 |
[(set_attr "type" "clz") |
| 3172 |
(set_attr "mode" "<MODE>")]) |
| 3173 |
|
| 3174 |
|
| 3175 |
(define_insn "*clo<mode>2" |
| 3176 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 3177 |
(clz:GPR (not:GPR (match_operand:GPR 1 "register_operand" "d"))))] |
| 3178 |
"ISA_HAS_CLZ_CLO" |
| 3179 |
"<d>clo\t%0,%1" |
| 3180 |
[(set_attr "type" "clz") |
| 3181 |
(set_attr "mode" "<MODE>")]) |
| 3182 |
|
| 3183 |
;; |
| 3184 |
;; ................... |
| 3185 |
;; |
| 3186 |
;; Count trailing zeroes. |
| 3187 |
;; |
| 3188 |
;; ................... |
| 3189 |
;; |
| 3190 |
|
| 3191 |
(define_insn "ctz<mode>2" |
| 3192 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 3193 |
(ctz:GPR (match_operand:GPR 1 "register_operand" "d")))] |
| 3194 |
"ISA_HAS_CTZ_CTO" |
| 3195 |
"<d>ctz\t%0,%1" |
| 3196 |
[(set_attr "type" "clz") |
| 3197 |
(set_attr "mode" "<MODE>")]) |
| 3198 |
|
| 3199 |
|
| 3200 |
;; |
| 3201 |
;; ................... |
| 3202 |
;; |
| 3203 |
;; Count number of set bits. |
| 3204 |
;; |
| 3205 |
;; ................... |
| 3206 |
;; |
| 3207 |
|
| 3208 |
(define_insn "popcount<mode>2" |
| 3209 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 3210 |
(popcount:GPR (match_operand:GPR 1 "register_operand" "d")))] |
| 3211 |
"ISA_HAS_POP" |
| 3212 |
"<d>pop\t%0,%1" |
| 3213 |
[(set_attr "type" "pop") |
| 3214 |
(set_attr "mode" "<MODE>")]) |
| 3215 |
|
| 3216 |
;; The POP instruction is special as it does not take into account the upper |
| 3217 |
;; 32bits and is documented that way. |
| 3218 |
(define_insn "*popcountdi2_trunc" |
| 3219 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 3220 |
(popcount:SI (truncate:SI (match_operand:DI 1 "register_operand" "d"))))] |
| 3221 |
"ISA_HAS_POP && TARGET_64BIT" |
| 3222 |
"pop\t%0,%1" |
| 3223 |
[(set_attr "type" "pop") |
| 3224 |
(set_attr "mode" "SI")]) |
| 3225 |
|
| 3226 |
;; |
| 3227 |
;; .................... |
| 3228 |
;; |
| 3229 |
;; NEGATION and ONE'S COMPLEMENT |
| 3230 |
;; |
| 3231 |
;; .................... |
| 3232 |
|
| 3233 |
(define_insn "negsi2" |
| 3234 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 3235 |
(neg:SI (match_operand:SI 1 "register_operand" "d")))] |
| 3236 |
"" |
| 3237 |
{ |
| 3238 |
if (TARGET_MIPS16) |
| 3239 |
return "neg\t%0,%1"; |
| 3240 |
else |
| 3241 |
return "subu\t%0,%.,%1"; |
| 3242 |
} |
| 3243 |
[(set_attr "alu_type" "sub") |
| 3244 |
(set_attr "mode" "SI")]) |
| 3245 |
|
| 3246 |
(define_insn "negdi2" |
| 3247 |
[(set (match_operand:DI 0 "register_operand" "=d") |
| 3248 |
(neg:DI (match_operand:DI 1 "register_operand" "d")))] |
| 3249 |
"TARGET_64BIT && !TARGET_MIPS16" |
| 3250 |
"dsubu\t%0,%.,%1" |
| 3251 |
[(set_attr "alu_type" "sub") |
| 3252 |
(set_attr "mode" "DI")]) |
| 3253 |
|
| 3254 |
;; The "legacy" (as opposed to "2008") form of NEG.fmt is an arithmetic |
| 3255 |
;; instruction that treats all NaN inputs as invalid; it does not flip |
| 3256 |
;; their sign bit. We therefore can't use that form if the signs of |
| 3257 |
;; NaNs matter. |
| 3258 |
|
| 3259 |
(define_insn "neg<mode>2" |
| 3260 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 3261 |
(neg:ANYF (match_operand:ANYF 1 "register_operand" "f")))] |
| 3262 |
"mips_abs == MIPS_IEEE_754_2008 || !HONOR_NANS (<MODE>mode)" |
| 3263 |
"neg.<fmt>\t%0,%1" |
| 3264 |
[(set_attr "type" "fneg") |
| 3265 |
(set_attr "mode" "<UNITMODE>")]) |
| 3266 |
|
| 3267 |
(define_insn "one_cmpl<mode>2" |
| 3268 |
[(set (match_operand:GPR 0 "register_operand" "=!u,d") |
| 3269 |
(not:GPR (match_operand:GPR 1 "register_operand" "!u,d")))] |
| 3270 |
"" |
| 3271 |
{ |
| 3272 |
if (TARGET_MIPS16) |
| 3273 |
return "not\t%0,%1"; |
| 3274 |
else |
| 3275 |
return "nor\t%0,%.,%1"; |
| 3276 |
} |
| 3277 |
[(set_attr "alu_type" "not") |
| 3278 |
(set_attr "compression" "micromips,*") |
| 3279 |
(set_attr "mode" "<MODE>")]) |
| 3280 |
|
| 3281 |
;; |
| 3282 |
;; .................... |
| 3283 |
;; |
| 3284 |
;; LOGICAL |
| 3285 |
;; |
| 3286 |
;; .................... |
| 3287 |
;; |
| 3288 |
|
| 3289 |
;; Many of these instructions use trivial define_expands, because we |
| 3290 |
;; want to use a different set of constraints when TARGET_MIPS16. |
| 3291 |
|
| 3292 |
(define_expand "and<mode>3" |
| 3293 |
[(set (match_operand:GPR 0 "register_operand") |
| 3294 |
(and:GPR (match_operand:GPR 1 "register_operand") |
| 3295 |
(match_operand:GPR 2 "and_reg_operand")))]) |
| 3296 |
|
| 3297 |
;; The middle-end is not allowed to convert ANDing with 0xffff_ffff into a |
| 3298 |
;; zero_extendsidi2 because of TARGET_TRULY_NOOP_TRUNCATION, so handle these |
| 3299 |
;; here. Note that this variant does not trigger for SI mode because we |
| 3300 |
;; require a 64-bit HOST_WIDE_INT and 0xffff_ffff wouldn't be a canonical |
| 3301 |
;; sign-extended SImode value. |
| 3302 |
;; |
| 3303 |
;; These are possible combinations for operand 1 and 2. The table |
| 3304 |
;; includes both MIPS and MIPS16 cases. (r=register, mem=memory, |
| 3305 |
;; 16=MIPS16, x=match, S=split): |
| 3306 |
;; |
| 3307 |
;; \ op1 r/EXT r/!EXT mem r/16 mem/16 |
| 3308 |
;; op2 |
| 3309 |
;; |
| 3310 |
;; andi x x |
| 3311 |
;; 0xff x x x x |
| 3312 |
;; 0xffff x x x x |
| 3313 |
;; 0xffff_ffff x S x S x |
| 3314 |
;; low-bitmask x |
| 3315 |
;; register x x |
| 3316 |
;; register =op1 x |
| 3317 |
|
| 3318 |
(define_insn "*and<mode>3" |
| 3319 |
[(set (match_operand:GPR 0 "register_operand" "=d,d,d,!u,d,d,d,!u,d,d") |
| 3320 |
(and:GPR (match_operand:GPR 1 "nonimmediate_operand" "o,o,W,!u,d,d,d,0,d,0") |
| 3321 |
(match_operand:GPR 2 "and_operand" "Yb,Yh,Yw,Uean,K,Yx,Yw,!u,d,Yz")))] |
| 3322 |
"!TARGET_MIPS16 && and_operands_ok (<MODE>mode, operands[1], operands[2])" |
| 3323 |
{ |
| 3324 |
int len; |
| 3325 |
int pos; |
| 3326 |
|
| 3327 |
switch (which_alternative) |
| 3328 |
{ |
| 3329 |
case 0: |
| 3330 |
operands[1] = gen_lowpart (QImode, operands[1]); |
| 3331 |
return "lbu\t%0,%1"; |
| 3332 |
case 1: |
| 3333 |
operands[1] = gen_lowpart (HImode, operands[1]); |
| 3334 |
return "lhu\t%0,%1"; |
| 3335 |
case 2: |
| 3336 |
operands[1] = gen_lowpart (SImode, operands[1]); |
| 3337 |
return "lwu\t%0,%1"; |
| 3338 |
case 3: |
| 3339 |
case 4: |
| 3340 |
return "andi\t%0,%1,%x2"; |
| 3341 |
case 5: |
| 3342 |
len = low_bitmask_len (<MODE>mode, INTVAL (operands[2])); |
| 3343 |
operands[2] = GEN_INT (len); |
| 3344 |
return "<d>ext\t%0,%1,0,%2"; |
| 3345 |
case 6: |
| 3346 |
return "#"; |
| 3347 |
case 7: |
| 3348 |
case 8: |
| 3349 |
return "and\t%0,%1,%2"; |
| 3350 |
case 9: |
| 3351 |
mips_bit_clear_info (<MODE>mode, INTVAL (operands[2]), &pos, &len); |
| 3352 |
operands[1] = GEN_INT (pos); |
| 3353 |
operands[2] = GEN_INT (len); |
| 3354 |
return "<d>ins\t%0,$0,%1,%2"; |
| 3355 |
default: |
| 3356 |
gcc_unreachable (); |
| 3357 |
} |
| 3358 |
} |
| 3359 |
[(set_attr "move_type" "load,load,load,andi,andi,ext_ins,shift_shift,logical,logical,ext_ins") |
| 3360 |
(set_attr "compression" "*,*,*,micromips,*,*,*,micromips,*,*") |
| 3361 |
(set_attr "mode" "<MODE>")]) |
| 3362 |
|
| 3363 |
(define_insn "*and<mode>3_mips16" |
| 3364 |
[(set (match_operand:GPR 0 "register_operand" "=d,d,d,d,d,d,d,d,d,d") |
| 3365 |
(and:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,W,W,W,d,0,d,0,0?") |
| 3366 |
(match_operand:GPR 2 "and_operand" "Yb,Yh,Yb,Yh,Yw,Yw,d,Yx,Yz,K")))] |
| 3367 |
"TARGET_MIPS16 && and_operands_ok (<MODE>mode, operands[1], operands[2])" |
| 3368 |
{ |
| 3369 |
int len; |
| 3370 |
int pos; |
| 3371 |
|
| 3372 |
switch (which_alternative) |
| 3373 |
{ |
| 3374 |
case 0: |
| 3375 |
return "zeb\t%0"; |
| 3376 |
case 1: |
| 3377 |
return "zeh\t%0"; |
| 3378 |
case 2: |
| 3379 |
operands[1] = gen_lowpart (QImode, operands[1]); |
| 3380 |
return "lbu\t%0,%1"; |
| 3381 |
case 3: |
| 3382 |
operands[1] = gen_lowpart (HImode, operands[1]); |
| 3383 |
return "lhu\t%0,%1"; |
| 3384 |
case 4: |
| 3385 |
operands[1] = gen_lowpart (SImode, operands[1]); |
| 3386 |
return "lwu\t%0,%1"; |
| 3387 |
case 5: |
| 3388 |
return "#"; |
| 3389 |
case 6: |
| 3390 |
return "and\t%0,%2"; |
| 3391 |
case 7: |
| 3392 |
len = low_bitmask_len (<MODE>mode, INTVAL (operands[2])); |
| 3393 |
operands[2] = GEN_INT (len); |
| 3394 |
return "ext\t%0,%1,0,%2"; |
| 3395 |
case 8: |
| 3396 |
mips_bit_clear_info (<MODE>mode, INTVAL (operands[2]), &pos, &len); |
| 3397 |
operands[1] = GEN_INT (pos); |
| 3398 |
operands[2] = GEN_INT (len); |
| 3399 |
return "ins\t%0,$0,%1,%2"; |
| 3400 |
case 9: |
| 3401 |
return "andi\t%0,%x2"; |
| 3402 |
default: |
| 3403 |
gcc_unreachable (); |
| 3404 |
} |
| 3405 |
} |
| 3406 |
[(set_attr "move_type" "andi,andi,load,load,load,shift_shift,logical,ext_ins,ext_ins,andi") |
| 3407 |
(set_attr "mode" "<MODE>") |
| 3408 |
(set_attr "extended_mips16" "no,no,no,no,no,no,no,yes,yes,yes") |
| 3409 |
(set (attr "enabled") |
| 3410 |
(cond [(and (eq_attr "alternative" "9") |
| 3411 |
(not (match_test "ISA_HAS_MIPS16E2"))) |
| 3412 |
(const_string "no") |
| 3413 |
(and (eq_attr "alternative" "0,1") |
| 3414 |
(match_test "!GENERATE_MIPS16E")) |
| 3415 |
(const_string "no")] |
| 3416 |
(const_string "yes")))]) |
| 3417 |
|
| 3418 |
(define_expand "ior<mode>3" |
| 3419 |
[(set (match_operand:GPR 0 "register_operand") |
| 3420 |
(ior:GPR (match_operand:GPR 1 "register_operand") |
| 3421 |
(match_operand:GPR 2 "uns_arith_operand")))] |
| 3422 |
"" |
| 3423 |
{ |
| 3424 |
if (TARGET_MIPS16 && !ISA_HAS_MIPS16E2) |
| 3425 |
operands[2] = force_reg (<MODE>mode, operands[2]); |
| 3426 |
}) |
| 3427 |
|
| 3428 |
(define_insn "*ior<mode>3" |
| 3429 |
[(set (match_operand:GPR 0 "register_operand" "=!u,d,d") |
| 3430 |
(ior:GPR (match_operand:GPR 1 "register_operand" "%0,d,d") |
| 3431 |
(match_operand:GPR 2 "uns_arith_operand" "!u,d,K")))] |
| 3432 |
"!TARGET_MIPS16" |
| 3433 |
"@ |
| 3434 |
or\t%0,%1,%2 |
| 3435 |
or\t%0,%1,%2 |
| 3436 |
ori\t%0,%1,%x2" |
| 3437 |
[(set_attr "alu_type" "or") |
| 3438 |
(set_attr "compression" "micromips,*,*") |
| 3439 |
(set_attr "mode" "<MODE>")]) |
| 3440 |
|
| 3441 |
(define_insn "*iorsi3_mips16_asmacro" |
| 3442 |
[(set (match_operand:SI 0 "register_operand" "=d,d") |
| 3443 |
(ior:SI (match_operand:SI 1 "register_operand" "%0,0") |
| 3444 |
(match_operand:SI 2 "uns_arith_operand" "d,K")))] |
| 3445 |
"ISA_HAS_MIPS16E2" |
| 3446 |
"@ |
| 3447 |
or\t%0,%2 |
| 3448 |
ori\t%0,%x2" |
| 3449 |
[(set_attr "alu_type" "or") |
| 3450 |
(set_attr "mode" "SI") |
| 3451 |
(set_attr "extended_mips16" "*,yes")]) |
| 3452 |
|
| 3453 |
(define_insn "*ior<mode>3_mips16" |
| 3454 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 3455 |
(ior:GPR (match_operand:GPR 1 "register_operand" "%0") |
| 3456 |
(match_operand:GPR 2 "register_operand" "d")))] |
| 3457 |
"TARGET_MIPS16 && !ISA_HAS_MIPS16E2" |
| 3458 |
"or\t%0,%2" |
| 3459 |
[(set_attr "alu_type" "or") |
| 3460 |
(set_attr "mode" "<MODE>")]) |
| 3461 |
|
| 3462 |
(define_expand "xor<mode>3" |
| 3463 |
[(set (match_operand:GPR 0 "register_operand") |
| 3464 |
(xor:GPR (match_operand:GPR 1 "register_operand") |
| 3465 |
(match_operand:GPR 2 "uns_arith_operand")))] |
| 3466 |
"" |
| 3467 |
"") |
| 3468 |
|
| 3469 |
(define_insn "*xor<mode>3" |
| 3470 |
[(set (match_operand:GPR 0 "register_operand" "=!u,d,d") |
| 3471 |
(xor:GPR (match_operand:GPR 1 "register_operand" "%0,d,d") |
| 3472 |
(match_operand:GPR 2 "uns_arith_operand" "!u,d,K")))] |
| 3473 |
"!TARGET_MIPS16" |
| 3474 |
"@ |
| 3475 |
xor\t%0,%1,%2 |
| 3476 |
xor\t%0,%1,%2 |
| 3477 |
xori\t%0,%1,%x2" |
| 3478 |
[(set_attr "alu_type" "xor") |
| 3479 |
(set_attr "compression" "micromips,*,*") |
| 3480 |
(set_attr "mode" "<MODE>")]) |
| 3481 |
|
| 3482 |
;; We increase statically the cost of the output register for XORI |
| 3483 |
;; to counterweight LRA cost calculation as XORI tends to be chosen |
| 3484 |
;; frequently hurting the code size. The reason of not choosing CMPI is |
| 3485 |
;; that LRA tends to add up the cost of the T register as it is in a small |
| 3486 |
;; class and a possible reload. In reality, the use of T register comes for |
| 3487 |
;; free in a number of cases as we don't need any MIPS16 registers. |
| 3488 |
(define_insn "*xor<mode>3_mips16" |
| 3489 |
[(set (match_operand:GPR 0 "register_operand" "=d,t,t,t,d?") |
| 3490 |
(xor:GPR (match_operand:GPR 1 "register_operand" "%0,d,d,d,0") |
| 3491 |
(match_operand:GPR 2 "uns_arith_operand" "d,Uub8,K,d,K")))] |
| 3492 |
"TARGET_MIPS16" |
| 3493 |
"@ |
| 3494 |
xor\t%0,%2 |
| 3495 |
cmpi\t%1,%2 |
| 3496 |
cmpi\t%1,%2 |
| 3497 |
cmp\t%1,%2 |
| 3498 |
xori\t%0,%x2" |
| 3499 |
[(set_attr "alu_type" "xor") |
| 3500 |
(set_attr "mode" "<MODE>") |
| 3501 |
(set_attr "extended_mips16" "no,no,yes,no,yes") |
| 3502 |
(set (attr "enabled") |
| 3503 |
(cond [(and (eq_attr "alternative" "4") |
| 3504 |
(not (match_test "ISA_HAS_MIPS16E2"))) |
| 3505 |
(const_string "no")] |
| 3506 |
(const_string "yes")))]) |
| 3507 |
|
| 3508 |
(define_insn "*nor<mode>3" |
| 3509 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 3510 |
(and:GPR (not:GPR (match_operand:GPR 1 "register_operand" "d")) |
| 3511 |
(not:GPR (match_operand:GPR 2 "register_operand" "d"))))] |
| 3512 |
"!TARGET_MIPS16" |
| 3513 |
"nor\t%0,%1,%2" |
| 3514 |
[(set_attr "alu_type" "nor") |
| 3515 |
(set_attr "mode" "<MODE>")]) |
| 3516 |
|
| 3517 |
;; |
| 3518 |
;; .................... |
| 3519 |
;; |
| 3520 |
;; TRUNCATION |
| 3521 |
;; |
| 3522 |
;; .................... |
| 3523 |
|
| 3524 |
|
| 3525 |
|
| 3526 |
(define_insn "truncdfsf2" |
| 3527 |
[(set (match_operand:SF 0 "register_operand" "=f") |
| 3528 |
(float_truncate:SF (match_operand:DF 1 "register_operand" "f")))] |
| 3529 |
"TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT" |
| 3530 |
"cvt.s.d\t%0,%1" |
| 3531 |
[(set_attr "type" "fcvt") |
| 3532 |
(set_attr "cnv_mode" "D2S") |
| 3533 |
(set_attr "mode" "SF")]) |
| 3534 |
|
| 3535 |
;; Integer truncation patterns. Truncating SImode values to smaller |
| 3536 |
;; modes is a no-op, as it is for most other GCC ports. Truncating |
| 3537 |
;; DImode values to SImode is not a no-op for TARGET_64BIT since we |
| 3538 |
;; need to make sure that the lower 32 bits are properly sign-extended |
| 3539 |
;; (see TARGET_TRULY_NOOP_TRUNCATION). Truncating DImode values into modes |
| 3540 |
;; smaller than SImode is equivalent to two separate truncations: |
| 3541 |
;; |
| 3542 |
;; A B |
| 3543 |
;; DI ---> HI == DI ---> SI ---> HI |
| 3544 |
;; DI ---> QI == DI ---> SI ---> QI |
| 3545 |
;; |
| 3546 |
;; Step A needs a real instruction but step B does not. |
| 3547 |
|
| 3548 |
(define_insn "truncdi<mode>2" |
| 3549 |
[(set (match_operand:SUBDI 0 "nonimmediate_operand" "=d,m") |
| 3550 |
(truncate:SUBDI (match_operand:DI 1 "register_operand" "d,d")))] |
| 3551 |
"TARGET_64BIT" |
| 3552 |
"@ |
| 3553 |
sll\t%0,%1,0 |
| 3554 |
<store>\t%1,%0" |
| 3555 |
[(set_attr "move_type" "sll0,store") |
| 3556 |
(set_attr "mode" "SI")]) |
| 3557 |
|
| 3558 |
;; Combiner patterns to optimize shift/truncate combinations. |
| 3559 |
|
| 3560 |
(define_insn "*ashr_trunc<mode>" |
| 3561 |
[(set (match_operand:SUBDI 0 "register_operand" "=d") |
| 3562 |
(truncate:SUBDI |
| 3563 |
(ashiftrt:DI (match_operand:DI 1 "register_operand" "d") |
| 3564 |
(match_operand:DI 2 "const_arith_operand" ""))))] |
| 3565 |
"TARGET_64BIT && !TARGET_MIPS16 && IN_RANGE (INTVAL (operands[2]), 32, 63)" |
| 3566 |
"dsra\t%0,%1,%2" |
| 3567 |
[(set_attr "type" "shift") |
| 3568 |
(set_attr "mode" "<MODE>")]) |
| 3569 |
|
| 3570 |
(define_insn "*lshr32_trunc<mode>" |
| 3571 |
[(set (match_operand:SUBDI 0 "register_operand" "=d") |
| 3572 |
(truncate:SUBDI |
| 3573 |
(lshiftrt:DI (match_operand:DI 1 "register_operand" "d") |
| 3574 |
(const_int 32))))] |
| 3575 |
"TARGET_64BIT && !TARGET_MIPS16" |
| 3576 |
"dsra\t%0,%1,32" |
| 3577 |
[(set_attr "type" "shift") |
| 3578 |
(set_attr "mode" "<MODE>")]) |
| 3579 |
|
| 3580 |
;; Logical shift by more than 32 results in proper SI values so truncation is |
| 3581 |
;; removed by the middle end. Note that a logical shift by 32 is handled by |
| 3582 |
;; the previous pattern. |
| 3583 |
(define_insn "*<optab>_trunc<mode>_exts" |
| 3584 |
[(set (match_operand:SUBDI 0 "register_operand" "=d") |
| 3585 |
(truncate:SUBDI |
| 3586 |
(any_shiftrt:DI (match_operand:DI 1 "register_operand" "d") |
| 3587 |
(match_operand:DI 2 "const_arith_operand" ""))))] |
| 3588 |
"ISA_HAS_EXTS && TARGET_64BIT && UINTVAL (operands[2]) < 32" |
| 3589 |
"exts\t%0,%1,%2,31" |
| 3590 |
[(set_attr "type" "arith") |
| 3591 |
(set_attr "mode" "<MODE>")]) |
| 3592 |
|
| 3593 |
;; This could likely be generalized for any SUBDI mode, and any right |
| 3594 |
;; shift, but AFAICT this is used so rarely it is not worth the additional |
| 3595 |
;; complexity. |
| 3596 |
(define_insn "" |
| 3597 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 3598 |
(ashiftrt:SI |
| 3599 |
(truncate:SI |
| 3600 |
(ashift:DI (match_operand:DI 1 "register_operand" "d") |
| 3601 |
(match_operand:DI 2 "const_arith_operand" ""))) |
| 3602 |
(match_operand:DI 3 "const_arith_operand" "")))] |
| 3603 |
"(ISA_HAS_EXTS && TARGET_64BIT |
| 3604 |
&& UINTVAL (operands[2]) < 32 && UINTVAL (operands[3]) < 32 |
| 3605 |
&& UINTVAL (operands[3]) >= UINTVAL (operands[2]))" |
| 3606 |
{ |
| 3607 |
rtx xoperands[4]; |
| 3608 |
xoperands[0] = operands[0]; |
| 3609 |
xoperands[1] = operands[1]; |
| 3610 |
|
| 3611 |
/* The length of the field is the size of the outer mode less the outer |
| 3612 |
shift constant. We fix the outer mode as SImode for simplicity. */ |
| 3613 |
unsigned int right_shift = INTVAL (operands[3]); |
| 3614 |
xoperands[3] = GEN_INT (32 - right_shift); |
| 3615 |
|
| 3616 |
/* The field starts at the outer shift constant less the inner shift |
| 3617 |
constant. */ |
| 3618 |
unsigned int left_shift = INTVAL (operands[2]); |
| 3619 |
xoperands[2] = GEN_INT (right_shift - left_shift); |
| 3620 |
|
| 3621 |
/* Sanity checks. These constraints are taken from the MIPS ISA |
| 3622 |
manual. */ |
| 3623 |
gcc_assert (INTVAL (xoperands[2]) >= 0 && INTVAL (xoperands[2]) < 32); |
| 3624 |
gcc_assert (INTVAL (xoperands[3]) > 0 && INTVAL (xoperands[3]) <= 32); |
| 3625 |
gcc_assert (INTVAL (xoperands[2]) + INTVAL (xoperands[3]) > 0 |
| 3626 |
&& INTVAL (xoperands[2]) + INTVAL (xoperands[3]) <= 32); |
| 3627 |
|
| 3628 |
output_asm_insn ("exts\t%0,%1,%2,%m3", xoperands); |
| 3629 |
return ""; |
| 3630 |
} |
| 3631 |
[(set_attr "type" "arith") |
| 3632 |
(set_attr "mode" "SI")]) |
| 3633 |
|
| 3634 |
;; |
| 3635 |
;; .................... |
| 3636 |
;; |
| 3637 |
;; ZERO EXTENSION |
| 3638 |
;; |
| 3639 |
;; .................... |
| 3640 |
|
| 3641 |
;; Extension insns. |
| 3642 |
|
| 3643 |
(define_expand "zero_extendsidi2" |
| 3644 |
[(set (match_operand:DI 0 "register_operand") |
| 3645 |
(zero_extend:DI (match_operand:SI 1 "nonimmediate_operand")))] |
| 3646 |
"TARGET_64BIT") |
| 3647 |
|
| 3648 |
(define_insn_and_split "*zero_extendsidi2" |
| 3649 |
[(set (match_operand:DI 0 "register_operand" "=d,d") |
| 3650 |
(zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,W")))] |
| 3651 |
"TARGET_64BIT && !ISA_HAS_EXT_INS" |
| 3652 |
"@ |
| 3653 |
# |
| 3654 |
lwu\t%0,%1" |
| 3655 |
"&& reload_completed && REG_P (operands[1])" |
| 3656 |
[(set (match_dup 0) |
| 3657 |
(ashift:DI (match_dup 1) (const_int 32))) |
| 3658 |
(set (match_dup 0) |
| 3659 |
(lshiftrt:DI (match_dup 0) (const_int 32)))] |
| 3660 |
{ operands[1] = gen_lowpart (DImode, operands[1]); } |
| 3661 |
[(set_attr "move_type" "shift_shift,load") |
| 3662 |
(set_attr "mode" "DI")]) |
| 3663 |
|
| 3664 |
(define_insn "*zero_extendsidi2_dext" |
| 3665 |
[(set (match_operand:DI 0 "register_operand" "=d,d") |
| 3666 |
(zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,W")))] |
| 3667 |
"TARGET_64BIT && ISA_HAS_EXT_INS" |
| 3668 |
"@ |
| 3669 |
dext\t%0,%1,0,32 |
| 3670 |
lwu\t%0,%1" |
| 3671 |
[(set_attr "move_type" "arith,load") |
| 3672 |
(set_attr "mode" "DI")]) |
| 3673 |
|
| 3674 |
;; See the comment before the *and<mode>3 pattern why this is generated by |
| 3675 |
;; combine. |
| 3676 |
|
| 3677 |
(define_split |
| 3678 |
[(set (match_operand:DI 0 "register_operand") |
| 3679 |
(and:DI (match_operand:DI 1 "register_operand") |
| 3680 |
(const_int 4294967295)))] |
| 3681 |
"TARGET_64BIT && !ISA_HAS_EXT_INS && reload_completed" |
| 3682 |
[(set (match_dup 0) |
| 3683 |
(ashift:DI (match_dup 1) (const_int 32))) |
| 3684 |
(set (match_dup 0) |
| 3685 |
(lshiftrt:DI (match_dup 0) (const_int 32)))]) |
| 3686 |
|
| 3687 |
(define_expand "zero_extend<SHORT:mode><GPR:mode>2" |
| 3688 |
[(set (match_operand:GPR 0 "register_operand") |
| 3689 |
(zero_extend:GPR (match_operand:SHORT 1 "nonimmediate_operand")))] |
| 3690 |
"" |
| 3691 |
{ |
| 3692 |
if (TARGET_MIPS16 && !GENERATE_MIPS16E |
| 3693 |
&& !memory_operand (operands[1], <SHORT:MODE>mode)) |
| 3694 |
{ |
| 3695 |
emit_insn (gen_and<GPR:mode>3 (operands[0], |
| 3696 |
gen_lowpart (<GPR:MODE>mode, operands[1]), |
| 3697 |
force_reg (<GPR:MODE>mode, |
| 3698 |
GEN_INT (<SHORT:mask>)))); |
| 3699 |
DONE; |
| 3700 |
} |
| 3701 |
}) |
| 3702 |
|
| 3703 |
(define_insn "*zero_extend<SHORT:mode><GPR:mode>2" |
| 3704 |
[(set (match_operand:GPR 0 "register_operand" "=!u,d,d") |
| 3705 |
(zero_extend:GPR |
| 3706 |
(match_operand:SHORT 1 "nonimmediate_operand" "!u,d,m")))] |
| 3707 |
"!TARGET_MIPS16" |
| 3708 |
"@ |
| 3709 |
andi\t%0,%1,<SHORT:mask> |
| 3710 |
andi\t%0,%1,<SHORT:mask> |
| 3711 |
l<SHORT:size>u\t%0,%1" |
| 3712 |
[(set_attr "move_type" "andi,andi,load") |
| 3713 |
(set_attr "compression" "micromips,*,*") |
| 3714 |
(set_attr "mode" "<GPR:MODE>")]) |
| 3715 |
|
| 3716 |
(define_insn "*zero_extend<SHORT:mode><GPR:mode>2_mips16e" |
| 3717 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 3718 |
(zero_extend:GPR (match_operand:SHORT 1 "register_operand" "0")))] |
| 3719 |
"GENERATE_MIPS16E" |
| 3720 |
"ze<SHORT:size>\t%0" |
| 3721 |
;; This instruction is effectively a special encoding of ANDI. |
| 3722 |
[(set_attr "move_type" "andi") |
| 3723 |
(set_attr "mode" "<GPR:MODE>")]) |
| 3724 |
|
| 3725 |
(define_insn "*zero_extend<SHORT:mode><GPR:mode>2_mips16" |
| 3726 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 3727 |
(zero_extend:GPR (match_operand:SHORT 1 "memory_operand" "m")))] |
| 3728 |
"TARGET_MIPS16" |
| 3729 |
"l<SHORT:size>u\t%0,%1" |
| 3730 |
[(set_attr "move_type" "load") |
| 3731 |
(set_attr "mode" "<GPR:MODE>")]) |
| 3732 |
|
| 3733 |
(define_expand "zero_extendqihi2" |
| 3734 |
[(set (match_operand:HI 0 "register_operand") |
| 3735 |
(zero_extend:HI (match_operand:QI 1 "nonimmediate_operand")))] |
| 3736 |
"" |
| 3737 |
{ |
| 3738 |
if (TARGET_MIPS16 && !memory_operand (operands[1], QImode)) |
| 3739 |
{ |
| 3740 |
emit_insn (gen_zero_extendqisi2 (gen_lowpart (SImode, operands[0]), |
| 3741 |
operands[1])); |
| 3742 |
DONE; |
| 3743 |
} |
| 3744 |
}) |
| 3745 |
|
| 3746 |
(define_insn "*zero_extendqihi2" |
| 3747 |
[(set (match_operand:HI 0 "register_operand" "=d,d") |
| 3748 |
(zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,m")))] |
| 3749 |
"!TARGET_MIPS16" |
| 3750 |
"@ |
| 3751 |
andi\t%0,%1,0x00ff |
| 3752 |
lbu\t%0,%1" |
| 3753 |
[(set_attr "move_type" "andi,load") |
| 3754 |
(set_attr "mode" "HI")]) |
| 3755 |
|
| 3756 |
(define_insn "*zero_extendqihi2_mips16" |
| 3757 |
[(set (match_operand:HI 0 "register_operand" "=d") |
| 3758 |
(zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))] |
| 3759 |
"TARGET_MIPS16" |
| 3760 |
"lbu\t%0,%1" |
| 3761 |
[(set_attr "move_type" "load") |
| 3762 |
(set_attr "mode" "HI")]) |
| 3763 |
|
| 3764 |
;; Combiner patterns to optimize truncate/zero_extend combinations. |
| 3765 |
|
| 3766 |
(define_insn "*zero_extend<GPR:mode>_trunc<SHORT:mode>" |
| 3767 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 3768 |
(zero_extend:GPR |
| 3769 |
(truncate:SHORT (match_operand:DI 1 "register_operand" "d"))))] |
| 3770 |
"TARGET_64BIT && !TARGET_MIPS16" |
| 3771 |
{ |
| 3772 |
operands[2] = GEN_INT (GET_MODE_MASK (<SHORT:MODE>mode)); |
| 3773 |
return "andi\t%0,%1,%x2"; |
| 3774 |
} |
| 3775 |
[(set_attr "alu_type" "and") |
| 3776 |
(set_attr "mode" "<GPR:MODE>")]) |
| 3777 |
|
| 3778 |
(define_insn "*zero_extendhi_truncqi" |
| 3779 |
[(set (match_operand:HI 0 "register_operand" "=d") |
| 3780 |
(zero_extend:HI |
| 3781 |
(truncate:QI (match_operand:DI 1 "register_operand" "d"))))] |
| 3782 |
"TARGET_64BIT && !TARGET_MIPS16" |
| 3783 |
"andi\t%0,%1,0xff" |
| 3784 |
[(set_attr "alu_type" "and") |
| 3785 |
(set_attr "mode" "HI")]) |
| 3786 |
|
| 3787 |
;; |
| 3788 |
;; .................... |
| 3789 |
;; |
| 3790 |
;; SIGN EXTENSION |
| 3791 |
;; |
| 3792 |
;; .................... |
| 3793 |
|
| 3794 |
;; Extension insns. |
| 3795 |
;; Those for integer source operand are ordered widest source type first. |
| 3796 |
|
| 3797 |
;; When TARGET_64BIT, all SImode integer and accumulator registers |
| 3798 |
;; should already be in sign-extended form (see TARGET_TRULY_NOOP_TRUNCATION |
| 3799 |
;; and truncdisi2). We can therefore get rid of register->register |
| 3800 |
;; instructions if we constrain the source to be in the same register as |
| 3801 |
;; the destination. |
| 3802 |
;; |
| 3803 |
;; Only the pre-reload scheduler sees the type of the register alternatives; |
| 3804 |
;; we split them into nothing before the post-reload scheduler runs. |
| 3805 |
;; These alternatives therefore have type "move" in order to reflect |
| 3806 |
;; what happens if the two pre-reload operands cannot be tied, and are |
| 3807 |
;; instead allocated two separate GPRs. We don't distinguish between |
| 3808 |
;; the GPR and LO cases because we don't usually know during pre-reload |
| 3809 |
;; scheduling whether an operand will be LO or not. |
| 3810 |
(define_insn_and_split "extendsidi2" |
| 3811 |
[(set (match_operand:DI 0 "register_operand" "=d,l,d") |
| 3812 |
(sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "0,0,m")))] |
| 3813 |
"TARGET_64BIT" |
| 3814 |
"@ |
| 3815 |
# |
| 3816 |
# |
| 3817 |
lw\t%0,%1" |
| 3818 |
"&& reload_completed && register_operand (operands[1], VOIDmode)" |
| 3819 |
[(const_int 0)] |
| 3820 |
{ |
| 3821 |
emit_note (NOTE_INSN_DELETED); |
| 3822 |
DONE; |
| 3823 |
} |
| 3824 |
[(set_attr "move_type" "move,move,load") |
| 3825 |
(set_attr "mode" "DI")]) |
| 3826 |
|
| 3827 |
(define_expand "extend<SHORT:mode><GPR:mode>2" |
| 3828 |
[(set (match_operand:GPR 0 "register_operand") |
| 3829 |
(sign_extend:GPR (match_operand:SHORT 1 "nonimmediate_operand")))] |
| 3830 |
"") |
| 3831 |
|
| 3832 |
(define_insn "*extend<SHORT:mode><GPR:mode>2_mips16e" |
| 3833 |
[(set (match_operand:GPR 0 "register_operand" "=d,d") |
| 3834 |
(sign_extend:GPR (match_operand:SHORT 1 "nonimmediate_operand" "0,m")))] |
| 3835 |
"GENERATE_MIPS16E" |
| 3836 |
"@ |
| 3837 |
se<SHORT:size>\t%0 |
| 3838 |
l<SHORT:size>\t%0,%1" |
| 3839 |
[(set_attr "move_type" "signext,load") |
| 3840 |
(set_attr "mode" "<GPR:MODE>")]) |
| 3841 |
|
| 3842 |
(define_insn_and_split "*extend<SHORT:mode><GPR:mode>2" |
| 3843 |
[(set (match_operand:GPR 0 "register_operand" "=d,d") |
| 3844 |
(sign_extend:GPR |
| 3845 |
(match_operand:SHORT 1 "nonimmediate_operand" "d,m")))] |
| 3846 |
"!ISA_HAS_SEB_SEH && !GENERATE_MIPS16E" |
| 3847 |
"@ |
| 3848 |
# |
| 3849 |
l<SHORT:size>\t%0,%1" |
| 3850 |
"&& reload_completed && REG_P (operands[1])" |
| 3851 |
[(set (match_dup 0) (ashift:GPR (match_dup 1) (match_dup 2))) |
| 3852 |
(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))] |
| 3853 |
{ |
| 3854 |
operands[1] = gen_lowpart (<GPR:MODE>mode, operands[1]); |
| 3855 |
operands[2] = GEN_INT (GET_MODE_BITSIZE (<GPR:MODE>mode) |
| 3856 |
- GET_MODE_BITSIZE (<SHORT:MODE>mode)); |
| 3857 |
} |
| 3858 |
[(set_attr "move_type" "shift_shift,load") |
| 3859 |
(set_attr "mode" "<GPR:MODE>")]) |
| 3860 |
|
| 3861 |
(define_insn "*extend<SHORT:mode><GPR:mode>2_se<SHORT:size>" |
| 3862 |
[(set (match_operand:GPR 0 "register_operand" "=d,d") |
| 3863 |
(sign_extend:GPR |
| 3864 |
(match_operand:SHORT 1 "nonimmediate_operand" "d,m")))] |
| 3865 |
"ISA_HAS_SEB_SEH" |
| 3866 |
"@ |
| 3867 |
se<SHORT:size>\t%0,%1 |
| 3868 |
l<SHORT:size>\t%0,%1" |
| 3869 |
[(set_attr "move_type" "signext,load") |
| 3870 |
(set_attr "mode" "<GPR:MODE>")]) |
| 3871 |
|
| 3872 |
(define_expand "extendqihi2" |
| 3873 |
[(set (match_operand:HI 0 "register_operand") |
| 3874 |
(sign_extend:HI (match_operand:QI 1 "nonimmediate_operand")))] |
| 3875 |
"") |
| 3876 |
|
| 3877 |
(define_insn "*extendqihi2_mips16e" |
| 3878 |
[(set (match_operand:HI 0 "register_operand" "=d,d") |
| 3879 |
(sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0,m")))] |
| 3880 |
"GENERATE_MIPS16E" |
| 3881 |
"@ |
| 3882 |
seb\t%0 |
| 3883 |
lb\t%0,%1" |
| 3884 |
[(set_attr "move_type" "signext,load") |
| 3885 |
(set_attr "mode" "SI")]) |
| 3886 |
|
| 3887 |
(define_insn_and_split "*extendqihi2" |
| 3888 |
[(set (match_operand:HI 0 "register_operand" "=d,d") |
| 3889 |
(sign_extend:HI |
| 3890 |
(match_operand:QI 1 "nonimmediate_operand" "d,m")))] |
| 3891 |
"!ISA_HAS_SEB_SEH && !GENERATE_MIPS16E" |
| 3892 |
"@ |
| 3893 |
# |
| 3894 |
lb\t%0,%1" |
| 3895 |
"&& reload_completed && REG_P (operands[1])" |
| 3896 |
[(set (match_dup 0) (ashift:SI (match_dup 1) (match_dup 2))) |
| 3897 |
(set (match_dup 0) (ashiftrt:SI (match_dup 0) (match_dup 2)))] |
| 3898 |
{ |
| 3899 |
operands[0] = gen_lowpart (SImode, operands[0]); |
| 3900 |
operands[1] = gen_lowpart (SImode, operands[1]); |
| 3901 |
operands[2] = GEN_INT (GET_MODE_BITSIZE (SImode) |
| 3902 |
- GET_MODE_BITSIZE (QImode)); |
| 3903 |
} |
| 3904 |
[(set_attr "move_type" "shift_shift,load") |
| 3905 |
(set_attr "mode" "SI")]) |
| 3906 |
|
| 3907 |
(define_insn "*extendqihi2_seb" |
| 3908 |
[(set (match_operand:HI 0 "register_operand" "=d,d") |
| 3909 |
(sign_extend:HI |
| 3910 |
(match_operand:QI 1 "nonimmediate_operand" "d,m")))] |
| 3911 |
"ISA_HAS_SEB_SEH" |
| 3912 |
"@ |
| 3913 |
seb\t%0,%1 |
| 3914 |
lb\t%0,%1" |
| 3915 |
[(set_attr "move_type" "signext,load") |
| 3916 |
(set_attr "mode" "SI")]) |
| 3917 |
|
| 3918 |
;; Combiner patterns for truncate/sign_extend combinations. The SI versions |
| 3919 |
;; use the shift/truncate patterns. |
| 3920 |
|
| 3921 |
(define_insn_and_split "*extenddi_truncate<mode>" |
| 3922 |
[(set (match_operand:DI 0 "register_operand" "=d") |
| 3923 |
(sign_extend:DI |
| 3924 |
(truncate:SHORT (match_operand:DI 1 "register_operand" "d"))))] |
| 3925 |
"TARGET_64BIT && !TARGET_MIPS16 && !ISA_HAS_EXTS" |
| 3926 |
"#" |
| 3927 |
"&& reload_completed" |
| 3928 |
[(set (match_dup 2) |
| 3929 |
(ashift:DI (match_dup 1) |
| 3930 |
(match_dup 3))) |
| 3931 |
(set (match_dup 0) |
| 3932 |
(ashiftrt:DI (match_dup 2) |
| 3933 |
(match_dup 3)))] |
| 3934 |
{ |
| 3935 |
operands[2] = gen_lowpart (DImode, operands[0]); |
| 3936 |
operands[3] = GEN_INT (BITS_PER_WORD - GET_MODE_BITSIZE (<MODE>mode)); |
| 3937 |
} |
| 3938 |
[(set_attr "move_type" "shift_shift") |
| 3939 |
(set_attr "mode" "DI")]) |
| 3940 |
|
| 3941 |
(define_insn_and_split "*extendsi_truncate<mode>" |
| 3942 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 3943 |
(sign_extend:SI |
| 3944 |
(truncate:SHORT (match_operand:DI 1 "register_operand" "d"))))] |
| 3945 |
"TARGET_64BIT && !TARGET_MIPS16 && !ISA_HAS_EXTS" |
| 3946 |
"#" |
| 3947 |
"&& reload_completed" |
| 3948 |
[(set (match_dup 2) |
| 3949 |
(ashift:DI (match_dup 1) |
| 3950 |
(match_dup 3))) |
| 3951 |
(set (match_dup 0) |
| 3952 |
(truncate:SI (ashiftrt:DI (match_dup 2) |
| 3953 |
(match_dup 3))))] |
| 3954 |
{ |
| 3955 |
operands[2] = gen_lowpart (DImode, operands[0]); |
| 3956 |
operands[3] = GEN_INT (BITS_PER_WORD - GET_MODE_BITSIZE (<MODE>mode)); |
| 3957 |
} |
| 3958 |
[(set_attr "move_type" "shift_shift") |
| 3959 |
(set_attr "mode" "SI")]) |
| 3960 |
|
| 3961 |
(define_insn_and_split "*extendhi_truncateqi" |
| 3962 |
[(set (match_operand:HI 0 "register_operand" "=d") |
| 3963 |
(sign_extend:HI |
| 3964 |
(truncate:QI (match_operand:DI 1 "register_operand" "d"))))] |
| 3965 |
"TARGET_64BIT && !TARGET_MIPS16 && !ISA_HAS_EXTS" |
| 3966 |
"#" |
| 3967 |
"&& reload_completed" |
| 3968 |
[(set (match_dup 2) |
| 3969 |
(ashift:DI (match_dup 1) |
| 3970 |
(const_int 56))) |
| 3971 |
(set (match_dup 0) |
| 3972 |
(truncate:HI (ashiftrt:DI (match_dup 2) |
| 3973 |
(const_int 56))))] |
| 3974 |
{ |
| 3975 |
operands[2] = gen_lowpart (DImode, operands[0]); |
| 3976 |
} |
| 3977 |
[(set_attr "move_type" "shift_shift") |
| 3978 |
(set_attr "mode" "SI")]) |
| 3979 |
|
| 3980 |
(define_insn "*extend<GPR:mode>_truncate<SHORT:mode>_exts" |
| 3981 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 3982 |
(sign_extend:GPR |
| 3983 |
(truncate:SHORT (match_operand:DI 1 "register_operand" "d"))))] |
| 3984 |
"TARGET_64BIT && !TARGET_MIPS16 && ISA_HAS_EXTS" |
| 3985 |
{ |
| 3986 |
operands[2] = GEN_INT (GET_MODE_BITSIZE (<SHORT:MODE>mode)); |
| 3987 |
return "exts\t%0,%1,0,%m2"; |
| 3988 |
} |
| 3989 |
[(set_attr "type" "arith") |
| 3990 |
(set_attr "mode" "<GPR:MODE>")]) |
| 3991 |
|
| 3992 |
(define_insn "*extendhi_truncateqi_exts" |
| 3993 |
[(set (match_operand:HI 0 "register_operand" "=d") |
| 3994 |
(sign_extend:HI |
| 3995 |
(truncate:QI (match_operand:DI 1 "register_operand" "d"))))] |
| 3996 |
"TARGET_64BIT && !TARGET_MIPS16 && ISA_HAS_EXTS" |
| 3997 |
"exts\t%0,%1,0,7" |
| 3998 |
[(set_attr "type" "arith") |
| 3999 |
(set_attr "mode" "SI")]) |
| 4000 |
|
| 4001 |
(define_insn "extendsfdf2" |
| 4002 |
[(set (match_operand:DF 0 "register_operand" "=f") |
| 4003 |
(float_extend:DF (match_operand:SF 1 "register_operand" "f")))] |
| 4004 |
"TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT" |
| 4005 |
"cvt.d.s\t%0,%1" |
| 4006 |
[(set_attr "type" "fcvt") |
| 4007 |
(set_attr "cnv_mode" "S2D") |
| 4008 |
(set_attr "mode" "DF")]) |
| 4009 |
|
| 4010 |
;; |
| 4011 |
;; .................... |
| 4012 |
;; |
| 4013 |
;; CONVERSIONS |
| 4014 |
;; |
| 4015 |
;; .................... |
| 4016 |
|
| 4017 |
(define_expand "fix_truncdfsi2" |
| 4018 |
[(set (match_operand:SI 0 "register_operand") |
| 4019 |
(fix:SI (match_operand:DF 1 "register_operand")))] |
| 4020 |
"TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT" |
| 4021 |
{ |
| 4022 |
if (!ISA_HAS_TRUNC_W) |
| 4023 |
{ |
| 4024 |
emit_insn (gen_fix_truncdfsi2_macro (operands[0], operands[1])); |
| 4025 |
DONE; |
| 4026 |
} |
| 4027 |
}) |
| 4028 |
|
| 4029 |
(define_insn "fix_truncdfsi2_insn" |
| 4030 |
[(set (match_operand:SI 0 "register_operand" "=f") |
| 4031 |
(fix:SI (match_operand:DF 1 "register_operand" "f")))] |
| 4032 |
"TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && ISA_HAS_TRUNC_W" |
| 4033 |
"trunc.w.d %0,%1" |
| 4034 |
[(set_attr "type" "fcvt") |
| 4035 |
(set_attr "mode" "DF") |
| 4036 |
(set_attr "cnv_mode" "D2I")]) |
| 4037 |
|
| 4038 |
(define_insn "fix_truncdfsi2_macro" |
| 4039 |
[(set (match_operand:SI 0 "register_operand" "=f") |
| 4040 |
(fix:SI (match_operand:DF 1 "register_operand" "f"))) |
| 4041 |
(clobber (match_scratch:DF 2 "=d"))] |
| 4042 |
"TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && !ISA_HAS_TRUNC_W" |
| 4043 |
{ |
| 4044 |
if (mips_nomacro.nesting_level > 0) |
| 4045 |
return ".set\tmacro\;trunc.w.d %0,%1,%2\;.set\tnomacro"; |
| 4046 |
else |
| 4047 |
return "trunc.w.d %0,%1,%2"; |
| 4048 |
} |
| 4049 |
[(set_attr "type" "fcvt") |
| 4050 |
(set_attr "mode" "DF") |
| 4051 |
(set_attr "cnv_mode" "D2I") |
| 4052 |
(set_attr "insn_count" "9")]) |
| 4053 |
|
| 4054 |
(define_expand "fix_truncsfsi2" |
| 4055 |
[(set (match_operand:SI 0 "register_operand") |
| 4056 |
(fix:SI (match_operand:SF 1 "register_operand")))] |
| 4057 |
"TARGET_HARD_FLOAT" |
| 4058 |
{ |
| 4059 |
if (!ISA_HAS_TRUNC_W) |
| 4060 |
{ |
| 4061 |
emit_insn (gen_fix_truncsfsi2_macro (operands[0], operands[1])); |
| 4062 |
DONE; |
| 4063 |
} |
| 4064 |
}) |
| 4065 |
|
| 4066 |
(define_insn "fix_truncsfsi2_insn" |
| 4067 |
[(set (match_operand:SI 0 "register_operand" "=f") |
| 4068 |
(fix:SI (match_operand:SF 1 "register_operand" "f")))] |
| 4069 |
"TARGET_HARD_FLOAT && ISA_HAS_TRUNC_W" |
| 4070 |
"trunc.w.s %0,%1" |
| 4071 |
[(set_attr "type" "fcvt") |
| 4072 |
(set_attr "mode" "SF") |
| 4073 |
(set_attr "cnv_mode" "S2I")]) |
| 4074 |
|
| 4075 |
(define_insn "fix_truncsfsi2_macro" |
| 4076 |
[(set (match_operand:SI 0 "register_operand" "=f") |
| 4077 |
(fix:SI (match_operand:SF 1 "register_operand" "f"))) |
| 4078 |
(clobber (match_scratch:SF 2 "=d"))] |
| 4079 |
"TARGET_HARD_FLOAT && !ISA_HAS_TRUNC_W" |
| 4080 |
{ |
| 4081 |
if (mips_nomacro.nesting_level > 0) |
| 4082 |
return ".set\tmacro\;trunc.w.s %0,%1,%2\;.set\tnomacro"; |
| 4083 |
else |
| 4084 |
return "trunc.w.s %0,%1,%2"; |
| 4085 |
} |
| 4086 |
[(set_attr "type" "fcvt") |
| 4087 |
(set_attr "mode" "SF") |
| 4088 |
(set_attr "cnv_mode" "S2I") |
| 4089 |
(set_attr "insn_count" "9")]) |
| 4090 |
|
| 4091 |
|
| 4092 |
(define_insn "fix_truncdfdi2" |
| 4093 |
[(set (match_operand:DI 0 "register_operand" "=f") |
| 4094 |
(fix:DI (match_operand:DF 1 "register_operand" "f")))] |
| 4095 |
"TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT" |
| 4096 |
"trunc.l.d %0,%1" |
| 4097 |
[(set_attr "type" "fcvt") |
| 4098 |
(set_attr "mode" "DF") |
| 4099 |
(set_attr "cnv_mode" "D2I")]) |
| 4100 |
|
| 4101 |
|
| 4102 |
(define_insn "fix_truncsfdi2" |
| 4103 |
[(set (match_operand:DI 0 "register_operand" "=f") |
| 4104 |
(fix:DI (match_operand:SF 1 "register_operand" "f")))] |
| 4105 |
"TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT" |
| 4106 |
"trunc.l.s %0,%1" |
| 4107 |
[(set_attr "type" "fcvt") |
| 4108 |
(set_attr "mode" "SF") |
| 4109 |
(set_attr "cnv_mode" "S2I")]) |
| 4110 |
|
| 4111 |
|
| 4112 |
(define_insn "floatsidf2" |
| 4113 |
[(set (match_operand:DF 0 "register_operand" "=f") |
| 4114 |
(float:DF (match_operand:SI 1 "register_operand" "f")))] |
| 4115 |
"TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT" |
| 4116 |
"cvt.d.w\t%0,%1" |
| 4117 |
[(set_attr "type" "fcvt") |
| 4118 |
(set_attr "mode" "DF") |
| 4119 |
(set_attr "cnv_mode" "I2D")]) |
| 4120 |
|
| 4121 |
|
| 4122 |
(define_insn "floatdidf2" |
| 4123 |
[(set (match_operand:DF 0 "register_operand" "=f") |
| 4124 |
(float:DF (match_operand:DI 1 "register_operand" "f")))] |
| 4125 |
"TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT" |
| 4126 |
"cvt.d.l\t%0,%1" |
| 4127 |
[(set_attr "type" "fcvt") |
| 4128 |
(set_attr "mode" "DF") |
| 4129 |
(set_attr "cnv_mode" "I2D")]) |
| 4130 |
|
| 4131 |
|
| 4132 |
(define_insn "floatsisf2" |
| 4133 |
[(set (match_operand:SF 0 "register_operand" "=f") |
| 4134 |
(float:SF (match_operand:SI 1 "register_operand" "f")))] |
| 4135 |
"TARGET_HARD_FLOAT" |
| 4136 |
"cvt.s.w\t%0,%1" |
| 4137 |
[(set_attr "type" "fcvt") |
| 4138 |
(set_attr "mode" "SF") |
| 4139 |
(set_attr "cnv_mode" "I2S")]) |
| 4140 |
|
| 4141 |
|
| 4142 |
(define_insn "floatdisf2" |
| 4143 |
[(set (match_operand:SF 0 "register_operand" "=f") |
| 4144 |
(float:SF (match_operand:DI 1 "register_operand" "f")))] |
| 4145 |
"TARGET_HARD_FLOAT && TARGET_FLOAT64 && TARGET_DOUBLE_FLOAT" |
| 4146 |
"cvt.s.l\t%0,%1" |
| 4147 |
[(set_attr "type" "fcvt") |
| 4148 |
(set_attr "mode" "SF") |
| 4149 |
(set_attr "cnv_mode" "I2S")]) |
| 4150 |
|
| 4151 |
|
| 4152 |
(define_expand "fixuns_truncdfsi2" |
| 4153 |
[(set (match_operand:SI 0 "register_operand") |
| 4154 |
(unsigned_fix:SI (match_operand:DF 1 "register_operand")))] |
| 4155 |
"TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT" |
| 4156 |
{ |
| 4157 |
rtx reg1 = gen_reg_rtx (DFmode); |
| 4158 |
rtx reg2 = gen_reg_rtx (DFmode); |
| 4159 |
rtx reg3 = gen_reg_rtx (SImode); |
| 4160 |
rtx_code_label *label1 = gen_label_rtx (); |
| 4161 |
rtx_code_label *label2 = gen_label_rtx (); |
| 4162 |
rtx test; |
| 4163 |
REAL_VALUE_TYPE offset; |
| 4164 |
|
| 4165 |
real_2expN (&offset, 31, DFmode); |
| 4166 |
|
| 4167 |
if (reg1) /* Turn off complaints about unreached code. */ |
| 4168 |
{ |
| 4169 |
mips_emit_move (reg1, const_double_from_real_value (offset, DFmode)); |
| 4170 |
do_pending_stack_adjust (); |
| 4171 |
|
| 4172 |
test = gen_rtx_GE (VOIDmode, operands[1], reg1); |
| 4173 |
emit_jump_insn (gen_cbranchdf4 (test, operands[1], reg1, label1)); |
| 4174 |
|
| 4175 |
emit_insn (gen_fix_truncdfsi2 (operands[0], operands[1])); |
| 4176 |
emit_jump_insn (gen_rtx_SET (pc_rtx, |
| 4177 |
gen_rtx_LABEL_REF (VOIDmode, label2))); |
| 4178 |
emit_barrier (); |
| 4179 |
|
| 4180 |
emit_label (label1); |
| 4181 |
mips_emit_move (reg2, gen_rtx_MINUS (DFmode, operands[1], reg1)); |
| 4182 |
mips_emit_move (reg3, GEN_INT (trunc_int_for_mode |
| 4183 |
(BITMASK_HIGH, SImode))); |
| 4184 |
|
| 4185 |
emit_insn (gen_fix_truncdfsi2 (operands[0], reg2)); |
| 4186 |
emit_insn (gen_iorsi3 (operands[0], operands[0], reg3)); |
| 4187 |
|
| 4188 |
emit_label (label2); |
| 4189 |
|
| 4190 |
/* Allow REG_NOTES to be set on last insn (labels don't have enough |
| 4191 |
fields, and can't be used for REG_NOTES anyway). */ |
| 4192 |
emit_use (stack_pointer_rtx); |
| 4193 |
DONE; |
| 4194 |
} |
| 4195 |
}) |
| 4196 |
|
| 4197 |
|
| 4198 |
(define_expand "fixuns_truncdfdi2" |
| 4199 |
[(set (match_operand:DI 0 "register_operand") |
| 4200 |
(unsigned_fix:DI (match_operand:DF 1 "register_operand")))] |
| 4201 |
"TARGET_HARD_FLOAT && TARGET_64BIT && TARGET_DOUBLE_FLOAT" |
| 4202 |
{ |
| 4203 |
rtx reg1 = gen_reg_rtx (DFmode); |
| 4204 |
rtx reg2 = gen_reg_rtx (DFmode); |
| 4205 |
rtx reg3 = gen_reg_rtx (DImode); |
| 4206 |
rtx_code_label *label1 = gen_label_rtx (); |
| 4207 |
rtx_code_label *label2 = gen_label_rtx (); |
| 4208 |
rtx test; |
| 4209 |
REAL_VALUE_TYPE offset; |
| 4210 |
|
| 4211 |
real_2expN (&offset, 63, DFmode); |
| 4212 |
|
| 4213 |
mips_emit_move (reg1, const_double_from_real_value (offset, DFmode)); |
| 4214 |
do_pending_stack_adjust (); |
| 4215 |
|
| 4216 |
test = gen_rtx_GE (VOIDmode, operands[1], reg1); |
| 4217 |
emit_jump_insn (gen_cbranchdf4 (test, operands[1], reg1, label1)); |
| 4218 |
|
| 4219 |
emit_insn (gen_fix_truncdfdi2 (operands[0], operands[1])); |
| 4220 |
emit_jump_insn (gen_rtx_SET (pc_rtx, gen_rtx_LABEL_REF (VOIDmode, label2))); |
| 4221 |
emit_barrier (); |
| 4222 |
|
| 4223 |
emit_label (label1); |
| 4224 |
mips_emit_move (reg2, gen_rtx_MINUS (DFmode, operands[1], reg1)); |
| 4225 |
mips_emit_move (reg3, GEN_INT (BITMASK_HIGH)); |
| 4226 |
emit_insn (gen_ashldi3 (reg3, reg3, GEN_INT (32))); |
| 4227 |
|
| 4228 |
emit_insn (gen_fix_truncdfdi2 (operands[0], reg2)); |
| 4229 |
emit_insn (gen_iordi3 (operands[0], operands[0], reg3)); |
| 4230 |
|
| 4231 |
emit_label (label2); |
| 4232 |
|
| 4233 |
/* Allow REG_NOTES to be set on last insn (labels don't have enough |
| 4234 |
fields, and can't be used for REG_NOTES anyway). */ |
| 4235 |
emit_use (stack_pointer_rtx); |
| 4236 |
DONE; |
| 4237 |
}) |
| 4238 |
|
| 4239 |
|
| 4240 |
(define_expand "fixuns_truncsfsi2" |
| 4241 |
[(set (match_operand:SI 0 "register_operand") |
| 4242 |
(unsigned_fix:SI (match_operand:SF 1 "register_operand")))] |
| 4243 |
"TARGET_HARD_FLOAT" |
| 4244 |
{ |
| 4245 |
rtx reg1 = gen_reg_rtx (SFmode); |
| 4246 |
rtx reg2 = gen_reg_rtx (SFmode); |
| 4247 |
rtx reg3 = gen_reg_rtx (SImode); |
| 4248 |
rtx_code_label *label1 = gen_label_rtx (); |
| 4249 |
rtx_code_label *label2 = gen_label_rtx (); |
| 4250 |
rtx test; |
| 4251 |
REAL_VALUE_TYPE offset; |
| 4252 |
|
| 4253 |
real_2expN (&offset, 31, SFmode); |
| 4254 |
|
| 4255 |
mips_emit_move (reg1, const_double_from_real_value (offset, SFmode)); |
| 4256 |
do_pending_stack_adjust (); |
| 4257 |
|
| 4258 |
test = gen_rtx_GE (VOIDmode, operands[1], reg1); |
| 4259 |
emit_jump_insn (gen_cbranchsf4 (test, operands[1], reg1, label1)); |
| 4260 |
|
| 4261 |
emit_insn (gen_fix_truncsfsi2 (operands[0], operands[1])); |
| 4262 |
emit_jump_insn (gen_rtx_SET (pc_rtx, gen_rtx_LABEL_REF (VOIDmode, label2))); |
| 4263 |
emit_barrier (); |
| 4264 |
|
| 4265 |
emit_label (label1); |
| 4266 |
mips_emit_move (reg2, gen_rtx_MINUS (SFmode, operands[1], reg1)); |
| 4267 |
mips_emit_move (reg3, GEN_INT (trunc_int_for_mode |
| 4268 |
(BITMASK_HIGH, SImode))); |
| 4269 |
|
| 4270 |
emit_insn (gen_fix_truncsfsi2 (operands[0], reg2)); |
| 4271 |
emit_insn (gen_iorsi3 (operands[0], operands[0], reg3)); |
| 4272 |
|
| 4273 |
emit_label (label2); |
| 4274 |
|
| 4275 |
/* Allow REG_NOTES to be set on last insn (labels don't have enough |
| 4276 |
fields, and can't be used for REG_NOTES anyway). */ |
| 4277 |
emit_use (stack_pointer_rtx); |
| 4278 |
DONE; |
| 4279 |
}) |
| 4280 |
|
| 4281 |
|
| 4282 |
(define_expand "fixuns_truncsfdi2" |
| 4283 |
[(set (match_operand:DI 0 "register_operand") |
| 4284 |
(unsigned_fix:DI (match_operand:SF 1 "register_operand")))] |
| 4285 |
"TARGET_HARD_FLOAT && TARGET_64BIT && TARGET_DOUBLE_FLOAT" |
| 4286 |
{ |
| 4287 |
rtx reg1 = gen_reg_rtx (SFmode); |
| 4288 |
rtx reg2 = gen_reg_rtx (SFmode); |
| 4289 |
rtx reg3 = gen_reg_rtx (DImode); |
| 4290 |
rtx_code_label *label1 = gen_label_rtx (); |
| 4291 |
rtx_code_label *label2 = gen_label_rtx (); |
| 4292 |
rtx test; |
| 4293 |
REAL_VALUE_TYPE offset; |
| 4294 |
|
| 4295 |
real_2expN (&offset, 63, SFmode); |
| 4296 |
|
| 4297 |
mips_emit_move (reg1, const_double_from_real_value (offset, SFmode)); |
| 4298 |
do_pending_stack_adjust (); |
| 4299 |
|
| 4300 |
test = gen_rtx_GE (VOIDmode, operands[1], reg1); |
| 4301 |
emit_jump_insn (gen_cbranchsf4 (test, operands[1], reg1, label1)); |
| 4302 |
|
| 4303 |
emit_insn (gen_fix_truncsfdi2 (operands[0], operands[1])); |
| 4304 |
emit_jump_insn (gen_rtx_SET (pc_rtx, gen_rtx_LABEL_REF (VOIDmode, label2))); |
| 4305 |
emit_barrier (); |
| 4306 |
|
| 4307 |
emit_label (label1); |
| 4308 |
mips_emit_move (reg2, gen_rtx_MINUS (SFmode, operands[1], reg1)); |
| 4309 |
mips_emit_move (reg3, GEN_INT (BITMASK_HIGH)); |
| 4310 |
emit_insn (gen_ashldi3 (reg3, reg3, GEN_INT (32))); |
| 4311 |
|
| 4312 |
emit_insn (gen_fix_truncsfdi2 (operands[0], reg2)); |
| 4313 |
emit_insn (gen_iordi3 (operands[0], operands[0], reg3)); |
| 4314 |
|
| 4315 |
emit_label (label2); |
| 4316 |
|
| 4317 |
/* Allow REG_NOTES to be set on last insn (labels don't have enough |
| 4318 |
fields, and can't be used for REG_NOTES anyway). */ |
| 4319 |
emit_use (stack_pointer_rtx); |
| 4320 |
DONE; |
| 4321 |
}) |
| 4322 |
|
| 4323 |
;; |
| 4324 |
;; .................... |
| 4325 |
;; |
| 4326 |
;; DATA MOVEMENT |
| 4327 |
;; |
| 4328 |
;; .................... |
| 4329 |
|
| 4330 |
;; Bit field extract patterns which use lwl/lwr or ldl/ldr. |
| 4331 |
|
| 4332 |
(define_expand "extvmisalign<mode>" |
| 4333 |
[(set (match_operand:GPR 0 "register_operand") |
| 4334 |
(sign_extract:GPR (match_operand:BLK 1 "memory_operand") |
| 4335 |
(match_operand 2 "const_int_operand") |
| 4336 |
(match_operand 3 "const_int_operand")))] |
| 4337 |
"ISA_HAS_LWL_LWR" |
| 4338 |
{ |
| 4339 |
if (mips_expand_ext_as_unaligned_load (operands[0], operands[1], |
| 4340 |
INTVAL (operands[2]), |
| 4341 |
INTVAL (operands[3]), |
| 4342 |
/*unsigned=*/ false)) |
| 4343 |
DONE; |
| 4344 |
else |
| 4345 |
FAIL; |
| 4346 |
}) |
| 4347 |
|
| 4348 |
(define_expand "extv<mode>" |
| 4349 |
[(set (match_operand:GPR 0 "register_operand") |
| 4350 |
(sign_extract:GPR (match_operand:GPR 1 "register_operand") |
| 4351 |
(match_operand 2 "const_int_operand") |
| 4352 |
(match_operand 3 "const_int_operand")))] |
| 4353 |
"ISA_HAS_EXTS" |
| 4354 |
{ |
| 4355 |
if (UINTVAL (operands[2]) > 32) |
| 4356 |
FAIL; |
| 4357 |
}) |
| 4358 |
|
| 4359 |
(define_insn "*extv<mode>" |
| 4360 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 4361 |
(sign_extract:GPR (match_operand:GPR 1 "register_operand" "d") |
| 4362 |
(match_operand 2 "const_int_operand" "") |
| 4363 |
(match_operand 3 "const_int_operand" "")))] |
| 4364 |
"ISA_HAS_EXTS && UINTVAL (operands[2]) <= 32" |
| 4365 |
"exts\t%0,%1,%3,%m2" |
| 4366 |
[(set_attr "type" "arith") |
| 4367 |
(set_attr "mode" "<MODE>")]) |
| 4368 |
|
| 4369 |
(define_expand "extzvmisalign<mode>" |
| 4370 |
[(set (match_operand:GPR 0 "register_operand") |
| 4371 |
(zero_extract:GPR (match_operand:BLK 1 "memory_operand") |
| 4372 |
(match_operand 2 "const_int_operand") |
| 4373 |
(match_operand 3 "const_int_operand")))] |
| 4374 |
"ISA_HAS_LWL_LWR" |
| 4375 |
{ |
| 4376 |
if (mips_expand_ext_as_unaligned_load (operands[0], operands[1], |
| 4377 |
INTVAL (operands[2]), |
| 4378 |
INTVAL (operands[3]), |
| 4379 |
/*unsigned=*/ true)) |
| 4380 |
DONE; |
| 4381 |
else |
| 4382 |
FAIL; |
| 4383 |
}) |
| 4384 |
|
| 4385 |
(define_expand "extzv<mode>" |
| 4386 |
[(set (match_operand:GPR 0 "register_operand") |
| 4387 |
(zero_extract:GPR (match_operand:GPR 1 "register_operand") |
| 4388 |
(match_operand 2 "const_int_operand") |
| 4389 |
(match_operand 3 "const_int_operand")))] |
| 4390 |
"" |
| 4391 |
{ |
| 4392 |
if (!mips_use_ins_ext_p (operands[1], INTVAL (operands[2]), |
| 4393 |
INTVAL (operands[3]))) |
| 4394 |
FAIL; |
| 4395 |
}) |
| 4396 |
|
| 4397 |
(define_insn "*extzv<mode>" |
| 4398 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 4399 |
(zero_extract:GPR (match_operand:GPR 1 "register_operand" "d") |
| 4400 |
(match_operand 2 "const_int_operand" "") |
| 4401 |
(match_operand 3 "const_int_operand" "")))] |
| 4402 |
"mips_use_ins_ext_p (operands[1], INTVAL (operands[2]), |
| 4403 |
INTVAL (operands[3]))" |
| 4404 |
"<d>ext\t%0,%1,%3,%2" |
| 4405 |
[(set_attr "type" "arith") |
| 4406 |
(set_attr "extended_mips16" "yes") |
| 4407 |
(set_attr "mode" "<MODE>")]) |
| 4408 |
|
| 4409 |
(define_insn "*extzv_truncsi_exts" |
| 4410 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 4411 |
(truncate:SI |
| 4412 |
(zero_extract:DI (match_operand:DI 1 "register_operand" "d") |
| 4413 |
(match_operand 2 "const_int_operand" "") |
| 4414 |
(match_operand 3 "const_int_operand" ""))))] |
| 4415 |
"ISA_HAS_EXTS && TARGET_64BIT && IN_RANGE (INTVAL (operands[2]), 32, 63)" |
| 4416 |
"exts\t%0,%1,%3,31" |
| 4417 |
[(set_attr "type" "arith") |
| 4418 |
(set_attr "mode" "SI")]) |
| 4419 |
|
| 4420 |
(define_insn "*insqisi_extended" |
| 4421 |
[(set (match_operand:DI 0 "register_operand" "=d") |
| 4422 |
(sign_extend:DI |
| 4423 |
(ior:SI (and:SI (subreg:SI (match_dup 0) 0) |
| 4424 |
(const_int 16777215)) |
| 4425 |
(ashift:SI |
| 4426 |
(subreg:SI (match_operand:QI 1 "register_operand" "d") 0) |
| 4427 |
(const_int 24)))))] |
| 4428 |
"TARGET_64BIT && !TARGET_MIPS16 && ISA_HAS_EXT_INS" |
| 4429 |
"ins\t%0,%1,24,8" |
| 4430 |
[(set_attr "mode" "SI") |
| 4431 |
(set_attr "perf_ratio" "1")]) |
| 4432 |
|
| 4433 |
(define_insn "*inshisi_extended" |
| 4434 |
[(set (match_operand:DI 0 "register_operand" "=d") |
| 4435 |
(sign_extend:DI |
| 4436 |
(ior:SI |
| 4437 |
(ashift:SI (subreg:SI (match_operand:HI 1 "register_operand" "d") 0) |
| 4438 |
(const_int 16)) |
| 4439 |
(zero_extend:SI (subreg:HI (match_dup 0) 0)))))] |
| 4440 |
"TARGET_64BIT && !TARGET_MIPS16 && ISA_HAS_EXT_INS" |
| 4441 |
"ins\t%0,%1,16,16" |
| 4442 |
[(set_attr "mode" "SI") |
| 4443 |
(set_attr "perf_ratio" "1")]) |
| 4444 |
|
| 4445 |
(define_expand "insvmisalign<mode>" |
| 4446 |
[(set (zero_extract:GPR (match_operand:BLK 0 "memory_operand") |
| 4447 |
(match_operand 1 "const_int_operand") |
| 4448 |
(match_operand 2 "const_int_operand")) |
| 4449 |
(match_operand:GPR 3 "reg_or_0_operand"))] |
| 4450 |
"ISA_HAS_LWL_LWR" |
| 4451 |
{ |
| 4452 |
if (mips_expand_ins_as_unaligned_store (operands[0], operands[3], |
| 4453 |
INTVAL (operands[1]), |
| 4454 |
INTVAL (operands[2]))) |
| 4455 |
DONE; |
| 4456 |
else |
| 4457 |
FAIL; |
| 4458 |
}) |
| 4459 |
|
| 4460 |
(define_expand "insv<mode>" |
| 4461 |
[(set (zero_extract:GPR (match_operand:GPR 0 "register_operand") |
| 4462 |
(match_operand 1 "const_int_operand") |
| 4463 |
(match_operand 2 "const_int_operand")) |
| 4464 |
(match_operand:GPR 3 "reg_or_0_operand"))] |
| 4465 |
"" |
| 4466 |
{ |
| 4467 |
if (!mips_use_ins_ext_p (operands[0], INTVAL (operands[1]), |
| 4468 |
INTVAL (operands[2]))) |
| 4469 |
FAIL; |
| 4470 |
}) |
| 4471 |
|
| 4472 |
(define_insn "*insv<mode>" |
| 4473 |
[(set (zero_extract:GPR (match_operand:GPR 0 "register_operand" "+d") |
| 4474 |
(match_operand:SI 1 "const_int_operand" "") |
| 4475 |
(match_operand:SI 2 "const_int_operand" "")) |
| 4476 |
(match_operand:GPR 3 "reg_or_0_operand" "dJ"))] |
| 4477 |
"mips_use_ins_ext_p (operands[0], INTVAL (operands[1]), |
| 4478 |
INTVAL (operands[2]))" |
| 4479 |
"<d>ins\t%0,%z3,%2,%1" |
| 4480 |
[(set_attr "type" "arith") |
| 4481 |
(set_attr "extended_mips16" "yes") |
| 4482 |
(set_attr "mode" "<MODE>")]) |
| 4483 |
|
| 4484 |
;; Combiner pattern for cins (clear and insert bit field). We can |
| 4485 |
;; implement mask-and-shift-left operation with this. Note that if |
| 4486 |
;; the upper bit of the mask is set in an SImode operation, the mask |
| 4487 |
;; itself will be sign-extended. mask_low_and_shift_len will |
| 4488 |
;; therefore be greater than our threshold of 32. |
| 4489 |
|
| 4490 |
(define_insn "*cins<mode>" |
| 4491 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 4492 |
(and:GPR |
| 4493 |
(ashift:GPR (match_operand:GPR 1 "register_operand" "d") |
| 4494 |
(match_operand:GPR 2 "const_int_operand" "")) |
| 4495 |
(match_operand:GPR 3 "const_int_operand" "")))] |
| 4496 |
"ISA_HAS_CINS |
| 4497 |
&& mask_low_and_shift_p (<MODE>mode, operands[3], operands[2], 32)" |
| 4498 |
{ |
| 4499 |
operands[3] = |
| 4500 |
GEN_INT (mask_low_and_shift_len (<MODE>mode, operands[3], operands[2])); |
| 4501 |
return "cins\t%0,%1,%2,%m3"; |
| 4502 |
} |
| 4503 |
[(set_attr "type" "shift") |
| 4504 |
(set_attr "mode" "<MODE>")]) |
| 4505 |
|
| 4506 |
;; Unaligned word moves generated by the bit field patterns. |
| 4507 |
;; |
| 4508 |
;; As far as the rtl is concerned, both the left-part and right-part |
| 4509 |
;; instructions can access the whole field. However, the real operand |
| 4510 |
;; refers to just the first or the last byte (depending on endianness). |
| 4511 |
;; We therefore use two memory operands to each instruction, one to |
| 4512 |
;; describe the rtl effect and one to use in the assembly output. |
| 4513 |
;; |
| 4514 |
;; Operands 0 and 1 are the rtl-level target and source respectively. |
| 4515 |
;; This allows us to use the standard length calculations for the "load" |
| 4516 |
;; and "store" type attributes. |
| 4517 |
|
| 4518 |
(define_insn "mov_<load>l" |
| 4519 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 4520 |
(unspec:GPR [(match_operand:BLK 1 "memory_operand" "m") |
| 4521 |
(match_operand:QI 2 "memory_operand" "ZC")] |
| 4522 |
UNSPEC_LOAD_LEFT))] |
| 4523 |
"(!TARGET_MIPS16 || ISA_HAS_MIPS16E2) |
| 4524 |
&& mips_mem_fits_mode_p (<MODE>mode, operands[1])" |
| 4525 |
"<load>l\t%0,%2" |
| 4526 |
[(set_attr "move_type" "load") |
| 4527 |
(set_attr "mode" "<MODE>") |
| 4528 |
(set_attr "extended_mips16" "yes")]) |
| 4529 |
|
| 4530 |
(define_insn "mov_<load>r" |
| 4531 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 4532 |
(unspec:GPR [(match_operand:BLK 1 "memory_operand" "m") |
| 4533 |
(match_operand:QI 2 "memory_operand" "ZC") |
| 4534 |
(match_operand:GPR 3 "register_operand" "0")] |
| 4535 |
UNSPEC_LOAD_RIGHT))] |
| 4536 |
"(!TARGET_MIPS16 || ISA_HAS_MIPS16E2) |
| 4537 |
&& mips_mem_fits_mode_p (<MODE>mode, operands[1])" |
| 4538 |
"<load>r\t%0,%2" |
| 4539 |
[(set_attr "move_type" "load") |
| 4540 |
(set_attr "mode" "<MODE>") |
| 4541 |
(set_attr "extended_mips16" "yes")]) |
| 4542 |
|
| 4543 |
(define_insn "mov_<store>l" |
| 4544 |
[(set (match_operand:BLK 0 "memory_operand" "=m") |
| 4545 |
(unspec:BLK [(match_operand:GPR 1 "reg_or_0_operand" "dJ") |
| 4546 |
(match_operand:QI 2 "memory_operand" "ZC")] |
| 4547 |
UNSPEC_STORE_LEFT))] |
| 4548 |
"!TARGET_MIPS16 |
| 4549 |
&& mips_mem_fits_mode_p (<MODE>mode, operands[0])" |
| 4550 |
"<store>l\t%z1,%2" |
| 4551 |
[(set_attr "move_type" "store") |
| 4552 |
(set_attr "mode" "<MODE>")]) |
| 4553 |
|
| 4554 |
(define_insn "mov_<store>r" |
| 4555 |
[(set (match_operand:BLK 0 "memory_operand" "+m") |
| 4556 |
(unspec:BLK [(match_operand:GPR 1 "reg_or_0_operand" "dJ") |
| 4557 |
(match_operand:QI 2 "memory_operand" "ZC") |
| 4558 |
(match_dup 0)] |
| 4559 |
UNSPEC_STORE_RIGHT))] |
| 4560 |
"!TARGET_MIPS16 |
| 4561 |
&& mips_mem_fits_mode_p (<MODE>mode, operands[0])" |
| 4562 |
"<store>r\t%z1,%2" |
| 4563 |
[(set_attr "move_type" "store") |
| 4564 |
(set_attr "mode" "<MODE>")]) |
| 4565 |
|
| 4566 |
(define_insn "mov_<store>l_mips16e2" |
| 4567 |
[(set (match_operand:BLK 0 "memory_operand" "=m") |
| 4568 |
(unspec:BLK [(match_operand:GPR 1 "register_operand" "d") |
| 4569 |
(match_operand:QI 2 "memory_operand" "ZC")] |
| 4570 |
UNSPEC_STORE_LEFT))] |
| 4571 |
"TARGET_MIPS16 && ISA_HAS_MIPS16E2 |
| 4572 |
&& mips_mem_fits_mode_p (<MODE>mode, operands[0])" |
| 4573 |
"<store>l\t%1,%2" |
| 4574 |
[(set_attr "move_type" "store") |
| 4575 |
(set_attr "mode" "<MODE>") |
| 4576 |
(set_attr "extended_mips16" "yes")]) |
| 4577 |
|
| 4578 |
(define_insn "mov_<store>r_mips16e2" |
| 4579 |
[(set (match_operand:BLK 0 "memory_operand" "+m") |
| 4580 |
(unspec:BLK [(match_operand:GPR 1 "register_operand" "d") |
| 4581 |
(match_operand:QI 2 "memory_operand" "ZC") |
| 4582 |
(match_dup 0)] |
| 4583 |
UNSPEC_STORE_RIGHT))] |
| 4584 |
"TARGET_MIPS16 && ISA_HAS_MIPS16E2 |
| 4585 |
&& mips_mem_fits_mode_p (<MODE>mode, operands[0])" |
| 4586 |
"<store>r\t%1,%2" |
| 4587 |
[(set_attr "move_type" "store") |
| 4588 |
(set_attr "mode" "<MODE>") |
| 4589 |
(set_attr "extended_mips16" "yes")]) |
| 4590 |
|
| 4591 |
;; Unaligned direct access |
| 4592 |
(define_expand "movmisalign<mode>" |
| 4593 |
[(set (match_operand:JOIN_MODE 0) |
| 4594 |
(match_operand:JOIN_MODE 1))] |
| 4595 |
"ISA_HAS_UNALIGNED_ACCESS" |
| 4596 |
{ |
| 4597 |
if (mips_legitimize_move (<MODE>mode, operands[0], operands[1])) |
| 4598 |
DONE; |
| 4599 |
}) |
| 4600 |
|
| 4601 |
;; An instruction to calculate the high part of a 64-bit SYMBOL_ABSOLUTE. |
| 4602 |
;; The required value is: |
| 4603 |
;; |
| 4604 |
;; (%highest(op1) << 48) + (%higher(op1) << 32) + (%hi(op1) << 16) |
| 4605 |
;; |
| 4606 |
;; which translates to: |
| 4607 |
;; |
| 4608 |
;; lui op0,%highest(op1) |
| 4609 |
;; daddiu op0,op0,%higher(op1) |
| 4610 |
;; dsll op0,op0,16 |
| 4611 |
;; daddiu op0,op0,%hi(op1) |
| 4612 |
;; dsll op0,op0,16 |
| 4613 |
;; |
| 4614 |
;; The split is deferred until after flow2 to allow the peephole2 below |
| 4615 |
;; to take effect. |
| 4616 |
(define_insn_and_split "*lea_high64" |
| 4617 |
[(set (match_operand:DI 0 "register_operand" "=d") |
| 4618 |
(high:DI (match_operand:DI 1 "absolute_symbolic_operand" "")))] |
| 4619 |
"TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS" |
| 4620 |
"#" |
| 4621 |
"&& epilogue_completed" |
| 4622 |
[(set (match_dup 0) (high:DI (match_dup 2))) |
| 4623 |
(set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 2))) |
| 4624 |
(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 16))) |
| 4625 |
(set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 3))) |
| 4626 |
(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 16)))] |
| 4627 |
{ |
| 4628 |
operands[2] = mips_unspec_address (operands[1], SYMBOL_64_HIGH); |
| 4629 |
operands[3] = mips_unspec_address (operands[1], SYMBOL_64_MID); |
| 4630 |
} |
| 4631 |
[(set_attr "insn_count" "5")]) |
| 4632 |
|
| 4633 |
;; Use a scratch register to reduce the latency of the above pattern |
| 4634 |
;; on superscalar machines. The optimized sequence is: |
| 4635 |
;; |
| 4636 |
;; lui op1,%highest(op2) |
| 4637 |
;; lui op0,%hi(op2) |
| 4638 |
;; daddiu op1,op1,%higher(op2) |
| 4639 |
;; dsll32 op1,op1,0 |
| 4640 |
;; daddu op1,op1,op0 |
| 4641 |
(define_peephole2 |
| 4642 |
[(set (match_operand:DI 1 "d_operand") |
| 4643 |
(high:DI (match_operand:DI 2 "absolute_symbolic_operand"))) |
| 4644 |
(match_scratch:DI 0 "d")] |
| 4645 |
"TARGET_EXPLICIT_RELOCS && ABI_HAS_64BIT_SYMBOLS" |
| 4646 |
[(set (match_dup 1) (high:DI (match_dup 3))) |
| 4647 |
(set (match_dup 0) (high:DI (match_dup 4))) |
| 4648 |
(set (match_dup 1) (lo_sum:DI (match_dup 1) (match_dup 3))) |
| 4649 |
(set (match_dup 1) (ashift:DI (match_dup 1) (const_int 32))) |
| 4650 |
(set (match_dup 1) (plus:DI (match_dup 1) (match_dup 0)))] |
| 4651 |
{ |
| 4652 |
operands[3] = mips_unspec_address (operands[2], SYMBOL_64_HIGH); |
| 4653 |
operands[4] = mips_unspec_address (operands[2], SYMBOL_64_LOW); |
| 4654 |
}) |
| 4655 |
|
| 4656 |
;; On most targets, the expansion of (lo_sum (high X) X) for a 64-bit |
| 4657 |
;; SYMBOL_ABSOLUTE X will take 6 cycles. This next pattern allows combine |
| 4658 |
;; to merge the HIGH and LO_SUM parts of a move if the HIGH part is only |
| 4659 |
;; used once. We can then use the sequence: |
| 4660 |
;; |
| 4661 |
;; lui op0,%highest(op1) |
| 4662 |
;; lui op2,%hi(op1) |
| 4663 |
;; daddiu op0,op0,%higher(op1) |
| 4664 |
;; daddiu op2,op2,%lo(op1) |
| 4665 |
;; dsll32 op0,op0,0 |
| 4666 |
;; daddu op0,op0,op2 |
| 4667 |
;; |
| 4668 |
;; which takes 4 cycles on most superscalar targets. |
| 4669 |
(define_insn_and_split "*lea64" |
| 4670 |
[(set (match_operand:DI 0 "register_operand" "=d") |
| 4671 |
(match_operand:DI 1 "absolute_symbolic_operand" "")) |
| 4672 |
(clobber (match_scratch:DI 2 "=&d"))] |
| 4673 |
"!TARGET_MIPS16 |
| 4674 |
&& TARGET_EXPLICIT_RELOCS |
| 4675 |
&& ABI_HAS_64BIT_SYMBOLS |
| 4676 |
&& cse_not_expected" |
| 4677 |
"#" |
| 4678 |
"&& reload_completed" |
| 4679 |
[(set (match_dup 0) (high:DI (match_dup 3))) |
| 4680 |
(set (match_dup 2) (high:DI (match_dup 4))) |
| 4681 |
(set (match_dup 0) (lo_sum:DI (match_dup 0) (match_dup 3))) |
| 4682 |
(set (match_dup 2) (lo_sum:DI (match_dup 2) (match_dup 4))) |
| 4683 |
(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32))) |
| 4684 |
(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))] |
| 4685 |
{ |
| 4686 |
operands[3] = mips_unspec_address (operands[1], SYMBOL_64_HIGH); |
| 4687 |
operands[4] = mips_unspec_address (operands[1], SYMBOL_64_LOW); |
| 4688 |
} |
| 4689 |
[(set_attr "insn_count" "6")]) |
| 4690 |
|
| 4691 |
;; Split HIGHs into: |
| 4692 |
;; |
| 4693 |
;; li op0,%hi(sym) |
| 4694 |
;; sll op0,16 |
| 4695 |
;; |
| 4696 |
;; on MIPS16 targets. |
| 4697 |
(define_split |
| 4698 |
[(set (match_operand:P 0 "d_operand") |
| 4699 |
(high:P (match_operand:P 1 "symbolic_operand_with_high")))] |
| 4700 |
"TARGET_MIPS16 && reload_completed && !ISA_HAS_MIPS16E2" |
| 4701 |
[(set (match_dup 0) (unspec:P [(match_dup 1)] UNSPEC_UNSHIFTED_HIGH)) |
| 4702 |
(set (match_dup 0) (ashift:P (match_dup 0) (const_int 16)))]) |
| 4703 |
|
| 4704 |
(define_insn "*unshifted_high" |
| 4705 |
[(set (match_operand:P 0 "d_operand" "=d") |
| 4706 |
(unspec:P [(match_operand:P 1 "symbolic_operand_with_high")] |
| 4707 |
UNSPEC_UNSHIFTED_HIGH))] |
| 4708 |
"" |
| 4709 |
"li\t%0,%h1" |
| 4710 |
[(set_attr "extended_mips16" "yes")]) |
| 4711 |
|
| 4712 |
;; Insns to fetch a symbol from a big GOT. |
| 4713 |
|
| 4714 |
(define_insn_and_split "*xgot_hi<mode>" |
| 4715 |
[(set (match_operand:P 0 "register_operand" "=d") |
| 4716 |
(high:P (match_operand:P 1 "got_disp_operand" "")))] |
| 4717 |
"TARGET_EXPLICIT_RELOCS && TARGET_XGOT" |
| 4718 |
"#" |
| 4719 |
"&& reload_completed" |
| 4720 |
[(set (match_dup 0) (high:P (match_dup 2))) |
| 4721 |
(set (match_dup 0) (plus:P (match_dup 0) (match_dup 3)))] |
| 4722 |
{ |
| 4723 |
operands[2] = mips_unspec_address (operands[1], SYMBOL_GOTOFF_DISP); |
| 4724 |
operands[3] = pic_offset_table_rtx; |
| 4725 |
} |
| 4726 |
[(set_attr "got" "xgot_high") |
| 4727 |
(set_attr "mode" "<MODE>")]) |
| 4728 |
|
| 4729 |
(define_insn_and_split "*xgot_lo<mode>" |
| 4730 |
[(set (match_operand:P 0 "register_operand" "=d") |
| 4731 |
(lo_sum:P (match_operand:P 1 "register_operand" "d") |
| 4732 |
(match_operand:P 2 "got_disp_operand" "")))] |
| 4733 |
"TARGET_EXPLICIT_RELOCS && TARGET_XGOT" |
| 4734 |
"#" |
| 4735 |
"&& reload_completed" |
| 4736 |
[(set (match_dup 0) |
| 4737 |
(unspec:P [(match_dup 1) (match_dup 3)] UNSPEC_LOAD_GOT))] |
| 4738 |
{ operands[3] = mips_unspec_address (operands[2], SYMBOL_GOTOFF_DISP); } |
| 4739 |
[(set_attr "got" "load") |
| 4740 |
(set_attr "mode" "<MODE>")]) |
| 4741 |
|
| 4742 |
;; Insns to fetch a symbol from a normal GOT. |
| 4743 |
|
| 4744 |
(define_insn_and_split "*got_disp<mode>" |
| 4745 |
[(set (match_operand:P 0 "register_operand" "=d") |
| 4746 |
(match_operand:P 1 "got_disp_operand" ""))] |
| 4747 |
"TARGET_EXPLICIT_RELOCS && !mips_split_p[SYMBOL_GOT_DISP]" |
| 4748 |
"#" |
| 4749 |
"&& reload_completed" |
| 4750 |
[(set (match_dup 0) (match_dup 2))] |
| 4751 |
{ operands[2] = mips_got_load (NULL, operands[1], SYMBOL_GOTOFF_DISP); } |
| 4752 |
[(set_attr "got" "load") |
| 4753 |
(set_attr "mode" "<MODE>")]) |
| 4754 |
|
| 4755 |
;; Insns for loading the "page" part of a page/ofst address from the GOT. |
| 4756 |
|
| 4757 |
(define_insn_and_split "*got_page<mode>" |
| 4758 |
[(set (match_operand:P 0 "register_operand" "=d") |
| 4759 |
(high:P (match_operand:P 1 "got_page_ofst_operand" "")))] |
| 4760 |
"TARGET_EXPLICIT_RELOCS && !mips_split_hi_p[SYMBOL_GOT_PAGE_OFST]" |
| 4761 |
"#" |
| 4762 |
"&& reload_completed" |
| 4763 |
[(set (match_dup 0) (match_dup 2))] |
| 4764 |
{ operands[2] = mips_got_load (NULL, operands[1], SYMBOL_GOTOFF_PAGE); } |
| 4765 |
[(set_attr "got" "load") |
| 4766 |
(set_attr "mode" "<MODE>")]) |
| 4767 |
|
| 4768 |
;; Convenience expander that generates the rhs of a load_got<mode> insn. |
| 4769 |
(define_expand "unspec_got_<mode>" |
| 4770 |
[(unspec:P [(match_operand:P 0) |
| 4771 |
(match_operand:P 1)] UNSPEC_LOAD_GOT)]) |
| 4772 |
|
| 4773 |
;; Lower-level instructions for loading an address from the GOT. |
| 4774 |
;; We could use MEMs, but an unspec gives more optimization |
| 4775 |
;; opportunities. |
| 4776 |
|
| 4777 |
(define_insn "load_got<mode>" |
| 4778 |
[(set (match_operand:P 0 "register_operand" "=d") |
| 4779 |
(unspec:P [(match_operand:P 1 "register_operand" "d") |
| 4780 |
(match_operand:P 2 "immediate_operand" "")] |
| 4781 |
UNSPEC_LOAD_GOT))] |
| 4782 |
"" |
| 4783 |
"<load>\t%0,%R2(%1)" |
| 4784 |
[(set_attr "got" "load") |
| 4785 |
(set_attr "mode" "<MODE>")]) |
| 4786 |
|
| 4787 |
;; Instructions for adding the low 16 bits of an address to a register. |
| 4788 |
;; Operand 2 is the address: mips_print_operand works out which relocation |
| 4789 |
;; should be applied. |
| 4790 |
|
| 4791 |
(define_insn "*low<mode>" |
| 4792 |
[(set (match_operand:P 0 "register_operand" "=d") |
| 4793 |
(lo_sum:P (match_operand:P 1 "register_operand" "d") |
| 4794 |
(match_operand:P 2 "immediate_operand" "")))] |
| 4795 |
"!TARGET_MIPS16" |
| 4796 |
"<d>addiu\t%0,%1,%R2" |
| 4797 |
[(set_attr "alu_type" "add") |
| 4798 |
(set_attr "mode" "<MODE>")]) |
| 4799 |
|
| 4800 |
(define_insn "*lowsi_mips16_gp" |
| 4801 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 4802 |
(lo_sum:SI (reg:SI GLOBAL_POINTER_REGNUM) |
| 4803 |
(match_operand 1 "immediate_operand" "")))] |
| 4804 |
"MIPS16_GP_LOADS" |
| 4805 |
"addiu\t%0,$28,%R1" |
| 4806 |
[(set_attr "alu_type" "add") |
| 4807 |
(set_attr "mode" "SI") |
| 4808 |
(set_attr "extended_mips16" "yes")]) |
| 4809 |
|
| 4810 |
(define_insn "*low<mode>_mips16" |
| 4811 |
[(set (match_operand:P 0 "register_operand" "=d") |
| 4812 |
(lo_sum:P (match_operand:P 1 "register_operand" "0") |
| 4813 |
(match_operand:P 2 "immediate_operand" "")))] |
| 4814 |
"TARGET_MIPS16" |
| 4815 |
"<d>addiu\t%0,%R2" |
| 4816 |
[(set_attr "alu_type" "add") |
| 4817 |
(set_attr "mode" "<MODE>") |
| 4818 |
(set_attr "extended_mips16" "yes")]) |
| 4819 |
|
| 4820 |
;; Expose MIPS16 uses of the global pointer after reload if the function |
| 4821 |
;; is responsible for setting up the register itself. |
| 4822 |
(define_split |
| 4823 |
[(set (match_operand:GPR 0 "d_operand") |
| 4824 |
(const:GPR (unspec:GPR [(const_int 0)] UNSPEC_GP)))] |
| 4825 |
"TARGET_MIPS16 && TARGET_USE_GOT && reload_completed" |
| 4826 |
[(set (match_dup 0) (match_dup 1))] |
| 4827 |
{ operands[1] = pic_offset_table_rtx; }) |
| 4828 |
|
| 4829 |
;; Allow combine to split complex const_int load sequences, using operand 2 |
| 4830 |
;; to store the intermediate results. See move_operand for details. |
| 4831 |
(define_split |
| 4832 |
[(set (match_operand:GPR 0 "register_operand") |
| 4833 |
(match_operand:GPR 1 "splittable_const_int_operand")) |
| 4834 |
(clobber (match_operand:GPR 2 "register_operand"))] |
| 4835 |
"" |
| 4836 |
[(const_int 0)] |
| 4837 |
{ |
| 4838 |
mips_move_integer (operands[2], operands[0], INTVAL (operands[1])); |
| 4839 |
DONE; |
| 4840 |
}) |
| 4841 |
|
| 4842 |
;; Likewise, for symbolic operands. |
| 4843 |
(define_split |
| 4844 |
[(set (match_operand:P 0 "register_operand") |
| 4845 |
(match_operand:P 1)) |
| 4846 |
(clobber (match_operand:P 2 "register_operand"))] |
| 4847 |
"mips_split_symbol (operands[2], operands[1], MAX_MACHINE_MODE, NULL)" |
| 4848 |
[(set (match_dup 0) (match_dup 3))] |
| 4849 |
{ |
| 4850 |
mips_split_symbol (operands[2], operands[1], |
| 4851 |
MAX_MACHINE_MODE, &operands[3]); |
| 4852 |
}) |
| 4853 |
|
| 4854 |
;; 64-bit integer moves |
| 4855 |
|
| 4856 |
;; Unlike most other insns, the move insns can't be split with |
| 4857 |
;; different predicates, because register spilling and other parts of |
| 4858 |
;; the compiler, have memoized the insn number already. |
| 4859 |
|
| 4860 |
(define_expand "movdi" |
| 4861 |
[(set (match_operand:DI 0 "") |
| 4862 |
(match_operand:DI 1 ""))] |
| 4863 |
"" |
| 4864 |
{ |
| 4865 |
if (mips_legitimize_move (DImode, operands[0], operands[1])) |
| 4866 |
DONE; |
| 4867 |
}) |
| 4868 |
|
| 4869 |
;; For mips16, we need a special case to handle storing $31 into |
| 4870 |
;; memory, since we don't have a constraint to match $31. This |
| 4871 |
;; instruction can be generated by save_restore_insns. |
| 4872 |
|
| 4873 |
(define_insn "*mov<mode>_ra" |
| 4874 |
[(set (match_operand:GPR 0 "stack_operand" "=m") |
| 4875 |
(reg:GPR RETURN_ADDR_REGNUM))] |
| 4876 |
"TARGET_MIPS16" |
| 4877 |
"<store>\t$31,%0" |
| 4878 |
[(set_attr "move_type" "store") |
| 4879 |
(set_attr "mode" "<MODE>")]) |
| 4880 |
|
| 4881 |
(define_insn "*movdi_32bit" |
| 4882 |
[(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,m,*a,*a,*d,*f,*f,*d,*m,*B*C*D,*B*C*D,*d,*m") |
| 4883 |
(match_operand:DI 1 "move_operand" "d,i,m,d,*J,*d,*a,*J*d,*m,*f,*f,*d,*m,*B*C*D,*B*C*D"))] |
| 4884 |
"!TARGET_64BIT && !TARGET_MIPS16 |
| 4885 |
&& (register_operand (operands[0], DImode) |
| 4886 |
|| reg_or_0_operand (operands[1], DImode))" |
| 4887 |
{ return mips_output_move (operands[0], operands[1]); } |
| 4888 |
[(set_attr "move_type" "move,const,load,store,imul,mtlo,mflo,mtc,fpload,mfc,fpstore,mtc,fpload,mfc,fpstore") |
| 4889 |
(set (attr "mode") |
| 4890 |
(if_then_else (eq_attr "move_type" "imul") |
| 4891 |
(const_string "SI") |
| 4892 |
(const_string "DI")))]) |
| 4893 |
|
| 4894 |
(define_insn "*movdi_32bit_mips16" |
| 4895 |
[(set (match_operand:DI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m,*d") |
| 4896 |
(match_operand:DI 1 "move_operand" "d,d,y,K,N,m,d,*x"))] |
| 4897 |
"!TARGET_64BIT && TARGET_MIPS16 |
| 4898 |
&& (register_operand (operands[0], DImode) |
| 4899 |
|| register_operand (operands[1], DImode))" |
| 4900 |
{ return mips_output_move (operands[0], operands[1]); } |
| 4901 |
[(set_attr "move_type" "move,move,move,const,constN,load,store,mflo") |
| 4902 |
(set_attr "mode" "DI")]) |
| 4903 |
|
| 4904 |
(define_insn "*movdi_64bit" |
| 4905 |
[(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,e,d,m,*f,*f,*d,*m,*a,*d,*B*C*D,*B*C*D,*d,*m") |
| 4906 |
(match_operand:DI 1 "move_operand" "d,Yd,Yf,m,dJ,*d*J,*m,*f,*f,*J*d,*a,*d,*m,*B*C*D,*B*C*D"))] |
| 4907 |
"TARGET_64BIT && !TARGET_MIPS16 |
| 4908 |
&& (register_operand (operands[0], DImode) |
| 4909 |
|| reg_or_0_operand (operands[1], DImode))" |
| 4910 |
{ return mips_output_move (operands[0], operands[1]); } |
| 4911 |
[(set_attr "move_type" "move,const,const,load,store,mtc,fpload,mfc,fpstore,mtlo,mflo,mtc,fpload,mfc,fpstore") |
| 4912 |
(set_attr "mode" "DI")]) |
| 4913 |
|
| 4914 |
(define_insn "*movdi_64bit_mips16" |
| 4915 |
[(set (match_operand:DI 0 "nonimmediate_operand" "=d,y,d,d,d,d,d,d,m,*d") |
| 4916 |
(match_operand:DI 1 "move_operand" "d,d,y,K,N,Yd,kf,m,d,*a"))] |
| 4917 |
"TARGET_64BIT && TARGET_MIPS16 |
| 4918 |
&& (register_operand (operands[0], DImode) |
| 4919 |
|| register_operand (operands[1], DImode))" |
| 4920 |
{ return mips_output_move (operands[0], operands[1]); } |
| 4921 |
[(set_attr "move_type" "move,move,move,const,constN,const,loadpool,load,store,mflo") |
| 4922 |
(set_attr "mode" "DI")]) |
| 4923 |
|
| 4924 |
;; On the mips16, we can split ld $r,N($r) into an add and a load, |
| 4925 |
;; when the original load is a 4 byte instruction but the add and the |
| 4926 |
;; load are 2 2 byte instructions. |
| 4927 |
|
| 4928 |
(define_split |
| 4929 |
[(set (match_operand:DI 0 "d_operand") |
| 4930 |
(mem:DI (plus:DI (match_dup 0) |
| 4931 |
(match_operand:DI 1 "const_int_operand"))))] |
| 4932 |
"TARGET_64BIT && TARGET_MIPS16 && reload_completed |
| 4933 |
&& !TARGET_DEBUG_D_MODE |
| 4934 |
&& ((INTVAL (operands[1]) < 0 |
| 4935 |
&& INTVAL (operands[1]) >= -0x10) |
| 4936 |
|| (INTVAL (operands[1]) >= 32 * 8 |
| 4937 |
&& INTVAL (operands[1]) <= 31 * 8 + 0x8) |
| 4938 |
|| (INTVAL (operands[1]) >= 0 |
| 4939 |
&& INTVAL (operands[1]) < 32 * 8 |
| 4940 |
&& (INTVAL (operands[1]) & 7) != 0))" |
| 4941 |
[(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1))) |
| 4942 |
(set (match_dup 0) (mem:DI (plus:DI (match_dup 0) (match_dup 2))))] |
| 4943 |
{ |
| 4944 |
HOST_WIDE_INT val = INTVAL (operands[1]); |
| 4945 |
|
| 4946 |
if (val < 0) |
| 4947 |
operands[2] = const0_rtx; |
| 4948 |
else if (val >= 32 * 8) |
| 4949 |
{ |
| 4950 |
int off = val & 7; |
| 4951 |
|
| 4952 |
operands[1] = GEN_INT (0x8 + off); |
| 4953 |
operands[2] = GEN_INT (val - off - 0x8); |
| 4954 |
} |
| 4955 |
else |
| 4956 |
{ |
| 4957 |
int off = val & 7; |
| 4958 |
|
| 4959 |
operands[1] = GEN_INT (off); |
| 4960 |
operands[2] = GEN_INT (val - off); |
| 4961 |
} |
| 4962 |
}) |
| 4963 |
|
| 4964 |
;; 32-bit Integer moves |
| 4965 |
|
| 4966 |
;; Unlike most other insns, the move insns can't be split with |
| 4967 |
;; different predicates, because register spilling and other parts of |
| 4968 |
;; the compiler, have memoized the insn number already. |
| 4969 |
|
| 4970 |
(define_expand "mov<mode>" |
| 4971 |
[(set (match_operand:IMOVE32 0 "") |
| 4972 |
(match_operand:IMOVE32 1 ""))] |
| 4973 |
"" |
| 4974 |
{ |
| 4975 |
if (mips_legitimize_move (<MODE>mode, operands[0], operands[1])) |
| 4976 |
DONE; |
| 4977 |
}) |
| 4978 |
|
| 4979 |
;; The difference between these two is whether or not ints are allowed |
| 4980 |
;; in FP registers (off by default, use -mdebugh to enable). |
| 4981 |
|
| 4982 |
(define_insn "*mov<mode>_internal" |
| 4983 |
[(set (match_operand:IMOVE32 0 "nonimmediate_operand" "=d,!u,!u,d,e,!u,!ks,d,ZS,ZT,m,*f,*f,*d,*m,*d,*z,*a,*d,*B*C*D,*B*C*D,*d,*m") |
| 4984 |
(match_operand:IMOVE32 1 "move_operand" "d,J,Udb7,Yd,Yf,ZT,ZS,m,!ks,!kbJ,dJ,*d*J,*m,*f,*f,*z,*d,*J*d,*a,*d,*m,*B*C*D,*B*C*D"))] |
| 4985 |
"!TARGET_MIPS16 |
| 4986 |
&& (register_operand (operands[0], <MODE>mode) |
| 4987 |
|| reg_or_0_operand (operands[1], <MODE>mode))" |
| 4988 |
{ return mips_output_move (operands[0], operands[1]); } |
| 4989 |
[(set_attr "move_type" "move,move,const,const,const,load,load,load,store,store,store,mtc,fpload,mfc,fpstore,mfc,mtc,mtlo,mflo,mtc,fpload,mfc,fpstore") |
| 4990 |
(set_attr "compression" "all,micromips,micromips,*,*,micromips,micromips,*,micromips,micromips,*,*,*,*,*,*,*,*,*,*,*,*,*") |
| 4991 |
(set_attr "mode" "SI")]) |
| 4992 |
|
| 4993 |
(define_insn "*mov<mode>_mips16" |
| 4994 |
[(set (match_operand:IMOVE32 0 "nonimmediate_operand" "=d,y,d,d,d,d,d,d,m,*d") |
| 4995 |
(match_operand:IMOVE32 1 "move_operand" "d,d,y,K,N,Yd,kf,m,d,*a"))] |
| 4996 |
"TARGET_MIPS16 |
| 4997 |
&& (register_operand (operands[0], <MODE>mode) |
| 4998 |
|| register_operand (operands[1], <MODE>mode))" |
| 4999 |
{ return mips_output_move (operands[0], operands[1]); } |
| 5000 |
[(set_attr "move_type" "move,move,move,const,constN,const,loadpool,load,store,mflo") |
| 5001 |
(set_attr "mode" "SI")]) |
| 5002 |
|
| 5003 |
;; On the mips16, we can split lw $r,N($r) into an add and a load, |
| 5004 |
;; when the original load is a 4 byte instruction but the add and the |
| 5005 |
;; load are 2 2 byte instructions. |
| 5006 |
|
| 5007 |
(define_split |
| 5008 |
[(set (match_operand:SI 0 "d_operand") |
| 5009 |
(mem:SI (plus:SI (match_dup 0) |
| 5010 |
(match_operand:SI 1 "const_int_operand"))))] |
| 5011 |
"TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE |
| 5012 |
&& ((INTVAL (operands[1]) < 0 |
| 5013 |
&& INTVAL (operands[1]) >= -0x80) |
| 5014 |
|| (INTVAL (operands[1]) >= 32 * 4 |
| 5015 |
&& INTVAL (operands[1]) <= 31 * 4 + 0x7c) |
| 5016 |
|| (INTVAL (operands[1]) >= 0 |
| 5017 |
&& INTVAL (operands[1]) < 32 * 4 |
| 5018 |
&& (INTVAL (operands[1]) & 3) != 0))" |
| 5019 |
[(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1))) |
| 5020 |
(set (match_dup 0) (mem:SI (plus:SI (match_dup 0) (match_dup 2))))] |
| 5021 |
{ |
| 5022 |
HOST_WIDE_INT val = INTVAL (operands[1]); |
| 5023 |
|
| 5024 |
if (val < 0) |
| 5025 |
operands[2] = const0_rtx; |
| 5026 |
else if (val >= 32 * 4) |
| 5027 |
{ |
| 5028 |
int off = val & 3; |
| 5029 |
|
| 5030 |
operands[1] = GEN_INT (0x7c + off); |
| 5031 |
operands[2] = GEN_INT (val - off - 0x7c); |
| 5032 |
} |
| 5033 |
else |
| 5034 |
{ |
| 5035 |
int off = val & 3; |
| 5036 |
|
| 5037 |
operands[1] = GEN_INT (off); |
| 5038 |
operands[2] = GEN_INT (val - off); |
| 5039 |
} |
| 5040 |
}) |
| 5041 |
|
| 5042 |
;; On the mips16, we can split a load of certain constants into a load |
| 5043 |
;; and an add. This turns a 4 byte instruction into 2 2 byte |
| 5044 |
;; instructions. |
| 5045 |
|
| 5046 |
(define_split |
| 5047 |
[(set (match_operand:SI 0 "d_operand") |
| 5048 |
(match_operand:SI 1 "const_int_operand"))] |
| 5049 |
"TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE |
| 5050 |
&& INTVAL (operands[1]) >= 0x100 |
| 5051 |
&& INTVAL (operands[1]) <= 0xff + 0x7f" |
| 5052 |
[(set (match_dup 0) (match_dup 1)) |
| 5053 |
(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))] |
| 5054 |
{ |
| 5055 |
int val = INTVAL (operands[1]); |
| 5056 |
|
| 5057 |
operands[1] = GEN_INT (0xff); |
| 5058 |
operands[2] = GEN_INT (val - 0xff); |
| 5059 |
}) |
| 5060 |
|
| 5061 |
;; MIPS4 supports loading and storing a floating point register from |
| 5062 |
;; the sum of two general registers. We use two versions for each of |
| 5063 |
;; these four instructions: one where the two general registers are |
| 5064 |
;; SImode, and one where they are DImode. This is because general |
| 5065 |
;; registers will be in SImode when they hold 32-bit values, but, |
| 5066 |
;; since the 32-bit values are always sign extended, the [ls][wd]xc1 |
| 5067 |
;; instructions will still work correctly. |
| 5068 |
|
| 5069 |
;; ??? Perhaps it would be better to support these instructions by |
| 5070 |
;; modifying TARGET_LEGITIMATE_ADDRESS_P and friends. However, since |
| 5071 |
;; these instructions can only be used to load and store floating |
| 5072 |
;; point registers, that would probably cause trouble in reload. |
| 5073 |
|
| 5074 |
(define_insn "*<ANYF:loadx>_<P:mode>" |
| 5075 |
[(set (match_operand:ANYF 0 "register_operand" "=f") |
| 5076 |
(mem:ANYF (plus:P (match_operand:P 1 "register_operand" "d") |
| 5077 |
(match_operand:P 2 "register_operand" "d"))))] |
| 5078 |
"ISA_HAS_LXC1_SXC1" |
| 5079 |
"<ANYF:loadx>\t%0,%1(%2)" |
| 5080 |
[(set_attr "type" "fpidxload") |
| 5081 |
(set_attr "mode" "<ANYF:UNITMODE>")]) |
| 5082 |
|
| 5083 |
(define_insn "*<ANYF:storex>_<P:mode>" |
| 5084 |
[(set (mem:ANYF (plus:P (match_operand:P 1 "register_operand" "d") |
| 5085 |
(match_operand:P 2 "register_operand" "d"))) |
| 5086 |
(match_operand:ANYF 0 "register_operand" "f"))] |
| 5087 |
"ISA_HAS_LXC1_SXC1" |
| 5088 |
"<ANYF:storex>\t%0,%1(%2)" |
| 5089 |
[(set_attr "type" "fpidxstore") |
| 5090 |
(set_attr "mode" "<ANYF:UNITMODE>")]) |
| 5091 |
|
| 5092 |
;; Scaled indexed address load. |
| 5093 |
;; Per md.texi, we only need to look for a pattern with multiply in the |
| 5094 |
;; address expression, not shift. |
| 5095 |
|
| 5096 |
(define_insn "*lwxs" |
| 5097 |
[(set (match_operand:IMOVE32 0 "register_operand" "=d") |
| 5098 |
(mem:IMOVE32 |
| 5099 |
(plus:P (mult:P (match_operand:P 1 "register_operand" "d") |
| 5100 |
(const_int 4)) |
| 5101 |
(match_operand:P 2 "register_operand" "d"))))] |
| 5102 |
"ISA_HAS_LWXS" |
| 5103 |
"lwxs\t%0,%1(%2)" |
| 5104 |
[(set_attr "type" "load") |
| 5105 |
(set_attr "mode" "SI")]) |
| 5106 |
|
| 5107 |
;; 16-bit Integer moves |
| 5108 |
|
| 5109 |
;; Unlike most other insns, the move insns can't be split with |
| 5110 |
;; different predicates, because register spilling and other parts of |
| 5111 |
;; the compiler, have memoized the insn number already. |
| 5112 |
;; Unsigned loads are used because LOAD_EXTEND_OP returns ZERO_EXTEND. |
| 5113 |
|
| 5114 |
(define_expand "movhi" |
| 5115 |
[(set (match_operand:HI 0 "") |
| 5116 |
(match_operand:HI 1 ""))] |
| 5117 |
"" |
| 5118 |
{ |
| 5119 |
if (mips_legitimize_move (HImode, operands[0], operands[1])) |
| 5120 |
DONE; |
| 5121 |
}) |
| 5122 |
|
| 5123 |
(define_insn "*movhi_internal" |
| 5124 |
[(set (match_operand:HI 0 "nonimmediate_operand" "=d,!u,d,!u,d,ZU,m,*a,*d") |
| 5125 |
(match_operand:HI 1 "move_operand" "d,J,I,ZU,m,!kbJ,dJ,*d*J,*a"))] |
| 5126 |
"!TARGET_MIPS16 |
| 5127 |
&& (register_operand (operands[0], HImode) |
| 5128 |
|| reg_or_0_operand (operands[1], HImode))" |
| 5129 |
{ return mips_output_move (operands[0], operands[1]); } |
| 5130 |
[(set_attr "move_type" "move,const,const,load,load,store,store,mtlo,mflo") |
| 5131 |
(set_attr "compression" "all,micromips,*,micromips,*,micromips,*,*,*") |
| 5132 |
(set_attr "mode" "HI")]) |
| 5133 |
|
| 5134 |
(define_insn "*movhi_mips16" |
| 5135 |
[(set (match_operand:HI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m,*d") |
| 5136 |
(match_operand:HI 1 "move_operand" "d,d,y,K,N,m,d,*a"))] |
| 5137 |
"TARGET_MIPS16 |
| 5138 |
&& (register_operand (operands[0], HImode) |
| 5139 |
|| register_operand (operands[1], HImode))" |
| 5140 |
{ return mips_output_move (operands[0], operands[1]); } |
| 5141 |
[(set_attr "move_type" "move,move,move,const,constN,load,store,mflo") |
| 5142 |
(set_attr "mode" "HI")]) |
| 5143 |
|
| 5144 |
;; On the mips16, we can split lh $r,N($r) into an add and a load, |
| 5145 |
;; when the original load is a 4 byte instruction but the add and the |
| 5146 |
;; load are 2 2 byte instructions. |
| 5147 |
|
| 5148 |
(define_split |
| 5149 |
[(set (match_operand:HI 0 "d_operand") |
| 5150 |
(mem:HI (plus:SI (match_dup 0) |
| 5151 |
(match_operand:SI 1 "const_int_operand"))))] |
| 5152 |
"TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE |
| 5153 |
&& ((INTVAL (operands[1]) < 0 |
| 5154 |
&& INTVAL (operands[1]) >= -0x80) |
| 5155 |
|| (INTVAL (operands[1]) >= 32 * 2 |
| 5156 |
&& INTVAL (operands[1]) <= 31 * 2 + 0x7e) |
| 5157 |
|| (INTVAL (operands[1]) >= 0 |
| 5158 |
&& INTVAL (operands[1]) < 32 * 2 |
| 5159 |
&& (INTVAL (operands[1]) & 1) != 0))" |
| 5160 |
[(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1))) |
| 5161 |
(set (match_dup 0) (mem:HI (plus:SI (match_dup 0) (match_dup 2))))] |
| 5162 |
{ |
| 5163 |
HOST_WIDE_INT val = INTVAL (operands[1]); |
| 5164 |
|
| 5165 |
if (val < 0) |
| 5166 |
operands[2] = const0_rtx; |
| 5167 |
else if (val >= 32 * 2) |
| 5168 |
{ |
| 5169 |
int off = val & 1; |
| 5170 |
|
| 5171 |
operands[1] = GEN_INT (0x7e + off); |
| 5172 |
operands[2] = GEN_INT (val - off - 0x7e); |
| 5173 |
} |
| 5174 |
else |
| 5175 |
{ |
| 5176 |
int off = val & 1; |
| 5177 |
|
| 5178 |
operands[1] = GEN_INT (off); |
| 5179 |
operands[2] = GEN_INT (val - off); |
| 5180 |
} |
| 5181 |
}) |
| 5182 |
|
| 5183 |
;; 8-bit Integer moves |
| 5184 |
|
| 5185 |
;; Unlike most other insns, the move insns can't be split with |
| 5186 |
;; different predicates, because register spilling and other parts of |
| 5187 |
;; the compiler, have memoized the insn number already. |
| 5188 |
;; Unsigned loads are used because LOAD_EXTEND_OP returns ZERO_EXTEND. |
| 5189 |
|
| 5190 |
(define_expand "movqi" |
| 5191 |
[(set (match_operand:QI 0 "") |
| 5192 |
(match_operand:QI 1 ""))] |
| 5193 |
"" |
| 5194 |
{ |
| 5195 |
if (mips_legitimize_move (QImode, operands[0], operands[1])) |
| 5196 |
DONE; |
| 5197 |
}) |
| 5198 |
|
| 5199 |
(define_insn "*movqi_internal" |
| 5200 |
[(set (match_operand:QI 0 "nonimmediate_operand" "=d,!u,d,!u,d,ZV,m,*a,*d") |
| 5201 |
(match_operand:QI 1 "move_operand" "d,J,I,ZW,m,!kbJ,dJ,*d*J,*a"))] |
| 5202 |
"!TARGET_MIPS16 |
| 5203 |
&& (register_operand (operands[0], QImode) |
| 5204 |
|| reg_or_0_operand (operands[1], QImode))" |
| 5205 |
{ return mips_output_move (operands[0], operands[1]); } |
| 5206 |
[(set_attr "move_type" "move,const,const,load,load,store,store,mtlo,mflo") |
| 5207 |
(set_attr "compression" "all,micromips,*,micromips,*,micromips,*,*,*") |
| 5208 |
(set_attr "mode" "QI")]) |
| 5209 |
|
| 5210 |
(define_insn "*movqi_mips16" |
| 5211 |
[(set (match_operand:QI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m,*d") |
| 5212 |
(match_operand:QI 1 "move_operand" "d,d,y,K,N,m,d,*a"))] |
| 5213 |
"TARGET_MIPS16 |
| 5214 |
&& (register_operand (operands[0], QImode) |
| 5215 |
|| register_operand (operands[1], QImode))" |
| 5216 |
{ return mips_output_move (operands[0], operands[1]); } |
| 5217 |
[(set_attr "move_type" "move,move,move,const,constN,load,store,mflo") |
| 5218 |
(set_attr "mode" "QI")]) |
| 5219 |
|
| 5220 |
;; On the mips16, we can split lb $r,N($r) into an add and a load, |
| 5221 |
;; when the original load is a 4 byte instruction but the add and the |
| 5222 |
;; load are 2 2 byte instructions. |
| 5223 |
|
| 5224 |
(define_split |
| 5225 |
[(set (match_operand:QI 0 "d_operand") |
| 5226 |
(mem:QI (plus:SI (match_dup 0) |
| 5227 |
(match_operand:SI 1 "const_int_operand"))))] |
| 5228 |
"TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE |
| 5229 |
&& ((INTVAL (operands[1]) < 0 |
| 5230 |
&& INTVAL (operands[1]) >= -0x80) |
| 5231 |
|| (INTVAL (operands[1]) >= 32 |
| 5232 |
&& INTVAL (operands[1]) <= 31 + 0x7f))" |
| 5233 |
[(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1))) |
| 5234 |
(set (match_dup 0) (mem:QI (plus:SI (match_dup 0) (match_dup 2))))] |
| 5235 |
{ |
| 5236 |
HOST_WIDE_INT val = INTVAL (operands[1]); |
| 5237 |
|
| 5238 |
if (val < 0) |
| 5239 |
operands[2] = const0_rtx; |
| 5240 |
else |
| 5241 |
{ |
| 5242 |
operands[1] = GEN_INT (0x7f); |
| 5243 |
operands[2] = GEN_INT (val - 0x7f); |
| 5244 |
} |
| 5245 |
}) |
| 5246 |
|
| 5247 |
;; 32-bit floating point moves |
| 5248 |
|
| 5249 |
(define_expand "movsf" |
| 5250 |
[(set (match_operand:SF 0 "") |
| 5251 |
(match_operand:SF 1 ""))] |
| 5252 |
"" |
| 5253 |
{ |
| 5254 |
if (mips_legitimize_move (SFmode, operands[0], operands[1])) |
| 5255 |
DONE; |
| 5256 |
}) |
| 5257 |
|
| 5258 |
(define_insn "movccf" |
| 5259 |
[(set (match_operand:CCF 0 "nonimmediate_operand" "=f,f,m") |
| 5260 |
(match_operand:CCF 1 "nonimmediate_operand" "f,m,f"))] |
| 5261 |
"ISA_HAS_CCF" |
| 5262 |
{ return mips_output_move (operands[0], operands[1]); } |
| 5263 |
[(set_attr "move_type" "fmove,fpload,fpstore")]) |
| 5264 |
|
| 5265 |
(define_insn "*movsf_hardfloat" |
| 5266 |
[(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m") |
| 5267 |
(match_operand:SF 1 "move_operand" "f,G,m,f,G,*d,*f,*G*d,*m,*d"))] |
| 5268 |
"TARGET_HARD_FLOAT |
| 5269 |
&& (register_operand (operands[0], SFmode) |
| 5270 |
|| reg_or_0_operand (operands[1], SFmode))" |
| 5271 |
{ return mips_output_move (operands[0], operands[1]); } |
| 5272 |
[(set_attr "move_type" "fmove,mtc,fpload,fpstore,store,mtc,mfc,move,load,store") |
| 5273 |
(set_attr "mode" "SF")]) |
| 5274 |
|
| 5275 |
(define_insn "*movsf_softfloat" |
| 5276 |
[(set (match_operand:SF 0 "nonimmediate_operand" "=d,d,m") |
| 5277 |
(match_operand:SF 1 "move_operand" "Gd,m,d"))] |
| 5278 |
"TARGET_SOFT_FLOAT && !TARGET_MIPS16 |
| 5279 |
&& (register_operand (operands[0], SFmode) |
| 5280 |
|| reg_or_0_operand (operands[1], SFmode))" |
| 5281 |
{ return mips_output_move (operands[0], operands[1]); } |
| 5282 |
[(set_attr "move_type" "move,load,store") |
| 5283 |
(set_attr "mode" "SF")]) |
| 5284 |
|
| 5285 |
(define_insn "*movsf_mips16" |
| 5286 |
[(set (match_operand:SF 0 "nonimmediate_operand" "=d,y,d,d,m") |
| 5287 |
(match_operand:SF 1 "move_operand" "d,d,y,m,d"))] |
| 5288 |
"TARGET_MIPS16 |
| 5289 |
&& (register_operand (operands[0], SFmode) |
| 5290 |
|| register_operand (operands[1], SFmode))" |
| 5291 |
{ return mips_output_move (operands[0], operands[1]); } |
| 5292 |
[(set_attr "move_type" "move,move,move,load,store") |
| 5293 |
(set_attr "mode" "SF")]) |
| 5294 |
|
| 5295 |
;; 64-bit floating point moves |
| 5296 |
|
| 5297 |
(define_expand "movdf" |
| 5298 |
[(set (match_operand:DF 0 "") |
| 5299 |
(match_operand:DF 1 ""))] |
| 5300 |
"" |
| 5301 |
{ |
| 5302 |
if (mips_legitimize_move (DFmode, operands[0], operands[1])) |
| 5303 |
DONE; |
| 5304 |
}) |
| 5305 |
|
| 5306 |
(define_insn "*movdf_hardfloat" |
| 5307 |
[(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m") |
| 5308 |
(match_operand:DF 1 "move_operand" "f,G,m,f,G,*d,*f,*d*G,*m,*d"))] |
| 5309 |
"TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT |
| 5310 |
&& (register_operand (operands[0], DFmode) |
| 5311 |
|| reg_or_0_operand (operands[1], DFmode))" |
| 5312 |
{ return mips_output_move (operands[0], operands[1]); } |
| 5313 |
[(set_attr "move_type" "fmove,mtc,fpload,fpstore,store,mtc,mfc,move,load,store") |
| 5314 |
(set_attr "mode" "DF")]) |
| 5315 |
|
| 5316 |
(define_insn "*movdf_softfloat" |
| 5317 |
[(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,m") |
| 5318 |
(match_operand:DF 1 "move_operand" "dG,m,dG"))] |
| 5319 |
"(TARGET_SOFT_FLOAT || TARGET_SINGLE_FLOAT) && !TARGET_MIPS16 |
| 5320 |
&& (register_operand (operands[0], DFmode) |
| 5321 |
|| reg_or_0_operand (operands[1], DFmode))" |
| 5322 |
{ return mips_output_move (operands[0], operands[1]); } |
| 5323 |
[(set_attr "move_type" "move,load,store") |
| 5324 |
(set_attr "mode" "DF")]) |
| 5325 |
|
| 5326 |
(define_insn "*movdf_mips16" |
| 5327 |
[(set (match_operand:DF 0 "nonimmediate_operand" "=d,y,d,d,m") |
| 5328 |
(match_operand:DF 1 "move_operand" "d,d,y,m,d"))] |
| 5329 |
"TARGET_MIPS16 |
| 5330 |
&& (register_operand (operands[0], DFmode) |
| 5331 |
|| register_operand (operands[1], DFmode))" |
| 5332 |
{ return mips_output_move (operands[0], operands[1]); } |
| 5333 |
[(set_attr "move_type" "move,move,move,load,store") |
| 5334 |
(set_attr "mode" "DF")]) |
| 5335 |
|
| 5336 |
;; 128-bit integer moves |
| 5337 |
|
| 5338 |
(define_expand "movti" |
| 5339 |
[(set (match_operand:TI 0) |
| 5340 |
(match_operand:TI 1))] |
| 5341 |
"TARGET_64BIT" |
| 5342 |
{ |
| 5343 |
if (mips_legitimize_move (TImode, operands[0], operands[1])) |
| 5344 |
DONE; |
| 5345 |
}) |
| 5346 |
|
| 5347 |
(define_insn "*movti" |
| 5348 |
[(set (match_operand:TI 0 "nonimmediate_operand" "=d,d,d,m,*a,*a,*d") |
| 5349 |
(match_operand:TI 1 "move_operand" "d,i,m,dJ,*J,*d,*a"))] |
| 5350 |
"TARGET_64BIT |
| 5351 |
&& !TARGET_MIPS16 |
| 5352 |
&& (register_operand (operands[0], TImode) |
| 5353 |
|| reg_or_0_operand (operands[1], TImode))" |
| 5354 |
{ return mips_output_move (operands[0], operands[1]); } |
| 5355 |
[(set_attr "move_type" "move,const,load,store,imul,mtlo,mflo") |
| 5356 |
(set (attr "mode") |
| 5357 |
(if_then_else (eq_attr "move_type" "imul") |
| 5358 |
(const_string "SI") |
| 5359 |
(const_string "TI")))]) |
| 5360 |
|
| 5361 |
(define_insn "*movti_mips16" |
| 5362 |
[(set (match_operand:TI 0 "nonimmediate_operand" "=d,y,d,d,d,d,m,*d") |
| 5363 |
(match_operand:TI 1 "move_operand" "d,d,y,K,N,m,d,*a"))] |
| 5364 |
"TARGET_64BIT |
| 5365 |
&& TARGET_MIPS16 |
| 5366 |
&& (register_operand (operands[0], TImode) |
| 5367 |
|| register_operand (operands[1], TImode))" |
| 5368 |
"#" |
| 5369 |
[(set_attr "move_type" "move,move,move,const,constN,load,store,mflo") |
| 5370 |
(set_attr "mode" "TI")]) |
| 5371 |
|
| 5372 |
;; 128-bit floating point moves |
| 5373 |
|
| 5374 |
(define_expand "movtf" |
| 5375 |
[(set (match_operand:TF 0) |
| 5376 |
(match_operand:TF 1))] |
| 5377 |
"TARGET_64BIT" |
| 5378 |
{ |
| 5379 |
if (mips_legitimize_move (TFmode, operands[0], operands[1])) |
| 5380 |
DONE; |
| 5381 |
}) |
| 5382 |
|
| 5383 |
;; This pattern handles both hard- and soft-float cases. |
| 5384 |
(define_insn "*movtf" |
| 5385 |
[(set (match_operand:TF 0 "nonimmediate_operand" "=d,d,m,f,d,f,m") |
| 5386 |
(match_operand:TF 1 "move_operand" "dG,m,dG,dG,f,m,f"))] |
| 5387 |
"TARGET_64BIT |
| 5388 |
&& !TARGET_MIPS16 |
| 5389 |
&& (register_operand (operands[0], TFmode) |
| 5390 |
|| reg_or_0_operand (operands[1], TFmode))" |
| 5391 |
"#" |
| 5392 |
[(set_attr "move_type" "move,load,store,mtc,mfc,fpload,fpstore") |
| 5393 |
(set_attr "mode" "TF")]) |
| 5394 |
|
| 5395 |
(define_insn "*movtf_mips16" |
| 5396 |
[(set (match_operand:TF 0 "nonimmediate_operand" "=d,y,d,d,m") |
| 5397 |
(match_operand:TF 1 "move_operand" "d,d,y,m,d"))] |
| 5398 |
"TARGET_64BIT |
| 5399 |
&& TARGET_MIPS16 |
| 5400 |
&& (register_operand (operands[0], TFmode) |
| 5401 |
|| register_operand (operands[1], TFmode))" |
| 5402 |
"#" |
| 5403 |
[(set_attr "move_type" "move,move,move,load,store") |
| 5404 |
(set_attr "mode" "TF")]) |
| 5405 |
|
| 5406 |
(define_split |
| 5407 |
[(set (match_operand:MOVE64 0 "nonimmediate_operand") |
| 5408 |
(match_operand:MOVE64 1 "move_operand"))] |
| 5409 |
"reload_completed && mips_split_move_insn_p (operands[0], operands[1], insn)" |
| 5410 |
[(const_int 0)] |
| 5411 |
{ |
| 5412 |
mips_split_move_insn (operands[0], operands[1], curr_insn); |
| 5413 |
DONE; |
| 5414 |
}) |
| 5415 |
|
| 5416 |
(define_split |
| 5417 |
[(set (match_operand:MOVE128 0 "nonimmediate_operand") |
| 5418 |
(match_operand:MOVE128 1 "move_operand"))] |
| 5419 |
"reload_completed && mips_split_move_insn_p (operands[0], operands[1], insn)" |
| 5420 |
[(const_int 0)] |
| 5421 |
{ |
| 5422 |
mips_split_move_insn (operands[0], operands[1], curr_insn); |
| 5423 |
DONE; |
| 5424 |
}) |
| 5425 |
|
| 5426 |
;; When generating mips16 code, split moves of negative constants into |
| 5427 |
;; a positive "li" followed by a negation. |
| 5428 |
(define_split |
| 5429 |
[(set (match_operand 0 "d_operand") |
| 5430 |
(match_operand 1 "const_int_operand"))] |
| 5431 |
"TARGET_MIPS16 && reload_completed && INTVAL (operands[1]) < 0" |
| 5432 |
[(set (match_dup 2) |
| 5433 |
(match_dup 3)) |
| 5434 |
(set (match_dup 2) |
| 5435 |
(neg:SI (match_dup 2)))] |
| 5436 |
{ |
| 5437 |
operands[2] = gen_lowpart (SImode, operands[0]); |
| 5438 |
operands[3] = GEN_INT (-INTVAL (operands[1])); |
| 5439 |
}) |
| 5440 |
|
| 5441 |
;; 64-bit paired-single floating point moves |
| 5442 |
|
| 5443 |
(define_expand "movv2sf" |
| 5444 |
[(set (match_operand:V2SF 0) |
| 5445 |
(match_operand:V2SF 1))] |
| 5446 |
"TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT" |
| 5447 |
{ |
| 5448 |
if (mips_legitimize_move (V2SFmode, operands[0], operands[1])) |
| 5449 |
DONE; |
| 5450 |
}) |
| 5451 |
|
| 5452 |
(define_insn "*movv2sf" |
| 5453 |
[(set (match_operand:V2SF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*d,*d,*d,*m") |
| 5454 |
(match_operand:V2SF 1 "move_operand" "f,YG,m,f,YG,*d,*f,*d*YG,*m,*d"))] |
| 5455 |
"TARGET_HARD_FLOAT |
| 5456 |
&& TARGET_PAIRED_SINGLE_FLOAT |
| 5457 |
&& (register_operand (operands[0], V2SFmode) |
| 5458 |
|| reg_or_0_operand (operands[1], V2SFmode))" |
| 5459 |
{ return mips_output_move (operands[0], operands[1]); } |
| 5460 |
[(set_attr "move_type" "fmove,mtc,fpload,fpstore,store,mtc,mfc,move,load,store") |
| 5461 |
(set_attr "mode" "DF")]) |
| 5462 |
|
| 5463 |
;; Extract the high part of a HI/LO value. See mips_hard_regno_mode_ok_p |
| 5464 |
;; for the reason why we can't just use (reg:GPR HI_REGNUM). |
| 5465 |
;; |
| 5466 |
;; When generating VR4120 or VR4130 code, we use MACCHI and DMACCHI |
| 5467 |
;; instead of MFHI. This avoids both the normal MIPS III hi/lo hazards |
| 5468 |
;; and the errata related to -mfix-vr4130. |
| 5469 |
(define_insn "mfhi<GPR:mode>_<HILO:mode>" |
| 5470 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 5471 |
(unspec:GPR [(match_operand:HILO 1 "hilo_operand" "x")] |
| 5472 |
UNSPEC_MFHI))] |
| 5473 |
"" |
| 5474 |
{ return ISA_HAS_MACCHI ? "<GPR:d>macchi\t%0,%.,%." : "mfhi\t%0"; } |
| 5475 |
[(set_attr "type" "mfhi") |
| 5476 |
(set_attr "mode" "<GPR:MODE>")]) |
| 5477 |
|
| 5478 |
;; Set the high part of a HI/LO value, given that the low part has |
| 5479 |
;; already been set. See mips_hard_regno_mode_ok_p for the reason |
| 5480 |
;; why we can't just use (reg:GPR HI_REGNUM). |
| 5481 |
(define_insn "mthi<GPR:mode>_<HILO:mode>" |
| 5482 |
[(set (match_operand:HILO 0 "register_operand" "=x") |
| 5483 |
(unspec:HILO [(match_operand:GPR 1 "reg_or_0_operand" "dJ") |
| 5484 |
(match_operand:GPR 2 "register_operand" "l")] |
| 5485 |
UNSPEC_MTHI))] |
| 5486 |
"" |
| 5487 |
"mthi\t%z1" |
| 5488 |
[(set_attr "type" "mthi") |
| 5489 |
(set_attr "mode" "SI")]) |
| 5490 |
|
| 5491 |
;; Emit a doubleword move in which exactly one of the operands is |
| 5492 |
;; a floating-point register. We can't just emit two normal moves |
| 5493 |
;; because of the constraints imposed by the FPU register model; |
| 5494 |
;; see mips_cannot_change_mode_class for details. Instead, we keep |
| 5495 |
;; the FPR whole and use special patterns to refer to each word of |
| 5496 |
;; the other operand. |
| 5497 |
|
| 5498 |
(define_expand "move_doubleword_fpr<mode>" |
| 5499 |
[(set (match_operand:SPLITF 0) |
| 5500 |
(match_operand:SPLITF 1))] |
| 5501 |
"" |
| 5502 |
{ |
| 5503 |
if (FP_REG_RTX_P (operands[0])) |
| 5504 |
{ |
| 5505 |
rtx low = mips_subword (operands[1], 0); |
| 5506 |
rtx high = mips_subword (operands[1], 1); |
| 5507 |
emit_insn (gen_load_low<mode> (operands[0], low)); |
| 5508 |
if (ISA_HAS_MXHC1 && !TARGET_64BIT) |
| 5509 |
emit_insn (gen_mthc1<mode> (operands[0], high, operands[0])); |
| 5510 |
else |
| 5511 |
emit_insn (gen_load_high<mode> (operands[0], high, operands[0])); |
| 5512 |
} |
| 5513 |
else |
| 5514 |
{ |
| 5515 |
rtx low = mips_subword (operands[0], 0); |
| 5516 |
rtx high = mips_subword (operands[0], 1); |
| 5517 |
emit_insn (gen_store_word<mode> (low, operands[1], const0_rtx)); |
| 5518 |
if (ISA_HAS_MXHC1 && !TARGET_64BIT) |
| 5519 |
emit_insn (gen_mfhc1<mode> (high, operands[1])); |
| 5520 |
else |
| 5521 |
emit_insn (gen_store_word<mode> (high, operands[1], const1_rtx)); |
| 5522 |
} |
| 5523 |
DONE; |
| 5524 |
}) |
| 5525 |
|
| 5526 |
;; Load the low word of operand 0 with operand 1. |
| 5527 |
(define_insn "load_low<mode>" |
| 5528 |
[(set (match_operand:SPLITF 0 "register_operand" "=f,f") |
| 5529 |
(unspec:SPLITF [(match_operand:<HALFMODE> 1 "general_operand" "dJ,m")] |
| 5530 |
UNSPEC_LOAD_LOW))] |
| 5531 |
"TARGET_HARD_FLOAT" |
| 5532 |
{ |
| 5533 |
operands[0] = mips_subword (operands[0], 0); |
| 5534 |
return mips_output_move (operands[0], operands[1]); |
| 5535 |
} |
| 5536 |
[(set_attr "move_type" "mtc,fpload") |
| 5537 |
(set_attr "mode" "<HALFMODE>")]) |
| 5538 |
|
| 5539 |
;; Load the high word of operand 0 from operand 1, preserving the value |
| 5540 |
;; in the low word. |
| 5541 |
(define_insn "load_high<mode>" |
| 5542 |
[(set (match_operand:SPLITF 0 "register_operand" "=f,f") |
| 5543 |
(unspec:SPLITF [(match_operand:<HALFMODE> 1 "general_operand" "dJ,m") |
| 5544 |
(match_operand:SPLITF 2 "register_operand" "0,0")] |
| 5545 |
UNSPEC_LOAD_HIGH))] |
| 5546 |
"TARGET_HARD_FLOAT" |
| 5547 |
{ |
| 5548 |
operands[0] = mips_subword (operands[0], 1); |
| 5549 |
return mips_output_move (operands[0], operands[1]); |
| 5550 |
} |
| 5551 |
[(set_attr "move_type" "mtc,fpload") |
| 5552 |
(set_attr "mode" "<HALFMODE>")]) |
| 5553 |
|
| 5554 |
;; Store one word of operand 1 in operand 0. Operand 2 is 1 to store the |
| 5555 |
;; high word and 0 to store the low word. |
| 5556 |
(define_insn "store_word<mode>" |
| 5557 |
[(set (match_operand:<HALFMODE> 0 "nonimmediate_operand" "=d,m") |
| 5558 |
(unspec:<HALFMODE> [(match_operand:SPLITF 1 "register_operand" "f,f") |
| 5559 |
(match_operand 2 "const_int_operand")] |
| 5560 |
UNSPEC_STORE_WORD))] |
| 5561 |
"TARGET_HARD_FLOAT" |
| 5562 |
{ |
| 5563 |
operands[1] = mips_subword (operands[1], INTVAL (operands[2])); |
| 5564 |
return mips_output_move (operands[0], operands[1]); |
| 5565 |
} |
| 5566 |
[(set_attr "move_type" "mfc,fpstore") |
| 5567 |
(set_attr "mode" "<HALFMODE>")]) |
| 5568 |
|
| 5569 |
;; Move operand 1 to the high word of operand 0 using mthc1, preserving the |
| 5570 |
;; value in the low word. |
| 5571 |
(define_insn "mthc1<mode>" |
| 5572 |
[(set (match_operand:SPLITF 0 "register_operand" "=f") |
| 5573 |
(unspec:SPLITF [(match_operand:<HALFMODE> 1 "reg_or_0_operand" "dJ") |
| 5574 |
(match_operand:SPLITF 2 "register_operand" "0")] |
| 5575 |
UNSPEC_MTHC1))] |
| 5576 |
"TARGET_HARD_FLOAT && ISA_HAS_MXHC1" |
| 5577 |
"mthc1\t%z1,%0" |
| 5578 |
[(set_attr "move_type" "mtc") |
| 5579 |
(set_attr "mode" "<HALFMODE>")]) |
| 5580 |
|
| 5581 |
;; Move high word of operand 1 to operand 0 using mfhc1. |
| 5582 |
(define_insn "mfhc1<mode>" |
| 5583 |
[(set (match_operand:<HALFMODE> 0 "register_operand" "=d") |
| 5584 |
(unspec:<HALFMODE> [(match_operand:SPLITF 1 "register_operand" "f")] |
| 5585 |
UNSPEC_MFHC1))] |
| 5586 |
"TARGET_HARD_FLOAT && ISA_HAS_MXHC1" |
| 5587 |
"mfhc1\t%0,%1" |
| 5588 |
[(set_attr "move_type" "mfc") |
| 5589 |
(set_attr "mode" "<HALFMODE>")]) |
| 5590 |
|
| 5591 |
;; Move a constant that satisfies CONST_GP_P into operand 0. |
| 5592 |
(define_expand "load_const_gp_<mode>" |
| 5593 |
[(set (match_operand:P 0 "register_operand" "=d") |
| 5594 |
(const:P (unspec:P [(const_int 0)] UNSPEC_GP)))]) |
| 5595 |
|
| 5596 |
;; Insn to initialize $gp for n32/n64 abicalls. Operand 0 is the offset |
| 5597 |
;; of _gp from the start of this function. Operand 1 is the incoming |
| 5598 |
;; function address. |
| 5599 |
(define_insn_and_split "loadgp_newabi_<mode>" |
| 5600 |
[(set (match_operand:P 0 "register_operand" "=&d") |
| 5601 |
(unspec:P [(match_operand:P 1) |
| 5602 |
(match_operand:P 2 "register_operand" "d")] |
| 5603 |
UNSPEC_LOADGP))] |
| 5604 |
"mips_current_loadgp_style () == LOADGP_NEWABI" |
| 5605 |
{ return mips_must_initialize_gp_p () ? "#" : ""; } |
| 5606 |
"&& mips_must_initialize_gp_p ()" |
| 5607 |
[(set (match_dup 0) (match_dup 3)) |
| 5608 |
(set (match_dup 0) (match_dup 4)) |
| 5609 |
(set (match_dup 0) (match_dup 5))] |
| 5610 |
{ |
| 5611 |
operands[3] = gen_rtx_HIGH (Pmode, operands[1]); |
| 5612 |
operands[4] = gen_rtx_PLUS (Pmode, operands[0], operands[2]); |
| 5613 |
operands[5] = gen_rtx_LO_SUM (Pmode, operands[0], operands[1]); |
| 5614 |
} |
| 5615 |
[(set_attr "type" "ghost")]) |
| 5616 |
|
| 5617 |
;; Likewise, for -mno-shared code. Operand 0 is the __gnu_local_gp symbol. |
| 5618 |
(define_insn_and_split "loadgp_absolute_<mode>" |
| 5619 |
[(set (match_operand:P 0 "register_operand" "=d") |
| 5620 |
(unspec:P [(match_operand:P 1)] UNSPEC_LOADGP))] |
| 5621 |
"mips_current_loadgp_style () == LOADGP_ABSOLUTE" |
| 5622 |
{ return mips_must_initialize_gp_p () ? "#" : ""; } |
| 5623 |
"&& mips_must_initialize_gp_p ()" |
| 5624 |
[(const_int 0)] |
| 5625 |
{ |
| 5626 |
mips_emit_move (operands[0], operands[1]); |
| 5627 |
DONE; |
| 5628 |
} |
| 5629 |
[(set_attr "type" "ghost")]) |
| 5630 |
|
| 5631 |
;; This blockage instruction prevents the gp load from being |
| 5632 |
;; scheduled after an implicit use of gp. It also prevents |
| 5633 |
;; the load from being deleted as dead. |
| 5634 |
(define_insn "loadgp_blockage" |
| 5635 |
[(unspec_volatile [(reg:SI 28)] UNSPEC_BLOCKAGE)] |
| 5636 |
"" |
| 5637 |
"" |
| 5638 |
[(set_attr "type" "ghost")]) |
| 5639 |
|
| 5640 |
;; Initialize $gp for RTP PIC. Operand 0 is the __GOTT_BASE__ symbol |
| 5641 |
;; and operand 1 is the __GOTT_INDEX__ symbol. |
| 5642 |
(define_insn_and_split "loadgp_rtp_<mode>" |
| 5643 |
[(set (match_operand:P 0 "register_operand" "=d") |
| 5644 |
(unspec:P [(match_operand:P 1 "symbol_ref_operand") |
| 5645 |
(match_operand:P 2 "symbol_ref_operand")] |
| 5646 |
UNSPEC_LOADGP))] |
| 5647 |
"mips_current_loadgp_style () == LOADGP_RTP" |
| 5648 |
{ return mips_must_initialize_gp_p () ? "#" : ""; } |
| 5649 |
"&& mips_must_initialize_gp_p ()" |
| 5650 |
[(set (match_dup 0) (high:P (match_dup 3))) |
| 5651 |
(set (match_dup 0) (unspec:P [(match_dup 0) |
| 5652 |
(match_dup 3)] UNSPEC_LOAD_GOT)) |
| 5653 |
(set (match_dup 0) (unspec:P [(match_dup 0) |
| 5654 |
(match_dup 4)] UNSPEC_LOAD_GOT))] |
| 5655 |
{ |
| 5656 |
operands[3] = mips_unspec_address (operands[1], SYMBOL_ABSOLUTE); |
| 5657 |
operands[4] = mips_unspec_address (operands[2], SYMBOL_HALF); |
| 5658 |
} |
| 5659 |
[(set_attr "type" "ghost")]) |
| 5660 |
|
| 5661 |
;; Initialize the global pointer for MIPS16 code. Operand 0 is the |
| 5662 |
;; global pointer and operand 1 is the MIPS16 register that holds |
| 5663 |
;; the required value. |
| 5664 |
(define_insn_and_split "copygp_mips16_<mode>" |
| 5665 |
[(set (match_operand:P 0 "register_operand" "=y") |
| 5666 |
(unspec:P [(match_operand:P 1 "register_operand" "d")] |
| 5667 |
UNSPEC_COPYGP))] |
| 5668 |
"TARGET_MIPS16" |
| 5669 |
{ return mips_must_initialize_gp_p () ? "#" : ""; } |
| 5670 |
"&& mips_must_initialize_gp_p ()" |
| 5671 |
[(set (match_dup 0) (match_dup 1))] |
| 5672 |
"" |
| 5673 |
[(set_attr "type" "ghost")]) |
| 5674 |
|
| 5675 |
;; A placeholder for where the cprestore instruction should go, |
| 5676 |
;; if we decide we need one. Operand 0 and operand 1 are as for |
| 5677 |
;; "cprestore". Operand 2 is a register that holds the gp value. |
| 5678 |
;; |
| 5679 |
;; The "cprestore" pattern requires operand 2 to be pic_offset_table_rtx, |
| 5680 |
;; otherwise any register that holds the correct value will do. |
| 5681 |
(define_insn_and_split "potential_cprestore_<mode>" |
| 5682 |
[(set (match_operand:P 0 "cprestore_save_slot_operand" "=X,X") |
| 5683 |
(unspec:P [(match_operand:P 1 "const_int_operand" "I,i") |
| 5684 |
(match_operand:P 2 "register_operand" "d,d")] |
| 5685 |
UNSPEC_POTENTIAL_CPRESTORE)) |
| 5686 |
(clobber (match_operand:P 3 "scratch_operand" "=X,&d"))] |
| 5687 |
"!TARGET_CPRESTORE_DIRECTIVE || operands[2] == pic_offset_table_rtx" |
| 5688 |
{ return mips_must_initialize_gp_p () ? "#" : ""; } |
| 5689 |
"mips_must_initialize_gp_p ()" |
| 5690 |
[(const_int 0)] |
| 5691 |
{ |
| 5692 |
mips_save_gp_to_cprestore_slot (operands[0], operands[1], |
| 5693 |
operands[2], operands[3]); |
| 5694 |
DONE; |
| 5695 |
} |
| 5696 |
[(set_attr "type" "ghost")]) |
| 5697 |
|
| 5698 |
;; Emit a .cprestore directive, which normally expands to a single store |
| 5699 |
;; instruction. Operand 0 is a (possibly illegitimate) sp-based MEM |
| 5700 |
;; for the cprestore slot. Operand 1 is the offset of the slot from |
| 5701 |
;; the stack pointer. (This is redundant with operand 0, but it makes |
| 5702 |
;; things a little simpler.) |
| 5703 |
(define_insn "cprestore_<mode>" |
| 5704 |
[(set (match_operand:P 0 "cprestore_save_slot_operand" "=X,X") |
| 5705 |
(unspec:P [(match_operand:P 1 "const_int_operand" "I,i") |
| 5706 |
(reg:P 28)] |
| 5707 |
UNSPEC_CPRESTORE))] |
| 5708 |
"TARGET_CPRESTORE_DIRECTIVE" |
| 5709 |
{ |
| 5710 |
if (mips_nomacro.nesting_level > 0 && which_alternative == 1) |
| 5711 |
return ".set\tmacro\;.cprestore\t%1\;.set\tnomacro"; |
| 5712 |
else |
| 5713 |
return ".cprestore\t%1"; |
| 5714 |
} |
| 5715 |
[(set_attr "type" "store") |
| 5716 |
(set_attr "insn_count" "1,3")]) |
| 5717 |
|
| 5718 |
(define_insn "use_cprestore_<mode>" |
| 5719 |
[(set (reg:P CPRESTORE_SLOT_REGNUM) |
| 5720 |
(match_operand:P 0 "cprestore_load_slot_operand"))] |
| 5721 |
"" |
| 5722 |
"" |
| 5723 |
[(set_attr "type" "ghost")]) |
| 5724 |
|
| 5725 |
;; Expand in-line code to clear the instruction cache between operand[0] and |
| 5726 |
;; operand[1]. |
| 5727 |
(define_expand "clear_cache" |
| 5728 |
[(match_operand 0 "pmode_register_operand") |
| 5729 |
(match_operand 1 "pmode_register_operand")] |
| 5730 |
"" |
| 5731 |
" |
| 5732 |
{ |
| 5733 |
if (TARGET_SYNCI) |
| 5734 |
{ |
| 5735 |
mips_expand_synci_loop (operands[0], operands[1]); |
| 5736 |
emit_insn (gen_sync ()); |
| 5737 |
emit_insn (PMODE_INSN (gen_clear_hazard, ())); |
| 5738 |
} |
| 5739 |
else if (mips_cache_flush_func && mips_cache_flush_func[0]) |
| 5740 |
{ |
| 5741 |
rtx len = gen_reg_rtx (Pmode); |
| 5742 |
emit_insn (gen_sub3_insn (len, operands[1], operands[0])); |
| 5743 |
MIPS_ICACHE_SYNC (operands[0], len); |
| 5744 |
} |
| 5745 |
DONE; |
| 5746 |
}") |
| 5747 |
|
| 5748 |
(define_insn "sync" |
| 5749 |
[(unspec_volatile [(const_int 0)] UNSPEC_SYNC)] |
| 5750 |
"GENERATE_SYNC" |
| 5751 |
{ return mips_output_sync (); }) |
| 5752 |
|
| 5753 |
(define_insn "synci" |
| 5754 |
[(unspec_volatile [(match_operand 0 "pmode_register_operand" "d")] |
| 5755 |
UNSPEC_SYNCI)] |
| 5756 |
"TARGET_SYNCI" |
| 5757 |
"synci\t0(%0)") |
| 5758 |
|
| 5759 |
(define_insn "rdhwr_synci_step_<mode>" |
| 5760 |
[(set (match_operand:P 0 "register_operand" "=d") |
| 5761 |
(unspec_volatile:P [(const_int 1)] |
| 5762 |
UNSPEC_RDHWR))] |
| 5763 |
"ISA_HAS_SYNCI" |
| 5764 |
"rdhwr\t%0,$1") |
| 5765 |
|
| 5766 |
(define_insn "clear_hazard_<mode>" |
| 5767 |
[(unspec_volatile [(const_int 0)] UNSPEC_CLEAR_HAZARD) |
| 5768 |
(clobber (reg:P RETURN_ADDR_REGNUM))] |
| 5769 |
"ISA_HAS_SYNCI" |
| 5770 |
{ |
| 5771 |
return "%(%<bal\t1f\n" |
| 5772 |
"\tnop\n" |
| 5773 |
"1:\t<d>addiu\t$31,$31,12\n" |
| 5774 |
"\tjr.hb\t$31\n" |
| 5775 |
"\tnop%>%)"; |
| 5776 |
} |
| 5777 |
[(set_attr "insn_count" "5")]) |
| 5778 |
|
| 5779 |
;; Cache operations for R4000-style caches. |
| 5780 |
(define_insn "mips_cache" |
| 5781 |
[(set (mem:BLK (scratch)) |
| 5782 |
(unspec:BLK [(match_operand:SI 0 "const_int_operand") |
| 5783 |
(match_operand:QI 1 "address_operand" "ZD")] |
| 5784 |
UNSPEC_MIPS_CACHE))] |
| 5785 |
"ISA_HAS_CACHE" |
| 5786 |
"cache\t%X0,%a1" |
| 5787 |
[(set_attr "extended_mips16" "yes")]) |
| 5788 |
|
| 5789 |
;; Similar, but with the operands hard-coded to an R10K cache barrier |
| 5790 |
;; operation. We keep the pattern distinct so that we can identify |
| 5791 |
;; cache operations inserted by -mr10k-cache-barrier=, and so that |
| 5792 |
;; the operation is never inserted into a delay slot. |
| 5793 |
(define_insn "r10k_cache_barrier" |
| 5794 |
[(set (mem:BLK (scratch)) |
| 5795 |
(unspec:BLK [(const_int 0)] UNSPEC_R10K_CACHE_BARRIER))] |
| 5796 |
"ISA_HAS_CACHE" |
| 5797 |
"cache\t0x14,0(%$)" |
| 5798 |
[(set_attr "can_delay" "no")]) |
| 5799 |
|
| 5800 |
;; Block moves, see mips.cc for more details. |
| 5801 |
;; Argument 0 is the destination |
| 5802 |
;; Argument 1 is the source |
| 5803 |
;; Argument 2 is the length |
| 5804 |
;; Argument 3 is the alignment |
| 5805 |
|
| 5806 |
(define_expand "cpymemsi" |
| 5807 |
[(parallel [(set (match_operand:BLK 0 "general_operand") |
| 5808 |
(match_operand:BLK 1 "general_operand")) |
| 5809 |
(use (match_operand:SI 2 "")) |
| 5810 |
(use (match_operand:SI 3 "const_int_operand"))])] |
| 5811 |
"!TARGET_MIPS16 && !TARGET_MEMCPY" |
| 5812 |
{ |
| 5813 |
if (mips_expand_block_move (operands[0], operands[1], operands[2])) |
| 5814 |
DONE; |
| 5815 |
else |
| 5816 |
FAIL; |
| 5817 |
}) |
| 5818 |
|
| 5819 |
;; |
| 5820 |
;; .................... |
| 5821 |
;; |
| 5822 |
;; SHIFTS |
| 5823 |
;; |
| 5824 |
;; .................... |
| 5825 |
|
| 5826 |
(define_expand "<optab><mode>3" |
| 5827 |
[(set (match_operand:GPR 0 "register_operand") |
| 5828 |
(any_shift:GPR (match_operand:GPR 1 "register_operand") |
| 5829 |
(match_operand:SI 2 "arith_operand")))] |
| 5830 |
"" |
| 5831 |
{ |
| 5832 |
/* On the mips16, a shift of more than 8 is a four byte instruction, |
| 5833 |
so, for a shift between 8 and 16, it is just as fast to do two |
| 5834 |
shifts of 8 or less. If there is a lot of shifting going on, we |
| 5835 |
may win in CSE. Otherwise combine will put the shifts back |
| 5836 |
together again. This can be called by mips_function_arg, so we must |
| 5837 |
be careful not to allocate a new register if we've reached the |
| 5838 |
reload pass. */ |
| 5839 |
if (TARGET_MIPS16 |
| 5840 |
&& optimize |
| 5841 |
&& CONST_INT_P (operands[2]) |
| 5842 |
&& INTVAL (operands[2]) > 8 |
| 5843 |
&& INTVAL (operands[2]) <= 16 |
| 5844 |
&& !reload_in_progress |
| 5845 |
&& !reload_completed) |
| 5846 |
{ |
| 5847 |
rtx temp = gen_reg_rtx (<MODE>mode); |
| 5848 |
|
| 5849 |
emit_insn (gen_<optab><mode>3 (temp, operands[1], GEN_INT (8))); |
| 5850 |
emit_insn (gen_<optab><mode>3 (operands[0], temp, |
| 5851 |
GEN_INT (INTVAL (operands[2]) - 8))); |
| 5852 |
DONE; |
| 5853 |
} |
| 5854 |
}) |
| 5855 |
|
| 5856 |
(define_insn "*<optab><mode>3" |
| 5857 |
[(set (match_operand:GPR 0 "register_operand" "=!u,d") |
| 5858 |
(any_shift:GPR (match_operand:GPR 1 "register_operand" "!u,d") |
| 5859 |
(match_operand:SI 2 "arith_operand" "Uib3,dI")))] |
| 5860 |
"!TARGET_MIPS16" |
| 5861 |
{ |
| 5862 |
if (CONST_INT_P (operands[2])) |
| 5863 |
operands[2] = GEN_INT (INTVAL (operands[2]) |
| 5864 |
& (GET_MODE_BITSIZE (<MODE>mode) - 1)); |
| 5865 |
|
| 5866 |
return "<d><insn>\t%0,%1,%2"; |
| 5867 |
} |
| 5868 |
[(set_attr "type" "shift") |
| 5869 |
(set_attr "compression" "<shift_compression>,none") |
| 5870 |
(set_attr "mode" "<MODE>")]) |
| 5871 |
|
| 5872 |
(define_insn "*<optab>si3_extend" |
| 5873 |
[(set (match_operand:DI 0 "register_operand" "=d") |
| 5874 |
(sign_extend:DI |
| 5875 |
(any_shift:SI (match_operand:SI 1 "register_operand" "d") |
| 5876 |
(match_operand:SI 2 "arith_operand" "dI"))))] |
| 5877 |
"TARGET_64BIT && !TARGET_MIPS16" |
| 5878 |
{ |
| 5879 |
if (CONST_INT_P (operands[2])) |
| 5880 |
operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f); |
| 5881 |
|
| 5882 |
return "<insn>\t%0,%1,%2"; |
| 5883 |
} |
| 5884 |
[(set_attr "type" "shift") |
| 5885 |
(set_attr "mode" "SI")]) |
| 5886 |
|
| 5887 |
(define_insn "*<optab>si3_mips16" |
| 5888 |
[(set (match_operand:SI 0 "register_operand" "=d,d,d") |
| 5889 |
(any_shift:SI (match_operand:SI 1 "register_operand" "0,d,d") |
| 5890 |
(match_operand:SI 2 "arith_operand" "d,Uib3,I")))] |
| 5891 |
"TARGET_MIPS16" |
| 5892 |
{ |
| 5893 |
if (which_alternative == 0) |
| 5894 |
return "<insn>\t%0,%2"; |
| 5895 |
|
| 5896 |
operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f); |
| 5897 |
return "<insn>\t%0,%1,%2"; |
| 5898 |
} |
| 5899 |
[(set_attr "type" "shift") |
| 5900 |
(set_attr "mode" "SI") |
| 5901 |
(set_attr "extended_mips16" "no,no,yes")]) |
| 5902 |
|
| 5903 |
(define_insn "<GPR:d>lsa" |
| 5904 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 5905 |
(plus:GPR (ashift:GPR (match_operand:GPR 1 "register_operand" "d") |
| 5906 |
(match_operand 2 "const_immlsa_operand" "")) |
| 5907 |
(match_operand:GPR 3 "register_operand" "d")))] |
| 5908 |
"ISA_HAS_<GPR:D>LSA" |
| 5909 |
"<GPR:d>lsa\t%0,%1,%3,%2" |
| 5910 |
[(set_attr "type" "arith") |
| 5911 |
(set_attr "mode" "<GPR:MODE>")]) |
| 5912 |
|
| 5913 |
;; We need separate DImode MIPS16 patterns because of the irregularity |
| 5914 |
;; of right shifts. |
| 5915 |
(define_insn "*ashldi3_mips16" |
| 5916 |
[(set (match_operand:DI 0 "register_operand" "=d,d,d") |
| 5917 |
(ashift:DI (match_operand:DI 1 "register_operand" "0,d,d") |
| 5918 |
(match_operand:SI 2 "arith_operand" "d,Uib3,I")))] |
| 5919 |
"TARGET_64BIT && TARGET_MIPS16" |
| 5920 |
{ |
| 5921 |
if (which_alternative == 0) |
| 5922 |
return "dsll\t%0,%2"; |
| 5923 |
|
| 5924 |
operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f); |
| 5925 |
return "dsll\t%0,%1,%2"; |
| 5926 |
} |
| 5927 |
[(set_attr "type" "shift") |
| 5928 |
(set_attr "mode" "DI") |
| 5929 |
(set_attr "extended_mips16" "no,no,yes")]) |
| 5930 |
|
| 5931 |
(define_insn "*ashrdi3_mips16" |
| 5932 |
[(set (match_operand:DI 0 "register_operand" "=d,d,d") |
| 5933 |
(ashiftrt:DI (match_operand:DI 1 "register_operand" "0,0,0") |
| 5934 |
(match_operand:SI 2 "arith_operand" "d,Uib3,I")))] |
| 5935 |
"TARGET_64BIT && TARGET_MIPS16" |
| 5936 |
{ |
| 5937 |
if (CONST_INT_P (operands[2])) |
| 5938 |
operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f); |
| 5939 |
|
| 5940 |
return "dsra\t%0,%2"; |
| 5941 |
} |
| 5942 |
[(set_attr "type" "shift") |
| 5943 |
(set_attr "mode" "DI") |
| 5944 |
(set_attr "extended_mips16" "no,no,yes")]) |
| 5945 |
|
| 5946 |
(define_insn "*lshrdi3_mips16" |
| 5947 |
[(set (match_operand:DI 0 "register_operand" "=d,d,d") |
| 5948 |
(lshiftrt:DI (match_operand:DI 1 "register_operand" "0,0,0") |
| 5949 |
(match_operand:SI 2 "arith_operand" "d,Uib3,I")))] |
| 5950 |
"TARGET_64BIT && TARGET_MIPS16" |
| 5951 |
{ |
| 5952 |
if (CONST_INT_P (operands[2])) |
| 5953 |
operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f); |
| 5954 |
|
| 5955 |
return "dsrl\t%0,%2"; |
| 5956 |
} |
| 5957 |
[(set_attr "type" "shift") |
| 5958 |
(set_attr "mode" "DI") |
| 5959 |
(set_attr "extended_mips16" "no,no,yes")]) |
| 5960 |
|
| 5961 |
;; On the mips16, we can split a 4 byte shift into 2 2 byte shifts. |
| 5962 |
|
| 5963 |
(define_split |
| 5964 |
[(set (match_operand:GPR 0 "d_operand") |
| 5965 |
(any_shift:GPR (match_operand:GPR 1 "d_operand") |
| 5966 |
(match_operand:GPR 2 "const_int_operand")))] |
| 5967 |
"TARGET_MIPS16 && reload_completed && !TARGET_DEBUG_D_MODE |
| 5968 |
&& INTVAL (operands[2]) > 8 |
| 5969 |
&& INTVAL (operands[2]) <= 16" |
| 5970 |
[(set (match_dup 0) (any_shift:GPR (match_dup 1) (const_int 8))) |
| 5971 |
(set (match_dup 0) (any_shift:GPR (match_dup 0) (match_dup 2)))] |
| 5972 |
{ operands[2] = GEN_INT (INTVAL (operands[2]) - 8); }) |
| 5973 |
|
| 5974 |
;; If we load a byte on the mips16 as a bitfield, the resulting |
| 5975 |
;; sequence of instructions is too complicated for combine, because it |
| 5976 |
;; involves four instructions: a load, a shift, a constant load into a |
| 5977 |
;; register, and an and (the key problem here is that the mips16 does |
| 5978 |
;; not have and immediate). We recognize a shift of a load in order |
| 5979 |
;; to make it simple enough for combine to understand. |
| 5980 |
;; |
| 5981 |
;; The instruction count here is the worst case. |
| 5982 |
(define_insn_and_split "" |
| 5983 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 5984 |
(lshiftrt:SI (match_operand:SI 1 "memory_operand" "m") |
| 5985 |
(match_operand:SI 2 "immediate_operand" "I")))] |
| 5986 |
"TARGET_MIPS16" |
| 5987 |
"#" |
| 5988 |
"&& 1" |
| 5989 |
[(set (match_dup 0) (match_dup 1)) |
| 5990 |
(set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))] |
| 5991 |
"" |
| 5992 |
[(set_attr "type" "load") |
| 5993 |
(set_attr "mode" "SI") |
| 5994 |
(set (attr "insn_count") |
| 5995 |
(symbol_ref "mips_load_store_insns (operands[1], insn) + 2"))]) |
| 5996 |
|
| 5997 |
(define_insn "rotr<mode>3" |
| 5998 |
[(set (match_operand:GPR 0 "register_operand" "=d") |
| 5999 |
(rotatert:GPR (match_operand:GPR 1 "register_operand" "d") |
| 6000 |
(match_operand:SI 2 "arith_operand" "dI")))] |
| 6001 |
"ISA_HAS_ROR" |
| 6002 |
{ |
| 6003 |
if (CONST_INT_P (operands[2])) |
| 6004 |
operands[2] = GEN_INT (INTVAL (operands[2]) |
| 6005 |
& (GET_MODE_BITSIZE (<MODE>mode) - 1)); |
| 6006 |
|
| 6007 |
return "<d>ror\t%0,%1,%2"; |
| 6008 |
} |
| 6009 |
[(set_attr "type" "shift") |
| 6010 |
(set_attr "mode" "<MODE>")]) |
| 6011 |
|
| 6012 |
(define_insn "bswaphi2" |
| 6013 |
[(set (match_operand:HI 0 "register_operand" "=d") |
| 6014 |
(bswap:HI (match_operand:HI 1 "register_operand" "d")))] |
| 6015 |
"ISA_HAS_WSBH" |
| 6016 |
"wsbh\t%0,%1" |
| 6017 |
[(set_attr "type" "shift")]) |
| 6018 |
|
| 6019 |
(define_insn_and_split "bswapsi2" |
| 6020 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 6021 |
(bswap:SI (match_operand:SI 1 "register_operand" "d")))] |
| 6022 |
"ISA_HAS_WSBH && ISA_HAS_ROR" |
| 6023 |
"#" |
| 6024 |
"&& 1" |
| 6025 |
[(set (match_dup 0) (unspec:SI [(match_dup 1)] UNSPEC_WSBH)) |
| 6026 |
(set (match_dup 0) (rotatert:SI (match_dup 0) (const_int 16)))] |
| 6027 |
"" |
| 6028 |
[(set_attr "insn_count" "2")]) |
| 6029 |
|
| 6030 |
(define_insn_and_split "bswapdi2" |
| 6031 |
[(set (match_operand:DI 0 "register_operand" "=d") |
| 6032 |
(bswap:DI (match_operand:DI 1 "register_operand" "d")))] |
| 6033 |
"TARGET_64BIT && ISA_HAS_WSBH" |
| 6034 |
"#" |
| 6035 |
"&& 1" |
| 6036 |
[(set (match_dup 0) (unspec:DI [(match_dup 1)] UNSPEC_DSBH)) |
| 6037 |
(set (match_dup 0) (unspec:DI [(match_dup 0)] UNSPEC_DSHD))] |
| 6038 |
"" |
| 6039 |
[(set_attr "insn_count" "2")]) |
| 6040 |
|
| 6041 |
(define_insn "wsbh" |
| 6042 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 6043 |
(unspec:SI [(match_operand:SI 1 "register_operand" "d")] UNSPEC_WSBH))] |
| 6044 |
"ISA_HAS_WSBH" |
| 6045 |
"wsbh\t%0,%1" |
| 6046 |
[(set_attr "type" "shift")]) |
| 6047 |
|
| 6048 |
(define_insn "dsbh" |
| 6049 |
[(set (match_operand:DI 0 "register_operand" "=d") |
| 6050 |
(unspec:DI [(match_operand:DI 1 "register_operand" "d")] UNSPEC_DSBH))] |
| 6051 |
"TARGET_64BIT && ISA_HAS_WSBH" |
| 6052 |
"dsbh\t%0,%1" |
| 6053 |
[(set_attr "type" "shift")]) |
| 6054 |
|
| 6055 |
(define_insn "dshd" |
| 6056 |
[(set (match_operand:DI 0 "register_operand" "=d") |
| 6057 |
(unspec:DI [(match_operand:DI 1 "register_operand" "d")] UNSPEC_DSHD))] |
| 6058 |
"TARGET_64BIT && ISA_HAS_WSBH" |
| 6059 |
"dshd\t%0,%1" |
| 6060 |
[(set_attr "type" "shift")]) |
| 6061 |
|
| 6062 |
;; |
| 6063 |
;; .................... |
| 6064 |
;; |
| 6065 |
;; CONDITIONAL BRANCHES |
| 6066 |
;; |
| 6067 |
;; .................... |
| 6068 |
|
| 6069 |
;; Conditional branches on floating-point equality tests. |
| 6070 |
|
| 6071 |
(define_insn "*branch_fp_<mode>" |
| 6072 |
[(set (pc) |
| 6073 |
(if_then_else |
| 6074 |
(match_operator 1 "equality_operator" |
| 6075 |
[(match_operand:FPCC 2 "register_operand" "<reg>") |
| 6076 |
(const_int 0)]) |
| 6077 |
(label_ref (match_operand 0 "" "")) |
| 6078 |
(pc)))] |
| 6079 |
"TARGET_HARD_FLOAT" |
| 6080 |
{ |
| 6081 |
return mips_output_conditional_branch (insn, operands, |
| 6082 |
MIPS_BRANCH ("b%F1", "%Z2%0"), |
| 6083 |
MIPS_BRANCH ("b%W1", "%Z2%0")); |
| 6084 |
} |
| 6085 |
[(set_attr "type" "branch")]) |
| 6086 |
|
| 6087 |
(define_insn "*branch_fp_inverted_<mode>" |
| 6088 |
[(set (pc) |
| 6089 |
(if_then_else |
| 6090 |
(match_operator 1 "equality_operator" |
| 6091 |
[(match_operand:FPCC 2 "register_operand" "<reg>") |
| 6092 |
(const_int 0)]) |
| 6093 |
(pc) |
| 6094 |
(label_ref (match_operand 0 "" ""))))] |
| 6095 |
"TARGET_HARD_FLOAT" |
| 6096 |
{ |
| 6097 |
return mips_output_conditional_branch (insn, operands, |
| 6098 |
MIPS_BRANCH ("b%W1", "%Z2%0"), |
| 6099 |
MIPS_BRANCH ("b%F1", "%Z2%0")); |
| 6100 |
} |
| 6101 |
[(set_attr "type" "branch")]) |
| 6102 |
|
| 6103 |
;; Conditional branches on ordered comparisons with zero. |
| 6104 |
|
| 6105 |
(define_insn "*branch_order<mode>" |
| 6106 |
[(set (pc) |
| 6107 |
(if_then_else |
| 6108 |
(match_operator 1 "order_operator" |
| 6109 |
[(match_operand:GPR 2 "register_operand" "d,d") |
| 6110 |
(match_operand:GPR 3 "reg_or_0_operand" "J,d")]) |
| 6111 |
(label_ref (match_operand 0 "" "")) |
| 6112 |
(pc)))] |
| 6113 |
"!TARGET_MIPS16" |
| 6114 |
{ return mips_output_order_conditional_branch (insn, operands, false); } |
| 6115 |
[(set_attr "type" "branch") |
| 6116 |
(set_attr "compact_form" "maybe,always") |
| 6117 |
(set_attr "hazard" "forbidden_slot")]) |
| 6118 |
|
| 6119 |
(define_insn "*branch_order<mode>_inverted" |
| 6120 |
[(set (pc) |
| 6121 |
(if_then_else |
| 6122 |
(match_operator 1 "order_operator" |
| 6123 |
[(match_operand:GPR 2 "register_operand" "d,d") |
| 6124 |
(match_operand:GPR 3 "reg_or_0_operand" "J,d")]) |
| 6125 |
(pc) |
| 6126 |
(label_ref (match_operand 0 "" ""))))] |
| 6127 |
"!TARGET_MIPS16" |
| 6128 |
{ return mips_output_order_conditional_branch (insn, operands, true); } |
| 6129 |
[(set_attr "type" "branch") |
| 6130 |
(set_attr "compact_form" "maybe,always") |
| 6131 |
(set_attr "hazard" "forbidden_slot")]) |
| 6132 |
|
| 6133 |
;; Conditional branch on equality comparison. |
| 6134 |
|
| 6135 |
(define_insn "*branch_equality<mode>" |
| 6136 |
[(set (pc) |
| 6137 |
(if_then_else |
| 6138 |
(match_operator 1 "equality_operator" |
| 6139 |
[(match_operand:GPR 2 "register_operand" "d") |
| 6140 |
(match_operand:GPR 3 "reg_or_0_operand" "dJ")]) |
| 6141 |
(label_ref (match_operand 0 "" "")) |
| 6142 |
(pc)))] |
| 6143 |
"!TARGET_MIPS16" |
| 6144 |
{ return mips_output_equal_conditional_branch (insn, operands, false); } |
| 6145 |
[(set_attr "type" "branch") |
| 6146 |
(set_attr "compact_form" "maybe") |
| 6147 |
(set_attr "hazard" "forbidden_slot")]) |
| 6148 |
|
| 6149 |
(define_insn "*branch_equality<mode>_inverted" |
| 6150 |
[(set (pc) |
| 6151 |
(if_then_else |
| 6152 |
(match_operator 1 "equality_operator" |
| 6153 |
[(match_operand:GPR 2 "register_operand" "d") |
| 6154 |
(match_operand:GPR 3 "reg_or_0_operand" "dJ")]) |
| 6155 |
(pc) |
| 6156 |
(label_ref (match_operand 0 "" ""))))] |
| 6157 |
"!TARGET_MIPS16" |
| 6158 |
{ return mips_output_equal_conditional_branch (insn, operands, true); } |
| 6159 |
[(set_attr "type" "branch") |
| 6160 |
(set_attr "compact_form" "maybe") |
| 6161 |
(set_attr "hazard" "forbidden_slot")]) |
| 6162 |
|
| 6163 |
;; MIPS16 branches |
| 6164 |
|
| 6165 |
(define_insn "*branch_equality<mode>_mips16" |
| 6166 |
[(set (pc) |
| 6167 |
(if_then_else |
| 6168 |
(match_operator 1 "equality_operator" |
| 6169 |
[(match_operand:GPR 2 "register_operand" "d,t") |
| 6170 |
(const_int 0)]) |
| 6171 |
(label_ref (match_operand 0 "" "")) |
| 6172 |
(pc)))] |
| 6173 |
"TARGET_MIPS16" |
| 6174 |
"@ |
| 6175 |
b%C1z\t%2,%0 |
| 6176 |
bt%C1z\t%0" |
| 6177 |
[(set_attr "type" "branch")]) |
| 6178 |
|
| 6179 |
(define_insn "*branch_equality<mode>_mips16_inverted" |
| 6180 |
[(set (pc) |
| 6181 |
(if_then_else |
| 6182 |
(match_operator 1 "equality_operator" |
| 6183 |
[(match_operand:GPR 2 "register_operand" "d,t") |
| 6184 |
(const_int 0)]) |
| 6185 |
(pc) |
| 6186 |
(label_ref (match_operand 0 "" ""))))] |
| 6187 |
"TARGET_MIPS16" |
| 6188 |
"@ |
| 6189 |
b%N1z\t%2,%0 |
| 6190 |
bt%N1z\t%0" |
| 6191 |
[(set_attr "type" "branch")]) |
| 6192 |
|
| 6193 |
(define_expand "cbranch<mode>4" |
| 6194 |
[(set (pc) |
| 6195 |
(if_then_else (match_operator 0 "comparison_operator" |
| 6196 |
[(match_operand:GPR 1 "register_operand") |
| 6197 |
(match_operand:GPR 2 "nonmemory_operand")]) |
| 6198 |
(label_ref (match_operand 3 "")) |
| 6199 |
(pc)))] |
| 6200 |
"" |
| 6201 |
{ |
| 6202 |
mips_expand_conditional_branch (operands); |
| 6203 |
DONE; |
| 6204 |
}) |
| 6205 |
|
| 6206 |
(define_expand "cbranch<mode>4" |
| 6207 |
[(set (pc) |
| 6208 |
(if_then_else (match_operator 0 "comparison_operator" |
| 6209 |
[(match_operand:SCALARF 1 "register_operand") |
| 6210 |
(match_operand:SCALARF 2 "register_operand")]) |
| 6211 |
(label_ref (match_operand 3 "")) |
| 6212 |
(pc)))] |
| 6213 |
"" |
| 6214 |
{ |
| 6215 |
mips_expand_conditional_branch (operands); |
| 6216 |
DONE; |
| 6217 |
}) |
| 6218 |
|
| 6219 |
;; Used to implement built-in functions. |
| 6220 |
(define_expand "condjump" |
| 6221 |
[(set (pc) |
| 6222 |
(if_then_else (match_operand 0) |
| 6223 |
(label_ref (match_operand 1)) |
| 6224 |
(pc)))]) |
| 6225 |
|
| 6226 |
;; Branch if bit is set/clear. |
| 6227 |
|
| 6228 |
(define_insn "*branch_bit<bbv><mode>" |
| 6229 |
[(set (pc) |
| 6230 |
(if_then_else |
| 6231 |
(equality_op (zero_extract:GPR |
| 6232 |
(match_operand:GPR 1 "register_operand" "d") |
| 6233 |
(const_int 1) |
| 6234 |
(match_operand 2 "const_int_operand" "")) |
| 6235 |
(const_int 0)) |
| 6236 |
(label_ref (match_operand 0 "")) |
| 6237 |
(pc)))] |
| 6238 |
"ISA_HAS_BBIT && UINTVAL (operands[2]) < GET_MODE_BITSIZE (<MODE>mode)" |
| 6239 |
{ |
| 6240 |
return |
| 6241 |
mips_output_conditional_branch (insn, operands, |
| 6242 |
MIPS_BRANCH ("bbit<bbv>", "%1,%2,%0"), |
| 6243 |
MIPS_BRANCH ("bbit<bbinv>", "%1,%2,%0")); |
| 6244 |
} |
| 6245 |
[(set_attr "type" "branch") |
| 6246 |
(set_attr "branch_likely" "no")]) |
| 6247 |
|
| 6248 |
(define_insn "*branch_bit<bbv><mode>_inverted" |
| 6249 |
[(set (pc) |
| 6250 |
(if_then_else |
| 6251 |
(equality_op (zero_extract:GPR |
| 6252 |
(match_operand:GPR 1 "register_operand" "d") |
| 6253 |
(const_int 1) |
| 6254 |
(match_operand 2 "const_int_operand" "")) |
| 6255 |
(const_int 0)) |
| 6256 |
(pc) |
| 6257 |
(label_ref (match_operand 0 ""))))] |
| 6258 |
"ISA_HAS_BBIT && UINTVAL (operands[2]) < GET_MODE_BITSIZE (<MODE>mode)" |
| 6259 |
{ |
| 6260 |
return |
| 6261 |
mips_output_conditional_branch (insn, operands, |
| 6262 |
MIPS_BRANCH ("bbit<bbinv>", "%1,%2,%0"), |
| 6263 |
MIPS_BRANCH ("bbit<bbv>", "%1,%2,%0")); |
| 6264 |
} |
| 6265 |
[(set_attr "type" "branch") |
| 6266 |
(set_attr "branch_likely" "no")]) |
| 6267 |
|
| 6268 |
;; |
| 6269 |
;; .................... |
| 6270 |
;; |
| 6271 |
;; SETTING A REGISTER FROM A COMPARISON |
| 6272 |
;; |
| 6273 |
;; .................... |
| 6274 |
|
| 6275 |
;; Destination is always set in SI mode. |
| 6276 |
|
| 6277 |
(define_expand "cstore<mode>4" |
| 6278 |
[(set (match_operand:SI 0 "register_operand") |
| 6279 |
(match_operator:SI 1 "mips_cstore_operator" |
| 6280 |
[(match_operand:GPR 2 "register_operand") |
| 6281 |
(match_operand:GPR 3 "nonmemory_operand")]))] |
| 6282 |
"" |
| 6283 |
{ |
| 6284 |
mips_expand_scc (operands); |
| 6285 |
DONE; |
| 6286 |
}) |
| 6287 |
|
| 6288 |
(define_insn "*seq_zero_<GPR:mode><GPR2:mode>" |
| 6289 |
[(set (match_operand:GPR2 0 "register_operand" "=d") |
| 6290 |
(eq:GPR2 (match_operand:GPR 1 "register_operand" "d") |
| 6291 |
(const_int 0)))] |
| 6292 |
"!TARGET_MIPS16 && !ISA_HAS_SEQ_SNE" |
| 6293 |
"sltu\t%0,%1,1" |
| 6294 |
[(set_attr "type" "slt") |
| 6295 |
(set_attr "mode" "<GPR:MODE>")]) |
| 6296 |
|
| 6297 |
(define_insn "*seq_zero_<GPR:mode><GPR2:mode>_mips16" |
| 6298 |
[(set (match_operand:GPR2 0 "register_operand" "=t") |
| 6299 |
(eq:GPR2 (match_operand:GPR 1 "register_operand" "d") |
| 6300 |
(const_int 0)))] |
| 6301 |
"TARGET_MIPS16 && !ISA_HAS_SEQ_SNE" |
| 6302 |
"sltu\t%1,1" |
| 6303 |
[(set_attr "type" "slt") |
| 6304 |
(set_attr "mode" "<GPR:MODE>")]) |
| 6305 |
|
| 6306 |
;; Generate sltiu unless using seq results in better code. |
| 6307 |
(define_insn "*seq_<GPR:mode><GPR2:mode>_seq" |
| 6308 |
[(set (match_operand:GPR2 0 "register_operand" "=d,d,d") |
| 6309 |
(eq:GPR2 (match_operand:GPR 1 "register_operand" "%d,d,d") |
| 6310 |
(match_operand:GPR 2 "reg_imm10_operand" "d,J,YB")))] |
| 6311 |
"ISA_HAS_SEQ_SNE" |
| 6312 |
"@ |
| 6313 |
seq\t%0,%1,%2 |
| 6314 |
sltiu\t%0,%1,1 |
| 6315 |
seqi\t%0,%1,%2" |
| 6316 |
[(set_attr "type" "slt") |
| 6317 |
(set_attr "mode" "<GPR:MODE>")]) |
| 6318 |
|
| 6319 |
(define_insn "*sne_zero_<GPR:mode><GPR2:mode>" |
| 6320 |
[(set (match_operand:GPR2 0 "register_operand" "=d") |
| 6321 |
(ne:GPR2 (match_operand:GPR 1 "register_operand" "d") |
| 6322 |
(const_int 0)))] |
| 6323 |
"!TARGET_MIPS16 && !ISA_HAS_SEQ_SNE" |
| 6324 |
"sltu\t%0,%.,%1" |
| 6325 |
[(set_attr "type" "slt") |
| 6326 |
(set_attr "mode" "<GPR:MODE>")]) |
| 6327 |
|
| 6328 |
;; Generate sltu unless using sne results in better code. |
| 6329 |
(define_insn "*sne_<GPR:mode><GPR2:mode>_sne" |
| 6330 |
[(set (match_operand:GPR2 0 "register_operand" "=d,d,d") |
| 6331 |
(ne:GPR2 (match_operand:GPR 1 "register_operand" "%d,d,d") |
| 6332 |
(match_operand:GPR 2 "reg_imm10_operand" "d,J,YB")))] |
| 6333 |
"ISA_HAS_SEQ_SNE" |
| 6334 |
"@ |
| 6335 |
sne\t%0,%1,%2 |
| 6336 |
sltu\t%0,%.,%1 |
| 6337 |
snei\t%0,%1,%2" |
| 6338 |
[(set_attr "type" "slt") |
| 6339 |
(set_attr "mode" "<GPR:MODE>")]) |
| 6340 |
|
| 6341 |
(define_insn "*sgt<u>_<GPR:mode><GPR2:mode>" |
| 6342 |
[(set (match_operand:GPR2 0 "register_operand" "=d") |
| 6343 |
(any_gt:GPR2 (match_operand:GPR 1 "register_operand" "d") |
| 6344 |
(match_operand:GPR 2 "reg_or_0_operand" "dJ")))] |
| 6345 |
"!TARGET_MIPS16" |
| 6346 |
"slt<u>\t%0,%z2,%1" |
| 6347 |
[(set_attr "type" "slt") |
| 6348 |
(set_attr "mode" "<GPR:MODE>")]) |
| 6349 |
|
| 6350 |
(define_insn "*sgt<u>_<GPR:mode><GPR2:mode>_mips16" |
| 6351 |
[(set (match_operand:GPR2 0 "register_operand" "=t") |
| 6352 |
(any_gt:GPR2 (match_operand:GPR 1 "register_operand" "d") |
| 6353 |
(match_operand:GPR 2 "register_operand" "d")))] |
| 6354 |
"TARGET_MIPS16" |
| 6355 |
"slt<u>\t%2,%1" |
| 6356 |
[(set_attr "type" "slt") |
| 6357 |
(set_attr "mode" "<GPR:MODE>")]) |
| 6358 |
|
| 6359 |
(define_insn "*sge<u>_<GPR:mode><GPR2:mode>" |
| 6360 |
[(set (match_operand:GPR2 0 "register_operand" "=d") |
| 6361 |
(any_ge:GPR2 (match_operand:GPR 1 "register_operand" "d") |
| 6362 |
(const_int 1)))] |
| 6363 |
"!TARGET_MIPS16" |
| 6364 |
"slt<u>\t%0,%.,%1" |
| 6365 |
[(set_attr "type" "slt") |
| 6366 |
(set_attr "mode" "<GPR:MODE>")]) |
| 6367 |
|
| 6368 |
(define_insn "*slt<u>_<GPR:mode><GPR2:mode>" |
| 6369 |
[(set (match_operand:GPR2 0 "register_operand" "=d") |
| 6370 |
(any_lt:GPR2 (match_operand:GPR 1 "register_operand" "d") |
| 6371 |
(match_operand:GPR 2 "arith_operand" "dI")))] |
| 6372 |
"!TARGET_MIPS16" |
| 6373 |
"slt<u>\t%0,%1,%2" |
| 6374 |
[(set_attr "type" "slt") |
| 6375 |
(set_attr "mode" "<GPR:MODE>")]) |
| 6376 |
|
| 6377 |
(define_insn "*slt<u>_<GPR:mode><GPR2:mode>_mips16" |
| 6378 |
[(set (match_operand:GPR2 0 "register_operand" "=t,t,t") |
| 6379 |
(any_lt:GPR2 (match_operand:GPR 1 "register_operand" "d,d,d") |
| 6380 |
(match_operand:GPR 2 "arith_operand" "d,Uub8,I")))] |
| 6381 |
"TARGET_MIPS16" |
| 6382 |
"slt<u>\t%1,%2" |
| 6383 |
[(set_attr "type" "slt") |
| 6384 |
(set_attr "mode" "<GPR:MODE>") |
| 6385 |
(set_attr "extended_mips16" "no,no,yes")]) |
| 6386 |
|
| 6387 |
(define_insn "*sle<u>_<GPR:mode><GPR2:mode>" |
| 6388 |
[(set (match_operand:GPR2 0 "register_operand" "=d") |
| 6389 |
(any_le:GPR2 (match_operand:GPR 1 "register_operand" "d") |
| 6390 |
(match_operand:GPR 2 "sle_operand" "")))] |
| 6391 |
"!TARGET_MIPS16" |
| 6392 |
{ |
| 6393 |
operands[2] = GEN_INT (INTVAL (operands[2]) + 1); |
| 6394 |
return "slt<u>\t%0,%1,%2"; |
| 6395 |
} |
| 6396 |
[(set_attr "type" "slt") |
| 6397 |
(set_attr "mode" "<GPR:MODE>")]) |
| 6398 |
|
| 6399 |
(define_insn "*sle<u>_<GPR:mode><GPR2:mode>_mips16" |
| 6400 |
[(set (match_operand:GPR2 0 "register_operand" "=t,t") |
| 6401 |
(any_le:GPR2 (match_operand:GPR 1 "register_operand" "d,d") |
| 6402 |
(match_operand:GPR 2 "sle_operand" "Udb8,i")))] |
| 6403 |
"TARGET_MIPS16" |
| 6404 |
{ |
| 6405 |
operands[2] = GEN_INT (INTVAL (operands[2]) + 1); |
| 6406 |
return "slt<u>\t%1,%2"; |
| 6407 |
} |
| 6408 |
[(set_attr "type" "slt") |
| 6409 |
(set_attr "mode" "<GPR:MODE>") |
| 6410 |
(set_attr "extended_mips16" "no,yes")]) |
| 6411 |
|
| 6412 |
;; |
| 6413 |
;; .................... |
| 6414 |
;; |
| 6415 |
;; FLOATING POINT COMPARISONS |
| 6416 |
;; |
| 6417 |
;; .................... |
| 6418 |
|
| 6419 |
(define_insn "s<code>_<SCALARF:mode>_using_<FPCC:mode>" |
| 6420 |
[(set (match_operand:FPCC 0 "register_operand" "=<reg>") |
| 6421 |
(fcond:FPCC (match_operand:SCALARF 1 "register_operand" "f") |
| 6422 |
(match_operand:SCALARF 2 "register_operand" "f")))] |
| 6423 |
"" |
| 6424 |
{ |
| 6425 |
return mips_output_compare ("<fpcmp>", "<fcond>", "<fmt>", "<FPCC:mode>", false); |
| 6426 |
} |
| 6427 |
[(set_attr "type" "fcmp") |
| 6428 |
(set_attr "mode" "FPSW")]) |
| 6429 |
|
| 6430 |
(define_insn "s<code>_<SCALARF:mode>_using_<FPCC:mode>" |
| 6431 |
[(set (match_operand:FPCC 0 "register_operand" "=<reg>") |
| 6432 |
(swapped_fcond:FPCC (match_operand:SCALARF 1 "register_operand" "f") |
| 6433 |
(match_operand:SCALARF 2 "register_operand" "f")))] |
| 6434 |
"" |
| 6435 |
{ |
| 6436 |
return mips_output_compare ("<fpcmp>", "<swapped_fcond>", "<fmt>", "<FPCC:mode>", true); |
| 6437 |
} |
| 6438 |
[(set_attr "type" "fcmp") |
| 6439 |
(set_attr "mode" "FPSW")]) |
| 6440 |
|
| 6441 |
;; |
| 6442 |
;; .................... |
| 6443 |
;; |
| 6444 |
;; UNCONDITIONAL BRANCHES |
| 6445 |
;; |
| 6446 |
;; .................... |
| 6447 |
|
| 6448 |
;; Unconditional branches. |
| 6449 |
|
| 6450 |
(define_expand "jump" |
| 6451 |
[(set (pc) |
| 6452 |
(label_ref (match_operand 0)))]) |
| 6453 |
|
| 6454 |
(define_insn "*jump_absolute" |
| 6455 |
[(set (pc) |
| 6456 |
(label_ref (match_operand 0)))] |
| 6457 |
"!TARGET_MIPS16 && TARGET_ABSOLUTE_JUMPS" |
| 6458 |
{ |
| 6459 |
if (get_attr_length (insn) <= 8) |
| 6460 |
{ |
| 6461 |
if (TARGET_CB_MAYBE) |
| 6462 |
return MIPS_ABSOLUTE_JUMP ("%*b%:\t%l0"); |
| 6463 |
else |
| 6464 |
return MIPS_ABSOLUTE_JUMP ("%*b\t%l0%/"); |
| 6465 |
} |
| 6466 |
else |
| 6467 |
{ |
| 6468 |
if (TARGET_CB_MAYBE && !final_sequence) |
| 6469 |
return MIPS_ABSOLUTE_JUMP ("%*bc\t%l0"); |
| 6470 |
else |
| 6471 |
return MIPS_ABSOLUTE_JUMP ("%*j\t%l0%/"); |
| 6472 |
} |
| 6473 |
} |
| 6474 |
[(set_attr "type" "branch") |
| 6475 |
(set_attr "compact_form" "maybe")]) |
| 6476 |
|
| 6477 |
(define_insn "*jump_pic" |
| 6478 |
[(set (pc) |
| 6479 |
(label_ref (match_operand 0)))] |
| 6480 |
"!TARGET_MIPS16 && !TARGET_ABSOLUTE_JUMPS" |
| 6481 |
{ |
| 6482 |
if (get_attr_length (insn) <= 8) |
| 6483 |
{ |
| 6484 |
if (TARGET_CB_MAYBE) |
| 6485 |
return "%*b%:\t%l0"; |
| 6486 |
else |
| 6487 |
return "%*b\t%l0%/"; |
| 6488 |
} |
| 6489 |
else |
| 6490 |
{ |
| 6491 |
mips_output_load_label (operands[0]); |
| 6492 |
if (TARGET_CB_MAYBE) |
| 6493 |
return "%*jr%:\t%@%]"; |
| 6494 |
else |
| 6495 |
return "%*jr\t%@%/%]"; |
| 6496 |
} |
| 6497 |
} |
| 6498 |
[(set_attr "type" "branch") |
| 6499 |
(set_attr "compact_form" "maybe")]) |
| 6500 |
|
| 6501 |
;; We need a different insn for the mips16, because a mips16 branch |
| 6502 |
;; does not have a delay slot. |
| 6503 |
|
| 6504 |
(define_insn "*jump_mips16" |
| 6505 |
[(set (pc) |
| 6506 |
(label_ref (match_operand 0 "" "")))] |
| 6507 |
"TARGET_MIPS16" |
| 6508 |
"b\t%l0" |
| 6509 |
[(set_attr "type" "branch") |
| 6510 |
(set (attr "length") |
| 6511 |
;; This calculation is like the normal branch one, but the |
| 6512 |
;; range of the unextended instruction is [-0x800, 0x7fe] rather |
| 6513 |
;; than [-0x100, 0xfe]. This translates to a range of: |
| 6514 |
;; |
| 6515 |
;; [-(0x800 - sizeof (branch)), 0x7fe] |
| 6516 |
;; == [-0x7fe, 0x7fe] |
| 6517 |
;; |
| 6518 |
;; from the shorten_branches reference address. Long-branch |
| 6519 |
;; sequences will replace this one, so the minimum length |
| 6520 |
;; is one instruction shorter than for conditional branches. |
| 6521 |
(cond [(and (le (minus (match_dup 0) (pc)) (const_int 2046)) |
| 6522 |
(le (minus (pc) (match_dup 0)) (const_int 2046))) |
| 6523 |
(const_int 2) |
| 6524 |
(and (le (minus (match_dup 0) (pc)) (const_int 65534)) |
| 6525 |
(le (minus (pc) (match_dup 0)) (const_int 65532))) |
| 6526 |
(const_int 4) |
| 6527 |
(and (match_test "TARGET_ABICALLS") |
| 6528 |
(not (match_test "TARGET_ABSOLUTE_ABICALLS"))) |
| 6529 |
(const_int 18) |
| 6530 |
(match_test "Pmode == SImode") |
| 6531 |
(const_int 14) |
| 6532 |
] (const_int 22)))]) |
| 6533 |
|
| 6534 |
(define_expand "indirect_jump" |
| 6535 |
[(set (pc) (match_operand 0 "register_operand"))] |
| 6536 |
"" |
| 6537 |
{ |
| 6538 |
operands[0] = force_reg (Pmode, operands[0]); |
| 6539 |
emit_jump_insn (PMODE_INSN (gen_indirect_jump, (operands[0]))); |
| 6540 |
DONE; |
| 6541 |
}) |
| 6542 |
|
| 6543 |
(define_insn "indirect_jump_<mode>" |
| 6544 |
[(set (pc) (match_operand:P 0 "register_operand" "d"))] |
| 6545 |
"" |
| 6546 |
{ |
| 6547 |
return mips_output_jump (operands, 0, -1, false); |
| 6548 |
} |
| 6549 |
[(set_attr "type" "jump") |
| 6550 |
(set_attr "mode" "none")]) |
| 6551 |
|
| 6552 |
;; A combined jump-and-move instruction, used for MIPS16 long-branch |
| 6553 |
;; sequences. Having a dedicated pattern is more convenient than |
| 6554 |
;; creating a SEQUENCE for this special case. |
| 6555 |
(define_insn "indirect_jump_and_restore_<mode>" |
| 6556 |
[(set (pc) (match_operand:P 1 "register_operand" "d")) |
| 6557 |
(set (match_operand:P 0 "register_operand" "=d") |
| 6558 |
(match_operand:P 2 "register_operand" "y"))] |
| 6559 |
"" |
| 6560 |
"%(%<jr\t%1\;move\t%0,%2%>%)" |
| 6561 |
[(set_attr "type" "multi") |
| 6562 |
(set_attr "extended_mips16" "yes")]) |
| 6563 |
|
| 6564 |
(define_expand "tablejump" |
| 6565 |
[(set (pc) |
| 6566 |
(match_operand 0 "register_operand")) |
| 6567 |
(use (label_ref (match_operand 1 "")))] |
| 6568 |
"!TARGET_MIPS16_SHORT_JUMP_TABLES" |
| 6569 |
{ |
| 6570 |
if (TARGET_GPWORD) |
| 6571 |
operands[0] = expand_binop (Pmode, add_optab, operands[0], |
| 6572 |
pic_offset_table_rtx, 0, 0, OPTAB_WIDEN); |
| 6573 |
else if (TARGET_RTP_PIC) |
| 6574 |
{ |
| 6575 |
/* When generating RTP PIC, we use case table entries that are relative |
| 6576 |
to the start of the function. Add the function's address to the |
| 6577 |
value we loaded. */ |
| 6578 |
rtx start = get_hard_reg_initial_val (Pmode, PIC_FUNCTION_ADDR_REGNUM); |
| 6579 |
operands[0] = expand_binop (ptr_mode, add_optab, operands[0], |
| 6580 |
start, 0, 0, OPTAB_WIDEN); |
| 6581 |
} |
| 6582 |
|
| 6583 |
emit_jump_insn (PMODE_INSN (gen_tablejump, (operands[0], operands[1]))); |
| 6584 |
DONE; |
| 6585 |
}) |
| 6586 |
|
| 6587 |
(define_insn "tablejump_<mode>" |
| 6588 |
[(set (pc) |
| 6589 |
(match_operand:P 0 "register_operand" "d")) |
| 6590 |
(use (label_ref (match_operand 1 "" "")))] |
| 6591 |
"" |
| 6592 |
{ |
| 6593 |
return mips_output_jump (operands, 0, -1, false); |
| 6594 |
} |
| 6595 |
[(set_attr "type" "jump") |
| 6596 |
(set_attr "mode" "none")]) |
| 6597 |
|
| 6598 |
;; For MIPS16, we don't know whether a given jump table will use short or |
| 6599 |
;; word-sized offsets until late in compilation, when we are able to determine |
| 6600 |
;; the sizes of the insns which comprise the containing function. This |
| 6601 |
;; necessitates the use of the casesi rather than the tablejump pattern, since |
| 6602 |
;; the latter tries to calculate the index of the offset to jump through early |
| 6603 |
;; in compilation, i.e. at expand time, when nothing is known about the |
| 6604 |
;; eventual function layout. |
| 6605 |
|
| 6606 |
(define_expand "casesi" |
| 6607 |
[(match_operand:SI 0 "register_operand" "") ; index to jump on |
| 6608 |
(match_operand:SI 1 "const_int_operand" "") ; lower bound |
| 6609 |
(match_operand:SI 2 "const_int_operand" "") ; total range |
| 6610 |
(match_operand 3 "" "") ; table label |
| 6611 |
(match_operand 4 "" "")] ; out of range label |
| 6612 |
"TARGET_MIPS16_SHORT_JUMP_TABLES" |
| 6613 |
{ |
| 6614 |
if (operands[1] != const0_rtx) |
| 6615 |
{ |
| 6616 |
rtx reg = gen_reg_rtx (SImode); |
| 6617 |
rtx offset = gen_int_mode (-INTVAL (operands[1]), SImode); |
| 6618 |
|
| 6619 |
if (!arith_operand (offset, SImode)) |
| 6620 |
offset = force_reg (SImode, offset); |
| 6621 |
|
| 6622 |
emit_insn (gen_addsi3 (reg, operands[0], offset)); |
| 6623 |
operands[0] = reg; |
| 6624 |
} |
| 6625 |
|
| 6626 |
if (!arith_operand (operands[0], SImode)) |
| 6627 |
operands[0] = force_reg (SImode, operands[0]); |
| 6628 |
|
| 6629 |
emit_cmp_and_jump_insns (operands[0], operands[2], GTU, |
| 6630 |
NULL_RTX, SImode, 1, operands[4]); |
| 6631 |
emit_jump_insn (PMODE_INSN (gen_casesi_internal_mips16, |
| 6632 |
(operands[0], operands[3]))); |
| 6633 |
DONE; |
| 6634 |
}) |
| 6635 |
|
| 6636 |
(define_insn "casesi_internal_mips16_<mode>" |
| 6637 |
[(set (pc) |
| 6638 |
(unspec:P [(match_operand:SI 0 "register_operand" "d") |
| 6639 |
(label_ref (match_operand 1 "" ""))] |
| 6640 |
UNSPEC_CASESI_DISPATCH)) |
| 6641 |
(clobber (match_scratch:P 2 "=d")) |
| 6642 |
(clobber (match_scratch:P 3 "=d"))] |
| 6643 |
"TARGET_MIPS16_SHORT_JUMP_TABLES" |
| 6644 |
{ |
| 6645 |
rtx diff_vec = PATTERN (NEXT_INSN (as_a <rtx_insn *> (operands[1]))); |
| 6646 |
|
| 6647 |
gcc_assert (GET_CODE (diff_vec) == ADDR_DIFF_VEC); |
| 6648 |
|
| 6649 |
switch (GET_MODE (diff_vec)) |
| 6650 |
{ |
| 6651 |
case E_HImode: |
| 6652 |
output_asm_insn ("sll\t%3,%0,1", operands); |
| 6653 |
output_asm_insn ("<d>la\t%2,%1", operands); |
| 6654 |
output_asm_insn ("<d>addu\t%3,%2,%3", operands); |
| 6655 |
output_asm_insn ("lh\t%3,0(%3)", operands); |
| 6656 |
break; |
| 6657 |
|
| 6658 |
case E_SImode: |
| 6659 |
output_asm_insn ("sll\t%3,%0,2", operands); |
| 6660 |
output_asm_insn ("<d>la\t%2,%1", operands); |
| 6661 |
output_asm_insn ("<d>addu\t%3,%2,%3", operands); |
| 6662 |
output_asm_insn ("lw\t%3,0(%3)", operands); |
| 6663 |
break; |
| 6664 |
|
| 6665 |
default: |
| 6666 |
gcc_unreachable (); |
| 6667 |
} |
| 6668 |
|
| 6669 |
output_asm_insn ("<d>addu\t%2,%2,%3", operands); |
| 6670 |
|
| 6671 |
if (GENERATE_MIPS16E) |
| 6672 |
return "jrc\t%2"; |
| 6673 |
else |
| 6674 |
return "jr\t%2"; |
| 6675 |
} |
| 6676 |
[(set (attr "insn_count") |
| 6677 |
(if_then_else (match_test "GENERATE_MIPS16E") |
| 6678 |
(const_string "6") |
| 6679 |
(const_string "7")))]) |
| 6680 |
|
| 6681 |
;; For TARGET_USE_GOT, we save the gp in the jmp_buf as well. |
| 6682 |
;; While it is possible to either pull it off the stack (in the |
| 6683 |
;; o32 case) or recalculate it given t9 and our target label, |
| 6684 |
;; it takes 3 or 4 insns to do so. |
| 6685 |
|
| 6686 |
(define_expand "builtin_setjmp_setup" |
| 6687 |
[(use (match_operand 0 "register_operand"))] |
| 6688 |
"TARGET_USE_GOT" |
| 6689 |
{ |
| 6690 |
rtx addr; |
| 6691 |
|
| 6692 |
addr = plus_constant (Pmode, operands[0], GET_MODE_SIZE (Pmode) * 3); |
| 6693 |
mips_emit_move (gen_rtx_MEM (Pmode, addr), pic_offset_table_rtx); |
| 6694 |
DONE; |
| 6695 |
}) |
| 6696 |
|
| 6697 |
;; Restore the gp that we saved above. Despite the earlier comment, it seems |
| 6698 |
;; that older code did recalculate the gp from $25. Continue to jump through |
| 6699 |
;; $25 for compatibility (we lose nothing by doing so). |
| 6700 |
|
| 6701 |
(define_expand "builtin_longjmp" |
| 6702 |
[(use (match_operand 0 "register_operand"))] |
| 6703 |
"TARGET_USE_GOT" |
| 6704 |
{ |
| 6705 |
/* The elements of the buffer are, in order: */ |
| 6706 |
int W = GET_MODE_SIZE (Pmode); |
| 6707 |
rtx fp = gen_rtx_MEM (Pmode, operands[0]); |
| 6708 |
rtx lab = gen_rtx_MEM (Pmode, plus_constant (Pmode, operands[0], 1*W)); |
| 6709 |
rtx stack = gen_rtx_MEM (Pmode, plus_constant (Pmode, operands[0], 2*W)); |
| 6710 |
rtx gpv = gen_rtx_MEM (Pmode, plus_constant (Pmode, operands[0], 3*W)); |
| 6711 |
rtx pv = gen_rtx_REG (Pmode, PIC_FUNCTION_ADDR_REGNUM); |
| 6712 |
/* Use gen_raw_REG to avoid being given pic_offset_table_rtx. |
| 6713 |
The target is bound to be using $28 as the global pointer |
| 6714 |
but the current function might not be. */ |
| 6715 |
rtx gp = gen_raw_REG (Pmode, GLOBAL_POINTER_REGNUM); |
| 6716 |
|
| 6717 |
/* This bit is similar to expand_builtin_longjmp except that it |
| 6718 |
restores $gp as well. */ |
| 6719 |
mips_emit_move (pv, lab); |
| 6720 |
/* Restore the frame pointer and stack pointer and gp. We must use a |
| 6721 |
temporary since the setjmp buffer may be a local. */ |
| 6722 |
fp = copy_to_reg (fp); |
| 6723 |
gpv = copy_to_reg (gpv); |
| 6724 |
emit_stack_restore (SAVE_NONLOCAL, stack); |
| 6725 |
|
| 6726 |
/* Ensure the frame pointer move is not optimized. */ |
| 6727 |
emit_insn (gen_blockage ()); |
| 6728 |
emit_clobber (hard_frame_pointer_rtx); |
| 6729 |
emit_clobber (frame_pointer_rtx); |
| 6730 |
emit_clobber (gp); |
| 6731 |
mips_emit_move (hard_frame_pointer_rtx, fp); |
| 6732 |
mips_emit_move (gp, gpv); |
| 6733 |
emit_use (hard_frame_pointer_rtx); |
| 6734 |
emit_use (stack_pointer_rtx); |
| 6735 |
emit_use (gp); |
| 6736 |
emit_indirect_jump (pv); |
| 6737 |
DONE; |
| 6738 |
}) |
| 6739 |
|
| 6740 |
;; |
| 6741 |
;; .................... |
| 6742 |
;; |
| 6743 |
;; Function prologue/epilogue |
| 6744 |
;; |
| 6745 |
;; .................... |
| 6746 |
;; |
| 6747 |
|
| 6748 |
(define_expand "prologue" |
| 6749 |
[(const_int 1)] |
| 6750 |
"" |
| 6751 |
{ |
| 6752 |
mips_expand_prologue (); |
| 6753 |
DONE; |
| 6754 |
}) |
| 6755 |
|
| 6756 |
;; Block any insns from being moved before this point, since the |
| 6757 |
;; profiling call to mcount can use various registers that aren't |
| 6758 |
;; saved or used to pass arguments. |
| 6759 |
|
| 6760 |
(define_insn "blockage" |
| 6761 |
[(unspec_volatile [(const_int 0)] UNSPEC_BLOCKAGE)] |
| 6762 |
"" |
| 6763 |
"" |
| 6764 |
[(set_attr "type" "ghost") |
| 6765 |
(set_attr "mode" "none")]) |
| 6766 |
|
| 6767 |
(define_insn "probe_stack_range_<P:mode>" |
| 6768 |
[(set (match_operand:P 0 "register_operand" "=d") |
| 6769 |
(unspec_volatile:P [(match_operand:P 1 "register_operand" "0") |
| 6770 |
(match_operand:P 2 "register_operand" "d")] |
| 6771 |
UNSPEC_PROBE_STACK_RANGE))] |
| 6772 |
"" |
| 6773 |
{ return mips_output_probe_stack_range (operands[0], operands[2]); } |
| 6774 |
[(set_attr "type" "unknown") |
| 6775 |
(set_attr "can_delay" "no") |
| 6776 |
(set_attr "mode" "<MODE>")]) |
| 6777 |
|
| 6778 |
(define_expand "epilogue" |
| 6779 |
[(const_int 2)] |
| 6780 |
"" |
| 6781 |
{ |
| 6782 |
mips_expand_epilogue (false); |
| 6783 |
DONE; |
| 6784 |
}) |
| 6785 |
|
| 6786 |
(define_expand "sibcall_epilogue" |
| 6787 |
[(const_int 2)] |
| 6788 |
"" |
| 6789 |
{ |
| 6790 |
mips_expand_epilogue (true); |
| 6791 |
DONE; |
| 6792 |
}) |
| 6793 |
|
| 6794 |
;; Trivial return. Make it look like a normal return insn as that |
| 6795 |
;; allows jump optimizations to work better. |
| 6796 |
|
| 6797 |
(define_expand "return" |
| 6798 |
[(simple_return)] |
| 6799 |
"mips_can_use_return_insn ()" |
| 6800 |
{ mips_expand_before_return (); }) |
| 6801 |
|
| 6802 |
(define_expand "simple_return" |
| 6803 |
[(simple_return)] |
| 6804 |
"" |
| 6805 |
{ mips_expand_before_return (); }) |
| 6806 |
|
| 6807 |
(define_insn "*<optab>" |
| 6808 |
[(any_return)] |
| 6809 |
"" |
| 6810 |
{ |
| 6811 |
operands[0] = gen_rtx_REG (Pmode, RETURN_ADDR_REGNUM); |
| 6812 |
return mips_output_jump (operands, 0, -1, false); |
| 6813 |
} |
| 6814 |
[(set_attr "type" "jump") |
| 6815 |
(set_attr "mode" "none")]) |
| 6816 |
|
| 6817 |
;; Insn to clear execution and instruction hazards while returning. |
| 6818 |
;; However, it doesn't clear hazards created by the insn in its delay slot. |
| 6819 |
;; Thus, explicitly place a nop in its delay slot. |
| 6820 |
|
| 6821 |
(define_insn "mips_hb_return_internal" |
| 6822 |
[(return) |
| 6823 |
(unspec_volatile [(match_operand 0 "pmode_register_operand" "")] |
| 6824 |
UNSPEC_JRHB)] |
| 6825 |
"" |
| 6826 |
{ |
| 6827 |
return "%(jr.hb\t$31%/%)"; |
| 6828 |
} |
| 6829 |
[(set_attr "insn_count" "2")]) |
| 6830 |
|
| 6831 |
;; Normal return. |
| 6832 |
|
| 6833 |
(define_insn "<optab>_internal" |
| 6834 |
[(any_return) |
| 6835 |
(use (match_operand 0 "pmode_register_operand" ""))] |
| 6836 |
"" |
| 6837 |
{ |
| 6838 |
return mips_output_jump (operands, 0, -1, false); |
| 6839 |
} |
| 6840 |
[(set_attr "type" "jump") |
| 6841 |
(set_attr "mode" "none")]) |
| 6842 |
|
| 6843 |
;; Exception return. |
| 6844 |
(define_insn "mips_eret" |
| 6845 |
[(return) |
| 6846 |
(unspec_volatile [(const_int 0)] UNSPEC_ERET)] |
| 6847 |
"" |
| 6848 |
"eret" |
| 6849 |
[(set_attr "type" "trap") |
| 6850 |
(set_attr "mode" "none")]) |
| 6851 |
|
| 6852 |
;; Debug exception return. |
| 6853 |
(define_insn "mips_deret" |
| 6854 |
[(return) |
| 6855 |
(unspec_volatile [(const_int 0)] UNSPEC_DERET)] |
| 6856 |
"" |
| 6857 |
"deret" |
| 6858 |
[(set_attr "type" "trap") |
| 6859 |
(set_attr "mode" "none")]) |
| 6860 |
|
| 6861 |
;; Disable interrupts. |
| 6862 |
(define_insn "mips_di" |
| 6863 |
[(unspec_volatile [(const_int 0)] UNSPEC_DI)] |
| 6864 |
"" |
| 6865 |
"di" |
| 6866 |
[(set_attr "type" "trap") |
| 6867 |
(set_attr "mode" "none")]) |
| 6868 |
|
| 6869 |
;; Execution hazard barrier. |
| 6870 |
(define_insn "mips_ehb" |
| 6871 |
[(unspec_volatile [(const_int 0)] UNSPEC_EHB)] |
| 6872 |
"" |
| 6873 |
"ehb" |
| 6874 |
[(set_attr "type" "trap") |
| 6875 |
(set_attr "mode" "none")]) |
| 6876 |
|
| 6877 |
;; Read GPR from previous shadow register set. |
| 6878 |
(define_insn "mips_rdpgpr_<mode>" |
| 6879 |
[(set (match_operand:P 0 "register_operand" "=d") |
| 6880 |
(unspec_volatile:P [(match_operand:P 1 "register_operand" "d")] |
| 6881 |
UNSPEC_RDPGPR))] |
| 6882 |
"" |
| 6883 |
"rdpgpr\t%0,%1" |
| 6884 |
[(set_attr "type" "move") |
| 6885 |
(set_attr "mode" "<MODE>")]) |
| 6886 |
|
| 6887 |
;; Move involving COP0 registers. |
| 6888 |
(define_insn "cop0_move" |
| 6889 |
[(set (match_operand:SI 0 "register_operand" "=B,d") |
| 6890 |
(unspec_volatile:SI [(match_operand:SI 1 "register_operand" "d,B")] |
| 6891 |
UNSPEC_COP0))] |
| 6892 |
"" |
| 6893 |
{ return mips_output_move (operands[0], operands[1]); } |
| 6894 |
[(set_attr "type" "mtc,mfc") |
| 6895 |
(set_attr "mode" "SI")]) |
| 6896 |
|
| 6897 |
;; This is used in compiling the unwind routines. |
| 6898 |
(define_expand "eh_return" |
| 6899 |
[(use (match_operand 0 "general_operand"))] |
| 6900 |
"" |
| 6901 |
{ |
| 6902 |
if (GET_MODE (operands[0]) != word_mode) |
| 6903 |
operands[0] = convert_to_mode (word_mode, operands[0], 0); |
| 6904 |
if (TARGET_64BIT) |
| 6905 |
emit_insn (gen_eh_set_lr_di (operands[0])); |
| 6906 |
else |
| 6907 |
emit_insn (gen_eh_set_lr_si (operands[0])); |
| 6908 |
DONE; |
| 6909 |
}) |
| 6910 |
|
| 6911 |
;; Clobber the return address on the stack. We can't expand this |
| 6912 |
;; until we know where it will be put in the stack frame. |
| 6913 |
|
| 6914 |
(define_insn "eh_set_lr_si" |
| 6915 |
[(unspec [(match_operand:SI 0 "register_operand" "d")] UNSPEC_EH_RETURN) |
| 6916 |
(clobber (match_scratch:SI 1 "=&d"))] |
| 6917 |
"! TARGET_64BIT" |
| 6918 |
"#") |
| 6919 |
|
| 6920 |
(define_insn "eh_set_lr_di" |
| 6921 |
[(unspec [(match_operand:DI 0 "register_operand" "d")] UNSPEC_EH_RETURN) |
| 6922 |
(clobber (match_scratch:DI 1 "=&d"))] |
| 6923 |
"TARGET_64BIT" |
| 6924 |
"#") |
| 6925 |
|
| 6926 |
(define_split |
| 6927 |
[(unspec [(match_operand 0 "register_operand")] UNSPEC_EH_RETURN) |
| 6928 |
(clobber (match_scratch 1))] |
| 6929 |
"reload_completed" |
| 6930 |
[(const_int 0)] |
| 6931 |
{ |
| 6932 |
mips_set_return_address (operands[0], operands[1]); |
| 6933 |
DONE; |
| 6934 |
}) |
| 6935 |
|
| 6936 |
(define_expand "exception_receiver" |
| 6937 |
[(const_int 0)] |
| 6938 |
"TARGET_USE_GOT" |
| 6939 |
{ |
| 6940 |
/* See the comment above load_call<mode> for details. */ |
| 6941 |
emit_insn (gen_set_got_version ()); |
| 6942 |
|
| 6943 |
/* If we have a call-clobbered $gp, restore it from its save slot. */ |
| 6944 |
if (HAVE_restore_gp_si) |
| 6945 |
emit_insn (gen_restore_gp_si ()); |
| 6946 |
else if (HAVE_restore_gp_di) |
| 6947 |
emit_insn (gen_restore_gp_di ()); |
| 6948 |
DONE; |
| 6949 |
}) |
| 6950 |
|
| 6951 |
(define_expand "nonlocal_goto_receiver" |
| 6952 |
[(const_int 0)] |
| 6953 |
"TARGET_USE_GOT" |
| 6954 |
{ |
| 6955 |
/* See the comment above load_call<mode> for details. */ |
| 6956 |
emit_insn (gen_set_got_version ()); |
| 6957 |
DONE; |
| 6958 |
}) |
| 6959 |
|
| 6960 |
;; Restore $gp from its .cprestore stack slot. The instruction remains |
| 6961 |
;; volatile until all uses of $28 are exposed. |
| 6962 |
(define_insn_and_split "restore_gp_<mode>" |
| 6963 |
[(set (reg:P 28) |
| 6964 |
(unspec_volatile:P [(const_int 0)] UNSPEC_RESTORE_GP)) |
| 6965 |
(clobber (match_scratch:P 0 "=&d"))] |
| 6966 |
"TARGET_CALL_CLOBBERED_GP" |
| 6967 |
"#" |
| 6968 |
"&& epilogue_completed" |
| 6969 |
[(const_int 0)] |
| 6970 |
{ |
| 6971 |
mips_restore_gp_from_cprestore_slot (operands[0]); |
| 6972 |
DONE; |
| 6973 |
} |
| 6974 |
[(set_attr "type" "ghost")]) |
| 6975 |
|
| 6976 |
;; Move between $gp and its register save slot. |
| 6977 |
(define_insn_and_split "move_gp<mode>" |
| 6978 |
[(set (match_operand:GPR 0 "nonimmediate_operand" "=d,m") |
| 6979 |
(unspec:GPR [(match_operand:GPR 1 "move_operand" "m,d")] |
| 6980 |
UNSPEC_MOVE_GP))] |
| 6981 |
"" |
| 6982 |
{ return mips_must_initialize_gp_p () ? "#" : ""; } |
| 6983 |
"mips_must_initialize_gp_p ()" |
| 6984 |
[(const_int 0)] |
| 6985 |
{ |
| 6986 |
mips_emit_move (operands[0], operands[1]); |
| 6987 |
DONE; |
| 6988 |
} |
| 6989 |
[(set_attr "type" "ghost")]) |
| 6990 |
|
| 6991 |
;; |
| 6992 |
;; .................... |
| 6993 |
;; |
| 6994 |
;; FUNCTION CALLS |
| 6995 |
;; |
| 6996 |
;; .................... |
| 6997 |
|
| 6998 |
;; Instructions to load a call address from the GOT. The address might |
| 6999 |
;; point to a function or to a lazy binding stub. In the latter case, |
| 7000 |
;; the stub will use the dynamic linker to resolve the function, which |
| 7001 |
;; in turn will change the GOT entry to point to the function's real |
| 7002 |
;; address. |
| 7003 |
;; |
| 7004 |
;; This means that every call, even pure and constant ones, can |
| 7005 |
;; potentially modify the GOT entry. And once a stub has been called, |
| 7006 |
;; we must not call it again. |
| 7007 |
;; |
| 7008 |
;; We represent this restriction using an imaginary, fixed, call-saved |
| 7009 |
;; register called GOT_VERSION_REGNUM. The idea is to make the register |
| 7010 |
;; live throughout the function and to change its value after every |
| 7011 |
;; potential call site. This stops any rtx value that uses the register |
| 7012 |
;; from being computed before an earlier call. To do this, we: |
| 7013 |
;; |
| 7014 |
;; - Ensure that the register is live on entry to the function, |
| 7015 |
;; so that it is never thought to be used uninitalized. |
| 7016 |
;; |
| 7017 |
;; - Ensure that the register is live on exit from the function, |
| 7018 |
;; so that it is live throughout. |
| 7019 |
;; |
| 7020 |
;; - Make each call (lazily-bound or not) use the current value |
| 7021 |
;; of GOT_VERSION_REGNUM, so that updates of the register are |
| 7022 |
;; not moved across call boundaries. |
| 7023 |
;; |
| 7024 |
;; - Add "ghost" definitions of the register to the beginning of |
| 7025 |
;; blocks reached by EH and ABNORMAL_CALL edges, because those |
| 7026 |
;; edges may involve calls that normal paths don't. (E.g. the |
| 7027 |
;; unwinding code that handles a non-call exception may change |
| 7028 |
;; lazily-bound GOT entries.) We do this by making the |
| 7029 |
;; exception_receiver and nonlocal_goto_receiver expanders emit |
| 7030 |
;; a set_got_version instruction. |
| 7031 |
;; |
| 7032 |
;; - After each call (lazily-bound or not), use a "ghost" |
| 7033 |
;; update_got_version instruction to change the register's value. |
| 7034 |
;; This instruction mimics the _possible_ effect of the dynamic |
| 7035 |
;; resolver during the call and it remains live even if the call |
| 7036 |
;; itself becomes dead. |
| 7037 |
;; |
| 7038 |
;; - Leave GOT_VERSION_REGNUM out of all register classes. |
| 7039 |
;; The register is therefore not a valid register_operand |
| 7040 |
;; and cannot be moved to or from other registers. |
| 7041 |
|
| 7042 |
(define_insn "load_call<mode>" |
| 7043 |
[(set (match_operand:P 0 "register_operand" "=d") |
| 7044 |
(unspec:P [(match_operand:P 1 "register_operand" "d") |
| 7045 |
(match_operand:P 2 "immediate_operand" "") |
| 7046 |
(reg:SI GOT_VERSION_REGNUM)] UNSPEC_LOAD_CALL))] |
| 7047 |
"TARGET_USE_GOT" |
| 7048 |
"<load>\t%0,%R2(%1)" |
| 7049 |
[(set_attr "got" "load") |
| 7050 |
(set_attr "mode" "<MODE>")]) |
| 7051 |
|
| 7052 |
(define_insn "set_got_version" |
| 7053 |
[(set (reg:SI GOT_VERSION_REGNUM) |
| 7054 |
(unspec_volatile:SI [(const_int 0)] UNSPEC_SET_GOT_VERSION))] |
| 7055 |
"TARGET_USE_GOT" |
| 7056 |
"" |
| 7057 |
[(set_attr "type" "ghost")]) |
| 7058 |
|
| 7059 |
(define_insn "update_got_version" |
| 7060 |
[(set (reg:SI GOT_VERSION_REGNUM) |
| 7061 |
(unspec:SI [(reg:SI GOT_VERSION_REGNUM)] UNSPEC_UPDATE_GOT_VERSION))] |
| 7062 |
"TARGET_USE_GOT" |
| 7063 |
"" |
| 7064 |
[(set_attr "type" "ghost")]) |
| 7065 |
|
| 7066 |
;; Sibling calls. All these patterns use jump instructions. |
| 7067 |
|
| 7068 |
;; If TARGET_SIBCALLS, call_insn_operand will only accept constant |
| 7069 |
;; addresses if a direct jump is acceptable. Since the 'S' constraint |
| 7070 |
;; is defined in terms of call_insn_operand, the same is true of the |
| 7071 |
;; constraints. |
| 7072 |
|
| 7073 |
;; When we use an indirect jump, we need a register that will be |
| 7074 |
;; preserved by the epilogue. Since TARGET_USE_PIC_FN_ADDR_REG forces |
| 7075 |
;; us to use $25 for this purpose -- and $25 is never clobbered by the |
| 7076 |
;; epilogue -- we might as well use it for !TARGET_USE_PIC_FN_ADDR_REG |
| 7077 |
;; as well. |
| 7078 |
|
| 7079 |
(define_expand "sibcall" |
| 7080 |
[(parallel [(call (match_operand 0 "") |
| 7081 |
(match_operand 1 "")) |
| 7082 |
(use (match_operand 2 "")) ;; next_arg_reg |
| 7083 |
(use (match_operand 3 ""))])] ;; struct_value_size_rtx |
| 7084 |
"TARGET_SIBCALLS" |
| 7085 |
{ |
| 7086 |
mips_expand_call (MIPS_CALL_SIBCALL, NULL_RTX, XEXP (operands[0], 0), |
| 7087 |
operands[1], operands[2], false); |
| 7088 |
DONE; |
| 7089 |
}) |
| 7090 |
|
| 7091 |
(define_insn "sibcall_internal" |
| 7092 |
[(call (mem:SI (match_operand 0 "call_insn_operand" "j,S")) |
| 7093 |
(match_operand 1 "" ""))] |
| 7094 |
"TARGET_SIBCALLS && SIBLING_CALL_P (insn)" |
| 7095 |
{ return mips_output_jump (operands, 0, 1, false); } |
| 7096 |
[(set_attr "jal" "indirect,direct") |
| 7097 |
(set_attr "jal_macro" "no")]) |
| 7098 |
|
| 7099 |
(define_expand "sibcall_value" |
| 7100 |
[(parallel [(set (match_operand 0 "") |
| 7101 |
(call (match_operand 1 "") |
| 7102 |
(match_operand 2 ""))) |
| 7103 |
(use (match_operand 3 ""))])] ;; next_arg_reg |
| 7104 |
"TARGET_SIBCALLS" |
| 7105 |
{ |
| 7106 |
mips_expand_call (MIPS_CALL_SIBCALL, operands[0], XEXP (operands[1], 0), |
| 7107 |
operands[2], operands[3], false); |
| 7108 |
DONE; |
| 7109 |
}) |
| 7110 |
|
| 7111 |
(define_insn "sibcall_value_internal" |
| 7112 |
[(set (match_operand 0 "register_operand" "") |
| 7113 |
(call (mem:SI (match_operand 1 "call_insn_operand" "j,S")) |
| 7114 |
(match_operand 2 "" "")))] |
| 7115 |
"TARGET_SIBCALLS && SIBLING_CALL_P (insn)" |
| 7116 |
{ return mips_output_jump (operands, 1, 2, false); } |
| 7117 |
[(set_attr "jal" "indirect,direct") |
| 7118 |
(set_attr "jal_macro" "no")]) |
| 7119 |
|
| 7120 |
(define_insn "sibcall_value_multiple_internal" |
| 7121 |
[(set (match_operand 0 "register_operand" "") |
| 7122 |
(call (mem:SI (match_operand 1 "call_insn_operand" "j,S")) |
| 7123 |
(match_operand 2 "" ""))) |
| 7124 |
(set (match_operand 3 "register_operand" "") |
| 7125 |
(call (mem:SI (match_dup 1)) |
| 7126 |
(match_dup 2)))] |
| 7127 |
"TARGET_SIBCALLS && SIBLING_CALL_P (insn)" |
| 7128 |
{ return mips_output_jump (operands, 1, 2, false); } |
| 7129 |
[(set_attr "jal" "indirect,direct") |
| 7130 |
(set_attr "jal_macro" "no")]) |
| 7131 |
|
| 7132 |
(define_expand "call" |
| 7133 |
[(parallel [(call (match_operand 0 "") |
| 7134 |
(match_operand 1 "")) |
| 7135 |
(use (match_operand 2 "")) ;; next_arg_reg |
| 7136 |
(use (match_operand 3 ""))])] ;; struct_value_size_rtx |
| 7137 |
"" |
| 7138 |
{ |
| 7139 |
mips_expand_call (MIPS_CALL_NORMAL, NULL_RTX, XEXP (operands[0], 0), |
| 7140 |
operands[1], operands[2], false); |
| 7141 |
DONE; |
| 7142 |
}) |
| 7143 |
|
| 7144 |
;; This instruction directly corresponds to an assembly-language "jal". |
| 7145 |
;; There are four cases: |
| 7146 |
;; |
| 7147 |
;; - -mno-abicalls: |
| 7148 |
;; Both symbolic and register destinations are OK. The pattern |
| 7149 |
;; always expands to a single mips instruction. |
| 7150 |
;; |
| 7151 |
;; - -mabicalls/-mno-explicit-relocs: |
| 7152 |
;; Again, both symbolic and register destinations are OK. |
| 7153 |
;; The call is treated as a multi-instruction black box. |
| 7154 |
;; |
| 7155 |
;; - -mabicalls/-mexplicit-relocs with n32 or n64: |
| 7156 |
;; Only "jal $25" is allowed. This expands to a single "jalr $25" |
| 7157 |
;; instruction. |
| 7158 |
;; |
| 7159 |
;; - -mabicalls/-mexplicit-relocs with o32 or o64: |
| 7160 |
;; Only "jal $25" is allowed. The call is actually two instructions: |
| 7161 |
;; "jalr $25" followed by an insn to reload $gp. |
| 7162 |
;; |
| 7163 |
;; In the last case, we can generate the individual instructions with |
| 7164 |
;; a define_split. There are several things to be wary of: |
| 7165 |
;; |
| 7166 |
;; - We can't expose the load of $gp before reload. If we did, |
| 7167 |
;; it might get removed as dead, but reload can introduce new |
| 7168 |
;; uses of $gp by rematerializing constants. |
| 7169 |
;; |
| 7170 |
;; - We shouldn't restore $gp after calls that never return. |
| 7171 |
;; It isn't valid to insert instructions between a noreturn |
| 7172 |
;; call and the following barrier. |
| 7173 |
;; |
| 7174 |
;; - The splitter deliberately changes the liveness of $gp. The unsplit |
| 7175 |
;; instruction preserves $gp and so have no effect on its liveness. |
| 7176 |
;; But once we generate the separate insns, it becomes obvious that |
| 7177 |
;; $gp is not live on entry to the call. |
| 7178 |
;; |
| 7179 |
(define_insn_and_split "call_internal" |
| 7180 |
[(call (mem:SI (match_operand 0 "call_insn_operand" "c,S")) |
| 7181 |
(match_operand 1 "" "")) |
| 7182 |
(clobber (reg:SI RETURN_ADDR_REGNUM))] |
| 7183 |
"" |
| 7184 |
{ |
| 7185 |
return (TARGET_SPLIT_CALLS ? "#" |
| 7186 |
: mips_output_jump (operands, 0, 1, true)); |
| 7187 |
} |
| 7188 |
"reload_completed && TARGET_SPLIT_CALLS" |
| 7189 |
[(const_int 0)] |
| 7190 |
{ |
| 7191 |
mips_split_call (curr_insn, gen_call_split (operands[0], operands[1])); |
| 7192 |
DONE; |
| 7193 |
} |
| 7194 |
[(set_attr "jal" "indirect,direct")]) |
| 7195 |
|
| 7196 |
(define_insn "call_split" |
| 7197 |
[(call (mem:SI (match_operand 0 "call_insn_operand" "c,S")) |
| 7198 |
(match_operand 1 "" "")) |
| 7199 |
(clobber (reg:SI RETURN_ADDR_REGNUM)) |
| 7200 |
(clobber (reg:SI 28))] |
| 7201 |
"TARGET_SPLIT_CALLS" |
| 7202 |
{ return mips_output_jump (operands, 0, 1, true); } |
| 7203 |
[(set_attr "jal" "indirect,direct") |
| 7204 |
(set_attr "jal_macro" "no")]) |
| 7205 |
|
| 7206 |
;; A pattern for calls that must be made directly. It is used for |
| 7207 |
;; MIPS16 calls that the linker may need to redirect to a hard-float |
| 7208 |
;; stub; the linker relies on the call relocation type to detect when |
| 7209 |
;; such redirection is needed. |
| 7210 |
(define_insn_and_split "call_internal_direct" |
| 7211 |
[(call (mem:SI (match_operand 0 "const_call_insn_operand")) |
| 7212 |
(match_operand 1)) |
| 7213 |
(const_int 1) |
| 7214 |
(clobber (reg:SI RETURN_ADDR_REGNUM))] |
| 7215 |
"" |
| 7216 |
{ |
| 7217 |
return (TARGET_SPLIT_CALLS ? "#" |
| 7218 |
: mips_output_jump (operands, 0, -1, true)); |
| 7219 |
} |
| 7220 |
"reload_completed && TARGET_SPLIT_CALLS" |
| 7221 |
[(const_int 0)] |
| 7222 |
{ |
| 7223 |
mips_split_call (curr_insn, |
| 7224 |
gen_call_direct_split (operands[0], operands[1])); |
| 7225 |
DONE; |
| 7226 |
} |
| 7227 |
[(set_attr "jal" "direct")]) |
| 7228 |
|
| 7229 |
(define_insn "call_direct_split" |
| 7230 |
[(call (mem:SI (match_operand 0 "const_call_insn_operand")) |
| 7231 |
(match_operand 1)) |
| 7232 |
(const_int 1) |
| 7233 |
(clobber (reg:SI RETURN_ADDR_REGNUM)) |
| 7234 |
(clobber (reg:SI 28))] |
| 7235 |
"TARGET_SPLIT_CALLS" |
| 7236 |
{ return mips_output_jump (operands, 0, -1, true); } |
| 7237 |
[(set_attr "jal" "direct") |
| 7238 |
(set_attr "jal_macro" "no")]) |
| 7239 |
|
| 7240 |
(define_expand "call_value" |
| 7241 |
[(parallel [(set (match_operand 0 "") |
| 7242 |
(call (match_operand 1 "") |
| 7243 |
(match_operand 2 ""))) |
| 7244 |
(use (match_operand 3 ""))])] ;; next_arg_reg |
| 7245 |
"" |
| 7246 |
{ |
| 7247 |
mips_expand_call (MIPS_CALL_NORMAL, operands[0], XEXP (operands[1], 0), |
| 7248 |
operands[2], operands[3], false); |
| 7249 |
DONE; |
| 7250 |
}) |
| 7251 |
|
| 7252 |
;; See comment for call_internal. |
| 7253 |
(define_insn_and_split "call_value_internal" |
| 7254 |
[(set (match_operand 0 "register_operand" "") |
| 7255 |
(call (mem:SI (match_operand 1 "call_insn_operand" "c,S")) |
| 7256 |
(match_operand 2 "" ""))) |
| 7257 |
(clobber (reg:SI RETURN_ADDR_REGNUM))] |
| 7258 |
"" |
| 7259 |
{ |
| 7260 |
return (TARGET_SPLIT_CALLS ? "#" |
| 7261 |
: mips_output_jump (operands, 1, 2, true)); |
| 7262 |
} |
| 7263 |
"reload_completed && TARGET_SPLIT_CALLS" |
| 7264 |
[(const_int 0)] |
| 7265 |
{ |
| 7266 |
mips_split_call (curr_insn, |
| 7267 |
gen_call_value_split (operands[0], operands[1], |
| 7268 |
operands[2])); |
| 7269 |
DONE; |
| 7270 |
} |
| 7271 |
[(set_attr "jal" "indirect,direct")]) |
| 7272 |
|
| 7273 |
(define_insn "call_value_split" |
| 7274 |
[(set (match_operand 0 "register_operand" "") |
| 7275 |
(call (mem:SI (match_operand 1 "call_insn_operand" "c,S")) |
| 7276 |
(match_operand 2 "" ""))) |
| 7277 |
(clobber (reg:SI RETURN_ADDR_REGNUM)) |
| 7278 |
(clobber (reg:SI 28))] |
| 7279 |
"TARGET_SPLIT_CALLS" |
| 7280 |
{ return mips_output_jump (operands, 1, 2, true); } |
| 7281 |
[(set_attr "jal" "indirect,direct") |
| 7282 |
(set_attr "jal_macro" "no")]) |
| 7283 |
|
| 7284 |
;; See call_internal_direct. |
| 7285 |
(define_insn_and_split "call_value_internal_direct" |
| 7286 |
[(set (match_operand 0 "register_operand") |
| 7287 |
(call (mem:SI (match_operand 1 "const_call_insn_operand")) |
| 7288 |
(match_operand 2))) |
| 7289 |
(const_int 1) |
| 7290 |
(clobber (reg:SI RETURN_ADDR_REGNUM))] |
| 7291 |
"" |
| 7292 |
{ |
| 7293 |
return (TARGET_SPLIT_CALLS ? "#" |
| 7294 |
: mips_output_jump (operands, 1, -1, true)); |
| 7295 |
} |
| 7296 |
"reload_completed && TARGET_SPLIT_CALLS" |
| 7297 |
[(const_int 0)] |
| 7298 |
{ |
| 7299 |
mips_split_call (curr_insn, |
| 7300 |
gen_call_value_direct_split (operands[0], operands[1], |
| 7301 |
operands[2])); |
| 7302 |
DONE; |
| 7303 |
} |
| 7304 |
[(set_attr "jal" "direct")]) |
| 7305 |
|
| 7306 |
(define_insn "call_value_direct_split" |
| 7307 |
[(set (match_operand 0 "register_operand") |
| 7308 |
(call (mem:SI (match_operand 1 "const_call_insn_operand")) |
| 7309 |
(match_operand 2))) |
| 7310 |
(const_int 1) |
| 7311 |
(clobber (reg:SI RETURN_ADDR_REGNUM)) |
| 7312 |
(clobber (reg:SI 28))] |
| 7313 |
"TARGET_SPLIT_CALLS" |
| 7314 |
{ return mips_output_jump (operands, 1, -1, true); } |
| 7315 |
[(set_attr "jal" "direct") |
| 7316 |
(set_attr "jal_macro" "no")]) |
| 7317 |
|
| 7318 |
;; See comment for call_internal. |
| 7319 |
(define_insn_and_split "call_value_multiple_internal" |
| 7320 |
[(set (match_operand 0 "register_operand" "") |
| 7321 |
(call (mem:SI (match_operand 1 "call_insn_operand" "c,S")) |
| 7322 |
(match_operand 2 "" ""))) |
| 7323 |
(set (match_operand 3 "register_operand" "") |
| 7324 |
(call (mem:SI (match_dup 1)) |
| 7325 |
(match_dup 2))) |
| 7326 |
(clobber (reg:SI RETURN_ADDR_REGNUM))] |
| 7327 |
"" |
| 7328 |
{ |
| 7329 |
return (TARGET_SPLIT_CALLS ? "#" |
| 7330 |
: mips_output_jump (operands, 1, 2, true)); |
| 7331 |
} |
| 7332 |
"reload_completed && TARGET_SPLIT_CALLS" |
| 7333 |
[(const_int 0)] |
| 7334 |
{ |
| 7335 |
mips_split_call (curr_insn, |
| 7336 |
gen_call_value_multiple_split (operands[0], operands[1], |
| 7337 |
operands[2], operands[3])); |
| 7338 |
DONE; |
| 7339 |
} |
| 7340 |
[(set_attr "jal" "indirect,direct")]) |
| 7341 |
|
| 7342 |
(define_insn "call_value_multiple_split" |
| 7343 |
[(set (match_operand 0 "register_operand" "") |
| 7344 |
(call (mem:SI (match_operand 1 "call_insn_operand" "c,S")) |
| 7345 |
(match_operand 2 "" ""))) |
| 7346 |
(set (match_operand 3 "register_operand" "") |
| 7347 |
(call (mem:SI (match_dup 1)) |
| 7348 |
(match_dup 2))) |
| 7349 |
(clobber (reg:SI RETURN_ADDR_REGNUM)) |
| 7350 |
(clobber (reg:SI 28))] |
| 7351 |
"TARGET_SPLIT_CALLS" |
| 7352 |
{ return mips_output_jump (operands, 1, 2, true); } |
| 7353 |
[(set_attr "jal" "indirect,direct") |
| 7354 |
(set_attr "jal_macro" "no")]) |
| 7355 |
|
| 7356 |
;; Call subroutine returning any type. |
| 7357 |
|
| 7358 |
(define_expand "untyped_call" |
| 7359 |
[(parallel [(call (match_operand 0 "") |
| 7360 |
(const_int 0)) |
| 7361 |
(match_operand 1 "") |
| 7362 |
(match_operand 2 "")])] |
| 7363 |
"" |
| 7364 |
{ |
| 7365 |
int i; |
| 7366 |
|
| 7367 |
emit_call_insn (gen_call (operands[0], const0_rtx, NULL, const0_rtx)); |
| 7368 |
|
| 7369 |
for (i = 0; i < XVECLEN (operands[2], 0); i++) |
| 7370 |
{ |
| 7371 |
rtx set = XVECEXP (operands[2], 0, i); |
| 7372 |
mips_emit_move (SET_DEST (set), SET_SRC (set)); |
| 7373 |
} |
| 7374 |
|
| 7375 |
emit_insn (gen_blockage ()); |
| 7376 |
DONE; |
| 7377 |
}) |
| 7378 |
|
| 7379 |
;; |
| 7380 |
;; .................... |
| 7381 |
;; |
| 7382 |
;; MISC. |
| 7383 |
;; |
| 7384 |
;; .................... |
| 7385 |
;; |
| 7386 |
|
| 7387 |
|
| 7388 |
(define_insn "prefetch" |
| 7389 |
[(prefetch (match_operand:QI 0 "address_operand" "ZD") |
| 7390 |
(match_operand 1 "const_int_operand" "n") |
| 7391 |
(match_operand 2 "const_int_operand" "n"))] |
| 7392 |
"ISA_HAS_PREFETCH && TARGET_EXPLICIT_RELOCS" |
| 7393 |
{ |
| 7394 |
if (TARGET_LOONGSON_2EF || TARGET_LOONGSON_EXT) |
| 7395 |
{ |
| 7396 |
/* Loongson 2[ef] and Loongson ext use load to $0 for prefetching. */ |
| 7397 |
if (TARGET_64BIT) |
| 7398 |
return "ld\t$0,%a0"; |
| 7399 |
else |
| 7400 |
return "lw\t$0,%a0"; |
| 7401 |
} |
| 7402 |
if (operands[1] == const2_rtx) |
| 7403 |
operands[1] = const0_rtx; |
| 7404 |
/* Loongson ext2 implementation pref instructions. */ |
| 7405 |
if (TARGET_LOONGSON_EXT2) |
| 7406 |
{ |
| 7407 |
operands[1] = mips_loongson_ext2_prefetch_cookie (operands[1], |
| 7408 |
operands[2]); |
| 7409 |
return "pref\t%1, %a0"; |
| 7410 |
} |
| 7411 |
operands[1] = mips_prefetch_cookie (operands[1], operands[2]); |
| 7412 |
return "pref\t%1,%a0"; |
| 7413 |
} |
| 7414 |
[(set_attr "type" "prefetch")]) |
| 7415 |
|
| 7416 |
(define_insn "*prefetch_indexed_<mode>" |
| 7417 |
[(prefetch (plus:P (match_operand:P 0 "register_operand" "d") |
| 7418 |
(match_operand:P 1 "register_operand" "d")) |
| 7419 |
(match_operand 2 "const_int_operand" "n") |
| 7420 |
(match_operand 3 "const_int_operand" "n"))] |
| 7421 |
"ISA_HAS_PREFETCHX && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT" |
| 7422 |
{ |
| 7423 |
if (TARGET_LOONGSON_EXT) |
| 7424 |
{ |
| 7425 |
/* Loongson Loongson ext use index load to $0 for prefetching. */ |
| 7426 |
if (TARGET_64BIT) |
| 7427 |
return "gsldx\t$0,0(%0,%1)"; |
| 7428 |
else |
| 7429 |
return "gslwx\t$0,0(%0,%1)"; |
| 7430 |
} |
| 7431 |
/* Loongson ext2 implementation pref instructions. */ |
| 7432 |
if (TARGET_LOONGSON_EXT2) |
| 7433 |
{ |
| 7434 |
operands[2] = mips_loongson_ext2_prefetch_cookie (operands[2], |
| 7435 |
operands[3]); |
| 7436 |
return "prefx\t%2,%1(%0)"; |
| 7437 |
} |
| 7438 |
operands[2] = mips_prefetch_cookie (operands[2], operands[3]); |
| 7439 |
return "prefx\t%2,%1(%0)"; |
| 7440 |
} |
| 7441 |
[(set_attr "type" "prefetchx")]) |
| 7442 |
|
| 7443 |
(define_insn "nop" |
| 7444 |
[(const_int 0)] |
| 7445 |
"" |
| 7446 |
"%(nop%)" |
| 7447 |
[(set_attr "type" "nop") |
| 7448 |
(set_attr "mode" "none")]) |
| 7449 |
|
| 7450 |
;; Like nop, but commented out when outside a .set noreorder block. |
| 7451 |
(define_insn "hazard_nop" |
| 7452 |
[(const_int 1)] |
| 7453 |
"" |
| 7454 |
{ |
| 7455 |
if (mips_noreorder.nesting_level > 0) |
| 7456 |
return "nop"; |
| 7457 |
else |
| 7458 |
return "#nop"; |
| 7459 |
} |
| 7460 |
[(set_attr "type" "nop")]) |
| 7461 |
|
| 7462 |
;; The `.insn' pseudo-op. |
| 7463 |
(define_insn "insn_pseudo" |
| 7464 |
[(unspec_volatile [(const_int 0)] UNSPEC_INSN_PSEUDO)] |
| 7465 |
"" |
| 7466 |
".insn" |
| 7467 |
[(set_attr "mode" "none") |
| 7468 |
(set_attr "insn_count" "0")]) |
| 7469 |
|
| 7470 |
;; MIPS4 Conditional move instructions. |
| 7471 |
|
| 7472 |
(define_insn "mov<GPR:mode>_on_<MOVECC:mode>" |
| 7473 |
[(set (match_operand:GPR 0 "register_operand" "=d,d") |
| 7474 |
(if_then_else:GPR |
| 7475 |
(match_operator 4 "equality_operator" |
| 7476 |
[(match_operand:MOVECC 1 "register_operand" "<MOVECC:reg>,<MOVECC:reg>") |
| 7477 |
(const_int 0)]) |
| 7478 |
(match_operand:GPR 2 "reg_or_0_operand" "dJ,0") |
| 7479 |
(match_operand:GPR 3 "reg_or_0_operand" "0,dJ")))] |
| 7480 |
"!TARGET_MIPS16 && ISA_HAS_CONDMOVE" |
| 7481 |
"@ |
| 7482 |
mov%T4\t%0,%z2,%1 |
| 7483 |
mov%t4\t%0,%z3,%1" |
| 7484 |
[(set_attr "type" "condmove") |
| 7485 |
(set_attr "mode" "<GPR:MODE>")]) |
| 7486 |
|
| 7487 |
(define_insn "mov<GPR:mode>_on_<MOVECC:mode>_mips16e2" |
| 7488 |
[(set (match_operand:GPR 0 "register_operand" "=d,d,d,d") |
| 7489 |
(if_then_else:GPR |
| 7490 |
(match_operator 4 "equality_operator" |
| 7491 |
[(match_operand:MOVECC 1 "register_operand" "<MOVECC:reg>,<MOVECC:reg>,t,t") |
| 7492 |
(const_int 0)]) |
| 7493 |
(match_operand:GPR 2 "reg_or_0_operand_mips16e2" "dJ,0,dJ,0") |
| 7494 |
(match_operand:GPR 3 "reg_or_0_operand_mips16e2" "0,dJ,0,dJ")))] |
| 7495 |
"ISA_HAS_MIPS16E2 && ISA_HAS_CONDMOVE" |
| 7496 |
"@ |
| 7497 |
mov%T4\t%0,%z2,%1 |
| 7498 |
mov%t4\t%0,%z3,%1 |
| 7499 |
movt%T4\t%0,%z2 |
| 7500 |
movt%t4\t%0,%z3" |
| 7501 |
[(set_attr "type" "condmove") |
| 7502 |
(set_attr "mode" "<GPR:MODE>") |
| 7503 |
(set_attr "extended_mips16" "yes")]) |
| 7504 |
|
| 7505 |
(define_insn "mov<GPR:mode>_on_<GPR2:mode>_ne" |
| 7506 |
[(set (match_operand:GPR 0 "register_operand" "=d,d") |
| 7507 |
(if_then_else:GPR |
| 7508 |
(match_operand:GPR2 1 "register_operand" "<GPR2:reg>,<GPR2:reg>") |
| 7509 |
(match_operand:GPR 2 "reg_or_0_operand" "dJ,0") |
| 7510 |
(match_operand:GPR 3 "reg_or_0_operand" "0,dJ")))] |
| 7511 |
"!TARGET_MIPS16 && ISA_HAS_CONDMOVE" |
| 7512 |
"@ |
| 7513 |
movn\t%0,%z2,%1 |
| 7514 |
movz\t%0,%z3,%1" |
| 7515 |
[(set_attr "type" "condmove") |
| 7516 |
(set_attr "mode" "<GPR:MODE>")]) |
| 7517 |
|
| 7518 |
(define_insn "mov<GPR:mode>_on_<GPR2:mode>_ne_mips16e2" |
| 7519 |
[(set (match_operand:GPR 0 "register_operand" "=d,d,d,d") |
| 7520 |
(if_then_else:GPR |
| 7521 |
(match_operand:GPR2 1 "register_operand" "<GPR2:reg>,<GPR2:reg>,t,t") |
| 7522 |
(match_operand:GPR 2 "reg_or_0_operand_mips16e2" "dJ,0,dJ,0") |
| 7523 |
(match_operand:GPR 3 "reg_or_0_operand_mips16e2" "0,dJ,0,dJ")))] |
| 7524 |
"ISA_HAS_MIPS16E2 && ISA_HAS_CONDMOVE" |
| 7525 |
"@ |
| 7526 |
movn\t%0,%z2,%1 |
| 7527 |
movz\t%0,%z3,%1 |
| 7528 |
movtn\t%0,%z2 |
| 7529 |
movtz\t%0,%z3" |
| 7530 |
[(set_attr "type" "condmove") |
| 7531 |
(set_attr "mode" "<GPR:MODE>") |
| 7532 |
(set_attr "extended_mips16" "yes")]) |
| 7533 |
|
| 7534 |
(define_insn "*mov<SCALARF:mode>_on_<MOVECC:mode>" |
| 7535 |
[(set (match_operand:SCALARF 0 "register_operand" "=f,f") |
| 7536 |
(if_then_else:SCALARF |
| 7537 |
(match_operator 4 "equality_operator" |
| 7538 |
[(match_operand:MOVECC 1 "register_operand" "<MOVECC:reg>,<MOVECC:reg>") |
| 7539 |
(const_int 0)]) |
| 7540 |
(match_operand:SCALARF 2 "register_operand" "f,0") |
| 7541 |
(match_operand:SCALARF 3 "register_operand" "0,f")))] |
| 7542 |
"ISA_HAS_FP_CONDMOVE" |
| 7543 |
"@ |
| 7544 |
mov%T4.<fmt>\t%0,%2,%1 |
| 7545 |
mov%t4.<fmt>\t%0,%3,%1" |
| 7546 |
[(set_attr "type" "condmove") |
| 7547 |
(set_attr "mode" "<SCALARF:MODE>")]) |
| 7548 |
|
| 7549 |
(define_insn "*sel<code><GPR:mode>_using_<GPR2:mode>" |
| 7550 |
[(set (match_operand:GPR 0 "register_operand" "=d,d") |
| 7551 |
(if_then_else:GPR |
| 7552 |
(equality_op:GPR2 (match_operand:GPR2 1 "register_operand" "d,d") |
| 7553 |
(const_int 0)) |
| 7554 |
(match_operand:GPR 2 "reg_or_0_operand" "d,J") |
| 7555 |
(match_operand:GPR 3 "reg_or_0_operand" "J,d")))] |
| 7556 |
"ISA_HAS_SEL |
| 7557 |
&& (register_operand (operands[2], <GPR:MODE>mode) |
| 7558 |
!= register_operand (operands[3], <GPR:MODE>mode))" |
| 7559 |
"@ |
| 7560 |
<sel>\t%0,%2,%1 |
| 7561 |
<selinv>\t%0,%3,%1" |
| 7562 |
[(set_attr "type" "condmove") |
| 7563 |
(set_attr "mode" "<GPR:MODE>")]) |
| 7564 |
|
| 7565 |
;; sel.fmt copies the 3rd argument when the 1st is non-zero and the 2nd |
| 7566 |
;; argument if the 1st is zero. This means operand 2 and 3 are |
| 7567 |
;; inverted in the instruction. |
| 7568 |
|
| 7569 |
(define_insn "*sel<mode>" |
| 7570 |
[(set (match_operand:SCALARF 0 "register_operand" "=f,f,f") |
| 7571 |
(if_then_else:SCALARF |
| 7572 |
(ne:CCF (match_operand:CCF 1 "register_operand" "0,f,f") |
| 7573 |
(const_int 0)) |
| 7574 |
(match_operand:SCALARF 2 "reg_or_0_operand" "f,G,f") |
| 7575 |
(match_operand:SCALARF 3 "reg_or_0_operand" "f,f,G")))] |
| 7576 |
"ISA_HAS_SEL && ISA_HAS_CCF" |
| 7577 |
"@ |
| 7578 |
sel.<fmt>\t%0,%3,%2 |
| 7579 |
seleqz.<fmt>\t%0,%3,%1 |
| 7580 |
selnez.<fmt>\t%0,%2,%1" |
| 7581 |
[(set_attr "type" "condmove") |
| 7582 |
(set_attr "mode" "<SCALARF:MODE>")]) |
| 7583 |
|
| 7584 |
;; These are the main define_expand's used to make conditional moves. |
| 7585 |
|
| 7586 |
(define_expand "mov<mode>cc" |
| 7587 |
[(set (match_dup 4) (match_operand 1 "comparison_operator")) |
| 7588 |
(set (match_operand:GPR 0 "register_operand") |
| 7589 |
(if_then_else:GPR (match_dup 5) |
| 7590 |
(match_operand:GPR 2 "reg_or_0_operand") |
| 7591 |
(match_operand:GPR 3 "reg_or_0_operand")))] |
| 7592 |
"ISA_HAS_CONDMOVE || ISA_HAS_SEL" |
| 7593 |
{ |
| 7594 |
if (!ISA_HAS_FP_CONDMOVE |
| 7595 |
&& !INTEGRAL_MODE_P (GET_MODE (XEXP (operands[1], 0)))) |
| 7596 |
FAIL; |
| 7597 |
|
| 7598 |
mips_expand_conditional_move (operands); |
| 7599 |
DONE; |
| 7600 |
}) |
| 7601 |
|
| 7602 |
(define_expand "mov<mode>cc" |
| 7603 |
[(set (match_dup 4) (match_operand 1 "comparison_operator")) |
| 7604 |
(set (match_operand:SCALARF 0 "register_operand") |
| 7605 |
(if_then_else:SCALARF (match_dup 5) |
| 7606 |
(match_operand:SCALARF 2 "reg_or_0_operand") |
| 7607 |
(match_operand:SCALARF 3 "reg_or_0_operand")))] |
| 7608 |
"ISA_HAS_FP_CONDMOVE |
| 7609 |
|| (ISA_HAS_SEL && ISA_HAS_CCF)" |
| 7610 |
{ |
| 7611 |
if (ISA_HAS_SEL && !FLOAT_MODE_P (GET_MODE (XEXP (operands[1], 0)))) |
| 7612 |
FAIL; |
| 7613 |
|
| 7614 |
/* Workaround an LRA bug which means that tied operands in the sel.fmt |
| 7615 |
pattern lead to the double precision destination of sel.d getting |
| 7616 |
reloaded with the full register file usable and the restrictions on |
| 7617 |
whether the CCFmode input can be used in odd-numbered single-precision |
| 7618 |
registers are ignored. For consistency reasons the CCF mode values |
| 7619 |
must be guaranteed to only exist in the even-registers because of |
| 7620 |
the unusual duality between single and double precision values. */ |
| 7621 |
if (ISA_HAS_SEL && <MODE>mode == DFmode |
| 7622 |
&& (!TARGET_ODD_SPREG || TARGET_FLOATXX)) |
| 7623 |
FAIL; |
| 7624 |
|
| 7625 |
mips_expand_conditional_move (operands); |
| 7626 |
DONE; |
| 7627 |
}) |
| 7628 |
|
| 7629 |
(define_expand "speculation_barrier" |
| 7630 |
[(unspec_volatile [(const_int 0)] VUNSPEC_SPECULATION_BARRIER)] |
| 7631 |
"" |
| 7632 |
" |
| 7633 |
mips_emit_speculation_barrier_function (); |
| 7634 |
DONE; |
| 7635 |
" |
| 7636 |
) |
| 7637 |
|
| 7638 |
|
| 7639 |
;; |
| 7640 |
;; .................... |
| 7641 |
;; |
| 7642 |
;; mips16 inline constant tables |
| 7643 |
;; |
| 7644 |
;; .................... |
| 7645 |
;; |
| 7646 |
|
| 7647 |
(define_insn "consttable" |
| 7648 |
[(unspec_volatile [(match_operand 0 "const_int_operand" "")] |
| 7649 |
UNSPEC_CONSTTABLE)] |
| 7650 |
"" |
| 7651 |
"" |
| 7652 |
[(set_attr "mode" "none") |
| 7653 |
(set_attr "insn_count" "0")]) |
| 7654 |
|
| 7655 |
(define_insn "consttable_end" |
| 7656 |
[(unspec_volatile [(match_operand 0 "const_int_operand" "")] |
| 7657 |
UNSPEC_CONSTTABLE_END)] |
| 7658 |
"" |
| 7659 |
"" |
| 7660 |
[(set_attr "mode" "none") |
| 7661 |
(set_attr "insn_count" "0")]) |
| 7662 |
|
| 7663 |
(define_insn "consttable_tls_reloc" |
| 7664 |
[(unspec_volatile [(match_operand 0 "tls_reloc_operand" "") |
| 7665 |
(match_operand 1 "const_int_operand" "")] |
| 7666 |
UNSPEC_CONSTTABLE_INT)] |
| 7667 |
"TARGET_MIPS16_PCREL_LOADS" |
| 7668 |
{ return mips_output_tls_reloc_directive (&operands[0]); } |
| 7669 |
[(set (attr "length") (symbol_ref "INTVAL (operands[1])"))]) |
| 7670 |
|
| 7671 |
(define_insn "consttable_int" |
| 7672 |
[(unspec_volatile [(match_operand 0 "consttable_operand" "") |
| 7673 |
(match_operand 1 "const_int_operand" "")] |
| 7674 |
UNSPEC_CONSTTABLE_INT)] |
| 7675 |
"TARGET_MIPS16" |
| 7676 |
{ |
| 7677 |
assemble_integer (mips_strip_unspec_address (operands[0]), |
| 7678 |
INTVAL (operands[1]), |
| 7679 |
BITS_PER_UNIT * INTVAL (operands[1]), 1); |
| 7680 |
return ""; |
| 7681 |
} |
| 7682 |
[(set (attr "length") (symbol_ref "INTVAL (operands[1])"))]) |
| 7683 |
|
| 7684 |
(define_insn "consttable_float" |
| 7685 |
[(unspec_volatile [(match_operand 0 "consttable_operand" "")] |
| 7686 |
UNSPEC_CONSTTABLE_FLOAT)] |
| 7687 |
"TARGET_MIPS16" |
| 7688 |
{ |
| 7689 |
gcc_assert (GET_CODE (operands[0]) == CONST_DOUBLE); |
| 7690 |
assemble_real (*CONST_DOUBLE_REAL_VALUE (operands[0]), |
| 7691 |
as_a <scalar_float_mode> (GET_MODE (operands[0])), |
| 7692 |
GET_MODE_BITSIZE (GET_MODE (operands[0]))); |
| 7693 |
return ""; |
| 7694 |
} |
| 7695 |
[(set (attr "length") |
| 7696 |
(symbol_ref "GET_MODE_SIZE (GET_MODE (operands[0]))"))]) |
| 7697 |
|
| 7698 |
(define_insn "align" |
| 7699 |
[(unspec_volatile [(match_operand 0 "const_int_operand" "")] UNSPEC_ALIGN)] |
| 7700 |
"" |
| 7701 |
".align\t%0" |
| 7702 |
[(set (attr "length") (symbol_ref "(1 << INTVAL (operands[0])) - 1"))]) |
| 7703 |
|
| 7704 |
(define_split |
| 7705 |
[(match_operand 0 "small_data_pattern")] |
| 7706 |
"reload_completed" |
| 7707 |
[(match_dup 0)] |
| 7708 |
{ operands[0] = mips_rewrite_small_data (operands[0]); }) |
| 7709 |
|
| 7710 |
;; |
| 7711 |
;; .................... |
| 7712 |
;; |
| 7713 |
;; MIPS16e Save/Restore |
| 7714 |
;; |
| 7715 |
;; .................... |
| 7716 |
;; |
| 7717 |
|
| 7718 |
(define_insn "*mips16e_save_restore" |
| 7719 |
[(match_parallel 0 "" |
| 7720 |
[(set (match_operand:SI 1 "register_operand") |
| 7721 |
(plus:SI (match_dup 1) |
| 7722 |
(match_operand:SI 2 "const_int_operand")))])] |
| 7723 |
"operands[1] == stack_pointer_rtx |
| 7724 |
&& mips16e_save_restore_pattern_p (operands[0], INTVAL (operands[2]), NULL)" |
| 7725 |
{ return mips16e_output_save_restore (operands[0], INTVAL (operands[2])); } |
| 7726 |
[(set_attr "type" "arith") |
| 7727 |
(set_attr "extended_mips16" "yes")]) |
| 7728 |
|
| 7729 |
;; Thread-Local Storage |
| 7730 |
|
| 7731 |
;; The TLS base pointer is accessed via "rdhwr $3, $29". No current |
| 7732 |
;; MIPS architecture defines this register, and no current |
| 7733 |
;; implementation provides it; instead, any OS which supports TLS is |
| 7734 |
;; expected to trap and emulate this instruction. rdhwr is part of the |
| 7735 |
;; MIPS 32r2 specification, but we use it on any architecture because |
| 7736 |
;; we expect it to be emulated. Use .set to force the assembler to |
| 7737 |
;; accept it. |
| 7738 |
;; |
| 7739 |
;; We do not use a constraint to force the destination to be $3 |
| 7740 |
;; because $3 can appear explicitly as a function return value. |
| 7741 |
;; If we leave the use of $3 implicit in the constraints until |
| 7742 |
;; reload, we may end up making a $3 return value live across |
| 7743 |
;; the instruction, leading to a spill failure when reloading it. |
| 7744 |
(define_insn_and_split "tls_get_tp_<mode>" |
| 7745 |
[(set (match_operand:P 0 "register_operand" "=d") |
| 7746 |
(unspec:P [(const_int 0)] UNSPEC_TLS_GET_TP)) |
| 7747 |
(clobber (reg:P TLS_GET_TP_REGNUM))] |
| 7748 |
"HAVE_AS_TLS && !TARGET_MIPS16" |
| 7749 |
"#" |
| 7750 |
"&& reload_completed" |
| 7751 |
[(set (reg:P TLS_GET_TP_REGNUM) |
| 7752 |
(unspec:P [(const_int 0)] UNSPEC_TLS_GET_TP)) |
| 7753 |
(set (match_dup 0) (reg:P TLS_GET_TP_REGNUM))] |
| 7754 |
"" |
| 7755 |
[(set_attr "type" "unknown") |
| 7756 |
(set_attr "mode" "<MODE>") |
| 7757 |
(set_attr "insn_count" "2")]) |
| 7758 |
|
| 7759 |
(define_insn "*tls_get_tp_<mode>_split" |
| 7760 |
[(set (reg:P TLS_GET_TP_REGNUM) |
| 7761 |
(unspec:P [(const_int 0)] UNSPEC_TLS_GET_TP))] |
| 7762 |
"HAVE_AS_TLS && !TARGET_MIPS16" |
| 7763 |
{ |
| 7764 |
if (mips_isa_rev >= 2) |
| 7765 |
return "rdhwr\t$3,$29"; |
| 7766 |
|
| 7767 |
return ".set\tpush\;.set\tmips32r2\t\;rdhwr\t$3,$29\;.set\tpop"; |
| 7768 |
} |
| 7769 |
[(set_attr "type" "unknown") |
| 7770 |
; Since rdhwr always generates a trap for now, putting it in a delay |
| 7771 |
; slot would make the kernel's emulation of it much slower. |
| 7772 |
(set_attr "can_delay" "no") |
| 7773 |
(set_attr "mode" "<MODE>")]) |
| 7774 |
|
| 7775 |
;; In MIPS16 mode, the TLS base pointer is accessed by a |
| 7776 |
;; libgcc helper function __mips16_rdhwr(), as 'rdhwr' is not |
| 7777 |
;; accessible in MIPS16. |
| 7778 |
;; |
| 7779 |
;; This is not represented as a call insn, to avoid the |
| 7780 |
;; unnecesarry clobbering of caller-save registers by a |
| 7781 |
;; function consisting only of: "rdhwr $3,$29; j $31; nop;" |
| 7782 |
;; |
| 7783 |
;; A $25 clobber is added to cater for a $25 load stub added by the |
| 7784 |
;; linker to __mips16_rdhwr when the call is made from non-PIC code. |
| 7785 |
|
| 7786 |
(define_insn_and_split "tls_get_tp_mips16_<mode>" |
| 7787 |
[(set (match_operand:P 0 "register_operand" "=d") |
| 7788 |
(unspec:P [(match_operand:P 1 "call_insn_operand" "dS")] |
| 7789 |
UNSPEC_TLS_GET_TP)) |
| 7790 |
(clobber (reg:P TLS_GET_TP_REGNUM)) |
| 7791 |
(clobber (reg:P PIC_FUNCTION_ADDR_REGNUM)) |
| 7792 |
(clobber (reg:P RETURN_ADDR_REGNUM))] |
| 7793 |
"HAVE_AS_TLS && TARGET_MIPS16" |
| 7794 |
"#" |
| 7795 |
"&& reload_completed" |
| 7796 |
[(parallel [(set (reg:P TLS_GET_TP_REGNUM) |
| 7797 |
(unspec:P [(match_dup 1)] UNSPEC_TLS_GET_TP)) |
| 7798 |
(clobber (reg:P PIC_FUNCTION_ADDR_REGNUM)) |
| 7799 |
(clobber (reg:P RETURN_ADDR_REGNUM))]) |
| 7800 |
(set (match_dup 0) (reg:P TLS_GET_TP_REGNUM))] |
| 7801 |
"" |
| 7802 |
[(set_attr "type" "multi") |
| 7803 |
(set_attr "insn_count" "4") |
| 7804 |
(set_attr "mode" "<MODE>")]) |
| 7805 |
|
| 7806 |
(define_insn "*tls_get_tp_mips16_call_<mode>" |
| 7807 |
[(set (reg:P TLS_GET_TP_REGNUM) |
| 7808 |
(unspec:P [(match_operand:P 0 "call_insn_operand" "dS")] |
| 7809 |
UNSPEC_TLS_GET_TP)) |
| 7810 |
(clobber (reg:P PIC_FUNCTION_ADDR_REGNUM)) |
| 7811 |
(clobber (reg:P RETURN_ADDR_REGNUM))] |
| 7812 |
"HAVE_AS_TLS && TARGET_MIPS16" |
| 7813 |
{ return mips_output_jump (operands, 0, -1, true); } |
| 7814 |
[(set_attr "type" "call") |
| 7815 |
(set_attr "insn_count" "3") |
| 7816 |
(set_attr "mode" "<MODE>")]) |
| 7817 |
|
| 7818 |
;; Named pattern for expanding thread pointer reference. |
| 7819 |
(define_expand "get_thread_pointer<mode>" |
| 7820 |
[(match_operand:P 0 "register_operand" "=d")] |
| 7821 |
"HAVE_AS_TLS" |
| 7822 |
{ |
| 7823 |
mips_expand_thread_pointer (operands[0]); |
| 7824 |
DONE; |
| 7825 |
}) |
| 7826 |
|
| 7827 |
;; __builtin_mips_get_fcsr: move the FCSR into operand 0. |
| 7828 |
(define_expand "mips_get_fcsr" |
| 7829 |
[(set (match_operand:SI 0 "register_operand") |
| 7830 |
(unspec_volatile:SI [(const_int 0)] UNSPEC_GET_FCSR))] |
| 7831 |
"TARGET_HARD_FLOAT_ABI" |
| 7832 |
{ |
| 7833 |
if (TARGET_MIPS16) |
| 7834 |
{ |
| 7835 |
mips16_expand_get_fcsr (operands[0]); |
| 7836 |
DONE; |
| 7837 |
} |
| 7838 |
}) |
| 7839 |
|
| 7840 |
(define_insn "*mips_get_fcsr" |
| 7841 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 7842 |
(unspec_volatile:SI [(const_int 0)] UNSPEC_GET_FCSR))] |
| 7843 |
"TARGET_HARD_FLOAT" |
| 7844 |
"cfc1\t%0,$31") |
| 7845 |
|
| 7846 |
;; See tls_get_tp_mips16_<mode> for why this form is used. |
| 7847 |
(define_insn "mips_get_fcsr_mips16_<mode>" |
| 7848 |
[(set (reg:SI GET_FCSR_REGNUM) |
| 7849 |
(unspec:SI [(match_operand:P 0 "call_insn_operand" "dS")] |
| 7850 |
UNSPEC_GET_FCSR)) |
| 7851 |
(clobber (reg:P PIC_FUNCTION_ADDR_REGNUM)) |
| 7852 |
(clobber (reg:P RETURN_ADDR_REGNUM))] |
| 7853 |
"TARGET_HARD_FLOAT_ABI && TARGET_MIPS16" |
| 7854 |
{ return mips_output_jump (operands, 0, -1, true); } |
| 7855 |
[(set_attr "type" "call") |
| 7856 |
(set_attr "insn_count" "3")]) |
| 7857 |
|
| 7858 |
;; __builtin_mips_set_fcsr: move operand 0 into the FCSR. |
| 7859 |
(define_expand "mips_set_fcsr" |
| 7860 |
[(unspec_volatile [(match_operand:SI 0 "register_operand")] |
| 7861 |
UNSPEC_SET_FCSR)] |
| 7862 |
"TARGET_HARD_FLOAT_ABI" |
| 7863 |
{ |
| 7864 |
if (TARGET_MIPS16) |
| 7865 |
{ |
| 7866 |
mips16_expand_set_fcsr (operands[0]); |
| 7867 |
DONE; |
| 7868 |
} |
| 7869 |
}) |
| 7870 |
|
| 7871 |
(define_insn "*mips_set_fcsr" |
| 7872 |
[(unspec_volatile [(match_operand:SI 0 "register_operand" "d")] |
| 7873 |
UNSPEC_SET_FCSR)] |
| 7874 |
"TARGET_HARD_FLOAT" |
| 7875 |
"ctc1\t%0,$31") |
| 7876 |
|
| 7877 |
;; See tls_get_tp_mips16_<mode> for why this form is used. |
| 7878 |
(define_insn "mips_set_fcsr_mips16_<mode>" |
| 7879 |
[(unspec_volatile:SI [(match_operand:P 0 "call_insn_operand" "dS") |
| 7880 |
(reg:SI SET_FCSR_REGNUM)] UNSPEC_SET_FCSR) |
| 7881 |
(clobber (reg:P PIC_FUNCTION_ADDR_REGNUM)) |
| 7882 |
(clobber (reg:P RETURN_ADDR_REGNUM))] |
| 7883 |
"TARGET_HARD_FLOAT_ABI && TARGET_MIPS16" |
| 7884 |
{ return mips_output_jump (operands, 0, -1, true); } |
| 7885 |
[(set_attr "type" "call") |
| 7886 |
(set_attr "insn_count" "3")]) |
| 7887 |
|
| 7888 |
;; Match paired HI/SI/SF/DFmode load/stores. |
| 7889 |
(define_insn "*join2_load_store<JOIN_MODE:mode>" |
| 7890 |
[(set (match_operand:JOIN_MODE 0 "nonimmediate_operand" "=d,f,m,m") |
| 7891 |
(match_operand:JOIN_MODE 1 "nonimmediate_operand" "m,m,d,f")) |
| 7892 |
(set (match_operand:JOIN_MODE 2 "nonimmediate_operand" "=d,f,m,m") |
| 7893 |
(match_operand:JOIN_MODE 3 "nonimmediate_operand" "m,m,d,f"))] |
| 7894 |
"ENABLE_LD_ST_PAIRS && reload_completed" |
| 7895 |
{ |
| 7896 |
bool load_p = (which_alternative == 0 || which_alternative == 1); |
| 7897 |
/* Reg-renaming pass reuses base register if it is dead after bonded loads. |
| 7898 |
Hardware does not bond those loads, even when they are consecutive. |
| 7899 |
However, order of the loads need to be checked for correctness. */ |
| 7900 |
if (!load_p || !reg_overlap_mentioned_p (operands[0], operands[1])) |
| 7901 |
{ |
| 7902 |
output_asm_insn (mips_output_move (operands[0], operands[1]), |
| 7903 |
operands); |
| 7904 |
output_asm_insn (mips_output_move (operands[2], operands[3]), |
| 7905 |
&operands[2]); |
| 7906 |
} |
| 7907 |
else |
| 7908 |
{ |
| 7909 |
output_asm_insn (mips_output_move (operands[2], operands[3]), |
| 7910 |
&operands[2]); |
| 7911 |
output_asm_insn (mips_output_move (operands[0], operands[1]), |
| 7912 |
operands); |
| 7913 |
} |
| 7914 |
return ""; |
| 7915 |
} |
| 7916 |
[(set_attr "move_type" "load,fpload,store,fpstore") |
| 7917 |
(set_attr "insn_count" "2,2,2,2")]) |
| 7918 |
|
| 7919 |
;; 2 HI/SI/SF/DF loads are joined. |
| 7920 |
;; P5600 does not support bonding of two LBs, hence QI mode is not included. |
| 7921 |
;; The loads must be non-volatile as they might be reordered at the time of asm |
| 7922 |
;; generation. |
| 7923 |
(define_peephole2 |
| 7924 |
[(set (match_operand:JOIN_MODE 0 "register_operand") |
| 7925 |
(match_operand:JOIN_MODE 1 "non_volatile_mem_operand")) |
| 7926 |
(set (match_operand:JOIN_MODE 2 "register_operand") |
| 7927 |
(match_operand:JOIN_MODE 3 "non_volatile_mem_operand"))] |
| 7928 |
"ENABLE_LD_ST_PAIRS |
| 7929 |
&& mips_load_store_bonding_p (operands, <JOIN_MODE:MODE>mode, true)" |
| 7930 |
[(parallel [(set (match_dup 0) |
| 7931 |
(match_dup 1)) |
| 7932 |
(set (match_dup 2) |
| 7933 |
(match_dup 3))])] |
| 7934 |
"") |
| 7935 |
|
| 7936 |
;; 2 HI/SI/SF/DF stores are joined. |
| 7937 |
;; P5600 does not support bonding of two SBs, hence QI mode is not included. |
| 7938 |
(define_peephole2 |
| 7939 |
[(set (match_operand:JOIN_MODE 0 "memory_operand") |
| 7940 |
(match_operand:JOIN_MODE 1 "register_operand")) |
| 7941 |
(set (match_operand:JOIN_MODE 2 "memory_operand") |
| 7942 |
(match_operand:JOIN_MODE 3 "register_operand"))] |
| 7943 |
"ENABLE_LD_ST_PAIRS |
| 7944 |
&& mips_load_store_bonding_p (operands, <JOIN_MODE:MODE>mode, false)" |
| 7945 |
[(parallel [(set (match_dup 0) |
| 7946 |
(match_dup 1)) |
| 7947 |
(set (match_dup 2) |
| 7948 |
(match_dup 3))])] |
| 7949 |
"") |
| 7950 |
|
| 7951 |
;; Match paired HImode loads. |
| 7952 |
(define_insn "*join2_loadhi" |
| 7953 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 7954 |
(any_extend:SI (match_operand:HI 1 "non_volatile_mem_operand" "m"))) |
| 7955 |
(set (match_operand:SI 2 "register_operand" "=r") |
| 7956 |
(any_extend:SI (match_operand:HI 3 "non_volatile_mem_operand" "m")))] |
| 7957 |
"ENABLE_LD_ST_PAIRS && reload_completed" |
| 7958 |
{ |
| 7959 |
/* Reg-renaming pass reuses base register if it is dead after bonded loads. |
| 7960 |
Hardware does not bond those loads, even when they are consecutive. |
| 7961 |
However, order of the loads need to be checked for correctness. */ |
| 7962 |
if (!reg_overlap_mentioned_p (operands[0], operands[1])) |
| 7963 |
{ |
| 7964 |
output_asm_insn ("lh<u>\t%0,%1", operands); |
| 7965 |
output_asm_insn ("lh<u>\t%2,%3", operands); |
| 7966 |
} |
| 7967 |
else |
| 7968 |
{ |
| 7969 |
output_asm_insn ("lh<u>\t%2,%3", operands); |
| 7970 |
output_asm_insn ("lh<u>\t%0,%1", operands); |
| 7971 |
} |
| 7972 |
|
| 7973 |
return ""; |
| 7974 |
} |
| 7975 |
[(set_attr "move_type" "load") |
| 7976 |
(set_attr "insn_count" "2")]) |
| 7977 |
|
| 7978 |
;; |
| 7979 |
;; Float point MIN/MAX |
| 7980 |
;; |
| 7981 |
|
| 7982 |
(define_insn "smin<mode>3" |
| 7983 |
[(set (match_operand:SCALARF 0 "register_operand" "=f") |
| 7984 |
(smin:SCALARF (match_operand:SCALARF 1 "register_operand" "f") |
| 7985 |
(match_operand:SCALARF 2 "register_operand" "f")))] |
| 7986 |
"ISA_HAS_FMIN_FMAX" |
| 7987 |
"min.<fmt>\t%0,%1,%2" |
| 7988 |
[(set_attr "type" "fminmax") |
| 7989 |
(set_attr "mode" "<UNITMODE>")]) |
| 7990 |
|
| 7991 |
(define_insn "smax<mode>3" |
| 7992 |
[(set (match_operand:SCALARF 0 "register_operand" "=f") |
| 7993 |
(smax:SCALARF (match_operand:SCALARF 1 "register_operand" "f") |
| 7994 |
(match_operand:SCALARF 2 "register_operand" "f")))] |
| 7995 |
"ISA_HAS_FMIN_FMAX" |
| 7996 |
"max.<fmt>\t%0,%1,%2" |
| 7997 |
[(set_attr "type" "fminmax") |
| 7998 |
(set_attr "mode" "<UNITMODE>")]) |
| 7999 |
|
| 8000 |
(define_insn "fmin<mode>3" |
| 8001 |
[(set (match_operand:SCALARF 0 "register_operand" "=f") |
| 8002 |
(unspec:SCALARF [(use (match_operand:SCALARF 1 "register_operand" "f")) |
| 8003 |
(use (match_operand:SCALARF 2 "register_operand" "f"))] |
| 8004 |
UNSPEC_FMIN))] |
| 8005 |
"ISA_HAS_FMIN_FMAX" |
| 8006 |
"min.<fmt>\t%0,%1,%2" |
| 8007 |
[(set_attr "type" "fminmax") |
| 8008 |
(set_attr "mode" "<UNITMODE>")]) |
| 8009 |
|
| 8010 |
(define_insn "fmax<mode>3" |
| 8011 |
[(set (match_operand:SCALARF 0 "register_operand" "=f") |
| 8012 |
(unspec:SCALARF [(use (match_operand:SCALARF 1 "register_operand" "f")) |
| 8013 |
(use (match_operand:SCALARF 2 "register_operand" "f"))] |
| 8014 |
UNSPEC_FMAX))] |
| 8015 |
"ISA_HAS_FMIN_FMAX" |
| 8016 |
"max.<fmt>\t%0,%1,%2" |
| 8017 |
[(set_attr "type" "fminmax") |
| 8018 |
(set_attr "mode" "<UNITMODE>")]) |
| 8019 |
|
| 8020 |
(define_insn "fmin_a_<mode>" |
| 8021 |
[(set (match_operand:SCALARF 0 "register_operand" "=f") |
| 8022 |
(if_then_else |
| 8023 |
(lt (abs:SCALARF (match_operand:SCALARF 1 "register_operand" "f")) |
| 8024 |
(abs:SCALARF (match_operand:SCALARF 2 "register_operand" "f"))) |
| 8025 |
(match_dup 1) |
| 8026 |
(match_dup 2)))] |
| 8027 |
"ISA_HAS_FMIN_FMAX" |
| 8028 |
"mina.<fmt>\t%0,%1,%2" |
| 8029 |
[(set_attr "type" "fminmax") |
| 8030 |
(set_attr "mode" "<UNITMODE>")]) |
| 8031 |
|
| 8032 |
(define_insn "fmax_a_<mode>" |
| 8033 |
[(set (match_operand:SCALARF 0 "register_operand" "=f") |
| 8034 |
(if_then_else |
| 8035 |
(gt (abs:SCALARF (match_operand:SCALARF 1 "register_operand" "f")) |
| 8036 |
(abs:SCALARF (match_operand:SCALARF 2 "register_operand" "f"))) |
| 8037 |
(match_dup 1) |
| 8038 |
(match_dup 2)))] |
| 8039 |
"ISA_HAS_FMIN_FMAX" |
| 8040 |
"maxa.<fmt>\t%0,%1,%2" |
| 8041 |
[(set_attr "type" "fminmax") |
| 8042 |
(set_attr "mode" "<UNITMODE>")]) |
| 8043 |
|
| 8044 |
;;Float point round to integral |
| 8045 |
(define_insn "rint<mode>2" |
| 8046 |
[(set (match_operand:SCALARF 0 "register_operand" "=f") |
| 8047 |
(unspec:SCALARF [(match_operand:SCALARF 1 "register_operand" "f")] |
| 8048 |
UNSPEC_FRINT))] |
| 8049 |
"ISA_HAS_FRINT" |
| 8050 |
"rint.<fmt>\t%0,%1" |
| 8051 |
[(set_attr "type" "frint") |
| 8052 |
(set_attr "mode" "<UNITMODE>")]) |
| 8053 |
|
| 8054 |
;;Float point class mask |
| 8055 |
(define_insn "fclass_<mode>" |
| 8056 |
[(set (match_operand:SCALARF 0 "register_operand" "=f") |
| 8057 |
(unspec:SCALARF [(match_operand:SCALARF 1 "register_operand" "f")] |
| 8058 |
UNSPEC_FCLASS))] |
| 8059 |
"ISA_HAS_FCLASS" |
| 8060 |
"class.<fmt>\t%0,%1" |
| 8061 |
[(set_attr "type" "fclass") |
| 8062 |
(set_attr "mode" "<UNITMODE>")]) |
| 8063 |
|
| 8064 |
;; 2 HI loads are joined. |
| 8065 |
(define_peephole2 |
| 8066 |
[(set (match_operand:SI 0 "register_operand") |
| 8067 |
(any_extend:SI (match_operand:HI 1 "non_volatile_mem_operand"))) |
| 8068 |
(set (match_operand:SI 2 "register_operand") |
| 8069 |
(any_extend:SI (match_operand:HI 3 "non_volatile_mem_operand")))] |
| 8070 |
"ENABLE_LD_ST_PAIRS |
| 8071 |
&& mips_load_store_bonding_p (operands, HImode, true)" |
| 8072 |
[(parallel [(set (match_dup 0) |
| 8073 |
(any_extend:SI (match_dup 1))) |
| 8074 |
(set (match_dup 2) |
| 8075 |
(any_extend:SI (match_dup 3)))])] |
| 8076 |
"") |
| 8077 |
|
| 8078 |
|
| 8079 |
;; Synchronization instructions. |
| 8080 |
|
| 8081 |
(include "sync.md") |
| 8082 |
|
| 8083 |
; The MIPS Paired-Single Floating Point and MIPS-3D Instructions. |
| 8084 |
|
| 8085 |
(include "mips-ps-3d.md") |
| 8086 |
|
| 8087 |
; The MIPS DSP Instructions. |
| 8088 |
|
| 8089 |
(include "mips-dsp.md") |
| 8090 |
|
| 8091 |
; The MIPS DSP REV 2 Instructions. |
| 8092 |
|
| 8093 |
(include "mips-dspr2.md") |
| 8094 |
|
| 8095 |
; MIPS fixed-point instructions. |
| 8096 |
(include "mips-fixed.md") |
| 8097 |
|
| 8098 |
; microMIPS patterns. |
| 8099 |
(include "micromips.md") |
| 8100 |
|
| 8101 |
; Loongson MultiMedia extensions Instructions (MMI) patterns. |
| 8102 |
(include "loongson-mmi.md") |
| 8103 |
|
| 8104 |
; The MIPS MSA Instructions. |
| 8105 |
(include "mips-msa.md") |
| 8106 |
|
| 8107 |
(define_c_enum "unspec" [ |
| 8108 |
UNSPEC_ADDRESS_FIRST |
| 8109 |
]) |