annotate gcc/optabs-tree.c @ 132:d34655255c78

update gcc-8.2
author mir3636
date Thu, 25 Oct 2018 10:21:07 +0900
parents 84e7813d76e9
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Tree-based target query functions relating to optabs
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2 Copyright (C) 1987-2018 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 This file is part of GCC.
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
7 the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
8 Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
9 version.
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
14 for more details.
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
17 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
18 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 #include "config.h"
kono
parents:
diff changeset
22 #include "system.h"
kono
parents:
diff changeset
23 #include "coretypes.h"
kono
parents:
diff changeset
24 #include "target.h"
kono
parents:
diff changeset
25 #include "insn-codes.h"
kono
parents:
diff changeset
26 #include "tree.h"
kono
parents:
diff changeset
27 #include "optabs-tree.h"
kono
parents:
diff changeset
28 #include "stor-layout.h"
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 /* Return the optab used for computing the operation given by the tree code,
kono
parents:
diff changeset
31 CODE and the tree EXP. This function is not always usable (for example, it
kono
parents:
diff changeset
32 cannot give complete results for multiplication or division) but probably
kono
parents:
diff changeset
33 ought to be relied on more widely throughout the expander. */
kono
parents:
diff changeset
34 optab
kono
parents:
diff changeset
35 optab_for_tree_code (enum tree_code code, const_tree type,
kono
parents:
diff changeset
36 enum optab_subtype subtype)
kono
parents:
diff changeset
37 {
kono
parents:
diff changeset
38 bool trapv;
kono
parents:
diff changeset
39 switch (code)
kono
parents:
diff changeset
40 {
kono
parents:
diff changeset
41 case BIT_AND_EXPR:
kono
parents:
diff changeset
42 return and_optab;
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 case BIT_IOR_EXPR:
kono
parents:
diff changeset
45 return ior_optab;
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 case BIT_NOT_EXPR:
kono
parents:
diff changeset
48 return one_cmpl_optab;
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 case BIT_XOR_EXPR:
kono
parents:
diff changeset
51 return xor_optab;
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 case MULT_HIGHPART_EXPR:
kono
parents:
diff changeset
54 return TYPE_UNSIGNED (type) ? umul_highpart_optab : smul_highpart_optab;
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 case TRUNC_MOD_EXPR:
kono
parents:
diff changeset
57 case CEIL_MOD_EXPR:
kono
parents:
diff changeset
58 case FLOOR_MOD_EXPR:
kono
parents:
diff changeset
59 case ROUND_MOD_EXPR:
kono
parents:
diff changeset
60 return TYPE_UNSIGNED (type) ? umod_optab : smod_optab;
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 case RDIV_EXPR:
kono
parents:
diff changeset
63 case TRUNC_DIV_EXPR:
kono
parents:
diff changeset
64 case CEIL_DIV_EXPR:
kono
parents:
diff changeset
65 case FLOOR_DIV_EXPR:
kono
parents:
diff changeset
66 case ROUND_DIV_EXPR:
kono
parents:
diff changeset
67 case EXACT_DIV_EXPR:
kono
parents:
diff changeset
68 if (TYPE_SATURATING (type))
kono
parents:
diff changeset
69 return TYPE_UNSIGNED (type) ? usdiv_optab : ssdiv_optab;
kono
parents:
diff changeset
70 return TYPE_UNSIGNED (type) ? udiv_optab : sdiv_optab;
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 case LSHIFT_EXPR:
kono
parents:
diff changeset
73 if (TREE_CODE (type) == VECTOR_TYPE)
kono
parents:
diff changeset
74 {
kono
parents:
diff changeset
75 if (subtype == optab_vector)
kono
parents:
diff changeset
76 return TYPE_SATURATING (type) ? unknown_optab : vashl_optab;
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 gcc_assert (subtype == optab_scalar);
kono
parents:
diff changeset
79 }
kono
parents:
diff changeset
80 if (TYPE_SATURATING (type))
kono
parents:
diff changeset
81 return TYPE_UNSIGNED (type) ? usashl_optab : ssashl_optab;
kono
parents:
diff changeset
82 return ashl_optab;
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 case RSHIFT_EXPR:
kono
parents:
diff changeset
85 if (TREE_CODE (type) == VECTOR_TYPE)
kono
parents:
diff changeset
86 {
kono
parents:
diff changeset
87 if (subtype == optab_vector)
kono
parents:
diff changeset
88 return TYPE_UNSIGNED (type) ? vlshr_optab : vashr_optab;
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 gcc_assert (subtype == optab_scalar);
kono
parents:
diff changeset
91 }
kono
parents:
diff changeset
92 return TYPE_UNSIGNED (type) ? lshr_optab : ashr_optab;
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 case LROTATE_EXPR:
kono
parents:
diff changeset
95 if (TREE_CODE (type) == VECTOR_TYPE)
kono
parents:
diff changeset
96 {
kono
parents:
diff changeset
97 if (subtype == optab_vector)
kono
parents:
diff changeset
98 return vrotl_optab;
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 gcc_assert (subtype == optab_scalar);
kono
parents:
diff changeset
101 }
kono
parents:
diff changeset
102 return rotl_optab;
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 case RROTATE_EXPR:
kono
parents:
diff changeset
105 if (TREE_CODE (type) == VECTOR_TYPE)
kono
parents:
diff changeset
106 {
kono
parents:
diff changeset
107 if (subtype == optab_vector)
kono
parents:
diff changeset
108 return vrotr_optab;
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 gcc_assert (subtype == optab_scalar);
kono
parents:
diff changeset
111 }
kono
parents:
diff changeset
112 return rotr_optab;
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 case MAX_EXPR:
kono
parents:
diff changeset
115 return TYPE_UNSIGNED (type) ? umax_optab : smax_optab;
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 case MIN_EXPR:
kono
parents:
diff changeset
118 return TYPE_UNSIGNED (type) ? umin_optab : smin_optab;
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 case REALIGN_LOAD_EXPR:
kono
parents:
diff changeset
121 return vec_realign_load_optab;
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 case WIDEN_SUM_EXPR:
kono
parents:
diff changeset
124 return TYPE_UNSIGNED (type) ? usum_widen_optab : ssum_widen_optab;
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 case DOT_PROD_EXPR:
kono
parents:
diff changeset
127 return TYPE_UNSIGNED (type) ? udot_prod_optab : sdot_prod_optab;
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 case SAD_EXPR:
kono
parents:
diff changeset
130 return TYPE_UNSIGNED (type) ? usad_optab : ssad_optab;
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 case WIDEN_MULT_PLUS_EXPR:
kono
parents:
diff changeset
133 return (TYPE_UNSIGNED (type)
kono
parents:
diff changeset
134 ? (TYPE_SATURATING (type)
kono
parents:
diff changeset
135 ? usmadd_widen_optab : umadd_widen_optab)
kono
parents:
diff changeset
136 : (TYPE_SATURATING (type)
kono
parents:
diff changeset
137 ? ssmadd_widen_optab : smadd_widen_optab));
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 case WIDEN_MULT_MINUS_EXPR:
kono
parents:
diff changeset
140 return (TYPE_UNSIGNED (type)
kono
parents:
diff changeset
141 ? (TYPE_SATURATING (type)
kono
parents:
diff changeset
142 ? usmsub_widen_optab : umsub_widen_optab)
kono
parents:
diff changeset
143 : (TYPE_SATURATING (type)
kono
parents:
diff changeset
144 ? ssmsub_widen_optab : smsub_widen_optab));
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 case VEC_WIDEN_MULT_HI_EXPR:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
147 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
148 ? vec_widen_umult_hi_optab : vec_widen_smult_hi_optab);
111
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 case VEC_WIDEN_MULT_LO_EXPR:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
151 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
152 ? vec_widen_umult_lo_optab : vec_widen_smult_lo_optab);
111
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 case VEC_WIDEN_MULT_EVEN_EXPR:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
155 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
156 ? vec_widen_umult_even_optab : vec_widen_smult_even_optab);
111
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 case VEC_WIDEN_MULT_ODD_EXPR:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
159 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
160 ? vec_widen_umult_odd_optab : vec_widen_smult_odd_optab);
111
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 case VEC_WIDEN_LSHIFT_HI_EXPR:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
163 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
164 ? vec_widen_ushiftl_hi_optab : vec_widen_sshiftl_hi_optab);
111
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 case VEC_WIDEN_LSHIFT_LO_EXPR:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
167 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
168 ? vec_widen_ushiftl_lo_optab : vec_widen_sshiftl_lo_optab);
111
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 case VEC_UNPACK_HI_EXPR:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
171 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
172 ? vec_unpacku_hi_optab : vec_unpacks_hi_optab);
111
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 case VEC_UNPACK_LO_EXPR:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
175 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
176 ? vec_unpacku_lo_optab : vec_unpacks_lo_optab);
111
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 case VEC_UNPACK_FLOAT_HI_EXPR:
kono
parents:
diff changeset
179 /* The signedness is determined from input operand. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
180 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
181 ? vec_unpacku_float_hi_optab : vec_unpacks_float_hi_optab);
111
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 case VEC_UNPACK_FLOAT_LO_EXPR:
kono
parents:
diff changeset
184 /* The signedness is determined from input operand. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
185 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
186 ? vec_unpacku_float_lo_optab : vec_unpacks_float_lo_optab);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
187
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
188 case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
189 /* The signedness is determined from output operand. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
190 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
191 ? vec_unpack_ufix_trunc_hi_optab
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
192 : vec_unpack_sfix_trunc_hi_optab);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
193
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
194 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
195 /* The signedness is determined from output operand. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
196 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
197 ? vec_unpack_ufix_trunc_lo_optab
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
198 : vec_unpack_sfix_trunc_lo_optab);
111
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200 case VEC_PACK_TRUNC_EXPR:
kono
parents:
diff changeset
201 return vec_pack_trunc_optab;
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 case VEC_PACK_SAT_EXPR:
kono
parents:
diff changeset
204 return TYPE_UNSIGNED (type) ? vec_pack_usat_optab : vec_pack_ssat_optab;
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 case VEC_PACK_FIX_TRUNC_EXPR:
kono
parents:
diff changeset
207 /* The signedness is determined from output operand. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
208 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
209 ? vec_pack_ufix_trunc_optab : vec_pack_sfix_trunc_optab);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
210
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
211 case VEC_PACK_FLOAT_EXPR:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
212 /* The signedness is determined from input operand. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
213 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
214 ? vec_packu_float_optab : vec_packs_float_optab);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
215
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
216 case VEC_DUPLICATE_EXPR:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
217 return vec_duplicate_optab;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
218
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
219 case VEC_SERIES_EXPR:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
220 return vec_series_optab;
111
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222 default:
kono
parents:
diff changeset
223 break;
kono
parents:
diff changeset
224 }
kono
parents:
diff changeset
225
kono
parents:
diff changeset
226 trapv = INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_TRAPS (type);
kono
parents:
diff changeset
227 switch (code)
kono
parents:
diff changeset
228 {
kono
parents:
diff changeset
229 case POINTER_PLUS_EXPR:
kono
parents:
diff changeset
230 case PLUS_EXPR:
kono
parents:
diff changeset
231 if (TYPE_SATURATING (type))
kono
parents:
diff changeset
232 return TYPE_UNSIGNED (type) ? usadd_optab : ssadd_optab;
kono
parents:
diff changeset
233 return trapv ? addv_optab : add_optab;
kono
parents:
diff changeset
234
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
235 case POINTER_DIFF_EXPR:
111
kono
parents:
diff changeset
236 case MINUS_EXPR:
kono
parents:
diff changeset
237 if (TYPE_SATURATING (type))
kono
parents:
diff changeset
238 return TYPE_UNSIGNED (type) ? ussub_optab : sssub_optab;
kono
parents:
diff changeset
239 return trapv ? subv_optab : sub_optab;
kono
parents:
diff changeset
240
kono
parents:
diff changeset
241 case MULT_EXPR:
kono
parents:
diff changeset
242 if (TYPE_SATURATING (type))
kono
parents:
diff changeset
243 return TYPE_UNSIGNED (type) ? usmul_optab : ssmul_optab;
kono
parents:
diff changeset
244 return trapv ? smulv_optab : smul_optab;
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 case NEGATE_EXPR:
kono
parents:
diff changeset
247 if (TYPE_SATURATING (type))
kono
parents:
diff changeset
248 return TYPE_UNSIGNED (type) ? usneg_optab : ssneg_optab;
kono
parents:
diff changeset
249 return trapv ? negv_optab : neg_optab;
kono
parents:
diff changeset
250
kono
parents:
diff changeset
251 case ABS_EXPR:
kono
parents:
diff changeset
252 return trapv ? absv_optab : abs_optab;
kono
parents:
diff changeset
253
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
254 case ABSU_EXPR:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
255 return abs_optab;
111
kono
parents:
diff changeset
256 default:
kono
parents:
diff changeset
257 return unknown_optab;
kono
parents:
diff changeset
258 }
kono
parents:
diff changeset
259 }
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 /* Function supportable_convert_operation
kono
parents:
diff changeset
262
kono
parents:
diff changeset
263 Check whether an operation represented by the code CODE is a
kono
parents:
diff changeset
264 convert operation that is supported by the target platform in
kono
parents:
diff changeset
265 vector form (i.e., when operating on arguments of type VECTYPE_IN
kono
parents:
diff changeset
266 producing a result of type VECTYPE_OUT).
kono
parents:
diff changeset
267
kono
parents:
diff changeset
268 Convert operations we currently support directly are FIX_TRUNC and FLOAT.
kono
parents:
diff changeset
269 This function checks if these operations are supported
kono
parents:
diff changeset
270 by the target platform either directly (via vector tree-codes), or via
kono
parents:
diff changeset
271 target builtins.
kono
parents:
diff changeset
272
kono
parents:
diff changeset
273 Output:
kono
parents:
diff changeset
274 - CODE1 is code of vector operation to be used when
kono
parents:
diff changeset
275 vectorizing the operation, if available.
kono
parents:
diff changeset
276 - DECL is decl of target builtin functions to be used
kono
parents:
diff changeset
277 when vectorizing the operation, if available. In this case,
kono
parents:
diff changeset
278 CODE1 is CALL_EXPR. */
kono
parents:
diff changeset
279
kono
parents:
diff changeset
280 bool
kono
parents:
diff changeset
281 supportable_convert_operation (enum tree_code code,
kono
parents:
diff changeset
282 tree vectype_out, tree vectype_in,
kono
parents:
diff changeset
283 tree *decl, enum tree_code *code1)
kono
parents:
diff changeset
284 {
kono
parents:
diff changeset
285 machine_mode m1,m2;
kono
parents:
diff changeset
286 bool truncp;
kono
parents:
diff changeset
287
kono
parents:
diff changeset
288 m1 = TYPE_MODE (vectype_out);
kono
parents:
diff changeset
289 m2 = TYPE_MODE (vectype_in);
kono
parents:
diff changeset
290
kono
parents:
diff changeset
291 /* First check if we can done conversion directly. */
kono
parents:
diff changeset
292 if ((code == FIX_TRUNC_EXPR
kono
parents:
diff changeset
293 && can_fix_p (m1,m2,TYPE_UNSIGNED (vectype_out), &truncp)
kono
parents:
diff changeset
294 != CODE_FOR_nothing)
kono
parents:
diff changeset
295 || (code == FLOAT_EXPR
kono
parents:
diff changeset
296 && can_float_p (m1,m2,TYPE_UNSIGNED (vectype_in))
kono
parents:
diff changeset
297 != CODE_FOR_nothing))
kono
parents:
diff changeset
298 {
kono
parents:
diff changeset
299 *code1 = code;
kono
parents:
diff changeset
300 return true;
kono
parents:
diff changeset
301 }
kono
parents:
diff changeset
302
kono
parents:
diff changeset
303 /* Now check for builtin. */
kono
parents:
diff changeset
304 if (targetm.vectorize.builtin_conversion
kono
parents:
diff changeset
305 && targetm.vectorize.builtin_conversion (code, vectype_out, vectype_in))
kono
parents:
diff changeset
306 {
kono
parents:
diff changeset
307 *code1 = CALL_EXPR;
kono
parents:
diff changeset
308 *decl = targetm.vectorize.builtin_conversion (code, vectype_out,
kono
parents:
diff changeset
309 vectype_in);
kono
parents:
diff changeset
310 return true;
kono
parents:
diff changeset
311 }
kono
parents:
diff changeset
312 return false;
kono
parents:
diff changeset
313 }
kono
parents:
diff changeset
314
kono
parents:
diff changeset
315 /* Return TRUE if appropriate vector insn is available
kono
parents:
diff changeset
316 for vector comparison expr with vector type VALUE_TYPE
kono
parents:
diff changeset
317 and resulting mask with MASK_TYPE. */
kono
parents:
diff changeset
318
kono
parents:
diff changeset
319 bool
kono
parents:
diff changeset
320 expand_vec_cmp_expr_p (tree value_type, tree mask_type, enum tree_code code)
kono
parents:
diff changeset
321 {
kono
parents:
diff changeset
322 if (get_vec_cmp_icode (TYPE_MODE (value_type), TYPE_MODE (mask_type),
kono
parents:
diff changeset
323 TYPE_UNSIGNED (value_type)) != CODE_FOR_nothing)
kono
parents:
diff changeset
324 return true;
kono
parents:
diff changeset
325 if ((code == EQ_EXPR || code == NE_EXPR)
kono
parents:
diff changeset
326 && (get_vec_cmp_eq_icode (TYPE_MODE (value_type), TYPE_MODE (mask_type))
kono
parents:
diff changeset
327 != CODE_FOR_nothing))
kono
parents:
diff changeset
328 return true;
kono
parents:
diff changeset
329 return false;
kono
parents:
diff changeset
330 }
kono
parents:
diff changeset
331
kono
parents:
diff changeset
332 /* Return TRUE iff, appropriate vector insns are available
kono
parents:
diff changeset
333 for vector cond expr with vector type VALUE_TYPE and a comparison
kono
parents:
diff changeset
334 with operand vector types in CMP_OP_TYPE. */
kono
parents:
diff changeset
335
kono
parents:
diff changeset
336 bool
kono
parents:
diff changeset
337 expand_vec_cond_expr_p (tree value_type, tree cmp_op_type, enum tree_code code)
kono
parents:
diff changeset
338 {
kono
parents:
diff changeset
339 machine_mode value_mode = TYPE_MODE (value_type);
kono
parents:
diff changeset
340 machine_mode cmp_op_mode = TYPE_MODE (cmp_op_type);
kono
parents:
diff changeset
341 if (VECTOR_BOOLEAN_TYPE_P (cmp_op_type)
kono
parents:
diff changeset
342 && get_vcond_mask_icode (TYPE_MODE (value_type),
kono
parents:
diff changeset
343 TYPE_MODE (cmp_op_type)) != CODE_FOR_nothing)
kono
parents:
diff changeset
344 return true;
kono
parents:
diff changeset
345
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
346 if (maybe_ne (GET_MODE_SIZE (value_mode), GET_MODE_SIZE (cmp_op_mode))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
347 || maybe_ne (GET_MODE_NUNITS (value_mode), GET_MODE_NUNITS (cmp_op_mode)))
111
kono
parents:
diff changeset
348 return false;
kono
parents:
diff changeset
349
kono
parents:
diff changeset
350 if (get_vcond_icode (TYPE_MODE (value_type), TYPE_MODE (cmp_op_type),
kono
parents:
diff changeset
351 TYPE_UNSIGNED (cmp_op_type)) == CODE_FOR_nothing
kono
parents:
diff changeset
352 && ((code != EQ_EXPR && code != NE_EXPR)
kono
parents:
diff changeset
353 || get_vcond_eq_icode (TYPE_MODE (value_type),
kono
parents:
diff changeset
354 TYPE_MODE (cmp_op_type)) == CODE_FOR_nothing))
kono
parents:
diff changeset
355 return false;
kono
parents:
diff changeset
356
kono
parents:
diff changeset
357 return true;
kono
parents:
diff changeset
358 }
kono
parents:
diff changeset
359
kono
parents:
diff changeset
360 /* Use the current target and options to initialize
kono
parents:
diff changeset
361 TREE_OPTIMIZATION_OPTABS (OPTNODE). */
kono
parents:
diff changeset
362
kono
parents:
diff changeset
363 void
kono
parents:
diff changeset
364 init_tree_optimization_optabs (tree optnode)
kono
parents:
diff changeset
365 {
kono
parents:
diff changeset
366 /* Quick exit if we have already computed optabs for this target. */
kono
parents:
diff changeset
367 if (TREE_OPTIMIZATION_BASE_OPTABS (optnode) == this_target_optabs)
kono
parents:
diff changeset
368 return;
kono
parents:
diff changeset
369
kono
parents:
diff changeset
370 /* Forget any previous information and set up for the current target. */
kono
parents:
diff changeset
371 TREE_OPTIMIZATION_BASE_OPTABS (optnode) = this_target_optabs;
kono
parents:
diff changeset
372 struct target_optabs *tmp_optabs = (struct target_optabs *)
kono
parents:
diff changeset
373 TREE_OPTIMIZATION_OPTABS (optnode);
kono
parents:
diff changeset
374 if (tmp_optabs)
kono
parents:
diff changeset
375 memset (tmp_optabs, 0, sizeof (struct target_optabs));
kono
parents:
diff changeset
376 else
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
377 tmp_optabs = ggc_cleared_alloc<target_optabs> ();
111
kono
parents:
diff changeset
378
kono
parents:
diff changeset
379 /* Generate a new set of optabs into tmp_optabs. */
kono
parents:
diff changeset
380 init_all_optabs (tmp_optabs);
kono
parents:
diff changeset
381
kono
parents:
diff changeset
382 /* If the optabs changed, record it. */
kono
parents:
diff changeset
383 if (memcmp (tmp_optabs, this_target_optabs, sizeof (struct target_optabs)))
kono
parents:
diff changeset
384 TREE_OPTIMIZATION_OPTABS (optnode) = tmp_optabs;
kono
parents:
diff changeset
385 else
kono
parents:
diff changeset
386 {
kono
parents:
diff changeset
387 TREE_OPTIMIZATION_OPTABS (optnode) = NULL;
kono
parents:
diff changeset
388 ggc_free (tmp_optabs);
kono
parents:
diff changeset
389 }
kono
parents:
diff changeset
390 }
kono
parents:
diff changeset
391
kono
parents:
diff changeset
392 /* Return TRUE if the target has support for vector right shift of an
kono
parents:
diff changeset
393 operand of type TYPE. If OT_TYPE is OPTAB_DEFAULT, check for existence
kono
parents:
diff changeset
394 of a shift by either a scalar or a vector. Otherwise, check only
kono
parents:
diff changeset
395 for a shift that matches OT_TYPE. */
kono
parents:
diff changeset
396
kono
parents:
diff changeset
397 bool
kono
parents:
diff changeset
398 target_supports_op_p (tree type, enum tree_code code,
kono
parents:
diff changeset
399 enum optab_subtype ot_subtype)
kono
parents:
diff changeset
400 {
kono
parents:
diff changeset
401 optab ot = optab_for_tree_code (code, type, ot_subtype);
kono
parents:
diff changeset
402 return (ot != unknown_optab
kono
parents:
diff changeset
403 && optab_handler (ot, TYPE_MODE (type)) != CODE_FOR_nothing);
kono
parents:
diff changeset
404 }
kono
parents:
diff changeset
405