comparison gcc/config/pa/predicates.md @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 ;; Predicate definitions for HP PA-RISC. 1 ;; Predicate definitions for HP PA-RISC.
2 ;; Copyright (C) 2005, 2007, 2010 Free Software Foundation, Inc. 2 ;; Copyright (C) 2005-2017 Free Software Foundation, Inc.
3 ;; 3 ;;
4 ;; This file is part of GCC. 4 ;; This file is part of GCC.
5 ;; 5 ;;
6 ;; GCC is free software; you can redistribute it and/or modify 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 7 ;; it under the terms of the GNU General Public License as published by
15 ;; 15 ;;
16 ;; You should have received a copy of the GNU General Public License 16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GCC; see the file COPYING3. If not see 17 ;; along with GCC; see the file COPYING3. If not see
18 ;; <http://www.gnu.org/licenses/>. 18 ;; <http://www.gnu.org/licenses/>.
19 19
20 ;; Return nonzero only if OP is a register of mode MODE, or 20 ;; Return truth value of whether OP is an integer which fits the range
21 ;; CONST0_RTX. 21 ;; constraining 5-bit signed immediate operands in three-address insns.
22 22
23 (define_predicate "reg_or_0_operand" 23 (define_predicate "int5_operand"
24 (match_code "subreg,reg,const_int,const_double") 24 (and (match_code "const_int")
25 { 25 (match_test "INT_5_BITS (op)")))
26 return (op == CONST0_RTX (mode) || register_operand (op, mode)); 26
27 ;; Return truth value of whether OP is an integer which fits the range
28 ;; constraining 5-bit unsigned immediate operands in three-address insns.
29
30 (define_predicate "uint5_operand"
31 (and (match_code "const_int")
32 (match_test "INT_U5_BITS (op)")))
33
34 ;; Return truth value of whether OP is an integer which fits the range
35 ;; constraining 6-bit unsigned immediate operands in three-address insns.
36
37 (define_predicate "uint6_operand"
38 (and (match_code "const_int")
39 (match_test "INT_U6_BITS (op)")))
40
41 ;; Return truth value of whether OP is an integer which fits the range
42 ;; constraining 11-bit signed immediate operands in three-address insns.
43
44 (define_predicate "int11_operand"
45 (and (match_code "const_int")
46 (match_test "INT_11_BITS (op)")))
47
48 ;; Return truth value of whether OP is an integer which fits the range
49 ;; constraining 14-bit signed immediate operands in three-address insns.
50
51 (define_predicate "int14_operand"
52 (and (match_code "const_int")
53 (match_test "INT_14_BITS (op)")))
54
55 ;; True iff OP is a const_int or const_double that will fit in 32 bits.
56
57 (define_predicate "uint32_operand"
58 (if_then_else (match_test "HOST_BITS_PER_WIDE_INT > 32")
59 (and (match_code "const_int")
60 (match_test "INTVAL (op) >= 0
61 && INTVAL (op) < (HOST_WIDE_INT) 1 << 32"))
62 (and (match_code "const_int,const_double")
63 (match_test "CONST_INT_P (op) || CONST_DOUBLE_HIGH (op) == 0"))))
64
65 ;; True iff depi can be used to compute (reg | OP).
66
67 (define_predicate "cint_ior_operand"
68 (and (match_code "const_int")
69 (match_test "pa_ior_mask_p (INTVAL (op))")))
70
71 ;; True iff OP is CONST_INT that can be moved in one instruction
72 ;; into a general register.
73
74 (define_predicate "cint_move_operand"
75 (and (match_code "const_int")
76 (match_test "pa_cint_ok_for_move (INTVAL (op))")))
77
78 ;; True iff OP is a CONST0_RTX for MODE.
79
80 (define_predicate "const_0_operand"
81 (and (match_code "const_int,const_double")
82 (match_test "op == CONST0_RTX (mode)")))
83
84 ;; A constant integer suitable for use in a PRE_MODIFY memory reference.
85
86 (define_predicate "pre_cint_operand"
87 (and (match_code "const_int")
88 (match_test "INTVAL (op) >= -0x2000 && INTVAL (op) < 0x10")))
89
90 ;; A constant integer suitable for use in a POST_MODIFY memory reference.
91
92 (define_predicate "post_cint_operand"
93 (and (match_code "const_int")
94 (match_test "INTVAL (op) < 0x2000 && INTVAL (op) >= -0x10")))
95
96 ;; True iff depi or extru can be used to compute (reg & OP).
97
98 (define_predicate "and_operand"
99 (ior (match_operand 0 "register_operand")
100 (and (match_code "const_int")
101 (match_test "pa_and_mask_p (INTVAL (op))"))))
102
103 ;; Return truth value of whether OP can be used as an operand in a
104 ;; three operand arithmetic insn that accepts registers of mode MODE
105 ;; or 5-bit signed integers.
106
107 (define_predicate "arith5_operand"
108 (ior (match_operand 0 "register_operand")
109 (match_operand 0 "int5_operand")))
110
111 ;; Return truth value of whether OP can be used as an operand in a
112 ;; three operand arithmetic insn that accepts registers of mode MODE
113 ;; or 11-bit signed integers.
114
115 (define_predicate "arith11_operand"
116 (ior (match_operand 0 "register_operand")
117 (match_operand 0 "int11_operand")))
118
119 ;; Return truth value of whether OP can be used as an operand in a
120 ;; three operand arithmetic insn that accepts registers of mode MODE
121 ;; or 14-bit signed integers.
122
123 (define_predicate "arith14_operand"
124 (ior (match_operand 0 "register_operand")
125 (match_operand 0 "int14_operand")))
126
127 ;; Return truth value of whether OP can be used as an operand in a
128 ;; three operand arithmetic insn that accepts registers of mode MODE
129 ;; or 32-bit signed integers.
130
131 (define_predicate "arith32_operand"
132 (ior (match_operand 0 "register_operand")
133 (match_code "const_int")))
134
135 ;; Return truth value of whether OP can be used as a shift operand in
136 ;; a shift insn that accepts registers of mode MODE or 5-bit shift amounts.
137
138 (define_predicate "shift5_operand"
139 (ior (match_operand 0 "register_operand")
140 (match_operand 0 "uint5_operand")))
141
142 ;; Return truth value of whether OP can be used as a shift operand in
143 ;; a shift insn that accepts registers of mode MODE or 6-bit shift amounts.
144
145 (define_predicate "shift6_operand"
146 (ior (match_operand 0 "register_operand")
147 (match_operand 0 "uint6_operand")))
148
149 ;; True iff OP can be used as an operand in an adddi3 insn.
150
151 (define_predicate "adddi3_operand"
152 (if_then_else (match_test "TARGET_64BIT")
153 (match_operand 0 "arith14_operand")
154 (match_operand 0 "arith11_operand")))
155
156 ;; True iff OP is valid as a base or index register in a REG+REG address.
157
158 (define_predicate "borx_reg_operand"
159 (match_code "reg")
160 {
161 /* We must reject virtual registers as the only expressions that
162 can be instantiated are REG and REG+CONST. */
163 if (op == virtual_incoming_args_rtx
164 || op == virtual_stack_vars_rtx
165 || op == virtual_stack_dynamic_rtx
166 || op == virtual_outgoing_args_rtx
167 || op == virtual_cfa_rtx)
168 return false;
169
170 /* While it's always safe to index off the frame pointer, it's not
171 profitable to do so when the frame pointer is being eliminated. */
172 if (!reload_completed
173 && flag_omit_frame_pointer
174 && !cfun->calls_alloca
175 && op == frame_pointer_rtx)
176 return false;
177
178 return register_operand (op, mode);
27 }) 179 })
28 180
29 ;; Return nonzero if OP is suitable for use in a call to a named 181 ;; Return nonzero if OP is suitable for use in a call to a named
30 ;; function. 182 ;; function.
31 ;; 183 ;;
37 { 189 {
38 return (GET_MODE (op) == word_mode 190 return (GET_MODE (op) == word_mode
39 && CONSTANT_P (op) && ! TARGET_PORTABLE_RUNTIME); 191 && CONSTANT_P (op) && ! TARGET_PORTABLE_RUNTIME);
40 }) 192 })
41 193
42 ;; Return 1 iff OP is an indexed memory operand. 194 ;; True iff OP can be used as the divisor in a div millicode call.
195
196 (define_predicate "div_operand"
197 (match_code "reg,const_int")
198 {
199 return (mode == SImode
200 && ((REG_P (op) && REGNO (op) == 25)
201 || (CONST_INT_P (op)
202 && INTVAL (op) > 0 && INTVAL (op) < 16
203 && pa_magic_milli[INTVAL (op)])));
204 })
205
206 ;; True iff OP is a reloading floating point register
207
208 (define_predicate "fp_reg_operand"
209 (and (match_code "reg")
210 (match_test "reg_renumber && FP_REG_P (op)")))
211
212 ;; True iff OP is a function label operand.
213
214 (define_special_predicate "function_label_operand"
215 (and (match_code "symbol_ref")
216 (match_test "FUNCTION_NAME_P (XSTR (op, 0))")))
217
218 ;; True iff OP is an indexed memory operand.
43 219
44 (define_predicate "indexed_memory_operand" 220 (define_predicate "indexed_memory_operand"
45 (match_code "subreg,mem") 221 (match_code "subreg,mem")
46 { 222 {
47 if (GET_MODE (op) != mode) 223 if (GET_MODE (op) != mode)
48 return 0; 224 return false;
49 225
50 /* Before reload, a (SUBREG (MEM...)) forces reloading into a register. */ 226 /* Before reload, a (SUBREG (MEM...)) forces reloading into a register. */
51 if (reload_completed && GET_CODE (op) == SUBREG) 227 if (reload_completed && GET_CODE (op) == SUBREG)
52 op = SUBREG_REG (op); 228 op = SUBREG_REG (op);
53 229
54 if (GET_CODE (op) != MEM || symbolic_memory_operand (op, mode)) 230 if (! MEM_P (op))
55 return 0; 231 return false;
56 232
57 op = XEXP (op, 0); 233 op = XEXP (op, 0);
58 234 return IS_INDEX_ADDR_P (op) && memory_address_p (mode, op);
59 return (memory_address_p (mode, op) && IS_INDEX_ADDR_P (op)); 235 })
60 }) 236
61 237 ;; True iff OP is a register plus base memory operand.
62 ;; Return 1 iff OP is a symbolic operand. 238
239 (define_predicate "reg_plus_base_memory_operand"
240 (match_code "subreg,mem")
241 {
242 if (GET_MODE (op) != mode)
243 return false;
244
245 /* Before reload, a (SUBREG (MEM...)) forces reloading into a register. */
246 if (reload_completed && GET_CODE (op) == SUBREG)
247 op = SUBREG_REG (op);
248
249 if (! MEM_P (op))
250 return false;
251
252 op = XEXP (op, 0);
253 if (GET_CODE (op) != PLUS)
254 return false;
255
256 if (REG_P (XEXP (op, 0)) && REG_OK_FOR_BASE_P (XEXP (op, 0)))
257 return GET_CODE (XEXP (op, 1)) == CONST_INT;
258
259 return false;
260 })
261
262 ;; True iff OP is a base14 operand.
263
264 (define_predicate "base14_operand"
265 (match_code "const_int")
266 {
267 if (!INT_14_BITS (op))
268 return false;
269
270 /* Although this may not be necessary, we require that the
271 base value is correctly aligned for its mode as this is
272 assumed in the instruction encoding. */
273 switch (mode)
274 {
275 case E_BLKmode:
276 case E_QImode:
277 case E_HImode:
278 return true;
279
280 default:
281 return (INTVAL (op) % GET_MODE_SIZE (mode)) == 0;
282 }
283
284 return false;
285 })
286
287 ;; True iff the operand OP can be used as the destination operand of
288 ;; an integer store. This also implies the operand could be used as
289 ;; the source operand of an integer load. LO_SUM DLT and indexed
290 ;; memory operands are not allowed. We accept reloading pseudos and
291 ;; other memory operands.
292
293 (define_predicate "integer_store_memory_operand"
294 (match_code "reg,mem")
295 {
296 if (reload_in_progress
297 && REG_P (op)
298 && REGNO (op) >= FIRST_PSEUDO_REGISTER
299 && reg_renumber [REGNO (op)] < 0)
300 return true;
301
302 if (reg_plus_base_memory_operand (op, mode))
303 {
304 if (reload_in_progress)
305 return true;
306
307 /* Extract CONST_INT operand. */
308 if (GET_CODE (op) == SUBREG)
309 op = SUBREG_REG (op);
310 op = XEXP (op, 0);
311 op = REG_P (XEXP (op, 0)) ? XEXP (op, 1) : XEXP (op, 0);
312 return base14_operand (op, mode) || INT_5_BITS (op);
313 }
314
315 if (!MEM_P (op))
316 return false;
317
318 return ((reload_in_progress || memory_address_p (mode, XEXP (op, 0)))
319 && !IS_LO_SUM_DLT_ADDR_P (XEXP (op, 0))
320 && !IS_INDEX_ADDR_P (XEXP (op, 0)));
321 })
322
323 ;; True iff the operand OP can be used as the destination operand of
324 ;; a floating point store. This also implies the operand could be used as
325 ;; the source operand of a floating point load. LO_SUM DLT and indexed
326 ;; memory operands are not allowed. Symbolic operands are accepted if
327 ;; INT14_OK_STRICT is true. We accept reloading pseudos and other memory
328 ;; operands.
329
330 (define_predicate "floating_point_store_memory_operand"
331 (match_code "reg,mem")
332 {
333 if (reload_in_progress
334 && REG_P (op)
335 && REGNO (op) >= FIRST_PSEUDO_REGISTER
336 && reg_renumber [REGNO (op)] < 0)
337 return true;
338
339 if (reg_plus_base_memory_operand (op, mode))
340 {
341 if (reload_in_progress)
342 return true;
343
344 /* Extract CONST_INT operand. */
345 if (GET_CODE (op) == SUBREG)
346 op = SUBREG_REG (op);
347 op = XEXP (op, 0);
348 op = REG_P (XEXP (op, 0)) ? XEXP (op, 1) : XEXP (op, 0);
349 return ((TARGET_PA_20
350 && !TARGET_ELF32
351 && base14_operand (op, mode))
352 || INT_5_BITS (op));
353 }
354
355 if (!MEM_P (op))
356 return false;
357
358 return ((reload_in_progress || memory_address_p (mode, XEXP (op, 0)))
359 && (INT14_OK_STRICT || !symbolic_memory_operand (op, VOIDmode))
360 && !IS_LO_SUM_DLT_ADDR_P (XEXP (op, 0))
361 && !IS_INDEX_ADDR_P (XEXP (op, 0)));
362 })
363
364 ;; Return true iff OP is an integer register.
365
366 (define_predicate "ireg_operand"
367 (and (match_code "reg")
368 (match_test "REGNO (op) > 0 && REGNO (op) < 32")))
369
370 ;; Return truth value of whether OP is an integer which fits the range
371 ;; constraining immediate operands in three-address insns, or is an
372 ;; integer register.
373
374 (define_predicate "ireg_or_int5_operand"
375 (ior (match_operand 0 "ireg_operand")
376 (match_operand 0 "int5_operand")))
377
378 ;; True iff OP is a CONST_INT of the forms 0...0xxxx, 0...01...1xxxx,
379 ;; or 1...1xxxx. Such values can be the left hand side x in (x << r),
380 ;; using the zvdepi instruction.
381
382 (define_predicate "lhs_lshift_cint_operand"
383 (match_code "const_int")
384 {
385 unsigned HOST_WIDE_INT x;
386 x = INTVAL (op) >> 4;
387 return (x & (x + 1)) == 0;
388 })
389
390 ;; True iff OP can be used in a zvdep instruction.
391
392 (define_predicate "lhs_lshift_operand"
393 (ior (match_operand 0 "register_operand")
394 (match_operand 0 "lhs_lshift_cint_operand")))
395
396 ;; Accept anything that can be used as a destination operand for a
397 ;; move instruction. We don't accept indexed memory operands since
398 ;; they are supported only for floating point stores.
399
400 (define_predicate "move_dest_operand"
401 (match_code "subreg,reg,mem")
402 {
403 if (register_operand (op, mode))
404 return true;
405
406 if (GET_MODE (op) != mode)
407 return false;
408
409 if (GET_CODE (op) == SUBREG)
410 op = SUBREG_REG (op);
411
412 if (! MEM_P (op))
413 return false;
414
415 op = XEXP (op, 0);
416
417 return (memory_address_p (mode, op)
418 && !IS_INDEX_ADDR_P (op)
419 && !IS_LO_SUM_DLT_ADDR_P (op));
420 })
421
422 ;; Accept anything that can be used as a source operand for a move
423 ;; instruction.
424
425 (define_predicate "move_src_operand"
426 (match_code "subreg,reg,const_int,const_double,mem")
427 {
428 if (register_operand (op, mode))
429 return true;
430
431 if (op == CONST0_RTX (mode))
432 return true;
433
434 if (CONST_INT_P (op))
435 return pa_cint_ok_for_move (INTVAL (op));
436
437 if (GET_MODE (op) != mode)
438 return false;
439
440 if (GET_CODE (op) == SUBREG)
441 op = SUBREG_REG (op);
442
443 if (! MEM_P (op))
444 return false;
445
446 /* Until problems with management of the REG_POINTER flag are resolved,
447 we need to delay creating move insns with unscaled indexed addresses
448 until CSE is not expected. */
449 if (!TARGET_NO_SPACE_REGS
450 && !cse_not_expected
451 && GET_CODE (XEXP (op, 0)) == PLUS
452 && REG_P (XEXP (XEXP (op, 0), 0))
453 && REG_P (XEXP (XEXP (op, 0), 1)))
454 return false;
455
456 return memory_address_p (mode, XEXP (op, 0));
457 })
458
459 ;; True iff OP is not a symbolic memory operand.
460
461 (define_predicate "nonsymb_mem_operand"
462 (match_code "subreg,mem")
463 {
464 if (GET_CODE (op) == SUBREG)
465 op = SUBREG_REG (op);
466
467 if (! MEM_P (op))
468 return false;
469
470 /* Until problems with management of the REG_POINTER flag are resolved,
471 we need to delay creating move insns with unscaled indexed addresses
472 until CSE is not expected. */
473 if (!TARGET_NO_SPACE_REGS
474 && !cse_not_expected
475 && GET_CODE (XEXP (op, 0)) == PLUS
476 && REG_P (XEXP (XEXP (op, 0), 0))
477 && REG_P (XEXP (XEXP (op, 0), 1)))
478 return false;
479
480 return (!symbolic_memory_operand (op, mode)
481 && memory_address_p (mode, XEXP (op, 0)));
482 })
483
484 ;; True iff OP is anything other than a hard register.
485
486 (define_predicate "non_hard_reg_operand"
487 (match_test "! (REG_P (op) && REGNO (op) < FIRST_PSEUDO_REGISTER)"))
488
489 ;; True iff OP is a reference to a label whose address can be loaded
490 ;; while generating PIC code.
491
492 (define_predicate "pic_label_operand"
493 (match_code "label_ref,const")
494 {
495 if (!flag_pic)
496 return false;
497
498 switch (GET_CODE (op))
499 {
500 case LABEL_REF:
501 return true;
502 case CONST:
503 op = XEXP (op, 0);
504 return (GET_CODE (XEXP (op, 0)) == LABEL_REF
505 && CONST_INT_P (XEXP (op, 1)));
506 default:
507 gcc_unreachable ();
508 }
509 return false;
510 })
511
512 ;; True iff the operand OP lives in text space. OP is a symbolic operand.
513 ;; If so, SYMBOL_REF_FLAG, which is set by pa_encode_section_info, is true.
514
515 (define_special_predicate "read_only_operand"
516 (match_test "true")
517 {
518 if (GET_CODE (op) == CONST)
519 op = XEXP (XEXP (op, 0), 0);
520 if (GET_CODE (op) == SYMBOL_REF)
521 {
522 if (flag_pic)
523 return SYMBOL_REF_FLAG (op) && !CONSTANT_POOL_ADDRESS_P (op);
524 else
525 return SYMBOL_REF_FLAG (op) || CONSTANT_POOL_ADDRESS_P (op);
526 }
527 return true;
528 })
529
530 ;; True iff the operand is a register operand, or a non-symbolic
531 ;; memory operand after reload. A SUBREG is not accepted since it
532 ;; will need a reload.
533 ;;
534 ;; This predicate is used for branch patterns that internally handle
535 ;; register reloading. We need to accept non-symbolic memory operands
536 ;; after reload to ensure that the pattern is still valid if reload
537 ;; didn't find a hard register for the operand. We also reject index
538 ;; and lo_sum DLT address as these are invalid for move destinations.
539
540 (define_predicate "reg_before_reload_operand"
541 (match_code "reg,mem")
542 {
543 rtx op0;
544
545 if (register_operand (op, mode))
546 return true;
547
548 if (!reload_in_progress && !reload_completed)
549 return false;
550
551 if (! MEM_P (op))
552 return false;
553
554 op0 = XEXP (op, 0);
555
556 return (memory_address_p (mode, op0)
557 && !IS_INDEX_ADDR_P (op0)
558 && !IS_LO_SUM_DLT_ADDR_P (op0)
559 && !symbolic_memory_operand (op, mode));
560 })
561
562 ;; True iff OP is a register or const_0 operand for MODE.
563
564 (define_predicate "reg_or_0_operand"
565 (ior (match_operand 0 "register_operand")
566 (match_operand 0 "const_0_operand")))
567
568 ;; True iff OP is either a register, zero, or a non-symbolic memory operand.
569
570 (define_predicate "reg_or_0_or_nonsymb_mem_operand"
571 (ior (match_operand 0 "reg_or_0_operand")
572 (match_operand 0 "nonsymb_mem_operand")))
573
574 ;; Accept REG and any CONST_INT that can be moved in one instruction
575 ;; into a general register.
576
577 (define_predicate "reg_or_cint_move_operand"
578 (ior (match_operand 0 "register_operand")
579 (match_operand 0 "cint_move_operand")))
580
581 ;; True iff OP can be used to compute (reg | OP).
582
583 (define_predicate "reg_or_cint_ior_operand"
584 (ior (match_operand 0 "register_operand")
585 (match_operand 0 "cint_ior_operand")))
586
587 ;; Return 1 if OP is a CONST_INT with the value 2, 4, or 8. These are
588 ;; the valid constants for shadd instructions.
589
590 (define_predicate "mem_shadd_operand"
591 (and (match_code "const_int")
592 (match_test "pa_mem_shadd_constant_p (INTVAL (op))")))
593
594 (define_predicate "shadd_operand"
595 (and (match_code "const_int")
596 (match_test "pa_shadd_constant_p (INTVAL (op))")))
597
598 ;; Return truth value of statement that OP is a symbolic memory operand.
599
600 (define_predicate "symbolic_memory_operand"
601 (match_code "subreg,mem")
602 {
603 if (GET_CODE (op) == SUBREG)
604 op = SUBREG_REG (op);
605 if (!MEM_P (op))
606 return false;
607 op = XEXP (op, 0);
608 if (GET_CODE (op) == LO_SUM)
609 op = XEXP (op, 1);
610 return pa_symbolic_expression_p (op);
611 })
612
613 ;; True iff OP is a symbolic operand.
63 ;; Note: an inline copy of this code is present in pa_secondary_reload. 614 ;; Note: an inline copy of this code is present in pa_secondary_reload.
64 615
65 (define_predicate "symbolic_operand" 616 (define_predicate "symbolic_operand"
66 (match_code "symbol_ref,label_ref,const") 617 (match_code "symbol_ref,label_ref,const")
67 { 618 {
68 switch (GET_CODE (op)) 619 switch (GET_CODE (op))
69 { 620 {
70 case SYMBOL_REF: 621 case SYMBOL_REF:
71 return !SYMBOL_REF_TLS_MODEL (op); 622 return !SYMBOL_REF_TLS_MODEL (op);
72 case LABEL_REF: 623 case LABEL_REF:
73 return 1; 624 return true;
74 case CONST: 625 case CONST:
75 op = XEXP (op, 0); 626 op = XEXP (op, 0);
76 return (GET_CODE (op) == PLUS 627 return (GET_CODE (op) == PLUS
77 && ((GET_CODE (XEXP (op, 0)) == SYMBOL_REF 628 && ((GET_CODE (XEXP (op, 0)) == SYMBOL_REF
78 && !SYMBOL_REF_TLS_MODEL (XEXP (op, 0))) 629 && !SYMBOL_REF_TLS_MODEL (XEXP (op, 0)))
79 || GET_CODE (XEXP (op, 0)) == LABEL_REF) 630 || GET_CODE (XEXP (op, 0)) == LABEL_REF)
80 && GET_CODE (XEXP (op, 1)) == CONST_INT); 631 && GET_CODE (XEXP (op, 1)) == CONST_INT);
81 default: 632 default:
82 return 0; 633 break;
83 } 634 }
84 }) 635 return false;
85
86 ;; Return truth value of statement that OP is a symbolic memory
87 ;; operand of mode MODE.
88
89 (define_predicate "symbolic_memory_operand"
90 (match_code "subreg,mem")
91 {
92 if (GET_CODE (op) == SUBREG)
93 op = SUBREG_REG (op);
94 if (GET_CODE (op) != MEM)
95 return 0;
96 op = XEXP (op, 0);
97 return ((GET_CODE (op) == SYMBOL_REF && !SYMBOL_REF_TLS_MODEL (op))
98 || GET_CODE (op) == CONST || GET_CODE (op) == HIGH
99 || GET_CODE (op) == LABEL_REF);
100 }) 636 })
101 637
102 ;; Return true if OP is a symbolic operand for the TLS Global Dynamic model. 638 ;; Return true if OP is a symbolic operand for the TLS Global Dynamic model.
639
103 (define_predicate "tgd_symbolic_operand" 640 (define_predicate "tgd_symbolic_operand"
104 (and (match_code "symbol_ref") 641 (and (match_code "symbol_ref")
105 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_GLOBAL_DYNAMIC"))) 642 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_GLOBAL_DYNAMIC")))
106 643
107 ;; Return true if OP is a symbolic operand for the TLS Local Dynamic model. 644 ;; Return true if OP is a symbolic operand for the TLS Local Dynamic model.
645
108 (define_predicate "tld_symbolic_operand" 646 (define_predicate "tld_symbolic_operand"
109 (and (match_code "symbol_ref") 647 (and (match_code "symbol_ref")
110 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_DYNAMIC"))) 648 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_DYNAMIC")))
111 649
112 ;; Return true if OP is a symbolic operand for the TLS Initial Exec model. 650 ;; Return true if OP is a symbolic operand for the TLS Initial Exec model.
651
113 (define_predicate "tie_symbolic_operand" 652 (define_predicate "tie_symbolic_operand"
114 (and (match_code "symbol_ref") 653 (and (match_code "symbol_ref")
115 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_INITIAL_EXEC"))) 654 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_INITIAL_EXEC")))
116 655
117 ;; Return true if OP is a symbolic operand for the TLS Local Exec model. 656 ;; Return true if OP is a symbolic operand for the TLS Local Exec model.
657
118 (define_predicate "tle_symbolic_operand" 658 (define_predicate "tle_symbolic_operand"
119 (and (match_code "symbol_ref") 659 (and (match_code "symbol_ref")
120 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_EXEC"))) 660 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_EXEC")))
121 661
122 662 ;; True iff this is a comparison operator. This allows the use of
123 ;; Return 1 if the operand is a register operand or a non-symbolic 663 ;; MATCH_OPERATOR to recognize all the branch insns.
124 ;; memory operand after reload. This predicate is used for branch 664
125 ;; patterns that internally handle register reloading. We need to 665 (define_predicate "cmpib_comparison_operator"
126 ;; accept non-symbolic memory operands after reload to ensure that the 666 (match_code "eq,ne,lt,le,leu,gt,gtu,ge"))
127 ;; pattern is still valid if reload didn't find a hard register for 667
128 ;; the operand. 668 ;; True iff OP is an operator suitable for use in a movb instruction.
129 669
130 (define_predicate "reg_before_reload_operand" 670 (define_predicate "movb_comparison_operator"
131 (match_code "reg,mem") 671 (match_code "eq,ne,lt,ge"))
132 { 672
133 /* Don't accept a SUBREG since it will need a reload. */ 673 ;; True iff OP is a PLUS, XOR or IOR operator.
134 if (GET_CODE (op) == SUBREG)
135 return 0;
136
137 if (register_operand (op, mode))
138 return 1;
139
140 if (reload_completed
141 && memory_operand (op, mode)
142 && !symbolic_memory_operand (op, mode))
143 return 1;
144
145 return 0;
146 })
147
148 ;; Return 1 if the operand is either a register, zero, or a memory
149 ;; operand that is not symbolic.
150
151 (define_predicate "reg_or_0_or_nonsymb_mem_operand"
152 (match_code "subreg,reg,mem,const_int,const_double")
153 {
154 if (register_operand (op, mode))
155 return 1;
156
157 if (op == CONST0_RTX (mode))
158 return 1;
159
160 if (GET_CODE (op) == SUBREG)
161 op = SUBREG_REG (op);
162
163 if (GET_CODE (op) != MEM)
164 return 0;
165
166 /* Until problems with management of the REG_POINTER flag are resolved,
167 we need to delay creating move insns with unscaled indexed addresses
168 until CSE is not expected. */
169 if (!TARGET_NO_SPACE_REGS
170 && !cse_not_expected
171 && GET_CODE (XEXP (op, 0)) == PLUS
172 && REG_P (XEXP (XEXP (op, 0), 0))
173 && REG_P (XEXP (XEXP (op, 0), 1)))
174 return 0;
175
176 return (!symbolic_memory_operand (op, mode)
177 && memory_address_p (mode, XEXP (op, 0)));
178 })
179
180 ;; Accept anything that can be used as a destination operand for a
181 ;; move instruction. We don't accept indexed memory operands since
182 ;; they are supported only for floating point stores.
183
184 (define_predicate "move_dest_operand"
185 (match_code "subreg,reg,mem")
186 {
187 if (register_operand (op, mode))
188 return 1;
189
190 if (GET_MODE (op) != mode)
191 return 0;
192
193 if (GET_CODE (op) == SUBREG)
194 op = SUBREG_REG (op);
195
196 if (GET_CODE (op) != MEM || symbolic_memory_operand (op, mode))
197 return 0;
198
199 op = XEXP (op, 0);
200
201 return (memory_address_p (mode, op)
202 && !IS_INDEX_ADDR_P (op)
203 && !IS_LO_SUM_DLT_ADDR_P (op));
204 })
205
206 ;; Accept anything that can be used as a source operand for a move
207 ;; instruction.
208
209 (define_predicate "move_src_operand"
210 (match_code "subreg,reg,const_int,const_double,mem")
211 {
212 if (register_operand (op, mode))
213 return 1;
214
215 if (op == CONST0_RTX (mode))
216 return 1;
217
218 if (GET_CODE (op) == CONST_INT)
219 return cint_ok_for_move (INTVAL (op));
220
221 if (GET_MODE (op) != mode)
222 return 0;
223
224 if (GET_CODE (op) == SUBREG)
225 op = SUBREG_REG (op);
226
227 if (GET_CODE (op) != MEM)
228 return 0;
229
230 /* Until problems with management of the REG_POINTER flag are resolved,
231 we need to delay creating move insns with unscaled indexed addresses
232 until CSE is not expected. */
233 if (!TARGET_NO_SPACE_REGS
234 && !cse_not_expected
235 && GET_CODE (XEXP (op, 0)) == PLUS
236 && REG_P (XEXP (XEXP (op, 0), 0))
237 && REG_P (XEXP (XEXP (op, 0), 1)))
238 return 0;
239
240 return memory_address_p (mode, XEXP (op, 0));
241 })
242
243 ;; Accept REG and any CONST_INT that can be moved in one instruction
244 ;; into a general register.
245
246 (define_predicate "reg_or_cint_move_operand"
247 (match_code "subreg,reg,const_int")
248 {
249 if (register_operand (op, mode))
250 return 1;
251
252 return (GET_CODE (op) == CONST_INT && cint_ok_for_move (INTVAL (op)));
253 })
254
255 ;; TODO: Add a comment here.
256
257 (define_predicate "pic_label_operand"
258 (match_code "label_ref,const")
259 {
260 if (!flag_pic)
261 return 0;
262
263 switch (GET_CODE (op))
264 {
265 case LABEL_REF:
266 return 1;
267 case CONST:
268 op = XEXP (op, 0);
269 return (GET_CODE (XEXP (op, 0)) == LABEL_REF
270 && GET_CODE (XEXP (op, 1)) == CONST_INT);
271 default:
272 return 0;
273 }
274 })
275
276 ;; TODO: Add a comment here.
277
278 (define_predicate "fp_reg_operand"
279 (match_code "reg")
280 {
281 return reg_renumber && FP_REG_P (op);
282 })
283
284 ;; Return truth value of whether OP can be used as an operand in a
285 ;; three operand arithmetic insn that accepts registers of mode MODE
286 ;; or 14-bit signed integers.
287
288 (define_predicate "arith_operand"
289 (match_code "subreg,reg,const_int")
290 {
291 return (register_operand (op, mode)
292 || (GET_CODE (op) == CONST_INT && INT_14_BITS (op)));
293 })
294
295 ;; Return truth value of whether OP can be used as an operand in a
296 ;; three operand arithmetic insn that accepts registers of mode MODE
297 ;; or 11-bit signed integers.
298
299 (define_predicate "arith11_operand"
300 (match_code "subreg,reg,const_int")
301 {
302 return (register_operand (op, mode)
303 || (GET_CODE (op) == CONST_INT && INT_11_BITS (op)));
304 })
305
306 ;; A constant integer suitable for use in a PRE_MODIFY memory
307 ;; reference.
308
309 (define_predicate "pre_cint_operand"
310 (match_code "const_int")
311 {
312 return (GET_CODE (op) == CONST_INT
313 && INTVAL (op) >= -0x2000 && INTVAL (op) < 0x10);
314 })
315
316 ;; A constant integer suitable for use in a POST_MODIFY memory
317 ;; reference.
318
319 (define_predicate "post_cint_operand"
320 (match_code "const_int")
321 {
322 return (GET_CODE (op) == CONST_INT
323 && INTVAL (op) < 0x2000 && INTVAL (op) >= -0x10);
324 })
325
326 ;; TODO: Add a comment here.
327
328 (define_predicate "arith_double_operand"
329 (match_code "subreg,reg,const_double")
330 {
331 return (register_operand (op, mode)
332 || (GET_CODE (op) == CONST_DOUBLE
333 && GET_MODE (op) == mode
334 && VAL_14_BITS_P (CONST_DOUBLE_LOW (op))
335 && ((CONST_DOUBLE_HIGH (op) >= 0)
336 == ((CONST_DOUBLE_LOW (op) & 0x1000) == 0))));
337 })
338
339 ;; Return truth value of whether OP is an integer which fits the range
340 ;; constraining immediate operands in three-address insns, or is an
341 ;; integer register.
342
343 (define_predicate "ireg_or_int5_operand"
344 (match_code "const_int,reg")
345 {
346 return ((GET_CODE (op) == CONST_INT && INT_5_BITS (op))
347 || (GET_CODE (op) == REG && REGNO (op) > 0 && REGNO (op) < 32));
348 })
349
350 ;; Return truth value of whether OP is an integer which fits the range
351 ;; constraining immediate operands in three-address insns.
352
353 (define_predicate "int5_operand"
354 (match_code "const_int")
355 {
356 return (GET_CODE (op) == CONST_INT && INT_5_BITS (op));
357 })
358
359 ;; Return truth value of whether OP is an integer which fits the range
360 ;; constraining immediate operands in three-address insns.
361
362 (define_predicate "uint5_operand"
363 (match_code "const_int")
364 {
365 return (GET_CODE (op) == CONST_INT && INT_U5_BITS (op));
366 })
367
368 ;; Return truth value of whether OP is an integer which fits the range
369 ;; constraining immediate operands in three-address insns.
370
371 (define_predicate "int11_operand"
372 (match_code "const_int")
373 {
374 return (GET_CODE (op) == CONST_INT && INT_11_BITS (op));
375 })
376
377 ;; Return truth value of whether OP is an integer which fits the range
378 ;; constraining immediate operands in three-address insns.
379
380 (define_predicate "uint32_operand"
381 (match_code "const_int,const_double")
382 {
383 #if HOST_BITS_PER_WIDE_INT > 32
384 /* All allowed constants will fit a CONST_INT. */
385 return (GET_CODE (op) == CONST_INT
386 && (INTVAL (op) >= 0 && INTVAL (op) < (HOST_WIDE_INT) 1 << 32));
387 #else
388 return (GET_CODE (op) == CONST_INT
389 || (GET_CODE (op) == CONST_DOUBLE
390 && CONST_DOUBLE_HIGH (op) == 0));
391 #endif
392 })
393
394 ;; Return truth value of whether OP is an integer which fits the range
395 ;; constraining immediate operands in three-address insns.
396
397 (define_predicate "arith5_operand"
398 (match_code "subreg,reg,const_int")
399 {
400 return register_operand (op, mode) || int5_operand (op, mode);
401 })
402
403 ;; True iff depi or extru can be used to compute (reg & OP).
404
405 (define_predicate "and_operand"
406 (match_code "subreg,reg,const_int")
407 {
408 return (register_operand (op, mode)
409 || (GET_CODE (op) == CONST_INT && and_mask_p (INTVAL (op))));
410 })
411
412 ;; True iff depi can be used to compute (reg | OP).
413
414 (define_predicate "ior_operand"
415 (match_code "const_int")
416 {
417 return (GET_CODE (op) == CONST_INT && ior_mask_p (INTVAL (op)));
418 })
419
420 ;; True iff OP is a CONST_INT of the forms 0...0xxxx or
421 ;; 0...01...1xxxx. Such values can be the left hand side x in (x <<
422 ;; r), using the zvdepi instruction.
423
424 (define_predicate "lhs_lshift_cint_operand"
425 (match_code "const_int")
426 {
427 unsigned HOST_WIDE_INT x;
428 if (GET_CODE (op) != CONST_INT)
429 return 0;
430 x = INTVAL (op) >> 4;
431 return (x & (x + 1)) == 0;
432 })
433
434 ;; TODO: Add a comment here.
435
436 (define_predicate "lhs_lshift_operand"
437 (match_code "subreg,reg,const_int")
438 {
439 return register_operand (op, mode) || lhs_lshift_cint_operand (op, mode);
440 })
441
442 ;; TODO: Add a comment here.
443
444 (define_predicate "arith32_operand"
445 (match_code "subreg,reg,const_int")
446 {
447 return register_operand (op, mode) || GET_CODE (op) == CONST_INT;
448 })
449
450 ;; TODO: Add a comment here.
451
452 (define_predicate "pc_or_label_operand"
453 (match_code "pc,label_ref")
454 {
455 return (GET_CODE (op) == PC || GET_CODE (op) == LABEL_REF);
456 })
457
458 ;; TODO: Add a comment here.
459 674
460 (define_predicate "plus_xor_ior_operator" 675 (define_predicate "plus_xor_ior_operator"
461 (match_code "plus,xor,ior") 676 (match_code "plus,xor,ior"))
462 {
463 return (GET_CODE (op) == PLUS || GET_CODE (op) == XOR
464 || GET_CODE (op) == IOR);
465 })
466
467 ;; Return 1 if OP is a CONST_INT with the value 2, 4, or 8. These are
468 ;; the valid constant for shadd instructions.
469
470 (define_predicate "shadd_operand"
471 (match_code "const_int")
472 {
473 return (GET_CODE (op) == CONST_INT && shadd_constant_p (INTVAL (op)));
474 })
475
476 ;; TODO: Add a comment here.
477
478 (define_predicate "div_operand"
479 (match_code "reg,const_int")
480 {
481 return (mode == SImode
482 && ((GET_CODE (op) == REG && REGNO (op) == 25)
483 || (GET_CODE (op) == CONST_INT && INTVAL (op) > 0
484 && INTVAL (op) < 16 && magic_milli[INTVAL (op)])));
485 })
486
487 ;; Return nonzero if OP is an integer register, else return zero.
488
489 (define_predicate "ireg_operand"
490 (match_code "reg")
491 {
492 return (GET_CODE (op) == REG && REGNO (op) > 0 && REGNO (op) < 32);
493 })
494
495 ;; Return 1 if this is a comparison operator. This allows the use of
496 ;; MATCH_OPERATOR to recognize all the branch insns.
497
498 (define_predicate "cmpib_comparison_operator"
499 (match_code "eq,ne,lt,le,leu,gt,gtu,ge")
500 {
501 return ((mode == VOIDmode || GET_MODE (op) == mode)
502 && (GET_CODE (op) == EQ
503 || GET_CODE (op) == NE
504 || GET_CODE (op) == GT
505 || GET_CODE (op) == GTU
506 || GET_CODE (op) == GE
507 || GET_CODE (op) == LT
508 || GET_CODE (op) == LE
509 || GET_CODE (op) == LEU));
510 })
511
512 ;; Return 1 if OP is an operator suitable for use in a movb
513 ;; instruction.
514
515 (define_predicate "movb_comparison_operator"
516 (match_code "eq,ne,lt,ge")
517 {
518 return (GET_CODE (op) == EQ || GET_CODE (op) == NE
519 || GET_CODE (op) == LT || GET_CODE (op) == GE);
520 })