| 1 |
;; Predicate definitions for SPARC. |
| 2 |
;; Copyright (C) 2005-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 |
;; Predicates for numerical constants. |
| 21 |
|
| 22 |
;; Return true if OP is the zero constant for MODE. |
| 23 |
(define_predicate "const_zero_operand" |
| 24 |
(and (match_code "const_int,const_wide_int,const_double,const_vector") |
| 25 |
(match_test "op == CONST0_RTX (mode)"))) |
| 26 |
|
| 27 |
;; Return true if the integer representation of OP is all ones. |
| 28 |
(define_predicate "const_all_ones_operand" |
| 29 |
(and (match_code "const_int,const_wide_int,const_double,const_vector") |
| 30 |
(match_test "INTEGRAL_MODE_P (GET_MODE (op))") |
| 31 |
(match_test "op == CONSTM1_RTX (GET_MODE (op))"))) |
| 32 |
|
| 33 |
;; Return true if OP is the integer constant 4096. |
| 34 |
(define_predicate "const_4096_operand" |
| 35 |
(and (match_code "const_int") |
| 36 |
(match_test "INTVAL (op) == 4096"))) |
| 37 |
|
| 38 |
;; Return true if OP is a constant that is representable by a 13-bit |
| 39 |
;; signed field. This is an acceptable immediate operand for most |
| 40 |
;; 3-address instructions. |
| 41 |
(define_predicate "small_int_operand" |
| 42 |
(and (match_code "const_int") |
| 43 |
(match_test "SPARC_SIMM13_P (INTVAL (op))"))) |
| 44 |
|
| 45 |
;; Return true if OP is a constant operand for the umul instruction. That |
| 46 |
;; instruction sign-extends immediate values just like all other SPARC |
| 47 |
;; instructions, but interprets the extended result as an unsigned number. |
| 48 |
(define_predicate "uns_small_int_operand" |
| 49 |
(and (match_code "const_int") |
| 50 |
(match_test "((INTVAL (op) >= 0 && INTVAL (op) < 0x1000) |
| 51 |
|| (INTVAL (op) >= 0xFFFFF000 |
| 52 |
&& INTVAL (op) <= 0xFFFFFFFF))"))) |
| 53 |
|
| 54 |
;; Return true if OP is a constant that can be loaded by the sethi instruction. |
| 55 |
;; The first test avoids emitting sethi to load zero for example. |
| 56 |
(define_predicate "const_high_operand" |
| 57 |
(and (match_code "const_int") |
| 58 |
(and (not (match_operand 0 "small_int_operand")) |
| 59 |
(match_test "SPARC_SETHI_P (INTVAL (op) & GET_MODE_MASK (mode))")))) |
| 60 |
|
| 61 |
;; Return true if OP is a constant whose 1's complement can be loaded by the |
| 62 |
;; sethi instruction. |
| 63 |
(define_predicate "const_compl_high_operand" |
| 64 |
(and (match_code "const_int") |
| 65 |
(and (not (match_operand 0 "small_int_operand")) |
| 66 |
(match_test "SPARC_SETHI_P (~INTVAL (op) & GET_MODE_MASK (mode))")))) |
| 67 |
|
| 68 |
;; Return true if OP is a FP constant that needs to be loaded by the sethi/losum |
| 69 |
;; pair of instructions. |
| 70 |
(define_predicate "fp_const_high_losum_operand" |
| 71 |
(match_operand 0 "const_double_operand") |
| 72 |
{ |
| 73 |
gcc_assert (mode == SFmode); |
| 74 |
return fp_high_losum_p (op); |
| 75 |
}) |
| 76 |
|
| 77 |
;; Return true if OP is a const_double or const_vector. |
| 78 |
(define_predicate "const_double_or_vector_operand" |
| 79 |
(match_code "const_double,const_vector")) |
| 80 |
|
| 81 |
;; Return true if OP is Zero, or if the target is V7. |
| 82 |
(define_predicate "zero_or_v7_operand" |
| 83 |
(and (match_code "const_int") |
| 84 |
(ior (match_test "INTVAL (op) == 0") |
| 85 |
(match_test "!TARGET_V8 && !TARGET_V9")))) |
| 86 |
|
| 87 |
;; Predicates for symbolic constants. |
| 88 |
|
| 89 |
;; Return true if OP is either a symbol reference or a sum of a symbol |
| 90 |
;; reference and a constant. |
| 91 |
(define_predicate "symbolic_operand" |
| 92 |
(match_code "symbol_ref,label_ref,const") |
| 93 |
{ |
| 94 |
machine_mode omode = GET_MODE (op); |
| 95 |
|
| 96 |
if (omode != mode && omode != VOIDmode && mode != VOIDmode) |
| 97 |
return false; |
| 98 |
|
| 99 |
switch (GET_CODE (op)) |
| 100 |
{ |
| 101 |
case SYMBOL_REF: |
| 102 |
return !SYMBOL_REF_TLS_MODEL (op); |
| 103 |
|
| 104 |
case LABEL_REF: |
| 105 |
return true; |
| 106 |
|
| 107 |
case CONST: |
| 108 |
op = XEXP (op, 0); |
| 109 |
return (((GET_CODE (XEXP (op, 0)) == SYMBOL_REF |
| 110 |
&& !SYMBOL_REF_TLS_MODEL (XEXP (op, 0))) |
| 111 |
|| GET_CODE (XEXP (op, 0)) == LABEL_REF) |
| 112 |
&& GET_CODE (XEXP (op, 1)) == CONST_INT); |
| 113 |
|
| 114 |
default: |
| 115 |
gcc_unreachable (); |
| 116 |
} |
| 117 |
}) |
| 118 |
|
| 119 |
;; Return true if OP is a symbolic operand for the TLS Global Dynamic model. |
| 120 |
(define_predicate "tgd_symbolic_operand" |
| 121 |
(and (match_code "symbol_ref") |
| 122 |
(match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_GLOBAL_DYNAMIC"))) |
| 123 |
|
| 124 |
;; Return true if OP is a symbolic operand for the TLS Local Dynamic model. |
| 125 |
(define_predicate "tld_symbolic_operand" |
| 126 |
(and (match_code "symbol_ref") |
| 127 |
(match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_DYNAMIC"))) |
| 128 |
|
| 129 |
;; Return true if OP is a symbolic operand for the TLS Initial Exec model. |
| 130 |
(define_predicate "tie_symbolic_operand" |
| 131 |
(and (match_code "symbol_ref") |
| 132 |
(match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_INITIAL_EXEC"))) |
| 133 |
|
| 134 |
;; Return true if OP is a symbolic operand for the TLS Local Exec model. |
| 135 |
(define_predicate "tle_symbolic_operand" |
| 136 |
(and (match_code "symbol_ref") |
| 137 |
(match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_EXEC"))) |
| 138 |
|
| 139 |
;; Return true if the operand is an argument used in generating PIC references |
| 140 |
;; in either the medium/low or embedded medium/anywhere code models on V9. |
| 141 |
;; Check for (const (minus (symbol_ref:GOT) |
| 142 |
;; (const (minus (label) (pc))))) |
| 143 |
(define_predicate "medium_pic_operand" |
| 144 |
(match_code "const") |
| 145 |
{ |
| 146 |
/* Check for (const (minus (symbol_ref:GOT) |
| 147 |
(const (minus (label) (pc))))). */ |
| 148 |
op = XEXP (op, 0); |
| 149 |
return GET_CODE (op) == MINUS |
| 150 |
&& GET_CODE (XEXP (op, 0)) == SYMBOL_REF |
| 151 |
&& GET_CODE (XEXP (op, 1)) == CONST |
| 152 |
&& GET_CODE (XEXP (XEXP (op, 1), 0)) == MINUS; |
| 153 |
}) |
| 154 |
|
| 155 |
;; Return true if OP is a LABEL_REF of mode MODE. |
| 156 |
(define_predicate "label_ref_operand" |
| 157 |
(and (match_code "label_ref") |
| 158 |
(match_test "GET_MODE (op) == mode"))) |
| 159 |
|
| 160 |
;; Return true if OP is a data segment reference. This includes the readonly |
| 161 |
;; data segment or, in other words, anything but the text segment. |
| 162 |
;; This is needed in the embedded medium/anywhere code model on V9. These |
| 163 |
;; values are accessed with EMBMEDANY_BASE_REG. */ |
| 164 |
(define_predicate "data_segment_operand" |
| 165 |
(match_code "symbol_ref,plus,const") |
| 166 |
{ |
| 167 |
switch (GET_CODE (op)) |
| 168 |
{ |
| 169 |
case SYMBOL_REF : |
| 170 |
return ! SYMBOL_REF_FUNCTION_P (op); |
| 171 |
case PLUS : |
| 172 |
/* Assume canonical format of symbol + constant. |
| 173 |
Fall through. */ |
| 174 |
case CONST : |
| 175 |
return data_segment_operand (XEXP (op, 0), VOIDmode); |
| 176 |
default : |
| 177 |
gcc_unreachable (); |
| 178 |
} |
| 179 |
}) |
| 180 |
|
| 181 |
;; Return true if OP is a text segment reference. |
| 182 |
;; This is needed in the embedded medium/anywhere code model on V9. |
| 183 |
(define_predicate "text_segment_operand" |
| 184 |
(match_code "label_ref,symbol_ref,plus,const") |
| 185 |
{ |
| 186 |
switch (GET_CODE (op)) |
| 187 |
{ |
| 188 |
case LABEL_REF : |
| 189 |
return true; |
| 190 |
case SYMBOL_REF : |
| 191 |
return SYMBOL_REF_FUNCTION_P (op); |
| 192 |
case PLUS : |
| 193 |
/* Assume canonical format of symbol + constant. |
| 194 |
Fall through. */ |
| 195 |
case CONST : |
| 196 |
return text_segment_operand (XEXP (op, 0), VOIDmode); |
| 197 |
default : |
| 198 |
gcc_unreachable (); |
| 199 |
} |
| 200 |
}) |
| 201 |
|
| 202 |
|
| 203 |
;; Predicates for registers. |
| 204 |
|
| 205 |
;; Return true if OP is either the zero constant or a register. |
| 206 |
(define_predicate "register_or_zero_operand" |
| 207 |
(ior (match_operand 0 "register_operand") |
| 208 |
(match_operand 0 "const_zero_operand"))) |
| 209 |
|
| 210 |
(define_predicate "register_or_v9_zero_operand" |
| 211 |
(ior (match_operand 0 "register_operand") |
| 212 |
(and (match_test "TARGET_V9") |
| 213 |
(match_operand 0 "const_zero_operand")))) |
| 214 |
|
| 215 |
;; Return true if OP is either the zero constant, the all-ones |
| 216 |
;; constant, or a register. |
| 217 |
(define_predicate "register_or_zero_or_all_ones_operand" |
| 218 |
(ior (match_operand 0 "register_or_zero_operand") |
| 219 |
(match_operand 0 "const_all_ones_operand"))) |
| 220 |
|
| 221 |
;; Return true if OP is a register operand in a floating point register. |
| 222 |
(define_predicate "fp_register_operand" |
| 223 |
(match_operand 0 "register_operand") |
| 224 |
{ |
| 225 |
if (GET_CODE (op) == SUBREG) |
| 226 |
op = SUBREG_REG (op); /* Possibly a MEM */ |
| 227 |
return REG_P (op) && SPARC_FP_REG_P (REGNO (op)); |
| 228 |
}) |
| 229 |
|
| 230 |
;; Return true if OP is an integer register of the appropriate mode |
| 231 |
;; for a cstore result. |
| 232 |
(define_special_predicate "cstore_result_operand" |
| 233 |
(match_test "register_operand (op, TARGET_ARCH64 ? DImode : SImode)")) |
| 234 |
|
| 235 |
;; Return true if OP is a floating point condition code register. |
| 236 |
(define_predicate "fcc_register_operand" |
| 237 |
(and (match_code "reg") |
| 238 |
(match_test "((unsigned) REGNO (op) - SPARC_FIRST_V9_FCC_REG) < 4"))) |
| 239 |
|
| 240 |
;; Return true if OP is the floating point condition code register fcc0. |
| 241 |
(define_predicate "fcc0_register_operand" |
| 242 |
(and (match_code "reg") |
| 243 |
(match_test "REGNO (op) == SPARC_FCC_REG"))) |
| 244 |
|
| 245 |
;; Return true if OP is an integer condition code register. |
| 246 |
(define_predicate "icc_register_operand" |
| 247 |
(and (match_code "reg") |
| 248 |
(match_test "REGNO (op) == SPARC_ICC_REG"))) |
| 249 |
|
| 250 |
;; Return true if OP is an integer or floating point condition code register. |
| 251 |
(define_predicate "icc_or_fcc_register_operand" |
| 252 |
(ior (match_operand 0 "icc_register_operand") |
| 253 |
(match_operand 0 "fcc_register_operand"))) |
| 254 |
|
| 255 |
|
| 256 |
;; Predicates for arithmetic instructions. |
| 257 |
|
| 258 |
;; Return true if OP is a register, or is a constant that is representable |
| 259 |
;; by a 13-bit signed field. This is an acceptable operand for most |
| 260 |
;; 3-address instructions. |
| 261 |
(define_predicate "arith_operand" |
| 262 |
(ior (match_operand 0 "register_operand") |
| 263 |
(match_operand 0 "small_int_operand"))) |
| 264 |
|
| 265 |
;; 64-bit: Same as above. |
| 266 |
;; 32-bit: Return true if OP is a register, or is a constant that is |
| 267 |
;; representable by a couple of 13-bit signed fields. This is an |
| 268 |
;; acceptable operand for most 3-address splitters. |
| 269 |
(define_predicate "arith_double_operand" |
| 270 |
(match_code "const_int,reg,subreg") |
| 271 |
{ |
| 272 |
bool arith_simple_operand = arith_operand (op, mode); |
| 273 |
HOST_WIDE_INT m1, m2; |
| 274 |
|
| 275 |
if (TARGET_ARCH64 || arith_simple_operand) |
| 276 |
return arith_simple_operand; |
| 277 |
|
| 278 |
if (GET_CODE (op) != CONST_INT) |
| 279 |
return false; |
| 280 |
|
| 281 |
m1 = trunc_int_for_mode (INTVAL (op), SImode); |
| 282 |
m2 = trunc_int_for_mode (INTVAL (op) >> 32, SImode); |
| 283 |
|
| 284 |
return SPARC_SIMM13_P (m1) && SPARC_SIMM13_P (m2); |
| 285 |
}) |
| 286 |
|
| 287 |
;; Return true if OP is suitable as second operand for add/sub. |
| 288 |
(define_predicate "arith_add_operand" |
| 289 |
(ior (match_operand 0 "arith_operand") |
| 290 |
(match_operand 0 "const_4096_operand"))) |
| 291 |
|
| 292 |
;; Return true if OP is suitable as second double operand for add/sub. |
| 293 |
(define_predicate "arith_double_add_operand" |
| 294 |
(match_code "const_int,reg,subreg") |
| 295 |
{ |
| 296 |
if (arith_double_operand (op, mode)) |
| 297 |
return true; |
| 298 |
|
| 299 |
/* Turning an add/sub instruction into the other changes the Carry flag |
| 300 |
so the 4096 trick cannot be used for double operations in 32-bit mode. */ |
| 301 |
return TARGET_ARCH64 && const_4096_operand (op, mode); |
| 302 |
}) |
| 303 |
|
| 304 |
;; Return true if OP is a register, or is a CONST_INT that can fit in a |
| 305 |
;; signed 10-bit immediate field. This is an acceptable SImode operand for |
| 306 |
;; the movrcc instructions. |
| 307 |
(define_predicate "arith10_operand" |
| 308 |
(ior (match_operand 0 "register_operand") |
| 309 |
(and (match_code "const_int") |
| 310 |
(match_test "SPARC_SIMM10_P (INTVAL (op))")))) |
| 311 |
|
| 312 |
;; Return true if OP is a register, or is a CONST_INT that can fit in a |
| 313 |
;; signed 11-bit immediate field. This is an acceptable SImode operand for |
| 314 |
;; the movcc instructions. |
| 315 |
(define_predicate "arith11_operand" |
| 316 |
(ior (match_operand 0 "register_operand") |
| 317 |
(and (match_code "const_int") |
| 318 |
(match_test "SPARC_SIMM11_P (INTVAL (op))")))) |
| 319 |
|
| 320 |
;; Return true if OP is a register or a constant for the umul instruction. |
| 321 |
(define_predicate "uns_arith_operand" |
| 322 |
(ior (match_operand 0 "register_operand") |
| 323 |
(match_operand 0 "uns_small_int_operand"))) |
| 324 |
|
| 325 |
;; Return true if OP is a register, or is a CONST_INT that can fit in a |
| 326 |
;; signed 5-bit immediate field. This is an acceptable second operand for |
| 327 |
;; the cbcond instructions. |
| 328 |
(define_predicate "arith5_operand" |
| 329 |
(ior (match_operand 0 "register_operand") |
| 330 |
(and (match_code "const_int") |
| 331 |
(match_test "SPARC_SIMM5_P (INTVAL (op))")))) |
| 332 |
|
| 333 |
;; Return true if OP is a constant in the range 0..7. This is an |
| 334 |
;; acceptable second operand for dictunpack instructions setting a |
| 335 |
;; V8QI mode in the destination register. |
| 336 |
(define_predicate "imm5_operand_dictunpack8" |
| 337 |
(and (match_code "const_int") |
| 338 |
(match_test "(INTVAL (op) >= 0 && INTVAL (op) < 8)"))) |
| 339 |
|
| 340 |
;; Return true if OP is a constant in the range 7..15. This is an |
| 341 |
;; acceptable second operand for dictunpack instructions setting a |
| 342 |
;; V4HI mode in the destination register. |
| 343 |
(define_predicate "imm5_operand_dictunpack16" |
| 344 |
(and (match_code "const_int") |
| 345 |
(match_test "(INTVAL (op) >= 8 && INTVAL (op) < 16)"))) |
| 346 |
|
| 347 |
;; Return true if OP is a constant in the range 15..31. This is an |
| 348 |
;; acceptable second operand for dictunpack instructions setting a |
| 349 |
;; V2SI mode in the destination register. |
| 350 |
(define_predicate "imm5_operand_dictunpack32" |
| 351 |
(and (match_code "const_int") |
| 352 |
(match_test "(INTVAL (op) >= 16 && INTVAL (op) < 32)"))) |
| 353 |
|
| 354 |
;; Return true if OP is a constant that is representable by a 2-bit |
| 355 |
;; unsigned field. This is an acceptable third operand for |
| 356 |
;; fpcmp*shl instructions. |
| 357 |
(define_predicate "imm2_operand" |
| 358 |
(and (match_code "const_int") |
| 359 |
(match_test "SPARC_IMM2_P (INTVAL (op))"))) |
| 360 |
|
| 361 |
;; Predicates for miscellaneous instructions. |
| 362 |
|
| 363 |
;; Return true if OP is valid for the lhs of a comparison insn. |
| 364 |
(define_predicate "compare_operand" |
| 365 |
(match_code "reg,subreg,zero_extract") |
| 366 |
{ |
| 367 |
if (GET_CODE (op) == ZERO_EXTRACT) |
| 368 |
return (register_operand (XEXP (op, 0), mode) |
| 369 |
&& small_int_operand (XEXP (op, 1), mode) |
| 370 |
&& small_int_operand (XEXP (op, 2), mode) |
| 371 |
/* This matches cmp_zero_extract. */ |
| 372 |
&& ((mode == SImode |
| 373 |
&& INTVAL (XEXP (op, 2)) > 19) |
| 374 |
/* This matches cmp_zero_extract_sp64. */ |
| 375 |
|| (TARGET_ARCH64 |
| 376 |
&& mode == DImode |
| 377 |
&& INTVAL (XEXP (op, 2)) > 51))); |
| 378 |
|
| 379 |
return register_operand (op, mode); |
| 380 |
}) |
| 381 |
|
| 382 |
;; Return true if OP is a valid operand for the source of a move insn. |
| 383 |
(define_predicate "input_operand" |
| 384 |
(match_code "const_int,const_double,const_vector,reg,subreg,mem") |
| 385 |
{ |
| 386 |
enum mode_class mclass; |
| 387 |
|
| 388 |
/* If both modes are non-void they must be the same. */ |
| 389 |
if (mode != VOIDmode && GET_MODE (op) != VOIDmode && mode != GET_MODE (op)) |
| 390 |
return false; |
| 391 |
|
| 392 |
mclass = GET_MODE_CLASS (mode); |
| 393 |
|
| 394 |
/* Allow any 1-instruction integer constant. */ |
| 395 |
if (mclass == MODE_INT |
| 396 |
&& mode != TImode |
| 397 |
&& (small_int_operand (op, mode) || const_high_operand (op, mode))) |
| 398 |
return true; |
| 399 |
|
| 400 |
/* If 32-bit mode and this is a DImode constant, allow it |
| 401 |
so that the splits can be generated. */ |
| 402 |
if (TARGET_ARCH32 && mode == DImode && GET_CODE (op) == CONST_INT) |
| 403 |
return true; |
| 404 |
|
| 405 |
/* Allow FP constants to be built in integer registers. */ |
| 406 |
if (mclass == MODE_FLOAT && GET_CODE (op) == CONST_DOUBLE) |
| 407 |
return true; |
| 408 |
|
| 409 |
if (mclass == MODE_VECTOR_INT && const_all_ones_operand (op, mode)) |
| 410 |
return true; |
| 411 |
|
| 412 |
if (register_or_zero_operand (op, mode)) |
| 413 |
return true; |
| 414 |
|
| 415 |
/* If this is a SUBREG, look inside so that we handle paradoxical ones. */ |
| 416 |
if (GET_CODE (op) == SUBREG) |
| 417 |
op = SUBREG_REG (op); |
| 418 |
|
| 419 |
/* Check for valid MEM forms. */ |
| 420 |
if (GET_CODE (op) == MEM) |
| 421 |
{ |
| 422 |
/* Except when LRA is precisely working hard to make them valid |
| 423 |
and relying entirely on the constraints. */ |
| 424 |
if (lra_in_progress) |
| 425 |
return true; |
| 426 |
|
| 427 |
return memory_address_p (mode, XEXP (op, 0)); |
| 428 |
} |
| 429 |
|
| 430 |
return false; |
| 431 |
}) |
| 432 |
|
| 433 |
;; Return true if OP is an address suitable for a call insn. |
| 434 |
;; Call insn on SPARC can take a PC-relative constant address |
| 435 |
;; or any regular memory address. |
| 436 |
(define_predicate "call_address_operand" |
| 437 |
(ior (match_operand 0 "symbolic_operand") |
| 438 |
(match_test "memory_address_p (Pmode, op)"))) |
| 439 |
|
| 440 |
;; Return true if OP is an operand suitable for a call insn. |
| 441 |
(define_predicate "call_operand" |
| 442 |
(and (match_code "mem") |
| 443 |
(match_test "call_address_operand (XEXP (op, 0), mode)"))) |
| 444 |
|
| 445 |
|
| 446 |
(define_predicate "mem_noofs_operand" |
| 447 |
(and (match_code "mem") |
| 448 |
(match_code "reg" "0"))) |
| 449 |
|
| 450 |
;; Predicates for operators. |
| 451 |
|
| 452 |
;; Return true if OP is a valid comparison operator for CCNZmode. |
| 453 |
(define_predicate "nz_comparison_operator" |
| 454 |
(match_code "eq,ne,lt,ge")) |
| 455 |
|
| 456 |
;; Return true if OP is a valid comparison operator for CCCmode. |
| 457 |
(define_predicate "c_comparison_operator" |
| 458 |
(match_code "ltu,geu")) |
| 459 |
|
| 460 |
;; Return true if OP is a valid comparison operator for CCVmode. |
| 461 |
(define_predicate "v_comparison_operator" |
| 462 |
(match_code "eq,ne")) |
| 463 |
|
| 464 |
;; Return true if OP is an integer comparison operator. This allows |
| 465 |
;; the use of MATCH_OPERATOR to recognize all the branch insns. |
| 466 |
(define_predicate "icc_comparison_operator" |
| 467 |
(match_operand 0 "ordered_comparison_operator") |
| 468 |
{ |
| 469 |
switch (GET_MODE (XEXP (op, 0))) |
| 470 |
{ |
| 471 |
case E_CCmode: |
| 472 |
case E_CCXmode: |
| 473 |
return true; |
| 474 |
case E_CCNZmode: |
| 475 |
case E_CCXNZmode: |
| 476 |
return nz_comparison_operator (op, mode); |
| 477 |
case E_CCCmode: |
| 478 |
case E_CCXCmode: |
| 479 |
return c_comparison_operator (op, mode); |
| 480 |
case E_CCVmode: |
| 481 |
case E_CCXVmode: |
| 482 |
return v_comparison_operator (op, mode); |
| 483 |
default: |
| 484 |
return false; |
| 485 |
} |
| 486 |
}) |
| 487 |
|
| 488 |
;; Return true if OP is a FP comparison operator. |
| 489 |
(define_predicate "fcc_comparison_operator" |
| 490 |
(match_operand 0 "comparison_operator") |
| 491 |
{ |
| 492 |
switch (GET_MODE (XEXP (op, 0))) |
| 493 |
{ |
| 494 |
case E_CCFPmode: |
| 495 |
case E_CCFPEmode: |
| 496 |
return true; |
| 497 |
default: |
| 498 |
return false; |
| 499 |
} |
| 500 |
}) |
| 501 |
|
| 502 |
;; Return true if OP is an integer or FP comparison operator. This allows |
| 503 |
;; the use of MATCH_OPERATOR to recognize all the conditional move insns. |
| 504 |
(define_predicate "icc_or_fcc_comparison_operator" |
| 505 |
(ior (match_operand 0 "icc_comparison_operator") |
| 506 |
(match_operand 0 "fcc_comparison_operator"))) |
| 507 |
|
| 508 |
;; Return true if OP is an integer comparison operator for V9. |
| 509 |
(define_predicate "v9_comparison_operator" |
| 510 |
(and (match_operand 0 "ordered_comparison_operator") |
| 511 |
(match_test "TARGET_V9"))) |
| 512 |
|
| 513 |
;; Return true if OP is a comparison operator suitable for use in V9 |
| 514 |
;; conditional move or branch on register contents instructions. |
| 515 |
(define_predicate "v9_register_comparison_operator" |
| 516 |
(match_code "eq,ne,ge,lt,le,gt")) |
| 517 |
|
| 518 |
;; Return true if OP is an operator which can set the condition codes |
| 519 |
;; explicitly. We do not include PLUS/MINUS/NEG/ASHIFT because these |
| 520 |
;; require CCNZmode, which we handle explicitly. |
| 521 |
(define_predicate "cc_arith_operator" |
| 522 |
(match_code "and,ior,xor")) |
| 523 |
|
| 524 |
;; Return true if OP is an operator which can bitwise complement its |
| 525 |
;; second operand and set the condition codes explicitly. |
| 526 |
;; XOR is not here because combine canonicalizes (xor (not ...) ...) |
| 527 |
;; and (xor ... (not ...)) to (not (xor ...)). |
| 528 |
(define_predicate "cc_arith_not_operator" |
| 529 |
(match_code "and,ior")) |
| 530 |
|
| 531 |
;; Return true if OP is an operator for a vec_cmp pattern |
| 532 |
;; VIS 4 is required for ordering comparisons if the mode is V8QI |
| 533 |
(define_predicate "vec_cmp_operator" |
| 534 |
(match_operand 0 "comparison_operator") |
| 535 |
{ |
| 536 |
const enum rtx_code code = GET_CODE (op); |
| 537 |
|
| 538 |
switch (GET_MODE (XEXP (op, 0))) |
| 539 |
{ |
| 540 |
case V8QImode: |
| 541 |
return code == EQ || code == NE || TARGET_VIS4; |
| 542 |
|
| 543 |
default: |
| 544 |
return true; |
| 545 |
} |
| 546 |
}) |
| 547 |
|
| 548 |
;; Return true if OP is an operator for a vec_cmpu pattern |
| 549 |
;; VIS 4 is required for ordering comparisons if the mode is not V8QI |
| 550 |
(define_predicate "vec_cmpu_operator" |
| 551 |
(match_operand 0 "comparison_operator") |
| 552 |
{ |
| 553 |
const enum rtx_code code = GET_CODE (op); |
| 554 |
|
| 555 |
switch (GET_MODE (XEXP (op, 0))) |
| 556 |
{ |
| 557 |
case V8QImode: |
| 558 |
return true; |
| 559 |
|
| 560 |
default: |
| 561 |
return code == EQ || code == NE || TARGET_VIS4; |
| 562 |
} |
| 563 |
}) |