comparison gcc/config/arm/predicates.md @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 ;; Predicate definitions for ARM and Thumb 1 ;; Predicate definitions for ARM and Thumb
2 ;; Copyright (C) 2004, 2007, 2008, 2010 Free Software Foundation, Inc. 2 ;; Copyright (C) 2004-2017 Free Software Foundation, Inc.
3 ;; Contributed by ARM Ltd. 3 ;; Contributed by ARM Ltd.
4 4
5 ;; This file is part of GCC. 5 ;; This file is part of GCC.
6 6
7 ;; GCC is free software; you can redistribute it and/or modify it 7 ;; GCC is free software; you can redistribute it and/or modify it
24 if (GET_CODE (op) == SUBREG) 24 if (GET_CODE (op) == SUBREG)
25 op = SUBREG_REG (op); 25 op = SUBREG_REG (op);
26 /* We don't consider registers whose class is NO_REGS 26 /* We don't consider registers whose class is NO_REGS
27 to be a register operand. */ 27 to be a register operand. */
28 /* XXX might have to check for lo regs only for thumb ??? */ 28 /* XXX might have to check for lo regs only for thumb ??? */
29 return (GET_CODE (op) == REG 29 return (REG_P (op)
30 && (REGNO (op) >= FIRST_PSEUDO_REGISTER 30 && (REGNO (op) >= FIRST_PSEUDO_REGISTER
31 || REGNO_REG_CLASS (REGNO (op)) != NO_REGS)); 31 || REGNO_REG_CLASS (REGNO (op)) != NO_REGS));
32 }) 32 })
33 33
34 ;; Any hard register. 34 (define_predicate "imm_for_neon_inv_logic_operand"
35 (define_predicate "arm_hard_register_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
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
56 ;; Any general register.
57 (define_predicate "arm_hard_general_register_operand"
36 (match_code "reg") 58 (match_code "reg")
37 { 59 {
38 return REGNO (op) < FIRST_PSEUDO_REGISTER; 60 return REGNO (op) <= LAST_ARM_REGNUM;
39 }) 61 })
40 62
41 ;; A low register. 63 ;; A low register.
42 (define_predicate "low_register_operand" 64 (define_predicate "low_register_operand"
43 (and (match_code "reg") 65 (and (match_code "reg")
53 (match_code "reg,subreg") 75 (match_code "reg,subreg")
54 { 76 {
55 if (GET_CODE (op) == SUBREG) 77 if (GET_CODE (op) == SUBREG)
56 op = SUBREG_REG (op); 78 op = SUBREG_REG (op);
57 79
58 return (GET_CODE (op) == REG 80 return (REG_P (op)
59 && (REGNO (op) <= LAST_ARM_REGNUM 81 && (REGNO (op) <= LAST_ARM_REGNUM
60 || REGNO (op) >= FIRST_PSEUDO_REGISTER)); 82 || REGNO (op) >= FIRST_PSEUDO_REGISTER));
61 }) 83 })
62 84
63 (define_predicate "f_register_operand" 85 (define_predicate "arm_general_adddi_operand"
86 (ior (match_operand 0 "arm_general_register_operand")
87 (and (match_code "const_int")
88 (match_test "const_ok_for_dimode_op (INTVAL (op), PLUS)"))))
89
90 (define_predicate "vfp_register_operand"
64 (match_code "reg,subreg") 91 (match_code "reg,subreg")
65 { 92 {
66 if (GET_CODE (op) == SUBREG) 93 if (GET_CODE (op) == SUBREG)
67 op = SUBREG_REG (op); 94 op = SUBREG_REG (op);
68 95
69 /* We don't consider registers whose class is NO_REGS 96 /* We don't consider registers whose class is NO_REGS
70 to be a register operand. */ 97 to be a register operand. */
71 return (GET_CODE (op) == REG 98 return (REG_P (op)
72 && (REGNO (op) >= FIRST_PSEUDO_REGISTER
73 || REGNO_REG_CLASS (REGNO (op)) == FPA_REGS));
74 })
75
76 (define_predicate "vfp_register_operand"
77 (match_code "reg,subreg")
78 {
79 if (GET_CODE (op) == SUBREG)
80 op = SUBREG_REG (op);
81
82 /* We don't consider registers whose class is NO_REGS
83 to be a register operand. */
84 return (GET_CODE (op) == REG
85 && (REGNO (op) >= FIRST_PSEUDO_REGISTER 99 && (REGNO (op) >= FIRST_PSEUDO_REGISTER
86 || REGNO_REG_CLASS (REGNO (op)) == VFP_D0_D7_REGS 100 || REGNO_REG_CLASS (REGNO (op)) == VFP_D0_D7_REGS
87 || REGNO_REG_CLASS (REGNO (op)) == VFP_LO_REGS 101 || REGNO_REG_CLASS (REGNO (op)) == VFP_LO_REGS
88 || (TARGET_VFPD32 102 || (TARGET_VFPD32
89 && REGNO_REG_CLASS (REGNO (op)) == VFP_REGS))); 103 && REGNO_REG_CLASS (REGNO (op)) == VFP_REGS)));
90 }) 104 })
91 105
106 (define_predicate "vfp_hard_register_operand"
107 (match_code "reg")
108 {
109 return (IS_VFP_REGNUM (REGNO (op)));
110 })
111
112 (define_predicate "zero_operand"
113 (and (match_code "const_int,const_double,const_vector")
114 (match_test "op == CONST0_RTX (mode)")))
115
116 ;; Match a register, or zero in the appropriate mode.
117 (define_predicate "reg_or_zero_operand"
118 (ior (match_operand 0 "s_register_operand")
119 (match_operand 0 "zero_operand")))
120
92 (define_special_predicate "subreg_lowpart_operator" 121 (define_special_predicate "subreg_lowpart_operator"
93 (and (match_code "subreg") 122 (and (match_code "subreg")
94 (match_test "subreg_lowpart_p (op)"))) 123 (match_test "subreg_lowpart_p (op)")))
95 124
96 ;; Reg, subreg(reg) or const_int. 125 ;; Reg, subreg(reg) or const_int.
115 (define_predicate "arm_not_immediate_operand" 144 (define_predicate "arm_not_immediate_operand"
116 (and (match_code "const_int") 145 (and (match_code "const_int")
117 (match_test "const_ok_for_arm (~INTVAL (op))"))) 146 (match_test "const_ok_for_arm (~INTVAL (op))")))
118 147
119 (define_predicate "const0_operand" 148 (define_predicate "const0_operand"
120 (and (match_code "const_int") 149 (match_test "op == CONST0_RTX (mode)"))
121 (match_test "INTVAL (op) == 0")))
122 150
123 ;; Something valid on the RHS of an ARM data-processing instruction 151 ;; Something valid on the RHS of an ARM data-processing instruction
124 (define_predicate "arm_rhs_operand" 152 (define_predicate "arm_rhs_operand"
125 (ior (match_operand 0 "s_register_operand") 153 (ior (match_operand 0 "s_register_operand")
126 (match_operand 0 "arm_immediate_operand"))) 154 (match_operand 0 "arm_immediate_operand")))
127 155
128 (define_predicate "arm_rhsm_operand" 156 (define_predicate "arm_rhsm_operand"
129 (ior (match_operand 0 "arm_rhs_operand") 157 (ior (match_operand 0 "arm_rhs_operand")
130 (match_operand 0 "memory_operand"))) 158 (match_operand 0 "memory_operand")))
131 159
160 (define_predicate "const_int_I_operand"
161 (and (match_operand 0 "const_int_operand")
162 (match_test "satisfies_constraint_I (op)")))
163
164 (define_predicate "const_int_M_operand"
165 (and (match_operand 0 "const_int_operand")
166 (match_test "satisfies_constraint_M (op)")))
167
168 ;; This doesn't have to do much because the constant is already checked
169 ;; in the shift_operator predicate.
132 (define_predicate "shift_amount_operand" 170 (define_predicate "shift_amount_operand"
133 (ior (and (match_test "TARGET_ARM") 171 (ior (and (match_test "TARGET_ARM")
134 (match_operand 0 "s_register_operand")) 172 (match_operand 0 "s_register_operand"))
135 (match_operand 0 "const_int_operand"))) 173 (match_operand 0 "const_int_operand")))
136 174
175 (define_predicate "const_neon_scalar_shift_amount_operand"
176 (and (match_code "const_int")
177 (match_test "IN_RANGE (UINTVAL (op), 1, GET_MODE_BITSIZE (mode))")))
178
179 (define_predicate "ldrd_strd_offset_operand"
180 (and (match_operand 0 "const_int_operand")
181 (match_test "TARGET_LDRD && offset_ok_for_ldrd_strd (INTVAL (op))")))
182
137 (define_predicate "arm_add_operand" 183 (define_predicate "arm_add_operand"
138 (ior (match_operand 0 "arm_rhs_operand") 184 (ior (match_operand 0 "arm_rhs_operand")
139 (match_operand 0 "arm_neg_immediate_operand"))) 185 (match_operand 0 "arm_neg_immediate_operand")))
186
187 (define_predicate "arm_anddi_operand_neon"
188 (ior (match_operand 0 "s_register_operand")
189 (and (match_code "const_int")
190 (match_test "const_ok_for_dimode_op (INTVAL (op), AND)"))
191 (match_operand 0 "neon_inv_logic_op2")))
192
193 (define_predicate "arm_iordi_operand_neon"
194 (ior (match_operand 0 "s_register_operand")
195 (and (match_code "const_int")
196 (match_test "const_ok_for_dimode_op (INTVAL (op), IOR)"))
197 (match_operand 0 "neon_logic_op2")))
198
199 (define_predicate "arm_xordi_operand"
200 (ior (match_operand 0 "s_register_operand")
201 (and (match_code "const_int")
202 (match_test "const_ok_for_dimode_op (INTVAL (op), XOR)"))))
203
204 (define_predicate "arm_adddi_operand"
205 (ior (match_operand 0 "s_register_operand")
206 (and (match_code "const_int")
207 (match_test "const_ok_for_dimode_op (INTVAL (op), PLUS)"))))
140 208
141 (define_predicate "arm_addimm_operand" 209 (define_predicate "arm_addimm_operand"
142 (ior (match_operand 0 "arm_immediate_operand") 210 (ior (match_operand 0 "arm_immediate_operand")
143 (match_operand 0 "arm_neg_immediate_operand"))) 211 (match_operand 0 "arm_neg_immediate_operand")))
144 212
168 236
169 (define_predicate "arm_reload_memory_operand" 237 (define_predicate "arm_reload_memory_operand"
170 (and (match_code "mem,reg,subreg") 238 (and (match_code "mem,reg,subreg")
171 (match_test "(!CONSTANT_P (op) 239 (match_test "(!CONSTANT_P (op)
172 && (true_regnum(op) == -1 240 && (true_regnum(op) == -1
173 || (GET_CODE (op) == REG 241 || (REG_P (op)
174 && REGNO (op) >= FIRST_PSEUDO_REGISTER)))"))) 242 && REGNO (op) >= FIRST_PSEUDO_REGISTER)))")))
175
176 ;; True for valid operands for the rhs of an floating point insns.
177 ;; Allows regs or certain consts on FPA, just regs for everything else.
178 (define_predicate "arm_float_rhs_operand"
179 (ior (match_operand 0 "s_register_operand")
180 (and (match_code "const_double")
181 (match_test "TARGET_FPA && arm_const_double_rtx (op)"))))
182
183 (define_predicate "arm_float_add_operand"
184 (ior (match_operand 0 "arm_float_rhs_operand")
185 (and (match_code "const_double")
186 (match_test "TARGET_FPA && neg_const_double_rtx_ok_for_fpa (op)"))))
187 243
188 (define_predicate "vfp_compare_operand" 244 (define_predicate "vfp_compare_operand"
189 (ior (match_operand 0 "s_register_operand") 245 (ior (match_operand 0 "s_register_operand")
190 (and (match_code "const_double") 246 (and (match_code "const_double")
191 (match_test "arm_const_double_rtx (op)")))) 247 (match_test "arm_const_double_rtx (op)"))))
192 248
193 (define_predicate "arm_float_compare_operand"
194 (if_then_else (match_test "TARGET_VFP")
195 (match_operand 0 "vfp_compare_operand")
196 (match_operand 0 "arm_float_rhs_operand")))
197
198 ;; True for valid index operands. 249 ;; True for valid index operands.
199 (define_predicate "index_operand" 250 (define_predicate "index_operand"
200 (ior (match_operand 0 "s_register_operand") 251 (ior (match_operand 0 "s_register_operand")
201 (and (match_operand 0 "immediate_operand") 252 (and (match_operand 0 "immediate_operand")
202 (match_test "(GET_CODE (op) != CONST_INT 253 (match_test "(!CONST_INT_P (op)
203 || (INTVAL (op) < 4096 && INTVAL (op) > -4096))")))) 254 || (INTVAL (op) < 4096 && INTVAL (op) > -4096))"))))
204 255
205 ;; True for operators that can be combined with a shift in ARM state. 256 ;; True for operators that can be combined with a shift in ARM state.
206 (define_special_predicate "shiftable_operator" 257 (define_special_predicate "shiftable_operator"
207 (and (match_code "plus,minus,ior,xor,and") 258 (and (match_code "plus,minus,ior,xor,and")
208 (match_test "mode == GET_MODE (op)"))) 259 (match_test "mode == GET_MODE (op)")))
209 260
261 (define_special_predicate "shiftable_operator_strict_it"
262 (and (match_code "plus,and")
263 (match_test "mode == GET_MODE (op)")))
264
210 ;; True for logical binary operators. 265 ;; True for logical binary operators.
211 (define_special_predicate "logical_binary_operator" 266 (define_special_predicate "logical_binary_operator"
212 (and (match_code "ior,xor,and") 267 (and (match_code "ior,xor,and")
213 (match_test "mode == GET_MODE (op)"))) 268 (match_test "mode == GET_MODE (op)")))
214 269
216 (define_special_predicate "commutative_binary_operator" 271 (define_special_predicate "commutative_binary_operator"
217 (and (match_code "ior,xor,and,plus") 272 (and (match_code "ior,xor,and,plus")
218 (match_test "mode == GET_MODE (op)"))) 273 (match_test "mode == GET_MODE (op)")))
219 274
220 ;; True for shift operators. 275 ;; True for shift operators.
276 ;; Notes:
277 ;; * mult is only permitted with a constant shift amount
278 ;; * patterns that permit register shift amounts only in ARM mode use
279 ;; shift_amount_operand, patterns that always allow registers do not,
280 ;; so we don't have to worry about that sort of thing here.
221 (define_special_predicate "shift_operator" 281 (define_special_predicate "shift_operator"
222 (and (ior (ior (and (match_code "mult") 282 (and (ior (ior (and (match_code "mult")
223 (match_test "power_of_two_operand (XEXP (op, 1), mode)")) 283 (match_test "power_of_two_operand (XEXP (op, 1), mode)"))
224 (and (match_code "rotate") 284 (and (match_code "rotate")
225 (match_test "GET_CODE (XEXP (op, 1)) == CONST_INT 285 (match_test "CONST_INT_P (XEXP (op, 1))
226 && ((unsigned HOST_WIDE_INT) INTVAL (XEXP (op, 1))) < 32"))) 286 && (UINTVAL (XEXP (op, 1))) < 32")))
227 (match_code "ashift,ashiftrt,lshiftrt,rotatert")) 287 (and (match_code "ashift,ashiftrt,lshiftrt,rotatert")
288 (match_test "!CONST_INT_P (XEXP (op, 1))
289 || (UINTVAL (XEXP (op, 1))) < 32")))
290 (match_test "mode == GET_MODE (op)")))
291
292 (define_special_predicate "shift_nomul_operator"
293 (and (ior (and (match_code "rotate")
294 (match_test "CONST_INT_P (XEXP (op, 1))
295 && (UINTVAL (XEXP (op, 1))) < 32"))
296 (and (match_code "ashift,ashiftrt,lshiftrt,rotatert")
297 (match_test "!CONST_INT_P (XEXP (op, 1))
298 || (UINTVAL (XEXP (op, 1))) < 32")))
299 (match_test "mode == GET_MODE (op)")))
300
301 ;; True for shift operators which can be used with saturation instructions.
302 (define_special_predicate "sat_shift_operator"
303 (and (ior (and (match_code "mult")
304 (match_test "power_of_two_operand (XEXP (op, 1), mode)"))
305 (and (match_code "ashift,ashiftrt")
306 (match_test "CONST_INT_P (XEXP (op, 1))
307 && (UINTVAL (XEXP (op, 1)) < 32)")))
228 (match_test "mode == GET_MODE (op)"))) 308 (match_test "mode == GET_MODE (op)")))
229 309
230 ;; True for MULT, to identify which variant of shift_operator is in use. 310 ;; True for MULT, to identify which variant of shift_operator is in use.
231 (define_special_predicate "mult_operator" 311 (define_special_predicate "mult_operator"
232 (match_code "mult")) 312 (match_code "mult"))
239 (define_special_predicate "equality_operator" 319 (define_special_predicate "equality_operator"
240 (match_code "eq,ne")) 320 (match_code "eq,ne"))
241 321
242 ;; True for integer comparisons and, if FP is active, for comparisons 322 ;; True for integer comparisons and, if FP is active, for comparisons
243 ;; other than LTGT or UNEQ. 323 ;; other than LTGT or UNEQ.
324 (define_special_predicate "expandable_comparison_operator"
325 (match_code "eq,ne,le,lt,ge,gt,geu,gtu,leu,ltu,
326 unordered,ordered,unlt,unle,unge,ungt"))
327
328 ;; Likewise, but only accept comparisons that are directly supported
329 ;; by ARM condition codes.
244 (define_special_predicate "arm_comparison_operator" 330 (define_special_predicate "arm_comparison_operator"
245 (ior (match_code "eq,ne,le,lt,ge,gt,geu,gtu,leu,ltu") 331 (and (match_operand 0 "expandable_comparison_operator")
246 (and (match_test "TARGET_32BIT && TARGET_HARD_FLOAT 332 (match_test "maybe_get_arm_condition_code (op) != ARM_NV")))
247 && (TARGET_FPA || TARGET_VFP)") 333
248 (match_code "unordered,ordered,unlt,unle,unge,ungt")))) 334 ;; Likewise, but don't ignore the mode.
335 ;; RTL SET operations require their operands source and destination have
336 ;; the same modes, so we can't ignore the modes there. See PR target/69161.
337 (define_predicate "arm_comparison_operator_mode"
338 (and (match_operand 0 "expandable_comparison_operator")
339 (match_test "maybe_get_arm_condition_code (op) != ARM_NV")))
249 340
250 (define_special_predicate "lt_ge_comparison_operator" 341 (define_special_predicate "lt_ge_comparison_operator"
251 (match_code "lt,ge")) 342 (match_code "lt,ge"))
343
344 ;; The vsel instruction only accepts the ARM condition codes listed below.
345 (define_special_predicate "arm_vsel_comparison_operator"
346 (and (match_operand 0 "expandable_comparison_operator")
347 (match_test "maybe_get_arm_condition_code (op) == ARM_GE
348 || maybe_get_arm_condition_code (op) == ARM_GT
349 || maybe_get_arm_condition_code (op) == ARM_EQ
350 || maybe_get_arm_condition_code (op) == ARM_VS
351 || maybe_get_arm_condition_code (op) == ARM_LT
352 || maybe_get_arm_condition_code (op) == ARM_LE
353 || maybe_get_arm_condition_code (op) == ARM_NE
354 || maybe_get_arm_condition_code (op) == ARM_VC")))
355
356 (define_special_predicate "arm_cond_move_operator"
357 (if_then_else (match_test "arm_restrict_it")
358 (and (match_test "TARGET_VFP5")
359 (match_operand 0 "arm_vsel_comparison_operator"))
360 (match_operand 0 "expandable_comparison_operator")))
252 361
253 (define_special_predicate "noov_comparison_operator" 362 (define_special_predicate "noov_comparison_operator"
254 (match_code "lt,ge,eq,ne")) 363 (match_code "lt,ge,eq,ne"))
255 364
256 (define_special_predicate "minmax_operator" 365 (define_special_predicate "minmax_operator"
285 || mode == CC_DLTUmode 394 || mode == CC_DLTUmode
286 || mode == CC_DGEUmode 395 || mode == CC_DGEUmode
287 || mode == CC_DGTUmode)); 396 || mode == CC_DGTUmode));
288 }) 397 })
289 398
399 ;; Any register, including CC
400 (define_predicate "cc_register_operand"
401 (and (match_code "reg")
402 (ior (match_operand 0 "s_register_operand")
403 (match_operand 0 "cc_register"))))
404
290 (define_special_predicate "arm_extendqisi_mem_op" 405 (define_special_predicate "arm_extendqisi_mem_op"
291 (and (match_operand 0 "memory_operand") 406 (and (match_operand 0 "memory_operand")
292 (match_test "arm_legitimate_address_outer_p (mode, XEXP (op, 0), 407 (match_test "TARGET_ARM ? arm_legitimate_address_outer_p (mode,
293 SIGN_EXTEND, 0)"))) 408 XEXP (op, 0),
409 SIGN_EXTEND,
410 0)
411 : memory_address_p (QImode, XEXP (op, 0))")))
294 412
295 (define_special_predicate "arm_reg_or_extendqisi_mem_op" 413 (define_special_predicate "arm_reg_or_extendqisi_mem_op"
296 (ior (match_operand 0 "arm_extendqisi_mem_op") 414 (ior (match_operand 0 "arm_extendqisi_mem_op")
297 (match_operand 0 "s_register_operand"))) 415 (match_operand 0 "s_register_operand")))
298 416
311 return true; 429 return true;
312 430
313 if (GET_CODE (op) == SUBREG) 431 if (GET_CODE (op) == SUBREG)
314 op = SUBREG_REG (op); 432 op = SUBREG_REG (op);
315 433
316 return GET_CODE (op) == MEM && memory_address_p (DImode, XEXP (op, 0)); 434 return MEM_P (op) && memory_address_p (DImode, XEXP (op, 0));
317 }) 435 })
318 436
319 (define_predicate "di_operand" 437 (define_predicate "di_operand"
320 (ior (match_code "const_int,const_double") 438 (ior (match_code "const_int,const_double")
321 (and (match_code "reg,subreg,mem") 439 (and (match_code "reg,subreg,mem")
328 return true; 446 return true;
329 447
330 if (GET_CODE (op) == SUBREG) 448 if (GET_CODE (op) == SUBREG)
331 op = SUBREG_REG (op); 449 op = SUBREG_REG (op);
332 450
333 return GET_CODE (op) == MEM && memory_address_p (DFmode, XEXP (op, 0)); 451 return MEM_P (op) && memory_address_p (DFmode, XEXP (op, 0));
334 }) 452 })
335 453
336 (define_predicate "soft_df_operand" 454 (define_predicate "soft_df_operand"
337 (ior (match_code "const_double") 455 (ior (match_code "const_double")
338 (and (match_code "reg,subreg,mem") 456 (and (match_code "reg,subreg,mem")
339 (match_operand 0 "nonimmediate_soft_df_operand")))) 457 (match_operand 0 "nonimmediate_soft_df_operand"))))
340 458
341 (define_predicate "const_shift_operand"
342 (and (match_code "const_int")
343 (ior (match_operand 0 "power_of_two_operand")
344 (match_test "((unsigned HOST_WIDE_INT) INTVAL (op)) < 32"))))
345
346
347 (define_special_predicate "load_multiple_operation" 459 (define_special_predicate "load_multiple_operation"
348 (match_code "parallel") 460 (match_code "parallel")
349 { 461 {
350 HOST_WIDE_INT count = XVECLEN (op, 0); 462 return ldm_stm_operation_p (op, /*load=*/true, SImode,
351 unsigned dest_regno; 463 /*consecutive=*/false,
352 rtx src_addr; 464 /*return_pc=*/false);
353 HOST_WIDE_INT i = 1, base = 0;
354 HOST_WIDE_INT offset = 0;
355 rtx elt;
356 bool addr_reg_loaded = false;
357 bool update = false;
358
359 if (count <= 1
360 || GET_CODE (XVECEXP (op, 0, 0)) != SET
361 || !REG_P (SET_DEST (XVECEXP (op, 0, 0))))
362 return false;
363
364 /* Check to see if this might be a write-back. */
365 if (GET_CODE (SET_SRC (elt = XVECEXP (op, 0, 0))) == PLUS)
366 {
367 i++;
368 base = 1;
369 update = true;
370
371 /* Now check it more carefully. */
372 if (GET_CODE (SET_DEST (elt)) != REG
373 || GET_CODE (XEXP (SET_SRC (elt), 0)) != REG
374 || GET_CODE (XEXP (SET_SRC (elt), 1)) != CONST_INT
375 || INTVAL (XEXP (SET_SRC (elt), 1)) != (count - 1) * 4)
376 return false;
377 }
378
379 /* Perform a quick check so we don't blow up below. */
380 if (count <= i
381 || GET_CODE (XVECEXP (op, 0, i - 1)) != SET
382 || GET_CODE (SET_DEST (XVECEXP (op, 0, i - 1))) != REG
383 || GET_CODE (SET_SRC (XVECEXP (op, 0, i - 1))) != MEM)
384 return false;
385
386 dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, i - 1)));
387 src_addr = XEXP (SET_SRC (XVECEXP (op, 0, i - 1)), 0);
388 if (GET_CODE (src_addr) == PLUS)
389 {
390 if (GET_CODE (XEXP (src_addr, 1)) != CONST_INT)
391 return false;
392 offset = INTVAL (XEXP (src_addr, 1));
393 src_addr = XEXP (src_addr, 0);
394 }
395 if (!REG_P (src_addr))
396 return false;
397
398 for (; i < count; i++)
399 {
400 elt = XVECEXP (op, 0, i);
401
402 if (GET_CODE (elt) != SET
403 || GET_CODE (SET_DEST (elt)) != REG
404 || GET_MODE (SET_DEST (elt)) != SImode
405 || REGNO (SET_DEST (elt)) <= dest_regno
406 || GET_CODE (SET_SRC (elt)) != MEM
407 || GET_MODE (SET_SRC (elt)) != SImode
408 || ((GET_CODE (XEXP (SET_SRC (elt), 0)) != PLUS
409 || !rtx_equal_p (XEXP (XEXP (SET_SRC (elt), 0), 0), src_addr)
410 || GET_CODE (XEXP (XEXP (SET_SRC (elt), 0), 1)) != CONST_INT
411 || INTVAL (XEXP (XEXP (SET_SRC (elt), 0), 1)) != offset + (i - base) * 4)
412 && (!REG_P (XEXP (SET_SRC (elt), 0))
413 || offset + (i - base) * 4 != 0)))
414 return false;
415 dest_regno = REGNO (SET_DEST (elt));
416 if (dest_regno == REGNO (src_addr))
417 addr_reg_loaded = true;
418 }
419 /* For Thumb, we only have updating instructions. If the pattern does
420 not describe an update, it must be because the address register is
421 in the list of loaded registers - on the hardware, this has the effect
422 of overriding the update. */
423 if (update && addr_reg_loaded)
424 return false;
425 if (TARGET_THUMB1)
426 return update || addr_reg_loaded;
427 return true;
428 }) 465 })
429 466
430 (define_special_predicate "store_multiple_operation" 467 (define_special_predicate "store_multiple_operation"
431 (match_code "parallel") 468 (match_code "parallel")
432 { 469 {
433 HOST_WIDE_INT count = XVECLEN (op, 0); 470 return ldm_stm_operation_p (op, /*load=*/false, SImode,
434 unsigned src_regno; 471 /*consecutive=*/false,
435 rtx dest_addr; 472 /*return_pc=*/false);
436 HOST_WIDE_INT i = 1, base = 0, offset = 0; 473 })
437 rtx elt; 474
438 475 (define_special_predicate "pop_multiple_return"
439 if (count <= 1 476 (match_code "parallel")
440 || GET_CODE (XVECEXP (op, 0, 0)) != SET) 477 {
441 return false; 478 return ldm_stm_operation_p (op, /*load=*/true, SImode,
442 479 /*consecutive=*/false,
443 /* Check to see if this might be a write-back. */ 480 /*return_pc=*/true);
444 if (GET_CODE (SET_SRC (elt = XVECEXP (op, 0, 0))) == PLUS) 481 })
445 { 482
446 i++; 483 (define_special_predicate "pop_multiple_fp"
447 base = 1; 484 (match_code "parallel")
448 485 {
449 /* Now check it more carefully. */ 486 return ldm_stm_operation_p (op, /*load=*/true, DFmode,
450 if (GET_CODE (SET_DEST (elt)) != REG 487 /*consecutive=*/true,
451 || GET_CODE (XEXP (SET_SRC (elt), 0)) != REG 488 /*return_pc=*/false);
452 || GET_CODE (XEXP (SET_SRC (elt), 1)) != CONST_INT
453 || INTVAL (XEXP (SET_SRC (elt), 1)) != (count - 1) * 4)
454 return false;
455 }
456
457 /* Perform a quick check so we don't blow up below. */
458 if (count <= i
459 || GET_CODE (XVECEXP (op, 0, i - 1)) != SET
460 || GET_CODE (SET_DEST (XVECEXP (op, 0, i - 1))) != MEM
461 || GET_CODE (SET_SRC (XVECEXP (op, 0, i - 1))) != REG)
462 return false;
463
464 src_regno = REGNO (SET_SRC (XVECEXP (op, 0, i - 1)));
465 dest_addr = XEXP (SET_DEST (XVECEXP (op, 0, i - 1)), 0);
466
467 if (GET_CODE (dest_addr) == PLUS)
468 {
469 if (GET_CODE (XEXP (dest_addr, 1)) != CONST_INT)
470 return false;
471 offset = INTVAL (XEXP (dest_addr, 1));
472 dest_addr = XEXP (dest_addr, 0);
473 }
474 if (!REG_P (dest_addr))
475 return false;
476
477 for (; i < count; i++)
478 {
479 elt = XVECEXP (op, 0, i);
480
481 if (GET_CODE (elt) != SET
482 || GET_CODE (SET_SRC (elt)) != REG
483 || GET_MODE (SET_SRC (elt)) != SImode
484 || REGNO (SET_SRC (elt)) <= src_regno
485 || GET_CODE (SET_DEST (elt)) != MEM
486 || GET_MODE (SET_DEST (elt)) != SImode
487 || ((GET_CODE (XEXP (SET_DEST (elt), 0)) != PLUS
488 || !rtx_equal_p (XEXP (XEXP (SET_DEST (elt), 0), 0), dest_addr)
489 || GET_CODE (XEXP (XEXP (SET_DEST (elt), 0), 1)) != CONST_INT
490 || INTVAL (XEXP (XEXP (SET_DEST (elt), 0), 1)) != offset + (i - base) * 4)
491 && (!REG_P (XEXP (SET_DEST (elt), 0))
492 || offset + (i - base) * 4 != 0)))
493 return false;
494 src_regno = REGNO (SET_SRC (elt));
495 }
496
497 return true;
498 }) 489 })
499 490
500 (define_special_predicate "multi_register_push" 491 (define_special_predicate "multi_register_push"
501 (match_code "parallel") 492 (match_code "parallel")
502 { 493 {
506 return false; 497 return false;
507 498
508 return true; 499 return true;
509 }) 500 })
510 501
502 (define_predicate "push_mult_memory_operand"
503 (match_code "mem")
504 {
505 /* ??? Given how PUSH_MULT is generated in the prologues, is there
506 any point in testing for thumb1 specially? All of the variants
507 use the same form. */
508 if (TARGET_THUMB1)
509 {
510 /* ??? No attempt is made to represent STMIA, or validate that
511 the stack adjustment matches the register count. This is
512 true of the ARM/Thumb2 path as well. */
513 rtx x = XEXP (op, 0);
514 if (GET_CODE (x) != PRE_MODIFY)
515 return false;
516 if (XEXP (x, 0) != stack_pointer_rtx)
517 return false;
518 x = XEXP (x, 1);
519 if (GET_CODE (x) != PLUS)
520 return false;
521 if (XEXP (x, 0) != stack_pointer_rtx)
522 return false;
523 return CONST_INT_P (XEXP (x, 1));
524 }
525
526 /* ARM and Thumb2 handle pre-modify in their legitimate_address. */
527 return memory_operand (op, mode);
528 })
529
511 ;;------------------------------------------------------------------------- 530 ;;-------------------------------------------------------------------------
512 ;; 531 ;;
513 ;; Thumb predicates 532 ;; Thumb predicates
514 ;; 533 ;;
515 534
516 (define_predicate "thumb1_cmp_operand" 535 (define_predicate "thumb1_cmp_operand"
517 (ior (and (match_code "reg,subreg") 536 (ior (and (match_code "reg,subreg")
518 (match_operand 0 "s_register_operand")) 537 (match_operand 0 "s_register_operand"))
519 (and (match_code "const_int") 538 (and (match_code "const_int")
520 (match_test "((unsigned HOST_WIDE_INT) INTVAL (op)) < 256")))) 539 (match_test "(UINTVAL (op)) < 256"))))
521 540
522 (define_predicate "thumb1_cmpneg_operand" 541 (define_predicate "thumb1_cmpneg_operand"
523 (and (match_code "const_int") 542 (and (match_code "const_int")
524 (match_test "INTVAL (op) < 0 && INTVAL (op) > -256"))) 543 (match_test "INTVAL (op) < 0 && INTVAL (op) > -256")))
525 544
538 (and (match_test "reload_in_progress || reload_completed") 557 (and (match_test "reload_in_progress || reload_completed")
539 (match_operand 0 "memory_operand"))))) 558 (match_operand 0 "memory_operand")))))
540 559
541 ;;------------------------------------------------------------------------- 560 ;;-------------------------------------------------------------------------
542 ;; 561 ;;
543 ;; MAVERICK predicates 562 ;; iWMMXt predicates
544 ;; 563 ;;
545 564
546 (define_predicate "cirrus_register_operand" 565 (define_predicate "imm_or_reg_operand"
547 (match_code "reg,subreg") 566 (ior (match_operand 0 "immediate_operand")
548 { 567 (match_operand 0 "register_operand")))
549 if (GET_CODE (op) == SUBREG)
550 op = SUBREG_REG (op);
551
552 return (GET_CODE (op) == REG
553 && (REGNO_REG_CLASS (REGNO (op)) == CIRRUS_REGS
554 || REGNO_REG_CLASS (REGNO (op)) == GENERAL_REGS));
555 })
556
557 (define_predicate "cirrus_fp_register"
558 (match_code "reg,subreg")
559 {
560 if (GET_CODE (op) == SUBREG)
561 op = SUBREG_REG (op);
562
563 return (GET_CODE (op) == REG
564 && (REGNO (op) >= FIRST_PSEUDO_REGISTER
565 || REGNO_REG_CLASS (REGNO (op)) == CIRRUS_REGS));
566 })
567
568 (define_predicate "cirrus_shift_const"
569 (and (match_code "const_int")
570 (match_test "((unsigned HOST_WIDE_INT) INTVAL (op)) < 64")))
571
572 568
573 ;; Neon predicates 569 ;; Neon predicates
574 570
575 (define_predicate "const_multiple_of_8_operand" 571 (define_predicate "const_multiple_of_8_operand"
576 (match_code "const_int") 572 (match_code "const_int")
578 unsigned HOST_WIDE_INT val = INTVAL (op); 574 unsigned HOST_WIDE_INT val = INTVAL (op);
579 return (val & 7) == 0; 575 return (val & 7) == 0;
580 }) 576 })
581 577
582 (define_predicate "imm_for_neon_mov_operand" 578 (define_predicate "imm_for_neon_mov_operand"
579 (match_code "const_vector,const_int")
580 {
581 return neon_immediate_valid_for_move (op, mode, NULL, NULL);
582 })
583
584 (define_predicate "imm_for_neon_lshift_operand"
583 (match_code "const_vector") 585 (match_code "const_vector")
584 { 586 {
585 return neon_immediate_valid_for_move (op, mode, NULL, NULL); 587 return neon_immediate_valid_for_shift (op, mode, NULL, NULL, true);
586 }) 588 })
587 589
588 (define_predicate "imm_for_neon_logic_operand" 590 (define_predicate "imm_for_neon_rshift_operand"
589 (match_code "const_vector") 591 (match_code "const_vector")
590 { 592 {
591 return (TARGET_NEON 593 return neon_immediate_valid_for_shift (op, mode, NULL, NULL, false);
592 && neon_immediate_valid_for_logic (op, mode, 0, NULL, NULL)); 594 })
593 }) 595
594 596 (define_predicate "imm_lshift_or_reg_neon"
595 (define_predicate "imm_for_neon_inv_logic_operand" 597 (ior (match_operand 0 "s_register_operand")
596 (match_code "const_vector") 598 (match_operand 0 "imm_for_neon_lshift_operand")))
597 { 599
598 return (TARGET_NEON 600 (define_predicate "imm_rshift_or_reg_neon"
599 && neon_immediate_valid_for_logic (op, mode, 1, NULL, NULL)); 601 (ior (match_operand 0 "s_register_operand")
600 }) 602 (match_operand 0 "imm_for_neon_rshift_operand")))
601 603
602 (define_predicate "neon_logic_op2"
603 (ior (match_operand 0 "imm_for_neon_logic_operand")
604 (match_operand 0 "s_register_operand")))
605
606 (define_predicate "neon_inv_logic_op2"
607 (ior (match_operand 0 "imm_for_neon_inv_logic_operand")
608 (match_operand 0 "s_register_operand")))
609
610 ;; TODO: We could check lane numbers more precisely based on the mode.
611 (define_predicate "neon_lane_number"
612 (and (match_code "const_int")
613 (match_test "INTVAL (op) >= 0 && INTVAL (op) <= 7")))
614 ;; Predicates for named expanders that overlap multiple ISAs. 604 ;; Predicates for named expanders that overlap multiple ISAs.
615 605
616 (define_predicate "cmpdi_operand" 606 (define_predicate "cmpdi_operand"
617 (if_then_else (match_test "TARGET_HARD_FLOAT && TARGET_MAVERICK") 607 (and (match_test "TARGET_32BIT")
618 (and (match_test "TARGET_ARM") 608 (match_operand 0 "arm_di_operand")))
619 (match_operand 0 "cirrus_fp_register"))
620 (and (match_test "TARGET_32BIT")
621 (match_operand 0 "arm_di_operand"))))
622 609
623 ;; True if the operand is memory reference suitable for a ldrex/strex. 610 ;; True if the operand is memory reference suitable for a ldrex/strex.
624 (define_predicate "arm_sync_memory_operand" 611 (define_predicate "arm_sync_memory_operand"
625 (and (match_operand 0 "memory_operand") 612 (and (match_operand 0 "memory_operand")
626 (match_code "reg" "0"))) 613 (match_code "reg" "0")))
627 614
628 ;; Predicates for parallel expanders based on mode. 615 ;; Predicates for parallel expanders based on mode.
629 (define_special_predicate "vect_par_constant_high" 616 (define_special_predicate "vect_par_constant_high"
630 (match_code "parallel") 617 (match_code "parallel")
631 { 618 {
632 HOST_WIDE_INT count = XVECLEN (op, 0); 619 return arm_simd_check_vect_par_cnst_half_p (op, mode, true);
633 int i;
634 int base = GET_MODE_NUNITS (mode);
635
636 if ((count < 1)
637 || (count != base/2))
638 return false;
639
640 if (!VECTOR_MODE_P (mode))
641 return false;
642
643 for (i = 0; i < count; i++)
644 {
645 rtx elt = XVECEXP (op, 0, i);
646 int val;
647
648 if (GET_CODE (elt) != CONST_INT)
649 return false;
650
651 val = INTVAL (elt);
652 if (val != (base/2) + i)
653 return false;
654 }
655 return true;
656 }) 620 })
657 621
658 (define_special_predicate "vect_par_constant_low" 622 (define_special_predicate "vect_par_constant_low"
659 (match_code "parallel") 623 (match_code "parallel")
660 { 624 {
661 HOST_WIDE_INT count = XVECLEN (op, 0); 625 return arm_simd_check_vect_par_cnst_half_p (op, mode, false);
662 int i; 626 })
663 int base = GET_MODE_NUNITS (mode); 627
664 628 (define_predicate "const_double_vcvt_power_of_two_reciprocal"
665 if ((count < 1) 629 (and (match_code "const_double")
666 || (count != base/2)) 630 (match_test "TARGET_32BIT
667 return false; 631 && vfp3_const_double_for_fract_bits (op)")))
668 632
669 if (!VECTOR_MODE_P (mode)) 633 (define_predicate "const_double_vcvt_power_of_two"
670 return false; 634 (and (match_code "const_double")
671 635 (match_test "TARGET_32BIT
672 for (i = 0; i < count; i++) 636 && vfp3_const_double_for_bits (op) > 0")))
673 { 637
674 rtx elt = XVECEXP (op, 0, i); 638 (define_predicate "neon_struct_operand"
675 int val; 639 (and (match_code "mem")
676 640 (match_test "TARGET_32BIT && neon_vector_mem_operand (op, 2, true)")))
677 if (GET_CODE (elt) != CONST_INT) 641
678 return false; 642 (define_predicate "neon_permissive_struct_operand"
679 643 (and (match_code "mem")
680 val = INTVAL (elt); 644 (match_test "TARGET_32BIT && neon_vector_mem_operand (op, 2, false)")))
681 if (val != i) 645
682 return false; 646 (define_predicate "neon_perm_struct_or_reg_operand"
683 } 647 (ior (match_operand 0 "neon_permissive_struct_operand")
684 return true; 648 (match_operand 0 "s_register_operand")))
685 }) 649
650 (define_special_predicate "add_operator"
651 (match_code "plus"))
652
653 (define_predicate "mem_noofs_operand"
654 (and (match_code "mem")
655 (match_code "reg" "0")))
656
657 (define_predicate "call_insn_operand"
658 (ior (and (match_code "symbol_ref")
659 (match_test "!arm_is_long_call_p (SYMBOL_REF_DECL (op))"))
660 (match_operand 0 "s_register_operand")))