]>
Commit | Line | Data |
---|---|---|
c9a88190 | 1 | ;; Predicate definitions for HP PA-RISC. |
99dee823 | 2 | ;; Copyright (C) 2005-2021 Free Software Foundation, Inc. |
c9a88190 KH |
3 | ;; |
4 | ;; This file is part of GCC. | |
5 | ;; | |
6 | ;; GCC is free software; you can redistribute it and/or modify | |
7 | ;; it under the terms of the GNU General Public License as published by | |
2f83c7d6 | 8 | ;; the Free Software Foundation; either version 3, or (at your option) |
c9a88190 KH |
9 | ;; any later version. |
10 | ;; | |
11 | ;; GCC is distributed in the hope that it will be useful, | |
12 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | ;; GNU General Public License for more details. | |
15 | ;; | |
16 | ;; You should have received a copy of the GNU General Public License | |
2f83c7d6 NC |
17 | ;; along with GCC; see the file COPYING3. If not see |
18 | ;; <http://www.gnu.org/licenses/>. | |
c9a88190 | 19 | |
9c575e20 JDA |
20 | ;; Return truth value of whether OP is an integer which fits the range |
21 | ;; constraining 5-bit signed immediate operands in three-address insns. | |
c9a88190 | 22 | |
9c575e20 JDA |
23 | (define_predicate "int5_operand" |
24 | (and (match_code "const_int") | |
25 | (match_test "INT_5_BITS (op)"))) | |
26 | ||
27 | ;; Return truth value of whether OP is an integer which fits the range | |
28 | ;; constraining 5-bit unsigned immediate operands in three-address insns. | |
29 | ||
30 | (define_predicate "uint5_operand" | |
31 | (and (match_code "const_int") | |
32 | (match_test "INT_U5_BITS (op)"))) | |
33 | ||
f6f94d94 JDA |
34 | ;; Return truth value of whether OP is an integer which fits the range |
35 | ;; constraining 6-bit unsigned immediate operands in three-address insns. | |
36 | ||
37 | (define_predicate "uint6_operand" | |
38 | (and (match_code "const_int") | |
39 | (match_test "INT_U6_BITS (op)"))) | |
40 | ||
9c575e20 JDA |
41 | ;; Return truth value of whether OP is an integer which fits the range |
42 | ;; constraining 11-bit signed immediate operands in three-address insns. | |
43 | ||
44 | (define_predicate "int11_operand" | |
45 | (and (match_code "const_int") | |
46 | (match_test "INT_11_BITS (op)"))) | |
47 | ||
48 | ;; Return truth value of whether OP is an integer which fits the range | |
49 | ;; constraining 14-bit signed immediate operands in three-address insns. | |
50 | ||
51 | (define_predicate "int14_operand" | |
52 | (and (match_code "const_int") | |
53 | (match_test "INT_14_BITS (op)"))) | |
54 | ||
55 | ;; True iff OP is a const_int or const_double that will fit in 32 bits. | |
56 | ||
57 | (define_predicate "uint32_operand" | |
58 | (if_then_else (match_test "HOST_BITS_PER_WIDE_INT > 32") | |
59 | (and (match_code "const_int") | |
60 | (match_test "INTVAL (op) >= 0 | |
61 | && INTVAL (op) < (HOST_WIDE_INT) 1 << 32")) | |
62 | (and (match_code "const_int,const_double") | |
63 | (match_test "CONST_INT_P (op) || CONST_DOUBLE_HIGH (op) == 0")))) | |
64 | ||
65 | ;; True iff depi can be used to compute (reg | OP). | |
66 | ||
67 | (define_predicate "cint_ior_operand" | |
68 | (and (match_code "const_int") | |
ae9d61ab | 69 | (match_test "pa_ior_mask_p (INTVAL (op))"))) |
9c575e20 JDA |
70 | |
71 | ;; True iff OP is CONST_INT that can be moved in one instruction | |
72 | ;; into a general register. | |
73 | ||
74 | (define_predicate "cint_move_operand" | |
75 | (and (match_code "const_int") | |
ae9d61ab | 76 | (match_test "pa_cint_ok_for_move (INTVAL (op))"))) |
9c575e20 JDA |
77 | |
78 | ;; True iff OP is a CONST0_RTX for MODE. | |
79 | ||
80 | (define_predicate "const_0_operand" | |
81 | (and (match_code "const_int,const_double") | |
82 | (match_test "op == CONST0_RTX (mode)"))) | |
83 | ||
84 | ;; A constant integer suitable for use in a PRE_MODIFY memory reference. | |
85 | ||
86 | (define_predicate "pre_cint_operand" | |
87 | (and (match_code "const_int") | |
88 | (match_test "INTVAL (op) >= -0x2000 && INTVAL (op) < 0x10"))) | |
89 | ||
90 | ;; A constant integer suitable for use in a POST_MODIFY memory reference. | |
91 | ||
92 | (define_predicate "post_cint_operand" | |
93 | (and (match_code "const_int") | |
94 | (match_test "INTVAL (op) < 0x2000 && INTVAL (op) >= -0x10"))) | |
95 | ||
96 | ;; True iff depi or extru can be used to compute (reg & OP). | |
97 | ||
98 | (define_predicate "and_operand" | |
99 | (ior (match_operand 0 "register_operand") | |
100 | (and (match_code "const_int") | |
ae9d61ab | 101 | (match_test "pa_and_mask_p (INTVAL (op))")))) |
9c575e20 JDA |
102 | |
103 | ;; Return truth value of whether OP can be used as an operand in a | |
104 | ;; three operand arithmetic insn that accepts registers of mode MODE | |
105 | ;; or 5-bit signed integers. | |
106 | ||
107 | (define_predicate "arith5_operand" | |
108 | (ior (match_operand 0 "register_operand") | |
109 | (match_operand 0 "int5_operand"))) | |
110 | ||
111 | ;; Return truth value of whether OP can be used as an operand in a | |
112 | ;; three operand arithmetic insn that accepts registers of mode MODE | |
113 | ;; or 11-bit signed integers. | |
114 | ||
115 | (define_predicate "arith11_operand" | |
116 | (ior (match_operand 0 "register_operand") | |
117 | (match_operand 0 "int11_operand"))) | |
118 | ||
119 | ;; Return truth value of whether OP can be used as an operand in a | |
120 | ;; three operand arithmetic insn that accepts registers of mode MODE | |
121 | ;; or 14-bit signed integers. | |
122 | ||
123 | (define_predicate "arith14_operand" | |
124 | (ior (match_operand 0 "register_operand") | |
125 | (match_operand 0 "int14_operand"))) | |
126 | ||
127 | ;; Return truth value of whether OP can be used as an operand in a | |
128 | ;; three operand arithmetic insn that accepts registers of mode MODE | |
129 | ;; or 32-bit signed integers. | |
130 | ||
131 | (define_predicate "arith32_operand" | |
132 | (ior (match_operand 0 "register_operand") | |
133 | (match_code "const_int"))) | |
134 | ||
f6f94d94 JDA |
135 | ;; Return truth value of whether OP can be used as a shift operand in |
136 | ;; a shift insn that accepts registers of mode MODE or 5-bit shift amounts. | |
137 | ||
138 | (define_predicate "shift5_operand" | |
139 | (ior (match_operand 0 "register_operand") | |
140 | (match_operand 0 "uint5_operand"))) | |
141 | ||
142 | ;; Return truth value of whether OP can be used as a shift operand in | |
143 | ;; a shift insn that accepts registers of mode MODE or 6-bit shift amounts. | |
144 | ||
145 | (define_predicate "shift6_operand" | |
146 | (ior (match_operand 0 "register_operand") | |
147 | (match_operand 0 "uint6_operand"))) | |
148 | ||
9c575e20 JDA |
149 | ;; True iff OP can be used as an operand in an adddi3 insn. |
150 | ||
151 | (define_predicate "adddi3_operand" | |
152 | (if_then_else (match_test "TARGET_64BIT") | |
153 | (match_operand 0 "arith14_operand") | |
154 | (match_operand 0 "arith11_operand"))) | |
155 | ||
156 | ;; True iff OP is valid as a base or index register in a REG+REG address. | |
157 | ||
158 | (define_predicate "borx_reg_operand" | |
159 | (match_code "reg") | |
c9a88190 | 160 | { |
9c575e20 JDA |
161 | /* We must reject virtual registers as the only expressions that |
162 | can be instantiated are REG and REG+CONST. */ | |
163 | if (op == virtual_incoming_args_rtx | |
164 | || op == virtual_stack_vars_rtx | |
165 | || op == virtual_stack_dynamic_rtx | |
166 | || op == virtual_outgoing_args_rtx | |
167 | || op == virtual_cfa_rtx) | |
168 | return false; | |
169 | ||
170 | /* While it's always safe to index off the frame pointer, it's not | |
171 | profitable to do so when the frame pointer is being eliminated. */ | |
172 | if (!reload_completed | |
173 | && flag_omit_frame_pointer | |
174 | && !cfun->calls_alloca | |
175 | && op == frame_pointer_rtx) | |
176 | return false; | |
177 | ||
178 | return register_operand (op, mode); | |
c9a88190 KH |
179 | }) |
180 | ||
181 | ;; Return nonzero if OP is suitable for use in a call to a named | |
182 | ;; function. | |
183 | ;; | |
184 | ;; For 2.5 try to eliminate either call_operand_address or | |
185 | ;; function_label_operand, they perform very similar functions. | |
186 | ||
187 | (define_predicate "call_operand_address" | |
188 | (match_code "label_ref,symbol_ref,const_int,const_double,const,high") | |
189 | { | |
190 | return (GET_MODE (op) == word_mode | |
191 | && CONSTANT_P (op) && ! TARGET_PORTABLE_RUNTIME); | |
192 | }) | |
193 | ||
9c575e20 JDA |
194 | ;; True iff OP can be used as the divisor in a div millicode call. |
195 | ||
196 | (define_predicate "div_operand" | |
197 | (match_code "reg,const_int") | |
198 | { | |
199 | return (mode == SImode | |
200 | && ((REG_P (op) && REGNO (op) == 25) | |
201 | || (CONST_INT_P (op) | |
202 | && INTVAL (op) > 0 && INTVAL (op) < 16 | |
ae9d61ab | 203 | && pa_magic_milli[INTVAL (op)]))); |
9c575e20 JDA |
204 | }) |
205 | ||
206 | ;; True iff OP is a reloading floating point register | |
207 | ||
208 | (define_predicate "fp_reg_operand" | |
209 | (and (match_code "reg") | |
210 | (match_test "reg_renumber && FP_REG_P (op)"))) | |
211 | ||
212 | ;; True iff OP is a function label operand. | |
213 | ||
214 | (define_special_predicate "function_label_operand" | |
215 | (and (match_code "symbol_ref") | |
216 | (match_test "FUNCTION_NAME_P (XSTR (op, 0))"))) | |
217 | ||
218 | ;; True iff OP is an indexed memory operand. | |
c9a88190 KH |
219 | |
220 | (define_predicate "indexed_memory_operand" | |
221 | (match_code "subreg,mem") | |
222 | { | |
223 | if (GET_MODE (op) != mode) | |
9c575e20 | 224 | return false; |
c9a88190 KH |
225 | |
226 | /* Before reload, a (SUBREG (MEM...)) forces reloading into a register. */ | |
227 | if (reload_completed && GET_CODE (op) == SUBREG) | |
228 | op = SUBREG_REG (op); | |
229 | ||
9c575e20 JDA |
230 | if (! MEM_P (op)) |
231 | return false; | |
c9a88190 KH |
232 | |
233 | op = XEXP (op, 0); | |
9c575e20 | 234 | return IS_INDEX_ADDR_P (op) && memory_address_p (mode, op); |
c9a88190 KH |
235 | }) |
236 | ||
1a04ac2b JDA |
237 | ;; True iff OP is a register plus base memory operand. |
238 | ||
239 | (define_predicate "reg_plus_base_memory_operand" | |
240 | (match_code "subreg,mem") | |
241 | { | |
242 | if (GET_MODE (op) != mode) | |
243 | return false; | |
244 | ||
245 | /* Before reload, a (SUBREG (MEM...)) forces reloading into a register. */ | |
246 | if (reload_completed && GET_CODE (op) == SUBREG) | |
247 | op = SUBREG_REG (op); | |
248 | ||
249 | if (! MEM_P (op)) | |
250 | return false; | |
251 | ||
252 | op = XEXP (op, 0); | |
253 | if (GET_CODE (op) != PLUS) | |
254 | return false; | |
255 | ||
256 | if (REG_P (XEXP (op, 0)) && REG_OK_FOR_BASE_P (XEXP (op, 0))) | |
257 | return GET_CODE (XEXP (op, 1)) == CONST_INT; | |
258 | ||
259 | return false; | |
260 | }) | |
261 | ||
262 | ;; True iff OP is a base14 operand. | |
263 | ||
264 | (define_predicate "base14_operand" | |
265 | (match_code "const_int") | |
266 | { | |
267 | if (!INT_14_BITS (op)) | |
268 | return false; | |
269 | ||
270 | /* Although this may not be necessary, we require that the | |
271 | base value is correctly aligned for its mode as this is | |
272 | assumed in the instruction encoding. */ | |
273 | switch (mode) | |
274 | { | |
4e10a5a7 RS |
275 | case E_BLKmode: |
276 | case E_QImode: | |
277 | case E_HImode: | |
1a04ac2b JDA |
278 | return true; |
279 | ||
177a9700 AH |
280 | case E_VOIDmode: |
281 | return false; | |
282 | ||
1a04ac2b | 283 | default: |
ceaca33e | 284 | return (INTVAL (op) % GET_MODE_SIZE (mode)) == 0; |
1a04ac2b JDA |
285 | } |
286 | ||
287 | return false; | |
288 | }) | |
289 | ||
9c575e20 JDA |
290 | ;; True iff the operand OP can be used as the destination operand of |
291 | ;; an integer store. This also implies the operand could be used as | |
1a04ac2b | 292 | ;; the source operand of an integer load. LO_SUM DLT and indexed |
9c575e20 JDA |
293 | ;; memory operands are not allowed. We accept reloading pseudos and |
294 | ;; other memory operands. | |
c9a88190 | 295 | |
9c575e20 JDA |
296 | (define_predicate "integer_store_memory_operand" |
297 | (match_code "reg,mem") | |
c9a88190 | 298 | { |
1a04ac2b JDA |
299 | if (reload_in_progress |
300 | && REG_P (op) | |
301 | && REGNO (op) >= FIRST_PSEUDO_REGISTER | |
302 | && reg_renumber [REGNO (op)] < 0) | |
303 | return true; | |
304 | ||
305 | if (reg_plus_base_memory_operand (op, mode)) | |
306 | { | |
d5a28db0 JDA |
307 | if (reload_in_progress) |
308 | return true; | |
309 | ||
1a04ac2b JDA |
310 | /* Extract CONST_INT operand. */ |
311 | if (GET_CODE (op) == SUBREG) | |
312 | op = SUBREG_REG (op); | |
313 | op = XEXP (op, 0); | |
314 | op = REG_P (XEXP (op, 0)) ? XEXP (op, 1) : XEXP (op, 0); | |
315 | return base14_operand (op, mode) || INT_5_BITS (op); | |
316 | } | |
317 | ||
318 | if (!MEM_P (op)) | |
319 | return false; | |
320 | ||
321 | return ((reload_in_progress || memory_address_p (mode, XEXP (op, 0))) | |
322 | && !IS_LO_SUM_DLT_ADDR_P (XEXP (op, 0)) | |
323 | && !IS_INDEX_ADDR_P (XEXP (op, 0))); | |
324 | }) | |
325 | ||
326 | ;; True iff the operand OP can be used as the destination operand of | |
327 | ;; a floating point store. This also implies the operand could be used as | |
328 | ;; the source operand of a floating point load. LO_SUM DLT and indexed | |
329 | ;; memory operands are not allowed. Symbolic operands are accepted if | |
330 | ;; INT14_OK_STRICT is true. We accept reloading pseudos and other memory | |
331 | ;; operands. | |
332 | ||
333 | (define_predicate "floating_point_store_memory_operand" | |
334 | (match_code "reg,mem") | |
335 | { | |
336 | if (reload_in_progress | |
337 | && REG_P (op) | |
338 | && REGNO (op) >= FIRST_PSEUDO_REGISTER | |
339 | && reg_renumber [REGNO (op)] < 0) | |
340 | return true; | |
341 | ||
342 | if (reg_plus_base_memory_operand (op, mode)) | |
343 | { | |
d5a28db0 JDA |
344 | if (reload_in_progress) |
345 | return true; | |
346 | ||
1a04ac2b JDA |
347 | /* Extract CONST_INT operand. */ |
348 | if (GET_CODE (op) == SUBREG) | |
349 | op = SUBREG_REG (op); | |
350 | op = XEXP (op, 0); | |
351 | op = REG_P (XEXP (op, 0)) ? XEXP (op, 1) : XEXP (op, 0); | |
352 | return ((TARGET_PA_20 | |
353 | && !TARGET_ELF32 | |
354 | && base14_operand (op, mode)) | |
355 | || INT_5_BITS (op)); | |
356 | } | |
357 | ||
358 | if (!MEM_P (op)) | |
359 | return false; | |
360 | ||
361 | return ((reload_in_progress || memory_address_p (mode, XEXP (op, 0))) | |
362 | && (INT14_OK_STRICT || !symbolic_memory_operand (op, VOIDmode)) | |
363 | && !IS_LO_SUM_DLT_ADDR_P (XEXP (op, 0)) | |
364 | && !IS_INDEX_ADDR_P (XEXP (op, 0))); | |
c9a88190 KH |
365 | }) |
366 | ||
9c575e20 | 367 | ;; Return true iff OP is an integer register. |
51076f96 | 368 | |
9c575e20 JDA |
369 | (define_predicate "ireg_operand" |
370 | (and (match_code "reg") | |
371 | (match_test "REGNO (op) > 0 && REGNO (op) < 32"))) | |
51076f96 | 372 | |
9c575e20 JDA |
373 | ;; Return truth value of whether OP is an integer which fits the range |
374 | ;; constraining immediate operands in three-address insns, or is an | |
375 | ;; integer register. | |
51076f96 | 376 | |
9c575e20 JDA |
377 | (define_predicate "ireg_or_int5_operand" |
378 | (ior (match_operand 0 "ireg_operand") | |
379 | (match_operand 0 "int5_operand"))) | |
51076f96 | 380 | |
5d9dc69a JDA |
381 | ;; True iff OP is a CONST_INT of the forms 0...0xxxx, 0...01...1xxxx, |
382 | ;; or 1...1xxxx. Such values can be the left hand side x in (x << r), | |
383 | ;; using the zvdepi instruction. | |
c9a88190 | 384 | |
9c575e20 JDA |
385 | (define_predicate "lhs_lshift_cint_operand" |
386 | (match_code "const_int") | |
c9a88190 | 387 | { |
9c575e20 JDA |
388 | unsigned HOST_WIDE_INT x; |
389 | x = INTVAL (op) >> 4; | |
390 | return (x & (x + 1)) == 0; | |
c9a88190 KH |
391 | }) |
392 | ||
9c575e20 | 393 | ;; True iff OP can be used in a zvdep instruction. |
c9a88190 | 394 | |
9c575e20 JDA |
395 | (define_predicate "lhs_lshift_operand" |
396 | (ior (match_operand 0 "register_operand") | |
397 | (match_operand 0 "lhs_lshift_cint_operand"))) | |
c9a88190 KH |
398 | |
399 | ;; Accept anything that can be used as a destination operand for a | |
400 | ;; move instruction. We don't accept indexed memory operands since | |
401 | ;; they are supported only for floating point stores. | |
402 | ||
403 | (define_predicate "move_dest_operand" | |
404 | (match_code "subreg,reg,mem") | |
405 | { | |
406 | if (register_operand (op, mode)) | |
9c575e20 | 407 | return true; |
c9a88190 KH |
408 | |
409 | if (GET_MODE (op) != mode) | |
9c575e20 | 410 | return false; |
c9a88190 KH |
411 | |
412 | if (GET_CODE (op) == SUBREG) | |
413 | op = SUBREG_REG (op); | |
414 | ||
1a04ac2b | 415 | if (! MEM_P (op)) |
9c575e20 | 416 | return false; |
c9a88190 KH |
417 | |
418 | op = XEXP (op, 0); | |
419 | ||
420 | return (memory_address_p (mode, op) | |
421 | && !IS_INDEX_ADDR_P (op) | |
422 | && !IS_LO_SUM_DLT_ADDR_P (op)); | |
423 | }) | |
424 | ||
425 | ;; Accept anything that can be used as a source operand for a move | |
426 | ;; instruction. | |
427 | ||
428 | (define_predicate "move_src_operand" | |
e214de0a | 429 | (match_code "subreg,reg,const_int,const_double,mem") |
c9a88190 KH |
430 | { |
431 | if (register_operand (op, mode)) | |
9c575e20 | 432 | return true; |
c9a88190 | 433 | |
e214de0a | 434 | if (op == CONST0_RTX (mode)) |
9c575e20 | 435 | return true; |
e214de0a | 436 | |
9c575e20 | 437 | if (CONST_INT_P (op)) |
ae9d61ab | 438 | return pa_cint_ok_for_move (INTVAL (op)); |
c9a88190 KH |
439 | |
440 | if (GET_MODE (op) != mode) | |
9c575e20 | 441 | return false; |
c9a88190 KH |
442 | |
443 | if (GET_CODE (op) == SUBREG) | |
444 | op = SUBREG_REG (op); | |
445 | ||
9c575e20 JDA |
446 | if (! MEM_P (op)) |
447 | return false; | |
c9a88190 KH |
448 | |
449 | /* Until problems with management of the REG_POINTER flag are resolved, | |
450 | we need to delay creating move insns with unscaled indexed addresses | |
451 | until CSE is not expected. */ | |
452 | if (!TARGET_NO_SPACE_REGS | |
453 | && !cse_not_expected | |
454 | && GET_CODE (XEXP (op, 0)) == PLUS | |
455 | && REG_P (XEXP (XEXP (op, 0), 0)) | |
456 | && REG_P (XEXP (XEXP (op, 0), 1))) | |
9c575e20 | 457 | return false; |
c9a88190 KH |
458 | |
459 | return memory_address_p (mode, XEXP (op, 0)); | |
460 | }) | |
461 | ||
9c575e20 | 462 | ;; True iff OP is not a symbolic memory operand. |
c9a88190 | 463 | |
9c575e20 JDA |
464 | (define_predicate "nonsymb_mem_operand" |
465 | (match_code "subreg,mem") | |
c9a88190 | 466 | { |
9c575e20 JDA |
467 | if (GET_CODE (op) == SUBREG) |
468 | op = SUBREG_REG (op); | |
469 | ||
470 | if (! MEM_P (op)) | |
471 | return false; | |
472 | ||
473 | /* Until problems with management of the REG_POINTER flag are resolved, | |
474 | we need to delay creating move insns with unscaled indexed addresses | |
475 | until CSE is not expected. */ | |
476 | if (!TARGET_NO_SPACE_REGS | |
477 | && !cse_not_expected | |
478 | && GET_CODE (XEXP (op, 0)) == PLUS | |
479 | && REG_P (XEXP (XEXP (op, 0), 0)) | |
480 | && REG_P (XEXP (XEXP (op, 0), 1))) | |
481 | return false; | |
c9a88190 | 482 | |
9c575e20 JDA |
483 | return (!symbolic_memory_operand (op, mode) |
484 | && memory_address_p (mode, XEXP (op, 0))); | |
c9a88190 KH |
485 | }) |
486 | ||
9c575e20 JDA |
487 | ;; True iff OP is anything other than a hard register. |
488 | ||
489 | (define_predicate "non_hard_reg_operand" | |
490 | (match_test "! (REG_P (op) && REGNO (op) < FIRST_PSEUDO_REGISTER)")) | |
491 | ||
492 | ;; True iff OP is a reference to a label whose address can be loaded | |
493 | ;; while generating PIC code. | |
c9a88190 KH |
494 | |
495 | (define_predicate "pic_label_operand" | |
496 | (match_code "label_ref,const") | |
497 | { | |
498 | if (!flag_pic) | |
9c575e20 | 499 | return false; |
c9a88190 KH |
500 | |
501 | switch (GET_CODE (op)) | |
502 | { | |
503 | case LABEL_REF: | |
9c575e20 | 504 | return true; |
c9a88190 KH |
505 | case CONST: |
506 | op = XEXP (op, 0); | |
507 | return (GET_CODE (XEXP (op, 0)) == LABEL_REF | |
9c575e20 | 508 | && CONST_INT_P (XEXP (op, 1))); |
c9a88190 | 509 | default: |
9c575e20 | 510 | gcc_unreachable (); |
c9a88190 | 511 | } |
9c575e20 | 512 | return false; |
c9a88190 KH |
513 | }) |
514 | ||
9c575e20 JDA |
515 | ;; True iff the operand OP lives in text space. OP is a symbolic operand. |
516 | ;; If so, SYMBOL_REF_FLAG, which is set by pa_encode_section_info, is true. | |
c9a88190 | 517 | |
9c575e20 JDA |
518 | (define_special_predicate "read_only_operand" |
519 | (match_test "true") | |
c9a88190 | 520 | { |
9c575e20 JDA |
521 | if (GET_CODE (op) == CONST) |
522 | op = XEXP (XEXP (op, 0), 0); | |
523 | if (GET_CODE (op) == SYMBOL_REF) | |
524 | { | |
525 | if (flag_pic) | |
526 | return SYMBOL_REF_FLAG (op) && !CONSTANT_POOL_ADDRESS_P (op); | |
527 | else | |
528 | return SYMBOL_REF_FLAG (op) || CONSTANT_POOL_ADDRESS_P (op); | |
529 | } | |
530 | return true; | |
c9a88190 KH |
531 | }) |
532 | ||
9c575e20 JDA |
533 | ;; True iff the operand is a register operand, or a non-symbolic |
534 | ;; memory operand after reload. A SUBREG is not accepted since it | |
535 | ;; will need a reload. | |
536 | ;; | |
537 | ;; This predicate is used for branch patterns that internally handle | |
538 | ;; register reloading. We need to accept non-symbolic memory operands | |
539 | ;; after reload to ensure that the pattern is still valid if reload | |
846ef40a JDA |
540 | ;; didn't find a hard register for the operand. We also reject index |
541 | ;; and lo_sum DLT address as these are invalid for move destinations. | |
c9a88190 | 542 | |
9c575e20 JDA |
543 | (define_predicate "reg_before_reload_operand" |
544 | (match_code "reg,mem") | |
c9a88190 | 545 | { |
846ef40a JDA |
546 | rtx op0; |
547 | ||
9c575e20 JDA |
548 | if (register_operand (op, mode)) |
549 | return true; | |
c9a88190 | 550 | |
846ef40a JDA |
551 | if (!reload_in_progress && !reload_completed) |
552 | return false; | |
c9a88190 | 553 | |
846ef40a JDA |
554 | if (! MEM_P (op)) |
555 | return false; | |
556 | ||
557 | op0 = XEXP (op, 0); | |
558 | ||
559 | return (memory_address_p (mode, op0) | |
560 | && !IS_INDEX_ADDR_P (op0) | |
561 | && !IS_LO_SUM_DLT_ADDR_P (op0) | |
562 | && !symbolic_memory_operand (op, mode)); | |
c9a88190 KH |
563 | }) |
564 | ||
9c575e20 | 565 | ;; True iff OP is a register or const_0 operand for MODE. |
c9a88190 | 566 | |
9c575e20 JDA |
567 | (define_predicate "reg_or_0_operand" |
568 | (ior (match_operand 0 "register_operand") | |
569 | (match_operand 0 "const_0_operand"))) | |
c9a88190 | 570 | |
9c575e20 | 571 | ;; True iff OP is either a register, zero, or a non-symbolic memory operand. |
c9a88190 | 572 | |
9c575e20 JDA |
573 | (define_predicate "reg_or_0_or_nonsymb_mem_operand" |
574 | (ior (match_operand 0 "reg_or_0_operand") | |
575 | (match_operand 0 "nonsymb_mem_operand"))) | |
c9a88190 | 576 | |
9c575e20 JDA |
577 | ;; Accept REG and any CONST_INT that can be moved in one instruction |
578 | ;; into a general register. | |
c9a88190 | 579 | |
9c575e20 JDA |
580 | (define_predicate "reg_or_cint_move_operand" |
581 | (ior (match_operand 0 "register_operand") | |
582 | (match_operand 0 "cint_move_operand"))) | |
c9a88190 | 583 | |
5e85ab88 JDA |
584 | ;; True iff OP can be used to compute (reg | OP). |
585 | ||
9c575e20 JDA |
586 | (define_predicate "reg_or_cint_ior_operand" |
587 | (ior (match_operand 0 "register_operand") | |
588 | (match_operand 0 "cint_ior_operand"))) | |
c9a88190 | 589 | |
9c575e20 JDA |
590 | ;; Return 1 if OP is a CONST_INT with the value 2, 4, or 8. These are |
591 | ;; the valid constants for shadd instructions. | |
c9a88190 | 592 | |
b47fbc53 JL |
593 | (define_predicate "mem_shadd_operand" |
594 | (and (match_code "const_int") | |
595 | (match_test "pa_mem_shadd_constant_p (INTVAL (op))"))) | |
596 | ||
9c575e20 JDA |
597 | (define_predicate "shadd_operand" |
598 | (and (match_code "const_int") | |
ae9d61ab | 599 | (match_test "pa_shadd_constant_p (INTVAL (op))"))) |
c9a88190 | 600 | |
9c575e20 | 601 | ;; Return truth value of statement that OP is a symbolic memory operand. |
c9a88190 | 602 | |
9c575e20 JDA |
603 | (define_predicate "symbolic_memory_operand" |
604 | (match_code "subreg,mem") | |
c9a88190 | 605 | { |
9c575e20 JDA |
606 | if (GET_CODE (op) == SUBREG) |
607 | op = SUBREG_REG (op); | |
608 | if (!MEM_P (op)) | |
609 | return false; | |
1a04ac2b JDA |
610 | op = XEXP (op, 0); |
611 | if (GET_CODE (op) == LO_SUM) | |
612 | op = XEXP (op, 1); | |
613 | return pa_symbolic_expression_p (op); | |
c9a88190 KH |
614 | }) |
615 | ||
9c575e20 JDA |
616 | ;; True iff OP is a symbolic operand. |
617 | ;; Note: an inline copy of this code is present in pa_secondary_reload. | |
c9a88190 | 618 | |
9c575e20 JDA |
619 | (define_predicate "symbolic_operand" |
620 | (match_code "symbol_ref,label_ref,const") | |
c9a88190 | 621 | { |
9c575e20 JDA |
622 | switch (GET_CODE (op)) |
623 | { | |
624 | case SYMBOL_REF: | |
625 | return !SYMBOL_REF_TLS_MODEL (op); | |
626 | case LABEL_REF: | |
627 | return true; | |
628 | case CONST: | |
629 | op = XEXP (op, 0); | |
630 | return (GET_CODE (op) == PLUS | |
631 | && ((GET_CODE (XEXP (op, 0)) == SYMBOL_REF | |
632 | && !SYMBOL_REF_TLS_MODEL (XEXP (op, 0))) | |
633 | || GET_CODE (XEXP (op, 0)) == LABEL_REF) | |
634 | && GET_CODE (XEXP (op, 1)) == CONST_INT); | |
635 | default: | |
1a04ac2b | 636 | break; |
9c575e20 | 637 | } |
1a04ac2b | 638 | return false; |
c9a88190 KH |
639 | }) |
640 | ||
9c575e20 | 641 | ;; Return true if OP is a symbolic operand for the TLS Global Dynamic model. |
c9a88190 | 642 | |
9c575e20 JDA |
643 | (define_predicate "tgd_symbolic_operand" |
644 | (and (match_code "symbol_ref") | |
645 | (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_GLOBAL_DYNAMIC"))) | |
c9a88190 | 646 | |
9c575e20 | 647 | ;; Return true if OP is a symbolic operand for the TLS Local Dynamic model. |
c9a88190 | 648 | |
9c575e20 JDA |
649 | (define_predicate "tld_symbolic_operand" |
650 | (and (match_code "symbol_ref") | |
651 | (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_DYNAMIC"))) | |
c9a88190 | 652 | |
9c575e20 | 653 | ;; Return true if OP is a symbolic operand for the TLS Initial Exec model. |
c9a88190 | 654 | |
9c575e20 JDA |
655 | (define_predicate "tie_symbolic_operand" |
656 | (and (match_code "symbol_ref") | |
657 | (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_INITIAL_EXEC"))) | |
c9a88190 | 658 | |
9c575e20 | 659 | ;; Return true if OP is a symbolic operand for the TLS Local Exec model. |
c9a88190 | 660 | |
9c575e20 JDA |
661 | (define_predicate "tle_symbolic_operand" |
662 | (and (match_code "symbol_ref") | |
663 | (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_EXEC"))) | |
c9a88190 | 664 | |
cf319b3f JDA |
665 | ;; True iff OP is an operator suitable for use in a double-word cmpib |
666 | ;; instruction. | |
667 | ||
668 | (define_predicate "cmpib_comparison_operator" | |
669 | (match_code "eq,ne,lt,le,leu,gt,gtu,ge")) | |
670 | ||
9c575e20 | 671 | ;; True iff OP is an operator suitable for use in a movb instruction. |
c9a88190 KH |
672 | |
673 | (define_predicate "movb_comparison_operator" | |
9c575e20 JDA |
674 | (match_code "eq,ne,lt,ge")) |
675 | ||
676 | ;; True iff OP is a PLUS, XOR or IOR operator. | |
677 | ||
678 | (define_predicate "plus_xor_ior_operator" | |
679 | (match_code "plus,xor,ior")) |