]>
Commit | Line | Data |
---|---|---|
dd552284 | 1 | ;; Predicate definitions for Tilera TILEPro chip. |
5624e564 | 2 | ;; Copyright (C) 2011-2015 Free Software Foundation, Inc. |
dd552284 WL |
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 network register identifier. | |
33 | (define_predicate "netreg_operand" | |
34 | (and (match_code "const_int") | |
35 | (match_test "IN_RANGE (INTVAL (op), 0, 6)"))) | |
36 | ||
37 | ; Return 1 if OP is an unsigned 5-bit constant. | |
38 | (define_predicate "u5bit_cint_operand" | |
39 | (and (match_code "const_int") | |
40 | (match_test "INTVAL (op) == (INTVAL (op) & 0x1F)"))) | |
41 | ||
42 | ;; Return 1 if OP is an unsigned 16-bit constant. | |
43 | (define_predicate "u16bit_cint_operand" | |
44 | (and (match_code "const_int") | |
45 | (match_test "(unsigned HOST_WIDE_INT)INTVAL (op) < (1U << 16)"))) | |
46 | ||
47 | ;; Return 1 if OP is a signed 8-bit constant. | |
48 | (define_predicate "s8bit_cint_operand" | |
49 | (and (match_code "const_int") | |
50 | (match_test "satisfies_constraint_I (op)"))) | |
51 | ||
52 | ;; Return 1 if OP is a signed 16-bit constant. | |
53 | (define_predicate "s16bit_cint_operand" | |
54 | (and (match_code "const_int") | |
55 | (match_test "satisfies_constraint_J (op)"))) | |
56 | ||
57 | ;; Return 1 if OP is a nonzero integer constant whose low 16 bits are zero. | |
58 | (define_predicate "auli_cint_operand" | |
59 | (and (match_code "const_int") | |
60 | (match_test "satisfies_constraint_K (op)"))) | |
61 | ||
62 | ;; Return 1 if OP is an unsigned 15-bit constant. | |
63 | (define_predicate "u15bit_cint_operand" | |
64 | (and (match_code "const_int") | |
65 | (match_test "(unsigned HOST_WIDE_INT)INTVAL (op) < (1U << 15)"))) | |
66 | ||
67 | ;; Return 1 if OP is a constant or any register. | |
68 | (define_predicate "reg_or_cint_operand" | |
69 | (ior (match_operand 0 "register_operand") | |
70 | (match_operand 0 "const_int_operand"))) | |
71 | ||
72 | ;; Return 1 if OP is a 4-element vector constant with identical signed | |
73 | ;; 8-bit elements or any register. | |
74 | (define_predicate "reg_or_v4s8bit_operand" | |
75 | (ior (match_operand 0 "register_operand") | |
76 | (and (match_code "const_vector") | |
77 | (match_test "CONST_VECTOR_NUNITS (op) == 4 | |
78 | && satisfies_constraint_I (CONST_VECTOR_ELT (op, 0)) | |
79 | && CONST_VECTOR_ELT (op, 0) == CONST_VECTOR_ELT (op, 1) | |
80 | && CONST_VECTOR_ELT (op, 0) == CONST_VECTOR_ELT (op, 2) | |
81 | && CONST_VECTOR_ELT (op, 0) == CONST_VECTOR_ELT (op, 3)")))) | |
82 | ||
83 | ;; Return 1 if OP is a 2-element vector constant with identical signed | |
84 | ;; 8-bit elements or any register. | |
85 | (define_predicate "reg_or_v2s8bit_operand" | |
86 | (ior (match_operand 0 "register_operand") | |
87 | (and (match_code "const_vector") | |
88 | (match_test "CONST_VECTOR_NUNITS (op) == 2 | |
89 | && satisfies_constraint_I (CONST_VECTOR_ELT (op, 0)) | |
90 | && CONST_VECTOR_ELT (op, 0) == CONST_VECTOR_ELT (op, 1)")))) | |
91 | ||
92 | ;; Return 1 if the operand is a valid second operand to an add insn. | |
93 | (define_predicate "add_operand" | |
94 | (if_then_else (match_code "const_int") | |
95 | (match_test "satisfies_constraint_J (op) || satisfies_constraint_K (op)") | |
96 | (match_operand 0 "register_operand"))) | |
97 | ||
98 | ;; Return 1 if the operand is a register or signed 8-bit immediate operand. | |
99 | (define_predicate "reg_or_s8bit_operand" | |
100 | (if_then_else (match_code "const_int") | |
101 | (match_test "satisfies_constraint_I (op)") | |
102 | (match_operand 0 "register_operand"))) | |
103 | ||
104 | ;; Return 1 for an operand suitable for ANDing with a register. | |
105 | (define_predicate "and_operand" | |
106 | (if_then_else (match_code "const_int") | |
107 | (match_test "satisfies_constraint_I (op) || satisfies_constraint_M (op)") | |
108 | (match_operand 0 "register_operand"))) | |
109 | ||
110 | ;; Return 1 if the operand is a register or unsigned 5-bit immediate operand. | |
111 | (define_predicate "reg_or_u5bit_operand" | |
112 | (if_then_else (match_code "const_int") | |
113 | (match_test "INTVAL (op) == (INTVAL (op) & 0x1F)") | |
114 | (match_operand 0 "register_operand"))) | |
115 | ||
116 | ; Return 1 if the operand is 2, 4 or 8. | |
117 | (define_predicate "cint_248_operand" | |
118 | (and (match_code "const_int") | |
119 | (match_test | |
120 | "INTVAL (op) == 2 || INTVAL (op) == 4 || INTVAL (op) == 8"))) | |
121 | ||
122 | ||
123 | ;; Return true if OP is a TLS symbolic operand. | |
124 | (define_predicate "tls_symbolic_operand" | |
125 | (and (match_code "symbol_ref") | |
126 | (match_test "SYMBOL_REF_TLS_MODEL (op) != TLS_MODEL_NONE"))) | |
127 | ||
128 | ;; Return true if OP is a symbolic operand for the TLS Global Dynamic model. | |
129 | (define_predicate "tls_gd_symbolic_operand" | |
130 | (and (match_code "symbol_ref") | |
131 | (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_GLOBAL_DYNAMIC"))) | |
132 | ||
133 | ;; Return true if OP is a symbolic operand for the TLS Local Dynamic model. | |
134 | (define_predicate "tls_ld_symbolic_operand" | |
135 | (and (match_code "symbol_ref") | |
136 | (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_DYNAMIC"))) | |
137 | ||
138 | ;; Return true if OP is a symbolic operand that can be used for the | |
139 | ;; TLS Initial Exec model. | |
140 | (define_predicate "tls_ie_symbolic_operand" | |
141 | (and (match_code "symbol_ref") | |
142 | (ior (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_INITIAL_EXEC") | |
143 | (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_EXEC")))) | |
144 | ||
145 | ;; Return true if OP is a symbolic operand for the TLS Local Exec model. | |
146 | (define_predicate "tls_le_symbolic_operand" | |
147 | (and (match_code "symbol_ref") | |
148 | (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_EXEC"))) | |
149 | ||
150 | ;; Returns true if OP is any general operand except for an | |
151 | ;; auto-incrementing address operand. | |
152 | (define_predicate "nonautoinc_operand" | |
153 | (and (match_operand 0 "general_operand") | |
154 | (not (ior (match_code "pre_dec") (match_code "pre_inc") | |
155 | (match_code "post_dec") (match_code "post_inc") | |
156 | (match_code "post_modify") (match_code "pre_modify"))))) | |
157 | ||
158 | ;; Returns true if OP is a non-auto-incrementing memory operand. | |
159 | (define_predicate "nonautoincmem_operand" | |
160 | (match_operand 0 "memory_operand") | |
161 | { | |
162 | return nonautoinc_operand (XEXP (op, 0), GET_MODE (XEXP (op, 0))); | |
163 | }) | |
164 | ||
165 | ;; Returns true if OP is a non-auto-incrementing memory, general | |
166 | ;; operand. | |
167 | (define_predicate "nonautoincmem_general_operand" | |
168 | (match_operand 0 "general_operand") | |
169 | { | |
170 | if (memory_operand (op, mode)) | |
171 | return nonautoinc_operand (XEXP (op, 0), GET_MODE (XEXP (op, 0))); | |
172 | else | |
173 | return true; | |
174 | }) | |
175 | ||
176 | ;; Returns true if OP is a non-auto-incrementing memory, non-immediate | |
177 | ;; operand. | |
178 | (define_predicate "nonautoincmem_nonimmediate_operand" | |
179 | (match_operand 0 "nonimmediate_operand") | |
180 | { | |
181 | if (memory_operand (op, mode)) | |
182 | return nonautoinc_operand (XEXP (op, 0), GET_MODE (XEXP (op, 0))); | |
183 | else | |
184 | return true; | |
185 | }) | |
186 | ||
187 | ;; Return true if OP is a valid operand for the source of a move insn. | |
188 | (define_predicate "move_operand" | |
189 | (match_operand 0 "general_operand") | |
190 | { | |
191 | /* If both modes are non-void they must be the same. */ | |
192 | if (mode != VOIDmode && GET_MODE (op) != VOIDmode && mode != GET_MODE (op)) | |
193 | return false; | |
194 | ||
195 | if (GET_MODE_SIZE (mode) > 4) | |
196 | return false; | |
197 | ||
198 | switch (GET_CODE (op)) | |
199 | { | |
200 | case CONST_INT: | |
201 | return (satisfies_constraint_J (op) | |
202 | || satisfies_constraint_K (op) | |
203 | || satisfies_constraint_N (op) | |
204 | || satisfies_constraint_P (op)); | |
205 | ||
206 | case HIGH: | |
207 | return true; | |
208 | ||
209 | case MEM: | |
210 | return memory_address_p (mode, XEXP (op, 0)); | |
211 | ||
212 | default: | |
213 | return register_operand (op, mode); | |
214 | } | |
215 | }) | |
216 | ||
217 | ;; Returns 1 if OP is a symbolic operand, i.e. a symbol_ref or a label_ref, | |
218 | ;; possibly with an offset. | |
219 | (define_predicate "symbolic_operand" | |
220 | (ior (match_code "symbol_ref,label_ref") | |
221 | (and (match_code "const") | |
222 | (match_test "GET_CODE (XEXP (op,0)) == PLUS | |
223 | && (GET_CODE (XEXP (XEXP (op,0), 0)) == SYMBOL_REF | |
224 | || GET_CODE (XEXP (XEXP (op,0), 0)) == LABEL_REF) | |
225 | && CONST_INT_P (XEXP (XEXP (op,0), 1))")))) | |
226 | ||
227 | ;; Returns 1 if OP is a symbolic operand, or a const unspec wrapper | |
228 | ;; representing a got reference, a tls reference, or pc-relative | |
229 | ;; reference. | |
230 | (define_predicate "const_symbolic_operand" | |
231 | (ior (match_operand 0 "symbolic_operand") | |
232 | (and (match_code "const") | |
233 | (match_test "GET_CODE (XEXP (op,0)) == UNSPEC") | |
234 | (ior (match_test "XINT (XEXP (op,0), 1) == UNSPEC_GOT16_SYM") | |
235 | (match_test "XINT (XEXP (op,0), 1) == UNSPEC_GOT32_SYM") | |
236 | (match_test "XINT (XEXP (op,0), 1) == UNSPEC_PCREL_SYM") | |
237 | (match_test "XINT (XEXP (op,0), 1) == UNSPEC_TLS_GD") | |
238 | (match_test "XINT (XEXP (op,0), 1) == UNSPEC_TLS_IE") | |
239 | (match_test "XINT (XEXP (op,0), 1) == UNSPEC_TLS_LE"))))) | |
240 | ||
241 | ;; Return true if OP is an address suitable for a call insn. | |
242 | ;; Call insn on TILE can take a PC-relative constant address | |
243 | ;; or any regular memory address. | |
244 | (define_predicate "call_address_operand" | |
245 | (ior (match_operand 0 "symbolic_operand") | |
246 | (match_test "memory_address_p (Pmode, op)"))) | |
247 | ||
248 | ;; Return true if OP is an operand suitable for a call insn. | |
249 | (define_predicate "call_operand" | |
250 | (and (match_code "mem") | |
251 | (match_test "call_address_operand (XEXP (op, 0), mode)"))) | |
252 | ||
253 | ;; Return 1 if OP is a signed comparison operation. | |
254 | ;; We can use these directly in compares against zero. | |
255 | (define_predicate "signed_comparison_operator" | |
256 | (match_code "eq,ne,le,lt,ge,gt")) | |
257 | ||
258 | ;; Return 1 if OP is a equal or not-equal operation. | |
259 | (define_predicate "eqne_operator" | |
260 | (match_code "eq,ne")) |