1 ;; Predicate definitions for POWER and PowerPC.
2 ;; Copyright (C) 2005-2013 Free Software Foundation, Inc.
4 ;; This file is part of GCC.
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)
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.
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/>.
20 ;; Return 1 for anything except PARALLEL.
21 (define_predicate "any_operand"
22 (match_code "const_int,const_double,const,symbol_ref,label_ref,subreg,reg,mem"))
24 ;; Return 1 for any PARALLEL.
25 (define_predicate "any_parallel_operand"
26 (match_code "parallel"))
28 ;; Return 1 if op is COUNT register.
29 (define_predicate "count_register_operand"
30 (and (match_code "reg")
31 (match_test "REGNO (op) == CTR_REGNO
32 || REGNO (op) > LAST_VIRTUAL_REGISTER")))
34 ;; Return 1 if op is an Altivec register.
35 (define_predicate "altivec_register_operand"
36 (match_operand 0 "register_operand")
38 if (GET_CODE (op) == SUBREG)
44 if (REGNO (op) > LAST_VIRTUAL_REGISTER)
47 return ALTIVEC_REGNO_P (REGNO (op));
50 ;; Return 1 if op is a VSX register.
51 (define_predicate "vsx_register_operand"
52 (match_operand 0 "register_operand")
54 if (GET_CODE (op) == SUBREG)
60 if (REGNO (op) > LAST_VIRTUAL_REGISTER)
63 return VSX_REGNO_P (REGNO (op));
66 ;; Return 1 if op is a vector register that operates on floating point vectors
67 ;; (either altivec or VSX).
68 (define_predicate "vfloat_operand"
69 (match_operand 0 "register_operand")
71 if (GET_CODE (op) == SUBREG)
77 if (REGNO (op) > LAST_VIRTUAL_REGISTER)
80 return VFLOAT_REGNO_P (REGNO (op));
83 ;; Return 1 if op is a vector register that operates on integer vectors
84 ;; (only altivec, VSX doesn't support integer vectors)
85 (define_predicate "vint_operand"
86 (match_operand 0 "register_operand")
88 if (GET_CODE (op) == SUBREG)
94 if (REGNO (op) > LAST_VIRTUAL_REGISTER)
97 return VINT_REGNO_P (REGNO (op));
100 ;; Return 1 if op is a vector register to do logical operations on (and, or,
102 (define_predicate "vlogical_operand"
103 (match_operand 0 "register_operand")
105 if (GET_CODE (op) == SUBREG)
106 op = SUBREG_REG (op);
111 if (REGNO (op) > LAST_VIRTUAL_REGISTER)
114 return VLOGICAL_REGNO_P (REGNO (op));
117 ;; Return 1 if op is the carry register.
118 (define_predicate "ca_operand"
119 (and (match_code "reg")
120 (match_test "CA_REGNO_P (REGNO (op))")))
122 ;; Return 1 if op is a signed 5-bit constant integer.
123 (define_predicate "s5bit_cint_operand"
124 (and (match_code "const_int")
125 (match_test "INTVAL (op) >= -16 && INTVAL (op) <= 15")))
127 ;; Return 1 if op is a unsigned 5-bit constant integer.
128 (define_predicate "u5bit_cint_operand"
129 (and (match_code "const_int")
130 (match_test "INTVAL (op) >= 0 && INTVAL (op) <= 31")))
132 ;; Return 1 if op is a signed 8-bit constant integer.
133 ;; Integer multiplication complete more quickly
134 (define_predicate "s8bit_cint_operand"
135 (and (match_code "const_int")
136 (match_test "INTVAL (op) >= -128 && INTVAL (op) <= 127")))
138 ;; Return 1 if op is a constant integer that can fit in a D field.
139 (define_predicate "short_cint_operand"
140 (and (match_code "const_int")
141 (match_test "satisfies_constraint_I (op)")))
143 ;; Return 1 if op is a constant integer that can fit in an unsigned D field.
144 (define_predicate "u_short_cint_operand"
145 (and (match_code "const_int")
146 (match_test "satisfies_constraint_K (op)")))
148 ;; Return 1 if op is a constant integer that cannot fit in a signed D field.
149 (define_predicate "non_short_cint_operand"
150 (and (match_code "const_int")
151 (match_test "(unsigned HOST_WIDE_INT)
152 (INTVAL (op) + 0x8000) >= 0x10000")))
154 ;; Return 1 if op is a positive constant integer that is an exact power of 2.
155 (define_predicate "exact_log2_cint_operand"
156 (and (match_code "const_int")
157 (match_test "INTVAL (op) > 0 && exact_log2 (INTVAL (op)) >= 0")))
159 ;; Match op = 0 or op = 1.
160 (define_predicate "const_0_to_1_operand"
161 (and (match_code "const_int")
162 (match_test "IN_RANGE (INTVAL (op), 0, 1)")))
164 ;; Match op = 2 or op = 3.
165 (define_predicate "const_2_to_3_operand"
166 (and (match_code "const_int")
167 (match_test "IN_RANGE (INTVAL (op), 2, 3)")))
169 ;; Return 1 if op is a register that is not special.
170 (define_predicate "gpc_reg_operand"
171 (match_operand 0 "register_operand")
173 if ((TARGET_E500_DOUBLE || TARGET_SPE) && invalid_e500_subreg (op, mode))
176 if (GET_CODE (op) == SUBREG)
177 op = SUBREG_REG (op);
182 if (REGNO (op) >= ARG_POINTER_REGNUM && !CA_REGNO_P (REGNO (op)))
185 return INT_REGNO_P (REGNO (op)) || FP_REGNO_P (REGNO (op));
188 ;; Return 1 if op is a register that is a condition register field.
189 (define_predicate "cc_reg_operand"
190 (match_operand 0 "register_operand")
192 if (GET_CODE (op) == SUBREG)
193 op = SUBREG_REG (op);
198 if (REGNO (op) > LAST_VIRTUAL_REGISTER)
201 return CR_REGNO_P (REGNO (op));
204 ;; Return 1 if op is a register that is a condition register field not cr0.
205 (define_predicate "cc_reg_not_cr0_operand"
206 (match_operand 0 "register_operand")
208 if (GET_CODE (op) == SUBREG)
209 op = SUBREG_REG (op);
214 if (REGNO (op) > LAST_VIRTUAL_REGISTER)
217 return CR_REGNO_NOT_CR0_P (REGNO (op));
220 ;; Return 1 if op is a register that is a condition register field and if generating microcode, not cr0.
221 (define_predicate "cc_reg_not_micro_cr0_operand"
222 (match_operand 0 "register_operand")
224 if (GET_CODE (op) == SUBREG)
225 op = SUBREG_REG (op);
230 if (REGNO (op) > LAST_VIRTUAL_REGISTER)
233 if (rs6000_gen_cell_microcode)
234 return CR_REGNO_NOT_CR0_P (REGNO (op));
236 return CR_REGNO_P (REGNO (op));
239 ;; Return 1 if op is a constant integer valid for D field
240 ;; or non-special register register.
241 (define_predicate "reg_or_short_operand"
242 (if_then_else (match_code "const_int")
243 (match_operand 0 "short_cint_operand")
244 (match_operand 0 "gpc_reg_operand")))
246 ;; Return 1 if op is a constant integer valid whose negation is valid for
247 ;; D field or non-special register register.
248 ;; Do not allow a constant zero because all patterns that call this
249 ;; predicate use "addic r1,r2,-const" to set carry when r2 is greater than
250 ;; or equal to const, which does not work for zero.
251 (define_predicate "reg_or_neg_short_operand"
252 (if_then_else (match_code "const_int")
253 (match_test "satisfies_constraint_P (op)
254 && INTVAL (op) != 0")
255 (match_operand 0 "gpc_reg_operand")))
257 ;; Return 1 if op is a constant integer valid for DS field
258 ;; or non-special register.
259 (define_predicate "reg_or_aligned_short_operand"
260 (if_then_else (match_code "const_int")
261 (and (match_operand 0 "short_cint_operand")
262 (match_test "!(INTVAL (op) & 3)"))
263 (match_operand 0 "gpc_reg_operand")))
265 ;; Return 1 if op is a constant integer whose high-order 16 bits are zero
266 ;; or non-special register.
267 (define_predicate "reg_or_u_short_operand"
268 (if_then_else (match_code "const_int")
269 (match_operand 0 "u_short_cint_operand")
270 (match_operand 0 "gpc_reg_operand")))
272 ;; Return 1 if op is any constant integer
273 ;; or non-special register.
274 (define_predicate "reg_or_cint_operand"
275 (ior (match_code "const_int")
276 (match_operand 0 "gpc_reg_operand")))
278 ;; Return 1 if op is a constant integer valid for addition
279 ;; or non-special register.
280 (define_predicate "reg_or_add_cint_operand"
281 (if_then_else (match_code "const_int")
282 (match_test "(HOST_BITS_PER_WIDE_INT == 32
283 && (mode == SImode || INTVAL (op) < 0x7fff8000))
284 || ((unsigned HOST_WIDE_INT) (INTVAL (op) + 0x80008000)
285 < (unsigned HOST_WIDE_INT) 0x100000000ll)")
286 (match_operand 0 "gpc_reg_operand")))
288 ;; Return 1 if op is a constant integer valid for subtraction
289 ;; or non-special register.
290 (define_predicate "reg_or_sub_cint_operand"
291 (if_then_else (match_code "const_int")
292 (match_test "(HOST_BITS_PER_WIDE_INT == 32
293 && (mode == SImode || - INTVAL (op) < 0x7fff8000))
294 || ((unsigned HOST_WIDE_INT) (- INTVAL (op)
296 ? 0x80000000 : 0x80008000))
297 < (unsigned HOST_WIDE_INT) 0x100000000ll)")
298 (match_operand 0 "gpc_reg_operand")))
300 ;; Return 1 if op is any 32-bit unsigned constant integer
301 ;; or non-special register.
302 (define_predicate "reg_or_logical_cint_operand"
303 (if_then_else (match_code "const_int")
304 (match_test "(GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT
306 || ((INTVAL (op) & GET_MODE_MASK (mode)
307 & (~ (unsigned HOST_WIDE_INT) 0xffffffff)) == 0)")
308 (if_then_else (match_code "const_double")
309 (match_test "GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT
311 && CONST_DOUBLE_HIGH (op) == 0")
312 (match_operand 0 "gpc_reg_operand"))))
314 ;; Return 1 if operand is a CONST_DOUBLE that can be set in a register
315 ;; with no more than one instruction per word.
316 (define_predicate "easy_fp_constant"
317 (match_code "const_double")
322 if (GET_MODE (op) != mode
323 || (!SCALAR_FLOAT_MODE_P (mode) && mode != DImode))
326 /* Consider all constants with -msoft-float to be easy. */
327 if ((TARGET_SOFT_FLOAT || TARGET_E500_SINGLE
328 || (TARGET_HARD_FLOAT && (TARGET_SINGLE_FLOAT && ! TARGET_DOUBLE_FLOAT)))
332 if (DECIMAL_FLOAT_MODE_P (mode))
335 /* If we are using V.4 style PIC, consider all constants to be hard. */
336 if (flag_pic && DEFAULT_ABI == ABI_V4)
339 #ifdef TARGET_RELOCATABLE
340 /* Similarly if we are using -mrelocatable, consider all constants
342 if (TARGET_RELOCATABLE)
349 if (TARGET_E500_DOUBLE)
352 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
353 REAL_VALUE_TO_TARGET_LONG_DOUBLE (rv, k);
355 return (num_insns_constant_wide ((HOST_WIDE_INT) k[0]) == 1
356 && num_insns_constant_wide ((HOST_WIDE_INT) k[1]) == 1
357 && num_insns_constant_wide ((HOST_WIDE_INT) k[2]) == 1
358 && num_insns_constant_wide ((HOST_WIDE_INT) k[3]) == 1);
361 /* The constant 0.f is easy under VSX. */
362 if (op == CONST0_RTX (DFmode) && VECTOR_UNIT_VSX_P (DFmode))
365 /* Force constants to memory before reload to utilize
366 compress_float_constant.
367 Avoid this when flag_unsafe_math_optimizations is enabled
368 because RDIV division to reciprocal optimization is not able
369 to regenerate the division. */
370 if (TARGET_E500_DOUBLE
371 || (!reload_in_progress && !reload_completed
372 && !flag_unsafe_math_optimizations))
375 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
376 REAL_VALUE_TO_TARGET_DOUBLE (rv, k);
378 return (num_insns_constant_wide ((HOST_WIDE_INT) k[0]) == 1
379 && num_insns_constant_wide ((HOST_WIDE_INT) k[1]) == 1);
382 /* The constant 0.f is easy. */
383 if (op == CONST0_RTX (SFmode))
386 /* Force constants to memory before reload to utilize
387 compress_float_constant.
388 Avoid this when flag_unsafe_math_optimizations is enabled
389 because RDIV division to reciprocal optimization is not able
390 to regenerate the division. */
391 if (!reload_in_progress && !reload_completed
392 && !flag_unsafe_math_optimizations)
395 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
396 REAL_VALUE_TO_TARGET_SINGLE (rv, k[0]);
398 return num_insns_constant_wide (k[0]) == 1;
401 return ((TARGET_POWERPC64
402 && GET_CODE (op) == CONST_DOUBLE && CONST_DOUBLE_LOW (op) == 0)
403 || (num_insns_constant (op, DImode) <= 2));
413 ;; Return 1 if the operand is a CONST_VECTOR and can be loaded into a
414 ;; vector register without using memory.
415 (define_predicate "easy_vector_constant"
416 (match_code "const_vector")
418 /* As the paired vectors are actually FPRs it seems that there is
419 no easy way to load a CONST_VECTOR without using memory. */
420 if (TARGET_PAIRED_FLOAT)
423 if (VECTOR_MEM_ALTIVEC_OR_VSX_P (mode))
425 if (zero_constant (op, mode))
428 return easy_altivec_constant (op, mode);
431 if (SPE_VECTOR_MODE (mode))
434 if (zero_constant (op, mode))
436 if (GET_MODE_CLASS (mode) != MODE_VECTOR_INT)
439 /* Limit SPE vectors to 15 bits signed. These we can generate with:
444 I don't know how efficient it would be to allow bigger constants,
445 considering we'll have an extra 'ori' for every 'li'. I doubt 5
446 instructions is better than a 64-bit memory load, but I don't
447 have the e500 timing specs. */
448 if (mode == V2SImode)
450 cst = INTVAL (CONST_VECTOR_ELT (op, 0));
451 cst2 = INTVAL (CONST_VECTOR_ELT (op, 1));
452 return cst >= -0x7fff && cst <= 0x7fff
453 && cst2 >= -0x7fff && cst2 <= 0x7fff;
460 ;; Same as easy_vector_constant but only for EASY_VECTOR_15_ADD_SELF.
461 (define_predicate "easy_vector_constant_add_self"
462 (and (match_code "const_vector")
463 (and (match_test "TARGET_ALTIVEC")
464 (match_test "easy_altivec_constant (op, mode)")))
467 if (mode == V2DImode || mode == V2DFmode)
469 val = const_vector_elt_as_int (op, GET_MODE_NUNITS (mode) - 1);
470 val = ((val & 0xff) ^ 0x80) - 0x80;
471 return EASY_VECTOR_15_ADD_SELF (val);
474 ;; Same as easy_vector_constant but only for EASY_VECTOR_MSB.
475 (define_predicate "easy_vector_constant_msb"
476 (and (match_code "const_vector")
477 (and (match_test "TARGET_ALTIVEC")
478 (match_test "easy_altivec_constant (op, mode)")))
481 if (mode == V2DImode || mode == V2DFmode)
483 val = const_vector_elt_as_int (op, GET_MODE_NUNITS (mode) - 1);
484 return EASY_VECTOR_MSB (val, GET_MODE_INNER (mode));
487 ;; Return 1 if operand is constant zero (scalars and vectors).
488 (define_predicate "zero_constant"
489 (and (match_code "const_int,const_double,const_vector")
490 (match_test "op == CONST0_RTX (mode)")))
492 ;; Return 1 if operand is 0.0.
493 (define_predicate "zero_fp_constant"
494 (and (match_code "const_double")
495 (match_test "SCALAR_FLOAT_MODE_P (mode)
496 && op == CONST0_RTX (mode)")))
498 ;; Return 1 if the operand is in volatile memory. Note that during the
499 ;; RTL generation phase, memory_operand does not return TRUE for volatile
500 ;; memory references. So this function allows us to recognize volatile
501 ;; references where it's safe.
502 (define_predicate "volatile_mem_operand"
503 (and (and (match_code "mem")
504 (match_test "MEM_VOLATILE_P (op)"))
505 (if_then_else (match_test "reload_completed")
506 (match_operand 0 "memory_operand")
507 (if_then_else (match_test "reload_in_progress")
508 (match_test "strict_memory_address_p (mode, XEXP (op, 0))")
509 (match_test "memory_address_p (mode, XEXP (op, 0))")))))
511 ;; Return 1 if the operand is an offsettable memory operand.
512 (define_predicate "offsettable_mem_operand"
513 (and (match_operand 0 "memory_operand")
514 (match_test "offsettable_nonstrict_memref_p (op)")))
516 ;; Return 1 if the operand is an indexed or indirect memory operand.
517 (define_predicate "indexed_or_indirect_operand"
521 if (VECTOR_MEM_ALTIVEC_P (mode)
522 && GET_CODE (op) == AND
523 && GET_CODE (XEXP (op, 1)) == CONST_INT
524 && INTVAL (XEXP (op, 1)) == -16)
527 return indexed_or_indirect_address (op, mode);
530 ;; Return 1 if the operand is an indexed or indirect memory operand with an
531 ;; AND -16 in it, used to recognize when we need to switch to Altivec loads
532 ;; to realign loops instead of VSX (altivec silently ignores the bottom bits,
533 ;; while VSX uses the full address and traps)
534 (define_predicate "altivec_indexed_or_indirect_operand"
538 if (VECTOR_MEM_ALTIVEC_OR_VSX_P (mode)
539 && GET_CODE (op) == AND
540 && GET_CODE (XEXP (op, 1)) == CONST_INT
541 && INTVAL (XEXP (op, 1)) == -16)
542 return indexed_or_indirect_address (XEXP (op, 0), mode);
547 ;; Return 1 if the operand is an indexed or indirect address.
548 (define_special_predicate "indexed_or_indirect_address"
549 (and (match_test "REG_P (op)
550 || (GET_CODE (op) == PLUS
551 /* Omit testing REG_P (XEXP (op, 0)). */
552 && REG_P (XEXP (op, 1)))")
553 (match_operand 0 "address_operand")))
555 ;; Used for the destination of the fix_truncdfsi2 expander.
556 ;; If stfiwx will be used, the result goes to memory; otherwise,
557 ;; we're going to emit a store and a load of a subreg, so the dest is a
559 (define_predicate "fix_trunc_dest_operand"
560 (if_then_else (match_test "! TARGET_E500_DOUBLE && TARGET_PPC_GFXOPT")
561 (match_operand 0 "memory_operand")
562 (match_operand 0 "gpc_reg_operand")))
564 ;; Return 1 if the operand is either a non-special register or can be used
565 ;; as the operand of a `mode' add insn.
566 (define_predicate "add_operand"
567 (if_then_else (match_code "const_int")
568 (match_test "satisfies_constraint_I (op)
569 || satisfies_constraint_L (op)")
570 (match_operand 0 "gpc_reg_operand")))
572 ;; Return 1 if OP is a constant but not a valid add_operand.
573 (define_predicate "non_add_cint_operand"
574 (and (match_code "const_int")
575 (match_test "!satisfies_constraint_I (op)
576 && !satisfies_constraint_L (op)")))
578 ;; Return 1 if the operand is a constant that can be used as the operand
580 (define_predicate "logical_const_operand"
581 (match_code "const_int,const_double")
583 HOST_WIDE_INT opl, oph;
585 if (GET_CODE (op) == CONST_INT)
587 opl = INTVAL (op) & GET_MODE_MASK (mode);
589 if (HOST_BITS_PER_WIDE_INT <= 32
590 && GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT && opl < 0)
593 else if (GET_CODE (op) == CONST_DOUBLE)
595 gcc_assert (GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT);
597 opl = CONST_DOUBLE_LOW (op);
598 oph = CONST_DOUBLE_HIGH (op);
605 return ((opl & ~ (unsigned HOST_WIDE_INT) 0xffff) == 0
606 || (opl & ~ (unsigned HOST_WIDE_INT) 0xffff0000) == 0);
609 ;; Return 1 if the operand is a non-special register or a constant that
610 ;; can be used as the operand of an OR or XOR.
611 (define_predicate "logical_operand"
612 (ior (match_operand 0 "gpc_reg_operand")
613 (match_operand 0 "logical_const_operand")))
615 ;; Return 1 if op is a constant that is not a logical operand, but could
616 ;; be split into one.
617 (define_predicate "non_logical_cint_operand"
618 (and (match_code "const_int,const_double")
619 (and (not (match_operand 0 "logical_operand"))
620 (match_operand 0 "reg_or_logical_cint_operand"))))
622 ;; Return 1 if op is a constant that can be encoded in a 32-bit mask,
623 ;; suitable for use with rlwinm (no more than two 1->0 or 0->1
624 ;; transitions). Reject all ones and all zeros, since these should have
625 ;; been optimized away and confuse the making of MB and ME.
626 (define_predicate "mask_operand"
627 (match_code "const_int")
629 HOST_WIDE_INT c, lsb;
633 if (TARGET_POWERPC64)
635 /* Fail if the mask is not 32-bit. */
636 if (mode == DImode && (c & ~(unsigned HOST_WIDE_INT) 0xffffffff) != 0)
639 /* Fail if the mask wraps around because the upper 32-bits of the
640 mask will all be 1s, contrary to GCC's internal view. */
641 if ((c & 0x80000001) == 0x80000001)
645 /* We don't change the number of transitions by inverting,
646 so make sure we start with the LS bit zero. */
650 /* Reject all zeros or all ones. */
654 /* Find the first transition. */
657 /* Invert to look for a second transition. */
660 /* Erase first transition. */
663 /* Find the second transition (if any). */
666 /* Match if all the bits above are 1's (or c is zero). */
670 ;; Return 1 for the PowerPC64 rlwinm corner case.
671 (define_predicate "mask_operand_wrap"
672 (match_code "const_int")
674 HOST_WIDE_INT c, lsb;
678 if ((c & 0x80000001) != 0x80000001)
692 ;; Return 1 if the operand is a constant that is a PowerPC64 mask
693 ;; suitable for use with rldicl or rldicr (no more than one 1->0 or 0->1
694 ;; transition). Reject all zeros, since zero should have been
695 ;; optimized away and confuses the making of MB and ME.
696 (define_predicate "mask64_operand"
697 (match_code "const_int")
699 HOST_WIDE_INT c, lsb;
703 /* Reject all zeros. */
707 /* We don't change the number of transitions by inverting,
708 so make sure we start with the LS bit zero. */
712 /* Find the first transition. */
715 /* Match if all the bits above are 1's (or c is zero). */
719 ;; Like mask64_operand, but allow up to three transitions. This
720 ;; predicate is used by insn patterns that generate two rldicl or
721 ;; rldicr machine insns.
722 (define_predicate "mask64_2_operand"
723 (match_code "const_int")
725 HOST_WIDE_INT c, lsb;
729 /* Disallow all zeros. */
733 /* We don't change the number of transitions by inverting,
734 so make sure we start with the LS bit zero. */
738 /* Find the first transition. */
741 /* Invert to look for a second transition. */
744 /* Erase first transition. */
747 /* Find the second transition. */
750 /* Invert to look for a third transition. */
753 /* Erase second transition. */
756 /* Find the third transition (if any). */
759 /* Match if all the bits above are 1's (or c is zero). */
763 ;; Like and_operand, but also match constants that can be implemented
764 ;; with two rldicl or rldicr insns.
765 (define_predicate "and64_2_operand"
766 (ior (match_operand 0 "mask64_2_operand")
767 (if_then_else (match_test "fixed_regs[CR0_REGNO]")
768 (match_operand 0 "gpc_reg_operand")
769 (match_operand 0 "logical_operand"))))
771 ;; Return 1 if the operand is either a non-special register or a
772 ;; constant that can be used as the operand of a logical AND.
773 (define_predicate "and_operand"
774 (ior (match_operand 0 "mask_operand")
775 (ior (and (match_test "TARGET_POWERPC64 && mode == DImode")
776 (match_operand 0 "mask64_operand"))
777 (if_then_else (match_test "fixed_regs[CR0_REGNO]")
778 (match_operand 0 "gpc_reg_operand")
779 (match_operand 0 "logical_operand")))))
781 ;; Return 1 if the operand is either a logical operand or a short cint operand.
782 (define_predicate "scc_eq_operand"
783 (ior (match_operand 0 "logical_operand")
784 (match_operand 0 "short_cint_operand")))
786 ;; Return 1 if the operand is a general non-special register or memory operand.
787 (define_predicate "reg_or_mem_operand"
788 (ior (match_operand 0 "memory_operand")
789 (ior (and (match_code "mem")
790 (match_test "macho_lo_sum_memory_operand (op, mode)"))
791 (ior (match_operand 0 "volatile_mem_operand")
792 (match_operand 0 "gpc_reg_operand")))))
794 ;; Return 1 if the operand is either an easy FP constant or memory or reg.
795 (define_predicate "reg_or_none500mem_operand"
796 (if_then_else (match_code "mem")
797 (and (match_test "!TARGET_E500_DOUBLE")
798 (ior (match_operand 0 "memory_operand")
799 (ior (match_test "macho_lo_sum_memory_operand (op, mode)")
800 (match_operand 0 "volatile_mem_operand"))))
801 (match_operand 0 "gpc_reg_operand")))
803 ;; Return 1 if the operand is CONST_DOUBLE 0, register or memory operand.
804 (define_predicate "zero_reg_mem_operand"
805 (ior (match_operand 0 "zero_fp_constant")
806 (match_operand 0 "reg_or_mem_operand")))
808 ;; Return 1 if the operand is a general register or memory operand without
809 ;; pre_inc or pre_dec or pre_modify, which produces invalid form of PowerPC
811 (define_predicate "lwa_operand"
812 (match_code "reg,subreg,mem")
814 rtx inner, addr, offset;
817 if (reload_completed && GET_CODE (inner) == SUBREG)
818 inner = SUBREG_REG (inner);
820 if (gpc_reg_operand (inner, mode))
822 if (!memory_operand (inner, mode))
824 addr = XEXP (inner, 0);
825 if (GET_CODE (addr) == PRE_INC
826 || GET_CODE (addr) == PRE_DEC
827 || (GET_CODE (addr) == PRE_MODIFY
828 && !legitimate_indexed_address_p (XEXP (addr, 1), 0)))
830 if (GET_CODE (addr) == LO_SUM
831 && GET_CODE (XEXP (addr, 0)) == REG
832 && GET_CODE (XEXP (addr, 1)) == CONST)
833 addr = XEXP (XEXP (addr, 1), 0);
834 if (GET_CODE (addr) != PLUS)
836 offset = XEXP (addr, 1);
837 if (GET_CODE (offset) != CONST_INT)
839 return INTVAL (offset) % 4 == 0;
842 ;; Return 1 if the operand, used inside a MEM, is a SYMBOL_REF.
843 (define_predicate "symbol_ref_operand"
844 (and (match_code "symbol_ref")
845 (match_test "(mode == VOIDmode || GET_MODE (op) == mode)
846 && (DEFAULT_ABI != ABI_AIX || SYMBOL_REF_FUNCTION_P (op))")))
848 ;; Return 1 if op is an operand that can be loaded via the GOT.
849 ;; or non-special register register field no cr0
850 (define_predicate "got_operand"
851 (match_code "symbol_ref,const,label_ref"))
853 ;; Return 1 if op is a simple reference that can be loaded via the GOT,
854 ;; excluding labels involving addition.
855 (define_predicate "got_no_const_operand"
856 (match_code "symbol_ref,label_ref"))
858 ;; Return 1 if op is a SYMBOL_REF for a TLS symbol.
859 (define_predicate "rs6000_tls_symbol_ref"
860 (and (match_code "symbol_ref")
861 (match_test "RS6000_SYMBOL_REF_TLS_P (op)")))
863 ;; Return 1 if the operand, used inside a MEM, is a valid first argument
864 ;; to CALL. This is a SYMBOL_REF, a pseudo-register, LR or CTR.
865 (define_predicate "call_operand"
866 (if_then_else (match_code "reg")
867 (match_test "REGNO (op) == LR_REGNO
868 || REGNO (op) == CTR_REGNO
869 || REGNO (op) >= FIRST_PSEUDO_REGISTER")
870 (match_code "symbol_ref")))
872 ;; Return 1 if the operand is a SYMBOL_REF for a function known to be in
874 (define_predicate "current_file_function_operand"
875 (and (match_code "symbol_ref")
876 (match_test "(DEFAULT_ABI != ABI_AIX || SYMBOL_REF_FUNCTION_P (op))
877 && ((SYMBOL_REF_LOCAL_P (op)
878 && (DEFAULT_ABI != ABI_AIX
879 || !SYMBOL_REF_EXTERNAL_P (op)))
880 || (op == XEXP (DECL_RTL (current_function_decl),
883 ;; Return 1 if this operand is a valid input for a move insn.
884 (define_predicate "input_operand"
885 (match_code "symbol_ref,const,reg,subreg,mem,
886 const_double,const_vector,const_int")
888 /* Memory is always valid. */
889 if (memory_operand (op, mode))
892 /* For floating-point, easy constants are valid. */
893 if (SCALAR_FLOAT_MODE_P (mode)
894 && easy_fp_constant (op, mode))
897 /* Allow any integer constant. */
898 if (GET_MODE_CLASS (mode) == MODE_INT
899 && (GET_CODE (op) == CONST_INT
900 || GET_CODE (op) == CONST_DOUBLE))
903 /* Allow easy vector constants. */
904 if (GET_CODE (op) == CONST_VECTOR
905 && easy_vector_constant (op, mode))
908 /* Do not allow invalid E500 subregs. */
909 if ((TARGET_E500_DOUBLE || TARGET_SPE)
910 && GET_CODE (op) == SUBREG
911 && invalid_e500_subreg (op, mode))
914 /* For floating-point or multi-word mode, the only remaining valid type
916 if (SCALAR_FLOAT_MODE_P (mode)
917 || GET_MODE_SIZE (mode) > UNITS_PER_WORD)
918 return register_operand (op, mode);
920 /* The only cases left are integral modes one word or smaller (we
921 do not get called for MODE_CC values). These can be in any
923 if (register_operand (op, mode))
926 /* V.4 allows SYMBOL_REFs and CONSTs that are in the small data region
928 if (DEFAULT_ABI == ABI_V4
929 && (GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == CONST)
930 && small_data_operand (op, Pmode))
936 ;; Return 1 if this operand is a valid input for a vsx_splat insn.
937 (define_predicate "splat_input_operand"
938 (match_code "symbol_ref,const,reg,subreg,mem,
939 const_double,const_vector,const_int")
943 if (! volatile_ok && MEM_VOLATILE_P (op))
947 else if (mode == DImode)
951 return memory_address_addr_space_p (mode, XEXP (op, 0),
952 MEM_ADDR_SPACE (op));
954 return input_operand (op, mode);
957 ;; Return true if OP is a non-immediate operand and not an invalid
958 ;; SUBREG operation on the e500.
959 (define_predicate "rs6000_nonimmediate_operand"
960 (match_code "reg,subreg,mem")
962 if ((TARGET_E500_DOUBLE || TARGET_SPE)
963 && GET_CODE (op) == SUBREG
964 && invalid_e500_subreg (op, mode))
967 return nonimmediate_operand (op, mode);
970 ;; Return true if operand is boolean operator.
971 (define_predicate "boolean_operator"
972 (match_code "and,ior,xor"))
974 ;; Return true if operand is OR-form of boolean operator.
975 (define_predicate "boolean_or_operator"
976 (match_code "ior,xor"))
978 ;; Return true if operand is an equality operator.
979 (define_special_predicate "equality_operator"
980 (match_code "eq,ne"))
982 ;; Return true if operand is MIN or MAX operator.
983 (define_predicate "min_max_operator"
984 (match_code "smin,smax,umin,umax"))
986 ;; Return 1 if OP is a comparison operation that is valid for a branch
987 ;; instruction. We check the opcode against the mode of the CC value.
988 ;; validate_condition_mode is an assertion.
989 (define_predicate "branch_comparison_operator"
990 (and (match_operand 0 "comparison_operator")
991 (and (match_test "GET_MODE_CLASS (GET_MODE (XEXP (op, 0))) == MODE_CC")
992 (match_test "validate_condition_mode (GET_CODE (op),
993 GET_MODE (XEXP (op, 0))),
996 (define_predicate "rs6000_cbranch_operator"
997 (if_then_else (match_test "TARGET_HARD_FLOAT && !TARGET_FPRS")
998 (match_operand 0 "ordered_comparison_operator")
999 (match_operand 0 "comparison_operator")))
1001 ;; Return 1 if OP is a comparison operation that is valid for an SCC insn --
1002 ;; it must be a positive comparison.
1003 (define_predicate "scc_comparison_operator"
1004 (and (match_operand 0 "branch_comparison_operator")
1005 (match_code "eq,lt,gt,ltu,gtu,unordered")))
1007 ;; Return 1 if OP is a comparison operation whose inverse would be valid for
1009 (define_predicate "scc_rev_comparison_operator"
1010 (and (match_operand 0 "branch_comparison_operator")
1011 (match_code "ne,le,ge,leu,geu,ordered")))
1013 ;; Return 1 if OP is a comparison operation that is valid for a branch
1014 ;; insn, which is true if the corresponding bit in the CC register is set.
1015 (define_predicate "branch_positive_comparison_operator"
1016 (and (match_operand 0 "branch_comparison_operator")
1017 (match_code "eq,lt,gt,ltu,gtu,unordered")))
1019 ;; Return 1 if OP is a load multiple operation, known to be a PARALLEL.
1020 (define_predicate "load_multiple_operation"
1021 (match_code "parallel")
1023 int count = XVECLEN (op, 0);
1024 unsigned int dest_regno;
1028 /* Perform a quick check so we don't blow up below. */
1030 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1031 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != REG
1032 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != MEM)
1035 dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, 0)));
1036 src_addr = XEXP (SET_SRC (XVECEXP (op, 0, 0)), 0);
1038 for (i = 1; i < count; i++)
1040 rtx elt = XVECEXP (op, 0, i);
1042 if (GET_CODE (elt) != SET
1043 || GET_CODE (SET_DEST (elt)) != REG
1044 || GET_MODE (SET_DEST (elt)) != SImode
1045 || REGNO (SET_DEST (elt)) != dest_regno + i
1046 || GET_CODE (SET_SRC (elt)) != MEM
1047 || GET_MODE (SET_SRC (elt)) != SImode
1048 || GET_CODE (XEXP (SET_SRC (elt), 0)) != PLUS
1049 || ! rtx_equal_p (XEXP (XEXP (SET_SRC (elt), 0), 0), src_addr)
1050 || GET_CODE (XEXP (XEXP (SET_SRC (elt), 0), 1)) != CONST_INT
1051 || INTVAL (XEXP (XEXP (SET_SRC (elt), 0), 1)) != i * 4)
1058 ;; Return 1 if OP is a store multiple operation, known to be a PARALLEL.
1059 ;; The second vector element is a CLOBBER.
1060 (define_predicate "store_multiple_operation"
1061 (match_code "parallel")
1063 int count = XVECLEN (op, 0) - 1;
1064 unsigned int src_regno;
1068 /* Perform a quick check so we don't blow up below. */
1070 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1071 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != MEM
1072 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != REG)
1075 src_regno = REGNO (SET_SRC (XVECEXP (op, 0, 0)));
1076 dest_addr = XEXP (SET_DEST (XVECEXP (op, 0, 0)), 0);
1078 for (i = 1; i < count; i++)
1080 rtx elt = XVECEXP (op, 0, i + 1);
1082 if (GET_CODE (elt) != SET
1083 || GET_CODE (SET_SRC (elt)) != REG
1084 || GET_MODE (SET_SRC (elt)) != SImode
1085 || REGNO (SET_SRC (elt)) != src_regno + i
1086 || GET_CODE (SET_DEST (elt)) != MEM
1087 || GET_MODE (SET_DEST (elt)) != SImode
1088 || GET_CODE (XEXP (SET_DEST (elt), 0)) != PLUS
1089 || ! rtx_equal_p (XEXP (XEXP (SET_DEST (elt), 0), 0), dest_addr)
1090 || GET_CODE (XEXP (XEXP (SET_DEST (elt), 0), 1)) != CONST_INT
1091 || INTVAL (XEXP (XEXP (SET_DEST (elt), 0), 1)) != i * 4)
1098 ;; Return 1 if OP is valid for a save_world call in prologue, known to be
1100 (define_predicate "save_world_operation"
1101 (match_code "parallel")
1106 int count = XVECLEN (op, 0);
1112 if (GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
1113 || GET_CODE (XVECEXP (op, 0, index++)) != USE)
1116 for (i=1; i <= 18; i++)
1118 elt = XVECEXP (op, 0, index++);
1119 if (GET_CODE (elt) != SET
1120 || GET_CODE (SET_DEST (elt)) != MEM
1121 || ! memory_operand (SET_DEST (elt), DFmode)
1122 || GET_CODE (SET_SRC (elt)) != REG
1123 || GET_MODE (SET_SRC (elt)) != DFmode)
1127 for (i=1; i <= 12; i++)
1129 elt = XVECEXP (op, 0, index++);
1130 if (GET_CODE (elt) != SET
1131 || GET_CODE (SET_DEST (elt)) != MEM
1132 || GET_CODE (SET_SRC (elt)) != REG
1133 || GET_MODE (SET_SRC (elt)) != V4SImode)
1137 for (i=1; i <= 19; i++)
1139 elt = XVECEXP (op, 0, index++);
1140 if (GET_CODE (elt) != SET
1141 || GET_CODE (SET_DEST (elt)) != MEM
1142 || ! memory_operand (SET_DEST (elt), Pmode)
1143 || GET_CODE (SET_SRC (elt)) != REG
1144 || GET_MODE (SET_SRC (elt)) != Pmode)
1148 elt = XVECEXP (op, 0, index++);
1149 if (GET_CODE (elt) != SET
1150 || GET_CODE (SET_DEST (elt)) != MEM
1151 || ! memory_operand (SET_DEST (elt), Pmode)
1152 || GET_CODE (SET_SRC (elt)) != REG
1153 || REGNO (SET_SRC (elt)) != CR2_REGNO
1154 || GET_MODE (SET_SRC (elt)) != Pmode)
1157 if (GET_CODE (XVECEXP (op, 0, index++)) != SET
1158 || GET_CODE (XVECEXP (op, 0, index++)) != SET)
1163 ;; Return 1 if OP is valid for a restore_world call in epilogue, known to be
1165 (define_predicate "restore_world_operation"
1166 (match_code "parallel")
1171 int count = XVECLEN (op, 0);
1177 if (GET_CODE (XVECEXP (op, 0, index++)) != RETURN
1178 || GET_CODE (XVECEXP (op, 0, index++)) != USE
1179 || GET_CODE (XVECEXP (op, 0, index++)) != USE
1180 || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER)
1183 elt = XVECEXP (op, 0, index++);
1184 if (GET_CODE (elt) != SET
1185 || GET_CODE (SET_SRC (elt)) != MEM
1186 || ! memory_operand (SET_SRC (elt), Pmode)
1187 || GET_CODE (SET_DEST (elt)) != REG
1188 || REGNO (SET_DEST (elt)) != CR2_REGNO
1189 || GET_MODE (SET_DEST (elt)) != Pmode)
1192 for (i=1; i <= 19; i++)
1194 elt = XVECEXP (op, 0, index++);
1195 if (GET_CODE (elt) != SET
1196 || GET_CODE (SET_SRC (elt)) != MEM
1197 || ! memory_operand (SET_SRC (elt), Pmode)
1198 || GET_CODE (SET_DEST (elt)) != REG
1199 || GET_MODE (SET_DEST (elt)) != Pmode)
1203 for (i=1; i <= 12; i++)
1205 elt = XVECEXP (op, 0, index++);
1206 if (GET_CODE (elt) != SET
1207 || GET_CODE (SET_SRC (elt)) != MEM
1208 || GET_CODE (SET_DEST (elt)) != REG
1209 || GET_MODE (SET_DEST (elt)) != V4SImode)
1213 for (i=1; i <= 18; i++)
1215 elt = XVECEXP (op, 0, index++);
1216 if (GET_CODE (elt) != SET
1217 || GET_CODE (SET_SRC (elt)) != MEM
1218 || ! memory_operand (SET_SRC (elt), DFmode)
1219 || GET_CODE (SET_DEST (elt)) != REG
1220 || GET_MODE (SET_DEST (elt)) != DFmode)
1224 if (GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
1225 || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
1226 || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
1227 || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
1228 || GET_CODE (XVECEXP (op, 0, index++)) != USE)
1233 ;; Return 1 if OP is valid for a vrsave call, known to be a PARALLEL.
1234 (define_predicate "vrsave_operation"
1235 (match_code "parallel")
1237 int count = XVECLEN (op, 0);
1238 unsigned int dest_regno, src_regno;
1242 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1243 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != REG
1244 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != UNSPEC_VOLATILE
1245 || XINT (SET_SRC (XVECEXP (op, 0, 0)), 1) != UNSPECV_SET_VRSAVE)
1248 dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, 0)));
1249 src_regno = REGNO (XVECEXP (SET_SRC (XVECEXP (op, 0, 0)), 0, 1));
1251 if (dest_regno != VRSAVE_REGNO || src_regno != VRSAVE_REGNO)
1254 for (i = 1; i < count; i++)
1256 rtx elt = XVECEXP (op, 0, i);
1258 if (GET_CODE (elt) != CLOBBER
1259 && GET_CODE (elt) != SET)
1266 ;; Return 1 if OP is valid for mfcr insn, known to be a PARALLEL.
1267 (define_predicate "mfcr_operation"
1268 (match_code "parallel")
1270 int count = XVECLEN (op, 0);
1273 /* Perform a quick check so we don't blow up below. */
1275 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1276 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != UNSPEC
1277 || XVECLEN (SET_SRC (XVECEXP (op, 0, 0)), 0) != 2)
1280 for (i = 0; i < count; i++)
1282 rtx exp = XVECEXP (op, 0, i);
1287 src_reg = XVECEXP (SET_SRC (exp), 0, 0);
1289 if (GET_CODE (src_reg) != REG
1290 || GET_MODE (src_reg) != CCmode
1291 || ! CR_REGNO_P (REGNO (src_reg)))
1294 if (GET_CODE (exp) != SET
1295 || GET_CODE (SET_DEST (exp)) != REG
1296 || GET_MODE (SET_DEST (exp)) != SImode
1297 || ! INT_REGNO_P (REGNO (SET_DEST (exp))))
1299 unspec = SET_SRC (exp);
1300 maskval = 1 << (MAX_CR_REGNO - REGNO (src_reg));
1302 if (GET_CODE (unspec) != UNSPEC
1303 || XINT (unspec, 1) != UNSPEC_MOVESI_FROM_CR
1304 || XVECLEN (unspec, 0) != 2
1305 || XVECEXP (unspec, 0, 0) != src_reg
1306 || GET_CODE (XVECEXP (unspec, 0, 1)) != CONST_INT
1307 || INTVAL (XVECEXP (unspec, 0, 1)) != maskval)
1313 ;; Return 1 if OP is valid for mtcrf insn, known to be a PARALLEL.
1314 (define_predicate "mtcrf_operation"
1315 (match_code "parallel")
1317 int count = XVECLEN (op, 0);
1321 /* Perform a quick check so we don't blow up below. */
1323 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1324 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != UNSPEC
1325 || XVECLEN (SET_SRC (XVECEXP (op, 0, 0)), 0) != 2)
1327 src_reg = XVECEXP (SET_SRC (XVECEXP (op, 0, 0)), 0, 0);
1329 if (GET_CODE (src_reg) != REG
1330 || GET_MODE (src_reg) != SImode
1331 || ! INT_REGNO_P (REGNO (src_reg)))
1334 for (i = 0; i < count; i++)
1336 rtx exp = XVECEXP (op, 0, i);
1340 if (GET_CODE (exp) != SET
1341 || GET_CODE (SET_DEST (exp)) != REG
1342 || GET_MODE (SET_DEST (exp)) != CCmode
1343 || ! CR_REGNO_P (REGNO (SET_DEST (exp))))
1345 unspec = SET_SRC (exp);
1346 maskval = 1 << (MAX_CR_REGNO - REGNO (SET_DEST (exp)));
1348 if (GET_CODE (unspec) != UNSPEC
1349 || XINT (unspec, 1) != UNSPEC_MOVESI_TO_CR
1350 || XVECLEN (unspec, 0) != 2
1351 || XVECEXP (unspec, 0, 0) != src_reg
1352 || GET_CODE (XVECEXP (unspec, 0, 1)) != CONST_INT
1353 || INTVAL (XVECEXP (unspec, 0, 1)) != maskval)
1359 ;; Return 1 if OP is valid for lmw insn, known to be a PARALLEL.
1360 (define_predicate "lmw_operation"
1361 (match_code "parallel")
1363 int count = XVECLEN (op, 0);
1364 unsigned int dest_regno;
1366 unsigned int base_regno;
1367 HOST_WIDE_INT offset;
1370 /* Perform a quick check so we don't blow up below. */
1372 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1373 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != REG
1374 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != MEM)
1377 dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, 0)));
1378 src_addr = XEXP (SET_SRC (XVECEXP (op, 0, 0)), 0);
1381 || count != 32 - (int) dest_regno)
1384 if (legitimate_indirect_address_p (src_addr, 0))
1387 base_regno = REGNO (src_addr);
1388 if (base_regno == 0)
1391 else if (rs6000_legitimate_offset_address_p (SImode, src_addr, false, false))
1393 offset = INTVAL (XEXP (src_addr, 1));
1394 base_regno = REGNO (XEXP (src_addr, 0));
1399 for (i = 0; i < count; i++)
1401 rtx elt = XVECEXP (op, 0, i);
1404 HOST_WIDE_INT newoffset;
1406 if (GET_CODE (elt) != SET
1407 || GET_CODE (SET_DEST (elt)) != REG
1408 || GET_MODE (SET_DEST (elt)) != SImode
1409 || REGNO (SET_DEST (elt)) != dest_regno + i
1410 || GET_CODE (SET_SRC (elt)) != MEM
1411 || GET_MODE (SET_SRC (elt)) != SImode)
1413 newaddr = XEXP (SET_SRC (elt), 0);
1414 if (legitimate_indirect_address_p (newaddr, 0))
1419 else if (rs6000_legitimate_offset_address_p (SImode, newaddr, false, false))
1421 addr_reg = XEXP (newaddr, 0);
1422 newoffset = INTVAL (XEXP (newaddr, 1));
1426 if (REGNO (addr_reg) != base_regno
1427 || newoffset != offset + 4 * i)
1434 ;; Return 1 if OP is valid for stmw insn, known to be a PARALLEL.
1435 (define_predicate "stmw_operation"
1436 (match_code "parallel")
1438 int count = XVECLEN (op, 0);
1439 unsigned int src_regno;
1441 unsigned int base_regno;
1442 HOST_WIDE_INT offset;
1445 /* Perform a quick check so we don't blow up below. */
1447 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1448 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != MEM
1449 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != REG)
1452 src_regno = REGNO (SET_SRC (XVECEXP (op, 0, 0)));
1453 dest_addr = XEXP (SET_DEST (XVECEXP (op, 0, 0)), 0);
1456 || count != 32 - (int) src_regno)
1459 if (legitimate_indirect_address_p (dest_addr, 0))
1462 base_regno = REGNO (dest_addr);
1463 if (base_regno == 0)
1466 else if (rs6000_legitimate_offset_address_p (SImode, dest_addr, false, false))
1468 offset = INTVAL (XEXP (dest_addr, 1));
1469 base_regno = REGNO (XEXP (dest_addr, 0));
1474 for (i = 0; i < count; i++)
1476 rtx elt = XVECEXP (op, 0, i);
1479 HOST_WIDE_INT newoffset;
1481 if (GET_CODE (elt) != SET
1482 || GET_CODE (SET_SRC (elt)) != REG
1483 || GET_MODE (SET_SRC (elt)) != SImode
1484 || REGNO (SET_SRC (elt)) != src_regno + i
1485 || GET_CODE (SET_DEST (elt)) != MEM
1486 || GET_MODE (SET_DEST (elt)) != SImode)
1488 newaddr = XEXP (SET_DEST (elt), 0);
1489 if (legitimate_indirect_address_p (newaddr, 0))
1494 else if (rs6000_legitimate_offset_address_p (SImode, newaddr, false, false))
1496 addr_reg = XEXP (newaddr, 0);
1497 newoffset = INTVAL (XEXP (newaddr, 1));
1501 if (REGNO (addr_reg) != base_regno
1502 || newoffset != offset + 4 * i)
1509 ;; Return 1 if OP is a stack tie operand.
1510 (define_predicate "tie_operand"
1511 (match_code "parallel")
1513 return (GET_CODE (XVECEXP (op, 0, 0)) == SET
1514 && GET_CODE (XEXP (XVECEXP (op, 0, 0), 0)) == MEM
1515 && GET_MODE (XEXP (XVECEXP (op, 0, 0), 0)) == BLKmode
1516 && XEXP (XVECEXP (op, 0, 0), 1) == const0_rtx);
1519 ;; Match a small code model toc reference (or medium and large
1520 ;; model toc references before reload).
1521 (define_predicate "small_toc_ref"
1522 (match_code "unspec,plus")
1524 if (GET_CODE (op) == PLUS && CONST_INT_P (XEXP (op, 1)))
1527 return GET_CODE (op) == UNSPEC && XINT (op, 1) == UNSPEC_TOCREL;