]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/expr.h
Remove MPX
[thirdparty/gcc.git] / gcc / expr.h
CommitLineData
e8bbfc4e 1/* Definitions for code generation pass of GNU compiler.
85ec4feb 2 Copyright (C) 1987-2018 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;
12e74c9e 56\f
b8698a0f 57/* This is run during target initialization to set up which modes can be
b5deb7b6
SL
58 used directly in memory and to initialize the block move optab. */
59extern void init_expr_target (void);
12e74c9e
RK
60
61/* This is run at the start of compiling a function. */
502b8322 62extern void init_expr (void);
12e74c9e 63
e8bbfc4e
RK
64/* Emit some rtl insns to move data between rtx's, converting machine modes.
65 Both modes must be floating or both fixed. */
502b8322 66extern void convert_move (rtx, rtx, int);
e8bbfc4e
RK
67
68/* Convert an rtx to specified machine mode and return the result. */
ef4bddc2 69extern rtx convert_to_mode (machine_mode, rtx, int);
e8bbfc4e 70
3fad11c9 71/* Convert an rtx to MODE from OLDMODE and return the result. */
ef4bddc2 72extern rtx convert_modes (machine_mode, machine_mode, rtx, int);
3fad11c9 73
ee516de9
EB
74/* Expand a call to memcpy or memmove or memcmp, and return the result. */
75extern rtx emit_block_op_via_libcall (enum built_in_function, rtx, rtx, rtx,
76 bool);
77
78static inline rtx
79emit_block_copy_via_libcall (rtx dst, rtx src, rtx size, bool tailcall = false)
80{
81 return emit_block_op_via_libcall (BUILT_IN_MEMCPY, dst, src, size, tailcall);
82}
83
84static inline rtx
85emit_block_move_via_libcall (rtx dst, rtx src, rtx size, bool tailcall = false)
86{
87 return emit_block_op_via_libcall (BUILT_IN_MEMMOVE, dst, src, size, tailcall);
88}
89
90static inline rtx
91emit_block_comp_via_libcall (rtx dst, rtx src, rtx size, bool tailcall = false)
92{
93 return emit_block_op_via_libcall (BUILT_IN_MEMCMP, dst, src, size, tailcall);
94}
44bb111a 95
ee516de9 96/* Emit code to move a block Y to a block X. */
44bb111a
RH
97enum block_op_methods
98{
99 BLOCK_OP_NORMAL,
8403445a 100 BLOCK_OP_NO_LIBCALL,
8148fe65
JJ
101 BLOCK_OP_CALL_PARM,
102 /* Like BLOCK_OP_NORMAL, but the libcall can be tail call optimized. */
fdd33254
ML
103 BLOCK_OP_TAILCALL,
104 /* Like BLOCK_OP_NO_LIBCALL, but instead of emitting a libcall return
105 pc_rtx to indicate nothing has been emitted and let the caller handle
106 it. */
107 BLOCK_OP_NO_LIBCALL_RET
44bb111a
RH
108};
109
095a2d76 110typedef rtx (*by_pieces_constfn) (void *, HOST_WIDE_INT, scalar_int_mode);
36b85e43 111
502b8322 112extern rtx emit_block_move (rtx, rtx, rtx, enum block_op_methods);
079a182e 113extern rtx emit_block_move_hints (rtx, rtx, rtx, enum block_op_methods,
3918b108
JH
114 unsigned int, HOST_WIDE_INT,
115 unsigned HOST_WIDE_INT,
82bb7d4e 116 unsigned HOST_WIDE_INT,
3918b108 117 unsigned HOST_WIDE_INT);
36b85e43
BS
118extern rtx emit_block_cmp_hints (rtx, rtx, rtx, tree, rtx, bool,
119 by_pieces_constfn, void *);
28ed065e 120extern bool emit_storent_insn (rtx to, rtx from);
12e74c9e
RK
121
122/* Copy all or part of a value X into registers starting at REGNO.
123 The number of registers to be filled is NREGS. */
ef4bddc2 124extern void move_block_to_reg (int, rtx, int, machine_mode);
12e74c9e
RK
125
126/* Copy all or part of a BLKmode value X out of registers starting at REGNO.
127 The number of registers to be filled is NREGS. */
502b8322 128extern void move_block_from_reg (int, rtx, int);
12e74c9e 129
084a1106 130/* Generate a non-consecutive group of registers represented by a PARALLEL. */
502b8322 131extern rtx gen_group_rtx (rtx);
084a1106 132
ae73d3be
JW
133/* Load a BLKmode value into non-consecutive registers represented by a
134 PARALLEL. */
f8f667be 135extern void emit_group_load (rtx, rtx, tree, poly_int64);
729a2125 136
27e29549 137/* Similarly, but load into new temporaries. */
f8f667be 138extern rtx emit_group_load_into_temps (rtx, rtx, tree, poly_int64);
27e29549 139
084a1106
JDA
140/* Move a non-consecutive group of registers represented by a PARALLEL into
141 a non-consecutive group of registers represented by a PARALLEL. */
502b8322 142extern void emit_group_move (rtx, rtx);
084a1106 143
27e29549
RH
144/* Move a group of registers represented by a PARALLEL into pseudos. */
145extern rtx emit_group_move_into_temps (rtx);
146
ae73d3be
JW
147/* Store a BLKmode value from non-consecutive registers represented by a
148 PARALLEL. */
f8f667be 149extern void emit_group_store (rtx, rtx, tree, poly_int64);
ae73d3be 150
9a002da8
RS
151extern rtx maybe_emit_group_store (rtx, tree);
152
7d810276
JJ
153/* Mark REG as holding a parameter for the next CALL_INSN.
154 Mode is TYPE_MODE of the non-promoted parameter, or VOIDmode. */
ef4bddc2
RS
155extern void use_reg_mode (rtx *, rtx, machine_mode);
156extern void clobber_reg_mode (rtx *, rtx, machine_mode);
7d810276 157
ef4bddc2 158extern rtx copy_blkmode_to_reg (machine_mode, tree);
2ba87a29 159
8c99eaf6 160/* Mark REG as holding a parameter for the next CALL_INSN. */
7d810276
JJ
161static inline void
162use_reg (rtx *fusage, rtx reg)
163{
164 use_reg_mode (fusage, reg, VOIDmode);
165}
729a2125 166
97891c11
TV
167/* Mark REG as clobbered by the call with FUSAGE as CALL_INSN_FUNCTION_USAGE. */
168static inline void
169clobber_reg (rtx *fusage, rtx reg)
170{
171 clobber_reg_mode (fusage, reg, VOIDmode);
172}
173
8c99eaf6
RK
174/* Mark NREGS consecutive regs, starting at REGNO, as holding parameters
175 for the next CALL_INSN. */
502b8322 176extern void use_regs (rtx *, int, int);
729a2125 177
ae73d3be 178/* Mark a PARALLEL as holding a parameter for the next CALL_INSN. */
502b8322 179extern void use_group_regs (rtx *, rtx);
12e74c9e 180
36b85e43
BS
181#ifdef GCC_INSN_CODES_H
182extern rtx expand_cmpstrn_or_cmpmem (insn_code, rtx, rtx, rtx, tree, rtx,
183 HOST_WIDE_INT);
184#endif
185
12e74c9e 186/* Write zeros through the storage of OBJECT.
8ac61af7 187 If OBJECT has BLKmode, SIZE is its length in bytes. */
8148fe65 188extern rtx clear_storage (rtx, rtx, enum block_op_methods);
079a182e 189extern rtx clear_storage_hints (rtx, rtx, enum block_op_methods,
3918b108
JH
190 unsigned int, HOST_WIDE_INT,
191 unsigned HOST_WIDE_INT,
82bb7d4e 192 unsigned HOST_WIDE_INT,
3918b108 193 unsigned HOST_WIDE_INT);
8c996513 194/* The same, but always output an library call. */
ee516de9 195extern rtx set_storage_via_libcall (rtx, rtx, rtx, bool = false);
12e74c9e 196
57e84f18 197/* Expand a setmem pattern; return true if successful. */
b8698a0f 198extern bool set_storage_via_setmem (rtx, rtx, rtx, unsigned int,
3918b108
JH
199 unsigned int, HOST_WIDE_INT,
200 unsigned HOST_WIDE_INT,
82bb7d4e 201 unsigned HOST_WIDE_INT,
3918b108 202 unsigned HOST_WIDE_INT);
57e84f18 203
cc2902df 204/* Return nonzero if it is desirable to store LEN bytes generated by
57814e5e
JJ
205 CONSTFUN with several move instructions by store_by_pieces
206 function. CONSTFUNDATA is a pointer which will be passed as argument
207 in every CONSTFUN call.
cfa31150
SL
208 ALIGN is maximum alignment we can assume.
209 MEMSETP is true if this is a real memset/bzero, not a copy
210 of a const string. */
502b8322 211extern int can_store_by_pieces (unsigned HOST_WIDE_INT,
36b85e43 212 by_pieces_constfn,
cfa31150 213 void *, unsigned int, bool);
57814e5e
JJ
214
215/* Generate several move instructions to store LEN bytes generated by
216 CONSTFUN to block TO. (A MEM rtx with BLKmode). CONSTFUNDATA is a
217 pointer which will be passed as argument in every CONSTFUN call.
8fd3cf4e 218 ALIGN is maximum alignment we can assume.
cfa31150 219 MEMSETP is true if this is a real memset/bzero, not a copy.
8fd3cf4e 220 Returns TO + LEN. */
36b85e43 221extern rtx store_by_pieces (rtx, unsigned HOST_WIDE_INT, by_pieces_constfn,
cfa31150 222 void *, unsigned int, bool, int);
57814e5e 223
12e74c9e 224/* Emit insns to set X from Y. */
f3222b79 225extern rtx_insn *emit_move_insn (rtx, rtx);
1476d1bd 226extern rtx_insn *gen_move_insn (rtx, rtx);
12e74c9e
RK
227
228/* Emit insns to set X from Y, with no frills. */
f3222b79 229extern rtx_insn *emit_move_insn_1 (rtx, rtx);
12e74c9e 230
ef4bddc2 231extern rtx_insn *emit_move_complex_push (machine_mode, rtx, rtx);
f3222b79 232extern rtx_insn *emit_move_complex_parts (rtx, rtx);
1f9ceff1 233extern rtx read_complex_part (rtx, bool);
1304953e 234extern void write_complex_part (rtx, rtx, bool);
ee45a32d 235extern rtx read_complex_part (rtx, bool);
ef4bddc2 236extern rtx emit_move_resolve_push (machine_mode, rtx);
ceca734e 237
12e74c9e
RK
238/* Push a block of length SIZE (perhaps variable)
239 and return an rtx to address the beginning of the block. */
a15b25dc 240extern rtx push_block (rtx, poly_int64, int);
12e74c9e 241
12e74c9e 242/* Generate code to push something onto the stack, given its mode and type. */
99206968 243extern bool emit_push_insn (rtx, machine_mode, tree, rtx, unsigned int,
a15b25dc 244 int, rtx, poly_int64, rtx, rtx, int, rtx, bool);
12e74c9e 245
585334d4 246/* Extract the accessible bit-range from a COMPONENT_REF. */
39bb8924
RS
247extern void get_bit_range (poly_uint64_pod *, poly_uint64_pod *, tree,
248 poly_int64_pod *, tree *);
8a91d545 249
19eb1ad7 250/* Expand an assignment that stores the value of FROM into TO. */
79f5e442 251extern void expand_assignment (tree, tree, bool);
12e74c9e
RK
252
253/* Generate code for computing expression EXP,
254 and storing the value into TARGET.
255 If SUGGEST_REG is nonzero, copy the value through a register
256 and return that register, if that is possible. */
ee45a32d 257extern rtx store_expr (tree, rtx, int, bool, bool);
e8bbfc4e
RK
258
259/* Given an rtx that may include add and multiply operations,
260 generate them as insns and return a pseudo-reg containing the value.
261 Useful after calling expand_expr with 1 as sum_ok. */
502b8322 262extern rtx force_operand (rtx, rtx);
e8bbfc4e 263
28ed065e 264/* Work horses for expand_expr. */
ef4bddc2 265extern rtx expand_expr_real (tree, rtx, machine_mode,
4c437f02 266 enum expand_modifier, rtx *, bool);
ef4bddc2 267extern rtx expand_expr_real_1 (tree, rtx, machine_mode,
4c437f02 268 enum expand_modifier, rtx *, bool);
ef4bddc2 269extern rtx expand_expr_real_2 (sepops, rtx, machine_mode,
28ed065e 270 enum expand_modifier);
673fda6b 271
12e74c9e
RK
272/* Generate code for computing expression EXP.
273 An rtx for the computed value is returned. The value is never null.
274 In the case of a void EXP, const0_rtx is returned. */
673fda6b 275static inline rtx
ef4bddc2 276expand_expr (tree exp, rtx target, machine_mode mode,
673fda6b
SB
277 enum expand_modifier modifier)
278{
4c437f02 279 return expand_expr_real (exp, target, mode, modifier, NULL, false);
673fda6b 280}
12e74c9e 281
84217346
MD
282static inline rtx
283expand_normal (tree exp)
284{
4c437f02 285 return expand_expr_real (exp, NULL_RTX, VOIDmode, EXPAND_NORMAL, NULL, false);
84217346
MD
286}
287
7f2f0a01 288
28f4ec01
BS
289/* Return the tree node and offset if a given argument corresponds to
290 a string constant. */
502b8322 291extern tree string_constant (tree, tree *);
28f4ec01 292
ad82abb8 293/* Two different ways of generating switch statements. */
357067f2
JH
294extern int try_casesi (tree, tree, tree, tree, rtx, rtx, rtx, profile_probability);
295extern int try_tablejump (tree, tree, tree, tree, rtx, rtx, profile_probability);
ad82abb8 296
22ea9ec0 297extern int safe_from_p (const_rtx, tree, int);
8f17b5c5 298
f9417da1
RG
299/* Get the personality libfunc for a function decl. */
300rtx get_personality_function (tree);
301
d8a2d370
DN
302/* Determine whether the LEN bytes can be moved by using several move
303 instructions. Return nonzero if a call to move_by_pieces should
304 succeed. */
36b85e43 305extern bool can_move_by_pieces (unsigned HOST_WIDE_INT, unsigned int);
d8a2d370
DN
306
307extern unsigned HOST_WIDE_INT highest_pow2_factor (const_tree);
d8a2d370
DN
308
309extern bool categorize_ctor_elements (const_tree, HOST_WIDE_INT *,
310 HOST_WIDE_INT *, bool *);
311
2d52a3a1
ZC
312extern void expand_operands (tree, tree, rtx, rtx*, rtx*,
313 enum expand_modifier);
36566b39
PK
314
315/* rtl.h and tree.h were included. */
316/* Return an rtx for the size in bytes of the value of an expr. */
317extern rtx expr_size (tree);
318
78528714 319#endif /* GCC_EXPR_H */