OSDN Git Service

* config/bfin/bfin.md (subsi3): Lose expander, change previously
[pf3gnuchains/gcc-fork.git] / gcc / config / bfin / predicates.md
1 ;; Predicate definitions for the Blackfin.
2 ;; Copyright (C) 2005, 2006  Free Software Foundation, Inc.
3 ;; Contributed by Analog Devices.
4 ;;
5 ;; This file is part of GCC.
6 ;;
7 ;; GCC is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
10 ;; any later version.
11 ;;
12 ;; GCC is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ;; GNU General Public License for more details.
16 ;;
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING.  If not, write to
19 ;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20 ;; Boston, MA 02110-1301, USA.
21
22 ;; Return nonzero iff OP is one of the integer constants 1 or 2.
23 (define_predicate "pos_scale_operand"
24   (and (match_code "const_int")
25        (match_test "INTVAL (op) == 1 || INTVAL (op) == 2")))
26
27 ;; Return nonzero iff OP is one of the integer constants 2 or 4.
28 (define_predicate "scale_by_operand"
29   (and (match_code "const_int")
30        (match_test "INTVAL (op) == 2 || INTVAL (op) == 4")))
31
32 ;; Return nonzero if OP is a constant that consists of two parts; lower
33 ;; bits all zero and upper bits all ones.  In this case, we can perform
34 ;; an AND operation with a sequence of two shifts.  Don't return nonzero
35 ;; if the constant would be cheap to load.
36 (define_predicate "highbits_operand"
37   (and (match_code "const_int")
38        (match_test "log2constp (-INTVAL (op)) && !CONST_7BIT_IMM_P (INTVAL (op))")))
39
40 ;; Return nonzero if OP is suitable as a right-hand side operand for an
41 ;; andsi3 operation.
42 (define_predicate "rhs_andsi3_operand"
43   (ior (match_operand 0 "register_operand")
44        (and (match_code "const_int")
45             (match_test "log2constp (~INTVAL (op)) || INTVAL (op) == 255 || INTVAL (op) == 65535"))))
46
47 ;; Return nonzero if OP is a register or a constant with exactly one bit
48 ;; set.
49 (define_predicate "regorlog2_operand"
50   (ior (match_operand 0 "register_operand")
51        (and (match_code "const_int")
52             (match_test "log2constp (INTVAL (op))"))))
53
54 ;; Return nonzero if OP is a register or an integer constant.
55 (define_predicate "reg_or_const_int_operand"
56   (ior (match_operand 0 "register_operand")
57        (match_code "const_int")))
58
59 (define_predicate "const01_operand"
60   (and (match_code "const_int")
61        (match_test "op == const0_rtx || op == const1_rtx")))
62
63 (define_predicate "vec_shift_operand"
64   (ior (and (match_code "const_int")
65             (match_test "INTVAL (op) >= -16 && INTVAL (op) < 15"))
66        (match_operand 0 "register_operand")))
67
68 ;; Like register_operand, but make sure that hard regs have a valid mode.
69 (define_predicate "valid_reg_operand"
70   (match_operand 0 "register_operand")
71 {
72   if (GET_CODE (op) == SUBREG)
73     op = SUBREG_REG (op);
74   if (REGNO (op) < FIRST_PSEUDO_REGISTER)
75     return HARD_REGNO_MODE_OK (REGNO (op), mode);
76   return 1;
77 })
78
79 ;; Return nonzero if OP is a LC register.
80 (define_predicate "lc_register_operand"
81   (and (match_code "reg")
82        (match_test "REGNO (op) == REG_LC0 || REGNO (op) == REG_LC1")))
83
84 ;; Return nonzero if OP is a LT register.
85 (define_predicate "lt_register_operand"
86   (and (match_code "reg")
87        (match_test "REGNO (op) == REG_LT0 || REGNO (op) == REG_LT1")))
88
89 ;; Return nonzero if OP is a LB register.
90 (define_predicate "lb_register_operand"
91   (and (match_code "reg")
92        (match_test "REGNO (op) == REG_LB0 || REGNO (op) == REG_LB1")))
93
94 ;; Return nonzero if OP is a register or a 7 bit signed constant.
95 (define_predicate "reg_or_7bit_operand"
96   (ior (match_operand 0 "register_operand")
97        (and (match_code "const_int")
98             (match_test "CONST_7BIT_IMM_P (INTVAL (op))"))))
99
100 ;; Return nonzero if OP is a register other than DREG and PREG.
101 (define_predicate "nondp_register_operand"
102   (match_operand 0 "register_operand")
103 {
104   unsigned int regno;
105   if (GET_CODE (op) == SUBREG)
106     op = SUBREG_REG (op);
107
108   regno = REGNO (op);
109   return (regno >= FIRST_PSEUDO_REGISTER || !DP_REGNO_P (regno));
110 })
111
112 ;; Return nonzero if OP is a register other than DREG and PREG, or MEM.
113 (define_predicate "nondp_reg_or_memory_operand"
114   (ior (match_operand 0 "nondp_register_operand")
115        (match_operand 0 "memory_operand")))
116
117 ;; Return nonzero if OP is a register or, when negated, a 7 bit signed
118 ;; constant.
119 (define_predicate "reg_or_neg7bit_operand"
120   (ior (match_operand 0 "register_operand")
121        (and (match_code "const_int")
122             (match_test "CONST_7BIT_IMM_P (-INTVAL (op))"))))
123
124 ;; Used for secondary reloads, this function returns 1 if OP is of the
125 ;; form (plus (fp) (const_int)).
126 (define_predicate "fp_plus_const_operand"
127   (match_code "plus")
128 {
129   rtx op1, op2;
130
131   op1 = XEXP (op, 0);
132   op2 = XEXP (op, 1);
133   return (REG_P (op1)
134           && (REGNO (op1) == FRAME_POINTER_REGNUM
135               || REGNO (op1) == STACK_POINTER_REGNUM)
136           && GET_CODE (op2) == CONST_INT);
137 })
138
139 ;; Returns 1 if OP is a symbolic operand, i.e. a symbol_ref or a label_ref,
140 ;; possibly with an offset.
141 (define_predicate "symbolic_operand"
142   (ior (match_code "symbol_ref,label_ref")
143        (and (match_code "const")
144             (match_test "GET_CODE (XEXP (op,0)) == PLUS
145                          && (GET_CODE (XEXP (XEXP (op, 0), 0)) == SYMBOL_REF
146                              || GET_CODE (XEXP (XEXP (op, 0), 0)) == LABEL_REF)
147                          && GET_CODE (XEXP (XEXP (op, 0), 1)) == CONST_INT"))))
148
149 ;; Returns 1 if OP is a plain constant or matched by symbolic_operand.
150 (define_predicate "symbolic_or_const_operand"
151   (ior (match_code "const_int,const_double")
152        (match_operand 0 "symbolic_operand")))
153
154 ;; Returns 1 if OP is a SYMBOL_REF.
155 (define_predicate "symbol_ref_operand"
156   (match_code "symbol_ref"))
157
158 ;; True for any non-virtual or eliminable register.  Used in places where
159 ;; instantiation of such a register may cause the pattern to not be recognized.
160 (define_predicate "register_no_elim_operand"
161   (match_operand 0 "register_operand")
162 {
163   if (GET_CODE (op) == SUBREG)
164     op = SUBREG_REG (op);
165   return !(op == arg_pointer_rtx
166            || op == frame_pointer_rtx
167            || (REGNO (op) >= FIRST_PSEUDO_REGISTER
168                && REGNO (op) <= LAST_VIRTUAL_REGISTER));
169 })
170
171 ;; Test for an operator valid in a conditional branch
172 (define_predicate "bfin_cbranch_operator"
173   (match_code "eq,ne"))