]>
Commit | Line | Data |
---|---|---|
dbb0cd11 | 1 | /* Definitions for code generation pass of GNU compiler. |
fbd26352 | 2 | Copyright (C) 1987-2019 Free Software Foundation, Inc. |
dbb0cd11 | 3 | |
f12b58b3 | 4 | This file is part of GCC. |
dbb0cd11 | 5 | |
f12b58b3 | 6 | GCC is free software; you can redistribute it and/or modify it under |
7 | the terms of the GNU General Public License as published by the Free | |
8c4c00c1 | 8 | Software Foundation; either version 3, or (at your option) any later |
f12b58b3 | 9 | version. |
dbb0cd11 | 10 | |
f12b58b3 | 11 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 | for more details. | |
dbb0cd11 | 15 | |
16 | You should have received a copy of the GNU General Public License | |
8c4c00c1 | 17 | along 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 | 34 | enum 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. */ | |
49 | typedef 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. */ |
59 | extern void init_expr_target (void); | |
b5479824 | 60 | |
61 | /* This is run at the start of compiling a function. */ | |
35cb5232 | 62 | extern 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 | 66 | extern void convert_move (rtx, rtx, int); |
dbb0cd11 | 67 | |
68 | /* Convert an rtx to specified machine mode and return the result. */ | |
3754d046 | 69 | extern rtx convert_to_mode (machine_mode, rtx, int); |
dbb0cd11 | 70 | |
48e657fd | 71 | /* Convert an rtx to MODE from OLDMODE and return the result. */ |
3754d046 | 72 | extern rtx convert_modes (machine_mode, machine_mode, rtx, int); |
48e657fd | 73 | |
61ffc71a | 74 | /* Expand a call to memcpy or memmove or memcmp, and return the result. */ |
75 | extern rtx emit_block_op_via_libcall (enum built_in_function, rtx, rtx, rtx, | |
76 | bool); | |
77 | ||
78 | static inline rtx | |
79 | emit_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 | ||
84 | static inline rtx | |
85 | emit_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 | ||
90 | static inline rtx | |
91 | emit_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 | } | |
0378dbdc | 95 | |
61ffc71a | 96 | /* Emit code to move a block Y to a block X. */ |
0378dbdc | 97 | enum block_op_methods |
98 | { | |
99 | BLOCK_OP_NORMAL, | |
a35a63ff | 100 | BLOCK_OP_NO_LIBCALL, |
0b25db21 | 101 | BLOCK_OP_CALL_PARM, |
102 | /* Like BLOCK_OP_NORMAL, but the libcall can be tail call optimized. */ | |
21781799 | 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 | |
0378dbdc | 108 | }; |
109 | ||
f77c4496 | 110 | typedef rtx (*by_pieces_constfn) (void *, HOST_WIDE_INT, scalar_int_mode); |
3e346f54 | 111 | |
35cb5232 | 112 | extern rtx emit_block_move (rtx, rtx, rtx, enum block_op_methods); |
162719b3 | 113 | extern rtx emit_block_move_hints (rtx, rtx, rtx, enum block_op_methods, |
36d63243 | 114 | unsigned int, HOST_WIDE_INT, |
115 | unsigned HOST_WIDE_INT, | |
9db0f34d | 116 | unsigned HOST_WIDE_INT, |
048f6aad | 117 | unsigned HOST_WIDE_INT, |
118 | bool bail_out_libcall = false, | |
119 | bool *is_move_done = NULL); | |
3e346f54 | 120 | extern rtx emit_block_cmp_hints (rtx, rtx, rtx, tree, rtx, bool, |
121 | by_pieces_constfn, void *); | |
16c9337c | 122 | extern bool emit_storent_insn (rtx to, rtx from); |
b5479824 | 123 | |
124 | /* Copy all or part of a value X into registers starting at REGNO. | |
125 | The number of registers to be filled is NREGS. */ | |
3754d046 | 126 | extern void move_block_to_reg (int, rtx, int, machine_mode); |
b5479824 | 127 | |
128 | /* Copy all or part of a BLKmode value X out of registers starting at REGNO. | |
129 | The number of registers to be filled is NREGS. */ | |
35cb5232 | 130 | extern void move_block_from_reg (int, rtx, int); |
b5479824 | 131 | |
b566e2e5 | 132 | /* Generate a non-consecutive group of registers represented by a PARALLEL. */ |
35cb5232 | 133 | extern rtx gen_group_rtx (rtx); |
b566e2e5 | 134 | |
2dbc68f6 | 135 | /* Load a BLKmode value into non-consecutive registers represented by a |
136 | PARALLEL. */ | |
8f4bb50f | 137 | extern void emit_group_load (rtx, rtx, tree, poly_int64); |
fe352cf1 | 138 | |
e2ff5c1b | 139 | /* Similarly, but load into new temporaries. */ |
8f4bb50f | 140 | extern rtx emit_group_load_into_temps (rtx, rtx, tree, poly_int64); |
e2ff5c1b | 141 | |
b566e2e5 | 142 | /* Move a non-consecutive group of registers represented by a PARALLEL into |
143 | a non-consecutive group of registers represented by a PARALLEL. */ | |
35cb5232 | 144 | extern void emit_group_move (rtx, rtx); |
b566e2e5 | 145 | |
e2ff5c1b | 146 | /* Move a group of registers represented by a PARALLEL into pseudos. */ |
147 | extern rtx emit_group_move_into_temps (rtx); | |
148 | ||
2dbc68f6 | 149 | /* Store a BLKmode value from non-consecutive registers represented by a |
150 | PARALLEL. */ | |
8f4bb50f | 151 | extern void emit_group_store (rtx, rtx, tree, poly_int64); |
2dbc68f6 | 152 | |
933eb13a | 153 | extern rtx maybe_emit_group_store (rtx, tree); |
154 | ||
b4eeceb9 | 155 | /* Mark REG as holding a parameter for the next CALL_INSN. |
156 | Mode is TYPE_MODE of the non-promoted parameter, or VOIDmode. */ | |
3754d046 | 157 | extern void use_reg_mode (rtx *, rtx, machine_mode); |
158 | extern void clobber_reg_mode (rtx *, rtx, machine_mode); | |
b4eeceb9 | 159 | |
3754d046 | 160 | extern rtx copy_blkmode_to_reg (machine_mode, tree); |
ee5ab2d1 | 161 | |
14602aee | 162 | /* Mark REG as holding a parameter for the next CALL_INSN. */ |
b4eeceb9 | 163 | static inline void |
164 | use_reg (rtx *fusage, rtx reg) | |
165 | { | |
166 | use_reg_mode (fusage, reg, VOIDmode); | |
167 | } | |
fe352cf1 | 168 | |
e67cfba4 | 169 | /* Mark REG as clobbered by the call with FUSAGE as CALL_INSN_FUNCTION_USAGE. */ |
170 | static inline void | |
171 | clobber_reg (rtx *fusage, rtx reg) | |
172 | { | |
173 | clobber_reg_mode (fusage, reg, VOIDmode); | |
174 | } | |
175 | ||
14602aee | 176 | /* Mark NREGS consecutive regs, starting at REGNO, as holding parameters |
177 | for the next CALL_INSN. */ | |
35cb5232 | 178 | extern void use_regs (rtx *, int, int); |
fe352cf1 | 179 | |
2dbc68f6 | 180 | /* Mark a PARALLEL as holding a parameter for the next CALL_INSN. */ |
35cb5232 | 181 | extern void use_group_regs (rtx *, rtx); |
b5479824 | 182 | |
3e346f54 | 183 | #ifdef GCC_INSN_CODES_H |
184 | extern rtx expand_cmpstrn_or_cmpmem (insn_code, rtx, rtx, rtx, tree, rtx, | |
185 | HOST_WIDE_INT); | |
186 | #endif | |
187 | ||
b5479824 | 188 | /* Write zeros through the storage of OBJECT. |
2a631e19 | 189 | If OBJECT has BLKmode, SIZE is its length in bytes. */ |
0b25db21 | 190 | extern rtx clear_storage (rtx, rtx, enum block_op_methods); |
162719b3 | 191 | extern rtx clear_storage_hints (rtx, rtx, enum block_op_methods, |
36d63243 | 192 | unsigned int, HOST_WIDE_INT, |
193 | unsigned HOST_WIDE_INT, | |
9db0f34d | 194 | unsigned HOST_WIDE_INT, |
36d63243 | 195 | unsigned HOST_WIDE_INT); |
ab608690 | 196 | /* The same, but always output an library call. */ |
61ffc71a | 197 | extern rtx set_storage_via_libcall (rtx, rtx, rtx, bool = false); |
b5479824 | 198 | |
7a3e5564 | 199 | /* Expand a setmem pattern; return true if successful. */ |
48e1416a | 200 | extern bool set_storage_via_setmem (rtx, rtx, rtx, unsigned int, |
36d63243 | 201 | unsigned int, HOST_WIDE_INT, |
202 | unsigned HOST_WIDE_INT, | |
9db0f34d | 203 | unsigned HOST_WIDE_INT, |
36d63243 | 204 | unsigned HOST_WIDE_INT); |
7a3e5564 | 205 | |
6ef828f9 | 206 | /* Return nonzero if it is desirable to store LEN bytes generated by |
6840589f | 207 | CONSTFUN with several move instructions by store_by_pieces |
208 | function. CONSTFUNDATA is a pointer which will be passed as argument | |
209 | in every CONSTFUN call. | |
4b297e2e | 210 | ALIGN is maximum alignment we can assume. |
211 | MEMSETP is true if this is a real memset/bzero, not a copy | |
212 | of a const string. */ | |
35cb5232 | 213 | extern int can_store_by_pieces (unsigned HOST_WIDE_INT, |
3e346f54 | 214 | by_pieces_constfn, |
4b297e2e | 215 | void *, unsigned int, bool); |
6840589f | 216 | |
217 | /* Generate several move instructions to store LEN bytes generated by | |
218 | CONSTFUN to block TO. (A MEM rtx with BLKmode). CONSTFUNDATA is a | |
219 | pointer which will be passed as argument in every CONSTFUN call. | |
9fe0e1b8 | 220 | ALIGN is maximum alignment we can assume. |
4b297e2e | 221 | MEMSETP is true if this is a real memset/bzero, not a copy. |
9fe0e1b8 | 222 | Returns TO + LEN. */ |
3e346f54 | 223 | extern rtx store_by_pieces (rtx, unsigned HOST_WIDE_INT, by_pieces_constfn, |
02aa6d73 | 224 | void *, unsigned int, bool, memop_ret); |
6840589f | 225 | |
b5479824 | 226 | /* Emit insns to set X from Y. */ |
c81fd430 | 227 | extern rtx_insn *emit_move_insn (rtx, rtx); |
f9a00e9e | 228 | extern rtx_insn *gen_move_insn (rtx, rtx); |
b5479824 | 229 | |
230 | /* Emit insns to set X from Y, with no frills. */ | |
c81fd430 | 231 | extern rtx_insn *emit_move_insn_1 (rtx, rtx); |
b5479824 | 232 | |
3754d046 | 233 | extern rtx_insn *emit_move_complex_push (machine_mode, rtx, rtx); |
c81fd430 | 234 | extern rtx_insn *emit_move_complex_parts (rtx, rtx); |
94f92c36 | 235 | extern rtx read_complex_part (rtx, bool); |
0c93c8a9 | 236 | extern void write_complex_part (rtx, rtx, bool); |
292237f3 | 237 | extern rtx read_complex_part (rtx, bool); |
3754d046 | 238 | extern rtx emit_move_resolve_push (machine_mode, rtx); |
64003036 | 239 | |
b5479824 | 240 | /* Push a block of length SIZE (perhaps variable) |
241 | and return an rtx to address the beginning of the block. */ | |
7562e467 | 242 | extern rtx push_block (rtx, poly_int64, int); |
b5479824 | 243 | |
b5479824 | 244 | /* Generate code to push something onto the stack, given its mode and type. */ |
a95e5776 | 245 | extern bool emit_push_insn (rtx, machine_mode, tree, rtx, unsigned int, |
7562e467 | 246 | int, rtx, poly_int64, rtx, rtx, int, rtx, bool); |
b5479824 | 247 | |
ace07d4a | 248 | /* Extract the accessible bit-range from a COMPONENT_REF. */ |
2a0c8955 | 249 | extern void get_bit_range (poly_uint64_pod *, poly_uint64_pod *, tree, |
250 | poly_int64_pod *, tree *); | |
e61263f2 | 251 | |
ab6d34f7 | 252 | /* Expand an assignment that stores the value of FROM into TO. */ |
5b5037b3 | 253 | extern void expand_assignment (tree, tree, bool); |
b5479824 | 254 | |
255 | /* Generate code for computing expression EXP, | |
256 | and storing the value into TARGET. | |
257 | If SUGGEST_REG is nonzero, copy the value through a register | |
258 | and return that register, if that is possible. */ | |
292237f3 | 259 | extern rtx store_expr (tree, rtx, int, bool, bool); |
dbb0cd11 | 260 | |
261 | /* Given an rtx that may include add and multiply operations, | |
262 | generate them as insns and return a pseudo-reg containing the value. | |
263 | Useful after calling expand_expr with 1 as sum_ok. */ | |
35cb5232 | 264 | extern rtx force_operand (rtx, rtx); |
dbb0cd11 | 265 | |
16c9337c | 266 | /* Work horses for expand_expr. */ |
3754d046 | 267 | extern rtx expand_expr_real (tree, rtx, machine_mode, |
a12f023f | 268 | enum expand_modifier, rtx *, bool); |
3754d046 | 269 | extern rtx expand_expr_real_1 (tree, rtx, machine_mode, |
a12f023f | 270 | enum expand_modifier, rtx *, bool); |
3754d046 | 271 | extern rtx expand_expr_real_2 (sepops, rtx, machine_mode, |
16c9337c | 272 | enum expand_modifier); |
5135beeb | 273 | |
b5479824 | 274 | /* Generate code for computing expression EXP. |
275 | An rtx for the computed value is returned. The value is never null. | |
276 | In the case of a void EXP, const0_rtx is returned. */ | |
5135beeb | 277 | static inline rtx |
3754d046 | 278 | expand_expr (tree exp, rtx target, machine_mode mode, |
5135beeb | 279 | enum expand_modifier modifier) |
280 | { | |
a12f023f | 281 | return expand_expr_real (exp, target, mode, modifier, NULL, false); |
5135beeb | 282 | } |
b5479824 | 283 | |
8ec3c5c2 | 284 | static inline rtx |
285 | expand_normal (tree exp) | |
286 | { | |
a12f023f | 287 | return expand_expr_real (exp, NULL_RTX, VOIDmode, EXPAND_NORMAL, NULL, false); |
8ec3c5c2 | 288 | } |
289 | ||
b6d206a2 | 290 | |
53800dbe | 291 | /* Return the tree node and offset if a given argument corresponds to |
292 | a string constant. */ | |
917baa6b | 293 | extern tree string_constant (tree, tree *, tree *, tree *); |
7c8e9b7d | 294 | |
295 | extern enum tree_code maybe_optimize_mod_cmp (enum tree_code, tree *, tree *); | |
53800dbe | 296 | |
539a3a92 | 297 | /* Two different ways of generating switch statements. */ |
720cfc43 | 298 | extern int try_casesi (tree, tree, tree, tree, rtx, rtx, rtx, profile_probability); |
299 | extern int try_tablejump (tree, tree, tree, tree, rtx, rtx, profile_probability); | |
539a3a92 | 300 | |
1f1872fd | 301 | extern int safe_from_p (const_rtx, tree, int); |
e41f0d80 | 302 | |
58d82cd0 | 303 | /* Get the personality libfunc for a function decl. */ |
304 | rtx get_personality_function (tree); | |
305 | ||
9ed99284 | 306 | /* Determine whether the LEN bytes can be moved by using several move |
307 | instructions. Return nonzero if a call to move_by_pieces should | |
308 | succeed. */ | |
3e346f54 | 309 | extern bool can_move_by_pieces (unsigned HOST_WIDE_INT, unsigned int); |
9ed99284 | 310 | |
311 | extern unsigned HOST_WIDE_INT highest_pow2_factor (const_tree); | |
9ed99284 | 312 | |
313 | extern bool categorize_ctor_elements (const_tree, HOST_WIDE_INT *, | |
c90b96f5 | 314 | HOST_WIDE_INT *, HOST_WIDE_INT *, |
315 | bool *); | |
9ed99284 | 316 | |
01ee997b | 317 | extern void expand_operands (tree, tree, rtx, rtx*, rtx*, |
318 | enum expand_modifier); | |
d53441c8 | 319 | |
320 | /* rtl.h and tree.h were included. */ | |
321 | /* Return an rtx for the size in bytes of the value of an expr. */ | |
322 | extern rtx expr_size (tree); | |
323 | ||
4c74e6d9 | 324 | #endif /* GCC_EXPR_H */ |