annotate gcc/config/tilegx/predicates.md @ 111:04ced10e8804

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