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