]>
Commit | Line | Data |
---|---|---|
0d4a78eb | 1 | ;; Predicate definitions for the Blackfin. |
66647d44 | 2 | ;; Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
4729dc92 | 3 | ;; Contributed by Analog Devices. |
0d4a78eb BS |
4 | ;; |
5 | ;; This file is part of GCC. | |
6 | ;; | |
7 | ;; GCC is free software; you can redistribute it and/or modify | |
8 | ;; it under the terms of the GNU General Public License as published by | |
2f83c7d6 | 9 | ;; the Free Software Foundation; either version 3, or (at your option) |
0d4a78eb BS |
10 | ;; any later version. |
11 | ;; | |
12 | ;; GCC is distributed in the hope that it will be useful, | |
13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | ;; GNU General Public License for more details. | |
16 | ;; | |
17 | ;; You should have received a copy of the GNU General Public License | |
2f83c7d6 NC |
18 | ;; along with GCC; see the file COPYING3. If not see |
19 | ;; <http://www.gnu.org/licenses/>. | |
0d4a78eb BS |
20 | |
21 | ;; Return nonzero iff OP is one of the integer constants 1 or 2. | |
22 | (define_predicate "pos_scale_operand" | |
23 | (and (match_code "const_int") | |
24 | (match_test "INTVAL (op) == 1 || INTVAL (op) == 2"))) | |
25 | ||
26 | ;; Return nonzero iff OP is one of the integer constants 2 or 4. | |
27 | (define_predicate "scale_by_operand" | |
28 | (and (match_code "const_int") | |
29 | (match_test "INTVAL (op) == 2 || INTVAL (op) == 4"))) | |
30 | ||
31 | ;; Return nonzero if OP is a constant that consists of two parts; lower | |
32 | ;; bits all zero and upper bits all ones. In this case, we can perform | |
33 | ;; an AND operation with a sequence of two shifts. Don't return nonzero | |
34 | ;; if the constant would be cheap to load. | |
35 | (define_predicate "highbits_operand" | |
36 | (and (match_code "const_int") | |
9fdd7520 | 37 | (match_test "log2constp (-INTVAL (op)) && !satisfies_constraint_Ks7 (op)"))) |
0d4a78eb BS |
38 | |
39 | ;; Return nonzero if OP is suitable as a right-hand side operand for an | |
40 | ;; andsi3 operation. | |
41 | (define_predicate "rhs_andsi3_operand" | |
42 | (ior (match_operand 0 "register_operand") | |
43 | (and (match_code "const_int") | |
44 | (match_test "log2constp (~INTVAL (op)) || INTVAL (op) == 255 || INTVAL (op) == 65535")))) | |
45 | ||
46 | ;; Return nonzero if OP is a register or a constant with exactly one bit | |
47 | ;; set. | |
48 | (define_predicate "regorlog2_operand" | |
49 | (ior (match_operand 0 "register_operand") | |
50 | (and (match_code "const_int") | |
51 | (match_test "log2constp (INTVAL (op))")))) | |
52 | ||
7ddcf3d2 BS |
53 | ;; Return nonzero if OP is a register or an integer constant. |
54 | (define_predicate "reg_or_const_int_operand" | |
55 | (ior (match_operand 0 "register_operand") | |
56 | (match_code "const_int"))) | |
57 | ||
75d8b2d0 | 58 | (define_predicate "const01_operand" |
554006bd BS |
59 | (and (match_code "const_int") |
60 | (match_test "op == const0_rtx || op == const1_rtx"))) | |
75d8b2d0 | 61 | |
c7cb1555 BS |
62 | (define_predicate "const1_operand" |
63 | (and (match_code "const_int") | |
64 | (match_test "op == const1_rtx"))) | |
65 | ||
66 | (define_predicate "const3_operand" | |
67 | (and (match_code "const_int") | |
68 | (match_test "INTVAL (op) == 3"))) | |
69 | ||
75d8b2d0 BS |
70 | (define_predicate "vec_shift_operand" |
71 | (ior (and (match_code "const_int") | |
72 | (match_test "INTVAL (op) >= -16 && INTVAL (op) < 15")) | |
73 | (match_operand 0 "register_operand"))) | |
74 | ||
0d4a78eb BS |
75 | ;; Like register_operand, but make sure that hard regs have a valid mode. |
76 | (define_predicate "valid_reg_operand" | |
77 | (match_operand 0 "register_operand") | |
78 | { | |
79 | if (GET_CODE (op) == SUBREG) | |
80 | op = SUBREG_REG (op); | |
81 | if (REGNO (op) < FIRST_PSEUDO_REGISTER) | |
82 | return HARD_REGNO_MODE_OK (REGNO (op), mode); | |
83 | return 1; | |
84 | }) | |
85 | ||
36662eb1 BS |
86 | ;; Return nonzero if OP is a D register. |
87 | (define_predicate "d_register_operand" | |
88 | (and (match_code "reg") | |
89 | (match_test "D_REGNO_P (REGNO (op))"))) | |
90 | ||
b03149e1 JZ |
91 | ;; Return nonzero if OP is a LC register. |
92 | (define_predicate "lc_register_operand" | |
93 | (and (match_code "reg") | |
94 | (match_test "REGNO (op) == REG_LC0 || REGNO (op) == REG_LC1"))) | |
95 | ||
96 | ;; Return nonzero if OP is a LT register. | |
97 | (define_predicate "lt_register_operand" | |
98 | (and (match_code "reg") | |
99 | (match_test "REGNO (op) == REG_LT0 || REGNO (op) == REG_LT1"))) | |
100 | ||
101 | ;; Return nonzero if OP is a LB register. | |
102 | (define_predicate "lb_register_operand" | |
103 | (and (match_code "reg") | |
104 | (match_test "REGNO (op) == REG_LB0 || REGNO (op) == REG_LB1"))) | |
105 | ||
942fd98f | 106 | ;; Return nonzero if OP is a register or a 7-bit signed constant. |
0d4a78eb BS |
107 | (define_predicate "reg_or_7bit_operand" |
108 | (ior (match_operand 0 "register_operand") | |
109 | (and (match_code "const_int") | |
9fdd7520 | 110 | (match_test "satisfies_constraint_Ks7 (op)")))) |
0d4a78eb | 111 | |
b03149e1 JZ |
112 | ;; Return nonzero if OP is a register other than DREG and PREG. |
113 | (define_predicate "nondp_register_operand" | |
114 | (match_operand 0 "register_operand") | |
115 | { | |
116 | unsigned int regno; | |
117 | if (GET_CODE (op) == SUBREG) | |
118 | op = SUBREG_REG (op); | |
119 | ||
120 | regno = REGNO (op); | |
121 | return (regno >= FIRST_PSEUDO_REGISTER || !DP_REGNO_P (regno)); | |
122 | }) | |
123 | ||
124 | ;; Return nonzero if OP is a register other than DREG and PREG, or MEM. | |
125 | (define_predicate "nondp_reg_or_memory_operand" | |
126 | (ior (match_operand 0 "nondp_register_operand") | |
127 | (match_operand 0 "memory_operand"))) | |
128 | ||
942fd98f | 129 | ;; Return nonzero if OP is a register or, when negated, a 7-bit signed |
d4e85050 BS |
130 | ;; constant. |
131 | (define_predicate "reg_or_neg7bit_operand" | |
132 | (ior (match_operand 0 "register_operand") | |
133 | (and (match_code "const_int") | |
9fdd7520 | 134 | (match_test "satisfies_constraint_KN7 (op)")))) |
d4e85050 | 135 | |
0d4a78eb BS |
136 | ;; Used for secondary reloads, this function returns 1 if OP is of the |
137 | ;; form (plus (fp) (const_int)). | |
138 | (define_predicate "fp_plus_const_operand" | |
139 | (match_code "plus") | |
140 | { | |
141 | rtx op1, op2; | |
142 | ||
143 | op1 = XEXP (op, 0); | |
144 | op2 = XEXP (op, 1); | |
145 | return (REG_P (op1) | |
146 | && (REGNO (op1) == FRAME_POINTER_REGNUM | |
147 | || REGNO (op1) == STACK_POINTER_REGNUM) | |
148 | && GET_CODE (op2) == CONST_INT); | |
149 | }) | |
150 | ||
151 | ;; Returns 1 if OP is a symbolic operand, i.e. a symbol_ref or a label_ref, | |
152 | ;; possibly with an offset. | |
153 | (define_predicate "symbolic_operand" | |
154 | (ior (match_code "symbol_ref,label_ref") | |
155 | (and (match_code "const") | |
156 | (match_test "GET_CODE (XEXP (op,0)) == PLUS | |
157 | && (GET_CODE (XEXP (XEXP (op, 0), 0)) == SYMBOL_REF | |
158 | || GET_CODE (XEXP (XEXP (op, 0), 0)) == LABEL_REF) | |
159 | && GET_CODE (XEXP (XEXP (op, 0), 1)) == CONST_INT")))) | |
160 | ||
161 | ;; Returns 1 if OP is a plain constant or matched by symbolic_operand. | |
162 | (define_predicate "symbolic_or_const_operand" | |
163 | (ior (match_code "const_int,const_double") | |
164 | (match_operand 0 "symbolic_operand"))) | |
165 | ||
6d459e2b BS |
166 | ;; Returns 1 if OP is a SYMBOL_REF. |
167 | (define_predicate "symbol_ref_operand" | |
168 | (match_code "symbol_ref")) | |
169 | ||
0d4a78eb BS |
170 | ;; True for any non-virtual or eliminable register. Used in places where |
171 | ;; instantiation of such a register may cause the pattern to not be recognized. | |
172 | (define_predicate "register_no_elim_operand" | |
173 | (match_operand 0 "register_operand") | |
174 | { | |
175 | if (GET_CODE (op) == SUBREG) | |
176 | op = SUBREG_REG (op); | |
177 | return !(op == arg_pointer_rtx | |
178 | || op == frame_pointer_rtx | |
179 | || (REGNO (op) >= FIRST_PSEUDO_REGISTER | |
180 | && REGNO (op) <= LAST_VIRTUAL_REGISTER)); | |
181 | }) | |
182 | ||
f90b7a5a PB |
183 | ;; Test for an operator valid in a BImode conditional branch |
184 | (define_predicate "bfin_bimode_comparison_operator" | |
0d4a78eb | 185 | (match_code "eq,ne")) |
36662eb1 | 186 | |
f90b7a5a PB |
187 | ;; Test for an operator whose result is accessible with movbisi. |
188 | (define_predicate "bfin_direct_comparison_operator" | |
189 | (match_code "eq,lt,le,leu,ltu")) | |
190 | ||
c7cb1555 | 191 | ;; The following three are used to compute the addrtype attribute. They return |
36662eb1 BS |
192 | ;; true if passed a memory address usable for a 16-bit load or store using a |
193 | ;; P or I register, respectively. If neither matches, we know we have a | |
942fd98f | 194 | ;; 32-bit instruction. |
c7cb1555 BS |
195 | ;; We subdivide the P case into normal P registers, and SP/FP. We can assume |
196 | ;; that speculative loads through SP and FP are no problem, so this has | |
197 | ;; an effect on the anomaly workaround code. | |
198 | ||
36662eb1 BS |
199 | (define_predicate "mem_p_address_operand" |
200 | (match_code "mem") | |
201 | { | |
202 | if (effective_address_32bit_p (op, mode)) | |
203 | return 0; | |
204 | op = XEXP (op, 0); | |
205 | if (GET_CODE (op) == PLUS || GET_RTX_CLASS (GET_CODE (op)) == RTX_AUTOINC) | |
206 | op = XEXP (op, 0); | |
207 | gcc_assert (REG_P (op)); | |
c7cb1555 BS |
208 | return PREG_P (op) && op != stack_pointer_rtx && op != frame_pointer_rtx; |
209 | }) | |
210 | ||
211 | (define_predicate "mem_spfp_address_operand" | |
212 | (match_code "mem") | |
213 | { | |
214 | if (effective_address_32bit_p (op, mode)) | |
215 | return 0; | |
216 | op = XEXP (op, 0); | |
217 | if (GET_CODE (op) == PLUS || GET_RTX_CLASS (GET_CODE (op)) == RTX_AUTOINC) | |
218 | op = XEXP (op, 0); | |
219 | gcc_assert (REG_P (op)); | |
220 | return op == stack_pointer_rtx || op == frame_pointer_rtx; | |
36662eb1 BS |
221 | }) |
222 | ||
223 | (define_predicate "mem_i_address_operand" | |
224 | (match_code "mem") | |
225 | { | |
226 | if (effective_address_32bit_p (op, mode)) | |
227 | return 0; | |
228 | op = XEXP (op, 0); | |
229 | if (GET_CODE (op) == PLUS || GET_RTX_CLASS (GET_CODE (op)) == RTX_AUTOINC) | |
230 | op = XEXP (op, 0); | |
231 | gcc_assert (REG_P (op)); | |
232 | return IREG_P (op); | |
233 | }) |