1 /* Definitions for code generation pass of GNU compiler.
2 Copyright (C) 2001-2017 Free Software Foundation, Inc.
4 This file is part of GCC.
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)
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.
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/>. */
23 #include "optabs-query.h"
24 #include "optabs-libfuncs.h"
26 /* Generate code for a widening multiply. */
27 extern rtx
expand_widening_mult (machine_mode
, rtx
, rtx
, rtx
, int, optab
);
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
{
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;
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;
51 /* Is the target operand. */
52 unsigned int target
: 1;
54 /* Unused; available for future use. */
55 unsigned int unused
: 6;
57 /* The mode passed to the convert_*_operand function. It has a
58 type-dependent meaning. */
59 ENUM_BITFIELD (machine_mode
) mode
: 16;
61 /* The value of the operand. */
64 /* The value of an EXPAND_INTEGER operand. */
68 /* Initialize OP with the given fields. Initialise the other fields
69 to their default values. */
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)
78 op
->unsigned_p
= unsigned_p
;
82 op
->int_value
= int_value
;
85 /* Make OP describe an operand that must use rtx X, even if X is volatile. */
88 create_fixed_operand (struct expand_operand
*op
, rtx x
)
90 create_expand_operand (op
, EXPAND_FIXED
, x
, VOIDmode
, false);
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. */
99 create_output_operand (struct expand_operand
*op
, rtx x
,
102 create_expand_operand (op
, EXPAND_OUTPUT
, x
, mode
, false);
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
111 create_input_operand (struct expand_operand
*op
, rtx value
,
114 create_expand_operand (op
, EXPAND_INPUT
, value
, mode
, false);
117 /* Like create_input_operand, except that VALUE must first be converted
118 to mode MODE. UNSIGNED_P says whether VALUE is unsigned. */
121 create_convert_operand_to (struct expand_operand
*op
, rtx value
,
122 machine_mode mode
, bool unsigned_p
)
124 create_expand_operand (op
, EXPAND_CONVERT_TO
, value
, mode
, unsigned_p
);
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. */
133 create_convert_operand_from (struct expand_operand
*op
, rtx value
,
134 machine_mode mode
, bool unsigned_p
)
136 create_expand_operand (op
, EXPAND_CONVERT_FROM
, value
, mode
, unsigned_p
);
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. */
144 create_address_operand (struct expand_operand
*op
, rtx value
)
146 create_expand_operand (op
, EXPAND_ADDRESS
, value
, Pmode
, false);
149 extern void create_integer_operand (struct expand_operand
*, poly_int64
);
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. */
167 extern rtx
expand_widen_pattern_expr (struct separate_ops
*, rtx
, rtx
, rtx
,
169 extern rtx
expand_ternary_op (machine_mode mode
, optab ternary_optab
,
170 rtx op0
, rtx op1
, rtx op2
, rtx target
,
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,
177 extern rtx
expand_vector_broadcast (machine_mode
, rtx
);
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
);
185 /* Expand a binary operation given optab and rtx operands. */
186 extern rtx
expand_binop (machine_mode
, optab
, rtx
, rtx
, rtx
, int,
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
);
193 /* Generate code to perform an operation on one operand with two results. */
194 extern int expand_twoval_unop (optab
, rtx
, rtx
, rtx
, int);
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);
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
,
203 extern rtx
expand_simple_unop (machine_mode
, enum rtx_code
, rtx
, rtx
,
206 /* Expand a unary arithmetic operation given optab rtx operand. */
207 extern rtx
expand_unop (machine_mode
, optab
, rtx
, rtx
, int);
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);
213 /* Expand the one's complement absolute value operation. */
214 extern rtx
expand_one_cmpl_abs_nojump (machine_mode
, rtx
, rtx
);
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
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
);
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
);
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
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
,
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 ());
248 /* Generate code to indirectly jump to a location given in the rtx LOC. */
249 extern void emit_indirect_jump (rtx
);
251 #include "insn-config.h"
253 #ifndef GCC_INSN_CONFIG_H
254 #error "insn-config.h must be included before optabs.h"
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);
261 /* Emit a conditional negate or bitwise complement operation. */
262 rtx
emit_conditional_neg_or_complement (rtx
, rtx_code
, machine_mode
, rtx
,
265 rtx
emit_conditional_add (rtx
, enum rtx_code
, rtx
, rtx
, machine_mode
,
266 rtx
, rtx
, machine_mode
, int);
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
);
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);
284 /* Generate code for a FLOAT_EXPR. */
285 extern void expand_float (rtx
, rtx
, int);
287 /* Generate code for a FIX_EXPR. */
288 extern void expand_fix (rtx
, rtx
, int);
290 /* Generate code for a FIXED_CONVERT_EXPR. */
291 extern void expand_fixed_convert (rtx
, rtx
, int, int);
293 /* Generate code for float to integral conversion. */
294 extern bool expand_sfix_optab (rtx
, rtx
, convert_optab
);
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
);
300 /* Generate a conditional trap instruction. */
301 extern rtx_insn
*gen_cond_trap (enum rtx_code
, rtx
, rtx
, rtx
);
303 /* Generate code for VEC_PERM_EXPR. */
304 extern rtx
expand_vec_perm (machine_mode
, rtx
, rtx
, rtx
, rtx
);
306 /* Generate code for vector comparison. */
307 extern rtx
expand_vec_cmp_expr (tree
, tree
, rtx
);
309 /* Generate code for VEC_COND_EXPR. */
310 extern rtx
expand_vec_cond_expr (tree
, tree
, tree
, tree
, rtx
);
312 /* Generate code for VEC_SERIES_EXPR. */
313 extern rtx
expand_vec_series_expr (machine_mode
, rtx
, rtx
, rtx
);
315 /* Generate code for MULT_HIGHPART_EXPR. */
316 extern rtx
expand_mult_highpart (machine_mode
, rtx
, rtx
, rtx
, bool);
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
);
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
,
332 extern bool insn_operand_matches (enum insn_code icode
, unsigned int opno
,
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
);
351 extern enum rtx_code
get_rtx_code (enum tree_code tcode
, bool unsignedp
);
353 #endif /* GCC_OPTABS_H */