OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [optabs.h] - Blame information for rev 849

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.