OSDN Git Service

2b0716e658c98a0ec4764e1e590f134818e8c5a9
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / predicates.md
1 ;; Predicate definitions for POWER and PowerPC.
2 ;; Copyright (C) 2005 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 2, 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 COPYING.  If not, write to
18 ;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
19 ;; Boston, MA 02110-1301, USA.
20
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"))
24
25 ;; Return 1 for any PARALLEL.
26 (define_predicate "any_parallel_operand"
27   (match_code "parallel"))
28
29 ;; Return 1 if op is COUNT register.
30 (define_predicate "count_register_operand"
31   (and (match_code "reg")
32        (match_test "REGNO (op) == COUNT_REGISTER_REGNUM
33                     || REGNO (op) > LAST_VIRTUAL_REGISTER")))
34   
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")))
41
42 ;; Return 1 if op is XER register.
43 (define_predicate "xer_operand"
44   (and (match_code "reg")
45        (match_test "XER_REGNO_P (REGNO (op))")))
46
47 ;; Return 1 if op is a signed 5-bit constant integer.
48 (define_predicate "s5bit_cint_operand"
49   (and (match_code "const_int")
50        (match_test "INTVAL (op) >= -16 && INTVAL (op) <= 15")))
51
52 ;; Return 1 if op is a unsigned 5-bit constant integer.
53 (define_predicate "u5bit_cint_operand"
54   (and (match_code "const_int")
55        (match_test "INTVAL (op) >= 0 && INTVAL (op) <= 31")))
56
57 ;; Return 1 if op is a signed 8-bit constant integer.
58 ;; Integer multiplication complete more quickly
59 (define_predicate "s8bit_cint_operand"
60   (and (match_code "const_int")
61        (match_test "INTVAL (op) >= -128 && INTVAL (op) <= 127")))
62
63 ;; Return 1 if op is a constant integer that can fit in a D field.
64 (define_predicate "short_cint_operand"
65   (and (match_code "const_int")
66        (match_test "CONST_OK_FOR_LETTER_P (INTVAL (op), 'I')")))
67
68 ;; Return 1 if op is a constant integer that can fit in an unsigned D field.
69 (define_predicate "u_short_cint_operand"
70   (and (match_code "const_int")
71        (match_test "CONST_OK_FOR_LETTER_P (INTVAL (op), 'K')")))
72
73 ;; Return 1 if op is a constant integer that cannot fit in a signed D field.
74 (define_predicate "non_short_cint_operand"
75   (and (match_code "const_int")
76        (match_test "(unsigned HOST_WIDE_INT)
77                     (INTVAL (op) + 0x8000) >= 0x10000")))
78
79 ;; Return 1 if op is a positive constant integer that is an exact power of 2.
80 (define_predicate "exact_log2_cint_operand"
81   (and (match_code "const_int")
82        (match_test "INTVAL (op) > 0 && exact_log2 (INTVAL (op)) >= 0")))
83
84 ;; Return 1 if op is a register that is not special.
85 (define_predicate "gpc_reg_operand"
86    (and (match_operand 0 "register_operand")
87         (match_test "GET_CODE (op) != REG
88                      || (REGNO (op) >= ARG_POINTER_REGNUM
89                          && !XER_REGNO_P (REGNO (op)))
90                      || REGNO (op) < MQ_REGNO")))
91
92 ;; Return 1 if op is a register that is a condition register field.
93 (define_predicate "cc_reg_operand"
94    (and (match_operand 0 "register_operand")
95         (match_test "GET_CODE (op) != REG
96                      || REGNO (op) > LAST_VIRTUAL_REGISTER
97                      || CR_REGNO_P (REGNO (op))")))
98
99 ;; Return 1 if op is a register that is a condition register field not cr0.
100 (define_predicate "cc_reg_not_cr0_operand"
101    (and (match_operand 0 "register_operand")
102         (match_test "GET_CODE (op) != REG
103                      || REGNO (op) > LAST_VIRTUAL_REGISTER
104                      || CR_REGNO_NOT_CR0_P (REGNO (op))")))
105
106 ;; Return 1 if op is a constant integer valid for D field
107 ;; or non-special register register.
108 (define_predicate "reg_or_short_operand"
109   (if_then_else (match_code "const_int")
110     (match_operand 0 "short_cint_operand")
111     (match_operand 0 "gpc_reg_operand")))
112
113 ;; Return 1 if op is a constant integer valid whose negation is valid for
114 ;; D field or non-special register register.
115 ;; Do not allow a constant zero because all patterns that call this
116 ;; predicate use "addic r1,r2,-const" to set carry when r2 is greater than
117 ;; or equal to const, which does not work for zero.
118 (define_predicate "reg_or_neg_short_operand"
119   (if_then_else (match_code "const_int")
120     (match_test "CONST_OK_FOR_LETTER_P (INTVAL (op), 'P')
121                  && INTVAL (op) != 0")
122     (match_operand 0 "gpc_reg_operand")))
123
124 ;; Return 1 if op is a constant integer valid for DS field
125 ;; or non-special register.
126 (define_predicate "reg_or_aligned_short_operand"
127   (if_then_else (match_code "const_int")
128     (and (match_operand 0 "short_cint_operand")
129          (match_test "!(INTVAL (op) & 3)"))
130     (match_operand 0 "gpc_reg_operand")))
131
132 ;; Return 1 if op is a constant integer whose high-order 16 bits are zero
133 ;; or non-special register.
134 (define_predicate "reg_or_u_short_operand"
135   (if_then_else (match_code "const_int")
136     (match_operand 0 "u_short_cint_operand")
137     (match_operand 0 "gpc_reg_operand")))
138
139 ;; Return 1 if op is any constant integer 
140 ;; or non-special register.
141 (define_predicate "reg_or_cint_operand"
142   (ior (match_code "const_int")
143        (match_operand 0 "gpc_reg_operand")))
144
145 ;; Return 1 if op is a constant integer valid for addition
146 ;; or non-special register.
147 (define_predicate "reg_or_add_cint_operand"
148   (if_then_else (match_code "const_int")
149     (match_test "(HOST_BITS_PER_WIDE_INT == 32
150                   && (mode == SImode || INTVAL (op) < 0x7fff8000))
151                  || ((unsigned HOST_WIDE_INT) (INTVAL (op) + 0x80008000)
152                      < (unsigned HOST_WIDE_INT) 0x100000000ll)")
153     (match_operand 0 "gpc_reg_operand")))
154
155 ;; Return 1 if op is a constant integer valid for subtraction
156 ;; or non-special register.
157 (define_predicate "reg_or_sub_cint_operand"
158   (if_then_else (match_code "const_int")
159     (match_test "(HOST_BITS_PER_WIDE_INT == 32
160                   && (mode == SImode || - INTVAL (op) < 0x7fff8000))
161                  || ((unsigned HOST_WIDE_INT) (- INTVAL (op) 
162                                                + (mode == SImode
163                                                   ? 0x80000000 : 0x80008000))
164                      < (unsigned HOST_WIDE_INT) 0x100000000ll)")
165     (match_operand 0 "gpc_reg_operand")))
166
167 ;; Return 1 if op is any 32-bit unsigned constant integer
168 ;; or non-special register.
169 (define_predicate "reg_or_logical_cint_operand"
170   (if_then_else (match_code "const_int")
171     (match_test "(GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT
172                   && INTVAL (op) >= 0)
173                  || ((INTVAL (op) & GET_MODE_MASK (mode)
174                       & (~ (unsigned HOST_WIDE_INT) 0xffffffff)) == 0)")
175     (if_then_else (match_code "const_double")
176       (match_test "GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT
177                    && mode == DImode
178                    && CONST_DOUBLE_HIGH (op) == 0")
179       (match_operand 0 "gpc_reg_operand"))))
180
181 ;; Return 1 if operand is a CONST_DOUBLE that can be set in a register
182 ;; with no more than one instruction per word.
183 (define_predicate "easy_fp_constant"
184   (match_code "const_double")
185 {
186   long k[4];
187   REAL_VALUE_TYPE rv;
188
189   if (GET_MODE (op) != mode
190       || (!SCALAR_FLOAT_MODE_P (mode) && mode != DImode))
191     return 0;
192
193   /* Consider all constants with -msoft-float to be easy.  */
194   if ((TARGET_SOFT_FLOAT || TARGET_E500_SINGLE)
195       && mode != DImode)
196     return 1;
197
198   /* If we are using V.4 style PIC, consider all constants to be hard.  */
199   if (flag_pic && DEFAULT_ABI == ABI_V4)
200     return 0;
201
202 #ifdef TARGET_RELOCATABLE
203   /* Similarly if we are using -mrelocatable, consider all constants
204      to be hard.  */
205   if (TARGET_RELOCATABLE)
206     return 0;
207 #endif
208
209   switch (mode)
210     {
211     case TFmode:
212       REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
213       REAL_VALUE_TO_TARGET_LONG_DOUBLE (rv, k);
214
215       return (num_insns_constant_wide ((HOST_WIDE_INT) k[0]) == 1
216               && num_insns_constant_wide ((HOST_WIDE_INT) k[1]) == 1
217               && num_insns_constant_wide ((HOST_WIDE_INT) k[2]) == 1
218               && num_insns_constant_wide ((HOST_WIDE_INT) k[3]) == 1);
219
220     case DFmode:
221       /* Force constants to memory before reload to utilize
222          compress_float_constant.
223          Avoid this when flag_unsafe_math_optimizations is enabled
224          because RDIV division to reciprocal optimization is not able
225          to regenerate the division.  */
226       if (TARGET_E500_DOUBLE
227           || (!reload_in_progress && !reload_completed
228               && !flag_unsafe_math_optimizations))
229         return 0;
230
231       REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
232       REAL_VALUE_TO_TARGET_DOUBLE (rv, k);
233
234       return (num_insns_constant_wide ((HOST_WIDE_INT) k[0]) == 1
235               && num_insns_constant_wide ((HOST_WIDE_INT) k[1]) == 1);
236
237     case SFmode:
238       /* The constant 0.f is easy.  */
239       if (op == CONST0_RTX (SFmode))
240         return 1;
241
242       /* Force constants to memory before reload to utilize
243          compress_float_constant.
244          Avoid this when flag_unsafe_math_optimizations is enabled
245          because RDIV division to reciprocal optimization is not able
246          to regenerate the division.  */
247       if (!reload_in_progress && !reload_completed
248           && !flag_unsafe_math_optimizations)
249         return 0;
250
251       REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
252       REAL_VALUE_TO_TARGET_SINGLE (rv, k[0]);
253
254       return num_insns_constant_wide (k[0]) == 1;
255
256   case DImode:
257     return ((TARGET_POWERPC64
258              && GET_CODE (op) == CONST_DOUBLE && CONST_DOUBLE_LOW (op) == 0)
259             || (num_insns_constant (op, DImode) <= 2));
260
261   case SImode:
262     return 1;
263
264   default:
265     gcc_unreachable ();
266   }
267 })
268
269 ;; Return 1 if the operand is a CONST_VECTOR and can be loaded into a
270 ;; vector register without using memory.
271 (define_predicate "easy_vector_constant"
272   (match_code "const_vector")
273 {
274   if (ALTIVEC_VECTOR_MODE (mode))
275     {
276       if (zero_constant (op, mode))
277         return true;
278       if (GET_MODE_CLASS (mode) != MODE_VECTOR_INT)
279         return false;
280
281       return easy_altivec_constant (op, mode);
282     }
283
284   if (SPE_VECTOR_MODE (mode))
285     {
286       int cst, cst2;
287       if (zero_constant (op, mode))
288         return true;
289       if (GET_MODE_CLASS (mode) != MODE_VECTOR_INT)
290         return false;
291
292       /* Limit SPE vectors to 15 bits signed.  These we can generate with:
293            li r0, CONSTANT1
294            evmergelo r0, r0, r0
295            li r0, CONSTANT2
296
297          I don't know how efficient it would be to allow bigger constants,
298          considering we'll have an extra 'ori' for every 'li'.  I doubt 5
299          instructions is better than a 64-bit memory load, but I don't
300          have the e500 timing specs.  */
301       if (mode == V2SImode)
302         {
303           cst  = INTVAL (CONST_VECTOR_ELT (op, 0));
304           cst2 = INTVAL (CONST_VECTOR_ELT (op, 1));
305           return cst  >= -0x7fff && cst <= 0x7fff
306                  && cst2 >= -0x7fff && cst2 <= 0x7fff;
307         }
308     }
309
310   return false;
311 })
312
313 ;; Same as easy_vector_constant but only for EASY_VECTOR_15_ADD_SELF.
314 (define_predicate "easy_vector_constant_add_self"
315   (and (match_code "const_vector")
316        (and (match_test "TARGET_ALTIVEC")
317             (match_test "easy_altivec_constant (op, mode)")))
318 {
319   rtx last = CONST_VECTOR_ELT (op, GET_MODE_NUNITS (mode) - 1);
320   HOST_WIDE_INT val = ((INTVAL (last) & 0xff) ^ 0x80) - 0x80;
321   return EASY_VECTOR_15_ADD_SELF (val);
322 })
323
324 ;; Return 1 if operand is constant zero (scalars and vectors).
325 (define_predicate "zero_constant"
326   (and (match_code "const_int,const_double,const_vector")
327        (match_test "op == CONST0_RTX (mode)")))
328
329 ;; Return 1 if operand is 0.0.
330 ;; or non-special register register field no cr0
331 (define_predicate "zero_fp_constant"
332   (and (match_code "const_double")
333        (match_test "SCALAR_FLOAT_MODE_P (mode)
334                     && op == CONST0_RTX (mode)")))
335
336 ;; Return 1 if the operand is in volatile memory.  Note that during the
337 ;; RTL generation phase, memory_operand does not return TRUE for volatile
338 ;; memory references.  So this function allows us to recognize volatile
339 ;; references where it's safe.
340 (define_predicate "volatile_mem_operand"
341   (and (and (match_code "mem")
342             (match_test "MEM_VOLATILE_P (op)"))
343        (if_then_else (match_test "reload_completed")
344          (match_operand 0 "memory_operand")
345          (if_then_else (match_test "reload_in_progress")
346            (match_test "strict_memory_address_p (mode, XEXP (op, 0))")
347            (match_test "memory_address_p (mode, XEXP (op, 0))")))))
348
349 ;; Return 1 if the operand is an offsettable memory operand.
350 (define_predicate "offsettable_mem_operand"
351   (and (match_code "mem")
352        (match_test "offsettable_address_p (reload_completed
353                                            || reload_in_progress,
354                                            mode, XEXP (op, 0))")))
355
356 ;; Return 1 if the operand is an indexed or indirect memory operand.
357 (define_predicate "indexed_or_indirect_operand"
358   (match_operand 0 "memory_operand")
359 {
360   rtx tmp = XEXP (op, 0);
361
362   if (TARGET_ALTIVEC
363       && ALTIVEC_VECTOR_MODE (mode)
364       && GET_CODE (tmp) == AND
365       && GET_CODE (XEXP (tmp, 1)) == CONST_INT
366       && INTVAL (XEXP (tmp, 1)) == -16)
367     tmp = XEXP (tmp, 0);
368
369     return REG_P (tmp)
370                   || (GET_CODE (tmp) == PLUS
371                       && REG_P (XEXP (tmp, 0)) 
372                       && REG_P (XEXP (tmp, 1)));
373 })
374
375 ;; Return 1 if the operand is a memory operand with an address divisible by 4
376 (define_predicate "word_offset_memref_operand"
377   (and (match_operand 0 "memory_operand")
378        (match_test "GET_CODE (XEXP (op, 0)) != PLUS
379                     || ! REG_P (XEXP (XEXP (op, 0), 0)) 
380                     || GET_CODE (XEXP (XEXP (op, 0), 1)) != CONST_INT
381                     || INTVAL (XEXP (XEXP (op, 0), 1)) % 4 == 0")))
382
383 ;; Return 1 if the operand is an indexed or indirect address.
384 (define_predicate "indexed_or_indirect_address"
385   (and (match_operand 0 "address_operand")
386        (match_test "REG_P (op)
387                     || (GET_CODE (op) == PLUS
388                         && REG_P (XEXP (op, 0)) 
389                         && REG_P (XEXP (op, 1)))")))
390
391 ;; Used for the destination of the fix_truncdfsi2 expander.
392 ;; If stfiwx will be used, the result goes to memory; otherwise,
393 ;; we're going to emit a store and a load of a subreg, so the dest is a
394 ;; register.
395 (define_predicate "fix_trunc_dest_operand"
396   (if_then_else (match_test "! TARGET_E500_DOUBLE && TARGET_PPC_GFXOPT")
397    (match_operand 0 "memory_operand")
398    (match_operand 0 "gpc_reg_operand")))
399
400 ;; Return 1 if the operand is either a non-special register or can be used
401 ;; as the operand of a `mode' add insn.
402 (define_predicate "add_operand"
403   (if_then_else (match_code "const_int")
404     (match_test "CONST_OK_FOR_LETTER_P (INTVAL (op), 'I')
405                  || CONST_OK_FOR_LETTER_P (INTVAL (op), 'L')")
406     (match_operand 0 "gpc_reg_operand")))
407
408 ;; Return 1 if OP is a constant but not a valid add_operand.
409 (define_predicate "non_add_cint_operand"
410   (and (match_code "const_int")
411        (match_test "!CONST_OK_FOR_LETTER_P (INTVAL (op), 'I')
412                     && !CONST_OK_FOR_LETTER_P (INTVAL (op), 'L')")))
413
414 ;; Return 1 if the operand is a non-special register or a constant that
415 ;; can be used as the operand of an OR or XOR.
416 (define_predicate "logical_operand"
417   (match_code "reg,subreg,const_int,const_double")
418 {
419   HOST_WIDE_INT opl, oph;
420
421   if (gpc_reg_operand (op, mode))
422     return 1;
423
424   if (GET_CODE (op) == CONST_INT)
425     {
426       opl = INTVAL (op) & GET_MODE_MASK (mode);
427
428       if (HOST_BITS_PER_WIDE_INT <= 32
429           && GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT && opl < 0)
430         return 0;
431     }
432   else if (GET_CODE (op) == CONST_DOUBLE)
433     {
434       gcc_assert (GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT);
435
436       opl = CONST_DOUBLE_LOW (op);
437       oph = CONST_DOUBLE_HIGH (op);
438       if (oph != 0)
439         return 0;
440     }
441   else
442     return 0;
443
444   return ((opl & ~ (unsigned HOST_WIDE_INT) 0xffff) == 0
445           || (opl & ~ (unsigned HOST_WIDE_INT) 0xffff0000) == 0);
446 })
447
448 ;; Return 1 if op is a constant that is not a logical operand, but could
449 ;; be split into one.
450 (define_predicate "non_logical_cint_operand"
451   (and (match_code "const_int,const_double")
452        (and (not (match_operand 0 "logical_operand"))
453             (match_operand 0 "reg_or_logical_cint_operand"))))
454
455 ;; Return 1 if op is a constant that can be encoded in a 32-bit mask,
456 ;; suitable for use with rlwinm (no more than two 1->0 or 0->1
457 ;; transitions).  Reject all ones and all zeros, since these should have
458 ;; been optimized away and confuse the making of MB and ME.
459 (define_predicate "mask_operand"
460   (match_code "const_int")
461 {
462   HOST_WIDE_INT c, lsb;
463
464   c = INTVAL (op);
465
466   if (TARGET_POWERPC64)
467     {
468       /* Fail if the mask is not 32-bit.  */
469       if (mode == DImode && (c & ~(unsigned HOST_WIDE_INT) 0xffffffff) != 0)
470         return 0;
471
472       /* Fail if the mask wraps around because the upper 32-bits of the
473          mask will all be 1s, contrary to GCC's internal view.  */
474       if ((c & 0x80000001) == 0x80000001)
475         return 0;
476     }
477
478   /* We don't change the number of transitions by inverting,
479      so make sure we start with the LS bit zero.  */
480   if (c & 1)
481     c = ~c;
482
483   /* Reject all zeros or all ones.  */
484   if (c == 0)
485     return 0;
486
487   /* Find the first transition.  */
488   lsb = c & -c;
489
490   /* Invert to look for a second transition.  */
491   c = ~c;
492
493   /* Erase first transition.  */
494   c &= -lsb;
495
496   /* Find the second transition (if any).  */
497   lsb = c & -c;
498
499   /* Match if all the bits above are 1's (or c is zero).  */
500   return c == -lsb;
501 })
502
503 ;; Return 1 for the PowerPC64 rlwinm corner case.
504 (define_predicate "mask_operand_wrap"
505   (match_code "const_int")
506 {
507   HOST_WIDE_INT c, lsb;
508
509   c = INTVAL (op);
510
511   if ((c & 0x80000001) != 0x80000001)
512     return 0;
513
514   c = ~c;
515   if (c == 0)
516     return 0;
517
518   lsb = c & -c;
519   c = ~c;
520   c &= -lsb;
521   lsb = c & -c;
522   return c == -lsb;
523 })
524
525 ;; Return 1 if the operand is a constant that is a PowerPC64 mask
526 ;; suitable for use with rldicl or rldicr (no more than one 1->0 or 0->1
527 ;; transition).  Reject all zeros, since zero should have been
528 ;; optimized away and confuses the making of MB and ME.
529 (define_predicate "mask64_operand"
530   (match_code "const_int")
531 {
532   HOST_WIDE_INT c, lsb;
533
534   c = INTVAL (op);
535
536   /* Reject all zeros.  */
537   if (c == 0)
538     return 0;
539
540   /* We don't change the number of transitions by inverting,
541      so make sure we start with the LS bit zero.  */
542   if (c & 1)
543     c = ~c;
544
545   /* Find the first transition.  */
546   lsb = c & -c;
547
548   /* Match if all the bits above are 1's (or c is zero).  */
549   return c == -lsb;
550 })
551
552 ;; Like mask64_operand, but allow up to three transitions.  This
553 ;; predicate is used by insn patterns that generate two rldicl or
554 ;; rldicr machine insns.
555 (define_predicate "mask64_2_operand"
556   (match_code "const_int")
557 {
558   HOST_WIDE_INT c, lsb;
559
560   c = INTVAL (op);
561
562   /* Disallow all zeros.  */
563   if (c == 0)
564     return 0;
565
566   /* We don't change the number of transitions by inverting,
567      so make sure we start with the LS bit zero.  */
568   if (c & 1)
569     c = ~c;
570
571   /* Find the first transition.  */
572   lsb = c & -c;
573
574   /* Invert to look for a second transition.  */
575   c = ~c;
576
577   /* Erase first transition.  */
578   c &= -lsb;
579
580   /* Find the second transition.  */
581   lsb = c & -c;
582
583   /* Invert to look for a third transition.  */
584   c = ~c;
585
586   /* Erase second transition.  */
587   c &= -lsb;
588
589   /* Find the third transition (if any).  */
590   lsb = c & -c;
591
592   /* Match if all the bits above are 1's (or c is zero).  */
593   return c == -lsb;
594 })
595
596 ;; Like and_operand, but also match constants that can be implemented
597 ;; with two rldicl or rldicr insns.
598 (define_predicate "and64_2_operand"
599   (ior (match_operand 0 "mask64_2_operand")
600        (if_then_else (match_test "fixed_regs[CR0_REGNO]")
601          (match_operand 0 "gpc_reg_operand")
602          (match_operand 0 "logical_operand"))))
603
604 ;; Return 1 if the operand is either a non-special register or a
605 ;; constant that can be used as the operand of a logical AND.
606 (define_predicate "and_operand"
607   (ior (match_operand 0 "mask_operand")
608        (ior (and (match_test "TARGET_POWERPC64 && mode == DImode")
609                  (match_operand 0 "mask64_operand"))
610             (if_then_else (match_test "fixed_regs[CR0_REGNO]")
611               (match_operand 0 "gpc_reg_operand")
612               (match_operand 0 "logical_operand")))))
613
614 ;; Return 1 if the operand is either a logical operand or a short cint operand.
615 (define_predicate "scc_eq_operand"
616   (ior (match_operand 0 "logical_operand")
617        (match_operand 0 "short_cint_operand")))
618
619 ;; Return 1 if the operand is a general non-special register or memory operand.
620 (define_predicate "reg_or_mem_operand"
621   (if_then_else (match_code "mem")
622      (ior (match_operand 0 "memory_operand")
623           (ior (match_test "macho_lo_sum_memory_operand (op, mode)")
624                (match_operand 0 "volatile_mem_operand")))
625      (match_operand 0 "gpc_reg_operand")))
626
627 ;; Return 1 if the operand is either an easy FP constant or memory or reg.
628 (define_predicate "reg_or_none500mem_operand"
629   (if_then_else (match_code "mem")
630      (and (match_test "!TARGET_E500_DOUBLE")
631           (ior (match_operand 0 "memory_operand")
632                (ior (match_test "macho_lo_sum_memory_operand (op, mode)")
633                     (match_operand 0 "volatile_mem_operand"))))
634      (match_operand 0 "gpc_reg_operand")))
635
636 ;; Return 1 if the operand is CONST_DOUBLE 0, register or memory operand.
637 (define_predicate "zero_reg_mem_operand"
638   (ior (match_operand 0 "zero_fp_constant")
639        (match_operand 0 "reg_or_mem_operand")))
640
641 ;; Return 1 if the operand is a general register or memory operand without
642 ;; pre_inc or pre_dec, which produces invalid form of PowerPC lwa
643 ;; instruction.
644 (define_predicate "lwa_operand"
645   (match_code "reg,subreg,mem")
646 {
647   rtx inner = op;
648
649   if (reload_completed && GET_CODE (inner) == SUBREG)
650     inner = SUBREG_REG (inner);
651
652   return gpc_reg_operand (inner, mode)
653     || (memory_operand (inner, mode)
654         && GET_CODE (XEXP (inner, 0)) != PRE_INC
655         && GET_CODE (XEXP (inner, 0)) != PRE_DEC
656         && (GET_CODE (XEXP (inner, 0)) != PLUS
657             || GET_CODE (XEXP (XEXP (inner, 0), 1)) != CONST_INT
658             || INTVAL (XEXP (XEXP (inner, 0), 1)) % 4 == 0));
659 })
660
661 ;; Return 1 if the operand, used inside a MEM, is a SYMBOL_REF.
662 (define_predicate "symbol_ref_operand"
663   (and (match_code "symbol_ref")
664        (match_test "(mode == VOIDmode || GET_MODE (op) == mode)
665                     && (DEFAULT_ABI != ABI_AIX || SYMBOL_REF_FUNCTION_P (op))")))
666
667 ;; Return 1 if op is an operand that can be loaded via the GOT.
668 ;; or non-special register register field no cr0
669 (define_predicate "got_operand"
670   (match_code "symbol_ref,const,label_ref"))
671
672 ;; Return 1 if op is a simple reference that can be loaded via the GOT,
673 ;; excluding labels involving addition.
674 (define_predicate "got_no_const_operand"
675   (match_code "symbol_ref,label_ref"))
676
677 ;; Return 1 if op is a SYMBOL_REF for a TLS symbol.
678 (define_predicate "rs6000_tls_symbol_ref"
679   (and (match_code "symbol_ref")
680        (match_test "RS6000_SYMBOL_REF_TLS_P (op)")))
681
682 ;; Return 1 if the operand, used inside a MEM, is a valid first argument
683 ;; to CALL.  This is a SYMBOL_REF, a pseudo-register, LR or CTR.
684 (define_predicate "call_operand"
685   (if_then_else (match_code "reg")
686      (match_test "REGNO (op) == LINK_REGISTER_REGNUM
687                   || REGNO (op) == COUNT_REGISTER_REGNUM
688                   || REGNO (op) >= FIRST_PSEUDO_REGISTER")
689      (match_code "symbol_ref")))
690
691 ;; Return 1 if the operand is a SYMBOL_REF for a function known to be in
692 ;; this file.
693 (define_predicate "current_file_function_operand"
694   (and (match_code "symbol_ref")
695        (match_test "(DEFAULT_ABI != ABI_AIX || SYMBOL_REF_FUNCTION_P (op))
696                     && (SYMBOL_REF_LOCAL_P (op)
697                         || (op == XEXP (DECL_RTL (current_function_decl),
698                                                   0)))")))
699
700 ;; Return 1 if this operand is a valid input for a move insn.
701 (define_predicate "input_operand"
702   (match_code "label_ref,symbol_ref,const,high,reg,subreg,mem,
703                const_double,const_vector,const_int,plus")
704 {
705   /* Memory is always valid.  */
706   if (memory_operand (op, mode))
707     return 1;
708
709   /* For floating-point, easy constants are valid.  */
710   if (SCALAR_FLOAT_MODE_P (mode)
711       && CONSTANT_P (op)
712       && easy_fp_constant (op, mode))
713     return 1;
714
715   /* Allow any integer constant.  */
716   if (GET_MODE_CLASS (mode) == MODE_INT
717       && (GET_CODE (op) == CONST_INT
718           || GET_CODE (op) == CONST_DOUBLE))
719     return 1;
720
721   /* Allow easy vector constants.  */
722   if (GET_CODE (op) == CONST_VECTOR
723       && easy_vector_constant (op, mode))
724     return 1;
725
726   /* For floating-point or multi-word mode, the only remaining valid type
727      is a register.  */
728   if (SCALAR_FLOAT_MODE_P (mode)
729       || GET_MODE_SIZE (mode) > UNITS_PER_WORD)
730     return register_operand (op, mode);
731
732   /* The only cases left are integral modes one word or smaller (we
733      do not get called for MODE_CC values).  These can be in any
734      register.  */
735   if (register_operand (op, mode))
736     return 1;
737
738   /* A SYMBOL_REF referring to the TOC is valid.  */
739   if (legitimate_constant_pool_address_p (op))
740     return 1;
741
742   /* A constant pool expression (relative to the TOC) is valid */
743   if (toc_relative_expr_p (op))
744     return 1;
745
746   /* V.4 allows SYMBOL_REFs and CONSTs that are in the small data region
747      to be valid.  */
748   if (DEFAULT_ABI == ABI_V4
749       && (GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == CONST)
750       && small_data_operand (op, Pmode))
751     return 1;
752
753   return 0;
754 })
755
756 ;; Return true if OP is an invalid SUBREG operation on the e500.
757 (define_predicate "rs6000_nonimmediate_operand"
758   (match_code "reg,subreg,mem")
759 {
760   if (TARGET_E500_DOUBLE
761       && GET_CODE (op) == SUBREG
762       && invalid_e500_subreg (op, mode))
763     return 0;
764
765   return nonimmediate_operand (op, mode);
766 })
767
768 ;; Return true if operand is boolean operator.
769 (define_predicate "boolean_operator"
770   (match_code "and,ior,xor"))
771
772 ;; Return true if operand is OR-form of boolean operator.
773 (define_predicate "boolean_or_operator"
774   (match_code "ior,xor"))
775
776 ;; Return true if operand is an equality operator.
777 (define_special_predicate "equality_operator"
778   (match_code "eq,ne"))
779
780 ;; Return true if operand is MIN or MAX operator.
781 (define_predicate "min_max_operator"
782   (match_code "smin,smax,umin,umax"))
783
784 ;; Return 1 if OP is a comparison operation that is valid for a branch
785 ;; instruction.  We check the opcode against the mode of the CC value.
786 ;; validate_condition_mode is an assertion.
787 (define_predicate "branch_comparison_operator"
788    (and (match_operand 0 "comparison_operator")
789         (and (match_test "GET_MODE_CLASS (GET_MODE (XEXP (op, 0))) == MODE_CC")
790              (match_test "validate_condition_mode (GET_CODE (op),
791                                                    GET_MODE (XEXP (op, 0))),
792                           1"))))
793
794 ;; Return 1 if OP is a comparison operation that is valid for an SCC insn --
795 ;; it must be a positive comparison.
796 (define_predicate "scc_comparison_operator"
797   (and (match_operand 0 "branch_comparison_operator")
798        (match_code "eq,lt,gt,ltu,gtu,unordered")))
799
800 ;; Return 1 if OP is a comparison operation that is valid for a branch
801 ;; insn, which is true if the corresponding bit in the CC register is set.
802 (define_predicate "branch_positive_comparison_operator"
803   (and (match_operand 0 "branch_comparison_operator")
804        (match_code "eq,lt,gt,ltu,gtu,unordered")))
805
806 ;; Return 1 is OP is a comparison operation that is valid for a trap insn.
807 (define_predicate "trap_comparison_operator"
808    (and (match_operand 0 "comparison_operator")
809         (match_code "eq,ne,le,lt,ge,gt,leu,ltu,geu,gtu")))
810
811 ;; Return 1 if OP is a load multiple operation, known to be a PARALLEL.
812 (define_predicate "load_multiple_operation"
813   (match_code "parallel")
814 {
815   int count = XVECLEN (op, 0);
816   unsigned int dest_regno;
817   rtx src_addr;
818   int i;
819
820   /* Perform a quick check so we don't blow up below.  */
821   if (count <= 1
822       || GET_CODE (XVECEXP (op, 0, 0)) != SET
823       || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != REG
824       || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != MEM)
825     return 0;
826
827   dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, 0)));
828   src_addr = XEXP (SET_SRC (XVECEXP (op, 0, 0)), 0);
829
830   for (i = 1; i < count; i++)
831     {
832       rtx elt = XVECEXP (op, 0, i);
833
834       if (GET_CODE (elt) != SET
835           || GET_CODE (SET_DEST (elt)) != REG
836           || GET_MODE (SET_DEST (elt)) != SImode
837           || REGNO (SET_DEST (elt)) != dest_regno + i
838           || GET_CODE (SET_SRC (elt)) != MEM
839           || GET_MODE (SET_SRC (elt)) != SImode
840           || GET_CODE (XEXP (SET_SRC (elt), 0)) != PLUS
841           || ! rtx_equal_p (XEXP (XEXP (SET_SRC (elt), 0), 0), src_addr)
842           || GET_CODE (XEXP (XEXP (SET_SRC (elt), 0), 1)) != CONST_INT
843           || INTVAL (XEXP (XEXP (SET_SRC (elt), 0), 1)) != i * 4)
844         return 0;
845     }
846
847   return 1;
848 })
849
850 ;; Return 1 if OP is a store multiple operation, known to be a PARALLEL.
851 ;; The second vector element is a CLOBBER.
852 (define_predicate "store_multiple_operation"
853   (match_code "parallel")
854 {
855   int count = XVECLEN (op, 0) - 1;
856   unsigned int src_regno;
857   rtx dest_addr;
858   int i;
859
860   /* Perform a quick check so we don't blow up below.  */
861   if (count <= 1
862       || GET_CODE (XVECEXP (op, 0, 0)) != SET
863       || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != MEM
864       || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != REG)
865     return 0;
866
867   src_regno = REGNO (SET_SRC (XVECEXP (op, 0, 0)));
868   dest_addr = XEXP (SET_DEST (XVECEXP (op, 0, 0)), 0);
869
870   for (i = 1; i < count; i++)
871     {
872       rtx elt = XVECEXP (op, 0, i + 1);
873
874       if (GET_CODE (elt) != SET
875           || GET_CODE (SET_SRC (elt)) != REG
876           || GET_MODE (SET_SRC (elt)) != SImode
877           || REGNO (SET_SRC (elt)) != src_regno + i
878           || GET_CODE (SET_DEST (elt)) != MEM
879           || GET_MODE (SET_DEST (elt)) != SImode
880           || GET_CODE (XEXP (SET_DEST (elt), 0)) != PLUS
881           || ! rtx_equal_p (XEXP (XEXP (SET_DEST (elt), 0), 0), dest_addr)
882           || GET_CODE (XEXP (XEXP (SET_DEST (elt), 0), 1)) != CONST_INT
883           || INTVAL (XEXP (XEXP (SET_DEST (elt), 0), 1)) != i * 4)
884         return 0;
885     }
886
887   return 1;
888 })
889
890 ;; Return 1 if OP is valid for a save_world call in prologue, known to be
891 ;; a PARLLEL.
892 (define_predicate "save_world_operation"
893   (match_code "parallel")
894 {
895   int index;
896   int i;
897   rtx elt;
898   int count = XVECLEN (op, 0);
899
900   if (count != 55)
901     return 0;
902
903   index = 0;
904   if (GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
905       || GET_CODE (XVECEXP (op, 0, index++)) != USE)
906     return 0;
907
908   for (i=1; i <= 18; i++)
909     {
910       elt = XVECEXP (op, 0, index++);
911       if (GET_CODE (elt) != SET
912           || GET_CODE (SET_DEST (elt)) != MEM
913           || ! memory_operand (SET_DEST (elt), DFmode)
914           || GET_CODE (SET_SRC (elt)) != REG
915           || GET_MODE (SET_SRC (elt)) != DFmode)
916         return 0;
917     }
918
919   for (i=1; i <= 12; i++)
920     {
921       elt = XVECEXP (op, 0, index++);
922       if (GET_CODE (elt) != SET
923           || GET_CODE (SET_DEST (elt)) != MEM
924           || GET_CODE (SET_SRC (elt)) != REG
925           || GET_MODE (SET_SRC (elt)) != V4SImode)
926         return 0;
927     }
928
929   for (i=1; i <= 19; i++)
930     {
931       elt = XVECEXP (op, 0, index++);
932       if (GET_CODE (elt) != SET
933           || GET_CODE (SET_DEST (elt)) != MEM
934           || ! memory_operand (SET_DEST (elt), Pmode)
935           || GET_CODE (SET_SRC (elt)) != REG
936           || GET_MODE (SET_SRC (elt)) != Pmode)
937         return 0;
938     }
939
940   elt = XVECEXP (op, 0, index++);
941   if (GET_CODE (elt) != SET
942       || GET_CODE (SET_DEST (elt)) != MEM
943       || ! memory_operand (SET_DEST (elt), Pmode)
944       || GET_CODE (SET_SRC (elt)) != REG
945       || REGNO (SET_SRC (elt)) != CR2_REGNO
946       || GET_MODE (SET_SRC (elt)) != Pmode)
947     return 0;
948
949   if (GET_CODE (XVECEXP (op, 0, index++)) != USE
950       || GET_CODE (XVECEXP (op, 0, index++)) != USE
951       || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER)
952     return 0;
953   return 1;
954 })
955
956 ;; Return 1 if OP is valid for a restore_world call in epilogue, known to be
957 ;; a PARLLEL.
958 (define_predicate "restore_world_operation"
959   (match_code "parallel")
960 {
961   int index;
962   int i;
963   rtx elt;
964   int count = XVECLEN (op, 0);
965
966   if (count != 59)
967     return 0;
968
969   index = 0;
970   if (GET_CODE (XVECEXP (op, 0, index++)) != RETURN
971       || GET_CODE (XVECEXP (op, 0, index++)) != USE
972       || GET_CODE (XVECEXP (op, 0, index++)) != USE
973       || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER)
974     return 0;
975
976   elt = XVECEXP (op, 0, index++);
977   if (GET_CODE (elt) != SET
978       || GET_CODE (SET_SRC (elt)) != MEM
979       || ! memory_operand (SET_SRC (elt), Pmode)
980       || GET_CODE (SET_DEST (elt)) != REG
981       || REGNO (SET_DEST (elt)) != CR2_REGNO
982       || GET_MODE (SET_DEST (elt)) != Pmode)
983     return 0;
984
985   for (i=1; i <= 19; i++)
986     {
987       elt = XVECEXP (op, 0, index++);
988       if (GET_CODE (elt) != SET
989           || GET_CODE (SET_SRC (elt)) != MEM
990           || ! memory_operand (SET_SRC (elt), Pmode)
991           || GET_CODE (SET_DEST (elt)) != REG
992           || GET_MODE (SET_DEST (elt)) != Pmode)
993         return 0;
994     }
995
996   for (i=1; i <= 12; i++)
997     {
998       elt = XVECEXP (op, 0, index++);
999       if (GET_CODE (elt) != SET
1000           || GET_CODE (SET_SRC (elt)) != MEM
1001           || GET_CODE (SET_DEST (elt)) != REG
1002           || GET_MODE (SET_DEST (elt)) != V4SImode)
1003         return 0;
1004     }
1005
1006   for (i=1; i <= 18; i++)
1007     {
1008       elt = XVECEXP (op, 0, index++);
1009       if (GET_CODE (elt) != SET
1010           || GET_CODE (SET_SRC (elt)) != MEM
1011           || ! memory_operand (SET_SRC (elt), DFmode)
1012           || GET_CODE (SET_DEST (elt)) != REG
1013           || GET_MODE (SET_DEST (elt)) != DFmode)
1014         return 0;
1015     }
1016
1017   if (GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
1018       || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
1019       || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
1020       || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
1021       || GET_CODE (XVECEXP (op, 0, index++)) != USE)
1022     return 0;
1023   return 1;
1024 })
1025
1026 ;; Return 1 if OP is valid for a vrsave call, known to be a PARALLEL.
1027 (define_predicate "vrsave_operation"
1028   (match_code "parallel")
1029 {
1030   int count = XVECLEN (op, 0);
1031   unsigned int dest_regno, src_regno;
1032   int i;
1033
1034   if (count <= 1
1035       || GET_CODE (XVECEXP (op, 0, 0)) != SET
1036       || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != REG
1037       || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != UNSPEC_VOLATILE
1038       || XINT (SET_SRC (XVECEXP (op, 0, 0)), 1) != UNSPECV_SET_VRSAVE)
1039     return 0;
1040
1041   dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, 0)));
1042   src_regno  = REGNO (XVECEXP (SET_SRC (XVECEXP (op, 0, 0)), 0, 1));
1043
1044   if (dest_regno != VRSAVE_REGNO || src_regno != VRSAVE_REGNO)
1045     return 0;
1046
1047   for (i = 1; i < count; i++)
1048     {
1049       rtx elt = XVECEXP (op, 0, i);
1050
1051       if (GET_CODE (elt) != CLOBBER
1052           && GET_CODE (elt) != SET)
1053         return 0;
1054     }
1055
1056   return 1;
1057 })
1058
1059 ;; Return 1 if OP is valid for mfcr insn, known to be a PARALLEL.
1060 (define_predicate "mfcr_operation"
1061   (match_code "parallel")
1062 {
1063   int count = XVECLEN (op, 0);
1064   int i;
1065
1066   /* Perform a quick check so we don't blow up below.  */
1067   if (count < 1
1068       || GET_CODE (XVECEXP (op, 0, 0)) != SET
1069       || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != UNSPEC
1070       || XVECLEN (SET_SRC (XVECEXP (op, 0, 0)), 0) != 2)
1071     return 0;
1072
1073   for (i = 0; i < count; i++)
1074     {
1075       rtx exp = XVECEXP (op, 0, i);
1076       rtx unspec;
1077       int maskval;
1078       rtx src_reg;
1079
1080       src_reg = XVECEXP (SET_SRC (exp), 0, 0);
1081
1082       if (GET_CODE (src_reg) != REG
1083           || GET_MODE (src_reg) != CCmode
1084           || ! CR_REGNO_P (REGNO (src_reg)))
1085         return 0;
1086
1087       if (GET_CODE (exp) != SET
1088           || GET_CODE (SET_DEST (exp)) != REG
1089           || GET_MODE (SET_DEST (exp)) != SImode
1090           || ! INT_REGNO_P (REGNO (SET_DEST (exp))))
1091         return 0;
1092       unspec = SET_SRC (exp);
1093       maskval = 1 << (MAX_CR_REGNO - REGNO (src_reg));
1094
1095       if (GET_CODE (unspec) != UNSPEC
1096           || XINT (unspec, 1) != UNSPEC_MOVESI_FROM_CR
1097           || XVECLEN (unspec, 0) != 2
1098           || XVECEXP (unspec, 0, 0) != src_reg
1099           || GET_CODE (XVECEXP (unspec, 0, 1)) != CONST_INT
1100           || INTVAL (XVECEXP (unspec, 0, 1)) != maskval)
1101         return 0;
1102     }
1103   return 1;
1104 })
1105
1106 ;; Return 1 if OP is valid for mtcrf insn, known to be a PARALLEL.
1107 (define_predicate "mtcrf_operation"
1108   (match_code "parallel")
1109 {
1110   int count = XVECLEN (op, 0);
1111   int i;
1112   rtx src_reg;
1113
1114   /* Perform a quick check so we don't blow up below.  */
1115   if (count < 1
1116       || GET_CODE (XVECEXP (op, 0, 0)) != SET
1117       || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != UNSPEC
1118       || XVECLEN (SET_SRC (XVECEXP (op, 0, 0)), 0) != 2)
1119     return 0;
1120   src_reg = XVECEXP (SET_SRC (XVECEXP (op, 0, 0)), 0, 0);
1121
1122   if (GET_CODE (src_reg) != REG
1123       || GET_MODE (src_reg) != SImode
1124       || ! INT_REGNO_P (REGNO (src_reg)))
1125     return 0;
1126
1127   for (i = 0; i < count; i++)
1128     {
1129       rtx exp = XVECEXP (op, 0, i);
1130       rtx unspec;
1131       int maskval;
1132
1133       if (GET_CODE (exp) != SET
1134           || GET_CODE (SET_DEST (exp)) != REG
1135           || GET_MODE (SET_DEST (exp)) != CCmode
1136           || ! CR_REGNO_P (REGNO (SET_DEST (exp))))
1137         return 0;
1138       unspec = SET_SRC (exp);
1139       maskval = 1 << (MAX_CR_REGNO - REGNO (SET_DEST (exp)));
1140
1141       if (GET_CODE (unspec) != UNSPEC
1142           || XINT (unspec, 1) != UNSPEC_MOVESI_TO_CR
1143           || XVECLEN (unspec, 0) != 2
1144           || XVECEXP (unspec, 0, 0) != src_reg
1145           || GET_CODE (XVECEXP (unspec, 0, 1)) != CONST_INT
1146           || INTVAL (XVECEXP (unspec, 0, 1)) != maskval)
1147         return 0;
1148     }
1149   return 1;
1150 })
1151
1152 ;; Return 1 if OP is valid for lmw insn, known to be a PARALLEL.
1153 (define_predicate "lmw_operation"
1154   (match_code "parallel")
1155 {
1156   int count = XVECLEN (op, 0);
1157   unsigned int dest_regno;
1158   rtx src_addr;
1159   unsigned int base_regno;
1160   HOST_WIDE_INT offset;
1161   int i;
1162
1163   /* Perform a quick check so we don't blow up below.  */
1164   if (count <= 1
1165       || GET_CODE (XVECEXP (op, 0, 0)) != SET
1166       || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != REG
1167       || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != MEM)
1168     return 0;
1169
1170   dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, 0)));
1171   src_addr = XEXP (SET_SRC (XVECEXP (op, 0, 0)), 0);
1172
1173   if (dest_regno > 31
1174       || count != 32 - (int) dest_regno)
1175     return 0;
1176
1177   if (legitimate_indirect_address_p (src_addr, 0))
1178     {
1179       offset = 0;
1180       base_regno = REGNO (src_addr);
1181       if (base_regno == 0)
1182         return 0;
1183     }
1184   else if (rs6000_legitimate_offset_address_p (SImode, src_addr, 0))
1185     {
1186       offset = INTVAL (XEXP (src_addr, 1));
1187       base_regno = REGNO (XEXP (src_addr, 0));
1188     }
1189   else
1190     return 0;
1191
1192   for (i = 0; i < count; i++)
1193     {
1194       rtx elt = XVECEXP (op, 0, i);
1195       rtx newaddr;
1196       rtx addr_reg;
1197       HOST_WIDE_INT newoffset;
1198
1199       if (GET_CODE (elt) != SET
1200           || GET_CODE (SET_DEST (elt)) != REG
1201           || GET_MODE (SET_DEST (elt)) != SImode
1202           || REGNO (SET_DEST (elt)) != dest_regno + i
1203           || GET_CODE (SET_SRC (elt)) != MEM
1204           || GET_MODE (SET_SRC (elt)) != SImode)
1205         return 0;
1206       newaddr = XEXP (SET_SRC (elt), 0);
1207       if (legitimate_indirect_address_p (newaddr, 0))
1208         {
1209           newoffset = 0;
1210           addr_reg = newaddr;
1211         }
1212       else if (rs6000_legitimate_offset_address_p (SImode, newaddr, 0))
1213         {
1214           addr_reg = XEXP (newaddr, 0);
1215           newoffset = INTVAL (XEXP (newaddr, 1));
1216         }
1217       else
1218         return 0;
1219       if (REGNO (addr_reg) != base_regno
1220           || newoffset != offset + 4 * i)
1221         return 0;
1222     }
1223
1224   return 1;
1225 })
1226
1227 ;; Return 1 if OP is valid for stmw insn, known to be a PARALLEL.
1228 (define_predicate "stmw_operation"
1229   (match_code "parallel")
1230 {
1231   int count = XVECLEN (op, 0);
1232   unsigned int src_regno;
1233   rtx dest_addr;
1234   unsigned int base_regno;
1235   HOST_WIDE_INT offset;
1236   int i;
1237
1238   /* Perform a quick check so we don't blow up below.  */
1239   if (count <= 1
1240       || GET_CODE (XVECEXP (op, 0, 0)) != SET
1241       || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != MEM
1242       || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != REG)
1243     return 0;
1244
1245   src_regno = REGNO (SET_SRC (XVECEXP (op, 0, 0)));
1246   dest_addr = XEXP (SET_DEST (XVECEXP (op, 0, 0)), 0);
1247
1248   if (src_regno > 31
1249       || count != 32 - (int) src_regno)
1250     return 0;
1251
1252   if (legitimate_indirect_address_p (dest_addr, 0))
1253     {
1254       offset = 0;
1255       base_regno = REGNO (dest_addr);
1256       if (base_regno == 0)
1257         return 0;
1258     }
1259   else if (rs6000_legitimate_offset_address_p (SImode, dest_addr, 0))
1260     {
1261       offset = INTVAL (XEXP (dest_addr, 1));
1262       base_regno = REGNO (XEXP (dest_addr, 0));
1263     }
1264   else
1265     return 0;
1266
1267   for (i = 0; i < count; i++)
1268     {
1269       rtx elt = XVECEXP (op, 0, i);
1270       rtx newaddr;
1271       rtx addr_reg;
1272       HOST_WIDE_INT newoffset;
1273
1274       if (GET_CODE (elt) != SET
1275           || GET_CODE (SET_SRC (elt)) != REG
1276           || GET_MODE (SET_SRC (elt)) != SImode
1277           || REGNO (SET_SRC (elt)) != src_regno + i
1278           || GET_CODE (SET_DEST (elt)) != MEM
1279           || GET_MODE (SET_DEST (elt)) != SImode)
1280         return 0;
1281       newaddr = XEXP (SET_DEST (elt), 0);
1282       if (legitimate_indirect_address_p (newaddr, 0))
1283         {
1284           newoffset = 0;
1285           addr_reg = newaddr;
1286         }
1287       else if (rs6000_legitimate_offset_address_p (SImode, newaddr, 0))
1288         {
1289           addr_reg = XEXP (newaddr, 0);
1290           newoffset = INTVAL (XEXP (newaddr, 1));
1291         }
1292       else
1293         return 0;
1294       if (REGNO (addr_reg) != base_regno
1295           || newoffset != offset + 4 * i)
1296         return 0;
1297     }
1298
1299   return 1;
1300 })