111
|
1 ;; Predicate definitions for Tilera TILE-Gx.
|
|
2 ;; Copyright (C) 2011-2017 Free Software Foundation, Inc.
|
|
3 ;; Contributed by Walter Lee (walt@tilera.com)
|
|
4 ;;
|
|
5 ;; This file is part of GCC.
|
|
6 ;;
|
|
7 ;; GCC is free software; you can redistribute it and/or modify it
|
|
8 ;; under the terms of the GNU General Public License as published
|
|
9 ;; by the Free Software Foundation; either version 3, or (at your
|
|
10 ;; option) any later version.
|
|
11 ;;
|
|
12 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
14 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
15 ;; 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 COPYING3. If not see
|
|
19 ;; <http://www.gnu.org/licenses/>.
|
|
20
|
|
21 ;; Return true if OP is the zero constant for MODE.
|
|
22 (define_predicate "const_zero_operand"
|
|
23 (and (match_code "const_int,const_double,const_vector")
|
|
24 (match_test "op == CONST0_RTX (mode)")))
|
|
25
|
|
26 ;; Returns true if OP is either the constant zero or a register.
|
|
27 (define_predicate "reg_or_0_operand"
|
|
28 (and (ior (match_operand 0 "register_operand")
|
|
29 (match_operand 0 "const_zero_operand"))
|
|
30 (match_test "GET_MODE_SIZE (mode) <= UNITS_PER_WORD")))
|
|
31
|
|
32 ; Return 1 if OP is a valid Pmode pointer.
|
|
33 (define_predicate "pointer_operand"
|
|
34 (and (match_operand 0 "address_operand")
|
|
35 (ior (match_operand 0 "pmode_register_operand")
|
|
36 (match_operand 0 "const_zero_operand"))))
|
|
37
|
|
38 ; Return 1 if OP is a network register identifier.
|
|
39 (define_predicate "netreg_operand"
|
|
40 (and (match_code "const_int")
|
|
41 (match_test "IN_RANGE (INTVAL (op), 0, 5)")))
|
|
42
|
|
43 ; Return 1 if OP is an unsigned 6-bit constant.
|
|
44 (define_predicate "u6bit_cint_operand"
|
|
45 (and (match_code "const_int")
|
|
46 (match_test "INTVAL (op) == (INTVAL (op) & 0x3F)")))
|
|
47
|
|
48 ;; Return 1 if OP is an unsigned 16-bit constant.
|
|
49 (define_predicate "u16bit_cint_operand"
|
|
50 (and (match_code "const_int")
|
|
51 (match_test "(unsigned HOST_WIDE_INT)INTVAL (op) < (1U << 16)")))
|
|
52
|
|
53 ;; Return 1 if OP is a signed 8-bit constant.
|
|
54 (define_predicate "s8bit_cint_operand"
|
|
55 (and (match_code "const_int")
|
|
56 (match_test "satisfies_constraint_I (op)")))
|
|
57
|
|
58 ;; Return 1 if OP is a signed 16-bit constant.
|
|
59 (define_predicate "s16bit_cint_operand"
|
|
60 (and (match_code "const_int")
|
|
61 (match_test "satisfies_constraint_J (op)")))
|
|
62
|
|
63 ;; Return 1 if OP is an unsigned 14-bit constant.
|
|
64 (define_predicate "u14bit_cint_operand"
|
|
65 (and (match_code "const_int")
|
|
66 (match_test "(unsigned HOST_WIDE_INT)INTVAL (op) < (1U << 14)")))
|
|
67
|
|
68 ;; Return 1 if OP is a constant or any register.
|
|
69 (define_predicate "reg_or_cint_operand"
|
|
70 (ior (match_operand 0 "register_operand")
|
|
71 (match_operand 0 "const_int_operand")))
|
|
72
|
|
73 ;; Returns 1 if OP is a "last" unspec wrapper for a symbol, got, or
|
|
74 ;; tls reference.
|
|
75 (define_predicate "const_last_symbolic_operand"
|
|
76 (and (match_code "const")
|
|
77 (match_test "GET_CODE (XEXP (op,0)) == UNSPEC")
|
|
78 (ior (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW0_LAST")
|
|
79 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW1_LAST")
|
|
80 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW2_LAST")
|
|
81 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW1_LAST_PCREL")
|
|
82 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW2_LAST_PCREL")
|
|
83 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW0_LAST_GOT")
|
|
84 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW1_LAST_GOT")
|
|
85 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW1_LAST_TLS_GD")
|
|
86 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW1_LAST_TLS_IE")
|
|
87 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW1_LAST_TLS_LE")
|
|
88 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW1_LAST_PLT_PCREL")
|
|
89 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW2_LAST_PLT_PCREL"))))
|
|
90
|
|
91 ;; Returns 1 if OP is an unspec wrapper for a symbol, got, or tls
|
|
92 ;; reference.
|
|
93 (define_predicate "const_symbolic_operand"
|
|
94 (and (match_code "const")
|
|
95 (match_test "GET_CODE (XEXP (op,0)) == UNSPEC")
|
|
96 (ior (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW0")
|
|
97 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW1")
|
|
98 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW2")
|
|
99 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW3")
|
|
100 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW0_PCREL")
|
|
101 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW1_PCREL")
|
|
102 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW0_GOT")
|
|
103 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW0_TLS_GD")
|
|
104 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW0_TLS_IE")
|
|
105 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW0_TLS_LE")
|
|
106 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW0_PLT_PCREL")
|
|
107 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_HW1_PLT_PCREL"))))
|
|
108
|
|
109 ;; Return 1 if OP is a 8-element vector constant with identical signed
|
|
110 ;; 8-bit elements or any register.
|
|
111 (define_predicate "reg_or_v8s8bit_operand"
|
|
112 (ior (match_operand 0 "register_operand")
|
|
113 (and (match_code "const_vector")
|
|
114 (match_test "CONST_VECTOR_NUNITS (op) == 8
|
|
115 && (satisfies_constraint_I
|
|
116 (unwrap_const_vec_duplicate (op)))"))))
|
|
117
|
|
118 ;; Return 1 if OP is a 4-element vector constant with identical signed
|
|
119 ;; 8-bit elements or any register.
|
|
120 (define_predicate "reg_or_v4s8bit_operand"
|
|
121 (ior (match_operand 0 "register_operand")
|
|
122 (and (match_code "const_vector")
|
|
123 (match_test "CONST_VECTOR_NUNITS (op) == 4
|
|
124 && (satisfies_constraint_I
|
|
125 (unwrap_const_vec_duplicate (op)))"))))
|
|
126
|
|
127 ;; Return 1 if the operand is a valid second operand to an add insn.
|
|
128 (define_predicate "add_operand"
|
|
129 (if_then_else (match_code "const_int")
|
|
130 (match_test "satisfies_constraint_J (op)")
|
|
131 (ior (match_operand 0 "register_operand")
|
|
132 (match_operand 0 "const_last_symbolic_operand"))))
|
|
133
|
|
134 ;; Return 1 if the operand is a register or signed 8-bit immediate operand.
|
|
135 (define_predicate "reg_or_s8bit_operand"
|
|
136 (if_then_else (match_code "const_int")
|
|
137 (match_test "satisfies_constraint_I (op)")
|
|
138 (match_operand 0 "register_operand")))
|
|
139
|
|
140 ;; Return 1 if the operand is a register or unsigned 5-bit immediate operand.
|
|
141 (define_predicate "reg_or_u5bit_operand"
|
|
142 (if_then_else (match_code "const_int")
|
|
143 (match_test "INTVAL (op) == (INTVAL (op) & 0x1F)")
|
|
144 (match_operand 0 "register_operand")))
|
|
145
|
|
146 ;; Return 1 if the operand is a register or unsigned 6-bit immediate operand.
|
|
147 (define_predicate "reg_or_u6bit_operand"
|
|
148 (if_then_else (match_code "const_int")
|
|
149 (match_test "INTVAL (op) == (INTVAL (op) & 0x3F)")
|
|
150 (match_operand 0 "register_operand")))
|
|
151
|
|
152 ;; Return 1 for an operand suitable for ANDing with a register.
|
|
153 (define_predicate "and_operand"
|
|
154 (if_then_else (match_code "const_int")
|
|
155 (match_test "satisfies_constraint_I (op) || satisfies_constraint_M (op)")
|
|
156 (match_operand 0 "register_operand")))
|
|
157
|
|
158 ; Return 1 if the operand is 2, 4 or 8.
|
|
159 (define_predicate "cint_248_operand"
|
|
160 (and (match_code "const_int")
|
|
161 (match_test
|
|
162 "INTVAL (op) == 2 || INTVAL (op) == 4 || INTVAL (op) == 8")))
|
|
163
|
|
164 ;; Return true if OP is a TLS symbolic operand.
|
|
165 (define_predicate "tls_symbolic_operand"
|
|
166 (and (match_code "symbol_ref")
|
|
167 (match_test "SYMBOL_REF_TLS_MODEL (op) != TLS_MODEL_NONE")))
|
|
168
|
|
169 ;; Return true if OP is a symbolic operand for the TLS Global Dynamic model.
|
|
170 (define_predicate "tls_gd_symbolic_operand"
|
|
171 (and (match_code "symbol_ref")
|
|
172 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_GLOBAL_DYNAMIC")))
|
|
173
|
|
174 ;; Return true if OP is a symbolic operand for the TLS Local Dynamic model.
|
|
175 (define_predicate "tls_ld_symbolic_operand"
|
|
176 (and (match_code "symbol_ref")
|
|
177 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_DYNAMIC")))
|
|
178
|
|
179 ;; Return true if OP is a symbolic operand that can be used for the
|
|
180 ;; TLS Initial Exec model.
|
|
181 (define_predicate "tls_ie_symbolic_operand"
|
|
182 (and (match_code "symbol_ref")
|
|
183 (ior (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_INITIAL_EXEC")
|
|
184 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_EXEC"))))
|
|
185
|
|
186 ;; Return true if OP is a symbolic operand for the TLS Local Exec model.
|
|
187 (define_predicate "tls_le_symbolic_operand"
|
|
188 (and (match_code "symbol_ref")
|
|
189 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_EXEC")))
|
|
190
|
|
191 ;; Returns true if OP is any general operand except for an
|
|
192 ;; auto-incrementing address operand.
|
|
193 (define_predicate "nonautoinc_operand"
|
|
194 (and (match_operand 0 "general_operand")
|
|
195 (not (ior (match_code "pre_dec") (match_code "pre_inc")
|
|
196 (match_code "post_dec") (match_code "post_inc")
|
|
197 (match_code "post_modify") (match_code "pre_modify")))))
|
|
198
|
|
199 ;; Returns true if OP is a non-auto-incrementing memory operand.
|
|
200 (define_predicate "nonautoincmem_operand"
|
|
201 (match_operand 0 "memory_operand")
|
|
202 {
|
|
203 return nonautoinc_operand (XEXP (op, 0), GET_MODE (XEXP (op, 0)));
|
|
204 })
|
|
205
|
|
206 ;; Returns true if OP is a non-auto-incrementing memory, general
|
|
207 ;; operand.
|
|
208 (define_predicate "nonautoincmem_general_operand"
|
|
209 (match_operand 0 "general_operand")
|
|
210 {
|
|
211 if (memory_operand (op, mode))
|
|
212 return nonautoinc_operand (XEXP (op, 0), GET_MODE (XEXP (op, 0)));
|
|
213 else
|
|
214 return true;
|
|
215 })
|
|
216
|
|
217 ;; Returns true if OP is a non-auto-incrementing memory, non-immediate
|
|
218 ;; operand.
|
|
219 (define_predicate "nonautoincmem_nonimmediate_operand"
|
|
220 (match_operand 0 "nonimmediate_operand")
|
|
221 {
|
|
222 if (memory_operand (op, mode))
|
|
223 return nonautoinc_operand (XEXP (op, 0), GET_MODE (XEXP (op, 0)));
|
|
224 else
|
|
225 return true;
|
|
226 })
|
|
227
|
|
228 ;; Return true if OP is a valid operand for the source of a move insn.
|
|
229 (define_predicate "move_operand"
|
|
230 (match_operand 0 "general_operand")
|
|
231 {
|
|
232 /* If both modes are non-void they must be the same. */
|
|
233 if (mode != VOIDmode && GET_MODE (op) != VOIDmode && mode != GET_MODE (op))
|
|
234 return false;
|
|
235
|
|
236 switch (GET_CODE (op))
|
|
237 {
|
|
238 case CONST_INT:
|
|
239 return (satisfies_constraint_J (op)
|
|
240 || satisfies_constraint_K (op)
|
|
241 || (mode == DImode &&
|
|
242 (satisfies_constraint_N (op)
|
|
243 || satisfies_constraint_P (op))));
|
|
244
|
|
245 case MEM:
|
|
246 return memory_address_p (mode, XEXP (op, 0));
|
|
247
|
|
248 case CONST:
|
|
249 return const_last_symbolic_operand (op, mode);
|
|
250
|
|
251 default:
|
|
252 return register_operand (op, mode);
|
|
253 }
|
|
254 })
|
|
255
|
|
256 ;; Returns 1 if OP is a symbolic operand, i.e. a symbol_ref or a label_ref,
|
|
257 ;; possibly with an offset.
|
|
258 (define_predicate "symbolic_operand"
|
|
259 (ior (match_code "symbol_ref,label_ref")
|
|
260 (and (match_code "const")
|
|
261 (match_test "GET_CODE (XEXP (op,0)) == PLUS
|
|
262 && (GET_CODE (XEXP (XEXP (op,0), 0)) == SYMBOL_REF
|
|
263 || GET_CODE (XEXP (XEXP (op,0), 0)) == LABEL_REF)
|
|
264 && CONST_INT_P (XEXP (XEXP (op,0), 1))"))))
|
|
265
|
|
266 ;; Return 1 for an unsigned 16 bit or a const symbolc operand.
|
|
267 (define_predicate "u16bit_or_const_symbolic_operand"
|
|
268 (ior (match_operand 0 "u16bit_cint_operand")
|
|
269 (match_operand 0 "const_symbolic_operand")))
|
|
270
|
|
271 ;; Return true if OP is an address suitable for a call insn.
|
|
272 ;; Call insn on TILE can take a PC-relative constant address
|
|
273 ;; or any regular memory address.
|
|
274 (define_predicate "call_address_operand"
|
|
275 (ior (match_operand 0 "symbolic_operand")
|
|
276 (match_test "memory_address_p (Pmode, op)")))
|
|
277
|
|
278 ;; Return true if OP is an operand suitable for a call insn.
|
|
279 (define_predicate "call_operand"
|
|
280 (and (match_code "mem")
|
|
281 (match_test "call_address_operand (XEXP (op, 0), mode)")))
|
|
282
|
|
283 ;; Return 1 if OP is a signed comparison operation.
|
|
284 ;; We can use these directly in compares against zero.
|
|
285 (define_predicate "signed_comparison_operator"
|
|
286 (match_code "eq,ne,le,lt,ge,gt"))
|
|
287
|
|
288 ;; Return 1 if OP is a equal or not-equal operation.
|
|
289 (define_predicate "eqne_operator"
|
|
290 (match_code "eq,ne"))
|