1 ;; Predicate definitions for IA-64.
2 ;; Copyright (C) 2004, 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, 59 Temple Place - Suite 330,
19 ;; Boston, MA 02111-1307, USA.
21 ;; True if OP is a valid operand for the MEM of a CALL insn.
22 (define_predicate "call_operand"
23 (ior (match_code "symbol_ref")
24 (match_operand 0 "register_operand")))
26 ;; True if OP refers to any kind of symbol.
27 ;; For roughly the same reasons that pmode_register_operand exists, this
28 ;; predicate ignores its mode argument.
29 (define_special_predicate "symbolic_operand"
30 (match_code "symbol_ref,const,label_ref"))
32 ;; True if OP is a SYMBOL_REF which refers to a function.
33 (define_predicate "function_operand"
34 (and (match_code "symbol_ref")
35 (match_test "SYMBOL_REF_FUNCTION_P (op)")))
37 ;; True if OP refers to a symbol, and is appropriate for a GOT load.
38 (define_predicate "got_symbolic_operand"
39 (match_operand 0 "symbolic_operand" "")
41 switch (GET_CODE (op))
47 /* This sort of load should not be used for things in sdata. */
48 return !SYMBOL_REF_SMALL_ADDR_P (op);
51 /* Accept only (plus (symbol_ref) (const_int)). */
53 if (GET_CODE (op) != PLUS
54 || GET_CODE (XEXP (op, 0)) != SYMBOL_REF
55 || GET_CODE (XEXP (op, 1)) != CONST_INT)
58 /* Ok if we're not using GOT entries at all. */
59 if (TARGET_NO_PIC || TARGET_AUTO_PIC)
62 /* The low 14 bits of the constant have been forced to zero
63 by ia64_expand_load_address, so that we do not use up so
64 many GOT entries. Prevent cse from undoing this. */
66 return (INTVAL (op) & 0x3fff) == 0;
73 ;; True if OP refers to a symbol in the sdata section.
74 (define_predicate "sdata_symbolic_operand"
75 (match_code "symbol_ref,const")
77 HOST_WIDE_INT offset = 0, size = 0;
79 switch (GET_CODE (op))
83 if (GET_CODE (op) != PLUS
84 || GET_CODE (XEXP (op, 0)) != SYMBOL_REF
85 || GET_CODE (XEXP (op, 1)) != CONST_INT)
87 offset = INTVAL (XEXP (op, 1));
92 if (CONSTANT_POOL_ADDRESS_P (op))
94 size = GET_MODE_SIZE (get_pool_mode (op));
95 if (size > ia64_section_threshold)
102 if (!SYMBOL_REF_LOCAL_P (op) || !SYMBOL_REF_SMALL_P (op))
105 /* Note that in addition to DECLs, we can get various forms
106 of constants here. */
107 t = SYMBOL_REF_DECL (op);
109 t = DECL_SIZE_UNIT (t);
111 t = TYPE_SIZE_UNIT (TREE_TYPE (t));
112 if (t && host_integerp (t, 0))
114 size = tree_low_cst (t, 0);
120 /* Deny the stupid user trick of addressing outside the object. Such
121 things quickly result in GPREL22 relocation overflows. Of course,
122 they're also highly undefined. From a pure pedant's point of view
123 they deserve a slap on the wrist (such as provided by a relocation
124 overflow), but that just leads to bugzilla noise. */
125 return (offset >= 0 && offset <= size);
132 ;; Like nonimmediate_operand, but don't allow MEMs that try to use a
133 ;; POST_MODIFY with a REG as displacement.
134 (define_predicate "destination_operand"
135 (and (match_operand 0 "nonimmediate_operand")
136 (match_test "GET_CODE (op) != MEM
137 || GET_CODE (XEXP (op, 0)) != POST_MODIFY
138 || GET_CODE (XEXP (XEXP (XEXP (op, 0), 1), 1)) != REG")))
140 ;; Like memory_operand, but don't allow post-increments.
141 (define_predicate "not_postinc_memory_operand"
142 (and (match_operand 0 "memory_operand")
143 (match_test "GET_RTX_CLASS (GET_CODE (XEXP (op, 0))) != RTX_AUTOINC")))
145 ;; True if OP is a general operand, excluding tls symbolic operands.
146 (define_predicate "move_operand"
147 (and (match_operand 0 "general_operand")
149 "GET_CODE (op) == SYMBOL_REF && SYMBOL_REF_TLS_MODEL (op)"))))
151 ;; True if OP is a register operand that is (or could be) a GR reg.
152 (define_predicate "gr_register_operand"
153 (match_operand 0 "register_operand")
156 if (GET_CODE (op) == SUBREG)
157 op = SUBREG_REG (op);
160 return (regno >= FIRST_PSEUDO_REGISTER || GENERAL_REGNO_P (regno));
163 ;; True if OP is a register operand that is (or could be) an FR reg.
164 (define_predicate "fr_register_operand"
165 (match_operand 0 "register_operand")
168 if (GET_CODE (op) == SUBREG)
169 op = SUBREG_REG (op);
172 return (regno >= FIRST_PSEUDO_REGISTER || FR_REGNO_P (regno));
175 ;; True if OP is a register operand that is (or could be) a GR/FR reg.
176 (define_predicate "grfr_register_operand"
177 (match_operand 0 "register_operand")
180 if (GET_CODE (op) == SUBREG)
181 op = SUBREG_REG (op);
184 return (regno >= FIRST_PSEUDO_REGISTER
185 || GENERAL_REGNO_P (regno)
186 || FR_REGNO_P (regno));
189 ;; True if OP is a nonimmediate operand that is (or could be) a GR reg.
190 (define_predicate "gr_nonimmediate_operand"
191 (match_operand 0 "nonimmediate_operand")
195 if (GET_CODE (op) == MEM)
197 if (GET_CODE (op) == SUBREG)
198 op = SUBREG_REG (op);
201 return (regno >= FIRST_PSEUDO_REGISTER || GENERAL_REGNO_P (regno));
204 ;; True if OP is a nonimmediate operand that is (or could be) a FR reg.
205 (define_predicate "fr_nonimmediate_operand"
206 (match_operand 0 "nonimmediate_operand")
210 if (GET_CODE (op) == MEM)
212 if (GET_CODE (op) == SUBREG)
213 op = SUBREG_REG (op);
216 return (regno >= FIRST_PSEUDO_REGISTER || FR_REGNO_P (regno));
219 ;; True if OP is a nonimmediate operand that is (or could be) a GR/FR reg.
220 (define_predicate "grfr_nonimmediate_operand"
221 (match_operand 0 "nonimmediate_operand")
225 if (GET_CODE (op) == MEM)
227 if (GET_CODE (op) == SUBREG)
228 op = SUBREG_REG (op);
231 return (regno >= FIRST_PSEUDO_REGISTER
232 || GENERAL_REGNO_P (regno)
233 || FR_REGNO_P (regno));
236 ;; True if OP is a GR register operand, or zero.
237 (define_predicate "gr_reg_or_0_operand"
238 (ior (match_operand 0 "gr_register_operand")
239 (and (match_code "const_int,const_double,const_vector")
240 (match_test "op == CONST0_RTX (GET_MODE (op))"))))
242 ;; True if OP is a GR register operand, or a 5 bit immediate operand.
243 (define_predicate "gr_reg_or_5bit_operand"
244 (ior (match_operand 0 "gr_register_operand")
245 (and (match_code "const_int")
246 (match_test "INTVAL (op) >= 0 && INTVAL (op) < 32"))))
248 ;; True if OP is a GR register operand, or a 6 bit immediate operand.
249 (define_predicate "gr_reg_or_6bit_operand"
250 (ior (match_operand 0 "gr_register_operand")
251 (and (match_code "const_int")
252 (match_test "CONST_OK_FOR_M (INTVAL (op))"))))
254 ;; True if OP is a GR register operand, or an 8 bit immediate operand.
255 (define_predicate "gr_reg_or_8bit_operand"
256 (ior (match_operand 0 "gr_register_operand")
257 (and (match_code "const_int")
258 (match_test "CONST_OK_FOR_K (INTVAL (op))"))))
260 ;; True if OP is a GR/FR register operand, or an 8 bit immediate operand.
261 (define_predicate "grfr_reg_or_8bit_operand"
262 (ior (match_operand 0 "grfr_register_operand")
263 (and (match_code "const_int")
264 (match_test "CONST_OK_FOR_K (INTVAL (op))"))))
266 ;; True if OP is a register operand, or an 8 bit adjusted immediate operand.
267 (define_predicate "gr_reg_or_8bit_adjusted_operand"
268 (ior (match_operand 0 "gr_register_operand")
269 (and (match_code "const_int")
270 (match_test "CONST_OK_FOR_L (INTVAL (op))"))))
272 ;; True if OP is a register operand, or is valid for both an 8 bit
273 ;; immediate and an 8 bit adjusted immediate operand. This is necessary
274 ;; because when we emit a compare, we don't know what the condition will be,
275 ;; so we need the union of the immediates accepted by GT and LT.
276 (define_predicate "gr_reg_or_8bit_and_adjusted_operand"
277 (ior (match_operand 0 "gr_register_operand")
278 (and (match_code "const_int")
279 (match_test "CONST_OK_FOR_K (INTVAL (op))
280 && CONST_OK_FOR_L (INTVAL (op))"))))
282 ;; True if OP is a register operand, or a 14 bit immediate operand.
283 (define_predicate "gr_reg_or_14bit_operand"
284 (ior (match_operand 0 "gr_register_operand")
285 (and (match_code "const_int")
286 (match_test "CONST_OK_FOR_I (INTVAL (op))"))))
288 ;; True if OP is a register operand, or a 22 bit immediate operand.
289 (define_predicate "gr_reg_or_22bit_operand"
290 (ior (match_operand 0 "gr_register_operand")
291 (and (match_code "const_int")
292 (match_test "CONST_OK_FOR_J (INTVAL (op))"))))
294 ;; True if OP is a 7 bit immediate operand.
295 (define_predicate "dshift_count_operand"
296 (and (match_code "const_int")
297 (match_test "INTVAL (op) >= 0 && INTVAL (op) < 128")))
299 ;; True if OP is a 6 bit immediate operand.
300 (define_predicate "shift_count_operand"
301 (and (match_code "const_int")
302 (match_test "CONST_OK_FOR_M (INTVAL (op))")))
304 ;; True if OP is a 5 bit immediate operand.
305 (define_predicate "shift_32bit_count_operand"
306 (and (match_code "const_int")
307 (match_test "INTVAL (op) >= 0 && INTVAL (op) < 32")))
309 ;; True if OP is one of the immediate values 2, 4, 8, or 16.
310 (define_predicate "shladd_operand"
311 (and (match_code "const_int")
312 (match_test "INTVAL (op) == 2 || INTVAL (op) == 4 ||
313 INTVAL (op) == 8 || INTVAL (op) == 16")))
315 ;; True if OP is one of the immediate values 1, 2, 3, or 4.
316 (define_predicate "shladd_log2_operand"
317 (and (match_code "const_int")
318 (match_test "INTVAL (op) >= 1 && INTVAL (op) <= 4")))
320 ;; True if OP is one of the immediate values -16, -8, -4, -1, 1, 4, 8, 16.
321 (define_predicate "fetchadd_operand"
322 (and (match_code "const_int")
323 (match_test "INTVAL (op) == -16 || INTVAL (op) == -8 ||
324 INTVAL (op) == -4 || INTVAL (op) == -1 ||
325 INTVAL (op) == 1 || INTVAL (op) == 4 ||
326 INTVAL (op) == 8 || INTVAL (op) == 16")))
328 ;; True if OP is 0..3.
329 (define_predicate "const_int_2bit_operand"
330 (and (match_code "const_int")
331 (match_test "INTVAL (op) >= 0 && INTVAL (op) <= 3")))
333 ;; True if OP is a floating-point constant zero, one, or a register.
334 (define_predicate "fr_reg_or_fp01_operand"
335 (ior (match_operand 0 "fr_register_operand")
336 (and (match_code "const_double")
337 (match_test "CONST_DOUBLE_OK_FOR_G (op)"))))
339 ;; Like fr_reg_or_fp01_operand, but don't allow any SUBREGs.
340 (define_predicate "xfreg_or_fp01_operand"
341 (and (match_operand 0 "fr_reg_or_fp01_operand")
342 (not (match_code "subreg"))))
344 ;; True if OP is a constant zero, or a register.
345 (define_predicate "fr_reg_or_0_operand"
346 (ior (match_operand 0 "fr_register_operand")
347 (and (match_code "const_double,const_vector")
348 (match_test "op == CONST0_RTX (GET_MODE (op))"))))
350 ;; True if this is a comparison operator, which accepts a normal 8-bit
351 ;; signed immediate operand.
352 (define_predicate "normal_comparison_operator"
353 (match_code "eq,ne,gt,le,gtu,leu"))
355 ;; True if this is a comparison operator, which accepts an adjusted 8-bit
356 ;; signed immediate operand.
357 (define_predicate "adjusted_comparison_operator"
358 (match_code "lt,ge,ltu,geu"))
360 ;; True if this is a signed inequality operator.
361 (define_predicate "signed_inequality_operator"
362 (match_code "ge,gt,le,lt"))
364 ;; True if this operator is valid for predication.
365 (define_predicate "predicate_operator"
366 (match_code "eq,ne"))
368 ;; True if this operator can be used in a conditional operation.
369 (define_predicate "condop_operator"
370 (match_code "plus,minus,ior,xor,and"))
372 ;; These three are hardware registers that can only be addressed in
373 ;; DImode. It's not strictly necessary to test mode == DImode here,
374 ;; but it makes decent insurance against someone writing a
375 ;; match_operand wrong.
377 ;; True if this is the ar.lc register.
378 (define_predicate "ar_lc_reg_operand"
379 (and (match_code "reg")
380 (match_test "mode == DImode && REGNO (op) == AR_LC_REGNUM")))
382 ;; True if this is the ar.ccv register.
383 (define_predicate "ar_ccv_reg_operand"
384 (and (match_code "reg")
385 (match_test "mode == DImode && REGNO (op) == AR_CCV_REGNUM")))
387 ;; True if this is the ar.pfs register.
388 (define_predicate "ar_pfs_reg_operand"
389 (and (match_code "reg")
390 (match_test "mode == DImode && REGNO (op) == AR_PFS_REGNUM")))
392 ;; True if OP is valid as a base register in a reg + offset address.
393 ;; ??? Should I copy the flag_omit_frame_pointer and cse_not_expected
394 ;; checks from pa.c basereg_operand as well? Seems to be OK without them
396 (define_predicate "basereg_operand"
397 (match_operand 0 "register_operand")
399 if (GET_CODE (op) == SUBREG)
400 op = SUBREG_REG (op);
401 return REG_POINTER (op);