1 ;; Predicate definitions for Renesas M32R.
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, 51 Franklin Street, Fifth Floor,
19 ;; Boston, MA 02110-1301, USA.
21 ;; Return true if OP is a register or the constant 0.
23 (define_predicate "reg_or_zero_operand"
24 (match_code "reg,subreg,const_int")
26 if (GET_CODE (op) == REG || GET_CODE (op) == SUBREG)
27 return register_operand (op, mode);
29 if (GET_CODE (op) != CONST_INT)
32 return INTVAL (op) == 0;
35 ;; Return nonzero if the operand is suitable for use in a conditional
38 (define_predicate "conditional_move_operand"
39 (match_code "reg,subreg,const_int")
41 /* Only defined for simple integers so far... */
42 if (mode != SImode && mode != HImode && mode != QImode)
45 /* At the moment we can handle moving registers and loading constants. */
46 /* To be added: Addition/subtraction/bitops/multiplication of registers. */
48 switch (GET_CODE (op))
54 return INT8_P (INTVAL (op));
58 fprintf (stderr, "Test for cond move op of type: %s\n",
59 GET_RTX_NAME (GET_CODE (op)));
65 ;; Return true if the code is a test of the carry bit.
67 (define_predicate "carry_compare_operand"
72 if (GET_MODE (op) != CCmode && GET_MODE (op) != VOIDmode)
75 if (GET_CODE (op) != NE && GET_CODE (op) != EQ)
79 if (GET_CODE (x) != REG || REGNO (x) != CARRY_REGNUM)
83 if (GET_CODE (x) != CONST_INT || INTVAL (x) != 0)
89 ;; Return 1 if OP is an EQ or NE comparison operator.
91 (define_predicate "eqne_comparison_operator"
94 enum rtx_code code = GET_CODE (op);
96 return (code == EQ || code == NE);
99 ;; Return 1 if OP is a signed comparison operator.
101 (define_predicate "signed_comparison_operator"
102 (match_code "eq,ne,lt,le,gt,ge")
104 enum rtx_code code = GET_CODE (op);
106 return (COMPARISON_P (op)
107 && (code == EQ || code == NE
108 || code == LT || code == LE || code == GT || code == GE));
111 ;; Return true if OP is an acceptable argument for a move destination.
113 (define_predicate "move_dest_operand"
114 (match_code "reg,subreg,mem")
116 switch (GET_CODE (op))
119 return register_operand (op, mode);
121 /* (subreg (mem ...) ...) can occur here if the inner part was once a
122 pseudo-reg and is now a stack slot. */
123 if (GET_CODE (SUBREG_REG (op)) == MEM)
124 return address_operand (XEXP (SUBREG_REG (op), 0), mode);
126 return register_operand (op, mode);
128 if (GET_CODE (XEXP (op, 0)) == POST_INC)
129 return 0; /* stores can't do post inc */
130 return address_operand (XEXP (op, 0), mode);
136 ;; Return true if OP is an acceptable argument for a single word move
139 (define_predicate "move_src_operand"
140 (match_code "reg,subreg,mem,const_int,const_double,label_ref,const,symbol_ref")
142 switch (GET_CODE (op))
147 return addr24_operand (op, mode);
149 /* ??? We allow more cse opportunities if we only allow constants
150 loadable with one insn, and split the rest into two. The instances
151 where this would help should be rare and the current way is
153 if (HOST_BITS_PER_WIDE_INT > 32)
155 HOST_WIDE_INT rest = INTVAL (op) >> 31;
156 return (rest == 0 || rest == -1);
163 else if (mode == SImode)
165 /* Large unsigned constants are represented as const_double's. */
166 unsigned HOST_WIDE_INT low, high;
168 low = CONST_DOUBLE_LOW (op);
169 high = CONST_DOUBLE_HIGH (op);
170 return high == 0 && low <= (unsigned) 0xffffffff;
175 return register_operand (op, mode);
177 /* (subreg (mem ...) ...) can occur here if the inner part was once a
178 pseudo-reg and is now a stack slot. */
179 if (GET_CODE (SUBREG_REG (op)) == MEM)
180 return address_operand (XEXP (SUBREG_REG (op), 0), mode);
182 return register_operand (op, mode);
184 if (GET_CODE (XEXP (op, 0)) == PRE_INC
185 || GET_CODE (XEXP (op, 0)) == PRE_DEC)
186 return 0; /* loads can't do pre-{inc,dec} */
187 return address_operand (XEXP (op, 0), mode);
193 ;; Return true if OP is an acceptable argument for a double word move
196 (define_predicate "move_double_src_operand"
197 (match_code "reg,subreg,mem,const_int,const_double")
199 switch (GET_CODE (op))
205 return register_operand (op, mode);
207 /* (subreg (mem ...) ...) can occur here if the inner part was once a
208 pseudo-reg and is now a stack slot. */
209 if (GET_CODE (SUBREG_REG (op)) == MEM)
210 return move_double_src_operand (SUBREG_REG (op), mode);
212 return register_operand (op, mode);
214 /* Disallow auto inc/dec for now. */
215 if (GET_CODE (XEXP (op, 0)) == PRE_DEC
216 || GET_CODE (XEXP (op, 0)) == PRE_INC)
218 return address_operand (XEXP (op, 0), mode);
224 ;; Return true if OP is a const_int requiring two instructions to
227 (define_predicate "two_insn_const_operand"
228 (match_code "const_int")
230 if (GET_CODE (op) != CONST_INT)
232 if (INT16_P (INTVAL (op))
233 || UINT24_P (INTVAL (op))
234 || UPPER16_P (INTVAL (op)))
239 ;; Returns 1 if OP is a symbol reference.
241 (define_predicate "symbolic_operand"
242 (match_code "symbol_ref,label_ref,const")
244 switch (GET_CODE (op))
256 ;; Return true if OP is a signed 8 bit immediate value.
258 (define_predicate "int8_operand"
259 (match_code "const_int")
261 if (GET_CODE (op) != CONST_INT)
263 return INT8_P (INTVAL (op));
266 ;; Return true if OP is an unsigned 16 bit immediate value.
268 (define_predicate "uint16_operand"
269 (match_code "const_int")
271 if (GET_CODE (op) != CONST_INT)
273 return UINT16_P (INTVAL (op));
276 ;; Return true if OP is a register or signed 16 bit value.
278 (define_predicate "reg_or_int16_operand"
279 (match_code "reg,subreg,const_int")
281 if (GET_CODE (op) == REG || GET_CODE (op) == SUBREG)
282 return register_operand (op, mode);
283 if (GET_CODE (op) != CONST_INT)
285 return INT16_P (INTVAL (op));
288 ;; Return true if OP is a register or an unsigned 16 bit value.
290 (define_predicate "reg_or_uint16_operand"
291 (match_code "reg,subreg,const_int")
293 if (GET_CODE (op) == REG || GET_CODE (op) == SUBREG)
294 return register_operand (op, mode);
295 if (GET_CODE (op) != CONST_INT)
297 return UINT16_P (INTVAL (op));
300 ;; Return true if OP is a register or signed 16 bit value for
303 (define_predicate "reg_or_cmp_int16_operand"
304 (match_code "reg,subreg,const_int")
306 if (GET_CODE (op) == REG || GET_CODE (op) == SUBREG)
307 return register_operand (op, mode);
308 if (GET_CODE (op) != CONST_INT)
310 return CMP_INT16_P (INTVAL (op));
313 ;; Return true if OP is a register or an integer value that can be
314 ;; used is SEQ/SNE. We can use either XOR of the value or ADD of the
315 ;; negative of the value for the constant. Don't allow 0, because
316 ;; that is special cased.
318 (define_predicate "reg_or_eq_int16_operand"
319 (match_code "reg,subreg,const_int")
323 if (GET_CODE (op) == REG || GET_CODE (op) == SUBREG)
324 return register_operand (op, mode);
326 if (GET_CODE (op) != CONST_INT)
330 return (value != 0) && (UINT16_P (value) || CMP_INT16_P (-value));
333 ;; Return true if OP is a signed 16 bit immediate value useful in
336 (define_predicate "cmp_int16_operand"
337 (match_code "const_int")
339 if (GET_CODE (op) != CONST_INT)
341 return CMP_INT16_P (INTVAL (op));
344 ;; Acceptable arguments to the call insn.
346 (define_predicate "call_address_operand"
347 (match_code "symbol_ref,label_ref,const")
349 return symbolic_operand (op, mode);
351 /* Constants and values in registers are not OK, because
352 the m32r BL instruction can only support PC relative branching. */
355 ;; Return true if OP is an acceptable input argument for a zero/sign
358 (define_predicate "extend_operand"
359 (match_code "reg,subreg,mem")
363 switch (GET_CODE (op))
367 return register_operand (op, mode);
371 if (GET_CODE (addr) == PRE_INC || GET_CODE (addr) == PRE_DEC)
372 return 0; /* loads can't do pre inc/pre dec */
374 return address_operand (addr, mode);
381 ;; Return nonzero if the operand is an insn that is a small
382 ;; insn. Allow const_int 0 as well, which is a placeholder for NOP
385 (define_predicate "small_insn_p"
386 (match_code "insn,call_insn,jump_insn")
388 if (GET_CODE (op) == CONST_INT && INTVAL (op) == 0)
394 return get_attr_length (op) == 2;
397 ;; Return true if op is an integer constant, less than or equal to
400 (define_predicate "m32r_block_immediate_operand"
401 (match_code "const_int")
403 if (GET_CODE (op) != CONST_INT
404 || INTVAL (op) > MAX_MOVE_BYTES
411 ;; Return nonzero if the operand is an insn that is a large insn.
413 (define_predicate "large_insn_p"
414 (match_code "insn,call_insn,jump_insn")
419 return get_attr_length (op) != 2;
422 ;; Returns 1 if OP is an acceptable operand for seth/add3.
424 (define_predicate "seth_add3_operand"
425 (match_code "symbol_ref,label_ref,const")
430 if (GET_CODE (op) == SYMBOL_REF
431 || GET_CODE (op) == LABEL_REF)
434 if (GET_CODE (op) == CONST
435 && GET_CODE (XEXP (op, 0)) == PLUS
436 && GET_CODE (XEXP (XEXP (op, 0), 0)) == SYMBOL_REF
437 && GET_CODE (XEXP (XEXP (op, 0), 1)) == CONST_INT
438 && INT16_P (INTVAL (XEXP (XEXP (op, 0), 1))))