]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/optabs.h
PR fortran/95090 - ICE: identifier overflow
[thirdparty/gcc.git] / gcc / optabs.h
CommitLineData
e78d8e51 1/* Definitions for code generation pass of GNU compiler.
8d9254fc 2 Copyright (C) 2001-2020 Free Software Foundation, Inc.
e78d8e51 3
40803cd5 4This file is part of GCC.
e78d8e51 5
40803cd5 6GCC is free software; you can redistribute it and/or modify
e78d8e51 7it under the terms of the GNU General Public License as published by
9dcd6f09 8the Free Software Foundation; either version 3, or (at your option)
e78d8e51
ZW
9any later version.
10
40803cd5 11GCC is distributed in the hope that it will be useful,
e78d8e51
ZW
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
9dcd6f09
NC
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
e78d8e51
ZW
19
20#ifndef GCC_OPTABS_H
21#define GCC_OPTABS_H
22
385399a8
RS
23#include "optabs-query.h"
24#include "optabs-libfuncs.h"
f151c9e1 25#include "vec-perm-indices.h"
e78d8e51 26
b99279f3 27/* Generate code for a widening multiply. */
ef4bddc2 28extern rtx expand_widening_mult (machine_mode, rtx, rtx, rtx, int, optab);
b99279f3 29
a5c7d693
RS
30/* Describes the type of an expand_operand. Each value is associated
31 with a create_*_operand function; see the comments above those
32 functions for details. */
33enum expand_operand_type {
34 EXPAND_FIXED,
35 EXPAND_OUTPUT,
36 EXPAND_INPUT,
37 EXPAND_CONVERT_TO,
38 EXPAND_CONVERT_FROM,
39 EXPAND_ADDRESS,
40 EXPAND_INTEGER
41};
42
43/* Information about an operand for instruction expansion. */
6c1dae73
MS
44class expand_operand {
45public:
a5c7d693
RS
46 /* The type of operand. */
47 ENUM_BITFIELD (expand_operand_type) type : 8;
48
49 /* True if any conversion should treat VALUE as being unsigned
50 rather than signed. Only meaningful for certain types. */
51 unsigned int unsigned_p : 1;
52
f96bf49a
JW
53 /* Is the target operand. */
54 unsigned int target : 1;
55
a5c7d693 56 /* Unused; available for future use. */
f96bf49a 57 unsigned int unused : 6;
a5c7d693
RS
58
59 /* The mode passed to the convert_*_operand function. It has a
60 type-dependent meaning. */
61 ENUM_BITFIELD (machine_mode) mode : 16;
62
63 /* The value of the operand. */
64 rtx value;
f8832fe1
RS
65
66 /* The value of an EXPAND_INTEGER operand. */
67 poly_int64 int_value;
a5c7d693
RS
68};
69
70/* Initialize OP with the given fields. Initialise the other fields
71 to their default values. */
72
73static inline void
99b1c316 74create_expand_operand (class expand_operand *op,
a5c7d693 75 enum expand_operand_type type,
ef4bddc2 76 rtx value, machine_mode mode,
f8832fe1 77 bool unsigned_p, poly_int64 int_value = 0)
a5c7d693
RS
78{
79 op->type = type;
80 op->unsigned_p = unsigned_p;
55c7ffae 81 op->target = 0;
a5c7d693
RS
82 op->unused = 0;
83 op->mode = mode;
84 op->value = value;
f8832fe1 85 op->int_value = int_value;
a5c7d693
RS
86}
87
88/* Make OP describe an operand that must use rtx X, even if X is volatile. */
89
90static inline void
99b1c316 91create_fixed_operand (class expand_operand *op, rtx x)
a5c7d693
RS
92{
93 create_expand_operand (op, EXPAND_FIXED, x, VOIDmode, false);
94}
95
96/* Make OP describe an output operand that must have mode MODE.
97 X, if nonnull, is a suggestion for where the output should be stored.
98 It is OK for VALUE to be inconsistent with MODE, although it will just
99 be ignored in that case. */
100
101static inline void
99b1c316 102create_output_operand (class expand_operand *op, rtx x,
ef4bddc2 103 machine_mode mode)
a5c7d693
RS
104{
105 create_expand_operand (op, EXPAND_OUTPUT, x, mode, false);
106}
107
108/* Make OP describe an input operand that must have mode MODE and
109 value VALUE; MODE cannot be VOIDmode. The backend may request that
110 VALUE be copied into a different kind of rtx before being passed
111 as an operand. */
112
113static inline void
99b1c316 114create_input_operand (class expand_operand *op, rtx value,
ef4bddc2 115 machine_mode mode)
a5c7d693
RS
116{
117 create_expand_operand (op, EXPAND_INPUT, value, mode, false);
118}
119
120/* Like create_input_operand, except that VALUE must first be converted
121 to mode MODE. UNSIGNED_P says whether VALUE is unsigned. */
122
123static inline void
99b1c316 124create_convert_operand_to (class expand_operand *op, rtx value,
ef4bddc2 125 machine_mode mode, bool unsigned_p)
a5c7d693
RS
126{
127 create_expand_operand (op, EXPAND_CONVERT_TO, value, mode, unsigned_p);
128}
129
130/* Make OP describe an input operand that should have the same value
131 as VALUE, after any mode conversion that the backend might request.
132 If VALUE is a CONST_INT, it should be treated as having mode MODE.
20103c0e
RS
133 UNSIGNED_P says whether VALUE is unsigned.
134
135 The conversion of VALUE can include a combination of numerical
136 conversion (as for convert_modes) and duplicating a scalar to fill
137 a vector (if VALUE is a scalar but the operand is a vector). */
a5c7d693
RS
138
139static inline void
99b1c316 140create_convert_operand_from (class expand_operand *op, rtx value,
ef4bddc2 141 machine_mode mode, bool unsigned_p)
a5c7d693
RS
142{
143 create_expand_operand (op, EXPAND_CONVERT_FROM, value, mode, unsigned_p);
144}
145
a5c7d693
RS
146
147/* Make OP describe an input Pmode address operand. VALUE is the value
148 of the address, but it may need to be converted to Pmode first. */
149
150static inline void
99b1c316 151create_address_operand (class expand_operand *op, rtx value)
a5c7d693
RS
152{
153 create_expand_operand (op, EXPAND_ADDRESS, value, Pmode, false);
154}
155
99b1c316 156extern void create_integer_operand (class expand_operand *, poly_int64);
02972eaf 157
b0710fe1
AM
158/* Passed to expand_simple_binop and expand_binop to say which options
159 to try to use if the requested operation can't be open-coded on the
160 requisite mode. Either OPTAB_LIB or OPTAB_LIB_WIDEN says try using
161 a library call. Either OPTAB_WIDEN or OPTAB_LIB_WIDEN says try
162 using a wider mode. OPTAB_MUST_WIDEN says try widening and don't
163 try anything else. */
164
165enum optab_methods
166{
167 OPTAB_DIRECT,
168 OPTAB_LIB,
169 OPTAB_WIDEN,
170 OPTAB_LIB_WIDEN,
171 OPTAB_MUST_WIDEN
172};
173
b0710fe1
AM
174extern rtx expand_widen_pattern_expr (struct separate_ops *, rtx , rtx , rtx,
175 rtx, int);
176extern rtx expand_ternary_op (machine_mode mode, optab ternary_optab,
177 rtx op0, rtx op1, rtx op2, rtx target,
178 int unsignedp);
179extern rtx simplify_expand_binop (machine_mode mode, optab binoptab,
180 rtx op0, rtx op1, rtx target, int unsignedp,
181 enum optab_methods methods);
182extern bool force_expand_binop (machine_mode, optab, rtx, rtx, rtx, int,
183 enum optab_methods);
be4c1d4a 184extern rtx expand_vector_broadcast (machine_mode, rtx);
b0710fe1
AM
185
186/* Generate code for a simple binary or unary operation. "Simple" in
187 this case means "can be unambiguously described by a (mode, code)
188 pair and mapped to a single optab." */
189extern rtx expand_simple_binop (machine_mode, enum rtx_code, rtx,
190 rtx, rtx, int, enum optab_methods);
191
192/* Expand a binary operation given optab and rtx operands. */
193extern rtx expand_binop (machine_mode, optab, rtx, rtx, rtx, int,
194 enum optab_methods);
a5c7d693 195
b0710fe1
AM
196/* Expand a binary operation with both signed and unsigned forms. */
197extern rtx sign_expand_binop (machine_mode, optab, optab, rtx, rtx,
198 rtx, int, enum optab_methods);
199
200/* Generate code to perform an operation on one operand with two results. */
201extern int expand_twoval_unop (optab, rtx, rtx, rtx, int);
202
203/* Generate code to perform an operation on two operands with two results. */
204extern int expand_twoval_binop (optab, rtx, rtx, rtx, rtx, int);
205
206/* Generate code to perform an operation on two operands with two
207 results, using a library function. */
208extern bool expand_twoval_binop_libfunc (optab, rtx, rtx, rtx, rtx,
209 enum rtx_code);
210extern rtx expand_simple_unop (machine_mode, enum rtx_code, rtx, rtx,
211 int);
212
213/* Expand a unary arithmetic operation given optab rtx operand. */
214extern rtx expand_unop (machine_mode, optab, rtx, rtx, int);
215
216/* Expand the absolute value operation. */
217extern rtx expand_abs_nojump (machine_mode, rtx, rtx, int);
218extern rtx expand_abs (machine_mode, rtx, rtx, int, int);
219
220/* Expand the one's complement absolute value operation. */
221extern rtx expand_one_cmpl_abs_nojump (machine_mode, rtx, rtx);
222
223/* Expand the copysign operation. */
224extern rtx expand_copysign (rtx, rtx, rtx);
225/* Generate an instruction with a given INSN_CODE with an output and
226 an input. */
227extern bool maybe_emit_unop_insn (enum insn_code, rtx, rtx, enum rtx_code);
228extern void emit_unop_insn (enum insn_code, rtx, rtx, enum rtx_code);
229
230/* Emit code to make a call to a constant function or a library call. */
f087c773 231extern void emit_libcall_block (rtx_insn *, rtx, rtx, rtx);
b0710fe1
AM
232
233/* The various uses that a comparison can have; used by can_compare_p:
234 jumps, conditional moves, store flag operations. */
235enum can_compare_purpose
236{
237 ccp_jump,
238 ccp_cmov,
239 ccp_store_flag
240};
241
242/* Nonzero if a compare of mode MODE can be done straightforwardly
243 (without splitting it into pieces). */
244extern int can_compare_p (enum rtx_code, machine_mode,
245 enum can_compare_purpose);
dcd2ca63
IL
246
247/* Return whether the backend can emit a vector comparison for code CODE,
248 comparing operands of mode CMP_OP_MODE and producing a result with
249 VALUE_MODE. */
250extern bool can_vcond_compare_p (enum rtx_code, machine_mode, machine_mode);
251
ef4bddc2
RS
252extern rtx prepare_operand (enum insn_code, rtx, int, machine_mode,
253 machine_mode, int);
b0710fe1
AM
254/* Emit a pair of rtl insns to compare two rtx's and to jump
255 to a label if the comparison is true. */
256extern void emit_cmp_and_jump_insns (rtx, rtx, enum rtx_code, rtx,
357067f2
JH
257 machine_mode, int, rtx,
258 profile_probability prob
259 = profile_probability::uninitialized ());
b0710fe1
AM
260
261/* Generate code to indirectly jump to a location given in the rtx LOC. */
262extern void emit_indirect_jump (rtx);
263
264#include "insn-config.h"
265
266#ifndef GCC_INSN_CONFIG_H
267#error "insn-config.h must be included before optabs.h"
268#endif
269
b0710fe1
AM
270/* Emit a conditional move operation. */
271rtx emit_conditional_move (rtx, enum rtx_code, rtx, rtx, machine_mode,
272 rtx, rtx, machine_mode, int);
273
ce68b5cf
KT
274/* Emit a conditional negate or bitwise complement operation. */
275rtx emit_conditional_neg_or_complement (rtx, rtx_code, machine_mode, rtx,
276 rtx, rtx);
277
b0710fe1
AM
278rtx emit_conditional_add (rtx, enum rtx_code, rtx, rtx, machine_mode,
279 rtx, rtx, machine_mode, int);
280
281/* Create but don't emit one rtl instruction to perform certain operations.
282 Modes must match; operands must meet the operation's predicates.
283 Likewise for subtraction and for just copying. */
e67d1102
RS
284extern rtx_insn *gen_add2_insn (rtx, rtx);
285extern rtx_insn *gen_add3_insn (rtx, rtx, rtx);
b0710fe1 286extern int have_add2_insn (rtx, rtx);
e67d1102 287extern rtx_insn *gen_addptr3_insn (rtx, rtx, rtx);
b0710fe1 288extern int have_addptr3_insn (rtx, rtx, rtx);
e67d1102
RS
289extern rtx_insn *gen_sub2_insn (rtx, rtx);
290extern rtx_insn *gen_sub3_insn (rtx, rtx, rtx);
b0710fe1
AM
291extern int have_sub2_insn (rtx, rtx);
292
b0710fe1
AM
293/* Generate the body of an insn to extend Y (with mode MFROM)
294 into X (with mode MTO). Do zero-extension if UNSIGNEDP is nonzero. */
e67d1102 295extern rtx_insn *gen_extend_insn (rtx, rtx, machine_mode, machine_mode, int);
b0710fe1 296
b0710fe1
AM
297/* Generate code for a FLOAT_EXPR. */
298extern void expand_float (rtx, rtx, int);
299
300/* Generate code for a FIX_EXPR. */
301extern void expand_fix (rtx, rtx, int);
302
303/* Generate code for a FIXED_CONVERT_EXPR. */
304extern void expand_fixed_convert (rtx, rtx, int, int);
305
306/* Generate code for float to integral conversion. */
307extern bool expand_sfix_optab (rtx, rtx, convert_optab);
308
309/* Report whether the machine description contains an insn which can
310 perform the operation described by CODE and MODE. */
311extern int have_insn_for (enum rtx_code, machine_mode);
2ef6ce06 312
b0710fe1 313/* Generate a conditional trap instruction. */
e67d1102 314extern rtx_insn *gen_cond_trap (enum rtx_code, rtx, rtx, rtx);
b0710fe1 315
b0710fe1 316/* Generate code for VEC_PERM_EXPR. */
f151c9e1
RS
317extern rtx expand_vec_perm_var (machine_mode, rtx, rtx, rtx, rtx);
318extern rtx expand_vec_perm_const (machine_mode, rtx, rtx,
319 const vec_perm_builder &, machine_mode, rtx);
b0710fe1 320
42fd8198
IE
321/* Generate code for vector comparison. */
322extern rtx expand_vec_cmp_expr (tree, tree, rtx);
323
b0710fe1
AM
324/* Generate code for VEC_COND_EXPR. */
325extern rtx expand_vec_cond_expr (tree, tree, tree, tree, rtx);
326
9adab579
RS
327/* Generate code for VEC_SERIES_EXPR. */
328extern rtx expand_vec_series_expr (machine_mode, rtx, rtx, rtx);
329
b0710fe1
AM
330/* Generate code for MULT_HIGHPART_EXPR. */
331extern rtx expand_mult_highpart (machine_mode, rtx, rtx, rtx, bool);
332
b0710fe1
AM
333extern rtx expand_sync_lock_test_and_set (rtx, rtx, rtx);
334extern rtx expand_atomic_test_and_set (rtx, rtx, enum memmodel);
335extern rtx expand_atomic_exchange (rtx, rtx, rtx, enum memmodel);
336extern bool expand_atomic_compare_and_swap (rtx *, rtx *, rtx, rtx, rtx, bool,
337 enum memmodel, enum memmodel);
338/* Generate memory barriers. */
339extern void expand_mem_thread_fence (enum memmodel);
340extern void expand_mem_signal_fence (enum memmodel);
341
342rtx expand_atomic_load (rtx, rtx, enum memmodel);
343rtx expand_atomic_store (rtx, rtx, enum memmodel, bool);
344rtx expand_atomic_fetch_op (rtx, rtx, rtx, enum rtx_code, enum memmodel,
345 bool);
346
347extern bool insn_operand_matches (enum insn_code icode, unsigned int opno,
348 rtx operand);
349extern bool valid_multiword_target_p (rtx);
99b1c316 350extern void create_convert_operand_from_type (class expand_operand *op,
b0710fe1
AM
351 rtx value, tree type);
352extern bool maybe_legitimize_operands (enum insn_code icode,
353 unsigned int opno, unsigned int nops,
99b1c316 354 class expand_operand *ops);
1476d1bd 355extern rtx_insn *maybe_gen_insn (enum insn_code icode, unsigned int nops,
99b1c316 356 class expand_operand *ops);
b0710fe1 357extern bool maybe_expand_insn (enum insn_code icode, unsigned int nops,
99b1c316 358 class expand_operand *ops);
b0710fe1 359extern bool maybe_expand_jump_insn (enum insn_code icode, unsigned int nops,
99b1c316 360 class expand_operand *ops);
b0710fe1 361extern void expand_insn (enum insn_code icode, unsigned int nops,
99b1c316 362 class expand_operand *ops);
b0710fe1 363extern void expand_jump_insn (enum insn_code icode, unsigned int nops,
99b1c316 364 class expand_operand *ops);
b0710fe1 365
2d52a3a1
ZC
366extern enum rtx_code get_rtx_code (enum tree_code tcode, bool unsignedp);
367
e78d8e51 368#endif /* GCC_OPTABS_H */