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