1 ;; Predicate definitions for Renesas M32R.
2 ;; Copyright (C) 2005, 2007 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 true if OP is a register or the constant 0.
22 (define_predicate "reg_or_zero_operand"
23 (match_code "reg,subreg,const_int")
25 if (GET_CODE (op) == REG || GET_CODE (op) == SUBREG)
26 return register_operand (op, mode);
28 if (GET_CODE (op) != CONST_INT)
31 return INTVAL (op) == 0;
34 ;; Return nonzero if the operand is suitable for use in a conditional
37 (define_predicate "conditional_move_operand"
38 (match_code "reg,subreg,const_int")
40 /* Only defined for simple integers so far... */
41 if (mode != SImode && mode != HImode && mode != QImode)
44 /* At the moment we can handle moving registers and loading constants. */
45 /* To be added: Addition/subtraction/bitops/multiplication of registers. */
47 switch (GET_CODE (op))
53 return satisfies_constraint_I (op);
57 fprintf (stderr, "Test for cond move op of type: %s\n",
58 GET_RTX_NAME (GET_CODE (op)));
64 ;; Return true if the code is a test of the carry bit.
66 (define_predicate "carry_compare_operand"
71 if (GET_MODE (op) != CCmode && GET_MODE (op) != VOIDmode)
74 if (GET_CODE (op) != NE && GET_CODE (op) != EQ)
78 if (GET_CODE (x) != REG || REGNO (x) != CARRY_REGNUM)
82 if (GET_CODE (x) != CONST_INT || INTVAL (x) != 0)
88 ;; Return 1 if OP is an EQ or NE comparison operator.
90 (define_predicate "eqne_comparison_operator"
93 enum rtx_code code = GET_CODE (op);
95 return (code == EQ || code == NE);
98 ;; Return 1 if OP is a signed comparison operator.
100 (define_predicate "signed_comparison_operator"
101 (match_code "eq,ne,lt,le,gt,ge")
103 enum rtx_code code = GET_CODE (op);
105 return (COMPARISON_P (op)
106 && (code == EQ || code == NE
107 || code == LT || code == LE || code == GT || code == GE));
110 ;; Return true if OP is an acceptable argument for a move destination.
112 (define_predicate "move_dest_operand"
113 (match_code "reg,subreg,mem")
115 switch (GET_CODE (op))
118 return register_operand (op, mode);
120 /* (subreg (mem ...) ...) can occur here if the inner part was once a
121 pseudo-reg and is now a stack slot. */
122 if (GET_CODE (SUBREG_REG (op)) == MEM)
123 return address_operand (XEXP (SUBREG_REG (op), 0), mode);
125 return register_operand (op, mode);
127 if (GET_CODE (XEXP (op, 0)) == POST_INC)
128 return 0; /* stores can't do post inc */
129 return address_operand (XEXP (op, 0), mode);
135 ;; Return true if OP is an acceptable argument for a single word move
138 (define_predicate "move_src_operand"
139 (match_code "reg,subreg,mem,const_int,const_double,label_ref,const,symbol_ref")
141 switch (GET_CODE (op))
146 return addr24_operand (op, mode);
148 /* ??? We allow more cse opportunities if we only allow constants
149 loadable with one insn, and split the rest into two. The instances
150 where this would help should be rare and the current way is
152 if (HOST_BITS_PER_WIDE_INT > 32)
154 HOST_WIDE_INT rest = INTVAL (op) >> 31;
155 return (rest == 0 || rest == -1);
162 else if (mode == SImode)
164 /* Large unsigned constants are represented as const_double's. */
165 unsigned HOST_WIDE_INT low, high;
167 low = CONST_DOUBLE_LOW (op);
168 high = CONST_DOUBLE_HIGH (op);
169 return high == 0 && low <= (unsigned) 0xffffffff;
174 return register_operand (op, mode);
176 /* (subreg (mem ...) ...) can occur here if the inner part was once a
177 pseudo-reg and is now a stack slot. */
178 if (GET_CODE (SUBREG_REG (op)) == MEM)
179 return address_operand (XEXP (SUBREG_REG (op), 0), mode);
181 return register_operand (op, mode);
183 if (GET_CODE (XEXP (op, 0)) == PRE_INC
184 || GET_CODE (XEXP (op, 0)) == PRE_DEC)
185 return 0; /* loads can't do pre-{inc,dec} */
186 return address_operand (XEXP (op, 0), mode);
192 ;; Return true if OP is an acceptable argument for a double word move
195 (define_predicate "move_double_src_operand"
196 (match_code "reg,subreg,mem,const_int,const_double")
198 switch (GET_CODE (op))
204 return register_operand (op, mode);
206 /* (subreg (mem ...) ...) can occur here if the inner part was once a
207 pseudo-reg and is now a stack slot. */
208 if (GET_CODE (SUBREG_REG (op)) == MEM)
209 return move_double_src_operand (SUBREG_REG (op), mode);
211 return register_operand (op, mode);
213 /* Disallow auto inc/dec for now. */
214 if (GET_CODE (XEXP (op, 0)) == PRE_DEC
215 || GET_CODE (XEXP (op, 0)) == PRE_INC)
217 return address_operand (XEXP (op, 0), mode);
223 ;; Return true if OP is a const_int requiring two instructions to
226 (define_predicate "two_insn_const_operand"
227 (match_code "const_int")
229 if (GET_CODE (op) != CONST_INT)
231 if (satisfies_constraint_J (op)
232 || satisfies_constraint_M (op)
233 || satisfies_constraint_L (op))
238 ;; Returns 1 if OP is a symbol reference.
240 (define_predicate "symbolic_operand"
241 (match_code "symbol_ref,label_ref,const")
243 switch (GET_CODE (op))
255 ;; Return true if OP is a signed 8-bit immediate value.
257 (define_predicate "int8_operand"
258 (match_code "const_int")
260 if (GET_CODE (op) != CONST_INT)
262 return satisfies_constraint_I (op);
265 ;; Return true if OP is an unsigned 16-bit immediate value.
267 (define_predicate "uint16_operand"
268 (match_code "const_int")
270 if (GET_CODE (op) != CONST_INT)
272 return satisfies_constraint_K (op);
275 ;; Return true if OP is a register or signed 16-bit value.
277 (define_predicate "reg_or_int16_operand"
278 (match_code "reg,subreg,const_int")
280 if (GET_CODE (op) == REG || GET_CODE (op) == SUBREG)
281 return register_operand (op, mode);
282 if (GET_CODE (op) != CONST_INT)
284 return satisfies_constraint_J (op);
287 ;; Return true if OP is a register or an unsigned 16-bit value.
289 (define_predicate "reg_or_uint16_operand"
290 (match_code "reg,subreg,const_int")
292 if (GET_CODE (op) == REG || GET_CODE (op) == SUBREG)
293 return register_operand (op, mode);
294 if (GET_CODE (op) != CONST_INT)
296 return satisfies_constraint_K (op);
299 ;; Return true if OP is a register or signed 16-bit value for
302 (define_predicate "reg_or_cmp_int16_operand"
303 (match_code "reg,subreg,const_int")
305 if (GET_CODE (op) == REG || GET_CODE (op) == SUBREG)
306 return register_operand (op, mode);
307 if (GET_CODE (op) != CONST_INT)
309 return satisfies_constraint_P (op);
312 ;; Return true if OP is a register or an integer value that can be
313 ;; used is SEQ/SNE. We can use either XOR of the value or ADD of the
314 ;; negative of the value for the constant. Don't allow 0, because
315 ;; that is special cased.
317 (define_predicate "reg_or_eq_int16_operand"
318 (match_code "reg,subreg,const_int")
322 if (GET_CODE (op) == REG || GET_CODE (op) == SUBREG)
323 return register_operand (op, mode);
325 if (GET_CODE (op) != CONST_INT)
329 return (value != 0) && (UINT16_P (value) || CMP_INT16_P (-value));
332 ;; Return true if OP is a signed 16-bit immediate value useful in
335 (define_predicate "cmp_int16_operand"
336 (match_code "const_int")
338 if (GET_CODE (op) != CONST_INT)
340 return satisfies_constraint_P (op);
343 ;; Acceptable arguments to the call insn.
345 (define_predicate "call_address_operand"
346 (match_code "symbol_ref,label_ref,const")
348 return symbolic_operand (op, mode);
350 /* Constants and values in registers are not OK, because
351 the m32r BL instruction can only support PC relative branching. */
354 ;; Return true if OP is an acceptable input argument for a zero/sign
357 (define_predicate "extend_operand"
358 (match_code "reg,subreg,mem")
362 switch (GET_CODE (op))
366 return register_operand (op, mode);
370 if (GET_CODE (addr) == PRE_INC || GET_CODE (addr) == PRE_DEC)
371 return 0; /* loads can't do pre inc/pre dec */
373 return address_operand (addr, mode);
380 ;; Return nonzero if the operand is an insn that is a small
381 ;; insn. Allow const_int 0 as well, which is a placeholder for NOP
384 (define_predicate "small_insn_p"
385 (match_code "insn,call_insn,jump_insn")
387 if (GET_CODE (op) == CONST_INT && INTVAL (op) == 0)
393 return get_attr_length (op) == 2;
396 ;; Return true if op is an integer constant, less than or equal to
399 (define_predicate "m32r_block_immediate_operand"
400 (match_code "const_int")
402 if (GET_CODE (op) != CONST_INT
403 || INTVAL (op) > MAX_MOVE_BYTES
410 ;; Return nonzero if the operand is an insn that is a large insn.
412 (define_predicate "large_insn_p"
413 (match_code "insn,call_insn,jump_insn")
418 return get_attr_length (op) != 2;
421 ;; Returns 1 if OP is an acceptable operand for seth/add3.
423 (define_predicate "seth_add3_operand"
424 (match_code "symbol_ref,label_ref,const")
429 if (GET_CODE (op) == SYMBOL_REF
430 || GET_CODE (op) == LABEL_REF)
433 if (GET_CODE (op) == CONST
434 && GET_CODE (XEXP (op, 0)) == PLUS
435 && GET_CODE (XEXP (XEXP (op, 0), 0)) == SYMBOL_REF
436 && satisfies_constraint_J (XEXP (XEXP (op, 0), 1)))