1 ;; Predicate definitions for HP PA-RISC.
2 ;; Copyright (C) 2005 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 2, 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 COPYING. If not, write to
18 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
19 ;; Boston, MA 02111-1307, USA.
21 ;; Return nonzero only if OP is a register of mode MODE, or
24 (define_predicate "reg_or_0_operand"
25 (match_code "subreg,reg,const_int,const_double")
27 return (op == CONST0_RTX (mode) || register_operand (op, mode));
30 ;; Return nonzero if OP is suitable for use in a call to a named
33 ;; For 2.5 try to eliminate either call_operand_address or
34 ;; function_label_operand, they perform very similar functions.
36 (define_predicate "call_operand_address"
37 (match_code "label_ref,symbol_ref,const_int,const_double,const,high")
39 return (GET_MODE (op) == word_mode
40 && CONSTANT_P (op) && ! TARGET_PORTABLE_RUNTIME);
43 ;; Return 1 iff OP is an indexed memory operand.
45 (define_predicate "indexed_memory_operand"
46 (match_code "subreg,mem")
48 if (GET_MODE (op) != mode)
51 /* Before reload, a (SUBREG (MEM...)) forces reloading into a register. */
52 if (reload_completed && GET_CODE (op) == SUBREG)
55 if (GET_CODE (op) != MEM || symbolic_memory_operand (op, mode))
60 return (memory_address_p (mode, op) && IS_INDEX_ADDR_P (op));
63 ;; TODO: Add a comment.
65 (define_predicate "symbolic_operand"
66 (match_code "symbol_ref,label_ref,const")
68 switch (GET_CODE (op))
75 return ((GET_CODE (XEXP (op, 0)) == SYMBOL_REF
76 || GET_CODE (XEXP (op, 0)) == LABEL_REF)
77 && GET_CODE (XEXP (op, 1)) == CONST_INT);
83 ;; Return truth value of statement that OP is a symbolic memory
84 ;; operand of mode MODE.
86 (define_predicate "symbolic_memory_operand"
87 (match_code "subreg,mem")
89 if (GET_CODE (op) == SUBREG)
91 if (GET_CODE (op) != MEM)
94 return (GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == CONST
95 || GET_CODE (op) == HIGH || GET_CODE (op) == LABEL_REF);
98 ;; Return 1 if the operand is a register operand or a non-symbolic
99 ;; memory operand after reload. This predicate is used for branch
100 ;; patterns that internally handle register reloading. We need to
101 ;; accept non-symbolic memory operands after reload to ensure that the
102 ;; pattern is still valid if reload didn't find a hard register for
105 (define_predicate "reg_before_reload_operand"
106 (match_code "reg,mem")
108 /* Don't accept a SUBREG since it will need a reload. */
109 if (GET_CODE (op) == SUBREG)
112 if (register_operand (op, mode))
116 && memory_operand (op, mode)
117 && !symbolic_memory_operand (op, mode))
123 ;; Return 1 if the operand is either a register, zero, or a memory
124 ;; operand that is not symbolic.
126 (define_predicate "reg_or_0_or_nonsymb_mem_operand"
127 (match_code "subreg,reg,mem,const_int,const_double")
129 if (register_operand (op, mode))
132 if (op == CONST0_RTX (mode))
135 if (GET_CODE (op) == SUBREG)
136 op = SUBREG_REG (op);
138 if (GET_CODE (op) != MEM)
141 /* Until problems with management of the REG_POINTER flag are resolved,
142 we need to delay creating move insns with unscaled indexed addresses
143 until CSE is not expected. */
144 if (!TARGET_NO_SPACE_REGS
146 && GET_CODE (XEXP (op, 0)) == PLUS
147 && REG_P (XEXP (XEXP (op, 0), 0))
148 && REG_P (XEXP (XEXP (op, 0), 1)))
151 return (!symbolic_memory_operand (op, mode)
152 && memory_address_p (mode, XEXP (op, 0)));
155 ;; Accept anything that can be used as a destination operand for a
156 ;; move instruction. We don't accept indexed memory operands since
157 ;; they are supported only for floating point stores.
159 (define_predicate "move_dest_operand"
160 (match_code "subreg,reg,mem")
162 if (register_operand (op, mode))
165 if (GET_MODE (op) != mode)
168 if (GET_CODE (op) == SUBREG)
169 op = SUBREG_REG (op);
171 if (GET_CODE (op) != MEM || symbolic_memory_operand (op, mode))
176 return (memory_address_p (mode, op)
177 && !IS_INDEX_ADDR_P (op)
178 && !IS_LO_SUM_DLT_ADDR_P (op));
181 ;; Accept anything that can be used as a source operand for a move
184 (define_predicate "move_src_operand"
185 (match_code "subreg,reg,const_int,mem")
187 if (register_operand (op, mode))
190 if (GET_CODE (op) == CONST_INT)
191 return cint_ok_for_move (INTVAL (op));
193 if (GET_MODE (op) != mode)
196 if (GET_CODE (op) == SUBREG)
197 op = SUBREG_REG (op);
199 if (GET_CODE (op) != MEM)
202 /* Until problems with management of the REG_POINTER flag are resolved,
203 we need to delay creating move insns with unscaled indexed addresses
204 until CSE is not expected. */
205 if (!TARGET_NO_SPACE_REGS
207 && GET_CODE (XEXP (op, 0)) == PLUS
208 && REG_P (XEXP (XEXP (op, 0), 0))
209 && REG_P (XEXP (XEXP (op, 0), 1)))
212 return memory_address_p (mode, XEXP (op, 0));
215 ;; Accept anything that can be used as the source operand for a
216 ;; prefetch instruction with a cache-control completer.
218 (define_predicate "prefetch_cc_operand"
221 if (GET_CODE (op) != MEM)
226 /* We must reject virtual registers as we don't allow REG+D. */
227 if (op == virtual_incoming_args_rtx
228 || op == virtual_stack_vars_rtx
229 || op == virtual_stack_dynamic_rtx
230 || op == virtual_outgoing_args_rtx
231 || op == virtual_cfa_rtx)
234 if (!REG_P (op) && !IS_INDEX_ADDR_P (op))
237 /* Until problems with management of the REG_POINTER flag are resolved,
238 we need to delay creating prefetch insns with unscaled indexed addresses
239 until CSE is not expected. */
240 if (!TARGET_NO_SPACE_REGS
242 && GET_CODE (op) == PLUS
243 && REG_P (XEXP (op, 0)))
246 return memory_address_p (mode, op);
249 ;; Accept anything that can be used as the source operand for a
250 ;; prefetch instruction with no cache-control completer.
252 (define_predicate "prefetch_nocc_operand"
255 if (GET_CODE (op) != MEM)
260 /* Until problems with management of the REG_POINTER flag are resolved,
261 we need to delay creating prefetch insns with unscaled indexed addresses
262 until CSE is not expected. */
263 if (!TARGET_NO_SPACE_REGS
265 && GET_CODE (op) == PLUS
266 && REG_P (XEXP (op, 0))
267 && REG_P (XEXP (op, 1)))
270 return memory_address_p (mode, op);
273 ;; Accept REG and any CONST_INT that can be moved in one instruction
274 ;; into a general register.
276 (define_predicate "reg_or_cint_move_operand"
277 (match_code "subreg,reg,const_int")
279 if (register_operand (op, mode))
282 return (GET_CODE (op) == CONST_INT && cint_ok_for_move (INTVAL (op)));
285 ;; TODO: Add a comment here.
287 (define_predicate "pic_label_operand"
288 (match_code "label_ref,const")
293 switch (GET_CODE (op))
299 return (GET_CODE (XEXP (op, 0)) == LABEL_REF
300 && GET_CODE (XEXP (op, 1)) == CONST_INT);
306 ;; TODO: Add a comment here.
308 (define_predicate "fp_reg_operand"
311 return reg_renumber && FP_REG_P (op);
314 ;; Return truth value of whether OP can be used as an operand in a
315 ;; three operand arithmetic insn that accepts registers of mode MODE
316 ;; or 14-bit signed integers.
318 (define_predicate "arith_operand"
319 (match_code "subreg,reg,const_int")
321 return (register_operand (op, mode)
322 || (GET_CODE (op) == CONST_INT && INT_14_BITS (op)));
325 ;; Return truth value of whether OP can be used as an operand in a
326 ;; three operand arithmetic insn that accepts registers of mode MODE
327 ;; or 11-bit signed integers.
329 (define_predicate "arith11_operand"
330 (match_code "subreg,reg,const_int")
332 return (register_operand (op, mode)
333 || (GET_CODE (op) == CONST_INT && INT_11_BITS (op)));
336 ;; A constant integer suitable for use in a PRE_MODIFY memory
339 (define_predicate "pre_cint_operand"
340 (match_code "const_int")
342 return (GET_CODE (op) == CONST_INT
343 && INTVAL (op) >= -0x2000 && INTVAL (op) < 0x10);
346 ;; A constant integer suitable for use in a POST_MODIFY memory
349 (define_predicate "post_cint_operand"
350 (match_code "const_int")
352 return (GET_CODE (op) == CONST_INT
353 && INTVAL (op) < 0x2000 && INTVAL (op) >= -0x10);
356 ;; TODO: Add a comment here.
358 (define_predicate "arith_double_operand"
359 (match_code "subreg,reg,const_double")
361 return (register_operand (op, mode)
362 || (GET_CODE (op) == CONST_DOUBLE
363 && GET_MODE (op) == mode
364 && VAL_14_BITS_P (CONST_DOUBLE_LOW (op))
365 && ((CONST_DOUBLE_HIGH (op) >= 0)
366 == ((CONST_DOUBLE_LOW (op) & 0x1000) == 0))));
369 ;; Return truth value of whether OP is an integer which fits the range
370 ;; constraining immediate operands in three-address insns, or is an
373 (define_predicate "ireg_or_int5_operand"
374 (match_code "const_int,reg")
376 return ((GET_CODE (op) == CONST_INT && INT_5_BITS (op))
377 || (GET_CODE (op) == REG && REGNO (op) > 0 && REGNO (op) < 32));
380 ;; Return truth value of whether OP is an integer which fits the range
381 ;; constraining immediate operands in three-address insns.
383 (define_predicate "int5_operand"
384 (match_code "const_int")
386 return (GET_CODE (op) == CONST_INT && INT_5_BITS (op));
389 ;; Return truth value of whether OP is an integer which fits the range
390 ;; constraining immediate operands in three-address insns.
392 (define_predicate "uint5_operand"
393 (match_code "const_int")
395 return (GET_CODE (op) == CONST_INT && INT_U5_BITS (op));
398 ;; Return truth value of whether OP is an integer which fits the range
399 ;; constraining immediate operands in three-address insns.
401 (define_predicate "int11_operand"
402 (match_code "const_int")
404 return (GET_CODE (op) == CONST_INT && INT_11_BITS (op));
407 ;; Return truth value of whether OP is an integer which fits the range
408 ;; constraining immediate operands in three-address insns.
410 (define_predicate "uint32_operand"
411 (match_code "const_int,const_double")
413 #if HOST_BITS_PER_WIDE_INT > 32
414 /* All allowed constants will fit a CONST_INT. */
415 return (GET_CODE (op) == CONST_INT
416 && (INTVAL (op) >= 0 && INTVAL (op) < (HOST_WIDE_INT) 1 << 32));
418 return (GET_CODE (op) == CONST_INT
419 || (GET_CODE (op) == CONST_DOUBLE
420 && CONST_DOUBLE_HIGH (op) == 0));
424 ;; Return truth value of whether OP is an integer which fits the range
425 ;; constraining immediate operands in three-address insns.
427 (define_predicate "arith5_operand"
428 (match_code "subreg,reg,const_int")
430 return register_operand (op, mode) || int5_operand (op, mode);
433 ;; True iff depi or extru can be used to compute (reg & OP).
435 (define_predicate "and_operand"
436 (match_code "subreg,reg,const_int")
438 return (register_operand (op, mode)
439 || (GET_CODE (op) == CONST_INT && and_mask_p (INTVAL (op))));
442 ;; True iff depi can be used to compute (reg | OP).
444 (define_predicate "ior_operand"
445 (match_code "const_int")
447 return (GET_CODE (op) == CONST_INT && ior_mask_p (INTVAL (op)));
450 ;; True iff OP is a CONST_INT of the forms 0...0xxxx or
451 ;; 0...01...1xxxx. Such values can be the left hand side x in (x <<
452 ;; r), using the zvdepi instruction.
454 (define_predicate "lhs_lshift_cint_operand"
455 (match_code "const_int")
457 unsigned HOST_WIDE_INT x;
458 if (GET_CODE (op) != CONST_INT)
460 x = INTVAL (op) >> 4;
461 return (x & (x + 1)) == 0;
464 ;; TODO: Add a comment here.
466 (define_predicate "lhs_lshift_operand"
467 (match_code "subreg,reg,const_int")
469 return register_operand (op, mode) || lhs_lshift_cint_operand (op, mode);
472 ;; TODO: Add a comment here.
474 (define_predicate "arith32_operand"
475 (match_code "subreg,reg,const_int")
477 return register_operand (op, mode) || GET_CODE (op) == CONST_INT;
480 ;; TODO: Add a comment here.
482 (define_predicate "pc_or_label_operand"
483 (match_code "pc,label_ref")
485 return (GET_CODE (op) == PC || GET_CODE (op) == LABEL_REF);
488 ;; TODO: Add a comment here.
490 (define_predicate "plus_xor_ior_operator"
491 (match_code "plus,xor,ior")
493 return (GET_CODE (op) == PLUS || GET_CODE (op) == XOR
494 || GET_CODE (op) == IOR);
497 ;; Return 1 if OP is a CONST_INT with the value 2, 4, or 8. These are
498 ;; the valid constant for shadd instructions.
500 (define_predicate "shadd_operand"
501 (match_code "const_int")
503 return (GET_CODE (op) == CONST_INT && shadd_constant_p (INTVAL (op)));
506 ;; TODO: Add a comment here.
508 (define_predicate "div_operand"
509 (match_code "reg,const_int")
511 return (mode == SImode
512 && ((GET_CODE (op) == REG && REGNO (op) == 25)
513 || (GET_CODE (op) == CONST_INT && INTVAL (op) > 0
514 && INTVAL (op) < 16 && magic_milli[INTVAL (op)])));
517 ;; Return nonzero if OP is an integer register, else return zero.
519 (define_predicate "ireg_operand"
522 return (GET_CODE (op) == REG && REGNO (op) > 0 && REGNO (op) < 32);
525 ;; Return 1 if this is a comparison operator. This allows the use of
526 ;; MATCH_OPERATOR to recognize all the branch insns.
528 (define_predicate "cmpib_comparison_operator"
529 (match_code "eq,ne,lt,le,leu,gt,gtu,ge")
531 return ((mode == VOIDmode || GET_MODE (op) == mode)
532 && (GET_CODE (op) == EQ
533 || GET_CODE (op) == NE
534 || GET_CODE (op) == GT
535 || GET_CODE (op) == GTU
536 || GET_CODE (op) == GE
537 || GET_CODE (op) == LT
538 || GET_CODE (op) == LE
539 || GET_CODE (op) == LEU));
542 ;; Return 1 if OP is an operator suitable for use in a movb
545 (define_predicate "movb_comparison_operator"
546 (match_code "eq,ne,lt,ge")
548 return (GET_CODE (op) == EQ || GET_CODE (op) == NE
549 || GET_CODE (op) == LT || GET_CODE (op) == GE);