OSDN Git Service

a5bad7bfcd4739a37e8ce696b36b1f4e59d30a8c
[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 multiplcation 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       || (GET_MODE_CLASS (mode) != MODE_FLOAT && 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       /* Force constants to memory before reload to utilize
239          compress_float_constant.
240          Avoid this when flag_unsafe_math_optimizations is enabled
241          because RDIV division to reciprocal optimization is not able
242          to regenerate the division.  */
243       if (!reload_in_progress && !reload_completed
244           && !flag_unsafe_math_optimizations)
245         return 0;
246
247       REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
248       REAL_VALUE_TO_TARGET_SINGLE (rv, k[0]);
249
250       return num_insns_constant_wide (k[0]) == 1;
251
252   case DImode:
253     return ((TARGET_POWERPC64
254              && GET_CODE (op) == CONST_DOUBLE && CONST_DOUBLE_LOW (op) == 0)
255             || (num_insns_constant (op, DImode) <= 2));
256
257   case SImode:
258     return 1;
259
260   default:
261     gcc_unreachable ();
262   }
263 })
264
265 ;; Return 1 if the operand is a CONST_VECTOR and can be loaded into a
266 ;; vector register without using memory.
267 (define_predicate "easy_vector_constant"
268   (match_code "const_vector")
269 {
270   int cst, cst2;
271
272   if (!TARGET_ALTIVEC && !TARGET_SPE)
273     return 0;
274
275   if (zero_constant (op, mode)
276       && ((TARGET_ALTIVEC && ALTIVEC_VECTOR_MODE (mode))
277           || (TARGET_SPE && SPE_VECTOR_MODE (mode))))
278     return 1;
279
280   if (GET_MODE_CLASS (mode) != MODE_VECTOR_INT)
281     return 0;
282
283   if (TARGET_SPE && mode == V1DImode)
284     return 0;
285
286   cst  = INTVAL (CONST_VECTOR_ELT (op, 0));
287   cst2 = INTVAL (CONST_VECTOR_ELT (op, 1));
288
289   /* Limit SPE vectors to 15 bits signed.  These we can generate with:
290        li r0, CONSTANT1
291        evmergelo r0, r0, r0
292        li r0, CONSTANT2
293
294      I don't know how efficient it would be to allow bigger constants,
295      considering we'll have an extra 'ori' for every 'li'.  I doubt 5
296      instructions is better than a 64-bit memory load, but I don't
297      have the e500 timing specs.  */
298   if (TARGET_SPE && mode == V2SImode
299       && cst  >= -0x7fff && cst <= 0x7fff
300       && cst2 >= -0x7fff && cst2 <= 0x7fff)
301     return 1;
302
303   if (TARGET_ALTIVEC
304       && easy_vector_same (op, mode))
305     {
306       cst = easy_vector_splat_const (cst, mode);
307       if (EASY_VECTOR_15_ADD_SELF (cst)
308           || EASY_VECTOR_15 (cst))
309         return 1;
310     }
311   return 0;
312 })
313
314 ;; Same as easy_vector_constant but only for EASY_VECTOR_15_ADD_SELF.
315 (define_predicate "easy_vector_constant_add_self"
316   (and (match_code "const_vector")
317        (and (match_test "TARGET_ALTIVEC")
318             (and (match_test "easy_vector_same (op, mode)")
319                  (match_test "EASY_VECTOR_15_ADD_SELF
320                                 (easy_vector_splat_const
321                                   (INTVAL (CONST_VECTOR_ELT (op, 0)),
322                                    mode))")))))
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 "GET_MODE_CLASS (mode) == MODE_FLOAT
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   (and (match_operand 0 "memory_operand")
359        (match_test "REG_P (XEXP (op, 0))
360                     || (GET_CODE (XEXP (op, 0)) == PLUS
361                         && REG_P (XEXP (XEXP (op, 0), 0)) 
362                         && REG_P (XEXP (XEXP (op, 0), 1)))")))
363
364 ;; Return 1 if the operand is a memory operand with an address divisible by 4
365 (define_predicate "word_offset_memref_operand"
366   (and (match_operand 0 "memory_operand")
367        (match_test "GET_CODE (XEXP (op, 0)) != PLUS
368                     || ! REG_P (XEXP (XEXP (op, 0), 0)) 
369                     || GET_CODE (XEXP (XEXP (op, 0), 1)) != CONST_INT
370                     || INTVAL (XEXP (XEXP (op, 0), 1)) % 4 == 0")))
371
372 ;; Used for the destination of the fix_truncdfsi2 expander.
373 ;; If stfiwx will be used, the result goes to memory; otherwise,
374 ;; we're going to emit a store and a load of a subreg, so the dest is a
375 ;; register.
376 (define_predicate "fix_trunc_dest_operand"
377   (if_then_else (match_test "! TARGET_E500_DOUBLE && TARGET_PPC_GFXOPT")
378    (match_operand 0 "memory_operand")
379    (match_operand 0 "gpc_reg_operand")))
380
381 ;; Return 1 if the operand is either a non-special register or can be used
382 ;; as the operand of a `mode' add insn.
383 (define_predicate "add_operand"
384   (if_then_else (match_code "const_int")
385     (match_test "CONST_OK_FOR_LETTER_P (INTVAL (op), 'I')
386                  || CONST_OK_FOR_LETTER_P (INTVAL (op), 'L')")
387     (match_operand 0 "gpc_reg_operand")))
388
389 ;; Return 1 if OP is a constant but not a valid add_operand.
390 (define_predicate "non_add_cint_operand"
391   (and (match_code "const_int")
392        (match_test "!CONST_OK_FOR_LETTER_P (INTVAL (op), 'I')
393                     && !CONST_OK_FOR_LETTER_P (INTVAL (op), 'L')")))
394
395 ;; Return 1 if the operand is a non-special register or a constant that
396 ;; can be used as the operand of an OR or XOR.
397 (define_predicate "logical_operand"
398   (match_code "reg,subreg,const_int,const_double")
399 {
400   HOST_WIDE_INT opl, oph;
401
402   if (gpc_reg_operand (op, mode))
403     return 1;
404
405   if (GET_CODE (op) == CONST_INT)
406     {
407       opl = INTVAL (op) & GET_MODE_MASK (mode);
408
409       if (HOST_BITS_PER_WIDE_INT <= 32
410           && GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT && opl < 0)
411         return 0;
412     }
413   else if (GET_CODE (op) == CONST_DOUBLE)
414     {
415       gcc_assert (GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT);
416
417       opl = CONST_DOUBLE_LOW (op);
418       oph = CONST_DOUBLE_HIGH (op);
419       if (oph != 0)
420         return 0;
421     }
422   else
423     return 0;
424
425   return ((opl & ~ (unsigned HOST_WIDE_INT) 0xffff) == 0
426           || (opl & ~ (unsigned HOST_WIDE_INT) 0xffff0000) == 0);
427 })
428
429 ;; Return 1 if op is a constant that is not a logical operand, but could
430 ;; be split into one.
431 (define_predicate "non_logical_cint_operand"
432   (and (match_code "const_int,const_double")
433        (and (not (match_operand 0 "logical_operand"))
434             (match_operand 0 "reg_or_logical_cint_operand"))))
435
436 ;; For SImode, return 1 if op is a constant that can be encoded in a
437 ;; 32-bit mask (no more than two 1->0 or 0->1 transitions).  Reject
438 ;; all ones and all zeros, since these should have been optimized away
439 ;; and confuse the making of MB and ME.
440 ;; For DImode, return 1 if the operand is a constant that is a
441 ;; PowerPC64 mask (no more than one 1->0 or 0->1 transitions).  Reject
442 ;; all zeros, since zero should have been optimized away and confuses
443 ;; the making of MB and ME.
444 (define_predicate "mask_operand"
445   (match_code "const_int")
446 {
447   HOST_WIDE_INT c, lsb;
448
449   c = INTVAL (op);
450
451   /* Fail in 64-bit mode if the mask wraps around because the upper
452      32-bits of the mask will all be 1s, contrary to GCC's internal view.  */
453   if (mode == SImode && TARGET_POWERPC64 && (c & 0x80000001) == 0x80000001)
454     return 0;
455
456   /* Reject all zeros or all ones in 32-bit mode.  */
457   if (c == 0 || (mode == SImode && c == -1))
458     return 0;
459
460   /* We don't change the number of transitions by inverting,
461      so make sure we start with the LS bit zero.  */
462   if (c & 1)
463     c = ~c;
464
465   /* Find the first transition.  */
466   lsb = c & -c;
467
468   if (mode == SImode)
469     {
470       /* Invert to look for a second transition.  */
471       c = ~c;
472
473       /* Erase first transition.  */
474       c &= -lsb;
475
476       /* Find the second transition (if any).  */
477       lsb = c & -c;
478     }
479
480   /* Match if all the bits above are 1's (or c is zero).  */
481   return c == -lsb;
482 })
483
484 ;; Return 1 for the PowerPC64 rlwinm corner case.
485 (define_predicate "mask_operand_wrap"
486   (match_code "const_int")
487 {
488   HOST_WIDE_INT c, lsb;
489
490   c = INTVAL (op);
491
492   if ((c & 0x80000001) != 0x80000001)
493     return 0;
494
495   c = ~c;
496   if (c == 0)
497     return 0;
498
499   lsb = c & -c;
500   c = ~c;
501   c &= -lsb;
502   lsb = c & -c;
503   return c == -lsb;
504 })
505
506 ;; Like mask_operand, but allow up to three transitions.  This
507 ;; predicate is used by insn patterns that generate two rldicl or
508 ;; rldicr machine insns.
509 (define_predicate "mask64_2_operand"
510   (match_code "const_int")
511 {
512   return mask64_1or2_operand (op, mode, false);
513 })
514
515 ;; Like and_operand, but also match constants that can be implemented
516 ;; with two rldicl or rldicr insns.
517 (define_predicate "and64_2_operand"
518   (ior (and (match_code "const_int")
519             (match_test "mask64_1or2_operand (op, mode, true)"))
520        (if_then_else (match_test "fixed_regs[CR0_REGNO]")
521          (match_operand 0 "gpc_reg_operand")
522          (match_operand 0 "logical_operand"))))
523
524 ;; Return 1 if the operand is either a non-special register or a
525 ;; constant that can be used as the operand of a logical AND.
526 (define_predicate "and_operand"
527   (ior (match_operand 0 "mask_operand")
528        (if_then_else (match_test "fixed_regs[CR0_REGNO]")
529          (match_operand 0 "gpc_reg_operand")
530          (match_operand 0 "logical_operand"))))
531
532 ;; Return 1 if the operand is either a logical operand or a short cint operand.
533 (define_predicate "scc_eq_operand"
534   (ior (match_operand 0 "logical_operand")
535        (match_operand 0 "short_cint_operand")))
536
537 ;; Return 1 if the operand is a general non-special register or memory operand.
538 (define_predicate "reg_or_mem_operand"
539   (if_then_else (match_code "mem")
540      (ior (match_operand 0 "memory_operand")
541           (ior (match_test "macho_lo_sum_memory_operand (op, mode)")
542                (match_operand 0 "volatile_mem_operand")))
543      (match_operand 0 "gpc_reg_operand")))
544
545 ;; Return 1 if the operand is either an easy FP constant or memory or reg.
546 (define_predicate "reg_or_none500mem_operand"
547   (if_then_else (match_code "mem")
548      (and (match_test "!TARGET_E500_DOUBLE")
549           (ior (match_operand 0 "memory_operand")
550                (ior (match_test "macho_lo_sum_memory_operand (op, mode)")
551                     (match_operand 0 "volatile_mem_operand"))))
552      (match_operand 0 "gpc_reg_operand")))
553
554 ;; Return 1 if the operand is CONST_DOUBLE 0, register or memory operand.
555 (define_predicate "zero_reg_mem_operand"
556   (ior (match_operand 0 "zero_fp_constant")
557        (match_operand 0 "reg_or_mem_operand")))
558
559 ;; Return 1 if the operand is a general register or memory operand without
560 ;; pre_inc or pre_dec, which produces invalid form of PowerPC lwa
561 ;; instruction.
562 (define_predicate "lwa_operand"
563   (match_code "reg,subreg,mem")
564 {
565   rtx inner = op;
566
567   if (reload_completed && GET_CODE (inner) == SUBREG)
568     inner = SUBREG_REG (inner);
569
570   return gpc_reg_operand (inner, mode)
571     || (memory_operand (inner, mode)
572         && GET_CODE (XEXP (inner, 0)) != PRE_INC
573         && GET_CODE (XEXP (inner, 0)) != PRE_DEC
574         && (GET_CODE (XEXP (inner, 0)) != PLUS
575             || GET_CODE (XEXP (XEXP (inner, 0), 1)) != CONST_INT
576             || INTVAL (XEXP (XEXP (inner, 0), 1)) % 4 == 0));
577 })
578
579 ;; Return 1 if the operand, used inside a MEM, is a SYMBOL_REF.
580 (define_predicate "symbol_ref_operand"
581   (and (match_code "symbol_ref")
582        (match_test "(mode == VOIDmode || GET_MODE (op) == mode)
583                     && (DEFAULT_ABI != ABI_AIX || SYMBOL_REF_FUNCTION_P (op))")))
584
585 ;; Return 1 if op is an operand that can be loaded via the GOT.
586 ;; or non-special register register field no cr0
587 (define_predicate "got_operand"
588   (match_code "symbol_ref,const,label_ref"))
589
590 ;; Return 1 if op is a simple reference that can be loaded via the GOT,
591 ;; excluding labels involving addition.
592 (define_predicate "got_no_const_operand"
593   (match_code "symbol_ref,label_ref"))
594
595 ;; Return 1 if op is a SYMBOL_REF for a TLS symbol.
596 (define_predicate "rs6000_tls_symbol_ref"
597   (and (match_code "symbol_ref")
598        (match_test "RS6000_SYMBOL_REF_TLS_P (op)")))
599
600 ;; Return 1 if the operand, used inside a MEM, is a valid first argument
601 ;; to CALL.  This is a SYMBOL_REF, a pseudo-register, LR or CTR.
602 (define_predicate "call_operand"
603   (if_then_else (match_code "reg")
604      (match_test "REGNO (op) == LINK_REGISTER_REGNUM
605                   || REGNO (op) == COUNT_REGISTER_REGNUM
606                   || REGNO (op) >= FIRST_PSEUDO_REGISTER")
607      (match_code "symbol_ref")))
608
609 ;; Return 1 if the operand is a SYMBOL_REF for a function known to be in
610 ;; this file.
611 (define_predicate "current_file_function_operand"
612   (and (match_code "symbol_ref")
613        (match_test "(DEFAULT_ABI != ABI_AIX || SYMBOL_REF_FUNCTION_P (op))
614                     && (SYMBOL_REF_LOCAL_P (op)
615                         || (op == XEXP (DECL_RTL (current_function_decl),
616                                                   0)))")))
617
618 ;; Return 1 if this operand is a valid input for a move insn.
619 (define_predicate "input_operand"
620   (match_code "label_ref,symbol_ref,const,high,reg,subreg,mem,
621                const_double,const_vector,const_int,plus")
622 {
623   /* Memory is always valid.  */
624   if (memory_operand (op, mode))
625     return 1;
626
627   /* For floating-point, easy constants are valid.  */
628   if (GET_MODE_CLASS (mode) == MODE_FLOAT
629       && CONSTANT_P (op)
630       && easy_fp_constant (op, mode))
631     return 1;
632
633   /* Allow any integer constant.  */
634   if (GET_MODE_CLASS (mode) == MODE_INT
635       && (GET_CODE (op) == CONST_INT
636           || GET_CODE (op) == CONST_DOUBLE))
637     return 1;
638
639   /* Allow easy vector constants.  */
640   if (GET_CODE (op) == CONST_VECTOR
641       && easy_vector_constant (op, mode))
642     return 1;
643
644   /* For floating-point or multi-word mode, the only remaining valid type
645      is a register.  */
646   if (GET_MODE_CLASS (mode) == MODE_FLOAT
647       || GET_MODE_SIZE (mode) > UNITS_PER_WORD)
648     return register_operand (op, mode);
649
650   /* The only cases left are integral modes one word or smaller (we
651      do not get called for MODE_CC values).  These can be in any
652      register.  */
653   if (register_operand (op, mode))
654     return 1;
655
656   /* A SYMBOL_REF referring to the TOC is valid.  */
657   if (legitimate_constant_pool_address_p (op))
658     return 1;
659
660   /* A constant pool expression (relative to the TOC) is valid */
661   if (toc_relative_expr_p (op))
662     return 1;
663
664   /* V.4 allows SYMBOL_REFs and CONSTs that are in the small data region
665      to be valid.  */
666   if (DEFAULT_ABI == ABI_V4
667       && (GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == CONST)
668       && small_data_operand (op, Pmode))
669     return 1;
670
671   return 0;
672 })
673
674 ;; Return true if OP is an invalid SUBREG operation on the e500.
675 (define_predicate "rs6000_nonimmediate_operand"
676   (match_code "reg,subreg,mem")
677 {
678   if (TARGET_E500_DOUBLE
679       && GET_CODE (op) == SUBREG
680       && invalid_e500_subreg (op, mode))
681     return 0;
682
683   return nonimmediate_operand (op, mode);
684 })
685
686 ;; Return true if operand is boolean operator.
687 (define_predicate "boolean_operator"
688   (match_code "and,ior,xor"))
689
690 ;; Return true if operand is OR-form of boolean operator.
691 (define_predicate "boolean_or_operator"
692   (match_code "ior,xor"))
693
694 ;; Return true if operand is MIN or MAX operator.
695 (define_predicate "min_max_operator"
696   (match_code "smin,smax,umin,umax"))
697
698 ;; Return 1 if OP is a comparison operation that is valid for a branch
699 ;; instruction.  We check the opcode against the mode of the CC value.
700 ;; validate_condition_mode is an assertion.
701 (define_predicate "branch_comparison_operator"
702    (and (match_operand 0 "comparison_operator")
703         (and (match_test "GET_MODE_CLASS (GET_MODE (XEXP (op, 0))) == MODE_CC")
704              (match_test "validate_condition_mode (GET_CODE (op),
705                                                    GET_MODE (XEXP (op, 0))),
706                           1"))))
707
708 ;; Return 1 if OP is a comparison operation that is valid for an SCC insn --
709 ;; it must be a positive comparison.
710 (define_predicate "scc_comparison_operator"
711   (and (match_operand 0 "branch_comparison_operator")
712        (match_code "eq,lt,gt,ltu,gtu,unordered")))
713
714 ;; Return 1 if OP is a comparison operation that is valid for a branch
715 ;; insn, which is true if the corresponding bit in the CC register is set.
716 (define_predicate "branch_positive_comparison_operator"
717   (and (match_operand 0 "branch_comparison_operator")
718        (match_code "eq,lt,gt,ltu,gtu,unordered")))
719
720 ;; Return 1 is OP is a comparison operation that is valid for a trap insn.
721 (define_predicate "trap_comparison_operator"
722    (and (match_operand 0 "comparison_operator")
723         (match_code "eq,ne,le,lt,ge,gt,leu,ltu,geu,gtu")))
724
725 ;; Return 1 if OP is a load multiple operation, known to be a PARALLEL.
726 (define_predicate "load_multiple_operation"
727   (match_code "parallel")
728 {
729   int count = XVECLEN (op, 0);
730   unsigned int dest_regno;
731   rtx src_addr;
732   int i;
733
734   /* Perform a quick check so we don't blow up below.  */
735   if (count <= 1
736       || GET_CODE (XVECEXP (op, 0, 0)) != SET
737       || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != REG
738       || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != MEM)
739     return 0;
740
741   dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, 0)));
742   src_addr = XEXP (SET_SRC (XVECEXP (op, 0, 0)), 0);
743
744   for (i = 1; i < count; i++)
745     {
746       rtx elt = XVECEXP (op, 0, i);
747
748       if (GET_CODE (elt) != SET
749           || GET_CODE (SET_DEST (elt)) != REG
750           || GET_MODE (SET_DEST (elt)) != SImode
751           || REGNO (SET_DEST (elt)) != dest_regno + i
752           || GET_CODE (SET_SRC (elt)) != MEM
753           || GET_MODE (SET_SRC (elt)) != SImode
754           || GET_CODE (XEXP (SET_SRC (elt), 0)) != PLUS
755           || ! rtx_equal_p (XEXP (XEXP (SET_SRC (elt), 0), 0), src_addr)
756           || GET_CODE (XEXP (XEXP (SET_SRC (elt), 0), 1)) != CONST_INT
757           || INTVAL (XEXP (XEXP (SET_SRC (elt), 0), 1)) != i * 4)
758         return 0;
759     }
760
761   return 1;
762 })
763
764 ;; Return 1 if OP is a store multiple operation, known to be a PARALLEL.
765 ;; The second vector element is a CLOBBER.
766 (define_predicate "store_multiple_operation"
767   (match_code "parallel")
768 {
769   int count = XVECLEN (op, 0) - 1;
770   unsigned int src_regno;
771   rtx dest_addr;
772   int i;
773
774   /* Perform a quick check so we don't blow up below.  */
775   if (count <= 1
776       || GET_CODE (XVECEXP (op, 0, 0)) != SET
777       || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != MEM
778       || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != REG)
779     return 0;
780
781   src_regno = REGNO (SET_SRC (XVECEXP (op, 0, 0)));
782   dest_addr = XEXP (SET_DEST (XVECEXP (op, 0, 0)), 0);
783
784   for (i = 1; i < count; i++)
785     {
786       rtx elt = XVECEXP (op, 0, i + 1);
787
788       if (GET_CODE (elt) != SET
789           || GET_CODE (SET_SRC (elt)) != REG
790           || GET_MODE (SET_SRC (elt)) != SImode
791           || REGNO (SET_SRC (elt)) != src_regno + i
792           || GET_CODE (SET_DEST (elt)) != MEM
793           || GET_MODE (SET_DEST (elt)) != SImode
794           || GET_CODE (XEXP (SET_DEST (elt), 0)) != PLUS
795           || ! rtx_equal_p (XEXP (XEXP (SET_DEST (elt), 0), 0), dest_addr)
796           || GET_CODE (XEXP (XEXP (SET_DEST (elt), 0), 1)) != CONST_INT
797           || INTVAL (XEXP (XEXP (SET_DEST (elt), 0), 1)) != i * 4)
798         return 0;
799     }
800
801   return 1;
802 })
803
804 ;; Return 1 if OP is valid for a save_world call in prologue, known to be
805 ;; a PARLLEL.
806 (define_predicate "save_world_operation"
807   (match_code "parallel")
808 {
809   int index;
810   int i;
811   rtx elt;
812   int count = XVECLEN (op, 0);
813
814   if (count != 55)
815     return 0;
816
817   index = 0;
818   if (GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
819       || GET_CODE (XVECEXP (op, 0, index++)) != USE)
820     return 0;
821
822   for (i=1; i <= 18; i++)
823     {
824       elt = XVECEXP (op, 0, index++);
825       if (GET_CODE (elt) != SET
826           || GET_CODE (SET_DEST (elt)) != MEM
827           || ! memory_operand (SET_DEST (elt), DFmode)
828           || GET_CODE (SET_SRC (elt)) != REG
829           || GET_MODE (SET_SRC (elt)) != DFmode)
830         return 0;
831     }
832
833   for (i=1; i <= 12; i++)
834     {
835       elt = XVECEXP (op, 0, index++);
836       if (GET_CODE (elt) != SET
837           || GET_CODE (SET_DEST (elt)) != MEM
838           || GET_CODE (SET_SRC (elt)) != REG
839           || GET_MODE (SET_SRC (elt)) != V4SImode)
840         return 0;
841     }
842
843   for (i=1; i <= 19; i++)
844     {
845       elt = XVECEXP (op, 0, index++);
846       if (GET_CODE (elt) != SET
847           || GET_CODE (SET_DEST (elt)) != MEM
848           || ! memory_operand (SET_DEST (elt), Pmode)
849           || GET_CODE (SET_SRC (elt)) != REG
850           || GET_MODE (SET_SRC (elt)) != Pmode)
851         return 0;
852     }
853
854   elt = XVECEXP (op, 0, index++);
855   if (GET_CODE (elt) != SET
856       || GET_CODE (SET_DEST (elt)) != MEM
857       || ! memory_operand (SET_DEST (elt), Pmode)
858       || GET_CODE (SET_SRC (elt)) != REG
859       || REGNO (SET_SRC (elt)) != CR2_REGNO
860       || GET_MODE (SET_SRC (elt)) != Pmode)
861     return 0;
862
863   if (GET_CODE (XVECEXP (op, 0, index++)) != USE
864       || GET_CODE (XVECEXP (op, 0, index++)) != USE
865       || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER)
866     return 0;
867   return 1;
868 })
869
870 ;; Return 1 if OP is valid for a restore_world call in epilogue, known to be
871 ;; a PARLLEL.
872 (define_predicate "restore_world_operation"
873   (match_code "parallel")
874 {
875   int index;
876   int i;
877   rtx elt;
878   int count = XVECLEN (op, 0);
879
880   if (count != 59)
881     return 0;
882
883   index = 0;
884   if (GET_CODE (XVECEXP (op, 0, index++)) != RETURN
885       || GET_CODE (XVECEXP (op, 0, index++)) != USE
886       || GET_CODE (XVECEXP (op, 0, index++)) != USE
887       || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER)
888     return 0;
889
890   elt = XVECEXP (op, 0, index++);
891   if (GET_CODE (elt) != SET
892       || GET_CODE (SET_SRC (elt)) != MEM
893       || ! memory_operand (SET_SRC (elt), Pmode)
894       || GET_CODE (SET_DEST (elt)) != REG
895       || REGNO (SET_DEST (elt)) != CR2_REGNO
896       || GET_MODE (SET_DEST (elt)) != Pmode)
897     return 0;
898
899   for (i=1; i <= 19; i++)
900     {
901       elt = XVECEXP (op, 0, index++);
902       if (GET_CODE (elt) != SET
903           || GET_CODE (SET_SRC (elt)) != MEM
904           || ! memory_operand (SET_SRC (elt), Pmode)
905           || GET_CODE (SET_DEST (elt)) != REG
906           || GET_MODE (SET_DEST (elt)) != Pmode)
907         return 0;
908     }
909
910   for (i=1; i <= 12; i++)
911     {
912       elt = XVECEXP (op, 0, index++);
913       if (GET_CODE (elt) != SET
914           || GET_CODE (SET_SRC (elt)) != MEM
915           || GET_CODE (SET_DEST (elt)) != REG
916           || GET_MODE (SET_DEST (elt)) != V4SImode)
917         return 0;
918     }
919
920   for (i=1; i <= 18; i++)
921     {
922       elt = XVECEXP (op, 0, index++);
923       if (GET_CODE (elt) != SET
924           || GET_CODE (SET_SRC (elt)) != MEM
925           || ! memory_operand (SET_SRC (elt), DFmode)
926           || GET_CODE (SET_DEST (elt)) != REG
927           || GET_MODE (SET_DEST (elt)) != DFmode)
928         return 0;
929     }
930
931   if (GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
932       || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
933       || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
934       || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
935       || GET_CODE (XVECEXP (op, 0, index++)) != USE)
936     return 0;
937   return 1;
938 })
939
940 ;; Return 1 if OP is valid for a vrsave call, known to be a PARALLEL.
941 (define_predicate "vrsave_operation"
942   (match_code "parallel")
943 {
944   int count = XVECLEN (op, 0);
945   unsigned int dest_regno, src_regno;
946   int i;
947
948   if (count <= 1
949       || GET_CODE (XVECEXP (op, 0, 0)) != SET
950       || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != REG
951       || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != UNSPEC_VOLATILE)
952     return 0;
953
954   dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, 0)));
955   src_regno  = REGNO (SET_SRC (XVECEXP (op, 0, 0)));
956
957   if (dest_regno != VRSAVE_REGNO
958       && src_regno != VRSAVE_REGNO)
959     return 0;
960
961   for (i = 1; i < count; i++)
962     {
963       rtx elt = XVECEXP (op, 0, i);
964
965       if (GET_CODE (elt) != CLOBBER
966           && GET_CODE (elt) != SET)
967         return 0;
968     }
969
970   return 1;
971 })
972
973 ;; Return 1 if OP is valid for mfcr insn, known to be a PARALLEL.
974 (define_predicate "mfcr_operation"
975   (match_code "parallel")
976 {
977   int count = XVECLEN (op, 0);
978   int i;
979
980   /* Perform a quick check so we don't blow up below.  */
981   if (count < 1
982       || GET_CODE (XVECEXP (op, 0, 0)) != SET
983       || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != UNSPEC
984       || XVECLEN (SET_SRC (XVECEXP (op, 0, 0)), 0) != 2)
985     return 0;
986
987   for (i = 0; i < count; i++)
988     {
989       rtx exp = XVECEXP (op, 0, i);
990       rtx unspec;
991       int maskval;
992       rtx src_reg;
993
994       src_reg = XVECEXP (SET_SRC (exp), 0, 0);
995
996       if (GET_CODE (src_reg) != REG
997           || GET_MODE (src_reg) != CCmode
998           || ! CR_REGNO_P (REGNO (src_reg)))
999         return 0;
1000
1001       if (GET_CODE (exp) != SET
1002           || GET_CODE (SET_DEST (exp)) != REG
1003           || GET_MODE (SET_DEST (exp)) != SImode
1004           || ! INT_REGNO_P (REGNO (SET_DEST (exp))))
1005         return 0;
1006       unspec = SET_SRC (exp);
1007       maskval = 1 << (MAX_CR_REGNO - REGNO (src_reg));
1008
1009       if (GET_CODE (unspec) != UNSPEC
1010           || XINT (unspec, 1) != UNSPEC_MOVESI_FROM_CR
1011           || XVECLEN (unspec, 0) != 2
1012           || XVECEXP (unspec, 0, 0) != src_reg
1013           || GET_CODE (XVECEXP (unspec, 0, 1)) != CONST_INT
1014           || INTVAL (XVECEXP (unspec, 0, 1)) != maskval)
1015         return 0;
1016     }
1017   return 1;
1018 })
1019
1020 ;; Return 1 if OP is valid for mtcrf insn, known to be a PARALLEL.
1021 (define_predicate "mtcrf_operation"
1022   (match_code "parallel")
1023 {
1024   int count = XVECLEN (op, 0);
1025   int i;
1026   rtx src_reg;
1027
1028   /* Perform a quick check so we don't blow up below.  */
1029   if (count < 1
1030       || GET_CODE (XVECEXP (op, 0, 0)) != SET
1031       || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != UNSPEC
1032       || XVECLEN (SET_SRC (XVECEXP (op, 0, 0)), 0) != 2)
1033     return 0;
1034   src_reg = XVECEXP (SET_SRC (XVECEXP (op, 0, 0)), 0, 0);
1035
1036   if (GET_CODE (src_reg) != REG
1037       || GET_MODE (src_reg) != SImode
1038       || ! INT_REGNO_P (REGNO (src_reg)))
1039     return 0;
1040
1041   for (i = 0; i < count; i++)
1042     {
1043       rtx exp = XVECEXP (op, 0, i);
1044       rtx unspec;
1045       int maskval;
1046
1047       if (GET_CODE (exp) != SET
1048           || GET_CODE (SET_DEST (exp)) != REG
1049           || GET_MODE (SET_DEST (exp)) != CCmode
1050           || ! CR_REGNO_P (REGNO (SET_DEST (exp))))
1051         return 0;
1052       unspec = SET_SRC (exp);
1053       maskval = 1 << (MAX_CR_REGNO - REGNO (SET_DEST (exp)));
1054
1055       if (GET_CODE (unspec) != UNSPEC
1056           || XINT (unspec, 1) != UNSPEC_MOVESI_TO_CR
1057           || XVECLEN (unspec, 0) != 2
1058           || XVECEXP (unspec, 0, 0) != src_reg
1059           || GET_CODE (XVECEXP (unspec, 0, 1)) != CONST_INT
1060           || INTVAL (XVECEXP (unspec, 0, 1)) != maskval)
1061         return 0;
1062     }
1063   return 1;
1064 })
1065
1066 ;; Return 1 if OP is valid for lmw insn, known to be a PARALLEL.
1067 (define_predicate "lmw_operation"
1068   (match_code "parallel")
1069 {
1070   int count = XVECLEN (op, 0);
1071   unsigned int dest_regno;
1072   rtx src_addr;
1073   unsigned int base_regno;
1074   HOST_WIDE_INT offset;
1075   int i;
1076
1077   /* Perform a quick check so we don't blow up below.  */
1078   if (count <= 1
1079       || GET_CODE (XVECEXP (op, 0, 0)) != SET
1080       || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != REG
1081       || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != MEM)
1082     return 0;
1083
1084   dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, 0)));
1085   src_addr = XEXP (SET_SRC (XVECEXP (op, 0, 0)), 0);
1086
1087   if (dest_regno > 31
1088       || count != 32 - (int) dest_regno)
1089     return 0;
1090
1091   if (legitimate_indirect_address_p (src_addr, 0))
1092     {
1093       offset = 0;
1094       base_regno = REGNO (src_addr);
1095       if (base_regno == 0)
1096         return 0;
1097     }
1098   else if (rs6000_legitimate_offset_address_p (SImode, src_addr, 0))
1099     {
1100       offset = INTVAL (XEXP (src_addr, 1));
1101       base_regno = REGNO (XEXP (src_addr, 0));
1102     }
1103   else
1104     return 0;
1105
1106   for (i = 0; i < count; i++)
1107     {
1108       rtx elt = XVECEXP (op, 0, i);
1109       rtx newaddr;
1110       rtx addr_reg;
1111       HOST_WIDE_INT newoffset;
1112
1113       if (GET_CODE (elt) != SET
1114           || GET_CODE (SET_DEST (elt)) != REG
1115           || GET_MODE (SET_DEST (elt)) != SImode
1116           || REGNO (SET_DEST (elt)) != dest_regno + i
1117           || GET_CODE (SET_SRC (elt)) != MEM
1118           || GET_MODE (SET_SRC (elt)) != SImode)
1119         return 0;
1120       newaddr = XEXP (SET_SRC (elt), 0);
1121       if (legitimate_indirect_address_p (newaddr, 0))
1122         {
1123           newoffset = 0;
1124           addr_reg = newaddr;
1125         }
1126       else if (rs6000_legitimate_offset_address_p (SImode, newaddr, 0))
1127         {
1128           addr_reg = XEXP (newaddr, 0);
1129           newoffset = INTVAL (XEXP (newaddr, 1));
1130         }
1131       else
1132         return 0;
1133       if (REGNO (addr_reg) != base_regno
1134           || newoffset != offset + 4 * i)
1135         return 0;
1136     }
1137
1138   return 1;
1139 })
1140
1141 ;; Return 1 if OP is valid for stmw insn, known to be a PARALLEL.
1142 (define_predicate "stmw_operation"
1143   (match_code "parallel")
1144 {
1145   int count = XVECLEN (op, 0);
1146   unsigned int src_regno;
1147   rtx dest_addr;
1148   unsigned int base_regno;
1149   HOST_WIDE_INT offset;
1150   int i;
1151
1152   /* Perform a quick check so we don't blow up below.  */
1153   if (count <= 1
1154       || GET_CODE (XVECEXP (op, 0, 0)) != SET
1155       || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != MEM
1156       || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != REG)
1157     return 0;
1158
1159   src_regno = REGNO (SET_SRC (XVECEXP (op, 0, 0)));
1160   dest_addr = XEXP (SET_DEST (XVECEXP (op, 0, 0)), 0);
1161
1162   if (src_regno > 31
1163       || count != 32 - (int) src_regno)
1164     return 0;
1165
1166   if (legitimate_indirect_address_p (dest_addr, 0))
1167     {
1168       offset = 0;
1169       base_regno = REGNO (dest_addr);
1170       if (base_regno == 0)
1171         return 0;
1172     }
1173   else if (rs6000_legitimate_offset_address_p (SImode, dest_addr, 0))
1174     {
1175       offset = INTVAL (XEXP (dest_addr, 1));
1176       base_regno = REGNO (XEXP (dest_addr, 0));
1177     }
1178   else
1179     return 0;
1180
1181   for (i = 0; i < count; i++)
1182     {
1183       rtx elt = XVECEXP (op, 0, i);
1184       rtx newaddr;
1185       rtx addr_reg;
1186       HOST_WIDE_INT newoffset;
1187
1188       if (GET_CODE (elt) != SET
1189           || GET_CODE (SET_SRC (elt)) != REG
1190           || GET_MODE (SET_SRC (elt)) != SImode
1191           || REGNO (SET_SRC (elt)) != src_regno + i
1192           || GET_CODE (SET_DEST (elt)) != MEM
1193           || GET_MODE (SET_DEST (elt)) != SImode)
1194         return 0;
1195       newaddr = XEXP (SET_DEST (elt), 0);
1196       if (legitimate_indirect_address_p (newaddr, 0))
1197         {
1198           newoffset = 0;
1199           addr_reg = newaddr;
1200         }
1201       else if (rs6000_legitimate_offset_address_p (SImode, newaddr, 0))
1202         {
1203           addr_reg = XEXP (newaddr, 0);
1204           newoffset = INTVAL (XEXP (newaddr, 1));
1205         }
1206       else
1207         return 0;
1208       if (REGNO (addr_reg) != base_regno
1209           || newoffset != offset + 4 * i)
1210         return 0;
1211     }
1212
1213   return 1;
1214 })