1 /* Communication between reload.c and reload1.c.
2 Copyright (C) 1987, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
4 This file is part of GNU CC.
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)
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.
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /* If secondary reloads are the same for inputs and outputs, define those
24 #ifdef SECONDARY_RELOAD_CLASS
25 #define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X) \
26 SECONDARY_RELOAD_CLASS (CLASS, MODE, X)
27 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, X) \
28 SECONDARY_RELOAD_CLASS (CLASS, MODE, X)
31 /* If either macro is defined, show that we need secondary reloads. */
32 #if defined(SECONDARY_INPUT_RELOAD_CLASS) || defined(SECONDARY_OUTPUT_RELOAD_CLASS)
33 #define HAVE_SECONDARY_RELOADS
36 /* See reload.c and reload1.c for comments on these variables. */
38 /* Maximum number of reloads we can need. */
39 #define MAX_RELOADS (2 * MAX_RECOG_OPERANDS * (MAX_REGS_PER_ADDRESS + 1))
41 extern rtx reload_in
[MAX_RELOADS
];
42 extern rtx reload_out
[MAX_RELOADS
];
43 extern rtx reload_in_reg
[MAX_RELOADS
];
44 extern enum reg_class reload_reg_class
[MAX_RELOADS
];
45 extern enum machine_mode reload_inmode
[MAX_RELOADS
];
46 extern enum machine_mode reload_outmode
[MAX_RELOADS
];
47 extern char reload_optional
[MAX_RELOADS
];
48 extern int reload_inc
[MAX_RELOADS
];
49 extern int reload_opnum
[MAX_RELOADS
];
50 extern int reload_secondary_p
[MAX_RELOADS
];
51 extern int reload_secondary_in_reload
[MAX_RELOADS
];
52 extern int reload_secondary_out_reload
[MAX_RELOADS
];
54 extern enum insn_code reload_secondary_in_icode
[MAX_RELOADS
];
55 extern enum insn_code reload_secondary_out_icode
[MAX_RELOADS
];
59 extern rtx reload_reg_rtx
[MAX_RELOADS
];
61 /* Encode the usage of a reload. The following codes are supported:
63 RELOAD_FOR_INPUT reload of an input operand
64 RELOAD_FOR_OUTPUT likewise, for output
65 RELOAD_FOR_INSN a reload that must not conflict with anything
66 used in the insn, but may conflict with
67 something used before or after the insn
68 RELOAD_FOR_INPUT_ADDRESS reload for parts of the address of an object
69 that is an input reload
70 RELOAD_FOR_OUTPUT_ADDRESS likewise, for output reload
71 RELOAD_FOR_OPERAND_ADDRESS reload for the address of a non-reloaded
72 operand; these don't conflict with
74 RELOAD_OTHER none of the above, usually multiple uses
75 RELOAD_FOR_OTHER_ADDRESS reload for part of the address of an input
76 that is marked RELOAD_OTHER.
78 This used to be "enum reload_when_needed" but some debuggers have trouble
79 with an enum tag and variable of the same name. */
83 RELOAD_FOR_INPUT
, RELOAD_FOR_OUTPUT
, RELOAD_FOR_INSN
,
84 RELOAD_FOR_INPUT_ADDRESS
, RELOAD_FOR_OUTPUT_ADDRESS
,
85 RELOAD_FOR_OPERAND_ADDRESS
, RELOAD_OTHER
, RELOAD_FOR_OTHER_ADDRESS
88 extern enum reload_type reload_when_needed
[MAX_RELOADS
];
90 extern rtx
*reg_equiv_constant
;
91 extern rtx
*reg_equiv_memory_loc
;
92 extern rtx
*reg_equiv_address
;
93 extern rtx
*reg_equiv_mem
;
95 /* All the "earlyclobber" operands of the current insn
97 extern int n_earlyclobbers
;
98 extern rtx reload_earlyclobbers
[MAX_RECOG_OPERANDS
];
100 /* Save the number of operands. */
101 extern int reload_n_operands
;
103 /* First uid used by insns created by reload in this function.
104 Used in find_equiv_reg. */
105 extern int reload_first_uid
;
107 /* Nonzero if indirect addressing is supported when the innermost MEM is
108 of the form (MEM (SYMBOL_REF sym)). It is assumed that the level to
109 which these are valid is the same as spill_indirect_levels, above. */
111 extern char indirect_symref_ok
;
113 /* Nonzero if an address (plus (reg frame_pointer) (reg ...)) is valid. */
114 extern char double_reg_address_ok
;
117 /* These arrays record the insn_code of insns that may be needed to
118 perform input and output reloads of special objects. They provide a
119 place to pass a scratch register. */
120 extern enum insn_code reload_in_optab
[];
121 extern enum insn_code reload_out_optab
[];
124 /* Functions from reload.c: */
126 /* Return a memory location that will be used to copy X in mode MODE.
127 If we haven't already made a location for this mode in this insn,
128 call find_reloads_address on the location being returned. */
129 extern rtx get_secondary_mem
PROTO((rtx
, enum machine_mode
,
130 int, enum reload_type
));
132 /* Clear any secondary memory locations we've made. */
133 extern void clear_secondary_mem
PROTO((void));
135 /* Transfer all replacements that used to be in reload FROM to be in
137 extern void transfer_replacements
PROTO((int, int));
139 /* Return 1 if ADDR is a valid memory address for mode MODE,
140 and check that each pseudo reg has the proper kind of
142 extern int strict_memory_address_p
PROTO((enum machine_mode
, rtx
));
144 /* Like rtx_equal_p except that it allows a REG and a SUBREG to match
145 if they are the same hard reg, and has special hacks for
146 autoincrement and autodecrement. */
147 extern int operands_match_p
PROTO((rtx
, rtx
));
149 /* Return the number of times character C occurs in string S. */
150 extern int n_occurrences
PROTO((int, char *));
152 /* Return 1 if altering OP will not modify the value of CLOBBER. */
153 extern int safe_from_earlyclobber
PROTO((rtx
, rtx
));
155 /* Search the body of INSN for values that need reloading and record them
156 with push_reload. REPLACE nonzero means record also where the values occur
157 so that subst_reloads can be used. */
158 extern void find_reloads
PROTO((rtx
, int, int, int, short *));
160 /* Compute the sum of X and Y, making canonicalizations assumed in an
161 address, namely: sum constant integers, surround the sum of two
162 constants with a CONST, put the constant as the second operand, and
163 group the constant on the outermost sum. */
164 extern rtx form_sum
PROTO((rtx
, rtx
));
166 /* Substitute into the current INSN the registers into which we have reloaded
167 the things that need reloading. */
168 extern void subst_reloads
PROTO((void));
170 /* Make a copy of any replacements being done into X and move those copies
171 to locations in Y, a copy of X. We only look at the highest level of
173 extern void copy_replacements
PROTO((rtx
, rtx
));
175 /* If LOC was scheduled to be replaced by something, return the replacement.
176 Otherwise, return *LOC. */
177 extern rtx find_replacement
PROTO((rtx
*));
179 /* Return nonzero if register in range [REGNO, ENDREGNO)
180 appears either explicitly or implicitly in X
181 other than being stored into. */
182 extern int refers_to_regno_for_reload_p
PROTO((int, int, rtx
, rtx
*));
184 /* Nonzero if modifying X will affect IN. */
185 extern int reg_overlap_mentioned_for_reload_p
PROTO((rtx
, rtx
));
187 /* Return nonzero if anything in X contains a MEM. Look also for pseudo
189 extern int refers_to_mem_for_reload_p
PROTO((rtx
));
191 /* Check the insns before INSN to see if there is a suitable register
192 containing the same value as GOAL. */
193 extern rtx find_equiv_reg
PROTO((rtx
, rtx
, enum reg_class
, int, short *,
194 int, enum machine_mode
));
196 /* Return 1 if register REGNO is the subject of a clobber in insn INSN. */
197 extern int regno_clobbered_p
PROTO((int, rtx
));
200 /* Functions in reload1.c: */
202 /* Initialize the reload pass once per compilation. */
203 extern void init_reload
PROTO((void));
205 /* The reload pass itself. */
206 extern int reload
STDIO_PROTO((rtx
, int, FILE *));
208 /* Mark the slots in regs_ever_live for the hard regs
209 used by pseudo-reg number REGNO. */
210 extern void mark_home_live
PROTO((int));
212 /* Scan X and replace any eliminable registers (such as fp) with a
213 replacement (such as sp), plus an offset. */
214 extern rtx eliminate_regs
PROTO((rtx
, enum machine_mode
, rtx
));
216 /* Emit code to perform an input reload of IN to RELOADREG. IN is from
217 operand OPNUM with reload type TYPE. */
218 extern rtx gen_input_reload
PROTO((rtx
, rtx
, int, enum reload_type
));
220 /* Functions in caller-save.c: */
222 /* Initialize for caller-save. */
223 extern void init_caller_save
PROTO((void));
225 /* Initialize save areas by showing that we haven't allocated any yet. */
226 extern void init_save_areas
PROTO((void));
228 /* Allocate save areas for any hard registers that might need saving. */
229 extern int setup_save_areas
PROTO((int *));
231 /* Find the places where hard regs are live across calls and save them. */
232 extern void save_call_clobbered_regs
PROTO((enum machine_mode
));