OSDN Git Service

Revert revision 161876.
[pf3gnuchains/gcc-fork.git] / gcc / optabs.h
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.
4
5 This file is part of GCC.
6
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.
11
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.
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 #ifndef GCC_OPTABS_H
22 #define GCC_OPTABS_H
23
24 #include "insn-codes.h"
25
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.
29
30    For example, add_optab applies to addition.
31
32    The `lib_call' slot is the name of the library function that
33    can be used to perform the operation.
34
35    A few optabs, such as move_optab, are used by special code.  */
36
37 struct optab_handlers
38 {
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;
43 };
44
45 struct optab_d
46 {
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];
53 };
54 typedef struct optab_d * optab;
55
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
60 {
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];
67 };
68 typedef struct convert_optab_d *convert_optab;
69
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)
73
74 /* Enumeration of valid indexes into optab_table.  */
75 enum optab_index
76 {
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,
90
91   OTI_add,
92   OTI_addv,
93   OTI_sub,
94   OTI_subv,
95
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,
135
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,
151
152   /* Logical and */
153   OTI_and,
154   /* Logical or */
155   OTI_ior,
156   /* Logical xor */
157   OTI_xor,
158
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,
169
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,
180
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,
193
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,
202
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,
274
275   /* Compare insn; two operands.  Used only for libcalls.  */
276   OTI_cmp,
277   OTI_ucmp,
278
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,
287
288   /* String length */
289   OTI_strlen,
290
291   /* Combined compare & jump/move/store flags/trap operations.  */
292   OTI_cbranch,
293   OTI_cmov,
294   OTI_cstore,
295   OTI_ctrap,
296
297   /* Push instruction.  */
298   OTI_push,
299
300   /* Conditional add instruction.  */
301   OTI_addcc,
302
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,
310
311   /* Summation, with result machine mode one or more wider than args.  */
312   OTI_ssum_widen,
313   OTI_usum_widen,
314
315   /* Dot product, with result machine mode one or more wider than args.  */
316   OTI_sdot_prod,
317   OTI_udot_prod,
318
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,
350
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,
357
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,
362
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,
367
368   /* Perform a raise to the power of integer.  */
369   OTI_powi,
370
371   OTI_MAX
372 };
373
374 extern struct optab_d optab_table[OTI_MAX];
375
376 #define ssadd_optab (&optab_table[OTI_ssadd])
377 #define usadd_optab (&optab_table[OTI_usadd])
378 #define sssub_optab (&optab_table[OTI_sssub])
379 #define ussub_optab (&optab_table[OTI_ussub])
380 #define ssmul_optab (&optab_table[OTI_ssmul])
381 #define usmul_optab (&optab_table[OTI_usmul])
382 #define ssdiv_optab (&optab_table[OTI_ssdiv])
383 #define usdiv_optab (&optab_table[OTI_usdiv])
384 #define ssneg_optab (&optab_table[OTI_ssneg])
385 #define usneg_optab (&optab_table[OTI_usneg])
386 #define ssashl_optab (&optab_table[OTI_ssashl])
387 #define usashl_optab (&optab_table[OTI_usashl])
388
389 #define add_optab (&optab_table[OTI_add])
390 #define sub_optab (&optab_table[OTI_sub])
391 #define smul_optab (&optab_table[OTI_smul])
392 #define addv_optab (&optab_table[OTI_addv])
393 #define subv_optab (&optab_table[OTI_subv])
394 #define smul_highpart_optab (&optab_table[OTI_smul_highpart])
395 #define umul_highpart_optab (&optab_table[OTI_umul_highpart])
396 #define smul_widen_optab (&optab_table[OTI_smul_widen])
397 #define umul_widen_optab (&optab_table[OTI_umul_widen])
398 #define usmul_widen_optab (&optab_table[OTI_usmul_widen])
399 #define smadd_widen_optab (&optab_table[OTI_smadd_widen])
400 #define umadd_widen_optab (&optab_table[OTI_umadd_widen])
401 #define ssmadd_widen_optab (&optab_table[OTI_ssmadd_widen])
402 #define usmadd_widen_optab (&optab_table[OTI_usmadd_widen])
403 #define smsub_widen_optab (&optab_table[OTI_smsub_widen])
404 #define umsub_widen_optab (&optab_table[OTI_umsub_widen])
405 #define ssmsub_widen_optab (&optab_table[OTI_ssmsub_widen])
406 #define usmsub_widen_optab (&optab_table[OTI_usmsub_widen])
407 #define sdiv_optab (&optab_table[OTI_sdiv])
408 #define smulv_optab (&optab_table[OTI_smulv])
409 #define sdivv_optab (&optab_table[OTI_sdivv])
410 #define sdivmod_optab (&optab_table[OTI_sdivmod])
411 #define udiv_optab (&optab_table[OTI_udiv])
412 #define udivmod_optab (&optab_table[OTI_udivmod])
413 #define smod_optab (&optab_table[OTI_smod])
414 #define umod_optab (&optab_table[OTI_umod])
415 #define fmod_optab (&optab_table[OTI_fmod])
416 #define remainder_optab (&optab_table[OTI_remainder])
417 #define ftrunc_optab (&optab_table[OTI_ftrunc])
418 #define and_optab (&optab_table[OTI_and])
419 #define ior_optab (&optab_table[OTI_ior])
420 #define xor_optab (&optab_table[OTI_xor])
421 #define ashl_optab (&optab_table[OTI_ashl])
422 #define lshr_optab (&optab_table[OTI_lshr])
423 #define ashr_optab (&optab_table[OTI_ashr])
424 #define rotl_optab (&optab_table[OTI_rotl])
425 #define rotr_optab (&optab_table[OTI_rotr])
426 #define vashl_optab (&optab_table[OTI_vashl])
427 #define vlshr_optab (&optab_table[OTI_vlshr])
428 #define vashr_optab (&optab_table[OTI_vashr])
429 #define vrotl_optab (&optab_table[OTI_vrotl])
430 #define vrotr_optab (&optab_table[OTI_vrotr])
431 #define smin_optab (&optab_table[OTI_smin])
432 #define smax_optab (&optab_table[OTI_smax])
433 #define umin_optab (&optab_table[OTI_umin])
434 #define umax_optab (&optab_table[OTI_umax])
435 #define pow_optab (&optab_table[OTI_pow])
436 #define atan2_optab (&optab_table[OTI_atan2])
437
438 #define mov_optab (&optab_table[OTI_mov])
439 #define movstrict_optab (&optab_table[OTI_movstrict])
440 #define movmisalign_optab (&optab_table[OTI_movmisalign])
441 #define storent_optab (&optab_table[OTI_storent])
442
443 #define neg_optab (&optab_table[OTI_neg])
444 #define negv_optab (&optab_table[OTI_negv])
445 #define abs_optab (&optab_table[OTI_abs])
446 #define absv_optab (&optab_table[OTI_absv])
447 #define one_cmpl_optab (&optab_table[OTI_one_cmpl])
448 #define bswap_optab (&optab_table[OTI_bswap])
449 #define ffs_optab (&optab_table[OTI_ffs])
450 #define clz_optab (&optab_table[OTI_clz])
451 #define ctz_optab (&optab_table[OTI_ctz])
452 #define popcount_optab (&optab_table[OTI_popcount])
453 #define parity_optab (&optab_table[OTI_parity])
454 #define sqrt_optab (&optab_table[OTI_sqrt])
455 #define sincos_optab (&optab_table[OTI_sincos])
456 #define sin_optab (&optab_table[OTI_sin])
457 #define asin_optab (&optab_table[OTI_asin])
458 #define cos_optab (&optab_table[OTI_cos])
459 #define acos_optab (&optab_table[OTI_acos])
460 #define exp_optab (&optab_table[OTI_exp])
461 #define exp10_optab (&optab_table[OTI_exp10])
462 #define exp2_optab (&optab_table[OTI_exp2])
463 #define expm1_optab (&optab_table[OTI_expm1])
464 #define ldexp_optab (&optab_table[OTI_ldexp])
465 #define scalb_optab (&optab_table[OTI_scalb])
466 #define significand_optab (&optab_table[OTI_significand])
467 #define logb_optab (&optab_table[OTI_logb])
468 #define ilogb_optab (&optab_table[OTI_ilogb])
469 #define log_optab (&optab_table[OTI_log])
470 #define log10_optab (&optab_table[OTI_log10])
471 #define log2_optab (&optab_table[OTI_log2])
472 #define log1p_optab (&optab_table[OTI_log1p])
473 #define floor_optab (&optab_table[OTI_floor])
474 #define ceil_optab (&optab_table[OTI_ceil])
475 #define btrunc_optab (&optab_table[OTI_btrunc])
476 #define round_optab (&optab_table[OTI_round])
477 #define nearbyint_optab (&optab_table[OTI_nearbyint])
478 #define rint_optab (&optab_table[OTI_rint])
479 #define tan_optab (&optab_table[OTI_tan])
480 #define atan_optab (&optab_table[OTI_atan])
481 #define copysign_optab (&optab_table[OTI_copysign])
482 #define signbit_optab (&optab_table[OTI_signbit])
483 #define isinf_optab (&optab_table[OTI_isinf])
484
485 #define cmp_optab (&optab_table[OTI_cmp])
486 #define ucmp_optab (&optab_table[OTI_ucmp])
487
488 #define eq_optab (&optab_table[OTI_eq])
489 #define ne_optab (&optab_table[OTI_ne])
490 #define gt_optab (&optab_table[OTI_gt])
491 #define ge_optab (&optab_table[OTI_ge])
492 #define lt_optab (&optab_table[OTI_lt])
493 #define le_optab (&optab_table[OTI_le])
494 #define unord_optab (&optab_table[OTI_unord])
495
496 #define strlen_optab (&optab_table[OTI_strlen])
497
498 #define cbranch_optab (&optab_table[OTI_cbranch])
499 #define cmov_optab (&optab_table[OTI_cmov])
500 #define cstore_optab (&optab_table[OTI_cstore])
501 #define ctrap_optab (&optab_table[OTI_ctrap])
502
503 #define push_optab (&optab_table[OTI_push])
504 #define addcc_optab (&optab_table[OTI_addcc])
505
506 #define reduc_smax_optab (&optab_table[OTI_reduc_smax])
507 #define reduc_umax_optab (&optab_table[OTI_reduc_umax])
508 #define reduc_smin_optab (&optab_table[OTI_reduc_smin])
509 #define reduc_umin_optab (&optab_table[OTI_reduc_umin])
510 #define reduc_splus_optab (&optab_table[OTI_reduc_splus])
511 #define reduc_uplus_optab (&optab_table[OTI_reduc_uplus])
512
513 #define ssum_widen_optab (&optab_table[OTI_ssum_widen])
514 #define usum_widen_optab (&optab_table[OTI_usum_widen])
515 #define sdot_prod_optab (&optab_table[OTI_sdot_prod])
516 #define udot_prod_optab (&optab_table[OTI_udot_prod])
517
518 #define vec_set_optab (&optab_table[OTI_vec_set])
519 #define vec_extract_optab (&optab_table[OTI_vec_extract])
520 #define vec_extract_even_optab (&optab_table[OTI_vec_extract_even])
521 #define vec_extract_odd_optab (&optab_table[OTI_vec_extract_odd])
522 #define vec_interleave_high_optab (&optab_table[OTI_vec_interleave_high])
523 #define vec_interleave_low_optab (&optab_table[OTI_vec_interleave_low])
524 #define vec_init_optab (&optab_table[OTI_vec_init])
525 #define vec_shl_optab (&optab_table[OTI_vec_shl])
526 #define vec_shr_optab (&optab_table[OTI_vec_shr])
527 #define vec_realign_load_optab (&optab_table[OTI_vec_realign_load])
528 #define vec_widen_umult_hi_optab (&optab_table[OTI_vec_widen_umult_hi])
529 #define vec_widen_umult_lo_optab (&optab_table[OTI_vec_widen_umult_lo])
530 #define vec_widen_smult_hi_optab (&optab_table[OTI_vec_widen_smult_hi])
531 #define vec_widen_smult_lo_optab (&optab_table[OTI_vec_widen_smult_lo])
532 #define vec_unpacks_hi_optab (&optab_table[OTI_vec_unpacks_hi])
533 #define vec_unpacks_lo_optab (&optab_table[OTI_vec_unpacks_lo])
534 #define vec_unpacku_hi_optab (&optab_table[OTI_vec_unpacku_hi])
535 #define vec_unpacku_lo_optab (&optab_table[OTI_vec_unpacku_lo])
536 #define vec_unpacks_float_hi_optab (&optab_table[OTI_vec_unpacks_float_hi])
537 #define vec_unpacks_float_lo_optab (&optab_table[OTI_vec_unpacks_float_lo])
538 #define vec_unpacku_float_hi_optab (&optab_table[OTI_vec_unpacku_float_hi])
539 #define vec_unpacku_float_lo_optab (&optab_table[OTI_vec_unpacku_float_lo])
540 #define vec_pack_trunc_optab (&optab_table[OTI_vec_pack_trunc])
541 #define vec_pack_ssat_optab (&optab_table[OTI_vec_pack_ssat])
542 #define vec_pack_usat_optab (&optab_table[OTI_vec_pack_usat])
543 #define vec_pack_sfix_trunc_optab (&optab_table[OTI_vec_pack_sfix_trunc])
544 #define vec_pack_ufix_trunc_optab (&optab_table[OTI_vec_pack_ufix_trunc])
545
546 #define powi_optab (&optab_table[OTI_powi])
547
548 /* Conversion optabs have their own table and indexes.  */
549 enum convert_optab_index
550 {
551   COI_sext,
552   COI_zext,
553   COI_trunc,
554
555   COI_sfix,
556   COI_ufix,
557
558   COI_sfixtrunc,
559   COI_ufixtrunc,
560
561   COI_sfloat,
562   COI_ufloat,
563
564   COI_lrint,
565   COI_lround,
566   COI_lfloor,
567   COI_lceil,
568
569   COI_fract,
570   COI_fractuns,
571   COI_satfract,
572   COI_satfractuns,
573
574   COI_MAX
575 };
576
577 extern struct convert_optab_d convert_optab_table[COI_MAX];
578
579 #define sext_optab (&convert_optab_table[COI_sext])
580 #define zext_optab (&convert_optab_table[COI_zext])
581 #define trunc_optab (&convert_optab_table[COI_trunc])
582 #define sfix_optab (&convert_optab_table[COI_sfix])
583 #define ufix_optab (&convert_optab_table[COI_ufix])
584 #define sfixtrunc_optab (&convert_optab_table[COI_sfixtrunc])
585 #define ufixtrunc_optab (&convert_optab_table[COI_ufixtrunc])
586 #define sfloat_optab (&convert_optab_table[COI_sfloat])
587 #define ufloat_optab (&convert_optab_table[COI_ufloat])
588 #define lrint_optab (&convert_optab_table[COI_lrint])
589 #define lround_optab (&convert_optab_table[COI_lround])
590 #define lfloor_optab (&convert_optab_table[COI_lfloor])
591 #define lceil_optab (&convert_optab_table[COI_lceil])
592 #define fract_optab (&convert_optab_table[COI_fract])
593 #define fractuns_optab (&convert_optab_table[COI_fractuns])
594 #define satfract_optab (&convert_optab_table[COI_satfract])
595 #define satfractuns_optab (&convert_optab_table[COI_satfractuns])
596
597 /* Contains the optab used for each rtx code.  */
598 extern optab code_to_optab[NUM_RTX_CODE + 1];
599
600 \f
601 typedef rtx (*rtxfun) (rtx);
602
603 /* Enumerates operations that have a named .md pattern associated
604    with them, but which are not implemented as library functions.  */
605 enum direct_optab_index
606 {
607 #ifdef HAVE_conditional_move
608   /* Conditional move operations.  */
609   DOI_movcc,
610 #endif
611
612   /* Operations that use a scratch register to perform input and output
613      reloads of special objects.  */
614   DOI_reload_in,
615   DOI_reload_out,
616
617   /* Vector conditional operations.  */
618   DOI_vcond,
619   DOI_vcondu,
620
621   /* Block move operation.  */
622   DOI_movmem,
623
624   /* Block set operation.  */
625   DOI_setmem,
626
627   /* Various types of block compare operation.  */
628   DOI_cmpstr,
629   DOI_cmpstrn,
630   DOI_cmpmem,
631
632   /* Synchronization primitives.  This first set is atomic operation for
633      which we don't care about the resulting value.  */
634   DOI_sync_add,
635   DOI_sync_sub,
636   DOI_sync_ior,
637   DOI_sync_and,
638   DOI_sync_xor,
639   DOI_sync_nand,
640
641   /* This second set is atomic operations in which we return the value
642      that existed in memory before the operation.  */
643   DOI_sync_old_add,
644   DOI_sync_old_sub,
645   DOI_sync_old_ior,
646   DOI_sync_old_and,
647   DOI_sync_old_xor,
648   DOI_sync_old_nand,
649
650   /* This third set is atomic operations in which we return the value
651      that resulted after performing the operation.  */
652   DOI_sync_new_add,
653   DOI_sync_new_sub,
654   DOI_sync_new_ior,
655   DOI_sync_new_and,
656   DOI_sync_new_xor,
657   DOI_sync_new_nand,
658
659   /* Atomic compare and swap.  */
660   DOI_sync_compare_and_swap,
661
662   /* Atomic exchange with acquire semantics.  */
663   DOI_sync_lock_test_and_set,
664
665   /* Atomic clear with release semantics.  */
666   DOI_sync_lock_release,
667
668   DOI_MAX
669 };
670
671 /* A structure that says which insn should be used to perform an operation
672    in a particular mode.  */
673 struct direct_optab_d
674 {
675   struct optab_handlers handlers[NUM_MACHINE_MODES];
676 };
677 typedef struct direct_optab_d *direct_optab;
678
679 extern struct direct_optab_d direct_optab_table[(int) DOI_MAX];
680
681 #ifdef HAVE_conditional_move
682 #define movcc_optab (&direct_optab_table[(int) DOI_movcc])
683 #endif
684 #define reload_in_optab (&direct_optab_table[(int) DOI_reload_in])
685 #define reload_out_optab (&direct_optab_table[(int) DOI_reload_out])
686 #define vcond_optab (&direct_optab_table[(int) DOI_vcond])
687 #define vcondu_optab (&direct_optab_table[(int) DOI_vcondu])
688 #define movmem_optab (&direct_optab_table[(int) DOI_movmem])
689 #define setmem_optab (&direct_optab_table[(int) DOI_setmem])
690 #define cmpstr_optab (&direct_optab_table[(int) DOI_cmpstr])
691 #define cmpstrn_optab (&direct_optab_table[(int) DOI_cmpstrn])
692 #define cmpmem_optab (&direct_optab_table[(int) DOI_cmpmem])
693 #define sync_add_optab (&direct_optab_table[(int) DOI_sync_add])
694 #define sync_sub_optab (&direct_optab_table[(int) DOI_sync_sub])
695 #define sync_ior_optab (&direct_optab_table[(int) DOI_sync_ior])
696 #define sync_and_optab (&direct_optab_table[(int) DOI_sync_and])
697 #define sync_xor_optab (&direct_optab_table[(int) DOI_sync_xor])
698 #define sync_nand_optab (&direct_optab_table[(int) DOI_sync_nand])
699 #define sync_old_add_optab (&direct_optab_table[(int) DOI_sync_old_add])
700 #define sync_old_sub_optab (&direct_optab_table[(int) DOI_sync_old_sub])
701 #define sync_old_ior_optab (&direct_optab_table[(int) DOI_sync_old_ior])
702 #define sync_old_and_optab (&direct_optab_table[(int) DOI_sync_old_and])
703 #define sync_old_xor_optab (&direct_optab_table[(int) DOI_sync_old_xor])
704 #define sync_old_nand_optab (&direct_optab_table[(int) DOI_sync_old_nand])
705 #define sync_new_add_optab (&direct_optab_table[(int) DOI_sync_new_add])
706 #define sync_new_sub_optab (&direct_optab_table[(int) DOI_sync_new_sub])
707 #define sync_new_ior_optab (&direct_optab_table[(int) DOI_sync_new_ior])
708 #define sync_new_and_optab (&direct_optab_table[(int) DOI_sync_new_and])
709 #define sync_new_xor_optab (&direct_optab_table[(int) DOI_sync_new_xor])
710 #define sync_new_nand_optab (&direct_optab_table[(int) DOI_sync_new_nand])
711 #define sync_compare_and_swap_optab \
712   (&direct_optab_table[(int) DOI_sync_compare_and_swap])
713 #define sync_lock_test_and_set_optab \
714   (&direct_optab_table[(int) DOI_sync_lock_test_and_set])
715 #define sync_lock_release_optab \
716   (&direct_optab_table[(int) DOI_sync_lock_release])
717 \f
718 /* Define functions given in optabs.c.  */
719
720 extern rtx expand_widen_pattern_expr (sepops ops, rtx op0, rtx op1, rtx wide_op,
721                                       rtx target, int unsignedp);
722
723 extern rtx expand_ternary_op (enum machine_mode mode, optab ternary_optab,
724                               rtx op0, rtx op1, rtx op2, rtx target,
725                               int unsignedp);
726
727 /* Expand a binary operation given optab and rtx operands.  */
728 extern rtx expand_binop (enum machine_mode, optab, rtx, rtx, rtx, int,
729                          enum optab_methods);
730
731 extern bool force_expand_binop (enum machine_mode, optab, rtx, rtx, rtx, int,
732                                 enum optab_methods);
733
734 /* Expand a binary operation with both signed and unsigned forms.  */
735 extern rtx sign_expand_binop (enum machine_mode, optab, optab, rtx, rtx,
736                               rtx, int, enum optab_methods);
737
738 /* Generate code to perform an operation on one operand with two results.  */
739 extern int expand_twoval_unop (optab, rtx, rtx, rtx, int);
740
741 /* Generate code to perform an operation on two operands with two results.  */
742 extern int expand_twoval_binop (optab, rtx, rtx, rtx, rtx, int);
743
744 /* Generate code to perform an operation on two operands with two
745    results, using a library function.  */
746 extern bool expand_twoval_binop_libfunc (optab, rtx, rtx, rtx, rtx,
747                                          enum rtx_code);
748
749 /* Expand a unary arithmetic operation given optab rtx operand.  */
750 extern rtx expand_unop (enum machine_mode, optab, rtx, rtx, int);
751
752 /* Expand the absolute value operation.  */
753 extern rtx expand_abs_nojump (enum machine_mode, rtx, rtx, int);
754 extern rtx expand_abs (enum machine_mode, rtx, rtx, int, int);
755
756 /* Expand the one's complement absolute value operation.  */
757 extern rtx expand_one_cmpl_abs_nojump (enum machine_mode, rtx, rtx);
758
759 /* Expand the copysign operation.  */
760 extern rtx expand_copysign (rtx, rtx, rtx);
761
762 /* Generate an instruction with a given INSN_CODE with an output and
763    an input.  */
764 extern void emit_unop_insn (int, rtx, rtx, enum rtx_code);
765 extern bool maybe_emit_unop_insn (int, rtx, rtx, enum rtx_code);
766
767 /* An extra flag to control optab_for_tree_code's behavior.  This is needed to
768    distinguish between machines with a vector shift that takes a scalar for the
769    shift amount vs. machines that take a vector for the shift amount.  */
770 enum optab_subtype
771 {
772   optab_default,
773   optab_scalar,
774   optab_vector
775 };
776
777 /* Return the optab used for computing the given operation on the type given by
778    the second argument.  The third argument distinguishes between the types of
779    vector shifts and rotates */
780 extern optab optab_for_tree_code (enum tree_code, const_tree, enum optab_subtype);
781
782 /* The various uses that a comparison can have; used by can_compare_p:
783    jumps, conditional moves, store flag operations.  */
784 enum can_compare_purpose
785 {
786   ccp_jump,
787   ccp_cmov,
788   ccp_store_flag
789 };
790
791 /* Nonzero if a compare of mode MODE can be done straightforwardly
792    (without splitting it into pieces).  */
793 extern int can_compare_p (enum rtx_code, enum machine_mode,
794                           enum can_compare_purpose);
795
796 /* Return the INSN_CODE to use for an extend operation.  */
797 extern enum insn_code can_extend_p (enum machine_mode, enum machine_mode, int);
798
799 /* Generate the body of an insn to extend Y (with mode MFROM)
800    into X (with mode MTO).  Do zero-extension if UNSIGNEDP is nonzero.  */
801 extern rtx gen_extend_insn (rtx, rtx, enum machine_mode,
802                             enum machine_mode, int);
803
804 /* Call this to reset the function entry for one optab.  */
805 extern void set_optab_libfunc (optab, enum machine_mode, const char *);
806 extern void set_conv_libfunc (convert_optab, enum machine_mode,
807                               enum machine_mode, const char *);
808
809 /* Generate code for a FIXED_CONVERT_EXPR.  */
810 extern void expand_fixed_convert (rtx, rtx, int, int);
811
812 /* Generate code for a FLOAT_EXPR.  */
813 extern void expand_float (rtx, rtx, int);
814
815 /* Generate code for a FIX_EXPR.  */
816 extern void expand_fix (rtx, rtx, int);
817
818 /* Generate code for float to integral conversion.  */
819 extern bool expand_sfix_optab (rtx, rtx, convert_optab);
820
821 /* Generate code for a widening multiply.  */
822 extern rtx expand_widening_mult (enum machine_mode, rtx, rtx, rtx, int, optab);
823
824 /* Return tree if target supports vector operations for COND_EXPR.  */
825 bool expand_vec_cond_expr_p (tree, enum machine_mode);
826
827 /* Generate code for VEC_COND_EXPR.  */
828 extern rtx expand_vec_cond_expr (tree, tree, tree, tree, rtx);
829 /* Generate code for VEC_LSHIFT_EXPR and VEC_RSHIFT_EXPR.  */
830 extern rtx expand_vec_shift_expr (sepops, rtx);
831
832 /* Return the insn used to implement mode MODE of OP, or CODE_FOR_nothing
833    if the target does not have such an insn.  */
834
835 static inline enum insn_code
836 optab_handler (optab op, enum machine_mode mode)
837 {
838   return (enum insn_code) (op->handlers[(int) mode].insn_code
839                            + (int) CODE_FOR_nothing);
840 }
841
842 /* Record that insn CODE should be used to implement mode MODE of OP.  */
843
844 static inline void
845 set_optab_handler (optab op, enum machine_mode mode, enum insn_code code)
846 {
847   op->handlers[(int) mode].insn_code = (int) code - (int) CODE_FOR_nothing;
848 }
849
850 /* Return the insn used to perform conversion OP from mode FROM_MODE
851    to mode TO_MODE; return CODE_FOR_nothing if the target does not have
852    such an insn.  */
853
854 static inline enum insn_code
855 convert_optab_handler (convert_optab op, enum machine_mode to_mode,
856                        enum machine_mode from_mode)
857 {
858   return ((enum insn_code)
859           (op->handlers[(int) to_mode][(int) from_mode].insn_code
860            + (int) CODE_FOR_nothing));
861 }
862
863 /* Record that insn CODE should be used to perform conversion OP
864    from mode FROM_MODE to mode TO_MODE.  */
865
866 static inline void
867 set_convert_optab_handler (convert_optab op, enum machine_mode to_mode,
868                            enum machine_mode from_mode, enum insn_code code)
869 {
870   op->handlers[(int) to_mode][(int) from_mode].insn_code
871     = (int) code - (int) CODE_FOR_nothing;
872 }
873
874 /* Return the insn used to implement mode MODE of OP, or CODE_FOR_nothing
875    if the target does not have such an insn.  */
876
877 static inline enum insn_code
878 direct_optab_handler (direct_optab op, enum machine_mode mode)
879 {
880   return (enum insn_code) (op->handlers[(int) mode].insn_code
881                            + (int) CODE_FOR_nothing);
882 }
883
884 /* Record that insn CODE should be used to implement mode MODE of OP.  */
885
886 static inline void
887 set_direct_optab_handler (direct_optab op, enum machine_mode mode,
888                           enum insn_code code)
889 {
890   op->handlers[(int) mode].insn_code = (int) code - (int) CODE_FOR_nothing;
891 }
892
893 extern rtx optab_libfunc (optab optab, enum machine_mode mode);
894 extern rtx convert_optab_libfunc (convert_optab optab, enum machine_mode mode1,
895                                   enum machine_mode mode2);
896 #endif /* GCC_OPTABS_H */