]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/expr.h
Ada: Switch from ACATS 2.6 to ACATS 4.2 testsuite
[thirdparty/gcc.git] / gcc / expr.h
CommitLineData
e8bbfc4e 1/* Definitions for code generation pass of GNU compiler.
6441eb6d 2 Copyright (C) 1987-2025 Free Software Foundation, Inc.
e8bbfc4e 3
1322177d 4This file is part of GCC.
e8bbfc4e 5
1322177d
LB
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
9dcd6f09 8Software Foundation; either version 3, or (at your option) any later
1322177d 9version.
e8bbfc4e 10
1322177d
LB
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
e8bbfc4e
RK
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/>. */
e8bbfc4e 19
78528714
JQ
20#ifndef GCC_EXPR_H
21#define GCC_EXPR_H
22
e8bbfc4e 23/* This is the 4th arg to `expand_expr'.
8403445a 24 EXPAND_STACK_PARM means we are possibly expanding a call param onto
0cc1b879 25 the stack.
e8bbfc4e
RK
26 EXPAND_SUM means it is ok to return a PLUS rtx or MULT rtx.
27 EXPAND_INITIALIZER is similar but also record any labels on forced_labels.
28 EXPAND_CONST_ADDRESS means it is ok to return a MEM whose address
99b5da08 29 is a constant that is not a legitimate address.
017e1b43
RH
30 EXPAND_WRITE means we are only going to write to the resulting rtx.
31 EXPAND_MEMORY means we are interested in a memory result, even if
4c437f02
BE
32 the memory is constant and we could have propagated a constant value,
33 or the memory is unaligned on a STRICT_ALIGNMENT target. */
0cc1b879 34enum expand_modifier {EXPAND_NORMAL = 0, EXPAND_STACK_PARM, EXPAND_SUM,
017e1b43
RH
35 EXPAND_CONST_ADDRESS, EXPAND_INITIALIZER, EXPAND_WRITE,
36 EXPAND_MEMORY};
e8bbfc4e 37
5c7a310f
MM
38/* Prevent the compiler from deferring stack pops. See
39 inhibit_defer_pop for more information. */
40#define NO_DEFER_POP (inhibit_defer_pop += 1)
41
42/* Allow the compiler to defer stack pops. See inhibit_defer_pop for
43 more information. */
44#define OK_DEFER_POP (inhibit_defer_pop -= 1)
e8bbfc4e 45\f
8e7aa1f9
MM
46/* This structure is used to pass around information about exploded
47 unary, binary and trinary expressions between expand_expr_real_1 and
48 friends. */
49typedef struct separate_ops
50{
51 enum tree_code code;
25efe060 52 location_t location;
8e7aa1f9
MM
53 tree type;
54 tree op0, op1, op2;
8e7aa1f9 55} *sepops;
d8a6de9e
AP
56
57typedef const struct separate_ops *const_sepops;
12e74c9e 58\f
b8698a0f 59/* This is run during target initialization to set up which modes can be
b5deb7b6
SL
60 used directly in memory and to initialize the block move optab. */
61extern void init_expr_target (void);
12e74c9e
RK
62
63/* This is run at the start of compiling a function. */
502b8322 64extern void init_expr (void);
12e74c9e 65
e8bbfc4e
RK
66/* Emit some rtl insns to move data between rtx's, converting machine modes.
67 Both modes must be floating or both fixed. */
502b8322 68extern void convert_move (rtx, rtx, int);
e8bbfc4e
RK
69
70/* Convert an rtx to specified machine mode and return the result. */
ef4bddc2 71extern rtx convert_to_mode (machine_mode, rtx, int);
e8bbfc4e 72
3fad11c9 73/* Convert an rtx to MODE from OLDMODE and return the result. */
ac4c8f53
RS
74extern rtx convert_modes (machine_mode mode, machine_mode oldmode,
75 rtx x, int unsignedp);
76
77/* Variant of convert_modes for ABI parameter passing/return. */
78extern rtx convert_float_to_wider_int (machine_mode mode, machine_mode fmode,
79 rtx x);
80
81/* Variant of convert_modes for ABI parameter passing/return. */
82extern rtx convert_wider_int_to_float (machine_mode mode, machine_mode imode,
83 rtx x);
3fad11c9 84
ee516de9
EB
85/* Expand a call to memcpy or memmove or memcmp, and return the result. */
86extern rtx emit_block_op_via_libcall (enum built_in_function, rtx, rtx, rtx,
87 bool);
88
cb3e0eac 89inline rtx
ee516de9
EB
90emit_block_copy_via_libcall (rtx dst, rtx src, rtx size, bool tailcall = false)
91{
92 return emit_block_op_via_libcall (BUILT_IN_MEMCPY, dst, src, size, tailcall);
93}
94
cb3e0eac 95inline rtx
ee516de9
EB
96emit_block_move_via_libcall (rtx dst, rtx src, rtx size, bool tailcall = false)
97{
98 return emit_block_op_via_libcall (BUILT_IN_MEMMOVE, dst, src, size, tailcall);
99}
100
cb3e0eac 101inline rtx
ee516de9
EB
102emit_block_comp_via_libcall (rtx dst, rtx src, rtx size, bool tailcall = false)
103{
104 return emit_block_op_via_libcall (BUILT_IN_MEMCMP, dst, src, size, tailcall);
105}
44bb111a 106
ee516de9 107/* Emit code to move a block Y to a block X. */
44bb111a
RH
108enum block_op_methods
109{
110 BLOCK_OP_NORMAL,
8403445a 111 BLOCK_OP_NO_LIBCALL,
8148fe65
JJ
112 BLOCK_OP_CALL_PARM,
113 /* Like BLOCK_OP_NORMAL, but the libcall can be tail call optimized. */
fdd33254
ML
114 BLOCK_OP_TAILCALL,
115 /* Like BLOCK_OP_NO_LIBCALL, but instead of emitting a libcall return
116 pc_rtx to indicate nothing has been emitted and let the caller handle
117 it. */
118 BLOCK_OP_NO_LIBCALL_RET
44bb111a
RH
119};
120
985b3a68 121typedef rtx (*by_pieces_constfn) (void *, void *, HOST_WIDE_INT,
e5e164ef 122 fixed_size_mode);
985b3a68
L
123
124/* The second pointer passed to by_pieces_constfn. */
125struct by_pieces_prev
126{
127 rtx data;
e5e164ef 128 fixed_size_mode mode;
985b3a68 129};
36b85e43 130
1ff6d9f7
AO
131extern rtx emit_block_move (rtx, rtx, rtx, enum block_op_methods,
132 unsigned ctz_size = 0);
079a182e 133extern rtx emit_block_move_hints (rtx, rtx, rtx, enum block_op_methods,
3918b108
JH
134 unsigned int, HOST_WIDE_INT,
135 unsigned HOST_WIDE_INT,
82bb7d4e 136 unsigned HOST_WIDE_INT,
db91c7cf
ML
137 unsigned HOST_WIDE_INT,
138 bool bail_out_libcall = false,
03a9b90a 139 bool *is_move_done = NULL,
1ff6d9f7
AO
140 bool might_overlap = false,
141 unsigned ctz_size = 0);
36b85e43 142extern rtx emit_block_cmp_hints (rtx, rtx, rtx, tree, rtx, bool,
1ff6d9f7
AO
143 by_pieces_constfn, void *,
144 unsigned ctz_len = 0);
28ed065e 145extern bool emit_storent_insn (rtx to, rtx from);
12e74c9e
RK
146
147/* Copy all or part of a value X into registers starting at REGNO.
148 The number of registers to be filled is NREGS. */
ef4bddc2 149extern void move_block_to_reg (int, rtx, int, machine_mode);
12e74c9e
RK
150
151/* Copy all or part of a BLKmode value X out of registers starting at REGNO.
152 The number of registers to be filled is NREGS. */
502b8322 153extern void move_block_from_reg (int, rtx, int);
12e74c9e 154
084a1106 155/* Generate a non-consecutive group of registers represented by a PARALLEL. */
502b8322 156extern rtx gen_group_rtx (rtx);
084a1106 157
ae73d3be
JW
158/* Load a BLKmode value into non-consecutive registers represented by a
159 PARALLEL. */
f8f667be 160extern void emit_group_load (rtx, rtx, tree, poly_int64);
729a2125 161
27e29549 162/* Similarly, but load into new temporaries. */
f8f667be 163extern rtx emit_group_load_into_temps (rtx, rtx, tree, poly_int64);
27e29549 164
084a1106
JDA
165/* Move a non-consecutive group of registers represented by a PARALLEL into
166 a non-consecutive group of registers represented by a PARALLEL. */
502b8322 167extern void emit_group_move (rtx, rtx);
084a1106 168
27e29549
RH
169/* Move a group of registers represented by a PARALLEL into pseudos. */
170extern rtx emit_group_move_into_temps (rtx);
171
ae73d3be
JW
172/* Store a BLKmode value from non-consecutive registers represented by a
173 PARALLEL. */
f8f667be 174extern void emit_group_store (rtx, rtx, tree, poly_int64);
ae73d3be 175
9a002da8
RS
176extern rtx maybe_emit_group_store (rtx, tree);
177
7d810276
JJ
178/* Mark REG as holding a parameter for the next CALL_INSN.
179 Mode is TYPE_MODE of the non-promoted parameter, or VOIDmode. */
ef4bddc2
RS
180extern void use_reg_mode (rtx *, rtx, machine_mode);
181extern void clobber_reg_mode (rtx *, rtx, machine_mode);
7d810276 182
ef4bddc2 183extern rtx copy_blkmode_to_reg (machine_mode, tree);
2ba87a29 184
8c99eaf6 185/* Mark REG as holding a parameter for the next CALL_INSN. */
cb3e0eac 186inline void
7d810276
JJ
187use_reg (rtx *fusage, rtx reg)
188{
189 use_reg_mode (fusage, reg, VOIDmode);
190}
729a2125 191
97891c11 192/* Mark REG as clobbered by the call with FUSAGE as CALL_INSN_FUNCTION_USAGE. */
cb3e0eac 193inline void
97891c11
TV
194clobber_reg (rtx *fusage, rtx reg)
195{
196 clobber_reg_mode (fusage, reg, VOIDmode);
197}
198
8c99eaf6
RK
199/* Mark NREGS consecutive regs, starting at REGNO, as holding parameters
200 for the next CALL_INSN. */
502b8322 201extern void use_regs (rtx *, int, int);
729a2125 202
ae73d3be 203/* Mark a PARALLEL as holding a parameter for the next CALL_INSN. */
502b8322 204extern void use_group_regs (rtx *, rtx);
12e74c9e 205
36b85e43
BS
206#ifdef GCC_INSN_CODES_H
207extern rtx expand_cmpstrn_or_cmpmem (insn_code, rtx, rtx, rtx, tree, rtx,
208 HOST_WIDE_INT);
209#endif
210
12e74c9e 211/* Write zeros through the storage of OBJECT.
8ac61af7 212 If OBJECT has BLKmode, SIZE is its length in bytes. */
8148fe65 213extern rtx clear_storage (rtx, rtx, enum block_op_methods);
079a182e 214extern rtx clear_storage_hints (rtx, rtx, enum block_op_methods,
3918b108
JH
215 unsigned int, HOST_WIDE_INT,
216 unsigned HOST_WIDE_INT,
82bb7d4e 217 unsigned HOST_WIDE_INT,
da9e6e63
AO
218 unsigned HOST_WIDE_INT,
219 unsigned);
8c996513 220/* The same, but always output an library call. */
ee516de9 221extern rtx set_storage_via_libcall (rtx, rtx, rtx, bool = false);
12e74c9e 222
57e84f18 223/* Expand a setmem pattern; return true if successful. */
b8698a0f 224extern bool set_storage_via_setmem (rtx, rtx, rtx, unsigned int,
3918b108
JH
225 unsigned int, HOST_WIDE_INT,
226 unsigned HOST_WIDE_INT,
82bb7d4e 227 unsigned HOST_WIDE_INT,
3918b108 228 unsigned HOST_WIDE_INT);
57e84f18 229
c41332ab 230/* Return true if it is desirable to store LEN bytes generated by
57814e5e
JJ
231 CONSTFUN with several move instructions by store_by_pieces
232 function. CONSTFUNDATA is a pointer which will be passed as argument
233 in every CONSTFUN call.
cfa31150
SL
234 ALIGN is maximum alignment we can assume.
235 MEMSETP is true if this is a real memset/bzero, not a copy
236 of a const string. */
c41332ab
UB
237extern bool can_store_by_pieces (unsigned HOST_WIDE_INT,
238 by_pieces_constfn,
239 void *, unsigned int, bool);
57814e5e
JJ
240
241/* Generate several move instructions to store LEN bytes generated by
242 CONSTFUN to block TO. (A MEM rtx with BLKmode). CONSTFUNDATA is a
243 pointer which will be passed as argument in every CONSTFUN call.
8fd3cf4e 244 ALIGN is maximum alignment we can assume.
cfa31150 245 MEMSETP is true if this is a real memset/bzero, not a copy.
8fd3cf4e 246 Returns TO + LEN. */
36b85e43 247extern rtx store_by_pieces (rtx, unsigned HOST_WIDE_INT, by_pieces_constfn,
2ff5ffb6 248 void *, unsigned int, bool, memop_ret);
57814e5e 249
e6e41b68
CM
250/* Generate several move instructions to clear LEN bytes of block TO. (A MEM
251 rtx with BLKmode). ALIGN is maximum alignment we can assume. */
252
253extern void clear_by_pieces (rtx, unsigned HOST_WIDE_INT, unsigned int);
254
da9e6e63
AO
255/* If can_store_by_pieces passes for worst-case values near MAX_LEN, call
256 store_by_pieces within conditionals so as to handle variable LEN efficiently,
257 storing VAL, if non-NULL_RTX, or valc instead. */
258extern bool try_store_by_multiple_pieces (rtx to, rtx len,
259 unsigned int ctz_len,
260 unsigned HOST_WIDE_INT min_len,
261 unsigned HOST_WIDE_INT max_len,
262 rtx val, char valc,
263 unsigned int align);
264
12e74c9e 265/* Emit insns to set X from Y. */
f3222b79 266extern rtx_insn *emit_move_insn (rtx, rtx);
1476d1bd 267extern rtx_insn *gen_move_insn (rtx, rtx);
12e74c9e
RK
268
269/* Emit insns to set X from Y, with no frills. */
f3222b79 270extern rtx_insn *emit_move_insn_1 (rtx, rtx);
12e74c9e 271
ef4bddc2 272extern rtx_insn *emit_move_complex_push (machine_mode, rtx, rtx);
f3222b79 273extern rtx_insn *emit_move_complex_parts (rtx, rtx);
1f9ceff1 274extern rtx read_complex_part (rtx, bool);
13f44099 275extern void write_complex_part (rtx, rtx, bool, bool);
ee45a32d 276extern rtx read_complex_part (rtx, bool);
ef4bddc2 277extern rtx emit_move_resolve_push (machine_mode, rtx);
ceca734e 278
12e74c9e
RK
279/* Push a block of length SIZE (perhaps variable)
280 and return an rtx to address the beginning of the block. */
a15b25dc 281extern rtx push_block (rtx, poly_int64, int);
12e74c9e 282
12e74c9e 283/* Generate code to push something onto the stack, given its mode and type. */
99206968 284extern bool emit_push_insn (rtx, machine_mode, tree, rtx, unsigned int,
a15b25dc 285 int, rtx, poly_int64, rtx, rtx, int, rtx, bool);
12e74c9e 286
585334d4 287/* Extract the accessible bit-range from a COMPONENT_REF. */
eaa41a6d
RS
288extern void get_bit_range (poly_uint64 *, poly_uint64 *, tree,
289 poly_int64 *, tree *);
8a91d545 290
19eb1ad7 291/* Expand an assignment that stores the value of FROM into TO. */
79f5e442 292extern void expand_assignment (tree, tree, bool);
12e74c9e
RK
293
294/* Generate code for computing expression EXP,
295 and storing the value into TARGET.
296 If SUGGEST_REG is nonzero, copy the value through a register
297 and return that register, if that is possible. */
ee45a32d 298extern rtx store_expr (tree, rtx, int, bool, bool);
e8bbfc4e
RK
299
300/* Given an rtx that may include add and multiply operations,
301 generate them as insns and return a pseudo-reg containing the value.
302 Useful after calling expand_expr with 1 as sum_ok. */
502b8322 303extern rtx force_operand (rtx, rtx);
e8bbfc4e 304
28ed065e 305/* Work horses for expand_expr. */
ef4bddc2 306extern rtx expand_expr_real (tree, rtx, machine_mode,
4c437f02 307 enum expand_modifier, rtx *, bool);
ef4bddc2 308extern rtx expand_expr_real_1 (tree, rtx, machine_mode,
4c437f02 309 enum expand_modifier, rtx *, bool);
d8a6de9e 310extern rtx expand_expr_real_2 (const_sepops, rtx, machine_mode,
28ed065e 311 enum expand_modifier);
06ee648e
AP
312extern rtx expand_expr_real_gassign (gassign *, rtx, machine_mode,
313 enum expand_modifier modifier,
314 rtx * = nullptr, bool = false);
673fda6b 315
12e74c9e
RK
316/* Generate code for computing expression EXP.
317 An rtx for the computed value is returned. The value is never null.
318 In the case of a void EXP, const0_rtx is returned. */
cb3e0eac 319inline rtx
ef4bddc2 320expand_expr (tree exp, rtx target, machine_mode mode,
673fda6b
SB
321 enum expand_modifier modifier)
322{
4c437f02 323 return expand_expr_real (exp, target, mode, modifier, NULL, false);
673fda6b 324}
12e74c9e 325
cb3e0eac 326inline rtx
84217346
MD
327expand_normal (tree exp)
328{
4c437f02 329 return expand_expr_real (exp, NULL_RTX, VOIDmode, EXPAND_NORMAL, NULL, false);
84217346
MD
330}
331
7f2f0a01 332
866626ef
MS
333/* Return STRING_CST and set offset, size and decl, if the first
334 argument corresponds to a string constant. */
e84bf0ef 335extern tree string_constant (tree, tree *, tree *, tree *);
866626ef
MS
336/* Similar to string_constant, return a STRING_CST corresponding
337 to the value representation of the first argument if it's
338 a constant. */
339extern tree byte_representation (tree, tree *, tree *, tree *);
c0cbe526
JJ
340
341extern enum tree_code maybe_optimize_mod_cmp (enum tree_code, tree *, tree *);
5de7bf5b 342extern void maybe_optimize_sub_cmp_0 (enum tree_code, tree *, tree *);
28f4ec01 343
ad82abb8 344/* Two different ways of generating switch statements. */
c41332ab
UB
345extern bool try_casesi (tree, tree, tree, tree, rtx, rtx, rtx,
346 profile_probability);
347extern bool try_tablejump (tree, tree, tree, tree, rtx, rtx,
348 profile_probability);
ad82abb8 349
c41332ab 350extern bool safe_from_p (const_rtx, tree, int);
8f17b5c5 351
f9417da1
RG
352/* Get the personality libfunc for a function decl. */
353rtx get_personality_function (tree);
354
d8a2d370
DN
355/* Determine whether the LEN bytes can be moved by using several move
356 instructions. Return nonzero if a call to move_by_pieces should
357 succeed. */
36b85e43 358extern bool can_move_by_pieces (unsigned HOST_WIDE_INT, unsigned int);
d8a2d370
DN
359
360extern unsigned HOST_WIDE_INT highest_pow2_factor (const_tree);
d8a2d370
DN
361
362extern bool categorize_ctor_elements (const_tree, HOST_WIDE_INT *,
0fca07e3 363 HOST_WIDE_INT *, HOST_WIDE_INT *,
673a448a
AO
364 int *);
365extern bool type_has_padding_at_level_p (tree);
ed6fd2ae 366extern bool immediate_const_ctor_p (const_tree, unsigned int words = 1);
c00e1e3a
RS
367extern void store_constructor (tree, rtx, int, poly_int64, bool);
368extern HOST_WIDE_INT int_expr_size (const_tree exp);
d8a2d370 369
2d52a3a1
ZC
370extern void expand_operands (tree, tree, rtx, rtx*, rtx*,
371 enum expand_modifier);
36566b39
PK
372
373/* rtl.h and tree.h were included. */
374/* Return an rtx for the size in bytes of the value of an expr. */
375extern rtx expr_size (tree);
376
7e0c0500
RB
377extern bool mem_ref_refers_to_non_mem_p (tree);
378extern bool non_mem_decl_p (tree);
379
74eb3570
MA
380/* Return the quotient of the polynomial long division of x^2N by POLYNOMIAL
381 in GF (2^N). */
382extern unsigned HOST_WIDE_INT
383gf2n_poly_long_div_quotient (unsigned HOST_WIDE_INT, unsigned short);
384
bb46d05a
MA
385/* Generate table-based CRC. */
386extern void generate_reflecting_code_standard (rtx *);
387extern void expand_crc_table_based (rtx, rtx, rtx, rtx, machine_mode);
388extern void expand_reversed_crc_table_based (rtx, rtx, rtx, rtx, machine_mode,
389 void (*) (rtx *));
390
78528714 391#endif /* GCC_EXPR_H */