comparison gcc/config/arm/predicates.md @ 67:f6334be47118

update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
date Tue, 22 Mar 2011 17:18:12 +0900
parents b7f97abdc517
children 04ced10e8804
comparison
equal deleted inserted replaced
65:65488c3d617d 67:f6334be47118
1 ;; Predicate definitions for ARM and Thumb 1 ;; Predicate definitions for ARM and Thumb
2 ;; Copyright (C) 2004, 2007, 2008 Free Software Foundation, Inc. 2 ;; Copyright (C) 2004, 2007, 2008, 2010 Free Software Foundation, Inc.
3 ;; Contributed by ARM Ltd. 3 ;; Contributed by ARM Ltd.
4 4
5 ;; This file is part of GCC. 5 ;; This file is part of GCC.
6 6
7 ;; GCC is free software; you can redistribute it and/or modify it 7 ;; GCC is free software; you can redistribute it and/or modify it
71 return (GET_CODE (op) == REG 71 return (GET_CODE (op) == REG
72 && (REGNO (op) >= FIRST_PSEUDO_REGISTER 72 && (REGNO (op) >= FIRST_PSEUDO_REGISTER
73 || REGNO_REG_CLASS (REGNO (op)) == FPA_REGS)); 73 || REGNO_REG_CLASS (REGNO (op)) == FPA_REGS));
74 }) 74 })
75 75
76 (define_predicate "vfp_register_operand"
77 (match_code "reg,subreg")
78 {
79 if (GET_CODE (op) == SUBREG)
80 op = SUBREG_REG (op);
81
82 /* We don't consider registers whose class is NO_REGS
83 to be a register operand. */
84 return (GET_CODE (op) == REG
85 && (REGNO (op) >= FIRST_PSEUDO_REGISTER
86 || REGNO_REG_CLASS (REGNO (op)) == VFP_D0_D7_REGS
87 || REGNO_REG_CLASS (REGNO (op)) == VFP_LO_REGS
88 || (TARGET_VFPD32
89 && REGNO_REG_CLASS (REGNO (op)) == VFP_REGS)));
90 })
91
76 (define_special_predicate "subreg_lowpart_operator" 92 (define_special_predicate "subreg_lowpart_operator"
77 (and (match_code "subreg") 93 (and (match_code "subreg")
78 (match_test "subreg_lowpart_p (op)"))) 94 (match_test "subreg_lowpart_p (op)")))
79 95
80 ;; Reg, subreg(reg) or const_int. 96 ;; Reg, subreg(reg) or const_int.
84 100
85 (define_predicate "arm_immediate_operand" 101 (define_predicate "arm_immediate_operand"
86 (and (match_code "const_int") 102 (and (match_code "const_int")
87 (match_test "const_ok_for_arm (INTVAL (op))"))) 103 (match_test "const_ok_for_arm (INTVAL (op))")))
88 104
105 ;; A constant value which fits into two instructions, each taking
106 ;; an arithmetic constant operand for one of the words.
107 (define_predicate "arm_immediate_di_operand"
108 (and (match_code "const_int,const_double")
109 (match_test "arm_const_double_by_immediates (op)")))
110
89 (define_predicate "arm_neg_immediate_operand" 111 (define_predicate "arm_neg_immediate_operand"
90 (and (match_code "const_int") 112 (and (match_code "const_int")
91 (match_test "const_ok_for_arm (-INTVAL (op))"))) 113 (match_test "const_ok_for_arm (-INTVAL (op))")))
92 114
93 (define_predicate "arm_not_immediate_operand" 115 (define_predicate "arm_not_immediate_operand"
105 127
106 (define_predicate "arm_rhsm_operand" 128 (define_predicate "arm_rhsm_operand"
107 (ior (match_operand 0 "arm_rhs_operand") 129 (ior (match_operand 0 "arm_rhs_operand")
108 (match_operand 0 "memory_operand"))) 130 (match_operand 0 "memory_operand")))
109 131
132 (define_predicate "shift_amount_operand"
133 (ior (and (match_test "TARGET_ARM")
134 (match_operand 0 "s_register_operand"))
135 (match_operand 0 "const_int_operand")))
136
110 (define_predicate "arm_add_operand" 137 (define_predicate "arm_add_operand"
111 (ior (match_operand 0 "arm_rhs_operand") 138 (ior (match_operand 0 "arm_rhs_operand")
112 (match_operand 0 "arm_neg_immediate_operand"))) 139 (match_operand 0 "arm_neg_immediate_operand")))
113 140
114 (define_predicate "arm_addimm_operand" 141 (define_predicate "arm_addimm_operand"
116 (match_operand 0 "arm_neg_immediate_operand"))) 143 (match_operand 0 "arm_neg_immediate_operand")))
117 144
118 (define_predicate "arm_not_operand" 145 (define_predicate "arm_not_operand"
119 (ior (match_operand 0 "arm_rhs_operand") 146 (ior (match_operand 0 "arm_rhs_operand")
120 (match_operand 0 "arm_not_immediate_operand"))) 147 (match_operand 0 "arm_not_immediate_operand")))
148
149 (define_predicate "arm_di_operand"
150 (ior (match_operand 0 "s_register_operand")
151 (match_operand 0 "arm_immediate_di_operand")))
121 152
122 ;; True if the operand is a memory reference which contains an 153 ;; True if the operand is a memory reference which contains an
123 ;; offsettable address. 154 ;; offsettable address.
124 (define_predicate "offsettable_memory_operand" 155 (define_predicate "offsettable_memory_operand"
125 (and (match_code "mem") 156 (and (match_code "mem")
177 (match_test "mode == GET_MODE (op)"))) 208 (match_test "mode == GET_MODE (op)")))
178 209
179 ;; True for logical binary operators. 210 ;; True for logical binary operators.
180 (define_special_predicate "logical_binary_operator" 211 (define_special_predicate "logical_binary_operator"
181 (and (match_code "ior,xor,and") 212 (and (match_code "ior,xor,and")
213 (match_test "mode == GET_MODE (op)")))
214
215 ;; True for commutative operators
216 (define_special_predicate "commutative_binary_operator"
217 (and (match_code "ior,xor,and,plus")
182 (match_test "mode == GET_MODE (op)"))) 218 (match_test "mode == GET_MODE (op)")))
183 219
184 ;; True for shift operators. 220 ;; True for shift operators.
185 (define_special_predicate "shift_operator" 221 (define_special_predicate "shift_operator"
186 (and (ior (ior (and (match_code "mult") 222 (and (ior (ior (and (match_code "mult")
189 (match_test "GET_CODE (XEXP (op, 1)) == CONST_INT 225 (match_test "GET_CODE (XEXP (op, 1)) == CONST_INT
190 && ((unsigned HOST_WIDE_INT) INTVAL (XEXP (op, 1))) < 32"))) 226 && ((unsigned HOST_WIDE_INT) INTVAL (XEXP (op, 1))) < 32")))
191 (match_code "ashift,ashiftrt,lshiftrt,rotatert")) 227 (match_code "ashift,ashiftrt,lshiftrt,rotatert"))
192 (match_test "mode == GET_MODE (op)"))) 228 (match_test "mode == GET_MODE (op)")))
193 229
230 ;; True for MULT, to identify which variant of shift_operator is in use.
231 (define_special_predicate "mult_operator"
232 (match_code "mult"))
233
194 ;; True for operators that have 16-bit thumb variants. */ 234 ;; True for operators that have 16-bit thumb variants. */
195 (define_special_predicate "thumb_16bit_operator" 235 (define_special_predicate "thumb_16bit_operator"
196 (match_code "plus,minus,and,ior,xor")) 236 (match_code "plus,minus,and,ior,xor"))
197 237
198 ;; True for EQ & NE 238 ;; True for EQ & NE
207 && (TARGET_FPA || TARGET_VFP)") 247 && (TARGET_FPA || TARGET_VFP)")
208 (match_code "unordered,ordered,unlt,unle,unge,ungt")))) 248 (match_code "unordered,ordered,unlt,unle,unge,ungt"))))
209 249
210 (define_special_predicate "lt_ge_comparison_operator" 250 (define_special_predicate "lt_ge_comparison_operator"
211 (match_code "lt,ge")) 251 (match_code "lt,ge"))
252
253 (define_special_predicate "noov_comparison_operator"
254 (match_code "lt,ge,eq,ne"))
212 255
213 (define_special_predicate "minmax_operator" 256 (define_special_predicate "minmax_operator"
214 (and (match_code "smin,smax,umin,umax") 257 (and (match_code "smin,smax,umin,umax")
215 (match_test "mode == GET_MODE (op)"))) 258 (match_test "mode == GET_MODE (op)")))
216 259
254 (match_operand 0 "s_register_operand"))) 297 (match_operand 0 "s_register_operand")))
255 298
256 (define_predicate "power_of_two_operand" 299 (define_predicate "power_of_two_operand"
257 (match_code "const_int") 300 (match_code "const_int")
258 { 301 {
259 HOST_WIDE_INT value = INTVAL (op); 302 unsigned HOST_WIDE_INT value = INTVAL (op) & 0xffffffff;
260 303
261 return value != 0 && (value & (value - 1)) == 0; 304 return value != 0 && (value & (value - 1)) == 0;
262 }) 305 })
263 306
264 (define_predicate "nonimmediate_di_operand" 307 (define_predicate "nonimmediate_di_operand"
303 346
304 (define_special_predicate "load_multiple_operation" 347 (define_special_predicate "load_multiple_operation"
305 (match_code "parallel") 348 (match_code "parallel")
306 { 349 {
307 HOST_WIDE_INT count = XVECLEN (op, 0); 350 HOST_WIDE_INT count = XVECLEN (op, 0);
308 int dest_regno; 351 unsigned dest_regno;
309 rtx src_addr; 352 rtx src_addr;
310 HOST_WIDE_INT i = 1, base = 0; 353 HOST_WIDE_INT i = 1, base = 0;
354 HOST_WIDE_INT offset = 0;
311 rtx elt; 355 rtx elt;
356 bool addr_reg_loaded = false;
357 bool update = false;
312 358
313 if (count <= 1 359 if (count <= 1
314 || GET_CODE (XVECEXP (op, 0, 0)) != SET) 360 || GET_CODE (XVECEXP (op, 0, 0)) != SET
361 || !REG_P (SET_DEST (XVECEXP (op, 0, 0))))
315 return false; 362 return false;
316 363
317 /* Check to see if this might be a write-back. */ 364 /* Check to see if this might be a write-back. */
318 if (GET_CODE (SET_SRC (elt = XVECEXP (op, 0, 0))) == PLUS) 365 if (GET_CODE (SET_SRC (elt = XVECEXP (op, 0, 0))) == PLUS)
319 { 366 {
320 i++; 367 i++;
321 base = 1; 368 base = 1;
369 update = true;
322 370
323 /* Now check it more carefully. */ 371 /* Now check it more carefully. */
324 if (GET_CODE (SET_DEST (elt)) != REG 372 if (GET_CODE (SET_DEST (elt)) != REG
325 || GET_CODE (XEXP (SET_SRC (elt), 0)) != REG 373 || GET_CODE (XEXP (SET_SRC (elt), 0)) != REG
326 || GET_CODE (XEXP (SET_SRC (elt), 1)) != CONST_INT 374 || GET_CODE (XEXP (SET_SRC (elt), 1)) != CONST_INT
335 || GET_CODE (SET_SRC (XVECEXP (op, 0, i - 1))) != MEM) 383 || GET_CODE (SET_SRC (XVECEXP (op, 0, i - 1))) != MEM)
336 return false; 384 return false;
337 385
338 dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, i - 1))); 386 dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, i - 1)));
339 src_addr = XEXP (SET_SRC (XVECEXP (op, 0, i - 1)), 0); 387 src_addr = XEXP (SET_SRC (XVECEXP (op, 0, i - 1)), 0);
388 if (GET_CODE (src_addr) == PLUS)
389 {
390 if (GET_CODE (XEXP (src_addr, 1)) != CONST_INT)
391 return false;
392 offset = INTVAL (XEXP (src_addr, 1));
393 src_addr = XEXP (src_addr, 0);
394 }
395 if (!REG_P (src_addr))
396 return false;
340 397
341 for (; i < count; i++) 398 for (; i < count; i++)
342 { 399 {
343 elt = XVECEXP (op, 0, i); 400 elt = XVECEXP (op, 0, i);
344 401
345 if (GET_CODE (elt) != SET 402 if (GET_CODE (elt) != SET
346 || GET_CODE (SET_DEST (elt)) != REG 403 || GET_CODE (SET_DEST (elt)) != REG
347 || GET_MODE (SET_DEST (elt)) != SImode 404 || GET_MODE (SET_DEST (elt)) != SImode
348 || REGNO (SET_DEST (elt)) != (unsigned int)(dest_regno + i - base) 405 || REGNO (SET_DEST (elt)) <= dest_regno
349 || GET_CODE (SET_SRC (elt)) != MEM 406 || GET_CODE (SET_SRC (elt)) != MEM
350 || GET_MODE (SET_SRC (elt)) != SImode 407 || GET_MODE (SET_SRC (elt)) != SImode
351 || GET_CODE (XEXP (SET_SRC (elt), 0)) != PLUS 408 || ((GET_CODE (XEXP (SET_SRC (elt), 0)) != PLUS
352 || !rtx_equal_p (XEXP (XEXP (SET_SRC (elt), 0), 0), src_addr) 409 || !rtx_equal_p (XEXP (XEXP (SET_SRC (elt), 0), 0), src_addr)
353 || GET_CODE (XEXP (XEXP (SET_SRC (elt), 0), 1)) != CONST_INT 410 || GET_CODE (XEXP (XEXP (SET_SRC (elt), 0), 1)) != CONST_INT
354 || INTVAL (XEXP (XEXP (SET_SRC (elt), 0), 1)) != (i - base) * 4) 411 || INTVAL (XEXP (XEXP (SET_SRC (elt), 0), 1)) != offset + (i - base) * 4)
412 && (!REG_P (XEXP (SET_SRC (elt), 0))
413 || offset + (i - base) * 4 != 0)))
355 return false; 414 return false;
415 dest_regno = REGNO (SET_DEST (elt));
416 if (dest_regno == REGNO (src_addr))
417 addr_reg_loaded = true;
356 } 418 }
357 419 /* For Thumb, we only have updating instructions. If the pattern does
420 not describe an update, it must be because the address register is
421 in the list of loaded registers - on the hardware, this has the effect
422 of overriding the update. */
423 if (update && addr_reg_loaded)
424 return false;
425 if (TARGET_THUMB1)
426 return update || addr_reg_loaded;
358 return true; 427 return true;
359 }) 428 })
360 429
361 (define_special_predicate "store_multiple_operation" 430 (define_special_predicate "store_multiple_operation"
362 (match_code "parallel") 431 (match_code "parallel")
363 { 432 {
364 HOST_WIDE_INT count = XVECLEN (op, 0); 433 HOST_WIDE_INT count = XVECLEN (op, 0);
365 int src_regno; 434 unsigned src_regno;
366 rtx dest_addr; 435 rtx dest_addr;
367 HOST_WIDE_INT i = 1, base = 0; 436 HOST_WIDE_INT i = 1, base = 0, offset = 0;
368 rtx elt; 437 rtx elt;
369 438
370 if (count <= 1 439 if (count <= 1
371 || GET_CODE (XVECEXP (op, 0, 0)) != SET) 440 || GET_CODE (XVECEXP (op, 0, 0)) != SET)
372 return false; 441 return false;
393 return false; 462 return false;
394 463
395 src_regno = REGNO (SET_SRC (XVECEXP (op, 0, i - 1))); 464 src_regno = REGNO (SET_SRC (XVECEXP (op, 0, i - 1)));
396 dest_addr = XEXP (SET_DEST (XVECEXP (op, 0, i - 1)), 0); 465 dest_addr = XEXP (SET_DEST (XVECEXP (op, 0, i - 1)), 0);
397 466
467 if (GET_CODE (dest_addr) == PLUS)
468 {
469 if (GET_CODE (XEXP (dest_addr, 1)) != CONST_INT)
470 return false;
471 offset = INTVAL (XEXP (dest_addr, 1));
472 dest_addr = XEXP (dest_addr, 0);
473 }
474 if (!REG_P (dest_addr))
475 return false;
476
398 for (; i < count; i++) 477 for (; i < count; i++)
399 { 478 {
400 elt = XVECEXP (op, 0, i); 479 elt = XVECEXP (op, 0, i);
401 480
402 if (GET_CODE (elt) != SET 481 if (GET_CODE (elt) != SET
403 || GET_CODE (SET_SRC (elt)) != REG 482 || GET_CODE (SET_SRC (elt)) != REG
404 || GET_MODE (SET_SRC (elt)) != SImode 483 || GET_MODE (SET_SRC (elt)) != SImode
405 || REGNO (SET_SRC (elt)) != (unsigned int)(src_regno + i - base) 484 || REGNO (SET_SRC (elt)) <= src_regno
406 || GET_CODE (SET_DEST (elt)) != MEM 485 || GET_CODE (SET_DEST (elt)) != MEM
407 || GET_MODE (SET_DEST (elt)) != SImode 486 || GET_MODE (SET_DEST (elt)) != SImode
408 || GET_CODE (XEXP (SET_DEST (elt), 0)) != PLUS 487 || ((GET_CODE (XEXP (SET_DEST (elt), 0)) != PLUS
409 || !rtx_equal_p (XEXP (XEXP (SET_DEST (elt), 0), 0), dest_addr) 488 || !rtx_equal_p (XEXP (XEXP (SET_DEST (elt), 0), 0), dest_addr)
410 || GET_CODE (XEXP (XEXP (SET_DEST (elt), 0), 1)) != CONST_INT 489 || GET_CODE (XEXP (XEXP (SET_DEST (elt), 0), 1)) != CONST_INT
411 || INTVAL (XEXP (XEXP (SET_DEST (elt), 0), 1)) != (i - base) * 4) 490 || INTVAL (XEXP (XEXP (SET_DEST (elt), 0), 1)) != offset + (i - base) * 4)
491 && (!REG_P (XEXP (SET_DEST (elt), 0))
492 || offset + (i - base) * 4 != 0)))
412 return false; 493 return false;
494 src_regno = REGNO (SET_SRC (elt));
413 } 495 }
414 496
415 return true; 497 return true;
416 }) 498 })
417 499
504 }) 586 })
505 587
506 (define_predicate "imm_for_neon_logic_operand" 588 (define_predicate "imm_for_neon_logic_operand"
507 (match_code "const_vector") 589 (match_code "const_vector")
508 { 590 {
509 return neon_immediate_valid_for_logic (op, mode, 0, NULL, NULL); 591 return (TARGET_NEON
592 && neon_immediate_valid_for_logic (op, mode, 0, NULL, NULL));
510 }) 593 })
511 594
512 (define_predicate "imm_for_neon_inv_logic_operand" 595 (define_predicate "imm_for_neon_inv_logic_operand"
513 (match_code "const_vector") 596 (match_code "const_vector")
514 { 597 {
515 return neon_immediate_valid_for_logic (op, mode, 1, NULL, NULL); 598 return (TARGET_NEON
599 && neon_immediate_valid_for_logic (op, mode, 1, NULL, NULL));
516 }) 600 })
517 601
518 (define_predicate "neon_logic_op2" 602 (define_predicate "neon_logic_op2"
519 (ior (match_operand 0 "imm_for_neon_logic_operand") 603 (ior (match_operand 0 "imm_for_neon_logic_operand")
520 (match_operand 0 "s_register_operand"))) 604 (match_operand 0 "s_register_operand")))
525 609
526 ;; TODO: We could check lane numbers more precisely based on the mode. 610 ;; TODO: We could check lane numbers more precisely based on the mode.
527 (define_predicate "neon_lane_number" 611 (define_predicate "neon_lane_number"
528 (and (match_code "const_int") 612 (and (match_code "const_int")
529 (match_test "INTVAL (op) >= 0 && INTVAL (op) <= 7"))) 613 (match_test "INTVAL (op) >= 0 && INTVAL (op) <= 7")))
530 614 ;; Predicates for named expanders that overlap multiple ISAs.
615
616 (define_predicate "cmpdi_operand"
617 (if_then_else (match_test "TARGET_HARD_FLOAT && TARGET_MAVERICK")
618 (and (match_test "TARGET_ARM")
619 (match_operand 0 "cirrus_fp_register"))
620 (and (match_test "TARGET_32BIT")
621 (match_operand 0 "arm_di_operand"))))
622
623 ;; True if the operand is memory reference suitable for a ldrex/strex.
624 (define_predicate "arm_sync_memory_operand"
625 (and (match_operand 0 "memory_operand")
626 (match_code "reg" "0")))
627
628 ;; Predicates for parallel expanders based on mode.
629 (define_special_predicate "vect_par_constant_high"
630 (match_code "parallel")
631 {
632 HOST_WIDE_INT count = XVECLEN (op, 0);
633 int i;
634 int base = GET_MODE_NUNITS (mode);
635
636 if ((count < 1)
637 || (count != base/2))
638 return false;
639
640 if (!VECTOR_MODE_P (mode))
641 return false;
642
643 for (i = 0; i < count; i++)
644 {
645 rtx elt = XVECEXP (op, 0, i);
646 int val;
647
648 if (GET_CODE (elt) != CONST_INT)
649 return false;
650
651 val = INTVAL (elt);
652 if (val != (base/2) + i)
653 return false;
654 }
655 return true;
656 })
657
658 (define_special_predicate "vect_par_constant_low"
659 (match_code "parallel")
660 {
661 HOST_WIDE_INT count = XVECLEN (op, 0);
662 int i;
663 int base = GET_MODE_NUNITS (mode);
664
665 if ((count < 1)
666 || (count != base/2))
667 return false;
668
669 if (!VECTOR_MODE_P (mode))
670 return false;
671
672 for (i = 0; i < count; i++)
673 {
674 rtx elt = XVECEXP (op, 0, i);
675 int val;
676
677 if (GET_CODE (elt) != CONST_INT)
678 return false;
679
680 val = INTVAL (elt);
681 if (val != i)
682 return false;
683 }
684 return true;
685 })