| 1 |
;; Predicate definitions for MIPS. |
| 2 |
;; Copyright (C) 2004-2025 Free Software Foundation, Inc. |
| 3 |
;; |
| 4 |
;; This file is part of GCC. |
| 5 |
;; |
| 6 |
;; GCC is free software; you can redistribute it and/or modify |
| 7 |
;; it under the terms of the GNU General Public License as published by |
| 8 |
;; the Free Software Foundation; either version 3, or (at your option) |
| 9 |
;; any later version. |
| 10 |
;; |
| 11 |
;; GCC is distributed in the hope that it will be useful, |
| 12 |
;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
;; GNU General Public License for more details. |
| 15 |
;; |
| 16 |
;; You should have received a copy of the GNU General Public License |
| 17 |
;; along with GCC; see the file COPYING3. If not see |
| 18 |
;; <http://www.gnu.org/licenses/>. |
| 19 |
|
| 20 |
(define_predicate "const_uns_arith_operand" |
| 21 |
(and (match_code "const_int") |
| 22 |
(match_test "SMALL_OPERAND_UNSIGNED (INTVAL (op))"))) |
| 23 |
|
| 24 |
(define_predicate "uns_arith_operand" |
| 25 |
(ior (match_operand 0 "const_uns_arith_operand") |
| 26 |
(match_operand 0 "register_operand"))) |
| 27 |
|
| 28 |
(define_predicate "const_arith_operand" |
| 29 |
(and (match_code "const_int") |
| 30 |
(match_test "SMALL_OPERAND (INTVAL (op))"))) |
| 31 |
|
| 32 |
(define_predicate "arith_operand" |
| 33 |
(ior (match_operand 0 "const_arith_operand") |
| 34 |
(match_operand 0 "register_operand"))) |
| 35 |
|
| 36 |
(define_predicate "const_immlsa_operand" |
| 37 |
(and (match_code "const_int") |
| 38 |
(match_test "IN_RANGE (INTVAL (op), 1, 4)"))) |
| 39 |
|
| 40 |
(define_predicate "const_msa_branch_operand" |
| 41 |
(and (match_code "const_int") |
| 42 |
(match_test "IN_RANGE (INTVAL (op), -1024, 1023)"))) |
| 43 |
|
| 44 |
(define_predicate "const_uimm3_operand" |
| 45 |
(and (match_code "const_int") |
| 46 |
(match_test "IN_RANGE (INTVAL (op), 0, 7)"))) |
| 47 |
|
| 48 |
(define_predicate "const_uimm4_operand" |
| 49 |
(and (match_code "const_int") |
| 50 |
(match_test "IN_RANGE (INTVAL (op), 0, 15)"))) |
| 51 |
|
| 52 |
(define_predicate "const_uimm5_operand" |
| 53 |
(and (match_code "const_int") |
| 54 |
(match_test "IN_RANGE (INTVAL (op), 0, 31)"))) |
| 55 |
|
| 56 |
(define_predicate "const_uimm6_operand" |
| 57 |
(and (match_code "const_int") |
| 58 |
(match_test "UIMM6_OPERAND (INTVAL (op))"))) |
| 59 |
|
| 60 |
(define_predicate "const_uimm8_operand" |
| 61 |
(and (match_code "const_int") |
| 62 |
(match_test "IN_RANGE (INTVAL (op), 0, 255)"))) |
| 63 |
|
| 64 |
(define_predicate "const_imm5_operand" |
| 65 |
(and (match_code "const_int") |
| 66 |
(match_test "IN_RANGE (INTVAL (op), -16, 15)"))) |
| 67 |
|
| 68 |
(define_predicate "const_imm10_operand" |
| 69 |
(and (match_code "const_int") |
| 70 |
(match_test "IMM10_OPERAND (INTVAL (op))"))) |
| 71 |
|
| 72 |
(define_predicate "reg_imm10_operand" |
| 73 |
(ior (match_operand 0 "const_imm10_operand") |
| 74 |
(match_operand 0 "register_operand"))) |
| 75 |
|
| 76 |
(define_predicate "aq10b_operand" |
| 77 |
(and (match_code "const_int") |
| 78 |
(match_test "mips_signed_immediate_p (INTVAL (op), 10, 0)"))) |
| 79 |
|
| 80 |
(define_predicate "aq10h_operand" |
| 81 |
(and (match_code "const_int") |
| 82 |
(match_test "mips_signed_immediate_p (INTVAL (op), 10, 1)"))) |
| 83 |
|
| 84 |
(define_predicate "aq10w_operand" |
| 85 |
(and (match_code "const_int") |
| 86 |
(match_test "mips_signed_immediate_p (INTVAL (op), 10, 2)"))) |
| 87 |
|
| 88 |
(define_predicate "aq10d_operand" |
| 89 |
(and (match_code "const_int") |
| 90 |
(match_test "mips_signed_immediate_p (INTVAL (op), 10, 3)"))) |
| 91 |
|
| 92 |
(define_predicate "sle_operand" |
| 93 |
(and (match_code "const_int") |
| 94 |
(match_test "SMALL_OPERAND (INTVAL (op) + 1)"))) |
| 95 |
|
| 96 |
(define_predicate "sleu_operand" |
| 97 |
(and (match_operand 0 "sle_operand") |
| 98 |
(match_test "INTVAL (op) + 1 != 0"))) |
| 99 |
|
| 100 |
(define_predicate "const_0_operand" |
| 101 |
(and (match_code "const_int,const_double,const_vector") |
| 102 |
(match_test "op == CONST0_RTX (GET_MODE (op))"))) |
| 103 |
|
| 104 |
(define_predicate "const_m1_operand" |
| 105 |
(and (match_code "const_int,const_double,const_vector") |
| 106 |
(match_test "op == CONSTM1_RTX (GET_MODE (op))"))) |
| 107 |
|
| 108 |
(define_predicate "reg_or_m1_operand" |
| 109 |
(ior (match_operand 0 "const_m1_operand") |
| 110 |
(match_operand 0 "register_operand"))) |
| 111 |
|
| 112 |
(define_predicate "reg_or_0_operand" |
| 113 |
(ior (and (match_operand 0 "const_0_operand") |
| 114 |
(not (match_test "TARGET_MIPS16"))) |
| 115 |
(match_operand 0 "register_operand"))) |
| 116 |
|
| 117 |
(define_predicate "reg_or_0_operand_mips16e2" |
| 118 |
(ior (and (match_operand 0 "const_0_operand") |
| 119 |
(ior (not (match_test "TARGET_MIPS16")) |
| 120 |
(match_test "ISA_HAS_MIPS16E2"))) |
| 121 |
(match_operand 0 "register_operand"))) |
| 122 |
|
| 123 |
(define_predicate "const_1_operand" |
| 124 |
(and (match_code "const_int,const_double,const_vector") |
| 125 |
(match_test "op == CONST1_RTX (GET_MODE (op))"))) |
| 126 |
|
| 127 |
(define_predicate "reg_or_1_operand" |
| 128 |
(ior (match_operand 0 "const_1_operand") |
| 129 |
(match_operand 0 "register_operand"))) |
| 130 |
|
| 131 |
;; These are used in vec_merge, hence accept bitmask as const_int. |
| 132 |
(define_predicate "const_exp_2_operand" |
| 133 |
(and (match_code "const_int") |
| 134 |
(match_test "IN_RANGE (exact_log2 (INTVAL (op)), 0, 1)"))) |
| 135 |
|
| 136 |
(define_predicate "const_exp_4_operand" |
| 137 |
(and (match_code "const_int") |
| 138 |
(match_test "IN_RANGE (exact_log2 (INTVAL (op)), 0, 3)"))) |
| 139 |
|
| 140 |
(define_predicate "const_exp_8_operand" |
| 141 |
(and (match_code "const_int") |
| 142 |
(match_test "IN_RANGE (exact_log2 (INTVAL (op)), 0, 7)"))) |
| 143 |
|
| 144 |
(define_predicate "const_exp_16_operand" |
| 145 |
(and (match_code "const_int") |
| 146 |
(match_test "IN_RANGE (exact_log2 (INTVAL (op)), 0, 15)"))) |
| 147 |
|
| 148 |
;; This is used for indexing into vectors, and hence only accepts const_int. |
| 149 |
(define_predicate "const_0_or_1_operand" |
| 150 |
(and (match_code "const_int") |
| 151 |
(match_test "IN_RANGE (INTVAL (op), 0, 1)"))) |
| 152 |
|
| 153 |
(define_predicate "const_2_or_3_operand" |
| 154 |
(and (match_code "const_int") |
| 155 |
(match_test "IN_RANGE (INTVAL (op), 2, 3)"))) |
| 156 |
|
| 157 |
(define_predicate "const_0_to_3_operand" |
| 158 |
(and (match_code "const_int") |
| 159 |
(match_test "IN_RANGE (INTVAL (op), 0, 3)"))) |
| 160 |
|
| 161 |
(define_predicate "qi_mask_operand" |
| 162 |
(and (match_code "const_int") |
| 163 |
(match_test "UINTVAL (op) == 0xff"))) |
| 164 |
|
| 165 |
(define_predicate "hi_mask_operand" |
| 166 |
(and (match_code "const_int") |
| 167 |
(match_test "UINTVAL (op) == 0xffff"))) |
| 168 |
|
| 169 |
(define_predicate "si_mask_operand" |
| 170 |
(and (match_code "const_int") |
| 171 |
(match_test "UINTVAL (op) == 0xffffffff"))) |
| 172 |
|
| 173 |
(define_predicate "bit_clear_operand" |
| 174 |
(and (match_code "const_int") |
| 175 |
(match_test "mips_bit_clear_p (mode, INTVAL (op))"))) |
| 176 |
|
| 177 |
(define_predicate "and_load_operand" |
| 178 |
(ior (match_operand 0 "qi_mask_operand") |
| 179 |
(match_operand 0 "hi_mask_operand") |
| 180 |
(match_operand 0 "si_mask_operand"))) |
| 181 |
|
| 182 |
(define_predicate "low_bitmask_operand" |
| 183 |
(and (match_test "ISA_HAS_EXT_INS") |
| 184 |
(match_code "const_int") |
| 185 |
(match_test "low_bitmask_len (mode, INTVAL (op)) > 16"))) |
| 186 |
|
| 187 |
(define_predicate "and_reg_operand" |
| 188 |
(ior (match_operand 0 "register_operand") |
| 189 |
(and (not (match_test "TARGET_MIPS16")) |
| 190 |
(match_operand 0 "const_uns_arith_operand")) |
| 191 |
(and (match_test "ISA_HAS_MIPS16E2") |
| 192 |
(match_operand 0 "const_uns_arith_operand") |
| 193 |
(not (match_operand 0 "hi_mask_operand")) |
| 194 |
(not (match_operand 0 "qi_mask_operand"))) |
| 195 |
(and (match_test "ISA_HAS_MIPS16E2") |
| 196 |
(match_operand 0 "const_uns_arith_operand")) |
| 197 |
(match_operand 0 "low_bitmask_operand") |
| 198 |
(match_operand 0 "si_mask_operand") |
| 199 |
(match_operand 0 "bit_clear_operand"))) |
| 200 |
|
| 201 |
(define_predicate "and_operand" |
| 202 |
(ior (match_operand 0 "and_load_operand") |
| 203 |
(match_operand 0 "and_reg_operand"))) |
| 204 |
|
| 205 |
(define_predicate "d_operand" |
| 206 |
(and (match_code "reg") |
| 207 |
(match_test "TARGET_MIPS16 |
| 208 |
? M16_REG_P (REGNO (op)) |
| 209 |
: GP_REG_P (REGNO (op))"))) |
| 210 |
|
| 211 |
(define_predicate "lwsp_swsp_operand" |
| 212 |
(and (match_code "mem") |
| 213 |
(match_test "lwsp_swsp_address_p (XEXP (op, 0), mode)"))) |
| 214 |
|
| 215 |
(define_predicate "lw16_sw16_operand" |
| 216 |
(and (match_code "mem") |
| 217 |
(match_test "m16_based_address_p (XEXP (op, 0), mode, uw4_operand)"))) |
| 218 |
|
| 219 |
(define_predicate "lhu16_sh16_operand" |
| 220 |
(and (match_code "mem") |
| 221 |
(match_test "m16_based_address_p (XEXP (op, 0), mode, uh4_operand)"))) |
| 222 |
|
| 223 |
(define_predicate "lbu16_operand" |
| 224 |
(and (match_code "mem") |
| 225 |
(match_test "m16_based_address_p (XEXP (op, 0), mode, db4_operand)"))) |
| 226 |
|
| 227 |
(define_predicate "sb16_operand" |
| 228 |
(and (match_code "mem") |
| 229 |
(match_test "m16_based_address_p (XEXP (op, 0), mode, ub4_operand)"))) |
| 230 |
|
| 231 |
(define_predicate "db4_operand" |
| 232 |
(and (match_code "const_int") |
| 233 |
(match_test "mips_unsigned_immediate_p (INTVAL (op) + 1, 4, 0)"))) |
| 234 |
|
| 235 |
(define_predicate "db7_operand" |
| 236 |
(and (match_code "const_int") |
| 237 |
(match_test "mips_unsigned_immediate_p (INTVAL (op) + 1, 7, 0)"))) |
| 238 |
|
| 239 |
(define_predicate "db8_operand" |
| 240 |
(and (match_code "const_int") |
| 241 |
(match_test "mips_unsigned_immediate_p (INTVAL (op) + 1, 8, 0)"))) |
| 242 |
|
| 243 |
(define_predicate "ib3_operand" |
| 244 |
(and (match_code "const_int") |
| 245 |
(match_test "mips_unsigned_immediate_p (INTVAL (op) - 1, 3, 0)"))) |
| 246 |
|
| 247 |
(define_predicate "sb4_operand" |
| 248 |
(and (match_code "const_int") |
| 249 |
(match_test "mips_signed_immediate_p (INTVAL (op), 4, 0)"))) |
| 250 |
|
| 251 |
(define_predicate "sb5_operand" |
| 252 |
(and (match_code "const_int") |
| 253 |
(match_test "mips_signed_immediate_p (INTVAL (op), 5, 0)"))) |
| 254 |
|
| 255 |
(define_predicate "sb8_operand" |
| 256 |
(and (match_code "const_int") |
| 257 |
(match_test "mips_signed_immediate_p (INTVAL (op), 8, 0)"))) |
| 258 |
|
| 259 |
(define_predicate "sd8_operand" |
| 260 |
(and (match_code "const_int") |
| 261 |
(match_test "mips_signed_immediate_p (INTVAL (op), 8, 3)"))) |
| 262 |
|
| 263 |
(define_predicate "ub4_operand" |
| 264 |
(and (match_code "const_int") |
| 265 |
(match_test "mips_unsigned_immediate_p (INTVAL (op), 4, 0)"))) |
| 266 |
|
| 267 |
(define_predicate "ub8_operand" |
| 268 |
(and (match_code "const_int") |
| 269 |
(match_test "mips_unsigned_immediate_p (INTVAL (op), 8, 0)"))) |
| 270 |
|
| 271 |
(define_predicate "uh4_operand" |
| 272 |
(and (match_code "const_int") |
| 273 |
(match_test "mips_unsigned_immediate_p (INTVAL (op), 4, 1)"))) |
| 274 |
|
| 275 |
(define_predicate "uw4_operand" |
| 276 |
(and (match_code "const_int") |
| 277 |
(match_test "mips_unsigned_immediate_p (INTVAL (op), 4, 2)"))) |
| 278 |
|
| 279 |
(define_predicate "uw5_operand" |
| 280 |
(and (match_code "const_int") |
| 281 |
(match_test "mips_unsigned_immediate_p (INTVAL (op), 5, 2)"))) |
| 282 |
|
| 283 |
(define_predicate "uw6_operand" |
| 284 |
(and (match_code "const_int") |
| 285 |
(match_test "mips_unsigned_immediate_p (INTVAL (op), 6, 2)"))) |
| 286 |
|
| 287 |
(define_predicate "uw8_operand" |
| 288 |
(and (match_code "const_int") |
| 289 |
(match_test "mips_unsigned_immediate_p (INTVAL (op), 8, 2)"))) |
| 290 |
|
| 291 |
(define_predicate "addiur2_operand" |
| 292 |
(and (match_code "const_int") |
| 293 |
(ior (match_test "INTVAL (op) == -1") |
| 294 |
(match_test "INTVAL (op) == 1") |
| 295 |
(match_test "INTVAL (op) == 4") |
| 296 |
(match_test "INTVAL (op) == 8") |
| 297 |
(match_test "INTVAL (op) == 12") |
| 298 |
(match_test "INTVAL (op) == 16") |
| 299 |
(match_test "INTVAL (op) == 20") |
| 300 |
(match_test "INTVAL (op) == 24")))) |
| 301 |
|
| 302 |
(define_predicate "addiusp_operand" |
| 303 |
(and (match_code "const_int") |
| 304 |
(ior (match_test "(IN_RANGE (INTVAL (op), 2, 257))") |
| 305 |
(match_test "(IN_RANGE (INTVAL (op), -258, -3))")))) |
| 306 |
|
| 307 |
(define_predicate "andi16_operand" |
| 308 |
(and (match_code "const_int") |
| 309 |
(ior (match_test "IN_RANGE (INTVAL (op), 1, 4)") |
| 310 |
(match_test "IN_RANGE (INTVAL (op), 7, 8)") |
| 311 |
(match_test "IN_RANGE (INTVAL (op), 15, 16)") |
| 312 |
(match_test "IN_RANGE (INTVAL (op), 31, 32)") |
| 313 |
(match_test "IN_RANGE (INTVAL (op), 63, 64)") |
| 314 |
(match_test "INTVAL (op) == 255") |
| 315 |
(match_test "INTVAL (op) == 32768") |
| 316 |
(match_test "INTVAL (op) == 65535")))) |
| 317 |
|
| 318 |
(define_predicate "movep_src_register" |
| 319 |
(and (match_code "reg") |
| 320 |
(ior (match_test ("IN_RANGE (REGNO (op), 2, 3)")) |
| 321 |
(match_test ("IN_RANGE (REGNO (op), 16, 20)"))))) |
| 322 |
|
| 323 |
(define_predicate "movep_src_operand" |
| 324 |
(ior (match_operand 0 "const_0_operand") |
| 325 |
(match_operand 0 "movep_src_register"))) |
| 326 |
|
| 327 |
(define_predicate "lo_operand" |
| 328 |
(and (match_code "reg") |
| 329 |
(match_test "REGNO (op) == LO_REGNUM"))) |
| 330 |
|
| 331 |
(define_predicate "hilo_operand" |
| 332 |
(and (match_code "reg") |
| 333 |
(match_test "MD_REG_P (REGNO (op))"))) |
| 334 |
|
| 335 |
(define_predicate "fcc_reload_operand" |
| 336 |
(and (match_code "reg,subreg") |
| 337 |
(match_test "ST_REG_P (true_regnum (op))"))) |
| 338 |
|
| 339 |
(define_predicate "muldiv_target_operand" |
| 340 |
(if_then_else (match_test "TARGET_MIPS16") |
| 341 |
(match_operand 0 "hilo_operand") |
| 342 |
(match_operand 0 "register_operand"))) |
| 343 |
|
| 344 |
(define_predicate "const_call_insn_operand" |
| 345 |
(match_code "const,symbol_ref,label_ref") |
| 346 |
{ |
| 347 |
enum mips_symbol_type symbol_type; |
| 348 |
|
| 349 |
if (!mips_symbolic_constant_p (op, SYMBOL_CONTEXT_CALL, &symbol_type)) |
| 350 |
return false; |
| 351 |
|
| 352 |
switch (symbol_type) |
| 353 |
{ |
| 354 |
case SYMBOL_ABSOLUTE: |
| 355 |
/* We can only use direct calls if we're sure that the target |
| 356 |
function does not need $25 to be valid on entry. */ |
| 357 |
if (mips_use_pic_fn_addr_reg_p (op)) |
| 358 |
return false; |
| 359 |
|
| 360 |
/* If -mlong-calls or if this function has an explicit long_call |
| 361 |
attribute, we must use register addressing. The |
| 362 |
SYMBOL_FLAG_LONG_CALL bit is set by mips_encode_section_info. */ |
| 363 |
return !(GET_CODE (op) == SYMBOL_REF && SYMBOL_REF_LONG_CALL_P (op)); |
| 364 |
|
| 365 |
case SYMBOL_GOT_DISP: |
| 366 |
/* Without explicit relocs, there is no special syntax for |
| 367 |
loading the address of a call destination into a register. |
| 368 |
Using "la $25,foo; jal $25" would prevent the lazy binding |
| 369 |
of "foo", so keep the address of global symbols with the |
| 370 |
jal macro. */ |
| 371 |
return !TARGET_EXPLICIT_RELOCS; |
| 372 |
|
| 373 |
default: |
| 374 |
return false; |
| 375 |
} |
| 376 |
}) |
| 377 |
|
| 378 |
(define_predicate "call_insn_operand" |
| 379 |
(ior (match_operand 0 "const_call_insn_operand") |
| 380 |
(match_operand 0 "register_operand"))) |
| 381 |
|
| 382 |
;; A legitimate CONST_INT operand that takes more than one instruction |
| 383 |
;; to load. |
| 384 |
(define_predicate "splittable_const_int_operand" |
| 385 |
(match_code "const_int") |
| 386 |
{ |
| 387 |
/* When generating mips16 code, TARGET_LEGITIMATE_CONSTANT_P rejects |
| 388 |
CONST_INTs that can't be loaded using simple insns. */ |
| 389 |
if (TARGET_MIPS16 && !TARGET_MIPS16E2) |
| 390 |
return false; |
| 391 |
|
| 392 |
/* Don't handle multi-word moves this way; we don't want to introduce |
| 393 |
the individual word-mode moves until after reload. */ |
| 394 |
if (GET_MODE_SIZE (mode) > UNITS_PER_WORD) |
| 395 |
return false; |
| 396 |
|
| 397 |
/* Otherwise check whether the constant can be loaded in a single |
| 398 |
instruction. */ |
| 399 |
return !LUI_INT (op) && !SMALL_INT (op) && !SMALL_INT_UNSIGNED (op); |
| 400 |
}) |
| 401 |
|
| 402 |
(define_predicate "move_operand" |
| 403 |
;; Allow HI and LO to be used as the source of a MIPS16 move. |
| 404 |
(ior (match_operand 0 "general_operand") |
| 405 |
(match_operand 0 "hilo_operand")) |
| 406 |
{ |
| 407 |
enum mips_symbol_type symbol_type; |
| 408 |
|
| 409 |
/* The thinking here is as follows: |
| 410 |
|
| 411 |
(1) The move expanders should split complex load sequences into |
| 412 |
individual instructions. Those individual instructions can |
| 413 |
then be optimized by all rtl passes. |
| 414 |
|
| 415 |
(2) The target of pre-reload load sequences should not be used |
| 416 |
to store temporary results. If the target register is only |
| 417 |
assigned one value, reload can rematerialize that value |
| 418 |
on demand, rather than spill it to the stack. |
| 419 |
|
| 420 |
(3) If we allowed pre-reload passes like combine and cse to recreate |
| 421 |
complex load sequences, we would want to be able to split the |
| 422 |
sequences before reload as well, so that the pre-reload scheduler |
| 423 |
can see the individual instructions. This falls foul of (2); |
| 424 |
the splitter would be forced to reuse the target register for |
| 425 |
intermediate results. |
| 426 |
|
| 427 |
(4) We want to define complex load splitters for combine. These |
| 428 |
splitters can request a temporary scratch register, which avoids |
| 429 |
the problem in (2). They allow things like: |
| 430 |
|
| 431 |
(set (reg T1) (high SYM)) |
| 432 |
(set (reg T2) (low (reg T1) SYM)) |
| 433 |
(set (reg X) (plus (reg T2) (const_int OFFSET))) |
| 434 |
|
| 435 |
to be combined into: |
| 436 |
|
| 437 |
(set (reg T3) (high SYM+OFFSET)) |
| 438 |
(set (reg X) (lo_sum (reg T3) SYM+OFFSET)) |
| 439 |
|
| 440 |
if T2 is only used this once. */ |
| 441 |
switch (GET_CODE (op)) |
| 442 |
{ |
| 443 |
case CONST_INT: |
| 444 |
return !splittable_const_int_operand (op, mode); |
| 445 |
|
| 446 |
case CONST: |
| 447 |
case SYMBOL_REF: |
| 448 |
case LABEL_REF: |
| 449 |
if (CONST_GP_P (op)) |
| 450 |
return true; |
| 451 |
return (mips_symbolic_constant_p (op, SYMBOL_CONTEXT_LEA, &symbol_type) |
| 452 |
&& !mips_split_p[symbol_type]); |
| 453 |
|
| 454 |
case HIGH: |
| 455 |
op = XEXP (op, 0); |
| 456 |
return (mips_symbolic_constant_p (op, SYMBOL_CONTEXT_LEA, &symbol_type) |
| 457 |
&& !mips_split_hi_p[symbol_type]); |
| 458 |
|
| 459 |
default: |
| 460 |
return true; |
| 461 |
} |
| 462 |
}) |
| 463 |
|
| 464 |
(define_predicate "cprestore_save_slot_operand" |
| 465 |
(and (match_code "mem") |
| 466 |
(match_test "mips_cprestore_address_p (XEXP (op, 0), false)"))) |
| 467 |
|
| 468 |
(define_predicate "cprestore_load_slot_operand" |
| 469 |
(and (match_code "mem") |
| 470 |
(match_test "mips_cprestore_address_p (XEXP (op, 0), true)"))) |
| 471 |
|
| 472 |
(define_predicate "consttable_operand" |
| 473 |
(match_test "CONSTANT_P (op)")) |
| 474 |
|
| 475 |
(define_predicate "symbolic_operand" |
| 476 |
(match_code "const,symbol_ref,label_ref") |
| 477 |
{ |
| 478 |
enum mips_symbol_type type; |
| 479 |
return mips_symbolic_constant_p (op, SYMBOL_CONTEXT_LEA, &type); |
| 480 |
}) |
| 481 |
|
| 482 |
(define_predicate "absolute_symbolic_operand" |
| 483 |
(match_code "const,symbol_ref,label_ref") |
| 484 |
{ |
| 485 |
enum mips_symbol_type type; |
| 486 |
return (mips_symbolic_constant_p (op, SYMBOL_CONTEXT_LEA, &type) |
| 487 |
&& type == SYMBOL_ABSOLUTE); |
| 488 |
}) |
| 489 |
|
| 490 |
(define_predicate "symbolic_operand_with_high" |
| 491 |
(match_code "const,symbol_ref,label_ref") |
| 492 |
{ |
| 493 |
enum mips_symbol_type type; |
| 494 |
return (mips_symbolic_constant_p (op, SYMBOL_CONTEXT_LEA, &type) |
| 495 |
&& mips_hi_relocs[(int) type]); |
| 496 |
}) |
| 497 |
|
| 498 |
(define_predicate "force_to_mem_operand" |
| 499 |
(match_code "const,symbol_ref,label_ref") |
| 500 |
{ |
| 501 |
enum mips_symbol_type symbol_type; |
| 502 |
return (mips_symbolic_constant_p (op, SYMBOL_CONTEXT_LEA, &symbol_type) |
| 503 |
&& mips_use_pcrel_pool_p[(int) symbol_type]); |
| 504 |
}) |
| 505 |
|
| 506 |
(define_predicate "got_disp_operand" |
| 507 |
(match_code "const,symbol_ref,label_ref") |
| 508 |
{ |
| 509 |
enum mips_symbol_type type; |
| 510 |
return (mips_symbolic_constant_p (op, SYMBOL_CONTEXT_LEA, &type) |
| 511 |
&& type == SYMBOL_GOT_DISP); |
| 512 |
}) |
| 513 |
|
| 514 |
(define_predicate "got_page_ofst_operand" |
| 515 |
(match_code "const,symbol_ref,label_ref") |
| 516 |
{ |
| 517 |
enum mips_symbol_type type; |
| 518 |
return (mips_symbolic_constant_p (op, SYMBOL_CONTEXT_LEA, &type) |
| 519 |
&& type == SYMBOL_GOT_PAGE_OFST); |
| 520 |
}) |
| 521 |
|
| 522 |
(define_predicate "tls_reloc_operand" |
| 523 |
(match_code "const,symbol_ref,label_ref") |
| 524 |
{ |
| 525 |
enum mips_symbol_type type; |
| 526 |
return (mips_symbolic_constant_p (op, SYMBOL_CONTEXT_LEA, &type) |
| 527 |
&& (type == SYMBOL_DTPREL || type == SYMBOL_TPREL)); |
| 528 |
}) |
| 529 |
|
| 530 |
(define_predicate "symbol_ref_operand" |
| 531 |
(match_code "symbol_ref")) |
| 532 |
|
| 533 |
(define_predicate "stack_operand" |
| 534 |
(and (match_code "mem") |
| 535 |
(match_test "mips_stack_address_p (XEXP (op, 0), GET_MODE (op))"))) |
| 536 |
|
| 537 |
(define_predicate "macc_msac_operand" |
| 538 |
(ior (and (match_code "plus") (match_test "ISA_HAS_MACC")) |
| 539 |
(and (match_code "minus") (match_test "ISA_HAS_MSAC"))) |
| 540 |
{ |
| 541 |
rtx mult = XEXP (op, GET_CODE (op) == PLUS ? 0 : 1); |
| 542 |
rtx accum = XEXP (op, GET_CODE (op) == PLUS ? 1 : 0); |
| 543 |
return (GET_CODE (mult) == MULT |
| 544 |
&& REG_P (XEXP (mult, 0)) |
| 545 |
&& REG_P (XEXP (mult, 1)) |
| 546 |
&& REG_P (accum)); |
| 547 |
}) |
| 548 |
|
| 549 |
|
| 550 |
(define_predicate "equality_operator" |
| 551 |
(match_code "eq,ne")) |
| 552 |
|
| 553 |
(define_predicate "extend_operator" |
| 554 |
(match_code "zero_extend,sign_extend")) |
| 555 |
|
| 556 |
(define_predicate "trap_comparison_operator" |
| 557 |
(match_code "eq,ne,lt,ltu,ge,geu")) |
| 558 |
|
| 559 |
(define_predicate "order_operator" |
| 560 |
(match_code "lt,ltu,le,leu,ge,geu,gt,gtu") |
| 561 |
{ |
| 562 |
if (XEXP (op, 1) == const0_rtx) |
| 563 |
return true; |
| 564 |
|
| 565 |
if (TARGET_CB_MAYBE |
| 566 |
&& (GET_CODE (op) == LT || GET_CODE (op) == LTU |
| 567 |
|| GET_CODE (op) == GE || GET_CODE (op) == GEU)) |
| 568 |
return true; |
| 569 |
|
| 570 |
return false; |
| 571 |
}) |
| 572 |
|
| 573 |
;; For NE, cstore uses sltu instructions in which the first operand is $0. |
| 574 |
;; This isn't possible in mips16 code. |
| 575 |
|
| 576 |
(define_predicate "mips_cstore_operator" |
| 577 |
(ior (match_code "eq,gt,gtu,ge,geu,lt,ltu,le,leu") |
| 578 |
(and (match_code "ne") (not (match_test "TARGET_MIPS16"))))) |
| 579 |
|
| 580 |
(define_predicate "small_data_pattern" |
| 581 |
(and (match_code "set,parallel,unspec,unspec_volatile,prefetch") |
| 582 |
(match_test "mips_small_data_pattern_p (op)"))) |
| 583 |
|
| 584 |
(define_predicate "mem_noofs_operand" |
| 585 |
(and (match_code "mem") |
| 586 |
(match_code "reg" "0"))) |
| 587 |
|
| 588 |
;; Return 1 if the operand is in non-volatile memory. |
| 589 |
(define_predicate "non_volatile_mem_operand" |
| 590 |
(and (match_operand 0 "memory_operand") |
| 591 |
(not (match_test "MEM_VOLATILE_P (op)")))) |
| 592 |
|
| 593 |
(define_predicate "const_vector_same_val_operand" |
| 594 |
(match_code "const_vector") |
| 595 |
{ |
| 596 |
return mips_const_vector_same_val_p (op, mode); |
| 597 |
}) |
| 598 |
|
| 599 |
(define_predicate "const_vector_same_simm5_operand" |
| 600 |
(match_code "const_vector") |
| 601 |
{ |
| 602 |
return mips_const_vector_same_int_p (op, mode, -16, 15); |
| 603 |
}) |
| 604 |
|
| 605 |
(define_predicate "const_vector_same_uimm5_operand" |
| 606 |
(match_code "const_vector") |
| 607 |
{ |
| 608 |
return mips_const_vector_same_int_p (op, mode, 0, 31); |
| 609 |
}) |
| 610 |
|
| 611 |
(define_predicate "const_vector_same_ximm5_operand" |
| 612 |
(match_code "const_vector") |
| 613 |
{ |
| 614 |
return mips_const_vector_same_int_p (op, mode, -31, 31); |
| 615 |
}) |
| 616 |
|
| 617 |
(define_predicate "const_vector_same_uimm6_operand" |
| 618 |
(match_code "const_vector") |
| 619 |
{ |
| 620 |
return mips_const_vector_same_int_p (op, mode, 0, 63); |
| 621 |
}) |
| 622 |
|
| 623 |
(define_predicate "const_vector_same_uimm8_operand" |
| 624 |
(match_code "const_vector") |
| 625 |
{ |
| 626 |
return mips_const_vector_same_int_p (op, mode, 0, 255); |
| 627 |
}) |
| 628 |
|
| 629 |
(define_predicate "par_const_vector_shf_set_operand" |
| 630 |
(match_code "parallel") |
| 631 |
{ |
| 632 |
return mips_const_vector_shuffle_set_p (op, mode); |
| 633 |
}) |
| 634 |
|
| 635 |
(define_predicate "reg_or_vector_same_val_operand" |
| 636 |
(ior (match_operand 0 "register_operand") |
| 637 |
(match_operand 0 "const_vector_same_val_operand"))) |
| 638 |
|
| 639 |
(define_predicate "reg_or_vector_same_simm5_operand" |
| 640 |
(ior (match_operand 0 "register_operand") |
| 641 |
(match_operand 0 "const_vector_same_simm5_operand"))) |
| 642 |
|
| 643 |
(define_predicate "reg_or_vector_same_uimm5_operand" |
| 644 |
(ior (match_operand 0 "register_operand") |
| 645 |
(match_operand 0 "const_vector_same_uimm5_operand"))) |
| 646 |
|
| 647 |
(define_predicate "reg_or_vector_same_ximm5_operand" |
| 648 |
(ior (match_operand 0 "register_operand") |
| 649 |
(match_operand 0 "const_vector_same_ximm5_operand"))) |
| 650 |
|
| 651 |
(define_predicate "reg_or_vector_same_uimm6_operand" |
| 652 |
(ior (match_operand 0 "register_operand") |
| 653 |
(match_operand 0 "const_vector_same_uimm6_operand"))) |