OSDN Git Service

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