1 ;; Predicate definitions for HP PA-RISC.
2 ;; Copyright (C) 2005, 2007, 2010, 2011 Free Software Foundation, Inc.
4 ;; This file is part of GCC.
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
8 ;; the Free Software Foundation; either version 3, or (at your option)
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.
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GCC; see the file COPYING3. If not see
18 ;; <http://www.gnu.org/licenses/>.
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.
23 (define_predicate "int5_operand"
24 (and (match_code "const_int")
25 (match_test "INT_5_BITS (op)")))
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.
30 (define_predicate "uint5_operand"
31 (and (match_code "const_int")
32 (match_test "INT_U5_BITS (op)")))
34 ;; Return truth value of whether OP is an integer which fits the range
35 ;; constraining 11-bit signed immediate operands in three-address insns.
37 (define_predicate "int11_operand"
38 (and (match_code "const_int")
39 (match_test "INT_11_BITS (op)")))
41 ;; Return truth value of whether OP is an integer which fits the range
42 ;; constraining 14-bit signed immediate operands in three-address insns.
44 (define_predicate "int14_operand"
45 (and (match_code "const_int")
46 (match_test "INT_14_BITS (op)")))
48 ;; True iff OP is a const_int or const_double that will fit in 32 bits.
50 (define_predicate "uint32_operand"
51 (if_then_else (match_test "HOST_BITS_PER_WIDE_INT > 32")
52 (and (match_code "const_int")
53 (match_test "INTVAL (op) >= 0
54 && INTVAL (op) < (HOST_WIDE_INT) 1 << 32"))
55 (and (match_code "const_int,const_double")
56 (match_test "CONST_INT_P (op) || CONST_DOUBLE_HIGH (op) == 0"))))
58 ;; True iff depi can be used to compute (reg | OP).
60 (define_predicate "cint_ior_operand"
61 (and (match_code "const_int")
62 (match_test "pa_ior_mask_p (INTVAL (op))")))
64 ;; True iff OP is CONST_INT that can be moved in one instruction
65 ;; into a general register.
67 (define_predicate "cint_move_operand"
68 (and (match_code "const_int")
69 (match_test "pa_cint_ok_for_move (INTVAL (op))")))
71 ;; True iff OP is a CONST0_RTX for MODE.
73 (define_predicate "const_0_operand"
74 (and (match_code "const_int,const_double")
75 (match_test "op == CONST0_RTX (mode)")))
77 ;; A constant integer suitable for use in a PRE_MODIFY memory reference.
79 (define_predicate "pre_cint_operand"
80 (and (match_code "const_int")
81 (match_test "INTVAL (op) >= -0x2000 && INTVAL (op) < 0x10")))
83 ;; A constant integer suitable for use in a POST_MODIFY memory reference.
85 (define_predicate "post_cint_operand"
86 (and (match_code "const_int")
87 (match_test "INTVAL (op) < 0x2000 && INTVAL (op) >= -0x10")))
89 ;; True iff depi or extru can be used to compute (reg & OP).
91 (define_predicate "and_operand"
92 (ior (match_operand 0 "register_operand")
93 (and (match_code "const_int")
94 (match_test "pa_and_mask_p (INTVAL (op))"))))
96 ;; Return truth value of whether OP can be used as an operand in a
97 ;; three operand arithmetic insn that accepts registers of mode MODE
98 ;; or 5-bit signed integers.
100 (define_predicate "arith5_operand"
101 (ior (match_operand 0 "register_operand")
102 (match_operand 0 "int5_operand")))
104 ;; Return truth value of whether OP can be used as an operand in a
105 ;; three operand arithmetic insn that accepts registers of mode MODE
106 ;; or 11-bit signed integers.
108 (define_predicate "arith11_operand"
109 (ior (match_operand 0 "register_operand")
110 (match_operand 0 "int11_operand")))
112 ;; Return truth value of whether OP can be used as an operand in a
113 ;; three operand arithmetic insn that accepts registers of mode MODE
114 ;; or 14-bit signed integers.
116 (define_predicate "arith14_operand"
117 (ior (match_operand 0 "register_operand")
118 (match_operand 0 "int14_operand")))
120 ;; Return truth value of whether OP can be used as an operand in a
121 ;; three operand arithmetic insn that accepts registers of mode MODE
122 ;; or 32-bit signed integers.
124 (define_predicate "arith32_operand"
125 (ior (match_operand 0 "register_operand")
126 (match_code "const_int")))
128 ;; True iff OP can be used as an operand in an adddi3 insn.
130 (define_predicate "adddi3_operand"
131 (if_then_else (match_test "TARGET_64BIT")
132 (match_operand 0 "arith14_operand")
133 (match_operand 0 "arith11_operand")))
135 ;; True iff OP is valid as a base or index register in a REG+REG address.
137 (define_predicate "borx_reg_operand"
140 /* We must reject virtual registers as the only expressions that
141 can be instantiated are REG and REG+CONST. */
142 if (op == virtual_incoming_args_rtx
143 || op == virtual_stack_vars_rtx
144 || op == virtual_stack_dynamic_rtx
145 || op == virtual_outgoing_args_rtx
146 || op == virtual_cfa_rtx)
149 /* While it's always safe to index off the frame pointer, it's not
150 profitable to do so when the frame pointer is being eliminated. */
151 if (!reload_completed
152 && flag_omit_frame_pointer
153 && !cfun->calls_alloca
154 && op == frame_pointer_rtx)
157 return register_operand (op, mode);
160 ;; Return nonzero if OP is suitable for use in a call to a named
163 ;; For 2.5 try to eliminate either call_operand_address or
164 ;; function_label_operand, they perform very similar functions.
166 (define_predicate "call_operand_address"
167 (match_code "label_ref,symbol_ref,const_int,const_double,const,high")
169 return (GET_MODE (op) == word_mode
170 && CONSTANT_P (op) && ! TARGET_PORTABLE_RUNTIME);
173 ;; True iff OP can be used as the divisor in a div millicode call.
175 (define_predicate "div_operand"
176 (match_code "reg,const_int")
178 return (mode == SImode
179 && ((REG_P (op) && REGNO (op) == 25)
181 && INTVAL (op) > 0 && INTVAL (op) < 16
182 && pa_magic_milli[INTVAL (op)])));
185 ;; True iff OP is a reloading floating point register
187 (define_predicate "fp_reg_operand"
188 (and (match_code "reg")
189 (match_test "reg_renumber && FP_REG_P (op)")))
191 ;; True iff OP is a function label operand.
193 (define_special_predicate "function_label_operand"
194 (and (match_code "symbol_ref")
195 (match_test "FUNCTION_NAME_P (XSTR (op, 0))")))
197 ;; True iff OP is an indexed memory operand.
199 (define_predicate "indexed_memory_operand"
200 (match_code "subreg,mem")
202 if (GET_MODE (op) != mode)
205 /* Before reload, a (SUBREG (MEM...)) forces reloading into a register. */
206 if (reload_completed && GET_CODE (op) == SUBREG)
207 op = SUBREG_REG (op);
213 return IS_INDEX_ADDR_P (op) && memory_address_p (mode, op);
216 ;; True iff the operand OP can be used as the destination operand of
217 ;; an integer store. This also implies the operand could be used as
218 ;; the source operand of an integer load. Symbolic, lo_sum and indexed
219 ;; memory operands are not allowed. We accept reloading pseudos and
220 ;; other memory operands.
222 (define_predicate "integer_store_memory_operand"
223 (match_code "reg,mem")
225 return ((reload_in_progress
227 && REGNO (op) >= FIRST_PSEUDO_REGISTER
228 && reg_renumber [REGNO (op)] < 0)
230 && (reload_in_progress || memory_address_p (mode, XEXP (op, 0)))
231 && !symbolic_memory_operand (op, VOIDmode)
232 && !IS_LO_SUM_DLT_ADDR_P (XEXP (op, 0))
233 && !IS_INDEX_ADDR_P (XEXP (op, 0))));
236 ;; Return true iff OP is an integer register.
238 (define_predicate "ireg_operand"
239 (and (match_code "reg")
240 (match_test "REGNO (op) > 0 && REGNO (op) < 32")))
242 ;; Return truth value of whether OP is an integer which fits the range
243 ;; constraining immediate operands in three-address insns, or is an
246 (define_predicate "ireg_or_int5_operand"
247 (ior (match_operand 0 "ireg_operand")
248 (match_operand 0 "int5_operand")))
250 ;; True iff OP is a CONST_INT of the forms 0...0xxxx or
251 ;; 0...01...1xxxx. Such values can be the left hand side x in (x <<
252 ;; r), using the zvdepi instruction.
254 (define_predicate "lhs_lshift_cint_operand"
255 (match_code "const_int")
257 unsigned HOST_WIDE_INT x;
258 x = INTVAL (op) >> 4;
259 return (x & (x + 1)) == 0;
262 ;; True iff OP can be used in a zvdep instruction.
264 (define_predicate "lhs_lshift_operand"
265 (ior (match_operand 0 "register_operand")
266 (match_operand 0 "lhs_lshift_cint_operand")))
268 ;; Accept anything that can be used as a destination operand for a
269 ;; move instruction. We don't accept indexed memory operands since
270 ;; they are supported only for floating point stores.
272 (define_predicate "move_dest_operand"
273 (match_code "subreg,reg,mem")
275 if (register_operand (op, mode))
278 if (GET_MODE (op) != mode)
281 if (GET_CODE (op) == SUBREG)
282 op = SUBREG_REG (op);
284 if (GET_CODE (op) != MEM || symbolic_memory_operand (op, mode))
289 return (memory_address_p (mode, op)
290 && !IS_INDEX_ADDR_P (op)
291 && !IS_LO_SUM_DLT_ADDR_P (op));
294 ;; Accept anything that can be used as a source operand for a move
297 (define_predicate "move_src_operand"
298 (match_code "subreg,reg,const_int,const_double,mem")
300 if (register_operand (op, mode))
303 if (op == CONST0_RTX (mode))
306 if (CONST_INT_P (op))
307 return pa_cint_ok_for_move (INTVAL (op));
309 if (GET_MODE (op) != mode)
312 if (GET_CODE (op) == SUBREG)
313 op = SUBREG_REG (op);
318 /* Until problems with management of the REG_POINTER flag are resolved,
319 we need to delay creating move insns with unscaled indexed addresses
320 until CSE is not expected. */
321 if (!TARGET_NO_SPACE_REGS
323 && GET_CODE (XEXP (op, 0)) == PLUS
324 && REG_P (XEXP (XEXP (op, 0), 0))
325 && REG_P (XEXP (XEXP (op, 0), 1)))
328 return memory_address_p (mode, XEXP (op, 0));
331 ;; True iff OP is not a symbolic memory operand.
333 (define_predicate "nonsymb_mem_operand"
334 (match_code "subreg,mem")
336 if (GET_CODE (op) == SUBREG)
337 op = SUBREG_REG (op);
342 /* Until problems with management of the REG_POINTER flag are resolved,
343 we need to delay creating move insns with unscaled indexed addresses
344 until CSE is not expected. */
345 if (!TARGET_NO_SPACE_REGS
347 && GET_CODE (XEXP (op, 0)) == PLUS
348 && REG_P (XEXP (XEXP (op, 0), 0))
349 && REG_P (XEXP (XEXP (op, 0), 1)))
352 return (!symbolic_memory_operand (op, mode)
353 && memory_address_p (mode, XEXP (op, 0)));
356 ;; True iff OP is anything other than a hard register.
358 (define_predicate "non_hard_reg_operand"
359 (match_test "! (REG_P (op) && REGNO (op) < FIRST_PSEUDO_REGISTER)"))
361 ;; True iff OP is a reference to a label whose address can be loaded
362 ;; while generating PIC code.
364 (define_predicate "pic_label_operand"
365 (match_code "label_ref,const")
370 switch (GET_CODE (op))
376 return (GET_CODE (XEXP (op, 0)) == LABEL_REF
377 && CONST_INT_P (XEXP (op, 1)));
384 ;; True iff the operand OP lives in text space. OP is a symbolic operand.
385 ;; If so, SYMBOL_REF_FLAG, which is set by pa_encode_section_info, is true.
387 (define_special_predicate "read_only_operand"
390 if (GET_CODE (op) == CONST)
391 op = XEXP (XEXP (op, 0), 0);
392 if (GET_CODE (op) == SYMBOL_REF)
395 return SYMBOL_REF_FLAG (op) && !CONSTANT_POOL_ADDRESS_P (op);
397 return SYMBOL_REF_FLAG (op) || CONSTANT_POOL_ADDRESS_P (op);
402 ;; True iff the operand is a register operand, or a non-symbolic
403 ;; memory operand after reload. A SUBREG is not accepted since it
404 ;; will need a reload.
406 ;; This predicate is used for branch patterns that internally handle
407 ;; register reloading. We need to accept non-symbolic memory operands
408 ;; after reload to ensure that the pattern is still valid if reload
409 ;; didn't find a hard register for the operand.
411 (define_predicate "reg_before_reload_operand"
412 (match_code "reg,mem")
414 if (register_operand (op, mode))
418 && memory_operand (op, mode)
419 && !symbolic_memory_operand (op, mode))
425 ;; True iff OP is a register or const_0 operand for MODE.
427 (define_predicate "reg_or_0_operand"
428 (ior (match_operand 0 "register_operand")
429 (match_operand 0 "const_0_operand")))
431 ;; True iff OP is either a register, zero, or a non-symbolic memory operand.
433 (define_predicate "reg_or_0_or_nonsymb_mem_operand"
434 (ior (match_operand 0 "reg_or_0_operand")
435 (match_operand 0 "nonsymb_mem_operand")))
437 ;; Accept REG and any CONST_INT that can be moved in one instruction
438 ;; into a general register.
440 (define_predicate "reg_or_cint_move_operand"
441 (ior (match_operand 0 "register_operand")
442 (match_operand 0 "cint_move_operand")))
444 ;; True iff OP can be used to compute (reg | OP).
446 (define_predicate "reg_or_cint_ior_operand"
447 (ior (match_operand 0 "register_operand")
448 (match_operand 0 "cint_ior_operand")))
450 ;; Return 1 if OP is a CONST_INT with the value 2, 4, or 8. These are
451 ;; the valid constants for shadd instructions.
453 (define_predicate "shadd_operand"
454 (and (match_code "const_int")
455 (match_test "pa_shadd_constant_p (INTVAL (op))")))
457 ;; Return truth value of statement that OP is a symbolic memory operand.
459 (define_predicate "symbolic_memory_operand"
460 (match_code "subreg,mem")
462 if (GET_CODE (op) == SUBREG)
463 op = SUBREG_REG (op);
466 return pa_symbolic_expression_p (XEXP (op, 0));
469 ;; True iff OP is a symbolic operand.
470 ;; Note: an inline copy of this code is present in pa_secondary_reload.
472 (define_predicate "symbolic_operand"
473 (match_code "symbol_ref,label_ref,const")
475 switch (GET_CODE (op))
478 return !SYMBOL_REF_TLS_MODEL (op);
483 return (GET_CODE (op) == PLUS
484 && ((GET_CODE (XEXP (op, 0)) == SYMBOL_REF
485 && !SYMBOL_REF_TLS_MODEL (XEXP (op, 0)))
486 || GET_CODE (XEXP (op, 0)) == LABEL_REF)
487 && GET_CODE (XEXP (op, 1)) == CONST_INT);
494 ;; Return true if OP is a symbolic operand for the TLS Global Dynamic model.
496 (define_predicate "tgd_symbolic_operand"
497 (and (match_code "symbol_ref")
498 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_GLOBAL_DYNAMIC")))
500 ;; Return true if OP is a symbolic operand for the TLS Local Dynamic model.
502 (define_predicate "tld_symbolic_operand"
503 (and (match_code "symbol_ref")
504 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_DYNAMIC")))
506 ;; Return true if OP is a symbolic operand for the TLS Initial Exec model.
508 (define_predicate "tie_symbolic_operand"
509 (and (match_code "symbol_ref")
510 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_INITIAL_EXEC")))
512 ;; Return true if OP is a symbolic operand for the TLS Local Exec model.
514 (define_predicate "tle_symbolic_operand"
515 (and (match_code "symbol_ref")
516 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_EXEC")))
518 ;; True iff this is a comparison operator. This allows the use of
519 ;; MATCH_OPERATOR to recognize all the branch insns.
521 (define_predicate "cmpib_comparison_operator"
522 (match_code "eq,ne,lt,le,leu,gt,gtu,ge"))
524 ;; True iff OP is an operator suitable for use in a movb instruction.
526 (define_predicate "movb_comparison_operator"
527 (match_code "eq,ne,lt,ge"))
529 ;; True iff OP is a PLUS, XOR or IOR operator.
531 (define_predicate "plus_xor_ior_operator"
532 (match_code "plus,xor,ior"))