Update FSF address.
[official-gcc.git] / gcc / config / m68k / predicates.md
blob99c57c0bec3ec1044acb83daf0fdc98db8d87109
1 ;; Predicate definitions for Motorola 68000.
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 ;; Special case of a general operand that's used as a source
22 ;; operand. Use this to permit reads from PC-relative memory when
23 ;; -mpcrel is specified.
25 (define_predicate "general_src_operand"
26   (match_code "const_int,const_double,const,symbol_ref,label_ref,subreg,reg,mem")
28   if (TARGET_PCREL
29       && GET_CODE (op) == MEM
30       && (GET_CODE (XEXP (op, 0)) == SYMBOL_REF
31           || GET_CODE (XEXP (op, 0)) == LABEL_REF
32           || GET_CODE (XEXP (op, 0)) == CONST))
33     return 1;
34   return general_operand (op, mode);
37 ;; Special case of a nonimmediate operand that's used as a source. Use
38 ;; this to permit reads from PC-relative memory when -mpcrel is
39 ;; specified.
41 (define_predicate "nonimmediate_src_operand"
42   (match_code "subreg,reg,mem")
44   if (TARGET_PCREL && GET_CODE (op) == MEM
45       && (GET_CODE (XEXP (op, 0)) == SYMBOL_REF
46           || GET_CODE (XEXP (op, 0)) == LABEL_REF
47           || GET_CODE (XEXP (op, 0)) == CONST))
48     return 1;
49   return nonimmediate_operand (op, mode);
52 ;; Special case of a memory operand that's used as a source. Use this
53 ;; to permit reads from PC-relative memory when -mpcrel is specified.
55 (define_predicate "memory_src_operand"
56   (match_code "subreg,mem")
58   if (TARGET_PCREL && GET_CODE (op) == MEM
59       && (GET_CODE (XEXP (op, 0)) == SYMBOL_REF
60           || GET_CODE (XEXP (op, 0)) == LABEL_REF
61           || GET_CODE (XEXP (op, 0)) == CONST))
62     return 1;
63   return memory_operand (op, mode);
66 ;; Similar to general_operand, but exclude stack_pointer_rtx.
68 (define_predicate "not_sp_operand"
69   (match_code "subreg,reg,mem")
71   return op != stack_pointer_rtx && nonimmediate_operand (op, mode);
74 ;; Predicate that accepts only a pc-relative address.  This is needed
75 ;; because pc-relative addresses don't satisfy the predicate
76 ;; "general_src_operand".
78 (define_predicate "pcrel_address"
79   (match_code "symbol_ref,label_ref,const")
81   return (GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == LABEL_REF
82           || GET_CODE (op) == CONST);
85 ;; Accept integer operands in the range 0..0xffffffff.  We have to
86 ;; check the range carefully since this predicate is used in DImode
87 ;; contexts.  Also, we need some extra crud to make it work when
88 ;; hosted on 64-bit machines.
90 (define_predicate "const_uint32_operand"
91   (match_code "const_int,const_double")
93   /* It doesn't make sense to ask this question with a mode that is
94      not larger than 32 bits.  */
95   if (GET_MODE_BITSIZE (mode) <= 32)
96     abort ();
98 #if HOST_BITS_PER_WIDE_INT > 32
99   /* All allowed constants will fit a CONST_INT.  */
100   return (GET_CODE (op) == CONST_INT
101           && (INTVAL (op) >= 0 && INTVAL (op) <= 0xffffffffL));
102 #else
103   return (GET_CODE (op) == CONST_INT
104           || (GET_CODE (op) == CONST_DOUBLE && CONST_DOUBLE_HIGH (op) == 0));
105 #endif
108 ;; Accept integer operands in the range -0x80000000..0x7fffffff.  We
109 ;; have to check the range carefully since this predicate is used in
110 ;; DImode contexts.
112 (define_predicate "const_sint32_operand"
113   (match_code "const_int")
115   /* It doesn't make sense to ask this question with a mode that is
116      not larger than 32 bits.  */
117   if (GET_MODE_BITSIZE (mode) <= 32)
118     abort ();
120   /* All allowed constants will fit a CONST_INT.  */
121   return (GET_CODE (op) == CONST_INT
122           && (INTVAL (op) >= (-0x7fffffff - 1) && INTVAL (op) <= 0x7fffffff));
125 ;; Return true if X is a valid comparison operator for the dbcc
126 ;; instruction.  Note it rejects floating point comparison
127 ;; operators. (In the future we could use Fdbcc).  It also rejects
128 ;; some comparisons when CC_NO_OVERFLOW is set.
130 (define_predicate "valid_dbcc_comparison_p"
131   (match_code "eq,ne,gtu,ltu,geu,leu,gt,lt,ge,le")
133   return valid_dbcc_comparison_p_2 (op, mode);
136 ;; Check for sign_extend or zero_extend.  Used for bit-count operands.
138 (define_predicate "extend_operator"
139   (match_code "sign_extend,zero_extend")
141   if (mode != VOIDmode && GET_MODE (op) != mode)
142     return 0;
143   switch (GET_CODE (op))
144     {
145     case SIGN_EXTEND:
146     case ZERO_EXTEND:
147       return 1;
148     default:
149       return 0;
150     }
153 ;; Returns true if OP is either a symbol reference or a sum of a
154 ;; symbol reference and a constant.
156 (define_predicate "symbolic_operand"
157   (match_code "symbol_ref,label_ref,const")
159   switch (GET_CODE (op))
160     {
161     case SYMBOL_REF:
162     case LABEL_REF:
163       return true;
165     case CONST:
166       op = XEXP (op, 0);
167       return ((GET_CODE (XEXP (op, 0)) == SYMBOL_REF
168                || GET_CODE (XEXP (op, 0)) == LABEL_REF)
169               && GET_CODE (XEXP (op, 1)) == CONST_INT);
171 #if 0 /* Deleted, with corresponding change in m68k.h,
172          so as to fit the specs.  No CONST_DOUBLE is ever symbolic.  */
173     case CONST_DOUBLE:
174       return GET_MODE (op) == mode;
175 #endif
177     default:
178       return false;
179     }
182 ;; TODO: Add a comment here.
184 (define_predicate "post_inc_operand"
185   (match_code "mem")
187   return MEM_P (op) && GET_CODE (XEXP (op, 0)) == POST_INC;
190 ;; TODO: Add a comment here.
192 (define_predicate "pre_dec_operand"
193   (match_code "mem")
195   return MEM_P (op) && GET_CODE (XEXP (op, 0)) == PRE_DEC;