1 ;; Predicate definitions for HP PA-RISC.
2 ;; Copyright (C) 2005, 2007, 2010 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 nonzero only if OP is a register of mode MODE, or
23 (define_predicate "reg_or_0_operand"
24 (match_code "subreg,reg,const_int,const_double")
26 return (op == CONST0_RTX (mode) || register_operand (op, mode));
29 ;; Return nonzero if OP is suitable for use in a call to a named
32 ;; For 2.5 try to eliminate either call_operand_address or
33 ;; function_label_operand, they perform very similar functions.
35 (define_predicate "call_operand_address"
36 (match_code "label_ref,symbol_ref,const_int,const_double,const,high")
38 return (GET_MODE (op) == word_mode
39 && CONSTANT_P (op) && ! TARGET_PORTABLE_RUNTIME);
42 ;; Return 1 iff OP is an indexed memory operand.
44 (define_predicate "indexed_memory_operand"
45 (match_code "subreg,mem")
47 if (GET_MODE (op) != mode)
50 /* Before reload, a (SUBREG (MEM...)) forces reloading into a register. */
51 if (reload_completed && GET_CODE (op) == SUBREG)
54 if (GET_CODE (op) != MEM || symbolic_memory_operand (op, mode))
59 return (memory_address_p (mode, op) && IS_INDEX_ADDR_P (op));
62 ;; Return 1 iff OP is a symbolic operand.
63 ;; Note: an inline copy of this code is present in pa_secondary_reload.
65 (define_predicate "symbolic_operand"
66 (match_code "symbol_ref,label_ref,const")
68 switch (GET_CODE (op))
71 return !SYMBOL_REF_TLS_MODEL (op);
76 return (GET_CODE (op) == PLUS
77 && ((GET_CODE (XEXP (op, 0)) == SYMBOL_REF
78 && !SYMBOL_REF_TLS_MODEL (XEXP (op, 0)))
79 || GET_CODE (XEXP (op, 0)) == LABEL_REF)
80 && GET_CODE (XEXP (op, 1)) == CONST_INT);
86 ;; Return truth value of statement that OP is a symbolic memory
87 ;; operand of mode MODE.
89 (define_predicate "symbolic_memory_operand"
90 (match_code "subreg,mem")
92 if (GET_CODE (op) == SUBREG)
94 if (GET_CODE (op) != MEM)
97 return ((GET_CODE (op) == SYMBOL_REF && !SYMBOL_REF_TLS_MODEL (op))
98 || GET_CODE (op) == CONST || GET_CODE (op) == HIGH
99 || GET_CODE (op) == LABEL_REF);
102 ;; Return true if OP is a symbolic operand for the TLS Global Dynamic model.
103 (define_predicate "tgd_symbolic_operand"
104 (and (match_code "symbol_ref")
105 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_GLOBAL_DYNAMIC")))
107 ;; Return true if OP is a symbolic operand for the TLS Local Dynamic model.
108 (define_predicate "tld_symbolic_operand"
109 (and (match_code "symbol_ref")
110 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_DYNAMIC")))
112 ;; Return true if OP is a symbolic operand for the TLS Initial Exec model.
113 (define_predicate "tie_symbolic_operand"
114 (and (match_code "symbol_ref")
115 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_INITIAL_EXEC")))
117 ;; Return true if OP is a symbolic operand for the TLS Local Exec model.
118 (define_predicate "tle_symbolic_operand"
119 (and (match_code "symbol_ref")
120 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_EXEC")))
123 ;; Return 1 if the operand is a register operand or a non-symbolic
124 ;; memory operand after reload. This predicate is used for branch
125 ;; patterns that internally handle register reloading. We need to
126 ;; accept non-symbolic memory operands after reload to ensure that the
127 ;; pattern is still valid if reload didn't find a hard register for
130 (define_predicate "reg_before_reload_operand"
131 (match_code "reg,mem")
133 /* Don't accept a SUBREG since it will need a reload. */
134 if (GET_CODE (op) == SUBREG)
137 if (register_operand (op, mode))
141 && memory_operand (op, mode)
142 && !symbolic_memory_operand (op, mode))
148 ;; Return 1 if the operand is either a register, zero, or a memory
149 ;; operand that is not symbolic.
151 (define_predicate "reg_or_0_or_nonsymb_mem_operand"
152 (match_code "subreg,reg,mem,const_int,const_double")
154 if (register_operand (op, mode))
157 if (op == CONST0_RTX (mode))
160 if (GET_CODE (op) == SUBREG)
161 op = SUBREG_REG (op);
163 if (GET_CODE (op) != MEM)
166 /* Until problems with management of the REG_POINTER flag are resolved,
167 we need to delay creating move insns with unscaled indexed addresses
168 until CSE is not expected. */
169 if (!TARGET_NO_SPACE_REGS
171 && GET_CODE (XEXP (op, 0)) == PLUS
172 && REG_P (XEXP (XEXP (op, 0), 0))
173 && REG_P (XEXP (XEXP (op, 0), 1)))
176 return (!symbolic_memory_operand (op, mode)
177 && memory_address_p (mode, XEXP (op, 0)));
180 ;; Accept anything that can be used as a destination operand for a
181 ;; move instruction. We don't accept indexed memory operands since
182 ;; they are supported only for floating point stores.
184 (define_predicate "move_dest_operand"
185 (match_code "subreg,reg,mem")
187 if (register_operand (op, mode))
190 if (GET_MODE (op) != mode)
193 if (GET_CODE (op) == SUBREG)
194 op = SUBREG_REG (op);
196 if (GET_CODE (op) != MEM || symbolic_memory_operand (op, mode))
201 return (memory_address_p (mode, op)
202 && !IS_INDEX_ADDR_P (op)
203 && !IS_LO_SUM_DLT_ADDR_P (op));
206 ;; Accept anything that can be used as a source operand for a move
209 (define_predicate "move_src_operand"
210 (match_code "subreg,reg,const_int,const_double,mem")
212 if (register_operand (op, mode))
215 if (op == CONST0_RTX (mode))
218 if (GET_CODE (op) == CONST_INT)
219 return cint_ok_for_move (INTVAL (op));
221 if (GET_MODE (op) != mode)
224 if (GET_CODE (op) == SUBREG)
225 op = SUBREG_REG (op);
227 if (GET_CODE (op) != MEM)
230 /* Until problems with management of the REG_POINTER flag are resolved,
231 we need to delay creating move insns with unscaled indexed addresses
232 until CSE is not expected. */
233 if (!TARGET_NO_SPACE_REGS
235 && GET_CODE (XEXP (op, 0)) == PLUS
236 && REG_P (XEXP (XEXP (op, 0), 0))
237 && REG_P (XEXP (XEXP (op, 0), 1)))
240 return memory_address_p (mode, XEXP (op, 0));
243 ;; Accept REG and any CONST_INT that can be moved in one instruction
244 ;; into a general register.
246 (define_predicate "reg_or_cint_move_operand"
247 (match_code "subreg,reg,const_int")
249 if (register_operand (op, mode))
252 return (GET_CODE (op) == CONST_INT && cint_ok_for_move (INTVAL (op)));
255 ;; TODO: Add a comment here.
257 (define_predicate "pic_label_operand"
258 (match_code "label_ref,const")
263 switch (GET_CODE (op))
269 return (GET_CODE (XEXP (op, 0)) == LABEL_REF
270 && GET_CODE (XEXP (op, 1)) == CONST_INT);
276 ;; TODO: Add a comment here.
278 (define_predicate "fp_reg_operand"
281 return reg_renumber && FP_REG_P (op);
284 ;; Return truth value of whether OP can be used as an operand in a
285 ;; three operand arithmetic insn that accepts registers of mode MODE
286 ;; or 14-bit signed integers.
288 (define_predicate "arith_operand"
289 (match_code "subreg,reg,const_int")
291 return (register_operand (op, mode)
292 || (GET_CODE (op) == CONST_INT && INT_14_BITS (op)));
295 ;; Return truth value of whether OP can be used as an operand in a
296 ;; three operand arithmetic insn that accepts registers of mode MODE
297 ;; or 11-bit signed integers.
299 (define_predicate "arith11_operand"
300 (match_code "subreg,reg,const_int")
302 return (register_operand (op, mode)
303 || (GET_CODE (op) == CONST_INT && INT_11_BITS (op)));
306 ;; A constant integer suitable for use in a PRE_MODIFY memory
309 (define_predicate "pre_cint_operand"
310 (match_code "const_int")
312 return (GET_CODE (op) == CONST_INT
313 && INTVAL (op) >= -0x2000 && INTVAL (op) < 0x10);
316 ;; A constant integer suitable for use in a POST_MODIFY memory
319 (define_predicate "post_cint_operand"
320 (match_code "const_int")
322 return (GET_CODE (op) == CONST_INT
323 && INTVAL (op) < 0x2000 && INTVAL (op) >= -0x10);
326 ;; TODO: Add a comment here.
328 (define_predicate "arith_double_operand"
329 (match_code "subreg,reg,const_double")
331 return (register_operand (op, mode)
332 || (GET_CODE (op) == CONST_DOUBLE
333 && GET_MODE (op) == mode
334 && VAL_14_BITS_P (CONST_DOUBLE_LOW (op))
335 && ((CONST_DOUBLE_HIGH (op) >= 0)
336 == ((CONST_DOUBLE_LOW (op) & 0x1000) == 0))));
339 ;; Return truth value of whether OP is an integer which fits the range
340 ;; constraining immediate operands in three-address insns, or is an
343 (define_predicate "ireg_or_int5_operand"
344 (match_code "const_int,reg")
346 return ((GET_CODE (op) == CONST_INT && INT_5_BITS (op))
347 || (GET_CODE (op) == REG && REGNO (op) > 0 && REGNO (op) < 32));
350 ;; Return truth value of whether OP is an integer which fits the range
351 ;; constraining immediate operands in three-address insns.
353 (define_predicate "int5_operand"
354 (match_code "const_int")
356 return (GET_CODE (op) == CONST_INT && INT_5_BITS (op));
359 ;; Return truth value of whether OP is an integer which fits the range
360 ;; constraining immediate operands in three-address insns.
362 (define_predicate "uint5_operand"
363 (match_code "const_int")
365 return (GET_CODE (op) == CONST_INT && INT_U5_BITS (op));
368 ;; Return truth value of whether OP is an integer which fits the range
369 ;; constraining immediate operands in three-address insns.
371 (define_predicate "int11_operand"
372 (match_code "const_int")
374 return (GET_CODE (op) == CONST_INT && INT_11_BITS (op));
377 ;; Return truth value of whether OP is an integer which fits the range
378 ;; constraining immediate operands in three-address insns.
380 (define_predicate "uint32_operand"
381 (match_code "const_int,const_double")
383 #if HOST_BITS_PER_WIDE_INT > 32
384 /* All allowed constants will fit a CONST_INT. */
385 return (GET_CODE (op) == CONST_INT
386 && (INTVAL (op) >= 0 && INTVAL (op) < (HOST_WIDE_INT) 1 << 32));
388 return (GET_CODE (op) == CONST_INT
389 || (GET_CODE (op) == CONST_DOUBLE
390 && CONST_DOUBLE_HIGH (op) == 0));
394 ;; Return truth value of whether OP is an integer which fits the range
395 ;; constraining immediate operands in three-address insns.
397 (define_predicate "arith5_operand"
398 (match_code "subreg,reg,const_int")
400 return register_operand (op, mode) || int5_operand (op, mode);
403 ;; True iff depi or extru can be used to compute (reg & OP).
405 (define_predicate "and_operand"
406 (match_code "subreg,reg,const_int")
408 return (register_operand (op, mode)
409 || (GET_CODE (op) == CONST_INT && and_mask_p (INTVAL (op))));
412 ;; True iff OP can be used to compute (reg | OP).
414 (define_predicate "reg_or_ior_operand"
415 (match_code "subreg,reg,const_int")
417 return (register_operand (op, mode)
418 || (GET_CODE (op) == CONST_INT && ior_mask_p (INTVAL (op))));
421 ;; True iff depi can be used to compute (reg | OP).
423 (define_predicate "ior_operand"
424 (match_code "const_int")
426 return (GET_CODE (op) == CONST_INT && ior_mask_p (INTVAL (op)));
429 ;; True iff OP is a CONST_INT of the forms 0...0xxxx or
430 ;; 0...01...1xxxx. Such values can be the left hand side x in (x <<
431 ;; r), using the zvdepi instruction.
433 (define_predicate "lhs_lshift_cint_operand"
434 (match_code "const_int")
436 unsigned HOST_WIDE_INT x;
437 if (GET_CODE (op) != CONST_INT)
439 x = INTVAL (op) >> 4;
440 return (x & (x + 1)) == 0;
443 ;; TODO: Add a comment here.
445 (define_predicate "lhs_lshift_operand"
446 (match_code "subreg,reg,const_int")
448 return register_operand (op, mode) || lhs_lshift_cint_operand (op, mode);
451 ;; TODO: Add a comment here.
453 (define_predicate "arith32_operand"
454 (match_code "subreg,reg,const_int")
456 return register_operand (op, mode) || GET_CODE (op) == CONST_INT;
459 ;; TODO: Add a comment here.
461 (define_predicate "pc_or_label_operand"
462 (match_code "pc,label_ref")
464 return (GET_CODE (op) == PC || GET_CODE (op) == LABEL_REF);
467 ;; TODO: Add a comment here.
469 (define_predicate "plus_xor_ior_operator"
470 (match_code "plus,xor,ior")
472 return (GET_CODE (op) == PLUS || GET_CODE (op) == XOR
473 || GET_CODE (op) == IOR);
476 ;; Return 1 if OP is a CONST_INT with the value 2, 4, or 8. These are
477 ;; the valid constant for shadd instructions.
479 (define_predicate "shadd_operand"
480 (match_code "const_int")
482 return (GET_CODE (op) == CONST_INT && shadd_constant_p (INTVAL (op)));
485 ;; TODO: Add a comment here.
487 (define_predicate "div_operand"
488 (match_code "reg,const_int")
490 return (mode == SImode
491 && ((GET_CODE (op) == REG && REGNO (op) == 25)
492 || (GET_CODE (op) == CONST_INT && INTVAL (op) > 0
493 && INTVAL (op) < 16 && magic_milli[INTVAL (op)])));
496 ;; Return nonzero if OP is an integer register, else return zero.
498 (define_predicate "ireg_operand"
501 return (GET_CODE (op) == REG && REGNO (op) > 0 && REGNO (op) < 32);
504 ;; Return 1 if this is a comparison operator. This allows the use of
505 ;; MATCH_OPERATOR to recognize all the branch insns.
507 (define_predicate "cmpib_comparison_operator"
508 (match_code "eq,ne,lt,le,leu,gt,gtu,ge")
510 return ((mode == VOIDmode || GET_MODE (op) == mode)
511 && (GET_CODE (op) == EQ
512 || GET_CODE (op) == NE
513 || GET_CODE (op) == GT
514 || GET_CODE (op) == GTU
515 || GET_CODE (op) == GE
516 || GET_CODE (op) == LT
517 || GET_CODE (op) == LE
518 || GET_CODE (op) == LEU));
521 ;; Return 1 if OP is an operator suitable for use in a movb
524 (define_predicate "movb_comparison_operator"
525 (match_code "eq,ne,lt,ge")
527 return (GET_CODE (op) == EQ || GET_CODE (op) == NE
528 || GET_CODE (op) == LT || GET_CODE (op) == GE);