1 ;; Predicate definitions for the Blackfin.
2 ;; Copyright (C) 2005-2024 Free Software Foundation, Inc.
3 ;; Contributed by Analog Devices.
5 ;; This file is part of GCC.
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 3, or (at your option)
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.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING3. If not see
19 ;; <http://www.gnu.org/licenses/>.
21 ;; Return nonzero iff OP is one of the integer constants 1 or 2.
22 (define_predicate "pos_scale_operand"
23 (and (match_code "const_int")
24 (match_test "INTVAL (op) == 1 || INTVAL (op) == 2")))
26 ;; Return nonzero iff OP is one of the integer constants 2 or 4.
27 (define_predicate "scale_by_operand"
28 (and (match_code "const_int")
29 (match_test "INTVAL (op) == 2 || INTVAL (op) == 4")))
31 ;; Return nonzero if OP is a constant that consists of two parts; lower
32 ;; bits all zero and upper bits all ones. In this case, we can perform
33 ;; an AND operation with a sequence of two shifts. Don't return nonzero
34 ;; if the constant would be cheap to load.
35 (define_predicate "highbits_operand"
36 (and (match_code "const_int")
37 (match_test "log2constp (-INTVAL (op)) && !satisfies_constraint_Ks7 (op)")))
39 ;; Return nonzero if OP is suitable as a right-hand side operand for an
41 (define_predicate "rhs_andsi3_operand"
42 (ior (match_operand 0 "register_operand")
43 (and (match_code "const_int")
44 (match_test "log2constp (~INTVAL (op)) || INTVAL (op) == 255 || INTVAL (op) == 65535"))))
46 ;; Return nonzero if OP is a register or a constant with exactly one bit
48 (define_predicate "regorlog2_operand"
49 (ior (match_operand 0 "register_operand")
50 (and (match_code "const_int")
51 (match_test "log2constp (INTVAL (op))"))))
53 ;; Return nonzero if OP is a register or an integer constant.
54 (define_predicate "reg_or_const_int_operand"
55 (ior (match_operand 0 "register_operand")
56 (match_code "const_int")))
58 (define_predicate "const01_operand"
59 (and (match_code "const_int")
60 (match_test "op == const0_rtx || op == const1_rtx")))
62 (define_predicate "const1_operand"
63 (and (match_code "const_int")
64 (match_test "op == const1_rtx")))
66 (define_predicate "const3_operand"
67 (and (match_code "const_int")
68 (match_test "INTVAL (op) == 3")))
70 (define_predicate "vec_shift_operand"
71 (ior (and (match_code "const_int")
72 (match_test "INTVAL (op) >= -16 && INTVAL (op) < 15"))
73 (match_operand 0 "register_operand")))
75 ;; Like register_operand, but make sure that hard regs have a valid mode.
76 (define_predicate "valid_reg_operand"
77 (match_operand 0 "register_operand")
79 if (GET_CODE (op) == SUBREG)
81 if (REGNO (op) < FIRST_PSEUDO_REGISTER)
82 return targetm.hard_regno_mode_ok (REGNO (op), mode);
86 ;; Return nonzero if OP is a D register.
87 (define_predicate "d_register_operand"
88 (and (match_code "reg")
89 (match_test "D_REGNO_P (REGNO (op))")))
91 (define_predicate "p_register_operand"
92 (and (match_code "reg")
93 (match_test "P_REGNO_P (REGNO (op))")))
95 (define_predicate "dp_register_operand"
96 (and (match_code "reg")
97 (match_test "D_REGNO_P (REGNO (op)) || P_REGNO_P (REGNO (op))")))
99 ;; Return nonzero if OP is a LC register.
100 (define_predicate "lc_register_operand"
101 (and (match_code "reg")
102 (match_test "REGNO (op) == REG_LC0 || REGNO (op) == REG_LC1")))
104 ;; Return nonzero if OP is a LT register.
105 (define_predicate "lt_register_operand"
106 (and (match_code "reg")
107 (match_test "REGNO (op) == REG_LT0 || REGNO (op) == REG_LT1")))
109 ;; Return nonzero if OP is a LB register.
110 (define_predicate "lb_register_operand"
111 (and (match_code "reg")
112 (match_test "REGNO (op) == REG_LB0 || REGNO (op) == REG_LB1")))
114 ;; Return nonzero if OP is a register or a 7-bit signed constant.
115 (define_predicate "reg_or_7bit_operand"
116 (ior (match_operand 0 "register_operand")
117 (and (match_code "const_int")
118 (match_test "satisfies_constraint_Ks7 (op)"))))
120 ;; Return nonzero if OP is a register other than DREG and PREG.
121 (define_predicate "nondp_register_operand"
122 (match_operand 0 "register_operand")
125 if (GET_CODE (op) == SUBREG)
126 op = SUBREG_REG (op);
129 return (regno >= FIRST_PSEUDO_REGISTER || !DP_REGNO_P (regno));
132 ;; Return nonzero if OP is a register other than DREG and PREG, or MEM.
133 (define_predicate "nondp_reg_or_memory_operand"
134 (ior (match_operand 0 "nondp_register_operand")
135 (match_operand 0 "memory_operand")))
137 ;; Return nonzero if OP is a register or, when negated, a 7-bit signed
139 (define_predicate "reg_or_neg7bit_operand"
140 (ior (match_operand 0 "register_operand")
141 (and (match_code "const_int")
142 (match_test "satisfies_constraint_KN7 (op)"))))
144 ;; Used for secondary reloads, this function returns 1 if OP is of the
145 ;; form (plus (fp) (const_int)).
146 (define_predicate "fp_plus_const_operand"
154 && (REGNO (op1) == FRAME_POINTER_REGNUM
155 || REGNO (op1) == STACK_POINTER_REGNUM)
156 && GET_CODE (op2) == CONST_INT);
159 ;; Returns 1 if OP is a symbolic operand, i.e. a symbol_ref or a label_ref,
160 ;; possibly with an offset.
161 (define_predicate "symbolic_operand"
162 (ior (match_code "symbol_ref,label_ref")
163 (and (match_code "const")
164 (match_test "GET_CODE (XEXP (op,0)) == PLUS
165 && (GET_CODE (XEXP (XEXP (op, 0), 0)) == SYMBOL_REF
166 || GET_CODE (XEXP (XEXP (op, 0), 0)) == LABEL_REF)
167 && GET_CODE (XEXP (XEXP (op, 0), 1)) == CONST_INT"))))
169 ;; Returns 1 if OP is a plain constant or matched by symbolic_operand.
170 (define_predicate "symbolic_or_const_operand"
171 (ior (match_code "const_int,const_double")
172 (match_operand 0 "symbolic_operand")))
174 ;; Returns 1 if OP is a SYMBOL_REF.
175 (define_predicate "symbol_ref_operand"
176 (match_code "symbol_ref"))
178 ;; True for any non-virtual and non-eliminable register. Used in places where
179 ;; instantiation of such a register may cause the pattern to not be recognized.
180 (define_predicate "register_no_elim_operand"
181 (match_operand 0 "register_operand")
183 if (GET_CODE (op) == SUBREG)
184 op = SUBREG_REG (op);
185 return !(op == arg_pointer_rtx
186 || op == frame_pointer_rtx
187 || VIRTUAL_REGISTER_P (op));
190 ;; Test for an operator valid in a BImode conditional branch
191 (define_predicate "bfin_bimode_comparison_operator"
192 (match_code "eq,ne"))
194 ;; Test for an operator whose result is accessible with movbisi.
195 (define_predicate "bfin_direct_comparison_operator"
196 (match_code "eq,lt,le,leu,ltu"))
198 ;; The following three are used to compute the addrtype attribute. They return
199 ;; true if passed a memory address usable for a 16-bit load or store using a
200 ;; P or I register, respectively. If neither matches, we know we have a
201 ;; 32-bit instruction.
202 ;; We subdivide the P case into normal P registers, and SP/FP. We can assume
203 ;; that speculative loads through SP and FP are no problem, so this has
204 ;; an effect on the anomaly workaround code.
206 (define_predicate "mem_p_address_operand"
209 if (effective_address_32bit_p (op, mode))
212 if (GET_CODE (op) == PLUS || GET_RTX_CLASS (GET_CODE (op)) == RTX_AUTOINC)
214 gcc_assert (REG_P (op));
215 return PREG_P (op) && op != stack_pointer_rtx && op != frame_pointer_rtx;
218 (define_predicate "mem_spfp_address_operand"
221 if (effective_address_32bit_p (op, mode))
224 if (GET_CODE (op) == PLUS || GET_RTX_CLASS (GET_CODE (op)) == RTX_AUTOINC)
226 gcc_assert (REG_P (op));
227 return op == stack_pointer_rtx || op == frame_pointer_rtx;
230 (define_predicate "mem_i_address_operand"
233 if (effective_address_32bit_p (op, mode))
236 if (GET_CODE (op) == PLUS || GET_RTX_CLASS (GET_CODE (op)) == RTX_AUTOINC)
238 gcc_assert (REG_P (op));
242 (define_predicate "push_multiple_operation"
243 (and (match_code "parallel")
244 (match_test "analyze_push_multiple_operation (op)")))
246 (define_predicate "pop_multiple_operation"
247 (and (match_code "parallel")
248 (match_test "analyze_pop_multiple_operation (op)")))