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