]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/expr.h
Update copyright years.
[thirdparty/gcc.git] / gcc / expr.h
CommitLineData
dbb0cd11 1/* Definitions for code generation pass of GNU compiler.
f1717362 2 Copyright (C) 1987-2016 Free Software Foundation, Inc.
dbb0cd11 3
f12b58b3 4This file is part of GCC.
dbb0cd11 5
f12b58b3 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
8c4c00c1 8Software Foundation; either version 3, or (at your option) any later
f12b58b3 9version.
dbb0cd11 10
f12b58b3 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.
dbb0cd11 15
16You should have received a copy of the GNU General Public License
8c4c00c1 17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
dbb0cd11 19
4c74e6d9 20#ifndef GCC_EXPR_H
21#define GCC_EXPR_H
22
dbb0cd11 23/* This is the 4th arg to `expand_expr'.
a35a63ff 24 EXPAND_STACK_PARM means we are possibly expanding a call param onto
6cf92966 25 the stack.
dbb0cd11 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
ab716090 29 is a constant that is not a legitimate address.
68b956ae 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
a12f023f 32 the memory is constant and we could have propagated a constant value,
33 or the memory is unaligned on a STRICT_ALIGNMENT target. */
6cf92966 34enum expand_modifier {EXPAND_NORMAL = 0, EXPAND_STACK_PARM, EXPAND_SUM,
68b956ae 35 EXPAND_CONST_ADDRESS, EXPAND_INITIALIZER, EXPAND_WRITE,
36 EXPAND_MEMORY};
dbb0cd11 37
b49854c6 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)
dbb0cd11 45\f
2c02962c 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;
b7834994 52 location_t location;
2c02962c 53 tree type;
54 tree op0, op1, op2;
2c02962c 55} *sepops;
b5479824 56\f
48e1416a 57/* This is run during target initialization to set up which modes can be
6d8b68a3 58 used directly in memory and to initialize the block move optab. */
59extern void init_expr_target (void);
b5479824 60
61/* This is run at the start of compiling a function. */
35cb5232 62extern void init_expr (void);
b5479824 63
dbb0cd11 64/* Emit some rtl insns to move data between rtx's, converting machine modes.
65 Both modes must be floating or both fixed. */
35cb5232 66extern void convert_move (rtx, rtx, int);
dbb0cd11 67
68/* Convert an rtx to specified machine mode and return the result. */
3754d046 69extern rtx convert_to_mode (machine_mode, rtx, int);
dbb0cd11 70
48e657fd 71/* Convert an rtx to MODE from OLDMODE and return the result. */
3754d046 72extern rtx convert_modes (machine_mode, machine_mode, rtx, int);
48e657fd 73
b2d92e37 74/* Emit code to move a block Y to a block X. */
0378dbdc 75
76enum block_op_methods
77{
78 BLOCK_OP_NORMAL,
a35a63ff 79 BLOCK_OP_NO_LIBCALL,
0b25db21 80 BLOCK_OP_CALL_PARM,
81 /* Like BLOCK_OP_NORMAL, but the libcall can be tail call optimized. */
82 BLOCK_OP_TAILCALL
0378dbdc 83};
84
d8f74faa 85extern GTY(()) tree block_clear_fn;
35cb5232 86extern void init_block_move_fn (const char *);
87extern void init_block_clear_fn (const char *);
d459e0d8 88
35cb5232 89extern rtx emit_block_move (rtx, rtx, rtx, enum block_op_methods);
ab608690 90extern rtx emit_block_move_via_libcall (rtx, rtx, rtx, bool);
162719b3 91extern rtx emit_block_move_hints (rtx, rtx, rtx, enum block_op_methods,
36d63243 92 unsigned int, HOST_WIDE_INT,
93 unsigned HOST_WIDE_INT,
9db0f34d 94 unsigned HOST_WIDE_INT,
36d63243 95 unsigned HOST_WIDE_INT);
16c9337c 96extern bool emit_storent_insn (rtx to, rtx from);
b5479824 97
98/* Copy all or part of a value X into registers starting at REGNO.
99 The number of registers to be filled is NREGS. */
3754d046 100extern void move_block_to_reg (int, rtx, int, machine_mode);
b5479824 101
102/* Copy all or part of a BLKmode value X out of registers starting at REGNO.
103 The number of registers to be filled is NREGS. */
35cb5232 104extern void move_block_from_reg (int, rtx, int);
b5479824 105
b566e2e5 106/* Generate a non-consecutive group of registers represented by a PARALLEL. */
35cb5232 107extern rtx gen_group_rtx (rtx);
b566e2e5 108
2dbc68f6 109/* Load a BLKmode value into non-consecutive registers represented by a
110 PARALLEL. */
5f4cd670 111extern void emit_group_load (rtx, rtx, tree, int);
fe352cf1 112
e2ff5c1b 113/* Similarly, but load into new temporaries. */
114extern rtx emit_group_load_into_temps (rtx, rtx, tree, int);
115
b566e2e5 116/* Move a non-consecutive group of registers represented by a PARALLEL into
117 a non-consecutive group of registers represented by a PARALLEL. */
35cb5232 118extern void emit_group_move (rtx, rtx);
b566e2e5 119
e2ff5c1b 120/* Move a group of registers represented by a PARALLEL into pseudos. */
121extern rtx emit_group_move_into_temps (rtx);
122
2dbc68f6 123/* Store a BLKmode value from non-consecutive registers represented by a
124 PARALLEL. */
5f4cd670 125extern void emit_group_store (rtx, rtx, tree, int);
2dbc68f6 126
933eb13a 127extern rtx maybe_emit_group_store (rtx, tree);
128
ab6d34f7 129/* Copy BLKmode object from a set of registers. */
7e91b548 130extern void copy_blkmode_from_reg (rtx, rtx, tree);
25eb0f59 131
b4eeceb9 132/* Mark REG as holding a parameter for the next CALL_INSN.
133 Mode is TYPE_MODE of the non-promoted parameter, or VOIDmode. */
3754d046 134extern void use_reg_mode (rtx *, rtx, machine_mode);
135extern void clobber_reg_mode (rtx *, rtx, machine_mode);
b4eeceb9 136
3754d046 137extern rtx copy_blkmode_to_reg (machine_mode, tree);
ee5ab2d1 138
14602aee 139/* Mark REG as holding a parameter for the next CALL_INSN. */
b4eeceb9 140static inline void
141use_reg (rtx *fusage, rtx reg)
142{
143 use_reg_mode (fusage, reg, VOIDmode);
144}
fe352cf1 145
e67cfba4 146/* Mark REG as clobbered by the call with FUSAGE as CALL_INSN_FUNCTION_USAGE. */
147static inline void
148clobber_reg (rtx *fusage, rtx reg)
149{
150 clobber_reg_mode (fusage, reg, VOIDmode);
151}
152
14602aee 153/* Mark NREGS consecutive regs, starting at REGNO, as holding parameters
154 for the next CALL_INSN. */
35cb5232 155extern void use_regs (rtx *, int, int);
fe352cf1 156
2dbc68f6 157/* Mark a PARALLEL as holding a parameter for the next CALL_INSN. */
35cb5232 158extern void use_group_regs (rtx *, rtx);
b5479824 159
160/* Write zeros through the storage of OBJECT.
2a631e19 161 If OBJECT has BLKmode, SIZE is its length in bytes. */
0b25db21 162extern rtx clear_storage (rtx, rtx, enum block_op_methods);
162719b3 163extern rtx clear_storage_hints (rtx, rtx, enum block_op_methods,
36d63243 164 unsigned int, HOST_WIDE_INT,
165 unsigned HOST_WIDE_INT,
9db0f34d 166 unsigned HOST_WIDE_INT,
36d63243 167 unsigned HOST_WIDE_INT);
ab608690 168/* The same, but always output an library call. */
169rtx set_storage_via_libcall (rtx, rtx, rtx, bool);
b5479824 170
7a3e5564 171/* Expand a setmem pattern; return true if successful. */
48e1416a 172extern bool set_storage_via_setmem (rtx, rtx, rtx, unsigned int,
36d63243 173 unsigned int, HOST_WIDE_INT,
174 unsigned HOST_WIDE_INT,
9db0f34d 175 unsigned HOST_WIDE_INT,
36d63243 176 unsigned HOST_WIDE_INT);
7a3e5564 177
8136e769 178extern unsigned HOST_WIDE_INT move_by_pieces_ninsns (unsigned HOST_WIDE_INT,
179 unsigned int,
180 unsigned int);
181
6ef828f9 182/* Return nonzero if it is desirable to store LEN bytes generated by
6840589f 183 CONSTFUN with several move instructions by store_by_pieces
184 function. CONSTFUNDATA is a pointer which will be passed as argument
185 in every CONSTFUN call.
4b297e2e 186 ALIGN is maximum alignment we can assume.
187 MEMSETP is true if this is a real memset/bzero, not a copy
188 of a const string. */
35cb5232 189extern int can_store_by_pieces (unsigned HOST_WIDE_INT,
190 rtx (*) (void *, HOST_WIDE_INT,
3754d046 191 machine_mode),
4b297e2e 192 void *, unsigned int, bool);
6840589f 193
194/* Generate several move instructions to store LEN bytes generated by
195 CONSTFUN to block TO. (A MEM rtx with BLKmode). CONSTFUNDATA is a
196 pointer which will be passed as argument in every CONSTFUN call.
9fe0e1b8 197 ALIGN is maximum alignment we can assume.
4b297e2e 198 MEMSETP is true if this is a real memset/bzero, not a copy.
9fe0e1b8 199 Returns TO + LEN. */
35cb5232 200extern rtx store_by_pieces (rtx, unsigned HOST_WIDE_INT,
3754d046 201 rtx (*) (void *, HOST_WIDE_INT, machine_mode),
4b297e2e 202 void *, unsigned int, bool, int);
6840589f 203
b5479824 204/* Emit insns to set X from Y. */
c81fd430 205extern rtx_insn *emit_move_insn (rtx, rtx);
f9a00e9e 206extern rtx_insn *gen_move_insn (rtx, rtx);
b5479824 207
208/* Emit insns to set X from Y, with no frills. */
c81fd430 209extern rtx_insn *emit_move_insn_1 (rtx, rtx);
b5479824 210
3754d046 211extern rtx_insn *emit_move_complex_push (machine_mode, rtx, rtx);
c81fd430 212extern rtx_insn *emit_move_complex_parts (rtx, rtx);
94f92c36 213extern rtx read_complex_part (rtx, bool);
0c93c8a9 214extern void write_complex_part (rtx, rtx, bool);
292237f3 215extern rtx read_complex_part (rtx, bool);
3754d046 216extern rtx emit_move_resolve_push (machine_mode, rtx);
64003036 217
b5479824 218/* Push a block of length SIZE (perhaps variable)
219 and return an rtx to address the beginning of the block. */
35cb5232 220extern rtx push_block (rtx, int, int);
b5479824 221
b5479824 222/* Generate code to push something onto the stack, given its mode and type. */
a95e5776 223extern bool emit_push_insn (rtx, machine_mode, tree, rtx, unsigned int,
224 int, rtx, int, rtx, rtx, int, rtx, bool);
b5479824 225
ab6d34f7 226/* Expand an assignment that stores the value of FROM into TO. */
5b5037b3 227extern void expand_assignment (tree, tree, bool);
b5479824 228
229/* Generate code for computing expression EXP,
230 and storing the value into TARGET.
231 If SUGGEST_REG is nonzero, copy the value through a register
232 and return that register, if that is possible. */
292237f3 233extern rtx store_expr_with_bounds (tree, rtx, int, bool, bool, tree);
234extern rtx store_expr (tree, rtx, int, bool, bool);
dbb0cd11 235
236/* Given an rtx that may include add and multiply operations,
237 generate them as insns and return a pseudo-reg containing the value.
238 Useful after calling expand_expr with 1 as sum_ok. */
35cb5232 239extern rtx force_operand (rtx, rtx);
dbb0cd11 240
16c9337c 241/* Work horses for expand_expr. */
3754d046 242extern rtx expand_expr_real (tree, rtx, machine_mode,
a12f023f 243 enum expand_modifier, rtx *, bool);
3754d046 244extern rtx expand_expr_real_1 (tree, rtx, machine_mode,
a12f023f 245 enum expand_modifier, rtx *, bool);
3754d046 246extern rtx expand_expr_real_2 (sepops, rtx, machine_mode,
16c9337c 247 enum expand_modifier);
5135beeb 248
b5479824 249/* Generate code for computing expression EXP.
250 An rtx for the computed value is returned. The value is never null.
251 In the case of a void EXP, const0_rtx is returned. */
5135beeb 252static inline rtx
3754d046 253expand_expr (tree exp, rtx target, machine_mode mode,
5135beeb 254 enum expand_modifier modifier)
255{
a12f023f 256 return expand_expr_real (exp, target, mode, modifier, NULL, false);
5135beeb 257}
b5479824 258
8ec3c5c2 259static inline rtx
260expand_normal (tree exp)
261{
a12f023f 262 return expand_expr_real (exp, NULL_RTX, VOIDmode, EXPAND_NORMAL, NULL, false);
8ec3c5c2 263}
264
b6d206a2 265
53800dbe 266/* Return the tree node and offset if a given argument corresponds to
267 a string constant. */
35cb5232 268extern tree string_constant (tree, tree *);
53800dbe 269
539a3a92 270/* Two different ways of generating switch statements. */
584abc98 271extern int try_casesi (tree, tree, tree, tree, rtx, rtx, rtx, int);
272extern int try_tablejump (tree, tree, tree, tree, rtx, rtx, int);
539a3a92 273
1f1872fd 274extern int safe_from_p (const_rtx, tree, int);
e41f0d80 275
58d82cd0 276/* Get the personality libfunc for a function decl. */
277rtx get_personality_function (tree);
278
9ed99284 279/* Determine whether the LEN bytes can be moved by using several move
280 instructions. Return nonzero if a call to move_by_pieces should
281 succeed. */
282extern int can_move_by_pieces (unsigned HOST_WIDE_INT, unsigned int);
283
284extern unsigned HOST_WIDE_INT highest_pow2_factor (const_tree);
9ed99284 285
286extern bool categorize_ctor_elements (const_tree, HOST_WIDE_INT *,
287 HOST_WIDE_INT *, bool *);
288
01ee997b 289extern void expand_operands (tree, tree, rtx, rtx*, rtx*,
290 enum expand_modifier);
d53441c8 291
292/* rtl.h and tree.h were included. */
293/* Return an rtx for the size in bytes of the value of an expr. */
294extern rtx expr_size (tree);
295
4c74e6d9 296#endif /* GCC_EXPR_H */