annotate gcc/optabs-tree.c @ 16: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
16
kono
parents:
diff changeset
1 /* Tree-based target query functions relating to optabs
kono
parents:
diff changeset
2 Copyright (C) 1987-2017 Free Software Foundation, Inc.
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 FMA_EXPR:
kono
parents:
diff changeset
147 return fma_optab;
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 case REDUC_MAX_EXPR:
kono
parents:
diff changeset
150 return TYPE_UNSIGNED (type)
kono
parents:
diff changeset
151 ? reduc_umax_scal_optab : reduc_smax_scal_optab;
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 case REDUC_MIN_EXPR:
kono
parents:
diff changeset
154 return TYPE_UNSIGNED (type)
kono
parents:
diff changeset
155 ? reduc_umin_scal_optab : reduc_smin_scal_optab;
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 case REDUC_PLUS_EXPR:
kono
parents:
diff changeset
158 return reduc_plus_scal_optab;
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 case VEC_WIDEN_MULT_HI_EXPR:
kono
parents:
diff changeset
161 return TYPE_UNSIGNED (type) ?
kono
parents:
diff changeset
162 vec_widen_umult_hi_optab : vec_widen_smult_hi_optab;
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 case VEC_WIDEN_MULT_LO_EXPR:
kono
parents:
diff changeset
165 return TYPE_UNSIGNED (type) ?
kono
parents:
diff changeset
166 vec_widen_umult_lo_optab : vec_widen_smult_lo_optab;
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 case VEC_WIDEN_MULT_EVEN_EXPR:
kono
parents:
diff changeset
169 return TYPE_UNSIGNED (type) ?
kono
parents:
diff changeset
170 vec_widen_umult_even_optab : vec_widen_smult_even_optab;
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 case VEC_WIDEN_MULT_ODD_EXPR:
kono
parents:
diff changeset
173 return TYPE_UNSIGNED (type) ?
kono
parents:
diff changeset
174 vec_widen_umult_odd_optab : vec_widen_smult_odd_optab;
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 case VEC_WIDEN_LSHIFT_HI_EXPR:
kono
parents:
diff changeset
177 return TYPE_UNSIGNED (type) ?
kono
parents:
diff changeset
178 vec_widen_ushiftl_hi_optab : vec_widen_sshiftl_hi_optab;
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 case VEC_WIDEN_LSHIFT_LO_EXPR:
kono
parents:
diff changeset
181 return TYPE_UNSIGNED (type) ?
kono
parents:
diff changeset
182 vec_widen_ushiftl_lo_optab : vec_widen_sshiftl_lo_optab;
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 case VEC_UNPACK_HI_EXPR:
kono
parents:
diff changeset
185 return TYPE_UNSIGNED (type) ?
kono
parents:
diff changeset
186 vec_unpacku_hi_optab : vec_unpacks_hi_optab;
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 case VEC_UNPACK_LO_EXPR:
kono
parents:
diff changeset
189 return TYPE_UNSIGNED (type) ?
kono
parents:
diff changeset
190 vec_unpacku_lo_optab : vec_unpacks_lo_optab;
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 case VEC_UNPACK_FLOAT_HI_EXPR:
kono
parents:
diff changeset
193 /* The signedness is determined from input operand. */
kono
parents:
diff changeset
194 return TYPE_UNSIGNED (type) ?
kono
parents:
diff changeset
195 vec_unpacku_float_hi_optab : vec_unpacks_float_hi_optab;
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 case VEC_UNPACK_FLOAT_LO_EXPR:
kono
parents:
diff changeset
198 /* The signedness is determined from input operand. */
kono
parents:
diff changeset
199 return TYPE_UNSIGNED (type) ?
kono
parents:
diff changeset
200 vec_unpacku_float_lo_optab : vec_unpacks_float_lo_optab;
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 case VEC_PACK_TRUNC_EXPR:
kono
parents:
diff changeset
203 return vec_pack_trunc_optab;
kono
parents:
diff changeset
204
kono
parents:
diff changeset
205 case VEC_PACK_SAT_EXPR:
kono
parents:
diff changeset
206 return TYPE_UNSIGNED (type) ? vec_pack_usat_optab : vec_pack_ssat_optab;
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 case VEC_PACK_FIX_TRUNC_EXPR:
kono
parents:
diff changeset
209 /* The signedness is determined from output operand. */
kono
parents:
diff changeset
210 return TYPE_UNSIGNED (type) ?
kono
parents:
diff changeset
211 vec_pack_ufix_trunc_optab : vec_pack_sfix_trunc_optab;
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 default:
kono
parents:
diff changeset
214 break;
kono
parents:
diff changeset
215 }
kono
parents:
diff changeset
216
kono
parents:
diff changeset
217 trapv = INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_TRAPS (type);
kono
parents:
diff changeset
218 switch (code)
kono
parents:
diff changeset
219 {
kono
parents:
diff changeset
220 case POINTER_PLUS_EXPR:
kono
parents:
diff changeset
221 case PLUS_EXPR:
kono
parents:
diff changeset
222 if (TYPE_SATURATING (type))
kono
parents:
diff changeset
223 return TYPE_UNSIGNED (type) ? usadd_optab : ssadd_optab;
kono
parents:
diff changeset
224 return trapv ? addv_optab : add_optab;
kono
parents:
diff changeset
225
kono
parents:
diff changeset
226 case MINUS_EXPR:
kono
parents:
diff changeset
227 if (TYPE_SATURATING (type))
kono
parents:
diff changeset
228 return TYPE_UNSIGNED (type) ? ussub_optab : sssub_optab;
kono
parents:
diff changeset
229 return trapv ? subv_optab : sub_optab;
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 case MULT_EXPR:
kono
parents:
diff changeset
232 if (TYPE_SATURATING (type))
kono
parents:
diff changeset
233 return TYPE_UNSIGNED (type) ? usmul_optab : ssmul_optab;
kono
parents:
diff changeset
234 return trapv ? smulv_optab : smul_optab;
kono
parents:
diff changeset
235
kono
parents:
diff changeset
236 case NEGATE_EXPR:
kono
parents:
diff changeset
237 if (TYPE_SATURATING (type))
kono
parents:
diff changeset
238 return TYPE_UNSIGNED (type) ? usneg_optab : ssneg_optab;
kono
parents:
diff changeset
239 return trapv ? negv_optab : neg_optab;
kono
parents:
diff changeset
240
kono
parents:
diff changeset
241 case ABS_EXPR:
kono
parents:
diff changeset
242 return trapv ? absv_optab : abs_optab;
kono
parents:
diff changeset
243
kono
parents:
diff changeset
244 default:
kono
parents:
diff changeset
245 return unknown_optab;
kono
parents:
diff changeset
246 }
kono
parents:
diff changeset
247 }
kono
parents:
diff changeset
248
kono
parents:
diff changeset
249 /* Function supportable_convert_operation
kono
parents:
diff changeset
250
kono
parents:
diff changeset
251 Check whether an operation represented by the code CODE is a
kono
parents:
diff changeset
252 convert operation that is supported by the target platform in
kono
parents:
diff changeset
253 vector form (i.e., when operating on arguments of type VECTYPE_IN
kono
parents:
diff changeset
254 producing a result of type VECTYPE_OUT).
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 Convert operations we currently support directly are FIX_TRUNC and FLOAT.
kono
parents:
diff changeset
257 This function checks if these operations are supported
kono
parents:
diff changeset
258 by the target platform either directly (via vector tree-codes), or via
kono
parents:
diff changeset
259 target builtins.
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 Output:
kono
parents:
diff changeset
262 - CODE1 is code of vector operation to be used when
kono
parents:
diff changeset
263 vectorizing the operation, if available.
kono
parents:
diff changeset
264 - DECL is decl of target builtin functions to be used
kono
parents:
diff changeset
265 when vectorizing the operation, if available. In this case,
kono
parents:
diff changeset
266 CODE1 is CALL_EXPR. */
kono
parents:
diff changeset
267
kono
parents:
diff changeset
268 bool
kono
parents:
diff changeset
269 supportable_convert_operation (enum tree_code code,
kono
parents:
diff changeset
270 tree vectype_out, tree vectype_in,
kono
parents:
diff changeset
271 tree *decl, enum tree_code *code1)
kono
parents:
diff changeset
272 {
kono
parents:
diff changeset
273 machine_mode m1,m2;
kono
parents:
diff changeset
274 bool truncp;
kono
parents:
diff changeset
275
kono
parents:
diff changeset
276 m1 = TYPE_MODE (vectype_out);
kono
parents:
diff changeset
277 m2 = TYPE_MODE (vectype_in);
kono
parents:
diff changeset
278
kono
parents:
diff changeset
279 /* First check if we can done conversion directly. */
kono
parents:
diff changeset
280 if ((code == FIX_TRUNC_EXPR
kono
parents:
diff changeset
281 && can_fix_p (m1,m2,TYPE_UNSIGNED (vectype_out), &truncp)
kono
parents:
diff changeset
282 != CODE_FOR_nothing)
kono
parents:
diff changeset
283 || (code == FLOAT_EXPR
kono
parents:
diff changeset
284 && can_float_p (m1,m2,TYPE_UNSIGNED (vectype_in))
kono
parents:
diff changeset
285 != CODE_FOR_nothing))
kono
parents:
diff changeset
286 {
kono
parents:
diff changeset
287 *code1 = code;
kono
parents:
diff changeset
288 return true;
kono
parents:
diff changeset
289 }
kono
parents:
diff changeset
290
kono
parents:
diff changeset
291 /* Now check for builtin. */
kono
parents:
diff changeset
292 if (targetm.vectorize.builtin_conversion
kono
parents:
diff changeset
293 && targetm.vectorize.builtin_conversion (code, vectype_out, vectype_in))
kono
parents:
diff changeset
294 {
kono
parents:
diff changeset
295 *code1 = CALL_EXPR;
kono
parents:
diff changeset
296 *decl = targetm.vectorize.builtin_conversion (code, vectype_out,
kono
parents:
diff changeset
297 vectype_in);
kono
parents:
diff changeset
298 return true;
kono
parents:
diff changeset
299 }
kono
parents:
diff changeset
300 return false;
kono
parents:
diff changeset
301 }
kono
parents:
diff changeset
302
kono
parents:
diff changeset
303 /* Return TRUE if appropriate vector insn is available
kono
parents:
diff changeset
304 for vector comparison expr with vector type VALUE_TYPE
kono
parents:
diff changeset
305 and resulting mask with MASK_TYPE. */
kono
parents:
diff changeset
306
kono
parents:
diff changeset
307 bool
kono
parents:
diff changeset
308 expand_vec_cmp_expr_p (tree value_type, tree mask_type, enum tree_code code)
kono
parents:
diff changeset
309 {
kono
parents:
diff changeset
310 if (get_vec_cmp_icode (TYPE_MODE (value_type), TYPE_MODE (mask_type),
kono
parents:
diff changeset
311 TYPE_UNSIGNED (value_type)) != CODE_FOR_nothing)
kono
parents:
diff changeset
312 return true;
kono
parents:
diff changeset
313 if ((code == EQ_EXPR || code == NE_EXPR)
kono
parents:
diff changeset
314 && (get_vec_cmp_eq_icode (TYPE_MODE (value_type), TYPE_MODE (mask_type))
kono
parents:
diff changeset
315 != CODE_FOR_nothing))
kono
parents:
diff changeset
316 return true;
kono
parents:
diff changeset
317 return false;
kono
parents:
diff changeset
318 }
kono
parents:
diff changeset
319
kono
parents:
diff changeset
320 /* Return TRUE iff, appropriate vector insns are available
kono
parents:
diff changeset
321 for vector cond expr with vector type VALUE_TYPE and a comparison
kono
parents:
diff changeset
322 with operand vector types in CMP_OP_TYPE. */
kono
parents:
diff changeset
323
kono
parents:
diff changeset
324 bool
kono
parents:
diff changeset
325 expand_vec_cond_expr_p (tree value_type, tree cmp_op_type, enum tree_code code)
kono
parents:
diff changeset
326 {
kono
parents:
diff changeset
327 machine_mode value_mode = TYPE_MODE (value_type);
kono
parents:
diff changeset
328 machine_mode cmp_op_mode = TYPE_MODE (cmp_op_type);
kono
parents:
diff changeset
329 if (VECTOR_BOOLEAN_TYPE_P (cmp_op_type)
kono
parents:
diff changeset
330 && get_vcond_mask_icode (TYPE_MODE (value_type),
kono
parents:
diff changeset
331 TYPE_MODE (cmp_op_type)) != CODE_FOR_nothing)
kono
parents:
diff changeset
332 return true;
kono
parents:
diff changeset
333
kono
parents:
diff changeset
334 if (GET_MODE_SIZE (value_mode) != GET_MODE_SIZE (cmp_op_mode)
kono
parents:
diff changeset
335 || GET_MODE_NUNITS (value_mode) != GET_MODE_NUNITS (cmp_op_mode))
kono
parents:
diff changeset
336 return false;
kono
parents:
diff changeset
337
kono
parents:
diff changeset
338 if (get_vcond_icode (TYPE_MODE (value_type), TYPE_MODE (cmp_op_type),
kono
parents:
diff changeset
339 TYPE_UNSIGNED (cmp_op_type)) == CODE_FOR_nothing
kono
parents:
diff changeset
340 && ((code != EQ_EXPR && code != NE_EXPR)
kono
parents:
diff changeset
341 || get_vcond_eq_icode (TYPE_MODE (value_type),
kono
parents:
diff changeset
342 TYPE_MODE (cmp_op_type)) == CODE_FOR_nothing))
kono
parents:
diff changeset
343 return false;
kono
parents:
diff changeset
344
kono
parents:
diff changeset
345 return true;
kono
parents:
diff changeset
346 }
kono
parents:
diff changeset
347
kono
parents:
diff changeset
348 /* Use the current target and options to initialize
kono
parents:
diff changeset
349 TREE_OPTIMIZATION_OPTABS (OPTNODE). */
kono
parents:
diff changeset
350
kono
parents:
diff changeset
351 void
kono
parents:
diff changeset
352 init_tree_optimization_optabs (tree optnode)
kono
parents:
diff changeset
353 {
kono
parents:
diff changeset
354 /* Quick exit if we have already computed optabs for this target. */
kono
parents:
diff changeset
355 if (TREE_OPTIMIZATION_BASE_OPTABS (optnode) == this_target_optabs)
kono
parents:
diff changeset
356 return;
kono
parents:
diff changeset
357
kono
parents:
diff changeset
358 /* Forget any previous information and set up for the current target. */
kono
parents:
diff changeset
359 TREE_OPTIMIZATION_BASE_OPTABS (optnode) = this_target_optabs;
kono
parents:
diff changeset
360 struct target_optabs *tmp_optabs = (struct target_optabs *)
kono
parents:
diff changeset
361 TREE_OPTIMIZATION_OPTABS (optnode);
kono
parents:
diff changeset
362 if (tmp_optabs)
kono
parents:
diff changeset
363 memset (tmp_optabs, 0, sizeof (struct target_optabs));
kono
parents:
diff changeset
364 else
kono
parents:
diff changeset
365 tmp_optabs = ggc_alloc<target_optabs> ();
kono
parents:
diff changeset
366
kono
parents:
diff changeset
367 /* Generate a new set of optabs into tmp_optabs. */
kono
parents:
diff changeset
368 init_all_optabs (tmp_optabs);
kono
parents:
diff changeset
369
kono
parents:
diff changeset
370 /* If the optabs changed, record it. */
kono
parents:
diff changeset
371 if (memcmp (tmp_optabs, this_target_optabs, sizeof (struct target_optabs)))
kono
parents:
diff changeset
372 TREE_OPTIMIZATION_OPTABS (optnode) = tmp_optabs;
kono
parents:
diff changeset
373 else
kono
parents:
diff changeset
374 {
kono
parents:
diff changeset
375 TREE_OPTIMIZATION_OPTABS (optnode) = NULL;
kono
parents:
diff changeset
376 ggc_free (tmp_optabs);
kono
parents:
diff changeset
377 }
kono
parents:
diff changeset
378 }
kono
parents:
diff changeset
379
kono
parents:
diff changeset
380 /* Return TRUE if the target has support for vector right shift of an
kono
parents:
diff changeset
381 operand of type TYPE. If OT_TYPE is OPTAB_DEFAULT, check for existence
kono
parents:
diff changeset
382 of a shift by either a scalar or a vector. Otherwise, check only
kono
parents:
diff changeset
383 for a shift that matches OT_TYPE. */
kono
parents:
diff changeset
384
kono
parents:
diff changeset
385 bool
kono
parents:
diff changeset
386 target_supports_op_p (tree type, enum tree_code code,
kono
parents:
diff changeset
387 enum optab_subtype ot_subtype)
kono
parents:
diff changeset
388 {
kono
parents:
diff changeset
389 optab ot = optab_for_tree_code (code, type, ot_subtype);
kono
parents:
diff changeset
390 return (ot != unknown_optab
kono
parents:
diff changeset
391 && optab_handler (ot, TYPE_MODE (type)) != CODE_FOR_nothing);
kono
parents:
diff changeset
392 }
kono
parents:
diff changeset
393