1 ;; Predicate definitions for Motorola MCore.
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 ;; Nonzero if OP is a normal arithmetic register.
23 (define_predicate "mcore_arith_reg_operand"
24 (match_code "reg,subreg")
26 if (! register_operand (op, mode))
29 if (GET_CODE (op) == SUBREG)
32 if (GET_CODE (op) == REG)
33 return REGNO (op) != CC_REG;
38 ;; Nonzero if OP can be source of a simple move operation.
40 (define_predicate "mcore_general_movsrc_operand"
41 (match_code "mem,const_int,reg,subreg,symbol_ref,label_ref")
43 /* Any (MEM LABEL_REF) is OK. That is a pc-relative load. */
44 if (GET_CODE (op) == MEM && GET_CODE (XEXP (op, 0)) == LABEL_REF)
47 return general_operand (op, mode);
50 ;; Nonzero if OP can be destination of a simple move operation.
52 (define_predicate "mcore_general_movdst_operand"
53 (match_code "mem,const_int,reg,subreg")
55 if (GET_CODE (op) == REG && REGNO (op) == CC_REG)
58 return general_operand (op, mode);
61 ;; Nonzero if OP should be recognized during reload for an ixh/ixw
62 ;; operand. See the ixh/ixw patterns.
64 (define_predicate "mcore_reload_operand"
65 (match_code "mem,reg,subreg")
67 if (mcore_arith_reg_operand (op, mode))
70 if (! reload_in_progress)
73 return GET_CODE (op) == MEM;
76 ;; Nonzero if OP is a valid source operand for an arithmetic insn.
78 (define_predicate "mcore_arith_J_operand"
79 (match_code "const_int,reg,subreg")
81 if (register_operand (op, mode))
84 if (GET_CODE (op) == CONST_INT && CONST_OK_FOR_J (INTVAL (op)))
90 ;; Nonzero if OP is a valid source operand for an arithmetic insn.
92 (define_predicate "mcore_arith_K_operand"
93 (match_code "const_int,reg,subreg")
95 if (register_operand (op, mode))
98 if (GET_CODE (op) == CONST_INT && CONST_OK_FOR_K (INTVAL (op)))
104 ;; Nonzero if OP is a valid source operand for a shift or rotate insn.
106 (define_predicate "mcore_arith_K_operand_not_0"
107 (match_code "const_int,reg,subreg")
109 if (register_operand (op, mode))
112 if ( GET_CODE (op) == CONST_INT
113 && CONST_OK_FOR_K (INTVAL (op))
120 ;; TODO: Add a comment here.
122 (define_predicate "mcore_arith_M_operand"
123 (match_code "const_int,reg,subreg")
125 if (register_operand (op, mode))
128 if (GET_CODE (op) == CONST_INT && CONST_OK_FOR_M (INTVAL (op)))
134 ;; TODO: Add a comment here.
136 (define_predicate "mcore_arith_K_S_operand"
137 (match_code "const_int,reg,subreg")
139 if (register_operand (op, mode))
142 if (GET_CODE (op) == CONST_INT)
144 if (CONST_OK_FOR_K (INTVAL (op)) || CONST_OK_FOR_M (~INTVAL (op)))
151 ;; Nonzero if OP is a valid source operand for a cmov with two consts
154 (define_predicate "mcore_arith_O_operand"
155 (match_code "const_int,reg,subreg")
157 if (register_operand (op, mode))
160 if (GET_CODE (op) == CONST_INT && CONST_OK_FOR_O (INTVAL (op)))
166 ;; Nonzero if OP is a valid source operand for loading.
168 (define_predicate "mcore_arith_imm_operand"
169 (match_code "const_int,reg,subreg")
171 if (register_operand (op, mode))
174 if (GET_CODE (op) == CONST_INT && const_ok_for_mcore (INTVAL (op)))
180 ;; TODO: Add a comment here.
182 (define_predicate "mcore_arith_any_imm_operand"
183 (match_code "const_int,reg,subreg")
185 if (register_operand (op, mode))
188 if (GET_CODE (op) == CONST_INT)
194 ;; Nonzero if OP is a valid source operand for a btsti.
196 (define_predicate "mcore_literal_K_operand"
197 (match_code "const_int")
199 if (GET_CODE (op) == CONST_INT && CONST_OK_FOR_K (INTVAL (op)))
205 ;; Nonzero if OP is a valid source operand for an add/sub insn.
207 (define_predicate "mcore_addsub_operand"
208 (match_code "const_int,reg,subreg")
210 if (register_operand (op, mode))
213 if (GET_CODE (op) == CONST_INT)
217 /* The following is removed because it precludes large constants from being
218 returned as valid source operands for and add/sub insn. While large
219 constants may not directly be used in an add/sub, they may if first loaded
220 into a register. Thus, this predicate should indicate that they are valid,
221 and the constraint in mcore.md should control whether an additional load to
222 register is needed. (see mcore.md, addsi). -- DAC 4/2/1998 */
224 if (CONST_OK_FOR_J(INTVAL(op)) || CONST_OK_FOR_L(INTVAL(op)))
232 ;; Nonzero if OP is a valid source operand for a compare operation.
234 (define_predicate "mcore_compare_operand"
235 (match_code "const_int,reg,subreg")
237 if (register_operand (op, mode))
240 if (GET_CODE (op) == CONST_INT && INTVAL (op) == 0)
246 ;; Return 1 if OP is a load multiple operation. It is known to be a
247 ;; PARALLEL and the first section will be tested.
249 (define_predicate "mcore_load_multiple_operation"
250 (match_code "parallel")
252 int count = XVECLEN (op, 0);
257 /* Perform a quick check so we don't blow up below. */
259 || GET_CODE (XVECEXP (op, 0, 0)) != SET
260 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != REG
261 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != MEM)
264 dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, 0)));
265 src_addr = XEXP (SET_SRC (XVECEXP (op, 0, 0)), 0);
267 for (i = 1; i < count; i++)
269 rtx elt = XVECEXP (op, 0, i);
271 if (GET_CODE (elt) != SET
272 || GET_CODE (SET_DEST (elt)) != REG
273 || GET_MODE (SET_DEST (elt)) != SImode
274 || REGNO (SET_DEST (elt)) != (unsigned) (dest_regno + i)
275 || GET_CODE (SET_SRC (elt)) != MEM
276 || GET_MODE (SET_SRC (elt)) != SImode
277 || GET_CODE (XEXP (SET_SRC (elt), 0)) != PLUS
278 || ! rtx_equal_p (XEXP (XEXP (SET_SRC (elt), 0), 0), src_addr)
279 || GET_CODE (XEXP (XEXP (SET_SRC (elt), 0), 1)) != CONST_INT
280 || INTVAL (XEXP (XEXP (SET_SRC (elt), 0), 1)) != i * 4)
287 ;; Similar, but tests for store multiple.
289 (define_predicate "mcore_store_multiple_operation"
290 (match_code "parallel")
292 int count = XVECLEN (op, 0);
297 /* Perform a quick check so we don't blow up below. */
299 || GET_CODE (XVECEXP (op, 0, 0)) != SET
300 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != MEM
301 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != REG)
304 src_regno = REGNO (SET_SRC (XVECEXP (op, 0, 0)));
305 dest_addr = XEXP (SET_DEST (XVECEXP (op, 0, 0)), 0);
307 for (i = 1; i < count; i++)
309 rtx elt = XVECEXP (op, 0, i);
311 if (GET_CODE (elt) != SET
312 || GET_CODE (SET_SRC (elt)) != REG
313 || GET_MODE (SET_SRC (elt)) != SImode
314 || REGNO (SET_SRC (elt)) != (unsigned) (src_regno + i)
315 || GET_CODE (SET_DEST (elt)) != MEM
316 || GET_MODE (SET_DEST (elt)) != SImode
317 || GET_CODE (XEXP (SET_DEST (elt), 0)) != PLUS
318 || ! rtx_equal_p (XEXP (XEXP (SET_DEST (elt), 0), 0), dest_addr)
319 || GET_CODE (XEXP (XEXP (SET_DEST (elt), 0), 1)) != CONST_INT
320 || INTVAL (XEXP (XEXP (SET_DEST (elt), 0), 1)) != i * 4)
327 ;; TODO: Add a comment here.
329 (define_predicate "mcore_call_address_operand"
330 (match_code "reg,subreg,const_int,symbol_ref")
332 return register_operand (op, mode) || CONSTANT_P (op);