2010-07-27 Paolo Carlini <paolo.carlini@oracle.com>
[official-gcc/alias-decl.git] / gcc / optabs.h
blob547339bcee66ecfd53e3fccf586c2789a0af4e3c
1 /* Definitions for code generation pass of GNU compiler.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
3 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
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/>. */
21 #ifndef GCC_OPTABS_H
22 #define GCC_OPTABS_H
24 #include "insn-codes.h"
26 /* Optabs are tables saying how to generate insn bodies
27 for various machine modes and numbers of operands.
28 Each optab applies to one operation.
30 For example, add_optab applies to addition.
32 The `lib_call' slot is the name of the library function that
33 can be used to perform the operation.
35 A few optabs, such as move_optab, are used by special code. */
37 struct optab_handlers
39 /* I - CODE_FOR_nothing, where I is either the insn code of the
40 associated insn generator or CODE_FOR_nothing if there is no such
41 insn on the target machine. */
42 int insn_code;
45 struct optab_d
47 enum rtx_code code;
48 char libcall_suffix;
49 const char *libcall_basename;
50 void (*libcall_gen)(struct optab_d *, const char *name, char suffix,
51 enum machine_mode);
52 struct optab_handlers handlers[NUM_MACHINE_MODES];
54 typedef struct optab_d * optab;
56 /* A convert_optab is for some sort of conversion operation between
57 modes. The first array index is the destination mode, the second
58 is the source mode. */
59 struct convert_optab_d
61 enum rtx_code code;
62 const char *libcall_basename;
63 void (*libcall_gen)(struct convert_optab_d *, const char *name,
64 enum machine_mode,
65 enum machine_mode);
66 struct optab_handlers handlers[NUM_MACHINE_MODES][NUM_MACHINE_MODES];
68 typedef struct convert_optab_d *convert_optab;
70 /* Given an enum insn_code, access the function to construct
71 the body of that kind of insn. */
72 #define GEN_FCN(CODE) (insn_data[CODE].genfun)
74 /* Enumeration of valid indexes into optab_table. */
75 enum optab_index
77 /* Fixed-point operators with signed/unsigned saturation */
78 OTI_ssadd,
79 OTI_usadd,
80 OTI_sssub,
81 OTI_ussub,
82 OTI_ssmul,
83 OTI_usmul,
84 OTI_ssdiv,
85 OTI_usdiv,
86 OTI_ssneg,
87 OTI_usneg,
88 OTI_ssashl,
89 OTI_usashl,
91 OTI_add,
92 OTI_addv,
93 OTI_sub,
94 OTI_subv,
96 /* Signed and fp multiply */
97 OTI_smul,
98 OTI_smulv,
99 /* Signed multiply, return high word */
100 OTI_smul_highpart,
101 OTI_umul_highpart,
102 /* Signed multiply with result one machine mode wider than args */
103 OTI_smul_widen,
104 OTI_umul_widen,
105 /* Widening multiply of one unsigned and one signed operand. */
106 OTI_usmul_widen,
107 /* Signed multiply and add with the result and addend one machine mode
108 wider than the multiplicand and multiplier. */
109 OTI_smadd_widen,
110 /* Unsigned multiply and add with the result and addend one machine mode
111 wider than the multiplicand and multiplier. */
112 OTI_umadd_widen,
113 /* Signed multiply and add with the result and addend one machine mode
114 wider than the multiplicand and multiplier.
115 All involved operations are saturating. */
116 OTI_ssmadd_widen,
117 /* Unsigned multiply and add with the result and addend one machine mode
118 wider than the multiplicand and multiplier.
119 All involved operations are saturating. */
120 OTI_usmadd_widen,
121 /* Signed multiply and subtract the result and minuend one machine mode
122 wider than the multiplicand and multiplier. */
123 OTI_smsub_widen,
124 /* Unsigned multiply and subtract the result and minuend one machine mode
125 wider than the multiplicand and multiplier. */
126 OTI_umsub_widen,
127 /* Signed multiply and subtract the result and minuend one machine mode
128 wider than the multiplicand and multiplier.
129 All involved operations are saturating. */
130 OTI_ssmsub_widen,
131 /* Unsigned multiply and subtract the result and minuend one machine mode
132 wider than the multiplicand and multiplier.
133 All involved operations are saturating. */
134 OTI_usmsub_widen,
136 /* Signed divide */
137 OTI_sdiv,
138 OTI_sdivv,
139 /* Signed divide-and-remainder in one */
140 OTI_sdivmod,
141 OTI_udiv,
142 OTI_udivmod,
143 /* Signed remainder */
144 OTI_smod,
145 OTI_umod,
146 /* Floating point remainder functions */
147 OTI_fmod,
148 OTI_remainder,
149 /* Convert float to integer in float fmt */
150 OTI_ftrunc,
152 /* Logical and */
153 OTI_and,
154 /* Logical or */
155 OTI_ior,
156 /* Logical xor */
157 OTI_xor,
159 /* Arithmetic shift left */
160 OTI_ashl,
161 /* Logical shift right */
162 OTI_lshr,
163 /* Arithmetic shift right */
164 OTI_ashr,
165 /* Rotate left */
166 OTI_rotl,
167 /* Rotate right */
168 OTI_rotr,
170 /* Arithmetic shift left of vector by vector */
171 OTI_vashl,
172 /* Logical shift right of vector by vector */
173 OTI_vlshr,
174 /* Arithmetic shift right of vector by vector */
175 OTI_vashr,
176 /* Rotate left of vector by vector */
177 OTI_vrotl,
178 /* Rotate right of vector by vector */
179 OTI_vrotr,
181 /* Signed and floating-point minimum value */
182 OTI_smin,
183 /* Signed and floating-point maximum value */
184 OTI_smax,
185 /* Unsigned minimum value */
186 OTI_umin,
187 /* Unsigned maximum value */
188 OTI_umax,
189 /* Power */
190 OTI_pow,
191 /* Arc tangent of y/x */
192 OTI_atan2,
194 /* Move instruction. */
195 OTI_mov,
196 /* Move, preserving high part of register. */
197 OTI_movstrict,
198 /* Move, with a misaligned memory. */
199 OTI_movmisalign,
200 /* Nontemporal store. */
201 OTI_storent,
203 /* Unary operations */
204 /* Negation */
205 OTI_neg,
206 OTI_negv,
207 /* Abs value */
208 OTI_abs,
209 OTI_absv,
210 /* Byteswap */
211 OTI_bswap,
212 /* Bitwise not */
213 OTI_one_cmpl,
214 /* Bit scanning and counting */
215 OTI_ffs,
216 OTI_clz,
217 OTI_ctz,
218 OTI_popcount,
219 OTI_parity,
220 /* Square root */
221 OTI_sqrt,
222 /* Sine-Cosine */
223 OTI_sincos,
224 /* Sine */
225 OTI_sin,
226 /* Inverse sine */
227 OTI_asin,
228 /* Cosine */
229 OTI_cos,
230 /* Inverse cosine */
231 OTI_acos,
232 /* Exponential */
233 OTI_exp,
234 /* Base-10 Exponential */
235 OTI_exp10,
236 /* Base-2 Exponential */
237 OTI_exp2,
238 /* Exponential - 1*/
239 OTI_expm1,
240 /* Load exponent of a floating point number */
241 OTI_ldexp,
242 /* Multiply floating-point number by integral power of radix */
243 OTI_scalb,
244 /* Mantissa of a floating-point number */
245 OTI_significand,
246 /* Radix-independent exponent */
247 OTI_logb,
248 OTI_ilogb,
249 /* Natural Logarithm */
250 OTI_log,
251 /* Base-10 Logarithm */
252 OTI_log10,
253 /* Base-2 Logarithm */
254 OTI_log2,
255 /* logarithm of 1 plus argument */
256 OTI_log1p,
257 /* Rounding functions */
258 OTI_floor,
259 OTI_ceil,
260 OTI_btrunc,
261 OTI_round,
262 OTI_nearbyint,
263 OTI_rint,
264 /* Tangent */
265 OTI_tan,
266 /* Inverse tangent */
267 OTI_atan,
268 /* Copy sign */
269 OTI_copysign,
270 /* Signbit */
271 OTI_signbit,
272 /* Test for infinite value */
273 OTI_isinf,
275 /* Compare insn; two operands. Used only for libcalls. */
276 OTI_cmp,
277 OTI_ucmp,
279 /* Floating point comparison optabs - used primarily for libfuncs */
280 OTI_eq,
281 OTI_ne,
282 OTI_gt,
283 OTI_ge,
284 OTI_lt,
285 OTI_le,
286 OTI_unord,
288 /* String length */
289 OTI_strlen,
291 /* Combined compare & jump/move/store flags/trap operations. */
292 OTI_cbranch,
293 OTI_cmov,
294 OTI_cstore,
295 OTI_ctrap,
297 /* Push instruction. */
298 OTI_push,
300 /* Conditional add instruction. */
301 OTI_addcc,
303 /* Reduction operations on a vector operand. */
304 OTI_reduc_smax,
305 OTI_reduc_umax,
306 OTI_reduc_smin,
307 OTI_reduc_umin,
308 OTI_reduc_splus,
309 OTI_reduc_uplus,
311 /* Summation, with result machine mode one or more wider than args. */
312 OTI_ssum_widen,
313 OTI_usum_widen,
315 /* Dot product, with result machine mode one or more wider than args. */
316 OTI_sdot_prod,
317 OTI_udot_prod,
319 /* Set specified field of vector operand. */
320 OTI_vec_set,
321 /* Extract specified field of vector operand. */
322 OTI_vec_extract,
323 /* Extract even/odd fields of vector operands. */
324 OTI_vec_extract_even,
325 OTI_vec_extract_odd,
326 /* Interleave fields of vector operands. */
327 OTI_vec_interleave_high,
328 OTI_vec_interleave_low,
329 /* Initialize vector operand. */
330 OTI_vec_init,
331 /* Whole vector shift. The shift amount is in bits. */
332 OTI_vec_shl,
333 OTI_vec_shr,
334 /* Extract specified elements from vectors, for vector load. */
335 OTI_vec_realign_load,
336 /* Widening multiplication.
337 The high/low part of the resulting vector of products is returned. */
338 OTI_vec_widen_umult_hi,
339 OTI_vec_widen_umult_lo,
340 OTI_vec_widen_smult_hi,
341 OTI_vec_widen_smult_lo,
342 /* Extract and widen the high/low part of a vector of signed or
343 floating point elements. */
344 OTI_vec_unpacks_hi,
345 OTI_vec_unpacks_lo,
346 /* Extract and widen the high/low part of a vector of unsigned
347 elements. */
348 OTI_vec_unpacku_hi,
349 OTI_vec_unpacku_lo,
351 /* Extract, convert to floating point and widen the high/low part of
352 a vector of signed or unsigned integer elements. */
353 OTI_vec_unpacks_float_hi,
354 OTI_vec_unpacks_float_lo,
355 OTI_vec_unpacku_float_hi,
356 OTI_vec_unpacku_float_lo,
358 /* Narrow (demote) and merge the elements of two vectors. */
359 OTI_vec_pack_trunc,
360 OTI_vec_pack_usat,
361 OTI_vec_pack_ssat,
363 /* Convert to signed/unsigned integer, narrow and merge elements
364 of two vectors of floating point elements. */
365 OTI_vec_pack_sfix_trunc,
366 OTI_vec_pack_ufix_trunc,
368 /* Perform a raise to the power of integer. */
369 OTI_powi,
371 OTI_MAX
374 #define ssadd_optab (&optab_table[OTI_ssadd])
375 #define usadd_optab (&optab_table[OTI_usadd])
376 #define sssub_optab (&optab_table[OTI_sssub])
377 #define ussub_optab (&optab_table[OTI_ussub])
378 #define ssmul_optab (&optab_table[OTI_ssmul])
379 #define usmul_optab (&optab_table[OTI_usmul])
380 #define ssdiv_optab (&optab_table[OTI_ssdiv])
381 #define usdiv_optab (&optab_table[OTI_usdiv])
382 #define ssneg_optab (&optab_table[OTI_ssneg])
383 #define usneg_optab (&optab_table[OTI_usneg])
384 #define ssashl_optab (&optab_table[OTI_ssashl])
385 #define usashl_optab (&optab_table[OTI_usashl])
387 #define add_optab (&optab_table[OTI_add])
388 #define sub_optab (&optab_table[OTI_sub])
389 #define smul_optab (&optab_table[OTI_smul])
390 #define addv_optab (&optab_table[OTI_addv])
391 #define subv_optab (&optab_table[OTI_subv])
392 #define smul_highpart_optab (&optab_table[OTI_smul_highpart])
393 #define umul_highpart_optab (&optab_table[OTI_umul_highpart])
394 #define smul_widen_optab (&optab_table[OTI_smul_widen])
395 #define umul_widen_optab (&optab_table[OTI_umul_widen])
396 #define usmul_widen_optab (&optab_table[OTI_usmul_widen])
397 #define smadd_widen_optab (&optab_table[OTI_smadd_widen])
398 #define umadd_widen_optab (&optab_table[OTI_umadd_widen])
399 #define ssmadd_widen_optab (&optab_table[OTI_ssmadd_widen])
400 #define usmadd_widen_optab (&optab_table[OTI_usmadd_widen])
401 #define smsub_widen_optab (&optab_table[OTI_smsub_widen])
402 #define umsub_widen_optab (&optab_table[OTI_umsub_widen])
403 #define ssmsub_widen_optab (&optab_table[OTI_ssmsub_widen])
404 #define usmsub_widen_optab (&optab_table[OTI_usmsub_widen])
405 #define sdiv_optab (&optab_table[OTI_sdiv])
406 #define smulv_optab (&optab_table[OTI_smulv])
407 #define sdivv_optab (&optab_table[OTI_sdivv])
408 #define sdivmod_optab (&optab_table[OTI_sdivmod])
409 #define udiv_optab (&optab_table[OTI_udiv])
410 #define udivmod_optab (&optab_table[OTI_udivmod])
411 #define smod_optab (&optab_table[OTI_smod])
412 #define umod_optab (&optab_table[OTI_umod])
413 #define fmod_optab (&optab_table[OTI_fmod])
414 #define remainder_optab (&optab_table[OTI_remainder])
415 #define ftrunc_optab (&optab_table[OTI_ftrunc])
416 #define and_optab (&optab_table[OTI_and])
417 #define ior_optab (&optab_table[OTI_ior])
418 #define xor_optab (&optab_table[OTI_xor])
419 #define ashl_optab (&optab_table[OTI_ashl])
420 #define lshr_optab (&optab_table[OTI_lshr])
421 #define ashr_optab (&optab_table[OTI_ashr])
422 #define rotl_optab (&optab_table[OTI_rotl])
423 #define rotr_optab (&optab_table[OTI_rotr])
424 #define vashl_optab (&optab_table[OTI_vashl])
425 #define vlshr_optab (&optab_table[OTI_vlshr])
426 #define vashr_optab (&optab_table[OTI_vashr])
427 #define vrotl_optab (&optab_table[OTI_vrotl])
428 #define vrotr_optab (&optab_table[OTI_vrotr])
429 #define smin_optab (&optab_table[OTI_smin])
430 #define smax_optab (&optab_table[OTI_smax])
431 #define umin_optab (&optab_table[OTI_umin])
432 #define umax_optab (&optab_table[OTI_umax])
433 #define pow_optab (&optab_table[OTI_pow])
434 #define atan2_optab (&optab_table[OTI_atan2])
436 #define mov_optab (&optab_table[OTI_mov])
437 #define movstrict_optab (&optab_table[OTI_movstrict])
438 #define movmisalign_optab (&optab_table[OTI_movmisalign])
439 #define storent_optab (&optab_table[OTI_storent])
441 #define neg_optab (&optab_table[OTI_neg])
442 #define negv_optab (&optab_table[OTI_negv])
443 #define abs_optab (&optab_table[OTI_abs])
444 #define absv_optab (&optab_table[OTI_absv])
445 #define one_cmpl_optab (&optab_table[OTI_one_cmpl])
446 #define bswap_optab (&optab_table[OTI_bswap])
447 #define ffs_optab (&optab_table[OTI_ffs])
448 #define clz_optab (&optab_table[OTI_clz])
449 #define ctz_optab (&optab_table[OTI_ctz])
450 #define popcount_optab (&optab_table[OTI_popcount])
451 #define parity_optab (&optab_table[OTI_parity])
452 #define sqrt_optab (&optab_table[OTI_sqrt])
453 #define sincos_optab (&optab_table[OTI_sincos])
454 #define sin_optab (&optab_table[OTI_sin])
455 #define asin_optab (&optab_table[OTI_asin])
456 #define cos_optab (&optab_table[OTI_cos])
457 #define acos_optab (&optab_table[OTI_acos])
458 #define exp_optab (&optab_table[OTI_exp])
459 #define exp10_optab (&optab_table[OTI_exp10])
460 #define exp2_optab (&optab_table[OTI_exp2])
461 #define expm1_optab (&optab_table[OTI_expm1])
462 #define ldexp_optab (&optab_table[OTI_ldexp])
463 #define scalb_optab (&optab_table[OTI_scalb])
464 #define significand_optab (&optab_table[OTI_significand])
465 #define logb_optab (&optab_table[OTI_logb])
466 #define ilogb_optab (&optab_table[OTI_ilogb])
467 #define log_optab (&optab_table[OTI_log])
468 #define log10_optab (&optab_table[OTI_log10])
469 #define log2_optab (&optab_table[OTI_log2])
470 #define log1p_optab (&optab_table[OTI_log1p])
471 #define floor_optab (&optab_table[OTI_floor])
472 #define ceil_optab (&optab_table[OTI_ceil])
473 #define btrunc_optab (&optab_table[OTI_btrunc])
474 #define round_optab (&optab_table[OTI_round])
475 #define nearbyint_optab (&optab_table[OTI_nearbyint])
476 #define rint_optab (&optab_table[OTI_rint])
477 #define tan_optab (&optab_table[OTI_tan])
478 #define atan_optab (&optab_table[OTI_atan])
479 #define copysign_optab (&optab_table[OTI_copysign])
480 #define signbit_optab (&optab_table[OTI_signbit])
481 #define isinf_optab (&optab_table[OTI_isinf])
483 #define cmp_optab (&optab_table[OTI_cmp])
484 #define ucmp_optab (&optab_table[OTI_ucmp])
486 #define eq_optab (&optab_table[OTI_eq])
487 #define ne_optab (&optab_table[OTI_ne])
488 #define gt_optab (&optab_table[OTI_gt])
489 #define ge_optab (&optab_table[OTI_ge])
490 #define lt_optab (&optab_table[OTI_lt])
491 #define le_optab (&optab_table[OTI_le])
492 #define unord_optab (&optab_table[OTI_unord])
494 #define strlen_optab (&optab_table[OTI_strlen])
496 #define cbranch_optab (&optab_table[OTI_cbranch])
497 #define cmov_optab (&optab_table[OTI_cmov])
498 #define cstore_optab (&optab_table[OTI_cstore])
499 #define ctrap_optab (&optab_table[OTI_ctrap])
501 #define push_optab (&optab_table[OTI_push])
502 #define addcc_optab (&optab_table[OTI_addcc])
504 #define reduc_smax_optab (&optab_table[OTI_reduc_smax])
505 #define reduc_umax_optab (&optab_table[OTI_reduc_umax])
506 #define reduc_smin_optab (&optab_table[OTI_reduc_smin])
507 #define reduc_umin_optab (&optab_table[OTI_reduc_umin])
508 #define reduc_splus_optab (&optab_table[OTI_reduc_splus])
509 #define reduc_uplus_optab (&optab_table[OTI_reduc_uplus])
511 #define ssum_widen_optab (&optab_table[OTI_ssum_widen])
512 #define usum_widen_optab (&optab_table[OTI_usum_widen])
513 #define sdot_prod_optab (&optab_table[OTI_sdot_prod])
514 #define udot_prod_optab (&optab_table[OTI_udot_prod])
516 #define vec_set_optab (&optab_table[OTI_vec_set])
517 #define vec_extract_optab (&optab_table[OTI_vec_extract])
518 #define vec_extract_even_optab (&optab_table[OTI_vec_extract_even])
519 #define vec_extract_odd_optab (&optab_table[OTI_vec_extract_odd])
520 #define vec_interleave_high_optab (&optab_table[OTI_vec_interleave_high])
521 #define vec_interleave_low_optab (&optab_table[OTI_vec_interleave_low])
522 #define vec_init_optab (&optab_table[OTI_vec_init])
523 #define vec_shl_optab (&optab_table[OTI_vec_shl])
524 #define vec_shr_optab (&optab_table[OTI_vec_shr])
525 #define vec_realign_load_optab (&optab_table[OTI_vec_realign_load])
526 #define vec_widen_umult_hi_optab (&optab_table[OTI_vec_widen_umult_hi])
527 #define vec_widen_umult_lo_optab (&optab_table[OTI_vec_widen_umult_lo])
528 #define vec_widen_smult_hi_optab (&optab_table[OTI_vec_widen_smult_hi])
529 #define vec_widen_smult_lo_optab (&optab_table[OTI_vec_widen_smult_lo])
530 #define vec_unpacks_hi_optab (&optab_table[OTI_vec_unpacks_hi])
531 #define vec_unpacks_lo_optab (&optab_table[OTI_vec_unpacks_lo])
532 #define vec_unpacku_hi_optab (&optab_table[OTI_vec_unpacku_hi])
533 #define vec_unpacku_lo_optab (&optab_table[OTI_vec_unpacku_lo])
534 #define vec_unpacks_float_hi_optab (&optab_table[OTI_vec_unpacks_float_hi])
535 #define vec_unpacks_float_lo_optab (&optab_table[OTI_vec_unpacks_float_lo])
536 #define vec_unpacku_float_hi_optab (&optab_table[OTI_vec_unpacku_float_hi])
537 #define vec_unpacku_float_lo_optab (&optab_table[OTI_vec_unpacku_float_lo])
538 #define vec_pack_trunc_optab (&optab_table[OTI_vec_pack_trunc])
539 #define vec_pack_ssat_optab (&optab_table[OTI_vec_pack_ssat])
540 #define vec_pack_usat_optab (&optab_table[OTI_vec_pack_usat])
541 #define vec_pack_sfix_trunc_optab (&optab_table[OTI_vec_pack_sfix_trunc])
542 #define vec_pack_ufix_trunc_optab (&optab_table[OTI_vec_pack_ufix_trunc])
544 #define powi_optab (&optab_table[OTI_powi])
546 /* Conversion optabs have their own table and indexes. */
547 enum convert_optab_index
549 COI_sext,
550 COI_zext,
551 COI_trunc,
553 COI_sfix,
554 COI_ufix,
556 COI_sfixtrunc,
557 COI_ufixtrunc,
559 COI_sfloat,
560 COI_ufloat,
562 COI_lrint,
563 COI_lround,
564 COI_lfloor,
565 COI_lceil,
567 COI_fract,
568 COI_fractuns,
569 COI_satfract,
570 COI_satfractuns,
572 COI_MAX
575 #define sext_optab (&convert_optab_table[COI_sext])
576 #define zext_optab (&convert_optab_table[COI_zext])
577 #define trunc_optab (&convert_optab_table[COI_trunc])
578 #define sfix_optab (&convert_optab_table[COI_sfix])
579 #define ufix_optab (&convert_optab_table[COI_ufix])
580 #define sfixtrunc_optab (&convert_optab_table[COI_sfixtrunc])
581 #define ufixtrunc_optab (&convert_optab_table[COI_ufixtrunc])
582 #define sfloat_optab (&convert_optab_table[COI_sfloat])
583 #define ufloat_optab (&convert_optab_table[COI_ufloat])
584 #define lrint_optab (&convert_optab_table[COI_lrint])
585 #define lround_optab (&convert_optab_table[COI_lround])
586 #define lfloor_optab (&convert_optab_table[COI_lfloor])
587 #define lceil_optab (&convert_optab_table[COI_lceil])
588 #define fract_optab (&convert_optab_table[COI_fract])
589 #define fractuns_optab (&convert_optab_table[COI_fractuns])
590 #define satfract_optab (&convert_optab_table[COI_satfract])
591 #define satfractuns_optab (&convert_optab_table[COI_satfractuns])
593 /* Contains the optab used for each rtx code. */
594 extern optab code_to_optab[NUM_RTX_CODE + 1];
597 typedef rtx (*rtxfun) (rtx);
599 /* Enumerates operations that have a named .md pattern associated
600 with them, but which are not implemented as library functions. */
601 enum direct_optab_index
603 #ifdef HAVE_conditional_move
604 /* Conditional move operations. */
605 DOI_movcc,
606 #endif
608 /* Operations that use a scratch register to perform input and output
609 reloads of special objects. */
610 DOI_reload_in,
611 DOI_reload_out,
613 /* Vector conditional operations. */
614 DOI_vcond,
615 DOI_vcondu,
617 /* Block move operation. */
618 DOI_movmem,
620 /* Block set operation. */
621 DOI_setmem,
623 /* Various types of block compare operation. */
624 DOI_cmpstr,
625 DOI_cmpstrn,
626 DOI_cmpmem,
628 /* Synchronization primitives. This first set is atomic operation for
629 which we don't care about the resulting value. */
630 DOI_sync_add,
631 DOI_sync_sub,
632 DOI_sync_ior,
633 DOI_sync_and,
634 DOI_sync_xor,
635 DOI_sync_nand,
637 /* This second set is atomic operations in which we return the value
638 that existed in memory before the operation. */
639 DOI_sync_old_add,
640 DOI_sync_old_sub,
641 DOI_sync_old_ior,
642 DOI_sync_old_and,
643 DOI_sync_old_xor,
644 DOI_sync_old_nand,
646 /* This third set is atomic operations in which we return the value
647 that resulted after performing the operation. */
648 DOI_sync_new_add,
649 DOI_sync_new_sub,
650 DOI_sync_new_ior,
651 DOI_sync_new_and,
652 DOI_sync_new_xor,
653 DOI_sync_new_nand,
655 /* Atomic compare and swap. */
656 DOI_sync_compare_and_swap,
658 /* Atomic exchange with acquire semantics. */
659 DOI_sync_lock_test_and_set,
661 /* Atomic clear with release semantics. */
662 DOI_sync_lock_release,
664 DOI_MAX
667 /* A structure that says which insn should be used to perform an operation
668 in a particular mode. */
669 struct direct_optab_d
671 struct optab_handlers handlers[NUM_MACHINE_MODES];
673 typedef struct direct_optab_d *direct_optab;
675 #ifdef HAVE_conditional_move
676 #define movcc_optab (&direct_optab_table[(int) DOI_movcc])
677 #endif
678 #define reload_in_optab (&direct_optab_table[(int) DOI_reload_in])
679 #define reload_out_optab (&direct_optab_table[(int) DOI_reload_out])
680 #define vcond_optab (&direct_optab_table[(int) DOI_vcond])
681 #define vcondu_optab (&direct_optab_table[(int) DOI_vcondu])
682 #define movmem_optab (&direct_optab_table[(int) DOI_movmem])
683 #define setmem_optab (&direct_optab_table[(int) DOI_setmem])
684 #define cmpstr_optab (&direct_optab_table[(int) DOI_cmpstr])
685 #define cmpstrn_optab (&direct_optab_table[(int) DOI_cmpstrn])
686 #define cmpmem_optab (&direct_optab_table[(int) DOI_cmpmem])
687 #define sync_add_optab (&direct_optab_table[(int) DOI_sync_add])
688 #define sync_sub_optab (&direct_optab_table[(int) DOI_sync_sub])
689 #define sync_ior_optab (&direct_optab_table[(int) DOI_sync_ior])
690 #define sync_and_optab (&direct_optab_table[(int) DOI_sync_and])
691 #define sync_xor_optab (&direct_optab_table[(int) DOI_sync_xor])
692 #define sync_nand_optab (&direct_optab_table[(int) DOI_sync_nand])
693 #define sync_old_add_optab (&direct_optab_table[(int) DOI_sync_old_add])
694 #define sync_old_sub_optab (&direct_optab_table[(int) DOI_sync_old_sub])
695 #define sync_old_ior_optab (&direct_optab_table[(int) DOI_sync_old_ior])
696 #define sync_old_and_optab (&direct_optab_table[(int) DOI_sync_old_and])
697 #define sync_old_xor_optab (&direct_optab_table[(int) DOI_sync_old_xor])
698 #define sync_old_nand_optab (&direct_optab_table[(int) DOI_sync_old_nand])
699 #define sync_new_add_optab (&direct_optab_table[(int) DOI_sync_new_add])
700 #define sync_new_sub_optab (&direct_optab_table[(int) DOI_sync_new_sub])
701 #define sync_new_ior_optab (&direct_optab_table[(int) DOI_sync_new_ior])
702 #define sync_new_and_optab (&direct_optab_table[(int) DOI_sync_new_and])
703 #define sync_new_xor_optab (&direct_optab_table[(int) DOI_sync_new_xor])
704 #define sync_new_nand_optab (&direct_optab_table[(int) DOI_sync_new_nand])
705 #define sync_compare_and_swap_optab \
706 (&direct_optab_table[(int) DOI_sync_compare_and_swap])
707 #define sync_lock_test_and_set_optab \
708 (&direct_optab_table[(int) DOI_sync_lock_test_and_set])
709 #define sync_lock_release_optab \
710 (&direct_optab_table[(int) DOI_sync_lock_release])
712 /* Target-dependent globals. */
713 struct target_optabs {
714 /* Tables of patterns that may have an associated libcall. */
715 struct optab_d x_optab_table[(int) OTI_MAX];
717 /* Tables of patterns for converting one mode to another. */
718 struct convert_optab_d x_convert_optab_table[(int) COI_MAX];
720 /* Tables of patterns for direct optabs (i.e. those which cannot be
721 implemented using a libcall). */
722 struct direct_optab_d x_direct_optab_table[(int) DOI_MAX];
725 extern struct target_optabs default_target_optabs;
726 #if SWITCHABLE_TARGET
727 extern struct target_optabs *this_target_optabs;
728 #else
729 #define this_target_optabs (&default_target_optabs)
730 #endif
732 #define optab_table \
733 (this_target_optabs->x_optab_table)
734 #define convert_optab_table \
735 (this_target_optabs->x_convert_optab_table)
736 #define direct_optab_table \
737 (this_target_optabs->x_direct_optab_table)
739 /* Define functions given in optabs.c. */
741 extern rtx expand_widen_pattern_expr (sepops ops, rtx op0, rtx op1, rtx wide_op,
742 rtx target, int unsignedp);
744 extern rtx expand_ternary_op (enum machine_mode mode, optab ternary_optab,
745 rtx op0, rtx op1, rtx op2, rtx target,
746 int unsignedp);
748 /* Expand a binary operation given optab and rtx operands. */
749 extern rtx expand_binop (enum machine_mode, optab, rtx, rtx, rtx, int,
750 enum optab_methods);
752 extern bool force_expand_binop (enum machine_mode, optab, rtx, rtx, rtx, int,
753 enum optab_methods);
755 /* Expand a binary operation with both signed and unsigned forms. */
756 extern rtx sign_expand_binop (enum machine_mode, optab, optab, rtx, rtx,
757 rtx, int, enum optab_methods);
759 /* Generate code to perform an operation on one operand with two results. */
760 extern int expand_twoval_unop (optab, rtx, rtx, rtx, int);
762 /* Generate code to perform an operation on two operands with two results. */
763 extern int expand_twoval_binop (optab, rtx, rtx, rtx, rtx, int);
765 /* Generate code to perform an operation on two operands with two
766 results, using a library function. */
767 extern bool expand_twoval_binop_libfunc (optab, rtx, rtx, rtx, rtx,
768 enum rtx_code);
770 /* Expand a unary arithmetic operation given optab rtx operand. */
771 extern rtx expand_unop (enum machine_mode, optab, rtx, rtx, int);
773 /* Expand the absolute value operation. */
774 extern rtx expand_abs_nojump (enum machine_mode, rtx, rtx, int);
775 extern rtx expand_abs (enum machine_mode, rtx, rtx, int, int);
777 /* Expand the one's complement absolute value operation. */
778 extern rtx expand_one_cmpl_abs_nojump (enum machine_mode, rtx, rtx);
780 /* Expand the copysign operation. */
781 extern rtx expand_copysign (rtx, rtx, rtx);
783 /* Generate an instruction with a given INSN_CODE with an output and
784 an input. */
785 extern void emit_unop_insn (int, rtx, rtx, enum rtx_code);
786 extern bool maybe_emit_unop_insn (int, rtx, rtx, enum rtx_code);
788 /* An extra flag to control optab_for_tree_code's behavior. This is needed to
789 distinguish between machines with a vector shift that takes a scalar for the
790 shift amount vs. machines that take a vector for the shift amount. */
791 enum optab_subtype
793 optab_default,
794 optab_scalar,
795 optab_vector
798 /* Return the optab used for computing the given operation on the type given by
799 the second argument. The third argument distinguishes between the types of
800 vector shifts and rotates */
801 extern optab optab_for_tree_code (enum tree_code, const_tree, enum optab_subtype);
803 /* The various uses that a comparison can have; used by can_compare_p:
804 jumps, conditional moves, store flag operations. */
805 enum can_compare_purpose
807 ccp_jump,
808 ccp_cmov,
809 ccp_store_flag
812 /* Nonzero if a compare of mode MODE can be done straightforwardly
813 (without splitting it into pieces). */
814 extern int can_compare_p (enum rtx_code, enum machine_mode,
815 enum can_compare_purpose);
817 /* Return the INSN_CODE to use for an extend operation. */
818 extern enum insn_code can_extend_p (enum machine_mode, enum machine_mode, int);
820 /* Generate the body of an insn to extend Y (with mode MFROM)
821 into X (with mode MTO). Do zero-extension if UNSIGNEDP is nonzero. */
822 extern rtx gen_extend_insn (rtx, rtx, enum machine_mode,
823 enum machine_mode, int);
825 /* Call this to reset the function entry for one optab. */
826 extern void set_optab_libfunc (optab, enum machine_mode, const char *);
827 extern void set_conv_libfunc (convert_optab, enum machine_mode,
828 enum machine_mode, const char *);
830 /* Generate code for a FIXED_CONVERT_EXPR. */
831 extern void expand_fixed_convert (rtx, rtx, int, int);
833 /* Generate code for a FLOAT_EXPR. */
834 extern void expand_float (rtx, rtx, int);
836 /* Generate code for a FIX_EXPR. */
837 extern void expand_fix (rtx, rtx, int);
839 /* Generate code for float to integral conversion. */
840 extern bool expand_sfix_optab (rtx, rtx, convert_optab);
842 /* Generate code for a widening multiply. */
843 extern rtx expand_widening_mult (enum machine_mode, rtx, rtx, rtx, int, optab);
845 /* Return tree if target supports vector operations for COND_EXPR. */
846 bool expand_vec_cond_expr_p (tree, enum machine_mode);
848 /* Generate code for VEC_COND_EXPR. */
849 extern rtx expand_vec_cond_expr (tree, tree, tree, tree, rtx);
850 /* Generate code for VEC_LSHIFT_EXPR and VEC_RSHIFT_EXPR. */
851 extern rtx expand_vec_shift_expr (sepops, rtx);
853 /* Return the insn used to implement mode MODE of OP, or CODE_FOR_nothing
854 if the target does not have such an insn. */
856 static inline enum insn_code
857 optab_handler (optab op, enum machine_mode mode)
859 return (enum insn_code) (op->handlers[(int) mode].insn_code
860 + (int) CODE_FOR_nothing);
863 /* Record that insn CODE should be used to implement mode MODE of OP. */
865 static inline void
866 set_optab_handler (optab op, enum machine_mode mode, enum insn_code code)
868 op->handlers[(int) mode].insn_code = (int) code - (int) CODE_FOR_nothing;
871 /* Return the insn used to perform conversion OP from mode FROM_MODE
872 to mode TO_MODE; return CODE_FOR_nothing if the target does not have
873 such an insn. */
875 static inline enum insn_code
876 convert_optab_handler (convert_optab op, enum machine_mode to_mode,
877 enum machine_mode from_mode)
879 return ((enum insn_code)
880 (op->handlers[(int) to_mode][(int) from_mode].insn_code
881 + (int) CODE_FOR_nothing));
884 /* Record that insn CODE should be used to perform conversion OP
885 from mode FROM_MODE to mode TO_MODE. */
887 static inline void
888 set_convert_optab_handler (convert_optab op, enum machine_mode to_mode,
889 enum machine_mode from_mode, enum insn_code code)
891 op->handlers[(int) to_mode][(int) from_mode].insn_code
892 = (int) code - (int) CODE_FOR_nothing;
895 /* Return the insn used to implement mode MODE of OP, or CODE_FOR_nothing
896 if the target does not have such an insn. */
898 static inline enum insn_code
899 direct_optab_handler (direct_optab op, enum machine_mode mode)
901 return (enum insn_code) (op->handlers[(int) mode].insn_code
902 + (int) CODE_FOR_nothing);
905 /* Record that insn CODE should be used to implement mode MODE of OP. */
907 static inline void
908 set_direct_optab_handler (direct_optab op, enum machine_mode mode,
909 enum insn_code code)
911 op->handlers[(int) mode].insn_code = (int) code - (int) CODE_FOR_nothing;
914 extern rtx optab_libfunc (optab optab, enum machine_mode mode);
915 extern rtx convert_optab_libfunc (convert_optab optab, enum machine_mode mode1,
916 enum machine_mode mode2);
917 #endif /* GCC_OPTABS_H */