* config/alpha/alpha.md, arm/arm.c, darwin.c, frv/frv.md,
[official-gcc.git] / gcc / config / frv / predicates.md
blob6320fd1688bb0a4eeb15fddbe82fb5b48128799d
1 ;; Predicate definitions for Frv.
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.
11 ;; GCC is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ;; GNU General Public License for more details.
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GCC; see the file COPYING.  If not, write to
18 ;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
19 ;; Boston, MA 02110-1301, USA.
21 ;; Return true if operand is a GPR register.
23 (define_predicate "integer_register_operand"
24   (match_code "reg,subreg")
26   if (GET_MODE (op) != mode && mode != VOIDmode)
27     return FALSE;
29   if (GET_CODE (op) == SUBREG)
30     {
31       if (GET_CODE (SUBREG_REG (op)) != REG)
32         return register_operand (op, mode);
34       op = SUBREG_REG (op);
35     }
37   if (GET_CODE (op) != REG)
38     return FALSE;
40   return GPR_AP_OR_PSEUDO_P (REGNO (op));
43 ;; Return 1 is OP is a memory operand, or will be turned into one by
44 ;; reload.
46 (define_predicate "frv_load_operand"
47   (match_code "reg,subreg,mem")
49   if (GET_MODE (op) != mode && mode != VOIDmode)
50     return FALSE;
52   if (reload_in_progress)
53     {
54       rtx tmp = op;
55       if (GET_CODE (tmp) == SUBREG)
56         tmp = SUBREG_REG (tmp);
57       if (GET_CODE (tmp) == REG
58           && REGNO (tmp) >= FIRST_PSEUDO_REGISTER)
59         op = reg_equiv_memory_loc[REGNO (tmp)];
60     }
62   return op && memory_operand (op, mode);
65 ;; Return true if operand is a GPR register.  Do not allow SUBREG's
66 ;; here, in order to prevent a combine bug.
68 (define_predicate "gpr_no_subreg_operand"
69   (match_code "reg")
71   if (GET_MODE (op) != mode && mode != VOIDmode)
72     return FALSE;
74   if (GET_CODE (op) != REG)
75     return FALSE;
77   return GPR_OR_PSEUDO_P (REGNO (op));
80 ;; Return 1 if operand is a GPR register or a FPR register.
82 (define_predicate "gpr_or_fpr_operand"
83   (match_code "reg,subreg")
85   int regno;
87   if (GET_MODE (op) != mode && mode != VOIDmode)
88     return FALSE;
90   if (GET_CODE (op) == SUBREG)
91     {
92       if (GET_CODE (SUBREG_REG (op)) != REG)
93         return register_operand (op, mode);
95       op = SUBREG_REG (op);
96     }
98   if (GET_CODE (op) != REG)
99     return FALSE;
101   regno = REGNO (op);
102   if (GPR_P (regno) || FPR_P (regno) || regno >= FIRST_PSEUDO_REGISTER)
103     return TRUE;
105   return FALSE;
108 ;; Return 1 if operand is a GPR register or 12 bit signed immediate.
110 (define_predicate "gpr_or_int12_operand"
111   (match_code "reg,subreg,const_int,const")
113   if (GET_CODE (op) == CONST_INT)
114     return IN_RANGE_P (INTVAL (op), -2048, 2047);
116   if (got12_operand (op, mode))
117     return true;
119   if (GET_MODE (op) != mode && mode != VOIDmode)
120     return FALSE;
122   if (GET_CODE (op) == SUBREG)
123     {
124       if (GET_CODE (SUBREG_REG (op)) != REG)
125         return register_operand (op, mode);
127       op = SUBREG_REG (op);
128     }
130   if (GET_CODE (op) != REG)
131     return FALSE;
133   return GPR_OR_PSEUDO_P (REGNO (op));
136 ;; Return 1 if operand is a GPR register, or a FPR register, or a 12
137 ;; bit signed immediate.
139 (define_predicate "gpr_fpr_or_int12_operand"
140   (match_code "reg,subreg,const_int")
142   int regno;
144   if (GET_CODE (op) == CONST_INT)
145     return IN_RANGE_P (INTVAL (op), -2048, 2047);
147   if (GET_MODE (op) != mode && mode != VOIDmode)
148     return FALSE;
150   if (GET_CODE (op) == SUBREG)
151     {
152       if (GET_CODE (SUBREG_REG (op)) != REG)
153         return register_operand (op, mode);
155       op = SUBREG_REG (op);
156     }
158   if (GET_CODE (op) != REG)
159     return FALSE;
161   regno = REGNO (op);
162   if (GPR_P (regno) || FPR_P (regno) || regno >= FIRST_PSEUDO_REGISTER)
163     return TRUE;
165   return FALSE;
168 ;; Return 1 if operand is a register or 10 bit signed immediate.
170 (define_predicate "gpr_or_int10_operand"
171   (match_code "reg,subreg,const_int")
173   if (GET_CODE (op) == CONST_INT)
174     return IN_RANGE_P (INTVAL (op), -512, 511);
176   if (GET_MODE (op) != mode && mode != VOIDmode)
177     return FALSE;
179   if (GET_CODE (op) == SUBREG)
180     {
181       if (GET_CODE (SUBREG_REG (op)) != REG)
182         return register_operand (op, mode);
184       op = SUBREG_REG (op);
185     }
187   if (GET_CODE (op) != REG)
188     return FALSE;
190   return GPR_OR_PSEUDO_P (REGNO (op));
193 ;; Return 1 if operand is a register or an integer immediate.
195 (define_predicate "gpr_or_int_operand"
196   (match_code "reg,subreg,const_int")
198   if (GET_CODE (op) == CONST_INT)
199     return TRUE;
201   if (GET_MODE (op) != mode && mode != VOIDmode)
202     return FALSE;
204   if (GET_CODE (op) == SUBREG)
205     {
206       if (GET_CODE (SUBREG_REG (op)) != REG)
207         return register_operand (op, mode);
209       op = SUBREG_REG (op);
210     }
212   if (GET_CODE (op) != REG)
213     return FALSE;
215   return GPR_OR_PSEUDO_P (REGNO (op));
218 ;; Return true if operand is something that can be an input for a move
219 ;; operation.
221 (define_predicate "move_source_operand"
222   (match_code "reg,subreg,const_int,mem,const_double,const,symbol_ref,label_ref")
224   rtx subreg;
225   enum rtx_code code;
227   switch (GET_CODE (op))
228     {
229     default:
230       break;
232     case CONST_INT:
233     case CONST_DOUBLE:
234       return immediate_operand (op, mode);
236     case SUBREG:
237       if (GET_MODE (op) != mode && mode != VOIDmode)
238         return FALSE;
240       subreg = SUBREG_REG (op);
241       code = GET_CODE (subreg);
242       if (code == MEM)
243         return frv_legitimate_address_p (mode, XEXP (subreg, 0),
244                                          reload_completed, FALSE, FALSE);
246       return (code == REG);
248     case REG:
249       if (GET_MODE (op) != mode && mode != VOIDmode)
250         return FALSE;
252       return TRUE;
254     case MEM:
255       return frv_legitimate_memory_operand (op, mode, FALSE);
256     }
258   return FALSE;
261 ;; Return true if operand is something that can be an output for a
262 ;; move operation.
264 (define_predicate "move_destination_operand"
265   (match_code "reg,subreg,mem")
267   rtx subreg;
268   enum rtx_code code;
270   switch (GET_CODE (op))
271     {
272     default:
273       break;
275     case SUBREG:
276       if (GET_MODE (op) != mode && mode != VOIDmode)
277         return FALSE;
279       subreg = SUBREG_REG (op);
280       code = GET_CODE (subreg);
281       if (code == MEM)
282         return frv_legitimate_address_p (mode, XEXP (subreg, 0),
283                                          reload_completed, FALSE, FALSE);
285       return (code == REG);
287     case REG:
288       if (GET_MODE (op) != mode && mode != VOIDmode)
289         return FALSE;
291       return TRUE;
293     case MEM:
294       return frv_legitimate_memory_operand (op, mode, FALSE);
295     }
297   return FALSE;
300 ;; Return true if we the operand is a valid destination for a movcc_fp
301 ;; instruction.  This means rejecting fcc_operands, since we need
302 ;; scratch registers to write to them.
304 (define_predicate "movcc_fp_destination_operand"
305   (match_code "reg,subreg,mem")
307   if (fcc_operand (op, mode))
308     return FALSE;
310   return move_destination_operand (op, mode);
313 ;; Return true if operand is something that can be an input for a
314 ;; conditional move operation.
316 (define_predicate "condexec_source_operand"
317   (match_code "reg,subreg,const_int,mem,const_double")
319   rtx subreg;
320   enum rtx_code code;
322   switch (GET_CODE (op))
323     {
324     default:
325       break;
327     case CONST_INT:
328     case CONST_DOUBLE:
329       return ZERO_P (op);
331     case SUBREG:
332       if (GET_MODE (op) != mode && mode != VOIDmode)
333         return FALSE;
335       subreg = SUBREG_REG (op);
336       code = GET_CODE (subreg);
337       if (code == MEM)
338         return frv_legitimate_address_p (mode, XEXP (subreg, 0),
339                                          reload_completed, TRUE, FALSE);
341       return (code == REG);
343     case REG:
344       if (GET_MODE (op) != mode && mode != VOIDmode)
345         return FALSE;
347       return TRUE;
349     case MEM:
350       return frv_legitimate_memory_operand (op, mode, TRUE);
351     }
353   return FALSE;
356 ;; Return true if operand is something that can be an output for a
357 ;; conditional move operation.
359 (define_predicate "condexec_dest_operand"
360   (match_code "reg,subreg,mem")
362   rtx subreg;
363   enum rtx_code code;
365   switch (GET_CODE (op))
366     {
367     default:
368       break;
370     case SUBREG:
371       if (GET_MODE (op) != mode && mode != VOIDmode)
372         return FALSE;
374       subreg = SUBREG_REG (op);
375       code = GET_CODE (subreg);
376       if (code == MEM)
377         return frv_legitimate_address_p (mode, XEXP (subreg, 0),
378                                          reload_completed, TRUE, FALSE);
380       return (code == REG);
382     case REG:
383       if (GET_MODE (op) != mode && mode != VOIDmode)
384         return FALSE;
386       return TRUE;
388     case MEM:
389       return frv_legitimate_memory_operand (op, mode, TRUE);
390     }
392   return FALSE;
395 ;; Return true if operand is a register of any flavor or a 0 of the
396 ;; appropriate type.
398 (define_predicate "reg_or_0_operand"
399   (match_code "reg,subreg,const_int")
401   switch (GET_CODE (op))
402     {
403     default:
404       break;
406     case REG:
407     case SUBREG:
408       if (GET_MODE (op) != mode && mode != VOIDmode)
409         return FALSE;
411       return register_operand (op, mode);
413     case CONST_INT:
414     case CONST_DOUBLE:
415       return ZERO_P (op);
416     }
418   return FALSE;
421 ;; Return true if operand is the link register.
423 (define_predicate "lr_operand"
424   (match_code "reg")
426   if (GET_CODE (op) != REG)
427     return FALSE;
429   if (GET_MODE (op) != mode && mode != VOIDmode)
430     return FALSE;
432   if (REGNO (op) != LR_REGNO && REGNO (op) < FIRST_PSEUDO_REGISTER)
433     return FALSE;
435   return TRUE;
438 ;; Return true if operand is a gpr register or a valid memory operand.
440 (define_predicate "gpr_or_memory_operand"
441   (match_code "reg,subreg,mem")
443   return (integer_register_operand (op, mode)
444           || frv_legitimate_memory_operand (op, mode, FALSE));
447 ;; Return true if operand is a gpr register, a valid memory operand,
448 ;; or a memory operand that can be made valid using an additional gpr
449 ;; register.
451 (define_predicate "gpr_or_memory_operand_with_scratch"
452   (match_code "reg,subreg,mem")
454   rtx addr;
456   if (gpr_or_memory_operand (op, mode))
457     return TRUE;
459   if (GET_CODE (op) != MEM)
460     return FALSE;
462   if (GET_MODE (op) != mode)
463     return FALSE;
465   addr = XEXP (op, 0);
467   if (GET_CODE (addr) != PLUS)
468     return FALSE;
469       
470   if (!integer_register_operand (XEXP (addr, 0), Pmode))
471     return FALSE;
473   if (GET_CODE (XEXP (addr, 1)) != CONST_INT)
474     return FALSE;
476   return TRUE;
479 ;; Return true if operand is a fpr register or a valid memory
480 ;; operation.
482 (define_predicate "fpr_or_memory_operand"
483   (match_code "reg,subreg,mem")
485   return (fpr_operand (op, mode)
486           || frv_legitimate_memory_operand (op, mode, FALSE));
489 ;; Return 1 if operand is a 12 bit signed immediate.
491 (define_predicate "int12_operand"
492   (match_code "const_int")
494   if (GET_CODE (op) != CONST_INT)
495     return FALSE;
497   return IN_RANGE_P (INTVAL (op), -2048, 2047);
500 ;; Return 1 if operand is an integer constant that takes 2
501 ;; instructions to load up and can be split into sethi/setlo
502 ;; instructions..
504 (define_predicate "int_2word_operand"
505   (match_code "const_int,const_double,symbol_ref,label_ref,const")
507   HOST_WIDE_INT value;
508   REAL_VALUE_TYPE rv;
509   long l;
511   switch (GET_CODE (op))
512     {
513     default:
514       break;
516     case LABEL_REF:
517       if (TARGET_FDPIC)
518         return FALSE;
519       
520       return (flag_pic == 0);
522     case CONST:
523       if (flag_pic || TARGET_FDPIC)
524         return FALSE;
526       op = XEXP (op, 0);
527       if (GET_CODE (op) == PLUS && GET_CODE (XEXP (op, 1)) == CONST_INT)
528         op = XEXP (op, 0);
529       return GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == LABEL_REF;
531     case SYMBOL_REF:
532       if (TARGET_FDPIC)
533         return FALSE;
534       
535       /* small data references are already 1 word */
536       return (flag_pic == 0) && (! SYMBOL_REF_SMALL_P (op));
538     case CONST_INT:
539       return ! IN_RANGE_P (INTVAL (op), -32768, 32767);
541     case CONST_DOUBLE:
542       if (GET_MODE (op) == SFmode)
543         {
544           REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
545           REAL_VALUE_TO_TARGET_SINGLE (rv, l);
546           value = l;
547           return ! IN_RANGE_P (value, -32768, 32767);
548         }
549       else if (GET_MODE (op) == VOIDmode)
550         {
551           value = CONST_DOUBLE_LOW (op);
552           return ! IN_RANGE_P (value, -32768, 32767);
553         }
554       break;
555     }
557   return FALSE;
560 ;; Return true if operand is the uClinux PIC register.
562 (define_predicate "fdpic_operand"
563   (match_code "reg")
565   if (!TARGET_FDPIC)
566     return FALSE;
568   if (GET_CODE (op) != REG)
569     return FALSE;
571   if (GET_MODE (op) != mode && mode != VOIDmode)
572     return FALSE;
574   if (REGNO (op) != FDPIC_REGNO && REGNO (op) < FIRST_PSEUDO_REGISTER)
575     return FALSE;
577   return TRUE;
580 ;; TODO: Add a comment here.
582 (define_predicate "fdpic_fptr_operand"
583   (match_code "reg")
585   if (GET_MODE (op) != mode && mode != VOIDmode)
586     return FALSE;
587   if (GET_CODE (op) != REG)
588     return FALSE;
589   if (REGNO (op) != FDPIC_FPTR_REGNO && REGNO (op) < FIRST_PSEUDO_REGISTER)
590     return FALSE;
591   return TRUE;
594 ;; An address operand that may use a pair of registers, an addressing
595 ;; mode that we reject in general.
597 (define_predicate "ldd_address_operand"
598   (match_code "reg,subreg,plus")
600   if (GET_MODE (op) != mode && GET_MODE (op) != VOIDmode)
601     return FALSE;
603   return frv_legitimate_address_p (DImode, op, reload_completed, FALSE, TRUE);
606 ;; TODO: Add a comment here.
608 (define_predicate "got12_operand"
609   (match_code "const")
611   struct frv_unspec unspec;
613   if (frv_const_unspec_p (op, &unspec))
614     switch (unspec.reloc)
615       {
616       case R_FRV_GOT12:
617       case R_FRV_GOTOFF12:
618       case R_FRV_FUNCDESC_GOT12:
619       case R_FRV_FUNCDESC_GOTOFF12:
620       case R_FRV_GPREL12:
621       case R_FRV_TLSMOFF12:
622         return true;
623       }
624   return false;
627 ;; Return true if OP is a valid const-unspec expression.
629 (define_predicate "const_unspec_operand"
630   (match_code "const")
632   struct frv_unspec unspec;
634   return frv_const_unspec_p (op, &unspec);
637 ;; Return true if operand is an icc register.
639 (define_predicate "icc_operand"
640   (match_code "reg")
642   int regno;
644   if (GET_MODE (op) != mode && mode != VOIDmode)
645     return FALSE;
647   if (GET_CODE (op) != REG)
648     return FALSE;
650   regno = REGNO (op);
651   return ICC_OR_PSEUDO_P (regno);
654 ;; Return true if operand is an fcc register.
656 (define_predicate "fcc_operand"
657   (match_code "reg")
659   int regno;
661   if (GET_MODE (op) != mode && mode != VOIDmode)
662     return FALSE;
664   if (GET_CODE (op) != REG)
665     return FALSE;
667   regno = REGNO (op);
668   return FCC_OR_PSEUDO_P (regno);
671 ;; Return true if operand is either an fcc or icc register.
673 (define_predicate "cc_operand"
674   (match_code "reg")
676   int regno;
678   if (GET_MODE (op) != mode && mode != VOIDmode)
679     return FALSE;
681   if (GET_CODE (op) != REG)
682     return FALSE;
684   regno = REGNO (op);
685   if (CC_OR_PSEUDO_P (regno))
686     return TRUE;
688   return FALSE;
691 ;; Return true if operand is an integer CCR register.
693 (define_predicate "icr_operand"
694   (match_code "reg")
696   int regno;
698   if (GET_MODE (op) != mode && mode != VOIDmode)
699     return FALSE;
701   if (GET_CODE (op) != REG)
702     return FALSE;
704   regno = REGNO (op);
705   return ICR_OR_PSEUDO_P (regno);
708 ;; Return true if operand is an fcc register.
710 (define_predicate "fcr_operand"
711   (match_code "reg")
713   int regno;
715   if (GET_MODE (op) != mode && mode != VOIDmode)
716     return FALSE;
718   if (GET_CODE (op) != REG)
719     return FALSE;
721   regno = REGNO (op);
722   return FCR_OR_PSEUDO_P (regno);
725 ;; Return true if operand is either an fcc or icc register.
727 (define_predicate "cr_operand"
728   (match_code "reg")
730   int regno;
732   if (GET_MODE (op) != mode && mode != VOIDmode)
733     return FALSE;
735   if (GET_CODE (op) != REG)
736     return FALSE;
738   regno = REGNO (op);
739   if (CR_OR_PSEUDO_P (regno))
740     return TRUE;
742   return FALSE;
745 ;; Return true if operand is a FPR register.
747 (define_predicate "fpr_operand"
748   (match_code "reg,subreg")
750   if (GET_MODE (op) != mode && mode != VOIDmode)
751     return FALSE;
753   if (GET_CODE (op) == SUBREG)
754     {
755       if (GET_CODE (SUBREG_REG (op)) != REG)
756         return register_operand (op, mode);
758       op = SUBREG_REG (op);
759     }
761   if (GET_CODE (op) != REG)
762     return FALSE;
764   return FPR_OR_PSEUDO_P (REGNO (op));
767 ;; Return true if operand is an even GPR or FPR register.
769 (define_predicate "even_reg_operand"
770   (match_code "reg,subreg")
772   int regno;
774   if (GET_MODE (op) != mode && mode != VOIDmode)
775     return FALSE;
777   if (GET_CODE (op) == SUBREG)
778     {
779       if (GET_CODE (SUBREG_REG (op)) != REG)
780         return register_operand (op, mode);
782       op = SUBREG_REG (op);
783     }
785   if (GET_CODE (op) != REG)
786     return FALSE;
788   regno = REGNO (op);
789   if (regno >= FIRST_PSEUDO_REGISTER)
790     return TRUE;
792   if (GPR_P (regno))
793     return (((regno - GPR_FIRST) & 1) == 0);
795   if (FPR_P (regno))
796     return (((regno - FPR_FIRST) & 1) == 0);
798   return FALSE;
801 ;; Return true if operand is an odd GPR register.
803 (define_predicate "odd_reg_operand"
804   (match_code "reg,subreg")
806   int regno;
808   if (GET_MODE (op) != mode && mode != VOIDmode)
809     return FALSE;
811   if (GET_CODE (op) == SUBREG)
812     {
813       if (GET_CODE (SUBREG_REG (op)) != REG)
814         return register_operand (op, mode);
816       op = SUBREG_REG (op);
817     }
819   if (GET_CODE (op) != REG)
820     return FALSE;
822   regno = REGNO (op);
823   /* Assume that reload will give us an even register.  */
824   if (regno >= FIRST_PSEUDO_REGISTER)
825     return FALSE;
827   if (GPR_P (regno))
828     return (((regno - GPR_FIRST) & 1) != 0);
830   if (FPR_P (regno))
831     return (((regno - FPR_FIRST) & 1) != 0);
833   return FALSE;
836 ;; Return true if operand is an even GPR register.
838 (define_predicate "even_gpr_operand"
839   (match_code "reg,subreg")
841   int regno;
843   if (GET_MODE (op) != mode && mode != VOIDmode)
844     return FALSE;
846   if (GET_CODE (op) == SUBREG)
847     {
848       if (GET_CODE (SUBREG_REG (op)) != REG)
849         return register_operand (op, mode);
851       op = SUBREG_REG (op);
852     }
854   if (GET_CODE (op) != REG)
855     return FALSE;
857   regno = REGNO (op);
858   if (regno >= FIRST_PSEUDO_REGISTER)
859     return TRUE;
861   if (! GPR_P (regno))
862     return FALSE;
864   return (((regno - GPR_FIRST) & 1) == 0);
867 ;; Return true if operand is an odd GPR register.
869 (define_predicate "odd_gpr_operand"
870   (match_code "reg,subreg")
872   int regno;
874   if (GET_MODE (op) != mode && mode != VOIDmode)
875     return FALSE;
877   if (GET_CODE (op) == SUBREG)
878     {
879       if (GET_CODE (SUBREG_REG (op)) != REG)
880         return register_operand (op, mode);
882       op = SUBREG_REG (op);
883     }
885   if (GET_CODE (op) != REG)
886     return FALSE;
888   regno = REGNO (op);
889   /* Assume that reload will give us an even register.  */
890   if (regno >= FIRST_PSEUDO_REGISTER)
891     return FALSE;
893   if (! GPR_P (regno))
894     return FALSE;
896   return (((regno - GPR_FIRST) & 1) != 0);
899 ;; Return true if operand is a quad aligned FPR register.
901 (define_predicate "quad_fpr_operand"
902   (match_code "reg,subreg")
904   int regno;
906   if (GET_MODE (op) != mode && mode != VOIDmode)
907     return FALSE;
909   if (GET_CODE (op) == SUBREG)
910     {
911       if (GET_CODE (SUBREG_REG (op)) != REG)
912         return register_operand (op, mode);
914       op = SUBREG_REG (op);
915     }
917   if (GET_CODE (op) != REG)
918     return FALSE;
920   regno = REGNO (op);
921   if (regno >= FIRST_PSEUDO_REGISTER)
922     return TRUE;
924   if (! FPR_P (regno))
925     return FALSE;
927   return (((regno - FPR_FIRST) & 3) == 0);
930 ;; Return true if operand is an even FPR register.
932 (define_predicate "even_fpr_operand"
933   (match_code "reg,subreg")
935   int regno;
937   if (GET_MODE (op) != mode && mode != VOIDmode)
938     return FALSE;
940   if (GET_CODE (op) == SUBREG)
941     {
942       if (GET_CODE (SUBREG_REG (op)) != REG)
943         return register_operand (op, mode);
945       op = SUBREG_REG (op);
946     }
948   if (GET_CODE (op) != REG)
949     return FALSE;
951   regno = REGNO (op);
952   if (regno >= FIRST_PSEUDO_REGISTER)
953     return TRUE;
955   if (! FPR_P (regno))
956     return FALSE;
958   return (((regno - FPR_FIRST) & 1) == 0);
961 ;; Return true if operand is an odd FPR register.
963 (define_predicate "odd_fpr_operand"
964   (match_code "reg,subreg")
966   int regno;
968   if (GET_MODE (op) != mode && mode != VOIDmode)
969     return FALSE;
971   if (GET_CODE (op) == SUBREG)
972     {
973       if (GET_CODE (SUBREG_REG (op)) != REG)
974         return register_operand (op, mode);
976       op = SUBREG_REG (op);
977     }
979   if (GET_CODE (op) != REG)
980     return FALSE;
982   regno = REGNO (op);
983   /* Assume that reload will give us an even register.  */
984   if (regno >= FIRST_PSEUDO_REGISTER)
985     return FALSE;
987   if (! FPR_P (regno))
988     return FALSE;
990   return (((regno - FPR_FIRST) & 1) != 0);
993 ;; Return true if operand is a 2 word memory address that can be
994 ;; loaded in one instruction to load or store.  We assume the stack
995 ;; and frame pointers are suitably aligned, and variables in the small
996 ;; data area.  FIXME -- at some we should recognize other globals and
997 ;; statics. We can't assume that any old pointer is aligned, given
998 ;; that arguments could be passed on an odd word on the stack and the
999 ;; address taken and passed through to another function.
1001 (define_predicate "dbl_memory_one_insn_operand"
1002   (match_code "mem")
1004   rtx addr;
1005   rtx addr_reg;
1007   if (! TARGET_DWORD)
1008     return FALSE;
1010   if (GET_CODE (op) != MEM)
1011     return FALSE;
1013   if (mode != VOIDmode && GET_MODE_SIZE (mode) != 2*UNITS_PER_WORD)
1014     return FALSE;
1016   addr = XEXP (op, 0);
1017   if (GET_CODE (addr) == REG)
1018     addr_reg = addr;
1020   else if (GET_CODE (addr) == PLUS)
1021     {
1022       rtx addr0 = XEXP (addr, 0);
1023       rtx addr1 = XEXP (addr, 1);
1025       if (GET_CODE (addr0) != REG)
1026         return FALSE;
1028       if (got12_operand (addr1, VOIDmode))
1029         return TRUE;
1031       if (GET_CODE (addr1) != CONST_INT)
1032         return FALSE;
1034       if ((INTVAL (addr1) & 7) != 0)
1035         return FALSE;
1037       addr_reg = addr0;
1038     }
1040   else
1041     return FALSE;
1043   if (addr_reg == frame_pointer_rtx || addr_reg == stack_pointer_rtx)
1044     return TRUE;
1046   return FALSE;
1049 ;; Return true if operand is a 2 word memory address that needs to use
1050 ;; two instructions to load or store.
1052 (define_predicate "dbl_memory_two_insn_operand"
1053   (match_code "mem")
1055   if (GET_CODE (op) != MEM)
1056     return FALSE;
1058   if (mode != VOIDmode && GET_MODE_SIZE (mode) != 2*UNITS_PER_WORD)
1059     return FALSE;
1061   if (! TARGET_DWORD)
1062     return TRUE;
1064   return ! dbl_memory_one_insn_operand (op, mode);
1067 ;; Return true if operand is a memory reference suitable for a call.
1069 (define_predicate "call_operand"
1070   (match_code "reg,subreg,const_int,const,symbol_ref")
1072   if (GET_MODE (op) != mode && mode != VOIDmode && GET_CODE (op) != CONST_INT)
1073     return FALSE;
1075   if (GET_CODE (op) == SYMBOL_REF)
1076     return !TARGET_LONG_CALLS || SYMBOL_REF_LOCAL_P (op);
1078   /* Note this doesn't allow reg+reg or reg+imm12 addressing (which should
1079      never occur anyway), but prevents reload from not handling the case
1080      properly of a call through a pointer on a function that calls
1081      vfork/setjmp, etc. due to the need to flush all of the registers to stack.  */
1082   return gpr_or_int12_operand (op, mode);
1085 ;; Return true if operand is a memory reference suitable for a
1086 ;; sibcall.
1088 (define_predicate "sibcall_operand"
1089   (match_code "reg,subreg,const_int,const")
1091   if (GET_MODE (op) != mode && mode != VOIDmode && GET_CODE (op) != CONST_INT)
1092     return FALSE;
1094   /* Note this doesn't allow reg+reg or reg+imm12 addressing (which should
1095      never occur anyway), but prevents reload from not handling the case
1096      properly of a call through a pointer on a function that calls
1097      vfork/setjmp, etc. due to the need to flush all of the registers to stack.  */
1098   return gpr_or_int12_operand (op, mode);
1101 ;; Return 1 if operand is an integer constant with the bottom 16 bits
1102 ;; clear.
1104 (define_predicate "upper_int16_operand"
1105   (match_code "const_int")
1107   if (GET_CODE (op) != CONST_INT)
1108     return FALSE;
1110   return ((INTVAL (op) & 0xffff) == 0);
1113 ;; Return 1 if operand is a 16 bit unsigned immediate.
1115 (define_predicate "uint16_operand"
1116   (match_code "const_int")
1118   if (GET_CODE (op) != CONST_INT)
1119     return FALSE;
1121   return IN_RANGE_P (INTVAL (op), 0, 0xffff);
1124 ;; Returns 1 if OP is either a SYMBOL_REF or a constant.
1126 (define_predicate "symbolic_operand"
1127   (match_code "symbol_ref,const_int")
1129   enum rtx_code c = GET_CODE (op);
1131   if (c == CONST)
1132     {
1133       /* Allow (const:SI (plus:SI (symbol_ref) (const_int))).  */
1134       return GET_MODE (op) == SImode
1135         && GET_CODE (XEXP (op, 0)) == PLUS
1136         && GET_CODE (XEXP (XEXP (op, 0), 0)) == SYMBOL_REF
1137         && GET_CODE (XEXP (XEXP (op, 0), 1)) == CONST_INT;
1138     }
1140   return c == SYMBOL_REF || c == CONST_INT;
1143 ;; Return true if operator is a kind of relational operator.
1145 (define_predicate "relational_operator"
1146   (match_code "eq,ne,le,lt,ge,gt,leu,ltu,geu,gtu")
1148   return (integer_relational_operator (op, mode)
1149           || float_relational_operator (op, mode));
1152 ;; Return true if OP is a relational operator suitable for CCmode,
1153 ;; CC_UNSmode or CC_NZmode.
1155 (define_predicate "integer_relational_operator"
1156   (match_code "eq,ne,le,lt,ge,gt,leu,ltu,geu,gtu")
1158   if (mode != VOIDmode && mode != GET_MODE (op))
1159     return FALSE;
1161   /* The allowable relations depend on the mode of the ICC register.  */
1162   switch (GET_CODE (op))
1163     {
1164     default:
1165       return FALSE;
1167     case EQ:
1168     case NE:
1169     case LT:
1170     case GE:
1171       return (GET_MODE (XEXP (op, 0)) == CC_NZmode
1172               || GET_MODE (XEXP (op, 0)) == CCmode);
1174     case LE:
1175     case GT:
1176       return GET_MODE (XEXP (op, 0)) == CCmode;
1178     case GTU:
1179     case GEU:
1180     case LTU:
1181     case LEU:
1182       return (GET_MODE (XEXP (op, 0)) == CC_NZmode
1183               || GET_MODE (XEXP (op, 0)) == CC_UNSmode);
1184     }
1187 ;; Return true if operator is a floating point relational operator.
1189 (define_predicate "float_relational_operator"
1190   (match_code "eq,ne,le,lt,ge,gt")
1192   if (mode != VOIDmode && mode != GET_MODE (op))
1193     return FALSE;
1195   switch (GET_CODE (op))
1196     {
1197     default:
1198       return FALSE;
1200     case EQ: case NE:
1201     case LE: case LT:
1202     case GE: case GT:
1203 #if 0
1204     case UEQ: case UNE:
1205     case ULE: case ULT:
1206     case UGE: case UGT:
1207     case ORDERED:
1208     case UNORDERED:
1209 #endif
1210       return GET_MODE (XEXP (op, 0)) == CC_FPmode;
1211     }
1214 ;; Return true if operator is EQ/NE of a conditional execution
1215 ;; register.
1217 (define_predicate "ccr_eqne_operator"
1218   (match_code "eq,ne")
1220   enum machine_mode op_mode = GET_MODE (op);
1221   rtx op0;
1222   rtx op1;
1223   int regno;
1225   if (mode != VOIDmode && op_mode != mode)
1226     return FALSE;
1228   switch (GET_CODE (op))
1229     {
1230     default:
1231       return FALSE;
1233     case EQ:
1234     case NE:
1235       break;
1236     }
1238   op1 = XEXP (op, 1);
1239   if (op1 != const0_rtx)
1240     return FALSE;
1242   op0 = XEXP (op, 0);
1243   if (GET_CODE (op0) != REG)
1244     return FALSE;
1246   regno = REGNO (op0);
1247   if (op_mode == CC_CCRmode && CR_OR_PSEUDO_P (regno))
1248     return TRUE;
1250   return FALSE;
1253 ;; Return true if operator is a minimum or maximum operator (both
1254 ;; signed and unsigned).
1256 (define_predicate "minmax_operator"
1257   (match_code "smin,smax,umin,umax")
1259   if (mode != VOIDmode && mode != GET_MODE (op))
1260     return FALSE;
1262   switch (GET_CODE (op))
1263     {
1264     default:
1265       return FALSE;
1267     case SMIN:
1268     case SMAX:
1269     case UMIN:
1270     case UMAX:
1271       break;
1272     }
1274   if (! integer_register_operand (XEXP (op, 0), mode))
1275     return FALSE;
1277   if (! gpr_or_int10_operand (XEXP (op, 1), mode))
1278     return FALSE;
1280   return TRUE;
1283 ;; Return true if operator is an integer binary operator that can
1284 ;; executed conditionally and takes 1 cycle.
1286 (define_predicate "condexec_si_binary_operator"
1287   (match_code "plus,minus,and,ior,xor,ashift,ashiftrt,lshiftrt")
1289   enum machine_mode op_mode = GET_MODE (op);
1291   if (mode != VOIDmode && op_mode != mode)
1292     return FALSE;
1294   switch (GET_CODE (op))
1295     {
1296     default:
1297       return FALSE;
1299     case PLUS:
1300     case MINUS:
1301     case AND:
1302     case IOR:
1303     case XOR:
1304     case ASHIFT:
1305     case ASHIFTRT:
1306     case LSHIFTRT:
1307       return TRUE;
1308     }
1311 ;; Return true if operator is an integer binary operator that can be
1312 ;; executed conditionally by a media instruction.
1314 (define_predicate "condexec_si_media_operator"
1315   (match_code "and,ior,xor")
1317   enum machine_mode op_mode = GET_MODE (op);
1319   if (mode != VOIDmode && op_mode != mode)
1320     return FALSE;
1322   switch (GET_CODE (op))
1323     {
1324     default:
1325       return FALSE;
1327     case AND:
1328     case IOR:
1329     case XOR:
1330       return TRUE;
1331     }
1334 ;; Return true if operator is an integer division operator that can
1335 ;; executed conditionally.
1337 (define_predicate "condexec_si_divide_operator"
1338   (match_code "div,udiv")
1340   enum machine_mode op_mode = GET_MODE (op);
1342   if (mode != VOIDmode && op_mode != mode)
1343     return FALSE;
1345   switch (GET_CODE (op))
1346     {
1347     default:
1348       return FALSE;
1350     case DIV:
1351     case UDIV:
1352       return TRUE;
1353     }
1356 ;; Return true if operator is an integer unary operator that can
1357 ;; executed conditionally.
1359 (define_predicate "condexec_si_unary_operator"
1360   (match_code "not,neg")
1362   enum machine_mode op_mode = GET_MODE (op);
1364   if (mode != VOIDmode && op_mode != mode)
1365     return FALSE;
1367   switch (GET_CODE (op))
1368     {
1369     default:
1370       return FALSE;
1372     case NEG:
1373     case NOT:
1374       return TRUE;
1375     }
1378 ;; Return true if operator is an addition or subtraction
1379 ;; expression. Such expressions can be evaluated conditionally by
1380 ;; floating-point instructions.
1382 (define_predicate "condexec_sf_add_operator"
1383   (match_code "plus,minus")
1385   enum machine_mode op_mode = GET_MODE (op);
1387   if (mode != VOIDmode && op_mode != mode)
1388     return FALSE;
1390   switch (GET_CODE (op))
1391     {
1392     default:
1393       return FALSE;
1395     case PLUS:
1396     case MINUS:
1397       return TRUE;
1398     }
1401 ;; Return true if operator is a conversion-type expression that can be
1402 ;; evaluated conditionally by floating-point instructions.
1404 (define_predicate "condexec_sf_conv_operator"
1405   (match_code "abs,neg")
1407   enum machine_mode op_mode = GET_MODE (op);
1409   if (mode != VOIDmode && op_mode != mode)
1410     return FALSE;
1412   switch (GET_CODE (op))
1413     {
1414     default:
1415       return FALSE;
1417     case NEG:
1418     case ABS:
1419       return TRUE;
1420     }
1423 ;; Return true if OP is an integer binary operator that can be
1424 ;; combined with a (set ... (compare:CC_NZ ...)) pattern.
1426 (define_predicate "intop_compare_operator"
1427   (match_code "plus,minus,and,ior,xor,ashift,ashiftrt,lshiftrt")
1429   if (mode != VOIDmode && GET_MODE (op) != mode)
1430     return FALSE;
1432   switch (GET_CODE (op))
1433     {
1434     default:
1435       return FALSE;
1437     case PLUS:
1438     case MINUS:
1439     case AND:
1440     case IOR:
1441     case XOR:
1442     case ASHIFTRT:
1443     case LSHIFTRT:
1444       return GET_MODE (op) == SImode;
1445     }
1448 ;; Return 1 if operand is a register or 6 bit signed immediate.
1450 (define_predicate "fpr_or_int6_operand"
1451   (match_code "reg,subreg,const_int")
1453   if (GET_CODE (op) == CONST_INT)
1454     return IN_RANGE_P (INTVAL (op), -32, 31);
1456   if (GET_MODE (op) != mode && mode != VOIDmode)
1457     return FALSE;
1459   if (GET_CODE (op) == SUBREG)
1460     {
1461       if (GET_CODE (SUBREG_REG (op)) != REG)
1462         return register_operand (op, mode);
1464       op = SUBREG_REG (op);
1465     }
1467   if (GET_CODE (op) != REG)
1468     return FALSE;
1470   return FPR_OR_PSEUDO_P (REGNO (op));
1473 ;; Return 1 if operand is a 6 bit signed immediate.
1475 (define_predicate "int6_operand"
1476   (match_code "const_int")
1478   if (GET_CODE (op) != CONST_INT)
1479     return FALSE;
1481   return IN_RANGE_P (INTVAL (op), -32, 31);
1484 ;; Return 1 if operand is a 5 bit signed immediate.
1486 (define_predicate "int5_operand"
1487   (match_code "const_int")
1489   return GET_CODE (op) == CONST_INT && IN_RANGE_P (INTVAL (op), -16, 15);
1492 ;; Return 1 if operand is a 5 bit unsigned immediate.
1494 (define_predicate "uint5_operand"
1495   (match_code "const_int")
1497   return GET_CODE (op) == CONST_INT && IN_RANGE_P (INTVAL (op), 0, 31);
1500 ;; Return 1 if operand is a 4 bit unsigned immediate.
1502 (define_predicate "uint4_operand"
1503   (match_code "const_int")
1505   return GET_CODE (op) == CONST_INT && IN_RANGE_P (INTVAL (op), 0, 15);
1508 ;; Return 1 if operand is a 1 bit unsigned immediate (0 or 1).
1510 (define_predicate "uint1_operand"
1511   (match_code "const_int")
1513   return GET_CODE (op) == CONST_INT && IN_RANGE_P (INTVAL (op), 0, 1);
1516 ;; Return 1 if operand is a valid ACC register number.
1518 (define_predicate "acc_operand"
1519   (match_code "reg,subreg")
1521   return ((mode == VOIDmode || mode == GET_MODE (op))
1522           && REG_P (op) && ACC_P (REGNO (op))
1523           && ((REGNO (op) - ACC_FIRST) & ~ACC_MASK) == 0);
1526 ;; Return 1 if operand is a valid even ACC register number.
1528 (define_predicate "even_acc_operand"
1529   (match_code "reg,subreg")
1531   return acc_operand (op, mode) && ((REGNO (op) - ACC_FIRST) & 1) == 0;
1534 ;; Return 1 if operand is zero or four.
1536 (define_predicate "quad_acc_operand"
1537   (match_code "reg,subreg")
1539   return acc_operand (op, mode) && ((REGNO (op) - ACC_FIRST) & 3) == 0;
1542 ;; Return 1 if operand is a valid ACCG register number.
1544 (define_predicate "accg_operand"
1545   (match_code "reg,subreg")
1547   return ((mode == VOIDmode || mode == GET_MODE (op))
1548           && REG_P (op) && ACCG_P (REGNO (op))
1549           && ((REGNO (op) - ACCG_FIRST) & ~ACC_MASK) == 0);