comparison gcc/reload.h @ 16:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
comparison
equal deleted inserted replaced
15:561a7518be6b 16:04ced10e8804
1 /* Communication between reload.c, reload1.c and the rest of compiler. 1 /* Communication between reload.c, reload1.c and the rest of compiler.
2 Copyright (C) 1987, 1991, 1992, 1993, 1994, 1995, 1997, 1998, 1999, 2 Copyright (C) 1987-2017 Free Software Foundation, Inc.
3 2000, 2001, 2003, 2004, 2007, 2008, 2010
4 Free Software Foundation, Inc.
5 3
6 This file is part of GCC. 4 This file is part of GCC.
7 5
8 GCC is free software; you can redistribute it and/or modify it under 6 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free 7 the terms of the GNU General Public License as published by the Free
17 15
18 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see 17 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */ 18 <http://www.gnu.org/licenses/>. */
21 19
20 #ifndef GCC_RELOAD_H
21 #define GCC_RELOAD_H
22 22
23 /* If secondary reloads are the same for inputs and outputs, define those 23 /* If secondary reloads are the same for inputs and outputs, define those
24 macros here. */ 24 macros here. */
25 25
26 #ifdef SECONDARY_RELOAD_CLASS 26 #ifdef SECONDARY_RELOAD_CLASS
28 SECONDARY_RELOAD_CLASS (CLASS, MODE, X) 28 SECONDARY_RELOAD_CLASS (CLASS, MODE, X)
29 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, X) \ 29 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, X) \
30 SECONDARY_RELOAD_CLASS (CLASS, MODE, X) 30 SECONDARY_RELOAD_CLASS (CLASS, MODE, X)
31 #endif 31 #endif
32 32
33 extern int register_move_cost (enum machine_mode, reg_class_t, reg_class_t); 33 extern int register_move_cost (machine_mode, reg_class_t, reg_class_t);
34 extern int memory_move_cost (enum machine_mode, enum reg_class, bool); 34 extern int memory_move_cost (machine_mode, reg_class_t, bool);
35 extern int memory_move_secondary_cost (enum machine_mode, reg_class_t, bool); 35 extern int memory_move_secondary_cost (machine_mode, reg_class_t, bool);
36 36
37 /* Maximum number of reloads we can need. */ 37 /* Maximum number of reloads we can need. */
38 #define MAX_RELOADS (2 * MAX_RECOG_OPERANDS * (MAX_REGS_PER_ADDRESS + 1)) 38 #define MAX_RELOADS (2 * MAX_RECOG_OPERANDS * (MAX_REGS_PER_ADDRESS + 1))
39 39
40 /* Encode the usage of a reload. The following codes are supported: 40 /* Encode the usage of a reload. The following codes are supported:
82 82
83 /* The class of registers to reload into. */ 83 /* The class of registers to reload into. */
84 enum reg_class rclass; 84 enum reg_class rclass;
85 85
86 /* The mode this operand should have when reloaded, on input. */ 86 /* The mode this operand should have when reloaded, on input. */
87 enum machine_mode inmode; 87 machine_mode inmode;
88 /* The mode this operand should have when reloaded, on output. */ 88 /* The mode this operand should have when reloaded, on output. */
89 enum machine_mode outmode; 89 machine_mode outmode;
90 90
91 /* The mode of the reload register. */ 91 /* The mode of the reload register. */
92 enum machine_mode mode; 92 machine_mode mode;
93 93
94 /* the largest number of registers this reload will require. */ 94 /* the largest number of registers this reload will require. */
95 unsigned int nregs; 95 unsigned int nregs;
96 96
97 /* Positive amount to increment or decrement by if 97 /* Positive amount to increment or decrement by if
157 /* Nonzero if indirect addressing is supported when the innermost MEM is 157 /* Nonzero if indirect addressing is supported when the innermost MEM is
158 of the form (MEM (SYMBOL_REF sym)). It is assumed that the level to 158 of the form (MEM (SYMBOL_REF sym)). It is assumed that the level to
159 which these are valid is the same as spill_indirect_levels, above. */ 159 which these are valid is the same as spill_indirect_levels, above. */
160 bool x_indirect_symref_ok; 160 bool x_indirect_symref_ok;
161 161
162 /* Nonzero if an address (plus (reg frame_pointer) (reg ...)) is valid. */
163 bool x_double_reg_address_ok;
164
165 /* Nonzero if indirect addressing is supported on the machine; this means 162 /* Nonzero if indirect addressing is supported on the machine; this means
166 that spilling (REG n) does not require reloading it into a register in 163 that spilling (REG n) does not require reloading it into a register in
167 order to do (MEM (REG n)) or (MEM (PLUS (REG n) (CONST_INT c))). The 164 order to do (MEM (REG n)) or (MEM (PLUS (REG n) (CONST_INT c))). The
168 value indicates the level of indirect addressing supported, e.g., two 165 value indicates the level of indirect addressing supported, e.g., two
169 means that (MEM (MEM (REG n))) is also valid if (REG n) does not get 166 means that (MEM (MEM (REG n))) is also valid if (REG n) does not get
170 a hard register. */ 167 a hard register. */
171 bool x_spill_indirect_levels; 168 unsigned char x_spill_indirect_levels;
172 169
173 /* True if caller-save has been reinitialized. */ 170 /* True if caller-save has been reinitialized. */
174 bool x_caller_save_initialized_p; 171 bool x_caller_save_initialized_p;
175 172
176 /* Modes for each hard register that we can save. The smallest mode is wide 173 /* Modes for each hard register that we can save. The smallest mode is wide
177 enough to save the entire contents of the register. When saving the 174 enough to save the entire contents of the register. When saving the
178 register because it is live we first try to save in multi-register modes. 175 register because it is live we first try to save in multi-register modes.
179 If that is not possible the save is done one register at a time. */ 176 If that is not possible the save is done one register at a time. */
180 enum machine_mode (x_regno_save_mode 177 machine_mode (x_regno_save_mode
181 [FIRST_PSEUDO_REGISTER] 178 [FIRST_PSEUDO_REGISTER]
182 [MAX_MOVE_MAX / MIN_UNITS_PER_WORD + 1]); 179 [MAX_MOVE_MAX / MIN_UNITS_PER_WORD + 1]);
180
181 /* Nonzero if an address (plus (reg frame_pointer) (reg ...)) is valid
182 in the given mode. */
183 bool x_double_reg_address_ok[MAX_MACHINE_MODE];
183 184
184 /* We will only make a register eligible for caller-save if it can be 185 /* We will only make a register eligible for caller-save if it can be
185 saved in its widest mode with a simple SET insn as long as the memory 186 saved in its widest mode with a simple SET insn as long as the memory
186 address is valid. We record the INSN_CODE is those insns here since 187 address is valid. We record the INSN_CODE is those insns here since
187 when we emit them, the addresses might not be valid, so they might not 188 when we emit them, the addresses might not be valid, so they might not
202 #define double_reg_address_ok \ 203 #define double_reg_address_ok \
203 (this_target_reload->x_double_reg_address_ok) 204 (this_target_reload->x_double_reg_address_ok)
204 #define caller_save_initialized_p \ 205 #define caller_save_initialized_p \
205 (this_target_reload->x_caller_save_initialized_p) 206 (this_target_reload->x_caller_save_initialized_p)
206 207
207 extern GTY (()) VEC(rtx,gc) *reg_equiv_memory_loc_vec; 208 /* Register equivalences. Indexed by register number. */
208 extern rtx *reg_equiv_constant; 209 struct reg_equivs_t
209 extern rtx *reg_equiv_invariant; 210 {
210 extern rtx *reg_equiv_memory_loc; 211 /* The constant value to which pseudo reg N is equivalent,
211 extern rtx *reg_equiv_address; 212 or zero if pseudo reg N is not equivalent to a constant.
212 extern rtx *reg_equiv_mem; 213 find_reloads looks at this in order to replace pseudo reg N
213 extern rtx *reg_equiv_alt_mem_list; 214 with the constant it stands for. */
214 215 rtx constant;
215 /* Element N is the list of insns that initialized reg N from its equivalent 216
216 constant or memory slot. */ 217 /* An invariant value to which pseudo reg N is equivalent.
217 extern GTY((length("reg_equiv_init_size"))) rtx *reg_equiv_init; 218 eliminate_regs_in_insn uses this to replace pseudos in particular
218 219 contexts. */
219 /* The size of the previous array, for GC purposes. */ 220 rtx invariant;
220 extern GTY(()) int reg_equiv_init_size; 221
222 /* A memory location to which pseudo reg N is equivalent,
223 prior to any register elimination (such as frame pointer to stack
224 pointer). Depending on whether or not it is a valid address, this value
225 is transferred to either equiv_address or equiv_mem. */
226 rtx memory_loc;
227
228 /* The address of stack slot to which pseudo reg N is equivalent.
229 This is used when the address is not valid as a memory address
230 (because its displacement is too big for the machine.) */
231 rtx address;
232
233 /* The memory slot to which pseudo reg N is equivalent,
234 or zero if pseudo reg N is not equivalent to a memory slot. */
235 rtx mem;
236
237 /* An EXPR_LIST of REG_EQUIVs containing MEMs with
238 alternate representations of the location of pseudo reg N. */
239 rtx_expr_list *alt_mem_list;
240
241 /* The list of insns that initialized reg N from its equivalent
242 constant or memory slot. */
243 rtx_insn_list *init;
244 };
245
246 #define reg_equiv_constant(ELT) \
247 (*reg_equivs)[(ELT)].constant
248 #define reg_equiv_invariant(ELT) \
249 (*reg_equivs)[(ELT)].invariant
250 #define reg_equiv_memory_loc(ELT) \
251 (*reg_equivs)[(ELT)].memory_loc
252 #define reg_equiv_address(ELT) \
253 (*reg_equivs)[(ELT)].address
254 #define reg_equiv_mem(ELT) \
255 (*reg_equivs)[(ELT)].mem
256 #define reg_equiv_alt_mem_list(ELT) \
257 (*reg_equivs)[(ELT)].alt_mem_list
258 #define reg_equiv_init(ELT) \
259 (*reg_equivs)[(ELT)].init
260
261 extern vec<reg_equivs_t, va_gc> *reg_equivs;
221 262
222 /* All the "earlyclobber" operands of the current insn 263 /* All the "earlyclobber" operands of the current insn
223 are recorded here. */ 264 are recorded here. */
224 extern int n_earlyclobbers; 265 extern int n_earlyclobbers;
225 extern rtx reload_earlyclobbers[MAX_RECOG_OPERANDS]; 266 extern rtx reload_earlyclobbers[MAX_RECOG_OPERANDS];
245 /* Link through a chains set up by calculate_needs_all_insns, containing 286 /* Link through a chains set up by calculate_needs_all_insns, containing
246 all insns that need reloading. */ 287 all insns that need reloading. */
247 struct insn_chain *next_need_reload; 288 struct insn_chain *next_need_reload;
248 289
249 /* The rtx of the insn. */ 290 /* The rtx of the insn. */
250 rtx insn; 291 rtx_insn *insn;
251 292
252 /* The basic block this insn is in. */ 293 /* The basic block this insn is in. */
253 int block; 294 int block;
254 295
255 /* Nonzero if find_reloads said the insn requires reloading. */ 296 /* Nonzero if find_reloads said the insn requires reloading. */
289 #endif 330 #endif
290 331
291 /* Functions from reload.c: */ 332 /* Functions from reload.c: */
292 333
293 extern reg_class_t secondary_reload_class (bool, reg_class_t, 334 extern reg_class_t secondary_reload_class (bool, reg_class_t,
294 enum machine_mode, rtx); 335 machine_mode, rtx);
295 336
296 #ifdef GCC_INSN_CODES_H 337 #ifdef GCC_INSN_CODES_H
297 extern enum reg_class scratch_reload_class (enum insn_code); 338 extern enum reg_class scratch_reload_class (enum insn_code);
298 #endif 339 #endif
299 340
300 /* Return a memory location that will be used to copy X in mode MODE. 341 /* Return a memory location that will be used to copy X in mode MODE.
301 If we haven't already made a location for this mode in this insn, 342 If we haven't already made a location for this mode in this insn,
302 call find_reloads_address on the location being returned. */ 343 call find_reloads_address on the location being returned. */
303 extern rtx get_secondary_mem (rtx, enum machine_mode, int, enum reload_type); 344 extern rtx get_secondary_mem (rtx, machine_mode, int, enum reload_type);
304 345
305 /* Clear any secondary memory locations we've made. */ 346 /* Clear any secondary memory locations we've made. */
306 extern void clear_secondary_mem (void); 347 extern void clear_secondary_mem (void);
307 348
308 /* Transfer all replacements that used to be in reload FROM to be in 349 /* Transfer all replacements that used to be in reload FROM to be in
324 extern int safe_from_earlyclobber (rtx, rtx); 365 extern int safe_from_earlyclobber (rtx, rtx);
325 366
326 /* Search the body of INSN for values that need reloading and record them 367 /* Search the body of INSN for values that need reloading and record them
327 with push_reload. REPLACE nonzero means record also where the values occur 368 with push_reload. REPLACE nonzero means record also where the values occur
328 so that subst_reloads can be used. */ 369 so that subst_reloads can be used. */
329 extern int find_reloads (rtx, int, int, int, short *); 370 extern int find_reloads (rtx_insn *, int, int, int, short *);
330 371
331 /* Compute the sum of X and Y, making canonicalizations assumed in an 372 /* Compute the sum of X and Y, making canonicalizations assumed in an
332 address, namely: sum constant integers, surround the sum of two 373 address, namely: sum constant integers, surround the sum of two
333 constants with a CONST, put the constant as the second operand, and 374 constants with a CONST, put the constant as the second operand, and
334 group the constant on the outermost sum. */ 375 group the constant on the outermost sum. */
335 extern rtx form_sum (enum machine_mode, rtx, rtx); 376 extern rtx form_sum (machine_mode, rtx, rtx);
336 377
337 /* Substitute into the current INSN the registers into which we have reloaded 378 /* Substitute into the current INSN the registers into which we have reloaded
338 the things that need reloading. */ 379 the things that need reloading. */
339 extern void subst_reloads (rtx); 380 extern void subst_reloads (rtx_insn *);
340 381
341 /* Make a copy of any replacements being done into X and move those copies 382 /* Make a copy of any replacements being done into X and move those copies
342 to locations in Y, a copy of X. We only look at the highest level of 383 to locations in Y, a copy of X. We only look at the highest level of
343 the RTL. */ 384 the RTL. */
344 extern void copy_replacements (rtx, rtx); 385 extern void copy_replacements (rtx, rtx);
353 /* Nonzero if modifying X will affect IN. */ 394 /* Nonzero if modifying X will affect IN. */
354 extern int reg_overlap_mentioned_for_reload_p (rtx, rtx); 395 extern int reg_overlap_mentioned_for_reload_p (rtx, rtx);
355 396
356 /* Check the insns before INSN to see if there is a suitable register 397 /* Check the insns before INSN to see if there is a suitable register
357 containing the same value as GOAL. */ 398 containing the same value as GOAL. */
358 extern rtx find_equiv_reg (rtx, rtx, enum reg_class, int, short *, 399 extern rtx find_equiv_reg (rtx, rtx_insn *, enum reg_class, int, short *,
359 int, enum machine_mode); 400 int, machine_mode);
360 401
361 /* Return 1 if register REGNO is the subject of a clobber in insn INSN. */ 402 /* Return 1 if register REGNO is the subject of a clobber in insn INSN. */
362 extern int regno_clobbered_p (unsigned int, rtx, enum machine_mode, int); 403 extern int regno_clobbered_p (unsigned int, rtx_insn *, machine_mode, int);
363 404
364 /* Return 1 if X is an operand of an insn that is being earlyclobbered. */ 405 /* Return 1 if X is an operand of an insn that is being earlyclobbered. */
365 extern int earlyclobber_operand_p (rtx); 406 extern int earlyclobber_operand_p (rtx);
366 407
367 /* Record one reload that needs to be performed. */ 408 /* Record one reload that needs to be performed. */
368 extern int push_reload (rtx, rtx, rtx *, rtx *, enum reg_class, 409 extern int push_reload (rtx, rtx, rtx *, rtx *, enum reg_class,
369 enum machine_mode, enum machine_mode, 410 machine_mode, machine_mode,
370 int, int, int, enum reload_type); 411 int, int, int, enum reload_type);
371
372 /* Functions in postreload.c: */
373 extern void reload_cse_regs (rtx);
374 412
375 /* Functions in reload1.c: */ 413 /* Functions in reload1.c: */
376 414
377 /* Initialize the reload pass once per compilation. */ 415 /* Initialize the reload pass once per compilation. */
378 extern void init_reload (void); 416 extern void init_reload (void);
379 417
380 /* The reload pass itself. */ 418 /* The reload pass itself. */
381 extern int reload (rtx, int); 419 extern bool reload (rtx_insn *, int);
382 420
383 /* Mark the slots in regs_ever_live for the hard regs 421 /* Mark the slots in regs_ever_live for the hard regs
384 used by pseudo-reg number REGNO. */ 422 used by pseudo-reg number REGNO. */
385 extern void mark_home_live (int); 423 extern void mark_home_live (int);
386 424
387 /* Scan X and replace any eliminable registers (such as fp) with a 425 /* Scan X and replace any eliminable registers (such as fp) with a
388 replacement (such as sp), plus an offset. */ 426 replacement (such as sp), plus an offset. */
389 extern rtx eliminate_regs (rtx, enum machine_mode, rtx); 427 extern rtx eliminate_regs (rtx, machine_mode, rtx);
390 extern bool elimination_target_reg_p (rtx); 428 extern bool elimination_target_reg_p (rtx);
391 429
392 /* Called from the register allocator to estimate costs of eliminating 430 /* Called from the register allocator to estimate costs of eliminating
393 invariant registers. */ 431 invariant registers. */
394 extern void calculate_elim_costs_all_insns (void); 432 extern void calculate_elim_costs_all_insns (void);
409 447
410 /* Find the places where hard regs are live across calls and save them. */ 448 /* Find the places where hard regs are live across calls and save them. */
411 extern void save_call_clobbered_regs (void); 449 extern void save_call_clobbered_regs (void);
412 450
413 /* Replace (subreg (reg)) with the appropriate (reg) for any operands. */ 451 /* Replace (subreg (reg)) with the appropriate (reg) for any operands. */
414 extern void cleanup_subreg_operands (rtx); 452 extern void cleanup_subreg_operands (rtx_insn *);
415 453
416 /* Debugging support. */ 454 /* Debugging support. */
417 extern void debug_reload_to_stream (FILE *); 455 extern void debug_reload_to_stream (FILE *);
418 extern void debug_reload (void); 456 extern void debug_reload (void);
419 457
420 /* Compute the actual register we should reload to, in case we're 458 /* Compute the actual register we should reload to, in case we're
421 reloading to/from a register that is wider than a word. */ 459 reloading to/from a register that is wider than a word. */
422 extern rtx reload_adjust_reg_for_mode (rtx, enum machine_mode); 460 extern rtx reload_adjust_reg_for_mode (rtx, machine_mode);
461
462 /* Allocate or grow the reg_equiv tables, initializing new entries to 0. */
463 extern void grow_reg_equivs (void);
464
465 #endif /* GCC_RELOAD_H */