OSDN Git Service

gcc/
[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 /* These arrays record the insn_code of insns that may be needed to
598    perform input and output reloads of special objects.  They provide a
599    place to pass a scratch register.  */
600 extern enum insn_code reload_in_optab[NUM_MACHINE_MODES];
601 extern enum insn_code reload_out_optab[NUM_MACHINE_MODES];
602
603 /* Contains the optab used for each rtx code.  */
604 extern optab code_to_optab[NUM_RTX_CODE + 1];
605
606 \f
607 typedef rtx (*rtxfun) (rtx);
608
609 #ifdef HAVE_conditional_move
610 /* Indexed by the machine mode, gives the insn code to make a conditional
611    move insn.  */
612
613 extern enum insn_code movcc_gen_code[NUM_MACHINE_MODES];
614 #endif
615
616 /* Indexed by the machine mode, gives the insn code for vector conditional
617    operation.  */
618
619 extern enum insn_code vcond_gen_code[NUM_MACHINE_MODES];
620 extern enum insn_code vcondu_gen_code[NUM_MACHINE_MODES];
621
622 /* This array records the insn_code of insns to perform block moves.  */
623 extern enum insn_code movmem_optab[NUM_MACHINE_MODES];
624
625 /* This array records the insn_code of insns to perform block sets.  */
626 extern enum insn_code setmem_optab[NUM_MACHINE_MODES];
627
628 /* These arrays record the insn_code of two different kinds of insns
629    to perform block compares.  */
630 extern enum insn_code cmpstr_optab[NUM_MACHINE_MODES];
631 extern enum insn_code cmpstrn_optab[NUM_MACHINE_MODES];
632 extern enum insn_code cmpmem_optab[NUM_MACHINE_MODES];
633
634 /* Synchronization primitives.  This first set is atomic operation for
635    which we don't care about the resulting value.  */
636 extern enum insn_code sync_add_optab[NUM_MACHINE_MODES];
637 extern enum insn_code sync_sub_optab[NUM_MACHINE_MODES];
638 extern enum insn_code sync_ior_optab[NUM_MACHINE_MODES];
639 extern enum insn_code sync_and_optab[NUM_MACHINE_MODES];
640 extern enum insn_code sync_xor_optab[NUM_MACHINE_MODES];
641 extern enum insn_code sync_nand_optab[NUM_MACHINE_MODES];
642
643 /* This second set is atomic operations in which we return the value
644    that existed in memory before the operation.  */
645 extern enum insn_code sync_old_add_optab[NUM_MACHINE_MODES];
646 extern enum insn_code sync_old_sub_optab[NUM_MACHINE_MODES];
647 extern enum insn_code sync_old_ior_optab[NUM_MACHINE_MODES];
648 extern enum insn_code sync_old_and_optab[NUM_MACHINE_MODES];
649 extern enum insn_code sync_old_xor_optab[NUM_MACHINE_MODES];
650 extern enum insn_code sync_old_nand_optab[NUM_MACHINE_MODES];
651
652 /* This third set is atomic operations in which we return the value
653    that resulted after performing the operation.  */
654 extern enum insn_code sync_new_add_optab[NUM_MACHINE_MODES];
655 extern enum insn_code sync_new_sub_optab[NUM_MACHINE_MODES];
656 extern enum insn_code sync_new_ior_optab[NUM_MACHINE_MODES];
657 extern enum insn_code sync_new_and_optab[NUM_MACHINE_MODES];
658 extern enum insn_code sync_new_xor_optab[NUM_MACHINE_MODES];
659 extern enum insn_code sync_new_nand_optab[NUM_MACHINE_MODES];
660
661 /* Atomic compare and swap.  */
662 extern enum insn_code sync_compare_and_swap[NUM_MACHINE_MODES];
663
664 /* Atomic exchange with acquire semantics.  */
665 extern enum insn_code sync_lock_test_and_set[NUM_MACHINE_MODES];
666
667 /* Atomic clear with release semantics.  */
668 extern enum insn_code sync_lock_release[NUM_MACHINE_MODES];
669
670 /* Define functions given in optabs.c.  */
671
672 extern rtx expand_widen_pattern_expr (sepops ops, rtx op0, rtx op1, rtx wide_op,
673                                       rtx target, int unsignedp);
674
675 extern rtx expand_ternary_op (enum machine_mode mode, optab ternary_optab,
676                               rtx op0, rtx op1, rtx op2, rtx target,
677                               int unsignedp);
678
679 /* Expand a binary operation given optab and rtx operands.  */
680 extern rtx expand_binop (enum machine_mode, optab, rtx, rtx, rtx, int,
681                          enum optab_methods);
682
683 extern bool force_expand_binop (enum machine_mode, optab, rtx, rtx, rtx, int,
684                                 enum optab_methods);
685
686 /* Expand a binary operation with both signed and unsigned forms.  */
687 extern rtx sign_expand_binop (enum machine_mode, optab, optab, rtx, rtx,
688                               rtx, int, enum optab_methods);
689
690 /* Generate code to perform an operation on one operand with two results.  */
691 extern int expand_twoval_unop (optab, rtx, rtx, rtx, int);
692
693 /* Generate code to perform an operation on two operands with two results.  */
694 extern int expand_twoval_binop (optab, rtx, rtx, rtx, rtx, int);
695
696 /* Generate code to perform an operation on two operands with two
697    results, using a library function.  */
698 extern bool expand_twoval_binop_libfunc (optab, rtx, rtx, rtx, rtx,
699                                          enum rtx_code);
700
701 /* Expand a unary arithmetic operation given optab rtx operand.  */
702 extern rtx expand_unop (enum machine_mode, optab, rtx, rtx, int);
703
704 /* Expand the absolute value operation.  */
705 extern rtx expand_abs_nojump (enum machine_mode, rtx, rtx, int);
706 extern rtx expand_abs (enum machine_mode, rtx, rtx, int, int);
707
708 /* Expand the one's complement absolute value operation.  */
709 extern rtx expand_one_cmpl_abs_nojump (enum machine_mode, rtx, rtx);
710
711 /* Expand the copysign operation.  */
712 extern rtx expand_copysign (rtx, rtx, rtx);
713
714 /* Generate an instruction with a given INSN_CODE with an output and
715    an input.  */
716 extern void emit_unop_insn (int, rtx, rtx, enum rtx_code);
717 extern bool maybe_emit_unop_insn (int, rtx, rtx, enum rtx_code);
718
719 /* An extra flag to control optab_for_tree_code's behavior.  This is needed to
720    distinguish between machines with a vector shift that takes a scalar for the
721    shift amount vs. machines that take a vector for the shift amount.  */
722 enum optab_subtype
723 {
724   optab_default,
725   optab_scalar,
726   optab_vector
727 };
728
729 /* Return the optab used for computing the given operation on the type given by
730    the second argument.  The third argument distinguishes between the types of
731    vector shifts and rotates */
732 extern optab optab_for_tree_code (enum tree_code, const_tree, enum optab_subtype);
733
734 /* The various uses that a comparison can have; used by can_compare_p:
735    jumps, conditional moves, store flag operations.  */
736 enum can_compare_purpose
737 {
738   ccp_jump,
739   ccp_cmov,
740   ccp_store_flag
741 };
742
743 /* Nonzero if a compare of mode MODE can be done straightforwardly
744    (without splitting it into pieces).  */
745 extern int can_compare_p (enum rtx_code, enum machine_mode,
746                           enum can_compare_purpose);
747
748 /* Return the INSN_CODE to use for an extend operation.  */
749 extern enum insn_code can_extend_p (enum machine_mode, enum machine_mode, int);
750
751 /* Generate the body of an insn to extend Y (with mode MFROM)
752    into X (with mode MTO).  Do zero-extension if UNSIGNEDP is nonzero.  */
753 extern rtx gen_extend_insn (rtx, rtx, enum machine_mode,
754                             enum machine_mode, int);
755
756 /* Call this to reset the function entry for one optab.  */
757 extern void set_optab_libfunc (optab, enum machine_mode, const char *);
758 extern void set_conv_libfunc (convert_optab, enum machine_mode,
759                               enum machine_mode, const char *);
760
761 /* Generate code for a FIXED_CONVERT_EXPR.  */
762 extern void expand_fixed_convert (rtx, rtx, int, int);
763
764 /* Generate code for a FLOAT_EXPR.  */
765 extern void expand_float (rtx, rtx, int);
766
767 /* Generate code for a FIX_EXPR.  */
768 extern void expand_fix (rtx, rtx, int);
769
770 /* Generate code for float to integral conversion.  */
771 extern bool expand_sfix_optab (rtx, rtx, convert_optab);
772
773 /* Generate code for a widening multiply.  */
774 extern rtx expand_widening_mult (enum machine_mode, rtx, rtx, rtx, int, optab);
775
776 /* Return tree if target supports vector operations for COND_EXPR.  */
777 bool expand_vec_cond_expr_p (tree, enum machine_mode);
778
779 /* Generate code for VEC_COND_EXPR.  */
780 extern rtx expand_vec_cond_expr (tree, tree, tree, tree, rtx);
781 /* Generate code for VEC_LSHIFT_EXPR and VEC_RSHIFT_EXPR.  */
782 extern rtx expand_vec_shift_expr (sepops, rtx);
783
784 /* Return the insn used to implement mode MODE of OP, or CODE_FOR_nothing
785    if the target does not have such an insn.  */
786
787 static inline enum insn_code
788 optab_handler (optab op, enum machine_mode mode)
789 {
790   return (enum insn_code) (op->handlers[(int) mode].insn_code
791                            + (int) CODE_FOR_nothing);
792 }
793
794 /* Record that insn CODE should be used to implement mode MODE of OP.  */
795
796 static inline void
797 set_optab_handler (optab op, enum machine_mode mode, enum insn_code code)
798 {
799   op->handlers[(int) mode].insn_code = (int) code - (int) CODE_FOR_nothing;
800 }
801
802 /* Return the insn used to perform conversion OP from mode FROM_MODE
803    to mode TO_MODE; return CODE_FOR_nothing if the target does not have
804    such an insn.  */
805
806 static inline enum insn_code
807 convert_optab_handler (convert_optab op, enum machine_mode to_mode,
808                        enum machine_mode from_mode)
809 {
810   return ((enum insn_code)
811           (op->handlers[(int) to_mode][(int) from_mode].insn_code
812            + (int) CODE_FOR_nothing));
813 }
814
815 /* Record that insn CODE should be used to perform conversion OP
816    from mode FROM_MODE to mode TO_MODE.  */
817
818 static inline void
819 set_convert_optab_handler (convert_optab op, enum machine_mode to_mode,
820                            enum machine_mode from_mode, enum insn_code code)
821 {
822   op->handlers[(int) to_mode][(int) from_mode].insn_code
823     = (int) code - (int) CODE_FOR_nothing;
824 }
825
826 extern rtx optab_libfunc (optab optab, enum machine_mode mode);
827 extern rtx convert_optab_libfunc (convert_optab optab, enum machine_mode mode1,
828                                   enum machine_mode mode2);
829 #endif /* GCC_OPTABS_H */