OSDN Git Service

* config/i386/sol2.h (PREFERRED_DEBUGGING_TYPE): Use stabs.
[pf3gnuchains/gcc-fork.git] / gcc / reload.h
1 /* Communication between reload.c and reload1.c.
2    Copyright (C) 1987, 91-95, 97, 1998 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING.  If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20
21
22 /* If secondary reloads are the same for inputs and outputs, define those
23    macros here.  */
24
25 #ifdef SECONDARY_RELOAD_CLASS
26 #define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X) \
27   SECONDARY_RELOAD_CLASS (CLASS, MODE, X)
28 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, X) \
29   SECONDARY_RELOAD_CLASS (CLASS, MODE, X)
30 #endif
31
32 /* If either macro is defined, show that we need secondary reloads.  */
33 #if defined(SECONDARY_INPUT_RELOAD_CLASS) || defined(SECONDARY_OUTPUT_RELOAD_CLASS)
34 #define HAVE_SECONDARY_RELOADS
35 #endif
36
37 /* If MEMORY_MOVE_COST isn't defined, give it a default here.  */
38 #ifndef MEMORY_MOVE_COST
39 #ifdef HAVE_SECONDARY_RELOADS
40 #define MEMORY_MOVE_COST(MODE,CLASS,IN) \
41   (4 + memory_move_secondary_cost ((MODE), (CLASS), (IN)))
42 #else
43 #define MEMORY_MOVE_COST(MODE,CLASS,IN) 4
44 #endif
45 #endif
46 extern int memory_move_secondary_cost PROTO ((enum machine_mode, enum reg_class, int));
47
48 /* Maximum number of reloads we can need.  */
49 #define MAX_RELOADS (2 * MAX_RECOG_OPERANDS * (MAX_REGS_PER_ADDRESS + 1))
50
51 /* Encode the usage of a reload.  The following codes are supported:
52
53    RELOAD_FOR_INPUT             reload of an input operand
54    RELOAD_FOR_OUTPUT            likewise, for output
55    RELOAD_FOR_INSN              a reload that must not conflict with anything
56                                 used in the insn, but may conflict with
57                                 something used before or after the insn
58    RELOAD_FOR_INPUT_ADDRESS     reload for parts of the address of an object
59                                 that is an input reload
60    RELOAD_FOR_INPADDR_ADDRESS   reload needed for RELOAD_FOR_INPUT_ADDRESS
61    RELOAD_FOR_OUTPUT_ADDRESS    like RELOAD_FOR INPUT_ADDRESS, for output
62    RELOAD_FOR_OUTADDR_ADDRESS   reload needed for RELOAD_FOR_OUTPUT_ADDRESS
63    RELOAD_FOR_OPERAND_ADDRESS   reload for the address of a non-reloaded
64                                 operand; these don't conflict with
65                                 any other addresses.
66    RELOAD_FOR_OPADDR_ADDR       reload needed for RELOAD_FOR_OPERAND_ADDRESS
67                                 reloads; usually secondary reloads
68    RELOAD_OTHER                 none of the above, usually multiple uses
69    RELOAD_FOR_OTHER_ADDRESS     reload for part of the address of an input
70                                 that is marked RELOAD_OTHER.
71
72    This used to be "enum reload_when_needed" but some debuggers have trouble
73    with an enum tag and variable of the same name.  */
74
75 enum reload_type
76 {
77   RELOAD_FOR_INPUT, RELOAD_FOR_OUTPUT, RELOAD_FOR_INSN, 
78   RELOAD_FOR_INPUT_ADDRESS, RELOAD_FOR_INPADDR_ADDRESS,
79   RELOAD_FOR_OUTPUT_ADDRESS, RELOAD_FOR_OUTADDR_ADDRESS,
80   RELOAD_FOR_OPERAND_ADDRESS, RELOAD_FOR_OPADDR_ADDR,
81   RELOAD_OTHER, RELOAD_FOR_OTHER_ADDRESS
82 };
83
84 #ifdef MAX_INSN_CODE
85 /* Each reload is recorded with a structure like this.  */
86 struct reload
87 {
88   /* The value to reload from */
89   rtx in;
90   /* Where to store reload-reg afterward if nec (often the same as
91      reload_in)  */
92   rtx out;
93
94   /* The class of registers to reload into.  */
95   enum reg_class class;
96
97   /* The mode this operand should have when reloaded, on input.  */
98   enum machine_mode inmode;
99   /* The mode this operand should have when reloaded, on output.  */
100   enum machine_mode outmode;
101
102   /* Positive amount to increment or decrement by if
103      reload_in is a PRE_DEC, PRE_INC, POST_DEC, POST_INC.
104      Ignored otherwise (don't assume it is zero).  */
105   int inc;
106   /* A reg for which reload_in is the equivalent.
107      If reload_in is a symbol_ref which came from
108      reg_equiv_constant, then this is the pseudo
109      which has that symbol_ref as equivalent.  */
110   rtx in_reg;
111   rtx out_reg;
112
113   /* Used in find_reload_regs to record the allocated register.  */
114   int regno;
115   /* This is the register to reload into.  If it is zero when `find_reloads'
116      returns, you must find a suitable register in the class specified by
117      reload_reg_class, and store here an rtx for that register with mode from
118      reload_inmode or reload_outmode.  */
119   rtx reg_rtx;
120   /* The operand number being reloaded.  This is used to group related reloads
121      and need not always be equal to the actual operand number in the insn,
122      though it current will be; for in-out operands, it is one of the two
123      operand numbers.  */
124   int opnum;
125
126   /* Gives the reload number of a secondary input reload, when needed;
127      otherwise -1.  */
128   int secondary_in_reload;
129   /* Gives the reload number of a secondary output reload, when needed;
130      otherwise -1.  */
131   int secondary_out_reload;
132   /* If a secondary input reload is required, gives the INSN_CODE that uses the
133      secondary reload as a scratch register, or CODE_FOR_nothing if the
134      secondary reload register is to be an intermediate register.  */
135   enum insn_code secondary_in_icode;
136   /* Likewise, for a secondary output reload.  */
137   enum insn_code secondary_out_icode;
138
139   /* Classifies reload as needed either for addressing an input reload,
140      addressing an output, for addressing a non-reloaded mem ref, or for
141      unspecified purposes (i.e., more than one of the above).  */
142   enum reload_type when_needed;
143   
144   /* Nonzero for an optional reload.  Optional reloads are ignored unless the
145      value is already sitting in a register.  */
146   unsigned int optional:1;
147   /* nonzero if this reload shouldn't be combined with another reload.  */
148   unsigned int nocombine:1;
149   /* Nonzero if this is a secondary register for one or more reloads.  */
150   unsigned int secondary_p:1;
151   /* Nonzero if this reload must use a register not already allocated to a
152      group.  */
153   unsigned int nongroup:1;
154 };
155
156 extern struct reload rld[MAX_RELOADS];
157 extern int n_reloads;
158 #endif
159
160 extern rtx *reg_equiv_constant;
161 extern rtx *reg_equiv_memory_loc;
162 extern rtx *reg_equiv_address;
163 extern rtx *reg_equiv_mem;
164
165 /* All the "earlyclobber" operands of the current insn
166    are recorded here.  */
167 extern int n_earlyclobbers;
168 extern rtx reload_earlyclobbers[MAX_RECOG_OPERANDS];
169
170 /* Save the number of operands.  */
171 extern int reload_n_operands;
172
173 /* First uid used by insns created by reload in this function.
174    Used in find_equiv_reg.  */
175 extern int reload_first_uid;
176
177 /* Nonzero if indirect addressing is supported when the innermost MEM is
178    of the form (MEM (SYMBOL_REF sym)).  It is assumed that the level to
179    which these are valid is the same as spill_indirect_levels, above.   */
180
181 extern char indirect_symref_ok;
182
183 /* Nonzero if an address (plus (reg frame_pointer) (reg ...)) is valid.  */
184 extern char double_reg_address_ok;
185
186 extern int num_not_at_initial_offset;
187
188 #ifdef MAX_INSN_CODE
189 /* These arrays record the insn_code of insns that may be needed to
190    perform input and output reloads of special objects.  They provide a
191    place to pass a scratch register.  */
192 extern enum insn_code reload_in_optab[];
193 extern enum insn_code reload_out_optab[];
194 #endif
195
196 struct needs
197 {
198   /* [0] is normal, [1] is nongroup.  */
199   short regs[2][N_REG_CLASSES];
200   short groups[N_REG_CLASSES];
201 };
202
203 #if defined SET_HARD_REG_BIT && defined CLEAR_REG_SET
204 /* This structure describes instructions which are relevant for reload.
205    Apart from all regular insns, this also includes CODE_LABELs, since they
206    must be examined for register elimination.  */
207 struct insn_chain 
208 {
209   /* Links to the neighbour instructions.  */
210   struct insn_chain *next, *prev;
211
212   /* Link through a chains set up by calculate_needs_all_insns, containing
213      all insns that need reloading.  */
214   struct insn_chain *next_need_reload;
215
216   /* The basic block this insn is in.  */
217   int block;
218   /* The rtx of the insn.  */
219   rtx insn;
220   /* Register life information: record all live hard registers, and all
221      live pseudos that have a hard register.
222      This information is recorded for the point immediately before the insn
223      (in live_before), and for the point within the insn at which all
224      outputs have just been written to (in live_after).  */
225   regset live_before;
226   regset live_after;
227
228   /* For each class, size of group of consecutive regs
229      that is needed for the reloads of this class.  */
230   char group_size[N_REG_CLASSES];
231   /* For each class, the machine mode which requires consecutive
232      groups of regs of that class.
233      If two different modes ever require groups of one class,
234      they must be the same size and equally restrictive for that class,
235      otherwise we can't handle the complexity.  */
236   enum machine_mode group_mode[N_REG_CLASSES];
237
238   /* Indicates if a register was counted against the need for
239      groups.  0 means it can count against max_nongroup instead.  */
240   HARD_REG_SET counted_for_groups;
241
242   /* Indicates if a register was counted against the need for
243      non-groups.  0 means it can become part of a new group.
244      During choose_reload_regs, 1 here means don't use this reg
245      as part of a group, even if it seems to be otherwise ok.  */
246   HARD_REG_SET counted_for_nongroups;
247
248   /* Indicates which registers have already been used for spills.  */
249   HARD_REG_SET used_spill_regs;
250
251   /* Describe the needs for reload registers of this insn.  */
252   struct needs need;
253
254   /* Nonzero if find_reloads said the insn requires reloading.  */
255   unsigned int need_reload:1;
256   /* Nonzero if find_reloads needs to be run during reload_as_needed to
257      perform modifications on any operands.  */
258   unsigned int need_operand_change:1;
259   /* Nonzero if eliminate_regs_in_insn said it requires eliminations.  */
260   unsigned int need_elim:1;
261   /* Nonzero if this insn was inserted by perform_caller_saves.  */
262   unsigned int is_caller_save_insn:1;
263 };
264
265 /* A chain of insn_chain structures to describe all non-note insns in
266    a function.  */
267 extern struct insn_chain *reload_insn_chain;
268
269 /* Allocate a new insn_chain structure.  */
270 extern struct insn_chain *new_insn_chain        PROTO((void));
271
272 extern void compute_use_by_pseudos              PROTO((HARD_REG_SET *, regset));
273 #endif
274
275 /* Functions from reload.c:  */
276
277 /* Return a memory location that will be used to copy X in mode MODE.  
278    If we haven't already made a location for this mode in this insn,
279    call find_reloads_address on the location being returned.  */
280 extern rtx get_secondary_mem PROTO((rtx, enum machine_mode,
281                                     int, enum reload_type));
282
283 /* Clear any secondary memory locations we've made.  */
284 extern void clear_secondary_mem PROTO((void));
285
286 /* Transfer all replacements that used to be in reload FROM to be in
287    reload TO.  */
288 extern void transfer_replacements PROTO((int, int));
289
290 /* IN_RTX is the value loaded by a reload that we now decided to inherit,
291    or a subpart of it.  If we have any replacements registered for IN_RTX,
292    chancel the reloads that were supposed to load them.
293    Return non-zero if we chanceled any reloads.  */
294 extern int remove_address_replacements PROTO((rtx in_rtx));
295
296 /* Like rtx_equal_p except that it allows a REG and a SUBREG to match
297    if they are the same hard reg, and has special hacks for
298    autoincrement and autodecrement.  */
299 extern int operands_match_p PROTO((rtx, rtx));
300
301 /* Return 1 if altering OP will not modify the value of CLOBBER. */
302 extern int safe_from_earlyclobber PROTO((rtx, rtx));
303
304 /* Search the body of INSN for values that need reloading and record them
305    with push_reload.  REPLACE nonzero means record also where the values occur
306    so that subst_reloads can be used.  */
307 extern int find_reloads PROTO((rtx, int, int, int, short *));
308
309 /* Compute the sum of X and Y, making canonicalizations assumed in an
310    address, namely: sum constant integers, surround the sum of two
311    constants with a CONST, put the constant as the second operand, and
312    group the constant on the outermost sum.  */
313 extern rtx form_sum PROTO((rtx, rtx));
314
315 /* Substitute into the current INSN the registers into which we have reloaded
316    the things that need reloading.  */
317 extern void subst_reloads PROTO((void));
318
319 /* Make a copy of any replacements being done into X and move those copies
320    to locations in Y, a copy of X.  We only look at the highest level of
321    the RTL.  */
322 extern void copy_replacements PROTO((rtx, rtx));
323
324 /* Change any replacements being done to *X to be done to *Y */
325 extern void move_replacements PROTO((rtx *x, rtx *y));
326
327 /* If LOC was scheduled to be replaced by something, return the replacement.
328    Otherwise, return *LOC.  */
329 extern rtx find_replacement PROTO((rtx *));
330
331 /* Return nonzero if register in range [REGNO, ENDREGNO)
332    appears either explicitly or implicitly in X
333    other than being stored into.  */
334 extern int refers_to_regno_for_reload_p PROTO((int, int, rtx, rtx *));
335
336 /* Nonzero if modifying X will affect IN.  */
337 extern int reg_overlap_mentioned_for_reload_p PROTO((rtx, rtx));
338
339 /* Return nonzero if anything in X contains a MEM.  Look also for pseudo
340    registers.  */
341 extern int refers_to_mem_for_reload_p PROTO((rtx));
342
343 /* Check the insns before INSN to see if there is a suitable register
344    containing the same value as GOAL.  */
345 extern rtx find_equiv_reg PROTO((rtx, rtx, enum reg_class, int, short *,
346                                  int, enum machine_mode));
347
348 /* Return 1 if register REGNO is the subject of a clobber in insn INSN.  */
349 extern int regno_clobbered_p PROTO((int, rtx));
350
351 /* Functions in reload1.c:  */
352
353 extern int reloads_conflict             PROTO ((int, int));
354
355 int count_occurrences            PROTO((rtx, rtx));
356
357 /* Initialize the reload pass once per compilation.  */
358 extern void init_reload PROTO((void));
359
360 /* The reload pass itself.  */
361 extern int reload PROTO((rtx, int, FILE *));
362
363 /* Mark the slots in regs_ever_live for the hard regs
364    used by pseudo-reg number REGNO.  */
365 extern void mark_home_live PROTO((int));
366
367 /* Scan X and replace any eliminable registers (such as fp) with a
368    replacement (such as sp), plus an offset.  */
369 extern rtx eliminate_regs PROTO((rtx, enum machine_mode, rtx));
370
371 /* Emit code to perform a reload from IN (which may be a reload register) to
372    OUT (which may also be a reload register).  IN or OUT is from operand
373    OPNUM with reload type TYPE.  */
374 extern rtx gen_reload PROTO((rtx, rtx, int, enum reload_type));
375
376 /* Deallocate the reload register used by reload number R.  */
377 extern void deallocate_reload_reg PROTO((int r));
378
379 /* Functions in caller-save.c:  */
380
381 /* Initialize for caller-save.  */
382 extern void init_caller_save PROTO((void));
383
384 /* Initialize save areas by showing that we haven't allocated any yet.  */
385 extern void init_save_areas PROTO((void));
386
387 /* Allocate save areas for any hard registers that might need saving.  */
388 extern void setup_save_areas PROTO((void));
389
390 /* Find the places where hard regs are live across calls and save them.  */
391 extern void save_call_clobbered_regs PROTO((void));
392
393 /* Replace (subreg (reg)) with the appropriate (reg) for any operands.  */
394 extern void cleanup_subreg_operands PROTO ((rtx));