1 ;; Predicate definitions for POWER and PowerPC.
2 ;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
3 ;; Free Software Foundation, Inc.
5 ;; This file is part of GCC.
7 ;; GCC is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 3, or (at your option)
12 ;; GCC is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING3. If not see
19 ;; <http://www.gnu.org/licenses/>.
21 ;; Return 1 for anything except PARALLEL.
22 (define_predicate "any_operand"
23 (match_code "const_int,const_double,const,symbol_ref,label_ref,subreg,reg,mem"))
25 ;; Return 1 for any PARALLEL.
26 (define_predicate "any_parallel_operand"
27 (match_code "parallel"))
29 ;; Return 1 if op is COUNT register.
30 (define_predicate "count_register_operand"
31 (and (match_code "reg")
32 (match_test "REGNO (op) == CTR_REGNO
33 || REGNO (op) > LAST_VIRTUAL_REGISTER")))
35 ;; Return 1 if op is an Altivec register.
36 (define_predicate "altivec_register_operand"
37 (and (match_operand 0 "register_operand")
38 (match_test "GET_CODE (op) != REG
39 || ALTIVEC_REGNO_P (REGNO (op))
40 || REGNO (op) > LAST_VIRTUAL_REGISTER")))
42 ;; Return 1 if op is a VSX register.
43 (define_predicate "vsx_register_operand"
44 (and (match_operand 0 "register_operand")
45 (match_test "GET_CODE (op) != REG
46 || VSX_REGNO_P (REGNO (op))
47 || REGNO (op) > LAST_VIRTUAL_REGISTER")))
49 ;; Return 1 if op is a vector register that operates on floating point vectors
50 ;; (either altivec or VSX).
51 (define_predicate "vfloat_operand"
52 (and (match_operand 0 "register_operand")
53 (match_test "GET_CODE (op) != REG
54 || VFLOAT_REGNO_P (REGNO (op))
55 || REGNO (op) > LAST_VIRTUAL_REGISTER")))
57 ;; Return 1 if op is a vector register that operates on integer vectors
58 ;; (only altivec, VSX doesn't support integer vectors)
59 (define_predicate "vint_operand"
60 (and (match_operand 0 "register_operand")
61 (match_test "GET_CODE (op) != REG
62 || VINT_REGNO_P (REGNO (op))
63 || REGNO (op) > LAST_VIRTUAL_REGISTER")))
65 ;; Return 1 if op is a vector register to do logical operations on (and, or,
67 (define_predicate "vlogical_operand"
68 (and (match_operand 0 "register_operand")
69 (match_test "GET_CODE (op) != REG
70 || VLOGICAL_REGNO_P (REGNO (op))
71 || REGNO (op) > LAST_VIRTUAL_REGISTER")))
73 ;; Return 1 if op is the carry register.
74 (define_predicate "ca_operand"
75 (and (match_code "reg")
76 (match_test "CA_REGNO_P (REGNO (op))")))
78 ;; Return 1 if op is a signed 5-bit constant integer.
79 (define_predicate "s5bit_cint_operand"
80 (and (match_code "const_int")
81 (match_test "INTVAL (op) >= -16 && INTVAL (op) <= 15")))
83 ;; Return 1 if op is a unsigned 5-bit constant integer.
84 (define_predicate "u5bit_cint_operand"
85 (and (match_code "const_int")
86 (match_test "INTVAL (op) >= 0 && INTVAL (op) <= 31")))
88 ;; Return 1 if op is a signed 8-bit constant integer.
89 ;; Integer multiplication complete more quickly
90 (define_predicate "s8bit_cint_operand"
91 (and (match_code "const_int")
92 (match_test "INTVAL (op) >= -128 && INTVAL (op) <= 127")))
94 ;; Return 1 if op is a constant integer that can fit in a D field.
95 (define_predicate "short_cint_operand"
96 (and (match_code "const_int")
97 (match_test "satisfies_constraint_I (op)")))
99 ;; Return 1 if op is a constant integer that can fit in an unsigned D field.
100 (define_predicate "u_short_cint_operand"
101 (and (match_code "const_int")
102 (match_test "satisfies_constraint_K (op)")))
104 ;; Return 1 if op is a constant integer that cannot fit in a signed D field.
105 (define_predicate "non_short_cint_operand"
106 (and (match_code "const_int")
107 (match_test "(unsigned HOST_WIDE_INT)
108 (INTVAL (op) + 0x8000) >= 0x10000")))
110 ;; Return 1 if op is a positive constant integer that is an exact power of 2.
111 (define_predicate "exact_log2_cint_operand"
112 (and (match_code "const_int")
113 (match_test "INTVAL (op) > 0 && exact_log2 (INTVAL (op)) >= 0")))
115 ;; Return 1 if op is a register that is not special.
116 (define_predicate "gpc_reg_operand"
117 (and (match_operand 0 "register_operand")
118 (match_test "(GET_CODE (op) != REG
119 || (REGNO (op) >= ARG_POINTER_REGNUM
120 && !CA_REGNO_P (REGNO (op)))
121 || REGNO (op) < MQ_REGNO)
122 && !((TARGET_E500_DOUBLE || TARGET_SPE)
123 && invalid_e500_subreg (op, mode))")))
125 ;; Return 1 if op is a register that is a condition register field.
126 (define_predicate "cc_reg_operand"
127 (and (match_operand 0 "register_operand")
128 (match_test "GET_CODE (op) != REG
129 || REGNO (op) > LAST_VIRTUAL_REGISTER
130 || CR_REGNO_P (REGNO (op))")))
132 ;; Return 1 if op is a register that is a condition register field not cr0.
133 (define_predicate "cc_reg_not_cr0_operand"
134 (and (match_operand 0 "register_operand")
135 (match_test "GET_CODE (op) != REG
136 || REGNO (op) > LAST_VIRTUAL_REGISTER
137 || CR_REGNO_NOT_CR0_P (REGNO (op))")))
139 ;; Return 1 if op is a register that is a condition register field and if generating microcode, not cr0.
140 (define_predicate "cc_reg_not_micro_cr0_operand"
141 (and (match_operand 0 "register_operand")
142 (match_test "GET_CODE (op) != REG
143 || REGNO (op) > LAST_VIRTUAL_REGISTER
144 || (rs6000_gen_cell_microcode && CR_REGNO_NOT_CR0_P (REGNO (op)))
145 || (!rs6000_gen_cell_microcode && CR_REGNO_P (REGNO (op)))")))
147 ;; Return 1 if op is a constant integer valid for D field
148 ;; or non-special register register.
149 (define_predicate "reg_or_short_operand"
150 (if_then_else (match_code "const_int")
151 (match_operand 0 "short_cint_operand")
152 (match_operand 0 "gpc_reg_operand")))
154 ;; Return 1 if op is a constant integer valid whose negation is valid for
155 ;; D field or non-special register register.
156 ;; Do not allow a constant zero because all patterns that call this
157 ;; predicate use "addic r1,r2,-const" to set carry when r2 is greater than
158 ;; or equal to const, which does not work for zero.
159 (define_predicate "reg_or_neg_short_operand"
160 (if_then_else (match_code "const_int")
161 (match_test "satisfies_constraint_P (op)
162 && INTVAL (op) != 0")
163 (match_operand 0 "gpc_reg_operand")))
165 ;; Return 1 if op is a constant integer valid for DS field
166 ;; or non-special register.
167 (define_predicate "reg_or_aligned_short_operand"
168 (if_then_else (match_code "const_int")
169 (and (match_operand 0 "short_cint_operand")
170 (match_test "!(INTVAL (op) & 3)"))
171 (match_operand 0 "gpc_reg_operand")))
173 ;; Return 1 if op is a constant integer whose high-order 16 bits are zero
174 ;; or non-special register.
175 (define_predicate "reg_or_u_short_operand"
176 (if_then_else (match_code "const_int")
177 (match_operand 0 "u_short_cint_operand")
178 (match_operand 0 "gpc_reg_operand")))
180 ;; Return 1 if op is any constant integer
181 ;; or non-special register.
182 (define_predicate "reg_or_cint_operand"
183 (ior (match_code "const_int")
184 (match_operand 0 "gpc_reg_operand")))
186 ;; Return 1 if op is a constant integer valid for addition
187 ;; or non-special register.
188 (define_predicate "reg_or_add_cint_operand"
189 (if_then_else (match_code "const_int")
190 (match_test "(HOST_BITS_PER_WIDE_INT == 32
191 && (mode == SImode || INTVAL (op) < 0x7fff8000))
192 || ((unsigned HOST_WIDE_INT) (INTVAL (op) + 0x80008000)
193 < (unsigned HOST_WIDE_INT) 0x100000000ll)")
194 (match_operand 0 "gpc_reg_operand")))
196 ;; Return 1 if op is a constant integer valid for subtraction
197 ;; or non-special register.
198 (define_predicate "reg_or_sub_cint_operand"
199 (if_then_else (match_code "const_int")
200 (match_test "(HOST_BITS_PER_WIDE_INT == 32
201 && (mode == SImode || - INTVAL (op) < 0x7fff8000))
202 || ((unsigned HOST_WIDE_INT) (- INTVAL (op)
204 ? 0x80000000 : 0x80008000))
205 < (unsigned HOST_WIDE_INT) 0x100000000ll)")
206 (match_operand 0 "gpc_reg_operand")))
208 ;; Return 1 if op is any 32-bit unsigned constant integer
209 ;; or non-special register.
210 (define_predicate "reg_or_logical_cint_operand"
211 (if_then_else (match_code "const_int")
212 (match_test "(GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT
214 || ((INTVAL (op) & GET_MODE_MASK (mode)
215 & (~ (unsigned HOST_WIDE_INT) 0xffffffff)) == 0)")
216 (if_then_else (match_code "const_double")
217 (match_test "GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT
219 && CONST_DOUBLE_HIGH (op) == 0")
220 (match_operand 0 "gpc_reg_operand"))))
222 ;; Return 1 if operand is a CONST_DOUBLE that can be set in a register
223 ;; with no more than one instruction per word.
224 (define_predicate "easy_fp_constant"
225 (match_code "const_double")
230 if (GET_MODE (op) != mode
231 || (!SCALAR_FLOAT_MODE_P (mode) && mode != DImode))
234 /* Consider all constants with -msoft-float to be easy. */
235 if ((TARGET_SOFT_FLOAT || TARGET_E500_SINGLE
236 || (TARGET_HARD_FLOAT && (TARGET_SINGLE_FLOAT && ! TARGET_DOUBLE_FLOAT)))
240 if (DECIMAL_FLOAT_MODE_P (mode))
243 /* If we are using V.4 style PIC, consider all constants to be hard. */
244 if (flag_pic && DEFAULT_ABI == ABI_V4)
247 #ifdef TARGET_RELOCATABLE
248 /* Similarly if we are using -mrelocatable, consider all constants
250 if (TARGET_RELOCATABLE)
257 if (TARGET_E500_DOUBLE)
260 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
261 REAL_VALUE_TO_TARGET_LONG_DOUBLE (rv, k);
263 return (num_insns_constant_wide ((HOST_WIDE_INT) k[0]) == 1
264 && num_insns_constant_wide ((HOST_WIDE_INT) k[1]) == 1
265 && num_insns_constant_wide ((HOST_WIDE_INT) k[2]) == 1
266 && num_insns_constant_wide ((HOST_WIDE_INT) k[3]) == 1);
269 /* The constant 0.f is easy under VSX. */
270 if (op == CONST0_RTX (DFmode) && VECTOR_UNIT_VSX_P (DFmode))
273 /* Force constants to memory before reload to utilize
274 compress_float_constant.
275 Avoid this when flag_unsafe_math_optimizations is enabled
276 because RDIV division to reciprocal optimization is not able
277 to regenerate the division. */
278 if (TARGET_E500_DOUBLE
279 || (!reload_in_progress && !reload_completed
280 && !flag_unsafe_math_optimizations))
283 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
284 REAL_VALUE_TO_TARGET_DOUBLE (rv, k);
286 return (num_insns_constant_wide ((HOST_WIDE_INT) k[0]) == 1
287 && num_insns_constant_wide ((HOST_WIDE_INT) k[1]) == 1);
290 /* The constant 0.f is easy. */
291 if (op == CONST0_RTX (SFmode))
294 /* Force constants to memory before reload to utilize
295 compress_float_constant.
296 Avoid this when flag_unsafe_math_optimizations is enabled
297 because RDIV division to reciprocal optimization is not able
298 to regenerate the division. */
299 if (!reload_in_progress && !reload_completed
300 && !flag_unsafe_math_optimizations)
303 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
304 REAL_VALUE_TO_TARGET_SINGLE (rv, k[0]);
306 return num_insns_constant_wide (k[0]) == 1;
309 return ((TARGET_POWERPC64
310 && GET_CODE (op) == CONST_DOUBLE && CONST_DOUBLE_LOW (op) == 0)
311 || (num_insns_constant (op, DImode) <= 2));
321 ;; Return 1 if the operand is a CONST_VECTOR and can be loaded into a
322 ;; vector register without using memory.
323 (define_predicate "easy_vector_constant"
324 (match_code "const_vector")
326 /* As the paired vectors are actually FPRs it seems that there is
327 no easy way to load a CONST_VECTOR without using memory. */
328 if (TARGET_PAIRED_FLOAT)
331 if (VECTOR_MEM_ALTIVEC_OR_VSX_P (mode))
333 if (zero_constant (op, mode))
336 return easy_altivec_constant (op, mode);
339 if (SPE_VECTOR_MODE (mode))
342 if (zero_constant (op, mode))
344 if (GET_MODE_CLASS (mode) != MODE_VECTOR_INT)
347 /* Limit SPE vectors to 15 bits signed. These we can generate with:
352 I don't know how efficient it would be to allow bigger constants,
353 considering we'll have an extra 'ori' for every 'li'. I doubt 5
354 instructions is better than a 64-bit memory load, but I don't
355 have the e500 timing specs. */
356 if (mode == V2SImode)
358 cst = INTVAL (CONST_VECTOR_ELT (op, 0));
359 cst2 = INTVAL (CONST_VECTOR_ELT (op, 1));
360 return cst >= -0x7fff && cst <= 0x7fff
361 && cst2 >= -0x7fff && cst2 <= 0x7fff;
368 ;; Same as easy_vector_constant but only for EASY_VECTOR_15_ADD_SELF.
369 (define_predicate "easy_vector_constant_add_self"
370 (and (match_code "const_vector")
371 (and (match_test "TARGET_ALTIVEC")
372 (match_test "easy_altivec_constant (op, mode)")))
375 if (mode == V2DImode || mode == V2DFmode)
377 val = const_vector_elt_as_int (op, GET_MODE_NUNITS (mode) - 1);
378 val = ((val & 0xff) ^ 0x80) - 0x80;
379 return EASY_VECTOR_15_ADD_SELF (val);
382 ;; Same as easy_vector_constant but only for EASY_VECTOR_MSB.
383 (define_predicate "easy_vector_constant_msb"
384 (and (match_code "const_vector")
385 (and (match_test "TARGET_ALTIVEC")
386 (match_test "easy_altivec_constant (op, mode)")))
389 if (mode == V2DImode || mode == V2DFmode)
391 val = const_vector_elt_as_int (op, GET_MODE_NUNITS (mode) - 1);
392 return EASY_VECTOR_MSB (val, GET_MODE_INNER (mode));
395 ;; Return 1 if operand is constant zero (scalars and vectors).
396 (define_predicate "zero_constant"
397 (and (match_code "const_int,const_double,const_vector")
398 (match_test "op == CONST0_RTX (mode)")))
400 ;; Return 1 if operand is 0.0.
401 ;; or non-special register register field no cr0
402 (define_predicate "zero_fp_constant"
403 (and (match_code "const_double")
404 (match_test "SCALAR_FLOAT_MODE_P (mode)
405 && op == CONST0_RTX (mode)")))
407 ;; Return 1 if the operand is in volatile memory. Note that during the
408 ;; RTL generation phase, memory_operand does not return TRUE for volatile
409 ;; memory references. So this function allows us to recognize volatile
410 ;; references where it's safe.
411 (define_predicate "volatile_mem_operand"
412 (and (and (match_code "mem")
413 (match_test "MEM_VOLATILE_P (op)"))
414 (if_then_else (match_test "reload_completed")
415 (match_operand 0 "memory_operand")
416 (if_then_else (match_test "reload_in_progress")
417 (match_test "strict_memory_address_p (mode, XEXP (op, 0))")
418 (match_test "memory_address_p (mode, XEXP (op, 0))")))))
420 ;; Return 1 if the operand is an offsettable memory operand.
421 (define_predicate "offsettable_mem_operand"
422 (and (match_operand 0 "memory_operand")
423 (match_test "offsettable_nonstrict_memref_p (op)")))
425 ;; Return 1 if the operand is a memory operand with an address divisible by 4
426 (define_predicate "word_offset_memref_operand"
427 (match_operand 0 "memory_operand")
429 /* Address inside MEM. */
432 /* Extract address from auto-inc/dec. */
433 if (GET_CODE (op) == PRE_INC
434 || GET_CODE (op) == PRE_DEC)
436 else if (GET_CODE (op) == PRE_MODIFY)
438 else if (GET_CODE (op) == LO_SUM
439 && GET_CODE (XEXP (op, 0)) == REG
440 && GET_CODE (XEXP (op, 1)) == CONST)
441 op = XEXP (XEXP (op, 1), 0);
443 return (GET_CODE (op) != PLUS
444 || GET_CODE (XEXP (op, 1)) != CONST_INT
445 || INTVAL (XEXP (op, 1)) % 4 == 0);
448 ;; Return 1 if the operand is an indexed or indirect memory operand.
449 (define_predicate "indexed_or_indirect_operand"
453 if (VECTOR_MEM_ALTIVEC_P (mode)
454 && GET_CODE (op) == AND
455 && GET_CODE (XEXP (op, 1)) == CONST_INT
456 && INTVAL (XEXP (op, 1)) == -16)
459 return indexed_or_indirect_address (op, mode);
462 ;; Return 1 if the operand is an indexed or indirect memory operand with an
463 ;; AND -16 in it, used to recognize when we need to switch to Altivec loads
464 ;; to realign loops instead of VSX (altivec silently ignores the bottom bits,
465 ;; while VSX uses the full address and traps)
466 (define_predicate "altivec_indexed_or_indirect_operand"
470 if (VECTOR_MEM_ALTIVEC_OR_VSX_P (mode)
471 && GET_CODE (op) == AND
472 && GET_CODE (XEXP (op, 1)) == CONST_INT
473 && INTVAL (XEXP (op, 1)) == -16)
474 return indexed_or_indirect_address (XEXP (op, 0), mode);
479 ;; Return 1 if the operand is an indexed or indirect address.
480 (define_special_predicate "indexed_or_indirect_address"
481 (and (match_test "REG_P (op)
482 || (GET_CODE (op) == PLUS
483 /* Omit testing REG_P (XEXP (op, 0)). */
484 && REG_P (XEXP (op, 1)))")
485 (match_operand 0 "address_operand")))
487 ;; Used for the destination of the fix_truncdfsi2 expander.
488 ;; If stfiwx will be used, the result goes to memory; otherwise,
489 ;; we're going to emit a store and a load of a subreg, so the dest is a
491 (define_predicate "fix_trunc_dest_operand"
492 (if_then_else (match_test "! TARGET_E500_DOUBLE && TARGET_PPC_GFXOPT")
493 (match_operand 0 "memory_operand")
494 (match_operand 0 "gpc_reg_operand")))
496 ;; Return 1 if the operand is either a non-special register or can be used
497 ;; as the operand of a `mode' add insn.
498 (define_predicate "add_operand"
499 (if_then_else (match_code "const_int")
500 (match_test "satisfies_constraint_I (op)
501 || satisfies_constraint_L (op)")
502 (match_operand 0 "gpc_reg_operand")))
504 ;; Return 1 if OP is a constant but not a valid add_operand.
505 (define_predicate "non_add_cint_operand"
506 (and (match_code "const_int")
507 (match_test "!satisfies_constraint_I (op)
508 && !satisfies_constraint_L (op)")))
510 ;; Return 1 if the operand is a constant that can be used as the operand
512 (define_predicate "logical_const_operand"
513 (match_code "const_int,const_double")
515 HOST_WIDE_INT opl, oph;
517 if (GET_CODE (op) == CONST_INT)
519 opl = INTVAL (op) & GET_MODE_MASK (mode);
521 if (HOST_BITS_PER_WIDE_INT <= 32
522 && GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT && opl < 0)
525 else if (GET_CODE (op) == CONST_DOUBLE)
527 gcc_assert (GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT);
529 opl = CONST_DOUBLE_LOW (op);
530 oph = CONST_DOUBLE_HIGH (op);
537 return ((opl & ~ (unsigned HOST_WIDE_INT) 0xffff) == 0
538 || (opl & ~ (unsigned HOST_WIDE_INT) 0xffff0000) == 0);
541 ;; Return 1 if the operand is a non-special register or a constant that
542 ;; can be used as the operand of an OR or XOR.
543 (define_predicate "logical_operand"
544 (ior (match_operand 0 "gpc_reg_operand")
545 (match_operand 0 "logical_const_operand")))
547 ;; Return 1 if op is a constant that is not a logical operand, but could
548 ;; be split into one.
549 (define_predicate "non_logical_cint_operand"
550 (and (match_code "const_int,const_double")
551 (and (not (match_operand 0 "logical_operand"))
552 (match_operand 0 "reg_or_logical_cint_operand"))))
554 ;; Return 1 if op is a constant that can be encoded in a 32-bit mask,
555 ;; suitable for use with rlwinm (no more than two 1->0 or 0->1
556 ;; transitions). Reject all ones and all zeros, since these should have
557 ;; been optimized away and confuse the making of MB and ME.
558 (define_predicate "mask_operand"
559 (match_code "const_int")
561 HOST_WIDE_INT c, lsb;
565 if (TARGET_POWERPC64)
567 /* Fail if the mask is not 32-bit. */
568 if (mode == DImode && (c & ~(unsigned HOST_WIDE_INT) 0xffffffff) != 0)
571 /* Fail if the mask wraps around because the upper 32-bits of the
572 mask will all be 1s, contrary to GCC's internal view. */
573 if ((c & 0x80000001) == 0x80000001)
577 /* We don't change the number of transitions by inverting,
578 so make sure we start with the LS bit zero. */
582 /* Reject all zeros or all ones. */
586 /* Find the first transition. */
589 /* Invert to look for a second transition. */
592 /* Erase first transition. */
595 /* Find the second transition (if any). */
598 /* Match if all the bits above are 1's (or c is zero). */
602 ;; Return 1 for the PowerPC64 rlwinm corner case.
603 (define_predicate "mask_operand_wrap"
604 (match_code "const_int")
606 HOST_WIDE_INT c, lsb;
610 if ((c & 0x80000001) != 0x80000001)
624 ;; Return 1 if the operand is a constant that is a PowerPC64 mask
625 ;; suitable for use with rldicl or rldicr (no more than one 1->0 or 0->1
626 ;; transition). Reject all zeros, since zero should have been
627 ;; optimized away and confuses the making of MB and ME.
628 (define_predicate "mask64_operand"
629 (match_code "const_int")
631 HOST_WIDE_INT c, lsb;
635 /* Reject all zeros. */
639 /* We don't change the number of transitions by inverting,
640 so make sure we start with the LS bit zero. */
644 /* Find the first transition. */
647 /* Match if all the bits above are 1's (or c is zero). */
651 ;; Like mask64_operand, but allow up to three transitions. This
652 ;; predicate is used by insn patterns that generate two rldicl or
653 ;; rldicr machine insns.
654 (define_predicate "mask64_2_operand"
655 (match_code "const_int")
657 HOST_WIDE_INT c, lsb;
661 /* Disallow all zeros. */
665 /* We don't change the number of transitions by inverting,
666 so make sure we start with the LS bit zero. */
670 /* Find the first transition. */
673 /* Invert to look for a second transition. */
676 /* Erase first transition. */
679 /* Find the second transition. */
682 /* Invert to look for a third transition. */
685 /* Erase second transition. */
688 /* Find the third transition (if any). */
691 /* Match if all the bits above are 1's (or c is zero). */
695 ;; Like and_operand, but also match constants that can be implemented
696 ;; with two rldicl or rldicr insns.
697 (define_predicate "and64_2_operand"
698 (ior (match_operand 0 "mask64_2_operand")
699 (if_then_else (match_test "fixed_regs[CR0_REGNO]")
700 (match_operand 0 "gpc_reg_operand")
701 (match_operand 0 "logical_operand"))))
703 ;; Return 1 if the operand is either a non-special register or a
704 ;; constant that can be used as the operand of a logical AND.
705 (define_predicate "and_operand"
706 (ior (match_operand 0 "mask_operand")
707 (ior (and (match_test "TARGET_POWERPC64 && mode == DImode")
708 (match_operand 0 "mask64_operand"))
709 (if_then_else (match_test "fixed_regs[CR0_REGNO]")
710 (match_operand 0 "gpc_reg_operand")
711 (match_operand 0 "logical_operand")))))
713 ;; Return 1 if the operand is either a logical operand or a short cint operand.
714 (define_predicate "scc_eq_operand"
715 (ior (match_operand 0 "logical_operand")
716 (match_operand 0 "short_cint_operand")))
718 ;; Return 1 if the operand is a general non-special register or memory operand.
719 (define_predicate "reg_or_mem_operand"
720 (ior (match_operand 0 "memory_operand")
721 (ior (and (match_code "mem")
722 (match_test "macho_lo_sum_memory_operand (op, mode)"))
723 (ior (match_operand 0 "volatile_mem_operand")
724 (match_operand 0 "gpc_reg_operand")))))
726 ;; Return 1 if the operand is either an easy FP constant or memory or reg.
727 (define_predicate "reg_or_none500mem_operand"
728 (if_then_else (match_code "mem")
729 (and (match_test "!TARGET_E500_DOUBLE")
730 (ior (match_operand 0 "memory_operand")
731 (ior (match_test "macho_lo_sum_memory_operand (op, mode)")
732 (match_operand 0 "volatile_mem_operand"))))
733 (match_operand 0 "gpc_reg_operand")))
735 ;; Return 1 if the operand is CONST_DOUBLE 0, register or memory operand.
736 (define_predicate "zero_reg_mem_operand"
737 (ior (match_operand 0 "zero_fp_constant")
738 (match_operand 0 "reg_or_mem_operand")))
740 ;; Return 1 if the operand is a general register or memory operand without
741 ;; pre_inc or pre_dec or pre_modify, which produces invalid form of PowerPC
743 (define_predicate "lwa_operand"
744 (match_code "reg,subreg,mem")
746 rtx inner, addr, offset;
749 if (reload_completed && GET_CODE (inner) == SUBREG)
750 inner = SUBREG_REG (inner);
752 if (gpc_reg_operand (inner, mode))
754 if (!memory_operand (inner, mode))
756 addr = XEXP (inner, 0);
757 if (GET_CODE (addr) == PRE_INC
758 || GET_CODE (addr) == PRE_DEC
759 || (GET_CODE (addr) == PRE_MODIFY
760 && !legitimate_indexed_address_p (XEXP (addr, 1), 0)))
762 if (GET_CODE (addr) == LO_SUM
763 && GET_CODE (XEXP (addr, 0)) == REG
764 && GET_CODE (XEXP (addr, 1)) == CONST)
765 addr = XEXP (XEXP (addr, 1), 0);
766 if (GET_CODE (addr) != PLUS)
768 offset = XEXP (addr, 1);
769 if (GET_CODE (offset) != CONST_INT)
771 return INTVAL (offset) % 4 == 0;
774 ;; Return 1 if the operand, used inside a MEM, is a SYMBOL_REF.
775 (define_predicate "symbol_ref_operand"
776 (and (match_code "symbol_ref")
777 (match_test "(mode == VOIDmode || GET_MODE (op) == mode)
778 && (DEFAULT_ABI != ABI_AIX || SYMBOL_REF_FUNCTION_P (op))")))
780 ;; Return 1 if op is an operand that can be loaded via the GOT.
781 ;; or non-special register register field no cr0
782 (define_predicate "got_operand"
783 (match_code "symbol_ref,const,label_ref"))
785 ;; Return 1 if op is a simple reference that can be loaded via the GOT,
786 ;; excluding labels involving addition.
787 (define_predicate "got_no_const_operand"
788 (match_code "symbol_ref,label_ref"))
790 ;; Return 1 if op is a SYMBOL_REF for a TLS symbol.
791 (define_predicate "rs6000_tls_symbol_ref"
792 (and (match_code "symbol_ref")
793 (match_test "RS6000_SYMBOL_REF_TLS_P (op)")))
795 ;; Return 1 if the operand, used inside a MEM, is a valid first argument
796 ;; to CALL. This is a SYMBOL_REF, a pseudo-register, LR or CTR.
797 (define_predicate "call_operand"
798 (if_then_else (match_code "reg")
799 (match_test "REGNO (op) == LR_REGNO
800 || REGNO (op) == CTR_REGNO
801 || REGNO (op) >= FIRST_PSEUDO_REGISTER")
802 (match_code "symbol_ref")))
804 ;; Return 1 if the operand is a SYMBOL_REF for a function known to be in
806 (define_predicate "current_file_function_operand"
807 (and (match_code "symbol_ref")
808 (match_test "(DEFAULT_ABI != ABI_AIX || SYMBOL_REF_FUNCTION_P (op))
809 && ((SYMBOL_REF_LOCAL_P (op)
810 && (DEFAULT_ABI != ABI_AIX
811 || !SYMBOL_REF_EXTERNAL_P (op)))
812 || (op == XEXP (DECL_RTL (current_function_decl),
815 ;; Return 1 if this operand is a valid input for a move insn.
816 (define_predicate "input_operand"
817 (match_code "label_ref,symbol_ref,const,high,reg,subreg,mem,
818 const_double,const_vector,const_int,plus")
820 /* Memory is always valid. */
821 if (memory_operand (op, mode))
824 /* For floating-point, easy constants are valid. */
825 if (SCALAR_FLOAT_MODE_P (mode)
827 && easy_fp_constant (op, mode))
830 /* Allow any integer constant. */
831 if (GET_MODE_CLASS (mode) == MODE_INT
832 && (GET_CODE (op) == CONST_INT
833 || GET_CODE (op) == CONST_DOUBLE))
836 /* Allow easy vector constants. */
837 if (GET_CODE (op) == CONST_VECTOR
838 && easy_vector_constant (op, mode))
841 /* Do not allow invalid E500 subregs. */
842 if ((TARGET_E500_DOUBLE || TARGET_SPE)
843 && GET_CODE (op) == SUBREG
844 && invalid_e500_subreg (op, mode))
847 /* For floating-point or multi-word mode, the only remaining valid type
849 if (SCALAR_FLOAT_MODE_P (mode)
850 || GET_MODE_SIZE (mode) > UNITS_PER_WORD)
851 return register_operand (op, mode);
853 /* The only cases left are integral modes one word or smaller (we
854 do not get called for MODE_CC values). These can be in any
856 if (register_operand (op, mode))
859 /* A SYMBOL_REF referring to the TOC is valid. */
860 if (legitimate_constant_pool_address_p (op, mode, false))
863 /* A constant pool expression (relative to the TOC) is valid */
864 if (toc_relative_expr_p (op))
867 /* V.4 allows SYMBOL_REFs and CONSTs that are in the small data region
869 if (DEFAULT_ABI == ABI_V4
870 && (GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == CONST)
871 && small_data_operand (op, Pmode))
877 ;; Return 1 if this operand is a valid input for a vsx_splat insn.
878 (define_predicate "splat_input_operand"
879 (match_code "label_ref,symbol_ref,const,high,reg,subreg,mem,
880 const_double,const_vector,const_int,plus")
886 else if (mode == DImode)
891 return input_operand (op, mode);
894 ;; Return true if OP is an invalid SUBREG operation on the e500.
895 (define_predicate "rs6000_nonimmediate_operand"
896 (match_code "reg,subreg,mem")
898 if ((TARGET_E500_DOUBLE || TARGET_SPE)
899 && GET_CODE (op) == SUBREG
900 && invalid_e500_subreg (op, mode))
903 return nonimmediate_operand (op, mode);
906 ;; Return true if operand is boolean operator.
907 (define_predicate "boolean_operator"
908 (match_code "and,ior,xor"))
910 ;; Return true if operand is OR-form of boolean operator.
911 (define_predicate "boolean_or_operator"
912 (match_code "ior,xor"))
914 ;; Return true if operand is an equality operator.
915 (define_special_predicate "equality_operator"
916 (match_code "eq,ne"))
918 ;; Return true if operand is MIN or MAX operator.
919 (define_predicate "min_max_operator"
920 (match_code "smin,smax,umin,umax"))
922 ;; Return 1 if OP is a comparison operation that is valid for a branch
923 ;; instruction. We check the opcode against the mode of the CC value.
924 ;; validate_condition_mode is an assertion.
925 (define_predicate "branch_comparison_operator"
926 (and (match_operand 0 "comparison_operator")
927 (and (match_test "GET_MODE_CLASS (GET_MODE (XEXP (op, 0))) == MODE_CC")
928 (match_test "validate_condition_mode (GET_CODE (op),
929 GET_MODE (XEXP (op, 0))),
932 (define_predicate "rs6000_cbranch_operator"
933 (if_then_else (match_test "TARGET_HARD_FLOAT && !TARGET_FPRS")
934 (match_operand 0 "ordered_comparison_operator")
935 (match_operand 0 "comparison_operator")))
937 ;; Return 1 if OP is a comparison operation that is valid for an SCC insn --
938 ;; it must be a positive comparison.
939 (define_predicate "scc_comparison_operator"
940 (and (match_operand 0 "branch_comparison_operator")
941 (match_code "eq,lt,gt,ltu,gtu,unordered")))
943 ;; Return 1 if OP is a comparison operation whose inverse would be valid for
945 (define_predicate "scc_rev_comparison_operator"
946 (and (match_operand 0 "branch_comparison_operator")
947 (match_code "ne,le,ge,leu,geu,ordered")))
949 ;; Return 1 if OP is a comparison operation that is valid for a branch
950 ;; insn, which is true if the corresponding bit in the CC register is set.
951 (define_predicate "branch_positive_comparison_operator"
952 (and (match_operand 0 "branch_comparison_operator")
953 (match_code "eq,lt,gt,ltu,gtu,unordered")))
955 ;; Return 1 if OP is a load multiple operation, known to be a PARALLEL.
956 (define_predicate "load_multiple_operation"
957 (match_code "parallel")
959 int count = XVECLEN (op, 0);
960 unsigned int dest_regno;
964 /* Perform a quick check so we don't blow up below. */
966 || GET_CODE (XVECEXP (op, 0, 0)) != SET
967 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != REG
968 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != MEM)
971 dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, 0)));
972 src_addr = XEXP (SET_SRC (XVECEXP (op, 0, 0)), 0);
974 for (i = 1; i < count; i++)
976 rtx elt = XVECEXP (op, 0, i);
978 if (GET_CODE (elt) != SET
979 || GET_CODE (SET_DEST (elt)) != REG
980 || GET_MODE (SET_DEST (elt)) != SImode
981 || REGNO (SET_DEST (elt)) != dest_regno + i
982 || GET_CODE (SET_SRC (elt)) != MEM
983 || GET_MODE (SET_SRC (elt)) != SImode
984 || GET_CODE (XEXP (SET_SRC (elt), 0)) != PLUS
985 || ! rtx_equal_p (XEXP (XEXP (SET_SRC (elt), 0), 0), src_addr)
986 || GET_CODE (XEXP (XEXP (SET_SRC (elt), 0), 1)) != CONST_INT
987 || INTVAL (XEXP (XEXP (SET_SRC (elt), 0), 1)) != i * 4)
994 ;; Return 1 if OP is a store multiple operation, known to be a PARALLEL.
995 ;; The second vector element is a CLOBBER.
996 (define_predicate "store_multiple_operation"
997 (match_code "parallel")
999 int count = XVECLEN (op, 0) - 1;
1000 unsigned int src_regno;
1004 /* Perform a quick check so we don't blow up below. */
1006 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1007 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != MEM
1008 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != REG)
1011 src_regno = REGNO (SET_SRC (XVECEXP (op, 0, 0)));
1012 dest_addr = XEXP (SET_DEST (XVECEXP (op, 0, 0)), 0);
1014 for (i = 1; i < count; i++)
1016 rtx elt = XVECEXP (op, 0, i + 1);
1018 if (GET_CODE (elt) != SET
1019 || GET_CODE (SET_SRC (elt)) != REG
1020 || GET_MODE (SET_SRC (elt)) != SImode
1021 || REGNO (SET_SRC (elt)) != src_regno + i
1022 || GET_CODE (SET_DEST (elt)) != MEM
1023 || GET_MODE (SET_DEST (elt)) != SImode
1024 || GET_CODE (XEXP (SET_DEST (elt), 0)) != PLUS
1025 || ! rtx_equal_p (XEXP (XEXP (SET_DEST (elt), 0), 0), dest_addr)
1026 || GET_CODE (XEXP (XEXP (SET_DEST (elt), 0), 1)) != CONST_INT
1027 || INTVAL (XEXP (XEXP (SET_DEST (elt), 0), 1)) != i * 4)
1034 ;; Return 1 if OP is valid for a save_world call in prologue, known to be
1036 (define_predicate "save_world_operation"
1037 (match_code "parallel")
1042 int count = XVECLEN (op, 0);
1048 if (GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
1049 || GET_CODE (XVECEXP (op, 0, index++)) != USE)
1052 for (i=1; i <= 18; i++)
1054 elt = XVECEXP (op, 0, index++);
1055 if (GET_CODE (elt) != SET
1056 || GET_CODE (SET_DEST (elt)) != MEM
1057 || ! memory_operand (SET_DEST (elt), DFmode)
1058 || GET_CODE (SET_SRC (elt)) != REG
1059 || GET_MODE (SET_SRC (elt)) != DFmode)
1063 for (i=1; i <= 12; i++)
1065 elt = XVECEXP (op, 0, index++);
1066 if (GET_CODE (elt) != SET
1067 || GET_CODE (SET_DEST (elt)) != MEM
1068 || GET_CODE (SET_SRC (elt)) != REG
1069 || GET_MODE (SET_SRC (elt)) != V4SImode)
1073 for (i=1; i <= 19; i++)
1075 elt = XVECEXP (op, 0, index++);
1076 if (GET_CODE (elt) != SET
1077 || GET_CODE (SET_DEST (elt)) != MEM
1078 || ! memory_operand (SET_DEST (elt), Pmode)
1079 || GET_CODE (SET_SRC (elt)) != REG
1080 || GET_MODE (SET_SRC (elt)) != Pmode)
1084 elt = XVECEXP (op, 0, index++);
1085 if (GET_CODE (elt) != SET
1086 || GET_CODE (SET_DEST (elt)) != MEM
1087 || ! memory_operand (SET_DEST (elt), Pmode)
1088 || GET_CODE (SET_SRC (elt)) != REG
1089 || REGNO (SET_SRC (elt)) != CR2_REGNO
1090 || GET_MODE (SET_SRC (elt)) != Pmode)
1093 if (GET_CODE (XVECEXP (op, 0, index++)) != SET
1094 || GET_CODE (XVECEXP (op, 0, index++)) != SET)
1099 ;; Return 1 if OP is valid for a restore_world call in epilogue, known to be
1101 (define_predicate "restore_world_operation"
1102 (match_code "parallel")
1107 int count = XVECLEN (op, 0);
1113 if (GET_CODE (XVECEXP (op, 0, index++)) != RETURN
1114 || GET_CODE (XVECEXP (op, 0, index++)) != USE
1115 || GET_CODE (XVECEXP (op, 0, index++)) != USE
1116 || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER)
1119 elt = XVECEXP (op, 0, index++);
1120 if (GET_CODE (elt) != SET
1121 || GET_CODE (SET_SRC (elt)) != MEM
1122 || ! memory_operand (SET_SRC (elt), Pmode)
1123 || GET_CODE (SET_DEST (elt)) != REG
1124 || REGNO (SET_DEST (elt)) != CR2_REGNO
1125 || GET_MODE (SET_DEST (elt)) != Pmode)
1128 for (i=1; i <= 19; i++)
1130 elt = XVECEXP (op, 0, index++);
1131 if (GET_CODE (elt) != SET
1132 || GET_CODE (SET_SRC (elt)) != MEM
1133 || ! memory_operand (SET_SRC (elt), Pmode)
1134 || GET_CODE (SET_DEST (elt)) != REG
1135 || GET_MODE (SET_DEST (elt)) != Pmode)
1139 for (i=1; i <= 12; i++)
1141 elt = XVECEXP (op, 0, index++);
1142 if (GET_CODE (elt) != SET
1143 || GET_CODE (SET_SRC (elt)) != MEM
1144 || GET_CODE (SET_DEST (elt)) != REG
1145 || GET_MODE (SET_DEST (elt)) != V4SImode)
1149 for (i=1; i <= 18; i++)
1151 elt = XVECEXP (op, 0, index++);
1152 if (GET_CODE (elt) != SET
1153 || GET_CODE (SET_SRC (elt)) != MEM
1154 || ! memory_operand (SET_SRC (elt), DFmode)
1155 || GET_CODE (SET_DEST (elt)) != REG
1156 || GET_MODE (SET_DEST (elt)) != DFmode)
1160 if (GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
1161 || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
1162 || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
1163 || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
1164 || GET_CODE (XVECEXP (op, 0, index++)) != USE)
1169 ;; Return 1 if OP is valid for a vrsave call, known to be a PARALLEL.
1170 (define_predicate "vrsave_operation"
1171 (match_code "parallel")
1173 int count = XVECLEN (op, 0);
1174 unsigned int dest_regno, src_regno;
1178 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1179 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != REG
1180 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != UNSPEC_VOLATILE
1181 || XINT (SET_SRC (XVECEXP (op, 0, 0)), 1) != UNSPECV_SET_VRSAVE)
1184 dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, 0)));
1185 src_regno = REGNO (XVECEXP (SET_SRC (XVECEXP (op, 0, 0)), 0, 1));
1187 if (dest_regno != VRSAVE_REGNO || src_regno != VRSAVE_REGNO)
1190 for (i = 1; i < count; i++)
1192 rtx elt = XVECEXP (op, 0, i);
1194 if (GET_CODE (elt) != CLOBBER
1195 && GET_CODE (elt) != SET)
1202 ;; Return 1 if OP is valid for mfcr insn, known to be a PARALLEL.
1203 (define_predicate "mfcr_operation"
1204 (match_code "parallel")
1206 int count = XVECLEN (op, 0);
1209 /* Perform a quick check so we don't blow up below. */
1211 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1212 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != UNSPEC
1213 || XVECLEN (SET_SRC (XVECEXP (op, 0, 0)), 0) != 2)
1216 for (i = 0; i < count; i++)
1218 rtx exp = XVECEXP (op, 0, i);
1223 src_reg = XVECEXP (SET_SRC (exp), 0, 0);
1225 if (GET_CODE (src_reg) != REG
1226 || GET_MODE (src_reg) != CCmode
1227 || ! CR_REGNO_P (REGNO (src_reg)))
1230 if (GET_CODE (exp) != SET
1231 || GET_CODE (SET_DEST (exp)) != REG
1232 || GET_MODE (SET_DEST (exp)) != SImode
1233 || ! INT_REGNO_P (REGNO (SET_DEST (exp))))
1235 unspec = SET_SRC (exp);
1236 maskval = 1 << (MAX_CR_REGNO - REGNO (src_reg));
1238 if (GET_CODE (unspec) != UNSPEC
1239 || XINT (unspec, 1) != UNSPEC_MOVESI_FROM_CR
1240 || XVECLEN (unspec, 0) != 2
1241 || XVECEXP (unspec, 0, 0) != src_reg
1242 || GET_CODE (XVECEXP (unspec, 0, 1)) != CONST_INT
1243 || INTVAL (XVECEXP (unspec, 0, 1)) != maskval)
1249 ;; Return 1 if OP is valid for mtcrf insn, known to be a PARALLEL.
1250 (define_predicate "mtcrf_operation"
1251 (match_code "parallel")
1253 int count = XVECLEN (op, 0);
1257 /* Perform a quick check so we don't blow up below. */
1259 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1260 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != UNSPEC
1261 || XVECLEN (SET_SRC (XVECEXP (op, 0, 0)), 0) != 2)
1263 src_reg = XVECEXP (SET_SRC (XVECEXP (op, 0, 0)), 0, 0);
1265 if (GET_CODE (src_reg) != REG
1266 || GET_MODE (src_reg) != SImode
1267 || ! INT_REGNO_P (REGNO (src_reg)))
1270 for (i = 0; i < count; i++)
1272 rtx exp = XVECEXP (op, 0, i);
1276 if (GET_CODE (exp) != SET
1277 || GET_CODE (SET_DEST (exp)) != REG
1278 || GET_MODE (SET_DEST (exp)) != CCmode
1279 || ! CR_REGNO_P (REGNO (SET_DEST (exp))))
1281 unspec = SET_SRC (exp);
1282 maskval = 1 << (MAX_CR_REGNO - REGNO (SET_DEST (exp)));
1284 if (GET_CODE (unspec) != UNSPEC
1285 || XINT (unspec, 1) != UNSPEC_MOVESI_TO_CR
1286 || XVECLEN (unspec, 0) != 2
1287 || XVECEXP (unspec, 0, 0) != src_reg
1288 || GET_CODE (XVECEXP (unspec, 0, 1)) != CONST_INT
1289 || INTVAL (XVECEXP (unspec, 0, 1)) != maskval)
1295 ;; Return 1 if OP is valid for lmw insn, known to be a PARALLEL.
1296 (define_predicate "lmw_operation"
1297 (match_code "parallel")
1299 int count = XVECLEN (op, 0);
1300 unsigned int dest_regno;
1302 unsigned int base_regno;
1303 HOST_WIDE_INT offset;
1306 /* Perform a quick check so we don't blow up below. */
1308 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1309 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != REG
1310 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != MEM)
1313 dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, 0)));
1314 src_addr = XEXP (SET_SRC (XVECEXP (op, 0, 0)), 0);
1317 || count != 32 - (int) dest_regno)
1320 if (legitimate_indirect_address_p (src_addr, 0))
1323 base_regno = REGNO (src_addr);
1324 if (base_regno == 0)
1327 else if (rs6000_legitimate_offset_address_p (SImode, src_addr, 0))
1329 offset = INTVAL (XEXP (src_addr, 1));
1330 base_regno = REGNO (XEXP (src_addr, 0));
1335 for (i = 0; i < count; i++)
1337 rtx elt = XVECEXP (op, 0, i);
1340 HOST_WIDE_INT newoffset;
1342 if (GET_CODE (elt) != SET
1343 || GET_CODE (SET_DEST (elt)) != REG
1344 || GET_MODE (SET_DEST (elt)) != SImode
1345 || REGNO (SET_DEST (elt)) != dest_regno + i
1346 || GET_CODE (SET_SRC (elt)) != MEM
1347 || GET_MODE (SET_SRC (elt)) != SImode)
1349 newaddr = XEXP (SET_SRC (elt), 0);
1350 if (legitimate_indirect_address_p (newaddr, 0))
1355 else if (rs6000_legitimate_offset_address_p (SImode, newaddr, 0))
1357 addr_reg = XEXP (newaddr, 0);
1358 newoffset = INTVAL (XEXP (newaddr, 1));
1362 if (REGNO (addr_reg) != base_regno
1363 || newoffset != offset + 4 * i)
1370 ;; Return 1 if OP is valid for stmw insn, known to be a PARALLEL.
1371 (define_predicate "stmw_operation"
1372 (match_code "parallel")
1374 int count = XVECLEN (op, 0);
1375 unsigned int src_regno;
1377 unsigned int base_regno;
1378 HOST_WIDE_INT offset;
1381 /* Perform a quick check so we don't blow up below. */
1383 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1384 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != MEM
1385 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != REG)
1388 src_regno = REGNO (SET_SRC (XVECEXP (op, 0, 0)));
1389 dest_addr = XEXP (SET_DEST (XVECEXP (op, 0, 0)), 0);
1392 || count != 32 - (int) src_regno)
1395 if (legitimate_indirect_address_p (dest_addr, 0))
1398 base_regno = REGNO (dest_addr);
1399 if (base_regno == 0)
1402 else if (rs6000_legitimate_offset_address_p (SImode, dest_addr, 0))
1404 offset = INTVAL (XEXP (dest_addr, 1));
1405 base_regno = REGNO (XEXP (dest_addr, 0));
1410 for (i = 0; i < count; i++)
1412 rtx elt = XVECEXP (op, 0, i);
1415 HOST_WIDE_INT newoffset;
1417 if (GET_CODE (elt) != SET
1418 || GET_CODE (SET_SRC (elt)) != REG
1419 || GET_MODE (SET_SRC (elt)) != SImode
1420 || REGNO (SET_SRC (elt)) != src_regno + i
1421 || GET_CODE (SET_DEST (elt)) != MEM
1422 || GET_MODE (SET_DEST (elt)) != SImode)
1424 newaddr = XEXP (SET_DEST (elt), 0);
1425 if (legitimate_indirect_address_p (newaddr, 0))
1430 else if (rs6000_legitimate_offset_address_p (SImode, newaddr, 0))
1432 addr_reg = XEXP (newaddr, 0);
1433 newoffset = INTVAL (XEXP (newaddr, 1));
1437 if (REGNO (addr_reg) != base_regno
1438 || newoffset != offset + 4 * i)