Introduce and use code_to_optab and optab_to_code functions
[gcc.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 2010, 2012 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 insn_code slot is the enum insn_code that says how to
33 generate an insn for this operation on a particular machine mode.
34 It is CODE_FOR_nothing if there is no such insn on the target machine.
35
36 The `lib_call' slot is the name of the library function that
37 can be used to perform the operation.
38
39 A few optabs, such as move_optab, are used by special code. */
40
41 struct optab_handlers
42 {
43 enum insn_code insn_code;
44 };
45
46 struct widening_optab_handlers
47 {
48 struct optab_handlers handlers[NUM_MACHINE_MODES][NUM_MACHINE_MODES];
49 };
50
51 struct optab_d
52 {
53 enum rtx_code code_;
54 char libcall_suffix;
55 const char *libcall_basename;
56 void (*libcall_gen)(struct optab_d *, const char *name, char suffix,
57 enum machine_mode);
58 struct optab_handlers handlers[NUM_MACHINE_MODES];
59 struct widening_optab_handlers *widening;
60 };
61 typedef struct optab_d * optab;
62
63 /* A convert_optab is for some sort of conversion operation between
64 modes. The first array index is the destination mode, the second
65 is the source mode. */
66 struct convert_optab_d
67 {
68 enum rtx_code code_;
69 const char *libcall_basename;
70 void (*libcall_gen)(struct convert_optab_d *, const char *name,
71 enum machine_mode,
72 enum machine_mode);
73 struct optab_handlers handlers[NUM_MACHINE_MODES][NUM_MACHINE_MODES];
74 };
75 typedef struct convert_optab_d *convert_optab;
76
77 /* Given an enum insn_code, access the function to construct
78 the body of that kind of insn. */
79 #define GEN_FCN(CODE) (insn_data[CODE].genfun)
80
81 /* Enumeration of valid indexes into optab_table. */
82 enum optab_index
83 {
84 /* Fixed-point operators with signed/unsigned saturation */
85 OTI_ssadd,
86 OTI_usadd,
87 OTI_sssub,
88 OTI_ussub,
89 OTI_ssmul,
90 OTI_usmul,
91 OTI_ssdiv,
92 OTI_usdiv,
93 OTI_ssneg,
94 OTI_usneg,
95 OTI_ssashl,
96 OTI_usashl,
97
98 OTI_add,
99 OTI_addv,
100 OTI_sub,
101 OTI_subv,
102
103 /* Signed and fp multiply */
104 OTI_smul,
105 OTI_smulv,
106 /* Signed multiply, return high word */
107 OTI_smul_highpart,
108 OTI_umul_highpart,
109 /* Signed multiply with result one machine mode wider than args */
110 OTI_smul_widen,
111 OTI_umul_widen,
112 /* Widening multiply of one unsigned and one signed operand. */
113 OTI_usmul_widen,
114 /* Signed multiply and add with the result and addend one machine mode
115 wider than the multiplicand and multiplier. */
116 OTI_smadd_widen,
117 /* Unsigned multiply and add with the result and addend one machine mode
118 wider than the multiplicand and multiplier. */
119 OTI_umadd_widen,
120 /* Signed multiply and add with the result and addend one machine mode
121 wider than the multiplicand and multiplier.
122 All involved operations are saturating. */
123 OTI_ssmadd_widen,
124 /* Unsigned multiply and add with the result and addend one machine mode
125 wider than the multiplicand and multiplier.
126 All involved operations are saturating. */
127 OTI_usmadd_widen,
128 /* Signed multiply and subtract the result and minuend one machine mode
129 wider than the multiplicand and multiplier. */
130 OTI_smsub_widen,
131 /* Unsigned multiply and subtract the result and minuend one machine mode
132 wider than the multiplicand and multiplier. */
133 OTI_umsub_widen,
134 /* Signed multiply and subtract the result and minuend one machine mode
135 wider than the multiplicand and multiplier.
136 All involved operations are saturating. */
137 OTI_ssmsub_widen,
138 /* Unsigned multiply and subtract the result and minuend one machine mode
139 wider than the multiplicand and multiplier.
140 All involved operations are saturating. */
141 OTI_usmsub_widen,
142
143 /* Signed divide */
144 OTI_sdiv,
145 OTI_sdivv,
146 /* Signed divide-and-remainder in one */
147 OTI_sdivmod,
148 OTI_udiv,
149 OTI_udivmod,
150 /* Signed remainder */
151 OTI_smod,
152 OTI_umod,
153 /* Floating point remainder functions */
154 OTI_fmod,
155 OTI_remainder,
156 /* Convert float to integer in float fmt */
157 OTI_ftrunc,
158
159 /* Logical and */
160 OTI_and,
161 /* Logical or */
162 OTI_ior,
163 /* Logical xor */
164 OTI_xor,
165
166 /* Arithmetic shift left */
167 OTI_ashl,
168 /* Logical shift right */
169 OTI_lshr,
170 /* Arithmetic shift right */
171 OTI_ashr,
172 /* Rotate left */
173 OTI_rotl,
174 /* Rotate right */
175 OTI_rotr,
176
177 /* Arithmetic shift left of vector by vector */
178 OTI_vashl,
179 /* Logical shift right of vector by vector */
180 OTI_vlshr,
181 /* Arithmetic shift right of vector by vector */
182 OTI_vashr,
183 /* Rotate left of vector by vector */
184 OTI_vrotl,
185 /* Rotate right of vector by vector */
186 OTI_vrotr,
187
188 /* Signed and floating-point minimum value */
189 OTI_smin,
190 /* Signed and floating-point maximum value */
191 OTI_smax,
192 /* Unsigned minimum value */
193 OTI_umin,
194 /* Unsigned maximum value */
195 OTI_umax,
196 /* Power */
197 OTI_pow,
198 /* Arc tangent of y/x */
199 OTI_atan2,
200 /* Floating multiply/add */
201 OTI_fma,
202 OTI_fms,
203 OTI_fnma,
204 OTI_fnms,
205
206 /* Move instruction. */
207 OTI_mov,
208 /* Move, preserving high part of register. */
209 OTI_movstrict,
210 /* Move, with a misaligned memory. */
211 OTI_movmisalign,
212 /* Nontemporal store. */
213 OTI_storent,
214
215 /* Unary operations */
216 /* Negation */
217 OTI_neg,
218 OTI_negv,
219 /* Abs value */
220 OTI_abs,
221 OTI_absv,
222 /* Byteswap */
223 OTI_bswap,
224 /* Bitwise not */
225 OTI_one_cmpl,
226 /* Bit scanning and counting */
227 OTI_ffs,
228 OTI_clz,
229 OTI_ctz,
230 OTI_clrsb,
231 OTI_popcount,
232 OTI_parity,
233 /* Square root */
234 OTI_sqrt,
235 /* Sine-Cosine */
236 OTI_sincos,
237 /* Sine */
238 OTI_sin,
239 /* Inverse sine */
240 OTI_asin,
241 /* Cosine */
242 OTI_cos,
243 /* Inverse cosine */
244 OTI_acos,
245 /* Exponential */
246 OTI_exp,
247 /* Base-10 Exponential */
248 OTI_exp10,
249 /* Base-2 Exponential */
250 OTI_exp2,
251 /* Exponential - 1*/
252 OTI_expm1,
253 /* Load exponent of a floating point number */
254 OTI_ldexp,
255 /* Multiply floating-point number by integral power of radix */
256 OTI_scalb,
257 /* Mantissa of a floating-point number */
258 OTI_significand,
259 /* Radix-independent exponent */
260 OTI_logb,
261 OTI_ilogb,
262 /* Natural Logarithm */
263 OTI_log,
264 /* Base-10 Logarithm */
265 OTI_log10,
266 /* Base-2 Logarithm */
267 OTI_log2,
268 /* logarithm of 1 plus argument */
269 OTI_log1p,
270 /* Rounding functions */
271 OTI_floor,
272 OTI_ceil,
273 OTI_btrunc,
274 OTI_round,
275 OTI_nearbyint,
276 OTI_rint,
277 /* Tangent */
278 OTI_tan,
279 /* Inverse tangent */
280 OTI_atan,
281 /* Copy sign */
282 OTI_copysign,
283 /* Signbit */
284 OTI_signbit,
285 /* Test for infinite value */
286 OTI_isinf,
287
288 /* Compare insn; two operands. Used only for libcalls. */
289 OTI_cmp,
290 OTI_ucmp,
291
292 /* Floating point comparison optabs - used primarily for libfuncs */
293 OTI_eq,
294 OTI_ne,
295 OTI_gt,
296 OTI_ge,
297 OTI_lt,
298 OTI_le,
299 OTI_unord,
300
301 /* String length */
302 OTI_strlen,
303
304 /* Combined compare & jump/move/store flags/trap operations. */
305 OTI_cbranch,
306 OTI_cmov,
307 OTI_cstore,
308 OTI_ctrap,
309
310 /* Push instruction. */
311 OTI_push,
312
313 /* Conditional add instruction. */
314 OTI_addcc,
315
316 /* Reduction operations on a vector operand. */
317 OTI_reduc_smax,
318 OTI_reduc_umax,
319 OTI_reduc_smin,
320 OTI_reduc_umin,
321 OTI_reduc_splus,
322 OTI_reduc_uplus,
323
324 /* Summation, with result machine mode one or more wider than args. */
325 OTI_ssum_widen,
326 OTI_usum_widen,
327
328 /* Dot product, with result machine mode one or more wider than args. */
329 OTI_sdot_prod,
330 OTI_udot_prod,
331
332 /* Set specified field of vector operand. */
333 OTI_vec_set,
334 /* Extract specified field of vector operand. */
335 OTI_vec_extract,
336 /* Initialize vector operand. */
337 OTI_vec_init,
338 /* Whole vector shift. The shift amount is in bits. */
339 OTI_vec_shl,
340 OTI_vec_shr,
341 /* Extract specified elements from vectors, for vector load. */
342 OTI_vec_realign_load,
343 /* Widening multiplication. The high/low/even/odd part of the
344 resulting vector of products is returned. */
345 OTI_vec_widen_umult_hi,
346 OTI_vec_widen_umult_lo,
347 OTI_vec_widen_smult_hi,
348 OTI_vec_widen_smult_lo,
349 OTI_vec_widen_umult_even,
350 OTI_vec_widen_umult_odd,
351 OTI_vec_widen_smult_even,
352 OTI_vec_widen_smult_odd,
353 /* Widening shift left.
354 The high/low part of the resulting vector is returned. */
355 OTI_vec_widen_ushiftl_hi,
356 OTI_vec_widen_ushiftl_lo,
357 OTI_vec_widen_sshiftl_hi,
358 OTI_vec_widen_sshiftl_lo,
359 /* Extract and widen the high/low part of a vector of signed or
360 floating point elements. */
361 OTI_vec_unpacks_hi,
362 OTI_vec_unpacks_lo,
363 /* Extract and widen the high/low part of a vector of unsigned
364 elements. */
365 OTI_vec_unpacku_hi,
366 OTI_vec_unpacku_lo,
367
368 /* Extract, convert to floating point and widen the high/low part of
369 a vector of signed or unsigned integer elements. */
370 OTI_vec_unpacks_float_hi,
371 OTI_vec_unpacks_float_lo,
372 OTI_vec_unpacku_float_hi,
373 OTI_vec_unpacku_float_lo,
374
375 /* Narrow (demote) and merge the elements of two vectors. */
376 OTI_vec_pack_trunc,
377 OTI_vec_pack_usat,
378 OTI_vec_pack_ssat,
379
380 /* Convert to signed/unsigned integer, narrow and merge elements
381 of two vectors of floating point elements. */
382 OTI_vec_pack_sfix_trunc,
383 OTI_vec_pack_ufix_trunc,
384
385 /* Perform a raise to the power of integer. */
386 OTI_powi,
387
388 /* Atomic compare and swap. */
389 OTI_sync_compare_and_swap,
390
391 /* Atomic exchange with acquire semantics. */
392 OTI_sync_lock_test_and_set,
393
394 /* This second set is atomic operations in which we return the value
395 that existed in memory before the operation. */
396 OTI_sync_old_add,
397 OTI_sync_old_sub,
398 OTI_sync_old_ior,
399 OTI_sync_old_and,
400 OTI_sync_old_xor,
401 OTI_sync_old_nand,
402
403 /* This third set is atomic operations in which we return the value
404 that resulted after performing the operation. */
405 OTI_sync_new_add,
406 OTI_sync_new_sub,
407 OTI_sync_new_ior,
408 OTI_sync_new_and,
409 OTI_sync_new_xor,
410 OTI_sync_new_nand,
411
412 OTI_MAX
413 };
414
415 #define unknown_optab NULL
416
417 #define ssadd_optab (&optab_table[OTI_ssadd])
418 #define usadd_optab (&optab_table[OTI_usadd])
419 #define sssub_optab (&optab_table[OTI_sssub])
420 #define ussub_optab (&optab_table[OTI_ussub])
421 #define ssmul_optab (&optab_table[OTI_ssmul])
422 #define usmul_optab (&optab_table[OTI_usmul])
423 #define ssdiv_optab (&optab_table[OTI_ssdiv])
424 #define usdiv_optab (&optab_table[OTI_usdiv])
425 #define ssneg_optab (&optab_table[OTI_ssneg])
426 #define usneg_optab (&optab_table[OTI_usneg])
427 #define ssashl_optab (&optab_table[OTI_ssashl])
428 #define usashl_optab (&optab_table[OTI_usashl])
429
430 #define add_optab (&optab_table[OTI_add])
431 #define sub_optab (&optab_table[OTI_sub])
432 #define smul_optab (&optab_table[OTI_smul])
433 #define addv_optab (&optab_table[OTI_addv])
434 #define subv_optab (&optab_table[OTI_subv])
435 #define smul_highpart_optab (&optab_table[OTI_smul_highpart])
436 #define umul_highpart_optab (&optab_table[OTI_umul_highpart])
437 #define smul_widen_optab (&optab_table[OTI_smul_widen])
438 #define umul_widen_optab (&optab_table[OTI_umul_widen])
439 #define usmul_widen_optab (&optab_table[OTI_usmul_widen])
440 #define smadd_widen_optab (&optab_table[OTI_smadd_widen])
441 #define umadd_widen_optab (&optab_table[OTI_umadd_widen])
442 #define ssmadd_widen_optab (&optab_table[OTI_ssmadd_widen])
443 #define usmadd_widen_optab (&optab_table[OTI_usmadd_widen])
444 #define smsub_widen_optab (&optab_table[OTI_smsub_widen])
445 #define umsub_widen_optab (&optab_table[OTI_umsub_widen])
446 #define ssmsub_widen_optab (&optab_table[OTI_ssmsub_widen])
447 #define usmsub_widen_optab (&optab_table[OTI_usmsub_widen])
448 #define sdiv_optab (&optab_table[OTI_sdiv])
449 #define smulv_optab (&optab_table[OTI_smulv])
450 #define sdivv_optab (&optab_table[OTI_sdivv])
451 #define sdivmod_optab (&optab_table[OTI_sdivmod])
452 #define udiv_optab (&optab_table[OTI_udiv])
453 #define udivmod_optab (&optab_table[OTI_udivmod])
454 #define smod_optab (&optab_table[OTI_smod])
455 #define umod_optab (&optab_table[OTI_umod])
456 #define fmod_optab (&optab_table[OTI_fmod])
457 #define remainder_optab (&optab_table[OTI_remainder])
458 #define ftrunc_optab (&optab_table[OTI_ftrunc])
459 #define and_optab (&optab_table[OTI_and])
460 #define ior_optab (&optab_table[OTI_ior])
461 #define xor_optab (&optab_table[OTI_xor])
462 #define ashl_optab (&optab_table[OTI_ashl])
463 #define lshr_optab (&optab_table[OTI_lshr])
464 #define ashr_optab (&optab_table[OTI_ashr])
465 #define rotl_optab (&optab_table[OTI_rotl])
466 #define rotr_optab (&optab_table[OTI_rotr])
467 #define vashl_optab (&optab_table[OTI_vashl])
468 #define vlshr_optab (&optab_table[OTI_vlshr])
469 #define vashr_optab (&optab_table[OTI_vashr])
470 #define vrotl_optab (&optab_table[OTI_vrotl])
471 #define vrotr_optab (&optab_table[OTI_vrotr])
472 #define smin_optab (&optab_table[OTI_smin])
473 #define smax_optab (&optab_table[OTI_smax])
474 #define umin_optab (&optab_table[OTI_umin])
475 #define umax_optab (&optab_table[OTI_umax])
476 #define pow_optab (&optab_table[OTI_pow])
477 #define atan2_optab (&optab_table[OTI_atan2])
478 #define fma_optab (&optab_table[OTI_fma])
479 #define fms_optab (&optab_table[OTI_fms])
480 #define fnma_optab (&optab_table[OTI_fnma])
481 #define fnms_optab (&optab_table[OTI_fnms])
482
483 #define mov_optab (&optab_table[OTI_mov])
484 #define movstrict_optab (&optab_table[OTI_movstrict])
485 #define movmisalign_optab (&optab_table[OTI_movmisalign])
486 #define storent_optab (&optab_table[OTI_storent])
487
488 #define neg_optab (&optab_table[OTI_neg])
489 #define negv_optab (&optab_table[OTI_negv])
490 #define abs_optab (&optab_table[OTI_abs])
491 #define absv_optab (&optab_table[OTI_absv])
492 #define one_cmpl_optab (&optab_table[OTI_one_cmpl])
493 #define bswap_optab (&optab_table[OTI_bswap])
494 #define ffs_optab (&optab_table[OTI_ffs])
495 #define clz_optab (&optab_table[OTI_clz])
496 #define ctz_optab (&optab_table[OTI_ctz])
497 #define clrsb_optab (&optab_table[OTI_clrsb])
498 #define popcount_optab (&optab_table[OTI_popcount])
499 #define parity_optab (&optab_table[OTI_parity])
500 #define sqrt_optab (&optab_table[OTI_sqrt])
501 #define sincos_optab (&optab_table[OTI_sincos])
502 #define sin_optab (&optab_table[OTI_sin])
503 #define asin_optab (&optab_table[OTI_asin])
504 #define cos_optab (&optab_table[OTI_cos])
505 #define acos_optab (&optab_table[OTI_acos])
506 #define exp_optab (&optab_table[OTI_exp])
507 #define exp10_optab (&optab_table[OTI_exp10])
508 #define exp2_optab (&optab_table[OTI_exp2])
509 #define expm1_optab (&optab_table[OTI_expm1])
510 #define ldexp_optab (&optab_table[OTI_ldexp])
511 #define scalb_optab (&optab_table[OTI_scalb])
512 #define significand_optab (&optab_table[OTI_significand])
513 #define logb_optab (&optab_table[OTI_logb])
514 #define ilogb_optab (&optab_table[OTI_ilogb])
515 #define log_optab (&optab_table[OTI_log])
516 #define log10_optab (&optab_table[OTI_log10])
517 #define log2_optab (&optab_table[OTI_log2])
518 #define log1p_optab (&optab_table[OTI_log1p])
519 #define floor_optab (&optab_table[OTI_floor])
520 #define ceil_optab (&optab_table[OTI_ceil])
521 #define btrunc_optab (&optab_table[OTI_btrunc])
522 #define round_optab (&optab_table[OTI_round])
523 #define nearbyint_optab (&optab_table[OTI_nearbyint])
524 #define rint_optab (&optab_table[OTI_rint])
525 #define tan_optab (&optab_table[OTI_tan])
526 #define atan_optab (&optab_table[OTI_atan])
527 #define copysign_optab (&optab_table[OTI_copysign])
528 #define signbit_optab (&optab_table[OTI_signbit])
529 #define isinf_optab (&optab_table[OTI_isinf])
530
531 #define cmp_optab (&optab_table[OTI_cmp])
532 #define ucmp_optab (&optab_table[OTI_ucmp])
533
534 #define eq_optab (&optab_table[OTI_eq])
535 #define ne_optab (&optab_table[OTI_ne])
536 #define gt_optab (&optab_table[OTI_gt])
537 #define ge_optab (&optab_table[OTI_ge])
538 #define lt_optab (&optab_table[OTI_lt])
539 #define le_optab (&optab_table[OTI_le])
540 #define unord_optab (&optab_table[OTI_unord])
541
542 #define strlen_optab (&optab_table[OTI_strlen])
543
544 #define cbranch_optab (&optab_table[OTI_cbranch])
545 #define cmov_optab (&optab_table[OTI_cmov])
546 #define cstore_optab (&optab_table[OTI_cstore])
547 #define ctrap_optab (&optab_table[OTI_ctrap])
548
549 #define push_optab (&optab_table[OTI_push])
550 #define addcc_optab (&optab_table[OTI_addcc])
551
552 #define reduc_smax_optab (&optab_table[OTI_reduc_smax])
553 #define reduc_umax_optab (&optab_table[OTI_reduc_umax])
554 #define reduc_smin_optab (&optab_table[OTI_reduc_smin])
555 #define reduc_umin_optab (&optab_table[OTI_reduc_umin])
556 #define reduc_splus_optab (&optab_table[OTI_reduc_splus])
557 #define reduc_uplus_optab (&optab_table[OTI_reduc_uplus])
558
559 #define ssum_widen_optab (&optab_table[OTI_ssum_widen])
560 #define usum_widen_optab (&optab_table[OTI_usum_widen])
561 #define sdot_prod_optab (&optab_table[OTI_sdot_prod])
562 #define udot_prod_optab (&optab_table[OTI_udot_prod])
563
564 #define vec_set_optab (&optab_table[OTI_vec_set])
565 #define vec_extract_optab (&optab_table[OTI_vec_extract])
566 #define vec_init_optab (&optab_table[OTI_vec_init])
567 #define vec_shl_optab (&optab_table[OTI_vec_shl])
568 #define vec_shr_optab (&optab_table[OTI_vec_shr])
569 #define vec_realign_load_optab (&optab_table[OTI_vec_realign_load])
570 #define vec_widen_umult_hi_optab (&optab_table[OTI_vec_widen_umult_hi])
571 #define vec_widen_umult_lo_optab (&optab_table[OTI_vec_widen_umult_lo])
572 #define vec_widen_smult_hi_optab (&optab_table[OTI_vec_widen_smult_hi])
573 #define vec_widen_smult_lo_optab (&optab_table[OTI_vec_widen_smult_lo])
574 #define vec_widen_umult_even_optab (&optab_table[OTI_vec_widen_umult_even])
575 #define vec_widen_umult_odd_optab (&optab_table[OTI_vec_widen_umult_odd])
576 #define vec_widen_smult_even_optab (&optab_table[OTI_vec_widen_smult_even])
577 #define vec_widen_smult_odd_optab (&optab_table[OTI_vec_widen_smult_odd])
578 #define vec_widen_ushiftl_hi_optab (&optab_table[OTI_vec_widen_ushiftl_hi])
579 #define vec_widen_ushiftl_lo_optab (&optab_table[OTI_vec_widen_ushiftl_lo])
580 #define vec_widen_sshiftl_hi_optab (&optab_table[OTI_vec_widen_sshiftl_hi])
581 #define vec_widen_sshiftl_lo_optab (&optab_table[OTI_vec_widen_sshiftl_lo])
582 #define vec_unpacks_hi_optab (&optab_table[OTI_vec_unpacks_hi])
583 #define vec_unpacks_lo_optab (&optab_table[OTI_vec_unpacks_lo])
584 #define vec_unpacku_hi_optab (&optab_table[OTI_vec_unpacku_hi])
585 #define vec_unpacku_lo_optab (&optab_table[OTI_vec_unpacku_lo])
586 #define vec_unpacks_float_hi_optab (&optab_table[OTI_vec_unpacks_float_hi])
587 #define vec_unpacks_float_lo_optab (&optab_table[OTI_vec_unpacks_float_lo])
588 #define vec_unpacku_float_hi_optab (&optab_table[OTI_vec_unpacku_float_hi])
589 #define vec_unpacku_float_lo_optab (&optab_table[OTI_vec_unpacku_float_lo])
590 #define vec_pack_trunc_optab (&optab_table[OTI_vec_pack_trunc])
591 #define vec_pack_ssat_optab (&optab_table[OTI_vec_pack_ssat])
592 #define vec_pack_usat_optab (&optab_table[OTI_vec_pack_usat])
593 #define vec_pack_sfix_trunc_optab (&optab_table[OTI_vec_pack_sfix_trunc])
594 #define vec_pack_ufix_trunc_optab (&optab_table[OTI_vec_pack_ufix_trunc])
595
596 #define powi_optab (&optab_table[OTI_powi])
597
598 #define sync_compare_and_swap_optab \
599 (&optab_table[(int) OTI_sync_compare_and_swap])
600 #define sync_lock_test_and_set_optab \
601 (&optab_table[(int) OTI_sync_lock_test_and_set])
602 #define sync_old_add_optab (&optab_table[(int) OTI_sync_old_add])
603 #define sync_old_sub_optab (&optab_table[(int) OTI_sync_old_sub])
604 #define sync_old_ior_optab (&optab_table[(int) OTI_sync_old_ior])
605 #define sync_old_and_optab (&optab_table[(int) OTI_sync_old_and])
606 #define sync_old_xor_optab (&optab_table[(int) OTI_sync_old_xor])
607 #define sync_old_nand_optab (&optab_table[(int) OTI_sync_old_nand])
608 #define sync_new_add_optab (&optab_table[(int) OTI_sync_new_add])
609 #define sync_new_sub_optab (&optab_table[(int) OTI_sync_new_sub])
610 #define sync_new_ior_optab (&optab_table[(int) OTI_sync_new_ior])
611 #define sync_new_and_optab (&optab_table[(int) OTI_sync_new_and])
612 #define sync_new_xor_optab (&optab_table[(int) OTI_sync_new_xor])
613 #define sync_new_nand_optab (&optab_table[(int) OTI_sync_new_nand])
614
615 /* Conversion optabs have their own table and indexes. */
616 enum convert_optab_index
617 {
618 COI_sext,
619 COI_zext,
620 COI_trunc,
621
622 COI_sfix,
623 COI_ufix,
624
625 COI_sfixtrunc,
626 COI_ufixtrunc,
627
628 COI_sfloat,
629 COI_ufloat,
630
631 COI_lrint,
632 COI_lround,
633 COI_lfloor,
634 COI_lceil,
635
636 COI_fract,
637 COI_fractuns,
638 COI_satfract,
639 COI_satfractuns,
640
641 COI_vec_load_lanes,
642 COI_vec_store_lanes,
643
644 /* Vector conditional operations. */
645 COI_vcond,
646 COI_vcondu,
647
648 COI_MAX
649 };
650
651 #define sext_optab (&convert_optab_table[COI_sext])
652 #define zext_optab (&convert_optab_table[COI_zext])
653 #define trunc_optab (&convert_optab_table[COI_trunc])
654 #define sfix_optab (&convert_optab_table[COI_sfix])
655 #define ufix_optab (&convert_optab_table[COI_ufix])
656 #define sfixtrunc_optab (&convert_optab_table[COI_sfixtrunc])
657 #define ufixtrunc_optab (&convert_optab_table[COI_ufixtrunc])
658 #define sfloat_optab (&convert_optab_table[COI_sfloat])
659 #define ufloat_optab (&convert_optab_table[COI_ufloat])
660 #define lrint_optab (&convert_optab_table[COI_lrint])
661 #define lround_optab (&convert_optab_table[COI_lround])
662 #define lfloor_optab (&convert_optab_table[COI_lfloor])
663 #define lceil_optab (&convert_optab_table[COI_lceil])
664 #define fract_optab (&convert_optab_table[COI_fract])
665 #define fractuns_optab (&convert_optab_table[COI_fractuns])
666 #define satfract_optab (&convert_optab_table[COI_satfract])
667 #define satfractuns_optab (&convert_optab_table[COI_satfractuns])
668 #define vec_load_lanes_optab (&convert_optab_table[COI_vec_load_lanes])
669 #define vec_store_lanes_optab (&convert_optab_table[COI_vec_store_lanes])
670 #define vcond_optab (&convert_optab_table[(int) COI_vcond])
671 #define vcondu_optab (&convert_optab_table[(int) COI_vcondu])
672
673 /* Contains the optab used for each rtx code. */
674 extern optab code_to_optab_[NUM_RTX_CODE + 1];
675
676 static inline optab
677 code_to_optab (enum rtx_code code)
678 {
679 return code_to_optab_[code];
680 }
681
682 #define optab_to_code(op) ((op)->code_)
683
684 \f
685 typedef rtx (*rtxfun) (rtx);
686
687 /* Enumerates operations that have a named .md pattern associated
688 with them, but which are not implemented as library functions. */
689 enum direct_optab_index
690 {
691 #ifdef HAVE_conditional_move
692 /* Conditional move operations. */
693 DOI_movcc,
694 #endif
695
696 /* Operations that use a scratch register to perform input and output
697 reloads of special objects. */
698 DOI_reload_in,
699 DOI_reload_out,
700
701 /* Block move operation. */
702 DOI_movmem,
703
704 /* Block set operation. */
705 DOI_setmem,
706
707 /* Various types of block compare operation. */
708 DOI_cmpstr,
709 DOI_cmpstrn,
710 DOI_cmpmem,
711
712 /* Atomic clear with release semantics. */
713 DOI_sync_lock_release,
714
715 /* Atomic operation with no resulting value. */
716 DOI_sync_add,
717 DOI_sync_sub,
718 DOI_sync_ior,
719 DOI_sync_and,
720 DOI_sync_xor,
721 DOI_sync_nand,
722
723 /* Atomic operations with memory model parameters. */
724 DOI_atomic_exchange,
725 DOI_atomic_compare_and_swap,
726 DOI_atomic_load,
727 DOI_atomic_store,
728 DOI_atomic_add_fetch,
729 DOI_atomic_sub_fetch,
730 DOI_atomic_and_fetch,
731 DOI_atomic_nand_fetch,
732 DOI_atomic_xor_fetch,
733 DOI_atomic_or_fetch,
734 DOI_atomic_fetch_add,
735 DOI_atomic_fetch_sub,
736 DOI_atomic_fetch_and,
737 DOI_atomic_fetch_nand,
738 DOI_atomic_fetch_xor,
739 DOI_atomic_fetch_or,
740 DOI_atomic_add,
741 DOI_atomic_sub,
742 DOI_atomic_and,
743 DOI_atomic_nand,
744 DOI_atomic_xor,
745 DOI_atomic_or,
746 DOI_atomic_always_lock_free,
747 DOI_atomic_is_lock_free,
748 DOI_atomic_thread_fence,
749 DOI_atomic_signal_fence,
750
751 /* Vector permutation. */
752 DOI_vec_perm,
753 DOI_vec_perm_const,
754
755 DOI_MAX
756 };
757
758 /* A structure that says which insn should be used to perform an operation
759 in a particular mode. */
760 struct direct_optab_d
761 {
762 struct optab_handlers handlers[NUM_MACHINE_MODES];
763 };
764 typedef struct direct_optab_d *direct_optab;
765
766 #ifdef HAVE_conditional_move
767 #define movcc_optab (&direct_optab_table[(int) DOI_movcc])
768 #endif
769 #define reload_in_optab (&direct_optab_table[(int) DOI_reload_in])
770 #define reload_out_optab (&direct_optab_table[(int) DOI_reload_out])
771 #define movmem_optab (&direct_optab_table[(int) DOI_movmem])
772 #define setmem_optab (&direct_optab_table[(int) DOI_setmem])
773 #define cmpstr_optab (&direct_optab_table[(int) DOI_cmpstr])
774 #define cmpstrn_optab (&direct_optab_table[(int) DOI_cmpstrn])
775 #define cmpmem_optab (&direct_optab_table[(int) DOI_cmpmem])
776 #define sync_lock_release_optab \
777 (&direct_optab_table[(int) DOI_sync_lock_release])
778 #define sync_add_optab (&direct_optab_table[(int) DOI_sync_add])
779 #define sync_sub_optab (&direct_optab_table[(int) DOI_sync_sub])
780 #define sync_ior_optab (&direct_optab_table[(int) DOI_sync_ior])
781 #define sync_and_optab (&direct_optab_table[(int) DOI_sync_and])
782 #define sync_xor_optab (&direct_optab_table[(int) DOI_sync_xor])
783 #define sync_nand_optab (&direct_optab_table[(int) DOI_sync_nand])
784
785 #define atomic_exchange_optab \
786 (&direct_optab_table[(int) DOI_atomic_exchange])
787 #define atomic_compare_and_swap_optab \
788 (&direct_optab_table[(int) DOI_atomic_compare_and_swap])
789 #define atomic_load_optab \
790 (&direct_optab_table[(int) DOI_atomic_load])
791 #define atomic_store_optab \
792 (&direct_optab_table[(int) DOI_atomic_store])
793 #define atomic_add_fetch_optab \
794 (&direct_optab_table[(int) DOI_atomic_add_fetch])
795 #define atomic_sub_fetch_optab \
796 (&direct_optab_table[(int) DOI_atomic_sub_fetch])
797 #define atomic_and_fetch_optab \
798 (&direct_optab_table[(int) DOI_atomic_and_fetch])
799 #define atomic_nand_fetch_optab \
800 (&direct_optab_table[(int) DOI_atomic_nand_fetch])
801 #define atomic_xor_fetch_optab \
802 (&direct_optab_table[(int) DOI_atomic_xor_fetch])
803 #define atomic_or_fetch_optab \
804 (&direct_optab_table[(int) DOI_atomic_or_fetch])
805 #define atomic_fetch_add_optab \
806 (&direct_optab_table[(int) DOI_atomic_fetch_add])
807 #define atomic_fetch_sub_optab \
808 (&direct_optab_table[(int) DOI_atomic_fetch_sub])
809 #define atomic_fetch_and_optab \
810 (&direct_optab_table[(int) DOI_atomic_fetch_and])
811 #define atomic_fetch_nand_optab \
812 (&direct_optab_table[(int) DOI_atomic_fetch_nand])
813 #define atomic_fetch_xor_optab \
814 (&direct_optab_table[(int) DOI_atomic_fetch_xor])
815 #define atomic_fetch_or_optab \
816 (&direct_optab_table[(int) DOI_atomic_fetch_or])
817 #define atomic_add_optab \
818 (&direct_optab_table[(int) DOI_atomic_add])
819 #define atomic_sub_optab \
820 (&direct_optab_table[(int) DOI_atomic_sub])
821 #define atomic_and_optab \
822 (&direct_optab_table[(int) DOI_atomic_and])
823 #define atomic_nand_optab \
824 (&direct_optab_table[(int) DOI_atomic_nand])
825 #define atomic_xor_optab \
826 (&direct_optab_table[(int) DOI_atomic_xor])
827 #define atomic_or_optab \
828 (&direct_optab_table[(int) DOI_atomic_or])
829 #define atomic_always_lock_free_optab \
830 (&direct_optab_table[(int) DOI_atomic_always_lock_free])
831 #define atomic_is_lock_free_optab \
832 (&direct_optab_table[(int) DOI_atomic_is_lock_free])
833 #define atomic_thread_fence_optab \
834 (&direct_optab_table[(int) DOI_atomic_thread_fence])
835 #define atomic_signal_fence_optab \
836 (&direct_optab_table[(int) DOI_atomic_signal_fence])
837
838 #define vec_perm_optab (&direct_optab_table[DOI_vec_perm])
839 #define vec_perm_const_optab (&direct_optab_table[(int) DOI_vec_perm_const])
840 \f
841 /* Target-dependent globals. */
842 struct target_optabs {
843 /* Tables of patterns that may have an associated libcall. */
844 struct optab_d x_optab_table[(int) OTI_MAX];
845
846 /* Tables of patterns for converting one mode to another. */
847 struct convert_optab_d x_convert_optab_table[(int) COI_MAX];
848
849 /* Tables of patterns for direct optabs (i.e. those which cannot be
850 implemented using a libcall). */
851 struct direct_optab_d x_direct_optab_table[(int) DOI_MAX];
852 };
853
854 extern struct target_optabs default_target_optabs;
855 #if SWITCHABLE_TARGET
856 extern struct target_optabs *this_target_optabs;
857 #else
858 #define this_target_optabs (&default_target_optabs)
859 #endif
860
861 #define optab_table \
862 (this_target_optabs->x_optab_table)
863 #define convert_optab_table \
864 (this_target_optabs->x_convert_optab_table)
865 #define direct_optab_table \
866 (this_target_optabs->x_direct_optab_table)
867 \f
868 /* Define functions given in optabs.c. */
869
870 extern rtx expand_widen_pattern_expr (sepops ops, rtx op0, rtx op1, rtx wide_op,
871 rtx target, int unsignedp);
872
873 extern rtx expand_ternary_op (enum machine_mode mode, optab ternary_optab,
874 rtx op0, rtx op1, rtx op2, rtx target,
875 int unsignedp);
876
877 /* Expand a binary operation given optab and rtx operands. */
878 extern rtx expand_binop (enum machine_mode, optab, rtx, rtx, rtx, int,
879 enum optab_methods);
880
881 extern rtx simplify_expand_binop (enum machine_mode mode, optab binoptab,
882 rtx op0, rtx op1, rtx target, int unsignedp,
883 enum optab_methods methods);
884
885 extern bool force_expand_binop (enum machine_mode, optab, rtx, rtx, rtx, int,
886 enum optab_methods);
887
888 /* Expand a binary operation with both signed and unsigned forms. */
889 extern rtx sign_expand_binop (enum machine_mode, optab, optab, rtx, rtx,
890 rtx, int, enum optab_methods);
891
892 /* Generate code to perform an operation on one operand with two results. */
893 extern int expand_twoval_unop (optab, rtx, rtx, rtx, int);
894
895 /* Generate code to perform an operation on two operands with two results. */
896 extern int expand_twoval_binop (optab, rtx, rtx, rtx, rtx, int);
897
898 /* Generate code to perform an operation on two operands with two
899 results, using a library function. */
900 extern bool expand_twoval_binop_libfunc (optab, rtx, rtx, rtx, rtx,
901 enum rtx_code);
902
903 /* Expand a unary arithmetic operation given optab rtx operand. */
904 extern rtx expand_unop (enum machine_mode, optab, rtx, rtx, int);
905
906 /* Expand the absolute value operation. */
907 extern rtx expand_abs_nojump (enum machine_mode, rtx, rtx, int);
908 extern rtx expand_abs (enum machine_mode, rtx, rtx, int, int);
909
910 /* Expand the one's complement absolute value operation. */
911 extern rtx expand_one_cmpl_abs_nojump (enum machine_mode, rtx, rtx);
912
913 /* Expand the copysign operation. */
914 extern rtx expand_copysign (rtx, rtx, rtx);
915
916 /* Generate an instruction with a given INSN_CODE with an output and
917 an input. */
918 extern void emit_unop_insn (enum insn_code, rtx, rtx, enum rtx_code);
919 extern bool maybe_emit_unop_insn (enum insn_code, rtx, rtx, enum rtx_code);
920
921 /* Find a widening optab even if it doesn't widen as much as we want. */
922 #define find_widening_optab_handler(A,B,C,D) \
923 find_widening_optab_handler_and_mode (A, B, C, D, NULL)
924 extern enum insn_code find_widening_optab_handler_and_mode (optab,
925 enum machine_mode,
926 enum machine_mode,
927 int,
928 enum machine_mode *);
929
930 /* An extra flag to control optab_for_tree_code's behavior. This is needed to
931 distinguish between machines with a vector shift that takes a scalar for the
932 shift amount vs. machines that take a vector for the shift amount. */
933 enum optab_subtype
934 {
935 optab_default,
936 optab_scalar,
937 optab_vector
938 };
939
940 /* Return the optab used for computing the given operation on the type given by
941 the second argument. The third argument distinguishes between the types of
942 vector shifts and rotates */
943 extern optab optab_for_tree_code (enum tree_code, const_tree, enum optab_subtype);
944
945 /* The various uses that a comparison can have; used by can_compare_p:
946 jumps, conditional moves, store flag operations. */
947 enum can_compare_purpose
948 {
949 ccp_jump,
950 ccp_cmov,
951 ccp_store_flag
952 };
953
954 /* Nonzero if a compare of mode MODE can be done straightforwardly
955 (without splitting it into pieces). */
956 extern int can_compare_p (enum rtx_code, enum machine_mode,
957 enum can_compare_purpose);
958
959 /* Return the INSN_CODE to use for an extend operation. */
960 extern enum insn_code can_extend_p (enum machine_mode, enum machine_mode, int);
961
962 /* Generate the body of an insn to extend Y (with mode MFROM)
963 into X (with mode MTO). Do zero-extension if UNSIGNEDP is nonzero. */
964 extern rtx gen_extend_insn (rtx, rtx, enum machine_mode,
965 enum machine_mode, int);
966
967 /* Call this to reset the function entry for one optab. */
968 extern void set_optab_libfunc (optab, enum machine_mode, const char *);
969 extern void set_conv_libfunc (convert_optab, enum machine_mode,
970 enum machine_mode, const char *);
971
972 /* Call this to install all of the __sync libcalls up to size MAX. */
973 extern void init_sync_libfuncs (int max);
974
975 /* Generate code for a FIXED_CONVERT_EXPR. */
976 extern void expand_fixed_convert (rtx, rtx, int, int);
977
978 /* Generate code for a FLOAT_EXPR. */
979 extern void expand_float (rtx, rtx, int);
980
981 /* Return the insn_code for a FLOAT_EXPR. */
982 enum insn_code can_float_p (enum machine_mode, enum machine_mode, int);
983
984 /* Return true if there is an inline compare and swap pattern. */
985 extern bool can_compare_and_swap_p (enum machine_mode, bool);
986
987 /* Return true if there is an inline atomic exchange pattern. */
988 extern bool can_atomic_exchange_p (enum machine_mode, bool);
989
990 /* Generate code for a compare and swap. */
991 extern bool expand_atomic_compare_and_swap (rtx *, rtx *, rtx, rtx, rtx, bool,
992 enum memmodel, enum memmodel);
993
994 /* Generate memory barriers. */
995 extern void expand_mem_thread_fence (enum memmodel);
996 extern void expand_mem_signal_fence (enum memmodel);
997
998 /* Check whether an operation represented by the code CODE is a
999 convert operation that is supported by the target platform in
1000 vector form */
1001 bool supportable_convert_operation (enum tree_code, tree, tree, tree *,
1002 enum tree_code *);
1003
1004 /* Generate code for a FIX_EXPR. */
1005 extern void expand_fix (rtx, rtx, int);
1006
1007 /* Generate code for float to integral conversion. */
1008 extern bool expand_sfix_optab (rtx, rtx, convert_optab);
1009
1010 /* Generate code for a widening multiply. */
1011 extern rtx expand_widening_mult (enum machine_mode, rtx, rtx, rtx, int, optab);
1012
1013 /* Return tree if target supports vector operations for COND_EXPR. */
1014 bool expand_vec_cond_expr_p (tree, tree);
1015
1016 /* Generate code for VEC_COND_EXPR. */
1017 extern rtx expand_vec_cond_expr (tree, tree, tree, tree, rtx);
1018 /* Generate code for VEC_LSHIFT_EXPR and VEC_RSHIFT_EXPR. */
1019 extern rtx expand_vec_shift_expr (sepops, rtx);
1020
1021 /* Return tree if target supports vector operations for VEC_PERM_EXPR. */
1022 extern bool can_vec_perm_p (enum machine_mode, bool, const unsigned char *);
1023
1024 /* Generate code for VEC_PERM_EXPR. */
1025 extern rtx expand_vec_perm (enum machine_mode, rtx, rtx, rtx, rtx);
1026
1027 /* Return non-zero if target supports a given highpart multiplication. */
1028 extern int can_mult_highpart_p (enum machine_mode, bool);
1029
1030 /* Generate code for MULT_HIGHPART_EXPR. */
1031 extern rtx expand_mult_highpart (enum machine_mode, rtx, rtx, rtx, bool);
1032
1033 /* Return the insn used to implement mode MODE of OP, or CODE_FOR_nothing
1034 if the target does not have such an insn. */
1035
1036 static inline enum insn_code
1037 optab_handler (optab op, enum machine_mode mode)
1038 {
1039 return op->handlers[(int) mode].insn_code;
1040 }
1041
1042 /* Like optab_handler, but for widening_operations that have a TO_MODE and
1043 a FROM_MODE. */
1044
1045 static inline enum insn_code
1046 widening_optab_handler (optab op, enum machine_mode to_mode,
1047 enum machine_mode from_mode)
1048 {
1049 if (to_mode == from_mode || from_mode == VOIDmode)
1050 return optab_handler (op, to_mode);
1051
1052 if (op->widening)
1053 return op->widening->handlers[(int) to_mode][(int) from_mode].insn_code;
1054
1055 return CODE_FOR_nothing;
1056 }
1057
1058 /* Record that insn CODE should be used to implement mode MODE of OP. */
1059
1060 static inline void
1061 set_optab_handler (optab op, enum machine_mode mode, enum insn_code code)
1062 {
1063 op->handlers[(int) mode].insn_code = code;
1064 }
1065
1066 /* Like set_optab_handler, but for widening operations that have a TO_MODE
1067 and a FROM_MODE. */
1068
1069 static inline void
1070 set_widening_optab_handler (optab op, enum machine_mode to_mode,
1071 enum machine_mode from_mode, enum insn_code code)
1072 {
1073 if (to_mode == from_mode)
1074 set_optab_handler (op, to_mode, code);
1075 else
1076 {
1077 if (op->widening == NULL)
1078 op->widening = XCNEW (struct widening_optab_handlers);
1079
1080 op->widening->handlers[(int) to_mode][(int) from_mode].insn_code = code;
1081 }
1082 }
1083
1084 /* Return the insn used to perform conversion OP from mode FROM_MODE
1085 to mode TO_MODE; return CODE_FOR_nothing if the target does not have
1086 such an insn. */
1087
1088 static inline enum insn_code
1089 convert_optab_handler (convert_optab op, enum machine_mode to_mode,
1090 enum machine_mode from_mode)
1091 {
1092 return op->handlers[(int) to_mode][(int) from_mode].insn_code;
1093 }
1094
1095 /* Record that insn CODE should be used to perform conversion OP
1096 from mode FROM_MODE to mode TO_MODE. */
1097
1098 static inline void
1099 set_convert_optab_handler (convert_optab op, enum machine_mode to_mode,
1100 enum machine_mode from_mode, enum insn_code code)
1101 {
1102 op->handlers[(int) to_mode][(int) from_mode].insn_code = code;
1103 }
1104
1105 /* Return the insn used to implement mode MODE of OP, or CODE_FOR_nothing
1106 if the target does not have such an insn. */
1107
1108 static inline enum insn_code
1109 direct_optab_handler (direct_optab op, enum machine_mode mode)
1110 {
1111 return op->handlers[(int) mode].insn_code;
1112 }
1113
1114 /* Record that insn CODE should be used to implement mode MODE of OP. */
1115
1116 static inline void
1117 set_direct_optab_handler (direct_optab op, enum machine_mode mode,
1118 enum insn_code code)
1119 {
1120 op->handlers[(int) mode].insn_code = code;
1121 }
1122
1123 /* Return true if UNOPTAB is for a trapping-on-overflow operation. */
1124
1125 static inline bool
1126 trapv_unoptab_p (optab unoptab)
1127 {
1128 return (unoptab == negv_optab
1129 || unoptab == absv_optab);
1130 }
1131
1132 /* Return true if BINOPTAB is for a trapping-on-overflow operation. */
1133
1134 static inline bool
1135 trapv_binoptab_p (optab binoptab)
1136 {
1137 return (binoptab == addv_optab
1138 || binoptab == subv_optab
1139 || binoptab == smulv_optab);
1140 }
1141
1142 extern rtx optab_libfunc (optab optab, enum machine_mode mode);
1143 extern rtx convert_optab_libfunc (convert_optab optab, enum machine_mode mode1,
1144 enum machine_mode mode2);
1145
1146 extern bool insn_operand_matches (enum insn_code icode, unsigned int opno,
1147 rtx operand);
1148
1149 /* Describes the type of an expand_operand. Each value is associated
1150 with a create_*_operand function; see the comments above those
1151 functions for details. */
1152 enum expand_operand_type {
1153 EXPAND_FIXED,
1154 EXPAND_OUTPUT,
1155 EXPAND_INPUT,
1156 EXPAND_CONVERT_TO,
1157 EXPAND_CONVERT_FROM,
1158 EXPAND_ADDRESS,
1159 EXPAND_INTEGER
1160 };
1161
1162 /* Information about an operand for instruction expansion. */
1163 struct expand_operand {
1164 /* The type of operand. */
1165 ENUM_BITFIELD (expand_operand_type) type : 8;
1166
1167 /* True if any conversion should treat VALUE as being unsigned
1168 rather than signed. Only meaningful for certain types. */
1169 unsigned int unsigned_p : 1;
1170
1171 /* Unused; available for future use. */
1172 unsigned int unused : 7;
1173
1174 /* The mode passed to the convert_*_operand function. It has a
1175 type-dependent meaning. */
1176 ENUM_BITFIELD (machine_mode) mode : 16;
1177
1178 /* The value of the operand. */
1179 rtx value;
1180 };
1181
1182 /* Initialize OP with the given fields. Initialise the other fields
1183 to their default values. */
1184
1185 static inline void
1186 create_expand_operand (struct expand_operand *op,
1187 enum expand_operand_type type,
1188 rtx value, enum machine_mode mode,
1189 bool unsigned_p)
1190 {
1191 op->type = type;
1192 op->unsigned_p = unsigned_p;
1193 op->unused = 0;
1194 op->mode = mode;
1195 op->value = value;
1196 }
1197
1198 /* Make OP describe an operand that must use rtx X, even if X is volatile. */
1199
1200 static inline void
1201 create_fixed_operand (struct expand_operand *op, rtx x)
1202 {
1203 create_expand_operand (op, EXPAND_FIXED, x, VOIDmode, false);
1204 }
1205
1206 /* Make OP describe an output operand that must have mode MODE.
1207 X, if nonnull, is a suggestion for where the output should be stored.
1208 It is OK for VALUE to be inconsistent with MODE, although it will just
1209 be ignored in that case. */
1210
1211 static inline void
1212 create_output_operand (struct expand_operand *op, rtx x,
1213 enum machine_mode mode)
1214 {
1215 create_expand_operand (op, EXPAND_OUTPUT, x, mode, false);
1216 }
1217
1218 /* Make OP describe an input operand that must have mode MODE and
1219 value VALUE; MODE cannot be VOIDmode. The backend may request that
1220 VALUE be copied into a different kind of rtx before being passed
1221 as an operand. */
1222
1223 static inline void
1224 create_input_operand (struct expand_operand *op, rtx value,
1225 enum machine_mode mode)
1226 {
1227 create_expand_operand (op, EXPAND_INPUT, value, mode, false);
1228 }
1229
1230 /* Like create_input_operand, except that VALUE must first be converted
1231 to mode MODE. UNSIGNED_P says whether VALUE is unsigned. */
1232
1233 static inline void
1234 create_convert_operand_to (struct expand_operand *op, rtx value,
1235 enum machine_mode mode, bool unsigned_p)
1236 {
1237 create_expand_operand (op, EXPAND_CONVERT_TO, value, mode, unsigned_p);
1238 }
1239
1240 /* Make OP describe an input operand that should have the same value
1241 as VALUE, after any mode conversion that the backend might request.
1242 If VALUE is a CONST_INT, it should be treated as having mode MODE.
1243 UNSIGNED_P says whether VALUE is unsigned. */
1244
1245 static inline void
1246 create_convert_operand_from (struct expand_operand *op, rtx value,
1247 enum machine_mode mode, bool unsigned_p)
1248 {
1249 create_expand_operand (op, EXPAND_CONVERT_FROM, value, mode, unsigned_p);
1250 }
1251
1252 extern void create_convert_operand_from_type (struct expand_operand *op,
1253 rtx value, tree type);
1254
1255 /* Make OP describe an input Pmode address operand. VALUE is the value
1256 of the address, but it may need to be converted to Pmode first. */
1257
1258 static inline void
1259 create_address_operand (struct expand_operand *op, rtx value)
1260 {
1261 create_expand_operand (op, EXPAND_ADDRESS, value, Pmode, false);
1262 }
1263
1264 /* Make OP describe an input operand that has value INTVAL and that has
1265 no inherent mode. This function should only be used for operands that
1266 are always expand-time constants. The backend may request that INTVAL
1267 be copied into a different kind of rtx, but it must specify the mode
1268 of that rtx if so. */
1269
1270 static inline void
1271 create_integer_operand (struct expand_operand *op, HOST_WIDE_INT intval)
1272 {
1273 create_expand_operand (op, EXPAND_INTEGER, GEN_INT (intval), VOIDmode, false);
1274 }
1275
1276 extern bool valid_multiword_target_p (rtx);
1277
1278 extern bool maybe_legitimize_operands (enum insn_code icode,
1279 unsigned int opno, unsigned int nops,
1280 struct expand_operand *ops);
1281 extern rtx maybe_gen_insn (enum insn_code icode, unsigned int nops,
1282 struct expand_operand *ops);
1283 extern bool maybe_expand_insn (enum insn_code icode, unsigned int nops,
1284 struct expand_operand *ops);
1285 extern bool maybe_expand_jump_insn (enum insn_code icode, unsigned int nops,
1286 struct expand_operand *ops);
1287 extern void expand_insn (enum insn_code icode, unsigned int nops,
1288 struct expand_operand *ops);
1289 extern void expand_jump_insn (enum insn_code icode, unsigned int nops,
1290 struct expand_operand *ops);
1291
1292 extern rtx prepare_operand (enum insn_code, rtx, int, enum machine_mode,
1293 enum machine_mode, int);
1294
1295 #endif /* GCC_OPTABS_H */