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