1 ;; Predicate definitions for TMS320C[34]x.
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 floating point value with value 0.0.
23 (define_predicate "fp_zero_operand"
24 (match_code "const_double")
28 if (GET_CODE (op) != CONST_DOUBLE)
30 REAL_VALUE_FROM_CONST_DOUBLE (r, op);
31 return REAL_VALUES_EQUAL (r, dconst0);
34 ;; TODO: Add a comment here.
36 (define_predicate "const_operand"
37 (match_code "const_int,const_double")
43 if (GET_CODE (op) != CONST_DOUBLE
44 || GET_MODE (op) != mode
45 || GET_MODE_CLASS (mode) != MODE_FLOAT)
48 return c4x_immed_float_p (op);
54 if (GET_CODE (op) != CONST_INT
55 || (GET_MODE (op) != VOIDmode && GET_MODE (op) != mode)
56 || GET_MODE_CLASS (mode) != MODE_INT)
59 return IS_HIGH_CONST (INTVAL (op)) || IS_INT16_CONST (INTVAL (op));
69 ;; TODO: Add a comment here.
71 (define_predicate "stik_const_operand"
72 (match_code "const_int")
74 return c4x_K_constant (op);
77 ;; TODO: Add a comment here.
79 (define_predicate "not_const_operand"
80 (match_code "const_int")
82 return c4x_N_constant (op);
85 ;; TODO: Add a comment here.
87 (define_predicate "reg_operand"
88 (match_code "reg,subreg")
90 if (GET_CODE (op) == SUBREG
91 && GET_MODE (op) == QFmode)
93 return register_operand (op, mode);
96 ;; TODO: Add a comment here.
98 (define_predicate "reg_or_const_operand"
99 (match_code "reg,subreg,const_int,const_double")
101 return reg_operand (op, mode) || const_operand (op, mode);
104 ;; Extended precision register R0-R1.
106 (define_predicate "r0r1_reg_operand"
107 (match_code "reg,subreg")
109 if (! reg_operand (op, mode))
111 if (GET_CODE (op) == SUBREG)
112 op = SUBREG_REG (op);
113 return REG_P (op) && IS_R0R1_OR_PSEUDO_REG (op);
116 ;; Extended precision register R2-R3.
118 (define_predicate "r2r3_reg_operand"
119 (match_code "reg,subreg")
121 if (! reg_operand (op, mode))
123 if (GET_CODE (op) == SUBREG)
124 op = SUBREG_REG (op);
125 return REG_P (op) && IS_R2R3_OR_PSEUDO_REG (op);
128 ;; Low extended precision register R0-R7.
130 (define_predicate "ext_low_reg_operand"
131 (match_code "reg,subreg")
133 if (! reg_operand (op, mode))
135 if (GET_CODE (op) == SUBREG)
136 op = SUBREG_REG (op);
137 return REG_P (op) && IS_EXT_LOW_OR_PSEUDO_REG (op);
140 ;; Extended precision register.
142 (define_predicate "ext_reg_operand"
143 (match_code "reg,subreg")
145 if (! reg_operand (op, mode))
147 if (GET_CODE (op) == SUBREG)
148 op = SUBREG_REG (op);
151 return IS_EXT_OR_PSEUDO_REG (op);
154 ;; Standard precision register.
156 (define_predicate "std_reg_operand"
157 (match_code "reg,subreg")
159 if (! reg_operand (op, mode))
161 if (GET_CODE (op) == SUBREG)
162 op = SUBREG_REG (op);
163 return REG_P (op) && IS_STD_OR_PSEUDO_REG (op);
166 ;; Standard precision or normal register.
168 (define_predicate "std_or_reg_operand"
169 (match_code "reg,subreg")
171 if (reload_in_progress)
172 return std_reg_operand (op, mode);
173 return reg_operand (op, mode);
178 (define_predicate "addr_reg_operand"
179 (match_code "reg,subreg")
181 if (! reg_operand (op, mode))
183 return c4x_a_register (op);
188 (define_predicate "index_reg_operand"
189 (match_code "reg,subreg")
191 if (! reg_operand (op, mode))
193 if (GET_CODE (op) == SUBREG)
194 op = SUBREG_REG (op);
195 return c4x_x_register (op);
200 (define_predicate "dp_reg_operand"
203 return REG_P (op) && IS_DP_OR_PSEUDO_REG (op);
208 (define_predicate "sp_reg_operand"
211 return REG_P (op) && IS_SP_OR_PSEUDO_REG (op);
216 (define_predicate "st_reg_operand"
219 return REG_P (op) && IS_ST_OR_PSEUDO_REG (op);
224 (define_predicate "rc_reg_operand"
227 return REG_P (op) && IS_RC_OR_PSEUDO_REG (op);
230 ;; TODO: Add a comment here.
232 (define_predicate "call_address_operand"
233 (match_code "reg,symbol_ref,label_ref,const")
235 return (REG_P (op) || symbolic_address_operand (op, mode));
238 ;; Check dst operand of a move instruction.
240 (define_predicate "dst_operand"
241 (match_code "subreg,reg,mem")
243 if (GET_CODE (op) == SUBREG
244 && mixed_subreg_operand (op, mode))
248 return reg_operand (op, mode);
250 return nonimmediate_operand (op, mode);
253 ;; Check src operand of two operand arithmetic instructions.
255 (define_predicate "src_operand"
256 (match_code "subreg,reg,mem,const_int,const_double")
258 if (GET_CODE (op) == SUBREG
259 && mixed_subreg_operand (op, mode))
263 return reg_operand (op, mode);
265 if (mode == VOIDmode)
266 mode = GET_MODE (op);
268 if (GET_CODE (op) == CONST_INT)
269 return (mode == QImode || mode == Pmode || mode == HImode)
270 && c4x_I_constant (op);
272 /* We don't like CONST_DOUBLE integers. */
273 if (GET_CODE (op) == CONST_DOUBLE)
274 return c4x_H_constant (op);
276 /* Disallow symbolic addresses. Only the predicate
277 symbolic_address_operand will match these. */
278 if (GET_CODE (op) == SYMBOL_REF
279 || GET_CODE (op) == LABEL_REF
280 || GET_CODE (op) == CONST)
283 /* If TARGET_LOAD_DIRECT_MEMS is nonzero, disallow direct memory
284 access to symbolic addresses. These operands will get forced
285 into a register and the movqi expander will generate a
286 HIGH/LO_SUM pair if TARGET_EXPOSE_LDP is nonzero. */
287 if (GET_CODE (op) == MEM
288 && ((GET_CODE (XEXP (op, 0)) == SYMBOL_REF
289 || GET_CODE (XEXP (op, 0)) == LABEL_REF
290 || GET_CODE (XEXP (op, 0)) == CONST)))
291 return !TARGET_EXPOSE_LDP &&
292 ! TARGET_LOAD_DIRECT_MEMS && GET_MODE (op) == mode;
294 return general_operand (op, mode);
297 ;; TODO: Add a comment here.
299 (define_predicate "src_hi_operand"
300 (match_code "subreg,reg,mem,const_double")
302 if (c4x_O_constant (op))
304 return src_operand (op, mode);
307 ;; Check src operand of two operand logical instructions.
309 (define_predicate "lsrc_operand"
310 (match_code "subreg,reg,mem,const_int,const_double")
312 if (mode == VOIDmode)
313 mode = GET_MODE (op);
315 if (mode != QImode && mode != Pmode)
316 fatal_insn ("mode not QImode", op);
318 if (GET_CODE (op) == CONST_INT)
319 return c4x_L_constant (op) || c4x_J_constant (op);
321 return src_operand (op, mode);
324 ;; Check src operand of two operand tricky instructions.
326 (define_predicate "tsrc_operand"
327 (match_code "subreg,reg,mem,const_int,const_double")
329 if (mode == VOIDmode)
330 mode = GET_MODE (op);
332 if (mode != QImode && mode != Pmode)
333 fatal_insn ("mode not QImode", op);
335 if (GET_CODE (op) == CONST_INT)
336 return c4x_L_constant (op) || c4x_N_constant (op) || c4x_J_constant (op);
338 return src_operand (op, mode);
341 ;; Check src operand of two operand non immediate instructions.
343 (define_predicate "nonimmediate_src_operand"
344 (match_code "subreg,reg,mem")
346 if (GET_CODE (op) == CONST_INT || GET_CODE (op) == CONST_DOUBLE)
349 return src_operand (op, mode);
352 ;; Check logical src operand of two operand non immediate instructions.
354 (define_predicate "nonimmediate_lsrc_operand"
355 (match_code "subreg,reg,mem")
357 if (GET_CODE (op) == CONST_INT || GET_CODE (op) == CONST_DOUBLE)
360 return lsrc_operand (op, mode);
363 ;; Match any operand.
365 (define_predicate "any_operand"
366 (match_code "subreg,reg,mem,const_int,const_double")
371 ;; Check for indirect operands allowable in parallel instruction.
373 (define_predicate "par_ind_operand"
376 if (mode != VOIDmode && mode != GET_MODE (op))
379 return c4x_S_indirect (op);
382 ;; Check for operands allowable in parallel instruction.
384 (define_predicate "parallel_operand"
385 (match_code "subreg,reg,mem")
387 return ext_low_reg_operand (op, mode) || par_ind_operand (op, mode);
390 ;; Symbolic address operand.
392 (define_predicate "symbolic_address_operand"
393 (match_code "symbol_ref,label_ref,const")
395 switch (GET_CODE (op))