]>
Commit | Line | Data |
---|---|---|
a657c98a | 1 | ;; Predicate definitions for ARM and Thumb |
d1e082c2 | 2 | ;; Copyright (C) 2004-2013 Free Software Foundation, Inc. |
a657c98a RE |
3 | ;; Contributed by ARM Ltd. |
4 | ||
5 | ;; This file is part of GCC. | |
6 | ||
7 | ;; GCC is free software; you can redistribute it and/or modify it | |
8 | ;; under the terms of the GNU General Public License as published | |
2f83c7d6 | 9 | ;; by the Free Software Foundation; either version 3, or (at your |
a657c98a RE |
10 | ;; option) any later version. |
11 | ||
12 | ;; GCC is distributed in the hope that it will be useful, but WITHOUT | |
13 | ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
14 | ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public | |
15 | ;; 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/>. | |
a657c98a RE |
20 | |
21 | (define_predicate "s_register_operand" | |
22 | (match_code "reg,subreg") | |
23 | { | |
24 | if (GET_CODE (op) == SUBREG) | |
25 | op = SUBREG_REG (op); | |
26 | /* We don't consider registers whose class is NO_REGS | |
27 | to be a register operand. */ | |
28 | /* XXX might have to check for lo regs only for thumb ??? */ | |
d435a4be | 29 | return (REG_P (op) |
a657c98a RE |
30 | && (REGNO (op) >= FIRST_PSEUDO_REGISTER |
31 | || REGNO_REG_CLASS (REGNO (op)) != NO_REGS)); | |
32 | }) | |
33 | ||
1c50eada KT |
34 | (define_predicate "imm_for_neon_inv_logic_operand" |
35 | (match_code "const_vector") | |
36 | { | |
37 | return (TARGET_NEON | |
38 | && neon_immediate_valid_for_logic (op, mode, 1, NULL, NULL)); | |
39 | }) | |
40 | ||
41 | (define_predicate "neon_inv_logic_op2" | |
42 | (ior (match_operand 0 "imm_for_neon_inv_logic_operand") | |
43 | (match_operand 0 "s_register_operand"))) | |
44 | ||
b6af05a9 KT |
45 | (define_predicate "imm_for_neon_logic_operand" |
46 | (match_code "const_vector") | |
47 | { | |
48 | return (TARGET_NEON | |
49 | && neon_immediate_valid_for_logic (op, mode, 0, NULL, NULL)); | |
50 | }) | |
51 | ||
52 | (define_predicate "neon_logic_op2" | |
53 | (ior (match_operand 0 "imm_for_neon_logic_operand") | |
54 | (match_operand 0 "s_register_operand"))) | |
55 | ||
a657c98a RE |
56 | ;; Any hard register. |
57 | (define_predicate "arm_hard_register_operand" | |
58 | (match_code "reg") | |
59 | { | |
60 | return REGNO (op) < FIRST_PSEUDO_REGISTER; | |
61 | }) | |
62 | ||
5b3e6663 PB |
63 | ;; A low register. |
64 | (define_predicate "low_register_operand" | |
65 | (and (match_code "reg") | |
66 | (match_test "REGNO (op) <= LAST_LO_REGNUM"))) | |
67 | ||
68 | ;; A low register or const_int. | |
69 | (define_predicate "low_reg_or_int_operand" | |
70 | (ior (match_code "const_int") | |
71 | (match_operand 0 "low_register_operand"))) | |
72 | ||
a657c98a RE |
73 | ;; Any core register, or any pseudo. */ |
74 | (define_predicate "arm_general_register_operand" | |
75 | (match_code "reg,subreg") | |
76 | { | |
77 | if (GET_CODE (op) == SUBREG) | |
78 | op = SUBREG_REG (op); | |
79 | ||
d435a4be | 80 | return (REG_P (op) |
a657c98a RE |
81 | && (REGNO (op) <= LAST_ARM_REGNUM |
82 | || REGNO (op) >= FIRST_PSEUDO_REGISTER)); | |
83 | }) | |
84 | ||
4e6f5666 JZ |
85 | (define_predicate "vfp_register_operand" |
86 | (match_code "reg,subreg") | |
87 | { | |
88 | if (GET_CODE (op) == SUBREG) | |
89 | op = SUBREG_REG (op); | |
90 | ||
91 | /* We don't consider registers whose class is NO_REGS | |
92 | to be a register operand. */ | |
d435a4be | 93 | return (REG_P (op) |
4e6f5666 | 94 | && (REGNO (op) >= FIRST_PSEUDO_REGISTER |
34db4735 | 95 | || REGNO_REG_CLASS (REGNO (op)) == VFP_D0_D7_REGS |
4e6f5666 JZ |
96 | || REGNO_REG_CLASS (REGNO (op)) == VFP_LO_REGS |
97 | || (TARGET_VFPD32 | |
98 | && REGNO_REG_CLASS (REGNO (op)) == VFP_REGS))); | |
99 | }) | |
100 | ||
681676df RE |
101 | (define_predicate "zero_operand" |
102 | (and (match_code "const_int,const_double,const_vector") | |
103 | (match_test "op == CONST0_RTX (mode)"))) | |
104 | ||
105 | ;; Match a register, or zero in the appropriate mode. | |
106 | (define_predicate "reg_or_zero_operand" | |
107 | (ior (match_operand 0 "s_register_operand") | |
108 | (match_operand 0 "zero_operand"))) | |
109 | ||
fa01135d RE |
110 | (define_special_predicate "subreg_lowpart_operator" |
111 | (and (match_code "subreg") | |
112 | (match_test "subreg_lowpart_p (op)"))) | |
113 | ||
a657c98a RE |
114 | ;; Reg, subreg(reg) or const_int. |
115 | (define_predicate "reg_or_int_operand" | |
116 | (ior (match_code "const_int") | |
117 | (match_operand 0 "s_register_operand"))) | |
118 | ||
119 | (define_predicate "arm_immediate_operand" | |
120 | (and (match_code "const_int") | |
121 | (match_test "const_ok_for_arm (INTVAL (op))"))) | |
122 | ||
73160ba9 DJ |
123 | ;; A constant value which fits into two instructions, each taking |
124 | ;; an arithmetic constant operand for one of the words. | |
125 | (define_predicate "arm_immediate_di_operand" | |
126 | (and (match_code "const_int,const_double") | |
127 | (match_test "arm_const_double_by_immediates (op)"))) | |
128 | ||
a657c98a RE |
129 | (define_predicate "arm_neg_immediate_operand" |
130 | (and (match_code "const_int") | |
131 | (match_test "const_ok_for_arm (-INTVAL (op))"))) | |
132 | ||
133 | (define_predicate "arm_not_immediate_operand" | |
134 | (and (match_code "const_int") | |
135 | (match_test "const_ok_for_arm (~INTVAL (op))"))) | |
136 | ||
f0c6475a BS |
137 | (define_predicate "const0_operand" |
138 | (and (match_code "const_int") | |
139 | (match_test "INTVAL (op) == 0"))) | |
140 | ||
a657c98a RE |
141 | ;; Something valid on the RHS of an ARM data-processing instruction |
142 | (define_predicate "arm_rhs_operand" | |
143 | (ior (match_operand 0 "s_register_operand") | |
144 | (match_operand 0 "arm_immediate_operand"))) | |
145 | ||
146 | (define_predicate "arm_rhsm_operand" | |
147 | (ior (match_operand 0 "arm_rhs_operand") | |
148 | (match_operand 0 "memory_operand"))) | |
149 | ||
55cdadd5 AS |
150 | ;; This doesn't have to do much because the constant is already checked |
151 | ;; in the shift_operator predicate. | |
c29e2982 BS |
152 | (define_predicate "shift_amount_operand" |
153 | (ior (and (match_test "TARGET_ARM") | |
154 | (match_operand 0 "s_register_operand")) | |
55cdadd5 | 155 | (match_operand 0 "const_int_operand"))) |
c29e2982 | 156 | |
36ba4aae IR |
157 | (define_predicate "const_neon_scalar_shift_amount_operand" |
158 | (and (match_code "const_int") | |
159 | (match_test "((unsigned HOST_WIDE_INT) INTVAL (op)) <= GET_MODE_BITSIZE (mode) | |
160 | && ((unsigned HOST_WIDE_INT) INTVAL (op)) > 0"))) | |
161 | ||
56289ed2 SD |
162 | (define_predicate "ldrd_strd_offset_operand" |
163 | (and (match_operand 0 "const_int_operand") | |
164 | (match_test "TARGET_LDRD && offset_ok_for_ldrd_strd (INTVAL (op))"))) | |
165 | ||
a657c98a RE |
166 | (define_predicate "arm_add_operand" |
167 | (ior (match_operand 0 "arm_rhs_operand") | |
168 | (match_operand 0 "arm_neg_immediate_operand"))) | |
169 | ||
1c50eada KT |
170 | (define_predicate "arm_anddi_operand_neon" |
171 | (ior (match_operand 0 "s_register_operand") | |
172 | (and (match_code "const_int") | |
173 | (match_test "const_ok_for_dimode_op (INTVAL (op), AND)")) | |
174 | (match_operand 0 "neon_inv_logic_op2"))) | |
175 | ||
b6af05a9 KT |
176 | (define_predicate "arm_iordi_operand_neon" |
177 | (ior (match_operand 0 "s_register_operand") | |
178 | (and (match_code "const_int") | |
179 | (match_test "const_ok_for_dimode_op (INTVAL (op), IOR)")) | |
180 | (match_operand 0 "neon_logic_op2"))) | |
181 | ||
79678d04 KT |
182 | (define_predicate "arm_xordi_operand" |
183 | (ior (match_operand 0 "s_register_operand") | |
184 | (and (match_code "const_int") | |
185 | (match_test "const_ok_for_dimode_op (INTVAL (op), XOR)")))) | |
186 | ||
44cd6810 WG |
187 | (define_predicate "arm_adddi_operand" |
188 | (ior (match_operand 0 "s_register_operand") | |
189 | (and (match_code "const_int") | |
190 | (match_test "const_ok_for_dimode_op (INTVAL (op), PLUS)")))) | |
191 | ||
a657c98a RE |
192 | (define_predicate "arm_addimm_operand" |
193 | (ior (match_operand 0 "arm_immediate_operand") | |
194 | (match_operand 0 "arm_neg_immediate_operand"))) | |
195 | ||
196 | (define_predicate "arm_not_operand" | |
197 | (ior (match_operand 0 "arm_rhs_operand") | |
198 | (match_operand 0 "arm_not_immediate_operand"))) | |
199 | ||
73160ba9 DJ |
200 | (define_predicate "arm_di_operand" |
201 | (ior (match_operand 0 "s_register_operand") | |
202 | (match_operand 0 "arm_immediate_di_operand"))) | |
203 | ||
a657c98a RE |
204 | ;; True if the operand is a memory reference which contains an |
205 | ;; offsettable address. | |
206 | (define_predicate "offsettable_memory_operand" | |
207 | (and (match_code "mem") | |
208 | (match_test | |
209 | "offsettable_address_p (reload_completed | reload_in_progress, | |
210 | mode, XEXP (op, 0))"))) | |
211 | ||
e6add59b RS |
212 | ;; True if the operand is a memory operand that does not have an |
213 | ;; automodified base register (and thus will not generate output reloads). | |
214 | (define_predicate "call_memory_operand" | |
215 | (and (match_code "mem") | |
216 | (and (match_test "GET_RTX_CLASS (GET_CODE (XEXP (op, 0))) | |
217 | != RTX_AUTOINC") | |
218 | (match_operand 0 "memory_operand")))) | |
219 | ||
a657c98a | 220 | (define_predicate "arm_reload_memory_operand" |
9d2da95b | 221 | (and (match_code "mem,reg,subreg") |
a657c98a RE |
222 | (match_test "(!CONSTANT_P (op) |
223 | && (true_regnum(op) == -1 | |
d435a4be | 224 | || (REG_P (op) |
a657c98a RE |
225 | && REGNO (op) >= FIRST_PSEUDO_REGISTER)))"))) |
226 | ||
a657c98a RE |
227 | (define_predicate "vfp_compare_operand" |
228 | (ior (match_operand 0 "s_register_operand") | |
229 | (and (match_code "const_double") | |
230 | (match_test "arm_const_double_rtx (op)")))) | |
231 | ||
232 | (define_predicate "arm_float_compare_operand" | |
233 | (if_then_else (match_test "TARGET_VFP") | |
234 | (match_operand 0 "vfp_compare_operand") | |
dae840fc | 235 | (match_operand 0 "s_register_operand"))) |
a657c98a RE |
236 | |
237 | ;; True for valid index operands. | |
238 | (define_predicate "index_operand" | |
239 | (ior (match_operand 0 "s_register_operand") | |
240 | (and (match_operand 0 "immediate_operand") | |
d435a4be | 241 | (match_test "(!CONST_INT_P (op) |
a657c98a RE |
242 | || (INTVAL (op) < 4096 && INTVAL (op) > -4096))")))) |
243 | ||
244 | ;; True for operators that can be combined with a shift in ARM state. | |
245 | (define_special_predicate "shiftable_operator" | |
246 | (and (match_code "plus,minus,ior,xor,and") | |
247 | (match_test "mode == GET_MODE (op)"))) | |
248 | ||
c112cf2b | 249 | ;; True for logical binary operators. |
a657c98a RE |
250 | (define_special_predicate "logical_binary_operator" |
251 | (and (match_code "ior,xor,and") | |
252 | (match_test "mode == GET_MODE (op)"))) | |
253 | ||
37119410 BS |
254 | ;; True for commutative operators |
255 | (define_special_predicate "commutative_binary_operator" | |
256 | (and (match_code "ior,xor,and,plus") | |
257 | (match_test "mode == GET_MODE (op)"))) | |
258 | ||
a657c98a | 259 | ;; True for shift operators. |
55cdadd5 AS |
260 | ;; Notes: |
261 | ;; * mult is only permitted with a constant shift amount | |
262 | ;; * patterns that permit register shift amounts only in ARM mode use | |
263 | ;; shift_amount_operand, patterns that always allow registers do not, | |
264 | ;; so we don't have to worry about that sort of thing here. | |
a657c98a RE |
265 | (define_special_predicate "shift_operator" |
266 | (and (ior (ior (and (match_code "mult") | |
267 | (match_test "power_of_two_operand (XEXP (op, 1), mode)")) | |
268 | (and (match_code "rotate") | |
d435a4be | 269 | (match_test "CONST_INT_P (XEXP (op, 1)) |
a657c98a | 270 | && ((unsigned HOST_WIDE_INT) INTVAL (XEXP (op, 1))) < 32"))) |
55cdadd5 | 271 | (and (match_code "ashift,ashiftrt,lshiftrt,rotatert") |
d435a4be | 272 | (match_test "!CONST_INT_P (XEXP (op, 1)) |
55cdadd5 | 273 | || ((unsigned HOST_WIDE_INT) INTVAL (XEXP (op, 1))) < 32"))) |
a657c98a RE |
274 | (match_test "mode == GET_MODE (op)"))) |
275 | ||
655b30bf JB |
276 | ;; True for shift operators which can be used with saturation instructions. |
277 | (define_special_predicate "sat_shift_operator" | |
5d216c70 UW |
278 | (and (ior (and (match_code "mult") |
279 | (match_test "power_of_two_operand (XEXP (op, 1), mode)")) | |
280 | (and (match_code "ashift,ashiftrt") | |
d435a4be | 281 | (match_test "CONST_INT_P (XEXP (op, 1)) |
5d216c70 | 282 | && ((unsigned HOST_WIDE_INT) INTVAL (XEXP (op, 1)) < 32)"))) |
655b30bf JB |
283 | (match_test "mode == GET_MODE (op)"))) |
284 | ||
c29e2982 BS |
285 | ;; True for MULT, to identify which variant of shift_operator is in use. |
286 | (define_special_predicate "mult_operator" | |
287 | (match_code "mult")) | |
288 | ||
5b3e6663 PB |
289 | ;; True for operators that have 16-bit thumb variants. */ |
290 | (define_special_predicate "thumb_16bit_operator" | |
291 | (match_code "plus,minus,and,ior,xor")) | |
292 | ||
a657c98a RE |
293 | ;; True for EQ & NE |
294 | (define_special_predicate "equality_operator" | |
295 | (match_code "eq,ne")) | |
296 | ||
f90b7a5a PB |
297 | ;; True for integer comparisons and, if FP is active, for comparisons |
298 | ;; other than LTGT or UNEQ. | |
aa0b3f8f RS |
299 | (define_special_predicate "expandable_comparison_operator" |
300 | (match_code "eq,ne,le,lt,ge,gt,geu,gtu,leu,ltu, | |
301 | unordered,ordered,unlt,unle,unge,ungt")) | |
302 | ||
303 | ;; Likewise, but only accept comparisons that are directly supported | |
304 | ;; by ARM condition codes. | |
a657c98a | 305 | (define_special_predicate "arm_comparison_operator" |
aa0b3f8f | 306 | (and (match_operand 0 "expandable_comparison_operator") |
723d95fe | 307 | (match_test "maybe_get_arm_condition_code (op) != ARM_NV"))) |
a657c98a | 308 | |
f0c6475a BS |
309 | (define_special_predicate "lt_ge_comparison_operator" |
310 | (match_code "lt,ge")) | |
311 | ||
a5a4c20a KT |
312 | ;; The vsel instruction only accepts the ARM condition codes listed below. |
313 | (define_special_predicate "arm_vsel_comparison_operator" | |
314 | (and (match_operand 0 "expandable_comparison_operator") | |
315 | (match_test "maybe_get_arm_condition_code (op) == ARM_GE | |
316 | || maybe_get_arm_condition_code (op) == ARM_GT | |
317 | || maybe_get_arm_condition_code (op) == ARM_EQ | |
318 | || maybe_get_arm_condition_code (op) == ARM_VS | |
319 | || maybe_get_arm_condition_code (op) == ARM_LT | |
320 | || maybe_get_arm_condition_code (op) == ARM_LE | |
321 | || maybe_get_arm_condition_code (op) == ARM_NE | |
322 | || maybe_get_arm_condition_code (op) == ARM_VC"))) | |
323 | ||
906668bb BS |
324 | (define_special_predicate "noov_comparison_operator" |
325 | (match_code "lt,ge,eq,ne")) | |
326 | ||
a657c98a RE |
327 | (define_special_predicate "minmax_operator" |
328 | (and (match_code "smin,smax,umin,umax") | |
329 | (match_test "mode == GET_MODE (op)"))) | |
330 | ||
331 | (define_special_predicate "cc_register" | |
332 | (and (match_code "reg") | |
333 | (and (match_test "REGNO (op) == CC_REGNUM") | |
334 | (ior (match_test "mode == GET_MODE (op)") | |
335 | (match_test "mode == VOIDmode && GET_MODE_CLASS (GET_MODE (op)) == MODE_CC"))))) | |
336 | ||
337 | (define_special_predicate "dominant_cc_register" | |
338 | (match_code "reg") | |
339 | { | |
340 | if (mode == VOIDmode) | |
341 | { | |
342 | mode = GET_MODE (op); | |
343 | ||
344 | if (GET_MODE_CLASS (mode) != MODE_CC) | |
345 | return false; | |
346 | } | |
347 | ||
348 | return (cc_register (op, mode) | |
349 | && (mode == CC_DNEmode | |
350 | || mode == CC_DEQmode | |
351 | || mode == CC_DLEmode | |
352 | || mode == CC_DLTmode | |
353 | || mode == CC_DGEmode | |
354 | || mode == CC_DGTmode | |
355 | || mode == CC_DLEUmode | |
356 | || mode == CC_DLTUmode | |
357 | || mode == CC_DGEUmode | |
358 | || mode == CC_DGTUmode)); | |
359 | }) | |
360 | ||
361 | (define_special_predicate "arm_extendqisi_mem_op" | |
362 | (and (match_operand 0 "memory_operand") | |
8d4f1548 RR |
363 | (match_test "TARGET_ARM ? arm_legitimate_address_outer_p (mode, |
364 | XEXP (op, 0), | |
365 | SIGN_EXTEND, | |
366 | 0) | |
367 | : memory_address_p (QImode, XEXP (op, 0))"))) | |
a657c98a | 368 | |
01577df7 RE |
369 | (define_special_predicate "arm_reg_or_extendqisi_mem_op" |
370 | (ior (match_operand 0 "arm_extendqisi_mem_op") | |
371 | (match_operand 0 "s_register_operand"))) | |
372 | ||
a657c98a RE |
373 | (define_predicate "power_of_two_operand" |
374 | (match_code "const_int") | |
375 | { | |
29b40d79 | 376 | unsigned HOST_WIDE_INT value = INTVAL (op) & 0xffffffff; |
a657c98a RE |
377 | |
378 | return value != 0 && (value & (value - 1)) == 0; | |
379 | }) | |
380 | ||
381 | (define_predicate "nonimmediate_di_operand" | |
382 | (match_code "reg,subreg,mem") | |
383 | { | |
384 | if (s_register_operand (op, mode)) | |
385 | return true; | |
386 | ||
387 | if (GET_CODE (op) == SUBREG) | |
388 | op = SUBREG_REG (op); | |
389 | ||
d435a4be | 390 | return MEM_P (op) && memory_address_p (DImode, XEXP (op, 0)); |
a657c98a RE |
391 | }) |
392 | ||
393 | (define_predicate "di_operand" | |
394 | (ior (match_code "const_int,const_double") | |
395 | (and (match_code "reg,subreg,mem") | |
396 | (match_operand 0 "nonimmediate_di_operand")))) | |
397 | ||
398 | (define_predicate "nonimmediate_soft_df_operand" | |
399 | (match_code "reg,subreg,mem") | |
400 | { | |
401 | if (s_register_operand (op, mode)) | |
402 | return true; | |
403 | ||
404 | if (GET_CODE (op) == SUBREG) | |
405 | op = SUBREG_REG (op); | |
406 | ||
d435a4be | 407 | return MEM_P (op) && memory_address_p (DFmode, XEXP (op, 0)); |
a657c98a RE |
408 | }) |
409 | ||
410 | (define_predicate "soft_df_operand" | |
411 | (ior (match_code "const_double") | |
412 | (and (match_code "reg,subreg,mem") | |
413 | (match_operand 0 "nonimmediate_soft_df_operand")))) | |
414 | ||
a657c98a RE |
415 | (define_special_predicate "load_multiple_operation" |
416 | (match_code "parallel") | |
417 | { | |
fb40241d IB |
418 | return ldm_stm_operation_p (op, /*load=*/true, SImode, |
419 | /*consecutive=*/false, | |
420 | /*return_pc=*/false); | |
a657c98a RE |
421 | }) |
422 | ||
423 | (define_special_predicate "store_multiple_operation" | |
424 | (match_code "parallel") | |
425 | { | |
fb40241d IB |
426 | return ldm_stm_operation_p (op, /*load=*/false, SImode, |
427 | /*consecutive=*/false, | |
428 | /*return_pc=*/false); | |
a657c98a RE |
429 | }) |
430 | ||
3aee1982 IB |
431 | (define_special_predicate "pop_multiple_return" |
432 | (match_code "parallel") | |
433 | { | |
434 | return ldm_stm_operation_p (op, /*load=*/true, SImode, | |
435 | /*consecutive=*/false, | |
436 | /*return_pc=*/true); | |
437 | }) | |
438 | ||
4b2678f8 IB |
439 | (define_special_predicate "pop_multiple_fp" |
440 | (match_code "parallel") | |
441 | { | |
442 | return ldm_stm_operation_p (op, /*load=*/true, DFmode, | |
443 | /*consecutive=*/true, | |
444 | /*return_pc=*/false); | |
445 | }) | |
446 | ||
a657c98a RE |
447 | (define_special_predicate "multi_register_push" |
448 | (match_code "parallel") | |
449 | { | |
450 | if ((GET_CODE (XVECEXP (op, 0, 0)) != SET) | |
451 | || (GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != UNSPEC) | |
452 | || (XINT (SET_SRC (XVECEXP (op, 0, 0)), 1) != UNSPEC_PUSH_MULT)) | |
453 | return false; | |
454 | ||
455 | return true; | |
456 | }) | |
457 | ||
d018b46e RH |
458 | (define_predicate "push_mult_memory_operand" |
459 | (match_code "mem") | |
460 | { | |
461 | /* ??? Given how PUSH_MULT is generated in the prologues, is there | |
462 | any point in testing for thumb1 specially? All of the variants | |
463 | use the same form. */ | |
464 | if (TARGET_THUMB1) | |
465 | { | |
466 | /* ??? No attempt is made to represent STMIA, or validate that | |
467 | the stack adjustment matches the register count. This is | |
468 | true of the ARM/Thumb2 path as well. */ | |
469 | rtx x = XEXP (op, 0); | |
470 | if (GET_CODE (x) != PRE_MODIFY) | |
471 | return false; | |
472 | if (XEXP (x, 0) != stack_pointer_rtx) | |
473 | return false; | |
474 | x = XEXP (x, 1); | |
475 | if (GET_CODE (x) != PLUS) | |
476 | return false; | |
477 | if (XEXP (x, 0) != stack_pointer_rtx) | |
478 | return false; | |
479 | return CONST_INT_P (XEXP (x, 1)); | |
480 | } | |
481 | ||
482 | /* ARM and Thumb2 handle pre-modify in their legitimate_address. */ | |
483 | return memory_operand (op, mode); | |
484 | }) | |
485 | ||
a657c98a RE |
486 | ;;------------------------------------------------------------------------- |
487 | ;; | |
488 | ;; Thumb predicates | |
489 | ;; | |
490 | ||
5b3e6663 | 491 | (define_predicate "thumb1_cmp_operand" |
a657c98a RE |
492 | (ior (and (match_code "reg,subreg") |
493 | (match_operand 0 "s_register_operand")) | |
494 | (and (match_code "const_int") | |
495 | (match_test "((unsigned HOST_WIDE_INT) INTVAL (op)) < 256")))) | |
496 | ||
5b3e6663 | 497 | (define_predicate "thumb1_cmpneg_operand" |
a657c98a RE |
498 | (and (match_code "const_int") |
499 | (match_test "INTVAL (op) < 0 && INTVAL (op) > -256"))) | |
500 | ||
501 | ;; Return TRUE if a result can be stored in OP without clobbering the | |
502 | ;; condition code register. Prior to reload we only accept a | |
503 | ;; register. After reload we have to be able to handle memory as | |
504 | ;; well, since a pseudo may not get a hard reg and reload cannot | |
505 | ;; handle output-reloads on jump insns. | |
506 | ||
507 | ;; We could possibly handle mem before reload as well, but that might | |
508 | ;; complicate things with the need to handle increment | |
509 | ;; side-effects. | |
510 | (define_predicate "thumb_cbrch_target_operand" | |
511 | (and (match_code "reg,subreg,mem") | |
512 | (ior (match_operand 0 "s_register_operand") | |
513 | (and (match_test "reload_in_progress || reload_completed") | |
514 | (match_operand 0 "memory_operand"))))) | |
515 | ||
516 | ;;------------------------------------------------------------------------- | |
517 | ;; | |
8fd03515 | 518 | ;; iWMMXt predicates |
dae840fc | 519 | ;; |
8fd03515 XQ |
520 | |
521 | (define_predicate "imm_or_reg_operand" | |
522 | (ior (match_operand 0 "immediate_operand") | |
523 | (match_operand 0 "register_operand"))) | |
a657c98a | 524 | |
88f77cba JB |
525 | ;; Neon predicates |
526 | ||
527 | (define_predicate "const_multiple_of_8_operand" | |
528 | (match_code "const_int") | |
529 | { | |
530 | unsigned HOST_WIDE_INT val = INTVAL (op); | |
531 | return (val & 7) == 0; | |
532 | }) | |
533 | ||
534 | (define_predicate "imm_for_neon_mov_operand" | |
00a3a76a | 535 | (match_code "const_vector,const_int") |
88f77cba JB |
536 | { |
537 | return neon_immediate_valid_for_move (op, mode, NULL, NULL); | |
538 | }) | |
539 | ||
31a0c825 DP |
540 | (define_predicate "imm_for_neon_lshift_operand" |
541 | (match_code "const_vector") | |
542 | { | |
543 | return neon_immediate_valid_for_shift (op, mode, NULL, NULL, true); | |
544 | }) | |
545 | ||
546 | (define_predicate "imm_for_neon_rshift_operand" | |
547 | (match_code "const_vector") | |
548 | { | |
549 | return neon_immediate_valid_for_shift (op, mode, NULL, NULL, false); | |
550 | }) | |
551 | ||
552 | (define_predicate "imm_lshift_or_reg_neon" | |
553 | (ior (match_operand 0 "s_register_operand") | |
554 | (match_operand 0 "imm_for_neon_lshift_operand"))) | |
555 | ||
556 | (define_predicate "imm_rshift_or_reg_neon" | |
557 | (ior (match_operand 0 "s_register_operand") | |
558 | (match_operand 0 "imm_for_neon_rshift_operand"))) | |
559 | ||
73160ba9 DJ |
560 | ;; Predicates for named expanders that overlap multiple ISAs. |
561 | ||
562 | (define_predicate "cmpdi_operand" | |
dae840fc RE |
563 | (and (match_test "TARGET_32BIT") |
564 | (match_operand 0 "arm_di_operand"))) | |
88f77cba | 565 | |
999a9cc5 MS |
566 | ;; True if the operand is memory reference suitable for a ldrex/strex. |
567 | (define_predicate "arm_sync_memory_operand" | |
568 | (and (match_operand 0 "memory_operand") | |
569 | (match_code "reg" "0"))) | |
570 | ||
46b57af1 TB |
571 | ;; Predicates for parallel expanders based on mode. |
572 | (define_special_predicate "vect_par_constant_high" | |
573 | (match_code "parallel") | |
574 | { | |
575 | HOST_WIDE_INT count = XVECLEN (op, 0); | |
576 | int i; | |
577 | int base = GET_MODE_NUNITS (mode); | |
578 | ||
579 | if ((count < 1) | |
580 | || (count != base/2)) | |
581 | return false; | |
582 | ||
583 | if (!VECTOR_MODE_P (mode)) | |
584 | return false; | |
585 | ||
586 | for (i = 0; i < count; i++) | |
587 | { | |
588 | rtx elt = XVECEXP (op, 0, i); | |
589 | int val; | |
590 | ||
d435a4be | 591 | if (!CONST_INT_P (elt)) |
46b57af1 TB |
592 | return false; |
593 | ||
594 | val = INTVAL (elt); | |
595 | if (val != (base/2) + i) | |
596 | return false; | |
597 | } | |
598 | return true; | |
599 | }) | |
600 | ||
601 | (define_special_predicate "vect_par_constant_low" | |
602 | (match_code "parallel") | |
603 | { | |
604 | HOST_WIDE_INT count = XVECLEN (op, 0); | |
605 | int i; | |
606 | int base = GET_MODE_NUNITS (mode); | |
607 | ||
608 | if ((count < 1) | |
609 | || (count != base/2)) | |
610 | return false; | |
611 | ||
612 | if (!VECTOR_MODE_P (mode)) | |
613 | return false; | |
614 | ||
615 | for (i = 0; i < count; i++) | |
616 | { | |
617 | rtx elt = XVECEXP (op, 0, i); | |
618 | int val; | |
619 | ||
d435a4be | 620 | if (!CONST_INT_P (elt)) |
46b57af1 TB |
621 | return false; |
622 | ||
623 | val = INTVAL (elt); | |
624 | if (val != i) | |
625 | return false; | |
626 | } | |
627 | return true; | |
628 | }) | |
6308e208 | 629 | |
7f3d8f56 RR |
630 | (define_predicate "const_double_vcvt_power_of_two_reciprocal" |
631 | (and (match_code "const_double") | |
632 | (match_test "TARGET_32BIT && TARGET_VFP | |
633 | && vfp3_const_double_for_fract_bits (op)"))) | |
634 | ||
12c4ecb1 | 635 | (define_predicate "neon_struct_operand" |
6308e208 RS |
636 | (and (match_code "mem") |
637 | (match_test "TARGET_32BIT && neon_vector_mem_operand (op, 2)"))) | |
9a1ea4b9 | 638 | |
12c4ecb1 RS |
639 | (define_predicate "neon_struct_or_register_operand" |
640 | (ior (match_operand 0 "neon_struct_operand") | |
641 | (match_operand 0 "s_register_operand"))) | |
642 | ||
9a1ea4b9 RR |
643 | (define_special_predicate "add_operator" |
644 | (match_code "plus")) | |
18f0fe6b RH |
645 | |
646 | (define_predicate "mem_noofs_operand" | |
647 | (and (match_code "mem") | |
648 | (match_code "reg" "0"))) | |
9adcfa3c RR |
649 | |
650 | (define_predicate "call_insn_operand" | |
651 | (ior (match_code "symbol_ref") | |
652 | (match_operand 0 "s_register_operand"))) |