]>
Commit | Line | Data |
---|---|---|
eab89b90 | 1 | /* Search an insn for pseudo regs that must be in hard regs and are not. |
b685dbae | 2 | Copyright (C) 1987, 88, 89, 92-6, 1997 Free Software Foundation, Inc. |
eab89b90 RK |
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 | |
e99215a3 RK |
18 | the Free Software Foundation, 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. */ | |
eab89b90 RK |
20 | |
21 | ||
22 | /* This file contains subroutines used only from the file reload1.c. | |
23 | It knows how to scan one insn for operands and values | |
24 | that need to be copied into registers to make valid code. | |
25 | It also finds other operands and values which are valid | |
26 | but for which equivalent values in registers exist and | |
27 | ought to be used instead. | |
28 | ||
29 | Before processing the first insn of the function, call `init_reload'. | |
30 | ||
31 | To scan an insn, call `find_reloads'. This does two things: | |
32 | 1. sets up tables describing which values must be reloaded | |
33 | for this insn, and what kind of hard regs they must be reloaded into; | |
34 | 2. optionally record the locations where those values appear in | |
35 | the data, so they can be replaced properly later. | |
36 | This is done only if the second arg to `find_reloads' is nonzero. | |
37 | ||
38 | The third arg to `find_reloads' specifies the number of levels | |
39 | of indirect addressing supported by the machine. If it is zero, | |
40 | indirect addressing is not valid. If it is one, (MEM (REG n)) | |
41 | is valid even if (REG n) did not get a hard register; if it is two, | |
42 | (MEM (MEM (REG n))) is also valid even if (REG n) did not get a | |
43 | hard register, and similarly for higher values. | |
44 | ||
45 | Then you must choose the hard regs to reload those pseudo regs into, | |
46 | and generate appropriate load insns before this insn and perhaps | |
47 | also store insns after this insn. Set up the array `reload_reg_rtx' | |
48 | to contain the REG rtx's for the registers you used. In some | |
49 | cases `find_reloads' will return a nonzero value in `reload_reg_rtx' | |
50 | for certain reloads. Then that tells you which register to use, | |
51 | so you do not need to allocate one. But you still do need to add extra | |
52 | instructions to copy the value into and out of that register. | |
53 | ||
54 | Finally you must call `subst_reloads' to substitute the reload reg rtx's | |
55 | into the locations already recorded. | |
56 | ||
57 | NOTE SIDE EFFECTS: | |
58 | ||
59 | find_reloads can alter the operands of the instruction it is called on. | |
60 | ||
61 | 1. Two operands of any sort may be interchanged, if they are in a | |
62 | commutative instruction. | |
63 | This happens only if find_reloads thinks the instruction will compile | |
64 | better that way. | |
65 | ||
66 | 2. Pseudo-registers that are equivalent to constants are replaced | |
67 | with those constants if they are not in hard registers. | |
68 | ||
69 | 1 happens every time find_reloads is called. | |
70 | 2 happens only when REPLACE is 1, which is only when | |
71 | actually doing the reloads, not when just counting them. | |
72 | ||
73 | ||
74 | Using a reload register for several reloads in one insn: | |
75 | ||
76 | When an insn has reloads, it is considered as having three parts: | |
77 | the input reloads, the insn itself after reloading, and the output reloads. | |
78 | Reloads of values used in memory addresses are often needed for only one part. | |
79 | ||
80 | When this is so, reload_when_needed records which part needs the reload. | |
81 | Two reloads for different parts of the insn can share the same reload | |
82 | register. | |
83 | ||
84 | When a reload is used for addresses in multiple parts, or when it is | |
85 | an ordinary operand, it is classified as RELOAD_OTHER, and cannot share | |
86 | a register with any other reload. */ | |
87 | ||
88 | #define REG_OK_STRICT | |
89 | ||
10bcde0d | 90 | #include <stdio.h> |
eab89b90 RK |
91 | #include "config.h" |
92 | #include "rtl.h" | |
93 | #include "insn-config.h" | |
94 | #include "insn-codes.h" | |
95 | #include "recog.h" | |
96 | #include "reload.h" | |
97 | #include "regs.h" | |
98 | #include "hard-reg-set.h" | |
99 | #include "flags.h" | |
100 | #include "real.h" | |
8a840ac9 | 101 | #include "output.h" |
eab89b90 RK |
102 | |
103 | #ifndef REGISTER_MOVE_COST | |
104 | #define REGISTER_MOVE_COST(x, y) 2 | |
105 | #endif | |
858c3c8c ILT |
106 | |
107 | #ifndef REGNO_MODE_OK_FOR_BASE_P | |
108 | #define REGNO_MODE_OK_FOR_BASE_P(REGNO, MODE) REGNO_OK_FOR_BASE_P (REGNO) | |
109 | #endif | |
110 | ||
111 | #ifndef REG_MODE_OK_FOR_BASE_P | |
112 | #define REG_MODE_OK_FOR_BASE_P(REGNO, MODE) REG_OK_FOR_BASE_P (REGNO) | |
113 | #endif | |
eab89b90 RK |
114 | \f |
115 | /* The variables set up by `find_reloads' are: | |
116 | ||
117 | n_reloads number of distinct reloads needed; max reload # + 1 | |
118 | tables indexed by reload number | |
119 | reload_in rtx for value to reload from | |
120 | reload_out rtx for where to store reload-reg afterward if nec | |
121 | (often the same as reload_in) | |
122 | reload_reg_class enum reg_class, saying what regs to reload into | |
123 | reload_inmode enum machine_mode; mode this operand should have | |
124 | when reloaded, on input. | |
125 | reload_outmode enum machine_mode; mode this operand should have | |
126 | when reloaded, on output. | |
eab89b90 RK |
127 | reload_optional char, nonzero for an optional reload. |
128 | Optional reloads are ignored unless the | |
129 | value is already sitting in a register. | |
130 | reload_inc int, positive amount to increment or decrement by if | |
131 | reload_in is a PRE_DEC, PRE_INC, POST_DEC, POST_INC. | |
132 | Ignored otherwise (don't assume it is zero). | |
133 | reload_in_reg rtx. A reg for which reload_in is the equivalent. | |
134 | If reload_in is a symbol_ref which came from | |
135 | reg_equiv_constant, then this is the pseudo | |
136 | which has that symbol_ref as equivalent. | |
137 | reload_reg_rtx rtx. This is the register to reload into. | |
138 | If it is zero when `find_reloads' returns, | |
139 | you must find a suitable register in the class | |
140 | specified by reload_reg_class, and store here | |
141 | an rtx for that register with mode from | |
142 | reload_inmode or reload_outmode. | |
143 | reload_nocombine char, nonzero if this reload shouldn't be | |
144 | combined with another reload. | |
a8c9daeb RK |
145 | reload_opnum int, operand number being reloaded. This is |
146 | used to group related reloads and need not always | |
147 | be equal to the actual operand number in the insn, | |
148 | though it current will be; for in-out operands, it | |
149 | is one of the two operand numbers. | |
150 | reload_when_needed enum, classifies reload as needed either for | |
eab89b90 RK |
151 | addressing an input reload, addressing an output, |
152 | for addressing a non-reloaded mem ref, | |
153 | or for unspecified purposes (i.e., more than one | |
154 | of the above). | |
eab89b90 | 155 | reload_secondary_p int, 1 if this is a secondary register for one |
9ec7078b RK |
156 | or more reloads. |
157 | reload_secondary_in_reload | |
158 | reload_secondary_out_reload | |
159 | int, gives the reload number of a secondary | |
160 | reload, when needed; otherwise -1 | |
161 | reload_secondary_in_icode | |
162 | reload_secondary_out_icode | |
163 | enum insn_code, if a secondary reload is required, | |
eab89b90 RK |
164 | gives the INSN_CODE that uses the secondary |
165 | reload as a scratch register, or CODE_FOR_nothing | |
166 | if the secondary reload register is to be an | |
167 | intermediate register. */ | |
168 | int n_reloads; | |
169 | ||
170 | rtx reload_in[MAX_RELOADS]; | |
171 | rtx reload_out[MAX_RELOADS]; | |
172 | enum reg_class reload_reg_class[MAX_RELOADS]; | |
173 | enum machine_mode reload_inmode[MAX_RELOADS]; | |
174 | enum machine_mode reload_outmode[MAX_RELOADS]; | |
eab89b90 RK |
175 | rtx reload_reg_rtx[MAX_RELOADS]; |
176 | char reload_optional[MAX_RELOADS]; | |
177 | int reload_inc[MAX_RELOADS]; | |
178 | rtx reload_in_reg[MAX_RELOADS]; | |
179 | char reload_nocombine[MAX_RELOADS]; | |
a8c9daeb RK |
180 | int reload_opnum[MAX_RELOADS]; |
181 | enum reload_type reload_when_needed[MAX_RELOADS]; | |
eab89b90 | 182 | int reload_secondary_p[MAX_RELOADS]; |
9ec7078b RK |
183 | int reload_secondary_in_reload[MAX_RELOADS]; |
184 | int reload_secondary_out_reload[MAX_RELOADS]; | |
185 | enum insn_code reload_secondary_in_icode[MAX_RELOADS]; | |
186 | enum insn_code reload_secondary_out_icode[MAX_RELOADS]; | |
eab89b90 RK |
187 | |
188 | /* All the "earlyclobber" operands of the current insn | |
189 | are recorded here. */ | |
190 | int n_earlyclobbers; | |
191 | rtx reload_earlyclobbers[MAX_RECOG_OPERANDS]; | |
192 | ||
a8c9daeb RK |
193 | int reload_n_operands; |
194 | ||
eab89b90 RK |
195 | /* Replacing reloads. |
196 | ||
197 | If `replace_reloads' is nonzero, then as each reload is recorded | |
198 | an entry is made for it in the table `replacements'. | |
199 | Then later `subst_reloads' can look through that table and | |
200 | perform all the replacements needed. */ | |
201 | ||
202 | /* Nonzero means record the places to replace. */ | |
203 | static int replace_reloads; | |
204 | ||
205 | /* Each replacement is recorded with a structure like this. */ | |
206 | struct replacement | |
207 | { | |
208 | rtx *where; /* Location to store in */ | |
209 | rtx *subreg_loc; /* Location of SUBREG if WHERE is inside | |
210 | a SUBREG; 0 otherwise. */ | |
211 | int what; /* which reload this is for */ | |
212 | enum machine_mode mode; /* mode it must have */ | |
213 | }; | |
214 | ||
215 | static struct replacement replacements[MAX_RECOG_OPERANDS * ((MAX_REGS_PER_ADDRESS * 2) + 1)]; | |
216 | ||
217 | /* Number of replacements currently recorded. */ | |
218 | static int n_replacements; | |
219 | ||
a8c9daeb RK |
220 | /* Used to track what is modified by an operand. */ |
221 | struct decomposition | |
222 | { | |
0f41302f MS |
223 | int reg_flag; /* Nonzero if referencing a register. */ |
224 | int safe; /* Nonzero if this can't conflict with anything. */ | |
225 | rtx base; /* Base address for MEM. */ | |
226 | HOST_WIDE_INT start; /* Starting offset or register number. */ | |
2a6d5ce0 | 227 | HOST_WIDE_INT end; /* Ending offset or register number. */ |
a8c9daeb RK |
228 | }; |
229 | ||
eab89b90 RK |
230 | /* MEM-rtx's created for pseudo-regs in stack slots not directly addressable; |
231 | (see reg_equiv_address). */ | |
232 | static rtx memlocs[MAX_RECOG_OPERANDS * ((MAX_REGS_PER_ADDRESS * 2) + 1)]; | |
233 | static int n_memlocs; | |
234 | ||
0dadecf6 RK |
235 | #ifdef SECONDARY_MEMORY_NEEDED |
236 | ||
237 | /* Save MEMs needed to copy from one class of registers to another. One MEM | |
238 | is used per mode, but normally only one or two modes are ever used. | |
239 | ||
a8c9daeb RK |
240 | We keep two versions, before and after register elimination. The one |
241 | after register elimination is record separately for each operand. This | |
242 | is done in case the address is not valid to be sure that we separately | |
243 | reload each. */ | |
0dadecf6 RK |
244 | |
245 | static rtx secondary_memlocs[NUM_MACHINE_MODES]; | |
77545d45 | 246 | static rtx secondary_memlocs_elim[NUM_MACHINE_MODES][MAX_RECOG_OPERANDS]; |
0dadecf6 RK |
247 | #endif |
248 | ||
eab89b90 RK |
249 | /* The instruction we are doing reloads for; |
250 | so we can test whether a register dies in it. */ | |
251 | static rtx this_insn; | |
252 | ||
253 | /* Nonzero if this instruction is a user-specified asm with operands. */ | |
254 | static int this_insn_is_asm; | |
255 | ||
256 | /* If hard_regs_live_known is nonzero, | |
257 | we can tell which hard regs are currently live, | |
258 | at least enough to succeed in choosing dummy reloads. */ | |
259 | static int hard_regs_live_known; | |
260 | ||
261 | /* Indexed by hard reg number, | |
262 | element is nonegative if hard reg has been spilled. | |
263 | This vector is passed to `find_reloads' as an argument | |
264 | and is not changed here. */ | |
265 | static short *static_reload_reg_p; | |
266 | ||
267 | /* Set to 1 in subst_reg_equivs if it changes anything. */ | |
268 | static int subst_reg_equivs_changed; | |
269 | ||
270 | /* On return from push_reload, holds the reload-number for the OUT | |
271 | operand, which can be different for that from the input operand. */ | |
272 | static int output_reloadnum; | |
273 | ||
9ec7078b RK |
274 | /* Compare two RTX's. */ |
275 | #define MATCHES(x, y) \ | |
276 | (x == y || (x != 0 && (GET_CODE (x) == REG \ | |
277 | ? GET_CODE (y) == REG && REGNO (x) == REGNO (y) \ | |
278 | : rtx_equal_p (x, y) && ! side_effects_p (x)))) | |
279 | ||
280 | /* Indicates if two reloads purposes are for similar enough things that we | |
281 | can merge their reloads. */ | |
282 | #define MERGABLE_RELOADS(when1, when2, op1, op2) \ | |
283 | ((when1) == RELOAD_OTHER || (when2) == RELOAD_OTHER \ | |
284 | || ((when1) == (when2) && (op1) == (op2)) \ | |
285 | || ((when1) == RELOAD_FOR_INPUT && (when2) == RELOAD_FOR_INPUT) \ | |
286 | || ((when1) == RELOAD_FOR_OPERAND_ADDRESS \ | |
287 | && (when2) == RELOAD_FOR_OPERAND_ADDRESS) \ | |
288 | || ((when1) == RELOAD_FOR_OTHER_ADDRESS \ | |
289 | && (when2) == RELOAD_FOR_OTHER_ADDRESS)) | |
290 | ||
291 | /* Nonzero if these two reload purposes produce RELOAD_OTHER when merged. */ | |
292 | #define MERGE_TO_OTHER(when1, when2, op1, op2) \ | |
293 | ((when1) != (when2) \ | |
294 | || ! ((op1) == (op2) \ | |
295 | || (when1) == RELOAD_FOR_INPUT \ | |
296 | || (when1) == RELOAD_FOR_OPERAND_ADDRESS \ | |
297 | || (when1) == RELOAD_FOR_OTHER_ADDRESS)) | |
298 | ||
47c8cf91 ILT |
299 | /* If we are going to reload an address, compute the reload type to |
300 | use. */ | |
301 | #define ADDR_TYPE(type) \ | |
302 | ((type) == RELOAD_FOR_INPUT_ADDRESS \ | |
303 | ? RELOAD_FOR_INPADDR_ADDRESS \ | |
304 | : ((type) == RELOAD_FOR_OUTPUT_ADDRESS \ | |
305 | ? RELOAD_FOR_OUTADDR_ADDRESS \ | |
306 | : (type))) | |
307 | ||
9ec7078b RK |
308 | static int push_secondary_reload PROTO((int, rtx, int, int, enum reg_class, |
309 | enum machine_mode, enum reload_type, | |
310 | enum insn_code *)); | |
c6716840 | 311 | static enum reg_class find_valid_class PROTO((enum machine_mode, int)); |
a8c9daeb RK |
312 | static int push_reload PROTO((rtx, rtx, rtx *, rtx *, enum reg_class, |
313 | enum machine_mode, enum machine_mode, | |
314 | int, int, int, enum reload_type)); | |
315 | static void push_replacement PROTO((rtx *, int, enum machine_mode)); | |
316 | static void combine_reloads PROTO((void)); | |
317 | static rtx find_dummy_reload PROTO((rtx, rtx, rtx *, rtx *, | |
36b50568 | 318 | enum machine_mode, enum machine_mode, |
a8c9daeb | 319 | enum reg_class, int)); |
4644aad4 | 320 | static int earlyclobber_operand_p PROTO((rtx)); |
a8c9daeb RK |
321 | static int hard_reg_set_here_p PROTO((int, int, rtx)); |
322 | static struct decomposition decompose PROTO((rtx)); | |
323 | static int immune_p PROTO((rtx, rtx, struct decomposition)); | |
324 | static int alternative_allows_memconst PROTO((char *, int)); | |
325 | static rtx find_reloads_toplev PROTO((rtx, int, enum reload_type, int, int)); | |
326 | static rtx make_memloc PROTO((rtx, int)); | |
327 | static int find_reloads_address PROTO((enum machine_mode, rtx *, rtx, rtx *, | |
328 | int, enum reload_type, int)); | |
329 | static rtx subst_reg_equivs PROTO((rtx)); | |
330 | static rtx subst_indexed_address PROTO((rtx)); | |
858c3c8c ILT |
331 | static int find_reloads_address_1 PROTO((enum machine_mode, rtx, int, rtx *, |
332 | int, enum reload_type,int)); | |
a8c9daeb RK |
333 | static void find_reloads_address_part PROTO((rtx, rtx *, enum reg_class, |
334 | enum machine_mode, int, | |
335 | enum reload_type, int)); | |
336 | static int find_inc_amount PROTO((rtx, rtx)); | |
eab89b90 RK |
337 | \f |
338 | #ifdef HAVE_SECONDARY_RELOADS | |
339 | ||
340 | /* Determine if any secondary reloads are needed for loading (if IN_P is | |
341 | non-zero) or storing (if IN_P is zero) X to or from a reload register of | |
9ec7078b RK |
342 | register class RELOAD_CLASS in mode RELOAD_MODE. If secondary reloads |
343 | are needed, push them. | |
344 | ||
345 | Return the reload number of the secondary reload we made, or -1 if | |
346 | we didn't need one. *PICODE is set to the insn_code to use if we do | |
347 | need a secondary reload. */ | |
348 | ||
349 | static int | |
350 | push_secondary_reload (in_p, x, opnum, optional, reload_class, reload_mode, | |
351 | type, picode) | |
352 | int in_p; | |
eab89b90 | 353 | rtx x; |
9ec7078b RK |
354 | int opnum; |
355 | int optional; | |
eab89b90 RK |
356 | enum reg_class reload_class; |
357 | enum machine_mode reload_mode; | |
9ec7078b | 358 | enum reload_type type; |
eab89b90 | 359 | enum insn_code *picode; |
eab89b90 RK |
360 | { |
361 | enum reg_class class = NO_REGS; | |
362 | enum machine_mode mode = reload_mode; | |
363 | enum insn_code icode = CODE_FOR_nothing; | |
364 | enum reg_class t_class = NO_REGS; | |
365 | enum machine_mode t_mode = VOIDmode; | |
366 | enum insn_code t_icode = CODE_FOR_nothing; | |
d94d2abc | 367 | enum reload_type secondary_type; |
9ec7078b RK |
368 | int i; |
369 | int s_reload, t_reload = -1; | |
370 | ||
47c8cf91 ILT |
371 | if (type == RELOAD_FOR_INPUT_ADDRESS |
372 | || type == RELOAD_FOR_OUTPUT_ADDRESS | |
373 | || type == RELOAD_FOR_INPADDR_ADDRESS | |
374 | || type == RELOAD_FOR_OUTADDR_ADDRESS) | |
d94d2abc RK |
375 | secondary_type = type; |
376 | else | |
377 | secondary_type = in_p ? RELOAD_FOR_INPUT_ADDRESS : RELOAD_FOR_OUTPUT_ADDRESS; | |
378 | ||
9ec7078b | 379 | *picode = CODE_FOR_nothing; |
eab89b90 | 380 | |
67340b03 RK |
381 | /* If X is a paradoxical SUBREG, use the inner value to determine both the |
382 | mode and object being reloaded. */ | |
383 | if (GET_CODE (x) == SUBREG | |
384 | && (GET_MODE_SIZE (GET_MODE (x)) | |
385 | > GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))))) | |
386 | { | |
387 | x = SUBREG_REG (x); | |
388 | reload_mode = GET_MODE (x); | |
389 | } | |
390 | ||
d45cf215 RS |
391 | /* If X is a pseudo-register that has an equivalent MEM (actually, if it |
392 | is still a pseudo-register by now, it *must* have an equivalent MEM | |
393 | but we don't want to assume that), use that equivalent when seeing if | |
394 | a secondary reload is needed since whether or not a reload is needed | |
395 | might be sensitive to the form of the MEM. */ | |
396 | ||
397 | if (GET_CODE (x) == REG && REGNO (x) >= FIRST_PSEUDO_REGISTER | |
398 | && reg_equiv_mem[REGNO (x)] != 0) | |
399 | x = reg_equiv_mem[REGNO (x)]; | |
400 | ||
eab89b90 RK |
401 | #ifdef SECONDARY_INPUT_RELOAD_CLASS |
402 | if (in_p) | |
403 | class = SECONDARY_INPUT_RELOAD_CLASS (reload_class, reload_mode, x); | |
404 | #endif | |
405 | ||
406 | #ifdef SECONDARY_OUTPUT_RELOAD_CLASS | |
407 | if (! in_p) | |
408 | class = SECONDARY_OUTPUT_RELOAD_CLASS (reload_class, reload_mode, x); | |
409 | #endif | |
410 | ||
9ec7078b | 411 | /* If we don't need any secondary registers, done. */ |
eab89b90 | 412 | if (class == NO_REGS) |
9ec7078b | 413 | return -1; |
eab89b90 RK |
414 | |
415 | /* Get a possible insn to use. If the predicate doesn't accept X, don't | |
416 | use the insn. */ | |
417 | ||
418 | icode = (in_p ? reload_in_optab[(int) reload_mode] | |
419 | : reload_out_optab[(int) reload_mode]); | |
420 | ||
421 | if (icode != CODE_FOR_nothing | |
422 | && insn_operand_predicate[(int) icode][in_p] | |
423 | && (! (insn_operand_predicate[(int) icode][in_p]) (x, reload_mode))) | |
424 | icode = CODE_FOR_nothing; | |
425 | ||
426 | /* If we will be using an insn, see if it can directly handle the reload | |
427 | register we will be using. If it can, the secondary reload is for a | |
428 | scratch register. If it can't, we will use the secondary reload for | |
429 | an intermediate register and require a tertiary reload for the scratch | |
430 | register. */ | |
431 | ||
432 | if (icode != CODE_FOR_nothing) | |
433 | { | |
434 | /* If IN_P is non-zero, the reload register will be the output in | |
435 | operand 0. If IN_P is zero, the reload register will be the input | |
436 | in operand 1. Outputs should have an initial "=", which we must | |
437 | skip. */ | |
438 | ||
d45cf215 | 439 | char insn_letter = insn_operand_constraint[(int) icode][!in_p][in_p]; |
eab89b90 | 440 | enum reg_class insn_class |
d45cf215 RS |
441 | = (insn_letter == 'r' ? GENERAL_REGS |
442 | : REG_CLASS_FROM_LETTER (insn_letter)); | |
eab89b90 RK |
443 | |
444 | if (insn_class == NO_REGS | |
445 | || (in_p && insn_operand_constraint[(int) icode][!in_p][0] != '=') | |
446 | /* The scratch register's constraint must start with "=&". */ | |
447 | || insn_operand_constraint[(int) icode][2][0] != '=' | |
448 | || insn_operand_constraint[(int) icode][2][1] != '&') | |
449 | abort (); | |
450 | ||
451 | if (reg_class_subset_p (reload_class, insn_class)) | |
452 | mode = insn_operand_mode[(int) icode][2]; | |
453 | else | |
454 | { | |
d45cf215 | 455 | char t_letter = insn_operand_constraint[(int) icode][2][2]; |
eab89b90 RK |
456 | class = insn_class; |
457 | t_mode = insn_operand_mode[(int) icode][2]; | |
d45cf215 RS |
458 | t_class = (t_letter == 'r' ? GENERAL_REGS |
459 | : REG_CLASS_FROM_LETTER (t_letter)); | |
eab89b90 RK |
460 | t_icode = icode; |
461 | icode = CODE_FOR_nothing; | |
462 | } | |
463 | } | |
464 | ||
9ec7078b RK |
465 | /* This case isn't valid, so fail. Reload is allowed to use the same |
466 | register for RELOAD_FOR_INPUT_ADDRESS and RELOAD_FOR_INPUT reloads, but | |
467 | in the case of a secondary register, we actually need two different | |
468 | registers for correct code. We fail here to prevent the possibility of | |
469 | silently generating incorrect code later. | |
470 | ||
471 | The convention is that secondary input reloads are valid only if the | |
472 | secondary_class is different from class. If you have such a case, you | |
473 | can not use secondary reloads, you must work around the problem some | |
474 | other way. | |
475 | ||
476 | Allow this when MODE is not reload_mode and assume that the generated | |
477 | code handles this case (it does on the Alpha, which is the only place | |
478 | this currently happens). */ | |
479 | ||
480 | if (in_p && class == reload_class && mode == reload_mode) | |
481 | abort (); | |
482 | ||
483 | /* If we need a tertiary reload, see if we have one we can reuse or else | |
484 | make a new one. */ | |
485 | ||
486 | if (t_class != NO_REGS) | |
487 | { | |
488 | for (t_reload = 0; t_reload < n_reloads; t_reload++) | |
489 | if (reload_secondary_p[t_reload] | |
490 | && (reg_class_subset_p (t_class, reload_reg_class[t_reload]) | |
491 | || reg_class_subset_p (reload_reg_class[t_reload], t_class)) | |
492 | && ((in_p && reload_inmode[t_reload] == t_mode) | |
493 | || (! in_p && reload_outmode[t_reload] == t_mode)) | |
494 | && ((in_p && (reload_secondary_in_icode[t_reload] | |
495 | == CODE_FOR_nothing)) | |
496 | || (! in_p &&(reload_secondary_out_icode[t_reload] | |
497 | == CODE_FOR_nothing))) | |
498 | && (reg_class_size[(int) t_class] == 1 | |
499 | #ifdef SMALL_REGISTER_CLASSES | |
f95182a4 | 500 | || SMALL_REGISTER_CLASSES |
9ec7078b RK |
501 | #endif |
502 | ) | |
503 | && MERGABLE_RELOADS (secondary_type, | |
504 | reload_when_needed[t_reload], | |
505 | opnum, reload_opnum[t_reload])) | |
506 | { | |
507 | if (in_p) | |
508 | reload_inmode[t_reload] = t_mode; | |
509 | if (! in_p) | |
510 | reload_outmode[t_reload] = t_mode; | |
511 | ||
512 | if (reg_class_subset_p (t_class, reload_reg_class[t_reload])) | |
513 | reload_reg_class[t_reload] = t_class; | |
514 | ||
515 | reload_opnum[t_reload] = MIN (reload_opnum[t_reload], opnum); | |
516 | reload_optional[t_reload] &= optional; | |
517 | reload_secondary_p[t_reload] = 1; | |
518 | if (MERGE_TO_OTHER (secondary_type, reload_when_needed[t_reload], | |
519 | opnum, reload_opnum[t_reload])) | |
520 | reload_when_needed[t_reload] = RELOAD_OTHER; | |
521 | } | |
522 | ||
523 | if (t_reload == n_reloads) | |
524 | { | |
525 | /* We need to make a new tertiary reload for this register class. */ | |
526 | reload_in[t_reload] = reload_out[t_reload] = 0; | |
527 | reload_reg_class[t_reload] = t_class; | |
528 | reload_inmode[t_reload] = in_p ? t_mode : VOIDmode; | |
529 | reload_outmode[t_reload] = ! in_p ? t_mode : VOIDmode; | |
530 | reload_reg_rtx[t_reload] = 0; | |
531 | reload_optional[t_reload] = optional; | |
532 | reload_inc[t_reload] = 0; | |
533 | /* Maybe we could combine these, but it seems too tricky. */ | |
534 | reload_nocombine[t_reload] = 1; | |
535 | reload_in_reg[t_reload] = 0; | |
536 | reload_opnum[t_reload] = opnum; | |
537 | reload_when_needed[t_reload] = secondary_type; | |
538 | reload_secondary_in_reload[t_reload] = -1; | |
539 | reload_secondary_out_reload[t_reload] = -1; | |
540 | reload_secondary_in_icode[t_reload] = CODE_FOR_nothing; | |
541 | reload_secondary_out_icode[t_reload] = CODE_FOR_nothing; | |
542 | reload_secondary_p[t_reload] = 1; | |
543 | ||
544 | n_reloads++; | |
545 | } | |
546 | } | |
547 | ||
548 | /* See if we can reuse an existing secondary reload. */ | |
549 | for (s_reload = 0; s_reload < n_reloads; s_reload++) | |
550 | if (reload_secondary_p[s_reload] | |
551 | && (reg_class_subset_p (class, reload_reg_class[s_reload]) | |
552 | || reg_class_subset_p (reload_reg_class[s_reload], class)) | |
553 | && ((in_p && reload_inmode[s_reload] == mode) | |
554 | || (! in_p && reload_outmode[s_reload] == mode)) | |
555 | && ((in_p && reload_secondary_in_reload[s_reload] == t_reload) | |
556 | || (! in_p && reload_secondary_out_reload[s_reload] == t_reload)) | |
557 | && ((in_p && reload_secondary_in_icode[s_reload] == t_icode) | |
558 | || (! in_p && reload_secondary_out_icode[s_reload] == t_icode)) | |
559 | && (reg_class_size[(int) class] == 1 | |
560 | #ifdef SMALL_REGISTER_CLASSES | |
f95182a4 | 561 | || SMALL_REGISTER_CLASSES |
9ec7078b RK |
562 | #endif |
563 | ) | |
564 | && MERGABLE_RELOADS (secondary_type, reload_when_needed[s_reload], | |
565 | opnum, reload_opnum[s_reload])) | |
566 | { | |
567 | if (in_p) | |
568 | reload_inmode[s_reload] = mode; | |
569 | if (! in_p) | |
570 | reload_outmode[s_reload] = mode; | |
571 | ||
572 | if (reg_class_subset_p (class, reload_reg_class[s_reload])) | |
573 | reload_reg_class[s_reload] = class; | |
574 | ||
575 | reload_opnum[s_reload] = MIN (reload_opnum[s_reload], opnum); | |
576 | reload_optional[s_reload] &= optional; | |
577 | reload_secondary_p[s_reload] = 1; | |
578 | if (MERGE_TO_OTHER (secondary_type, reload_when_needed[s_reload], | |
579 | opnum, reload_opnum[s_reload])) | |
580 | reload_when_needed[s_reload] = RELOAD_OTHER; | |
581 | } | |
eab89b90 | 582 | |
9ec7078b RK |
583 | if (s_reload == n_reloads) |
584 | { | |
585 | /* We need to make a new secondary reload for this register class. */ | |
586 | reload_in[s_reload] = reload_out[s_reload] = 0; | |
587 | reload_reg_class[s_reload] = class; | |
588 | ||
589 | reload_inmode[s_reload] = in_p ? mode : VOIDmode; | |
590 | reload_outmode[s_reload] = ! in_p ? mode : VOIDmode; | |
591 | reload_reg_rtx[s_reload] = 0; | |
592 | reload_optional[s_reload] = optional; | |
593 | reload_inc[s_reload] = 0; | |
594 | /* Maybe we could combine these, but it seems too tricky. */ | |
595 | reload_nocombine[s_reload] = 1; | |
596 | reload_in_reg[s_reload] = 0; | |
597 | reload_opnum[s_reload] = opnum; | |
598 | reload_when_needed[s_reload] = secondary_type; | |
599 | reload_secondary_in_reload[s_reload] = in_p ? t_reload : -1; | |
600 | reload_secondary_out_reload[s_reload] = ! in_p ? t_reload : -1; | |
601 | reload_secondary_in_icode[s_reload] = in_p ? t_icode : CODE_FOR_nothing; | |
602 | reload_secondary_out_icode[s_reload] | |
603 | = ! in_p ? t_icode : CODE_FOR_nothing; | |
604 | reload_secondary_p[s_reload] = 1; | |
605 | ||
606 | n_reloads++; | |
607 | ||
608 | #ifdef SECONDARY_MEMORY_NEEDED | |
609 | /* If we need a memory location to copy between the two reload regs, | |
610 | set it up now. */ | |
611 | ||
612 | if (in_p && icode == CODE_FOR_nothing | |
f49e4127 JW |
613 | && SECONDARY_MEMORY_NEEDED (class, reload_class, mode)) |
614 | get_secondary_mem (x, mode, opnum, type); | |
9ec7078b RK |
615 | |
616 | if (! in_p && icode == CODE_FOR_nothing | |
f49e4127 JW |
617 | && SECONDARY_MEMORY_NEEDED (reload_class, class, mode)) |
618 | get_secondary_mem (x, mode, opnum, type); | |
9ec7078b RK |
619 | #endif |
620 | } | |
621 | ||
622 | *picode = icode; | |
623 | return s_reload; | |
eab89b90 RK |
624 | } |
625 | #endif /* HAVE_SECONDARY_RELOADS */ | |
626 | \f | |
0dadecf6 RK |
627 | #ifdef SECONDARY_MEMORY_NEEDED |
628 | ||
629 | /* Return a memory location that will be used to copy X in mode MODE. | |
630 | If we haven't already made a location for this mode in this insn, | |
631 | call find_reloads_address on the location being returned. */ | |
632 | ||
633 | rtx | |
a8c9daeb | 634 | get_secondary_mem (x, mode, opnum, type) |
0dadecf6 RK |
635 | rtx x; |
636 | enum machine_mode mode; | |
a8c9daeb RK |
637 | int opnum; |
638 | enum reload_type type; | |
0dadecf6 RK |
639 | { |
640 | rtx loc; | |
641 | int mem_valid; | |
642 | ||
64609742 RK |
643 | /* By default, if MODE is narrower than a word, widen it to a word. |
644 | This is required because most machines that require these memory | |
645 | locations do not support short load and stores from all registers | |
646 | (e.g., FP registers). */ | |
647 | ||
648 | #ifdef SECONDARY_MEMORY_NEEDED_MODE | |
649 | mode = SECONDARY_MEMORY_NEEDED_MODE (mode); | |
650 | #else | |
0dadecf6 RK |
651 | if (GET_MODE_BITSIZE (mode) < BITS_PER_WORD) |
652 | mode = mode_for_size (BITS_PER_WORD, GET_MODE_CLASS (mode), 0); | |
64609742 | 653 | #endif |
0dadecf6 | 654 | |
77545d45 RK |
655 | /* If we already have made a MEM for this operand in MODE, return it. */ |
656 | if (secondary_memlocs_elim[(int) mode][opnum] != 0) | |
657 | return secondary_memlocs_elim[(int) mode][opnum]; | |
0dadecf6 RK |
658 | |
659 | /* If this is the first time we've tried to get a MEM for this mode, | |
660 | allocate a new one. `something_changed' in reload will get set | |
661 | by noticing that the frame size has changed. */ | |
662 | ||
663 | if (secondary_memlocs[(int) mode] == 0) | |
b24a53d5 JW |
664 | { |
665 | #ifdef SECONDARY_MEMORY_NEEDED_RTX | |
666 | secondary_memlocs[(int) mode] = SECONDARY_MEMORY_NEEDED_RTX (mode); | |
667 | #else | |
668 | secondary_memlocs[(int) mode] | |
669 | = assign_stack_local (mode, GET_MODE_SIZE (mode), 0); | |
670 | #endif | |
671 | } | |
0dadecf6 RK |
672 | |
673 | /* Get a version of the address doing any eliminations needed. If that | |
674 | didn't give us a new MEM, make a new one if it isn't valid. */ | |
675 | ||
a8c9daeb | 676 | loc = eliminate_regs (secondary_memlocs[(int) mode], VOIDmode, NULL_RTX); |
0dadecf6 RK |
677 | mem_valid = strict_memory_address_p (mode, XEXP (loc, 0)); |
678 | ||
679 | if (! mem_valid && loc == secondary_memlocs[(int) mode]) | |
680 | loc = copy_rtx (loc); | |
681 | ||
682 | /* The only time the call below will do anything is if the stack | |
683 | offset is too large. In that case IND_LEVELS doesn't matter, so we | |
a8c9daeb RK |
684 | can just pass a zero. Adjust the type to be the address of the |
685 | corresponding object. If the address was valid, save the eliminated | |
686 | address. If it wasn't valid, we need to make a reload each time, so | |
687 | don't save it. */ | |
0dadecf6 | 688 | |
a8c9daeb RK |
689 | if (! mem_valid) |
690 | { | |
691 | type = (type == RELOAD_FOR_INPUT ? RELOAD_FOR_INPUT_ADDRESS | |
692 | : type == RELOAD_FOR_OUTPUT ? RELOAD_FOR_OUTPUT_ADDRESS | |
693 | : RELOAD_OTHER); | |
8d618585 | 694 | |
a8c9daeb RK |
695 | find_reloads_address (mode, NULL_PTR, XEXP (loc, 0), &XEXP (loc, 0), |
696 | opnum, type, 0); | |
697 | } | |
0dadecf6 | 698 | |
77545d45 | 699 | secondary_memlocs_elim[(int) mode][opnum] = loc; |
0dadecf6 RK |
700 | return loc; |
701 | } | |
702 | ||
703 | /* Clear any secondary memory locations we've made. */ | |
704 | ||
705 | void | |
706 | clear_secondary_mem () | |
707 | { | |
4c9a05bc | 708 | bzero ((char *) secondary_memlocs, sizeof secondary_memlocs); |
0dadecf6 RK |
709 | } |
710 | #endif /* SECONDARY_MEMORY_NEEDED */ | |
711 | \f | |
c6716840 RK |
712 | /* Find the largest class for which every register number plus N is valid in |
713 | M1 (if in range). Abort if no such class exists. */ | |
714 | ||
715 | static enum reg_class | |
716 | find_valid_class (m1, n) | |
717 | enum machine_mode m1; | |
718 | int n; | |
719 | { | |
720 | int class; | |
721 | int regno; | |
722 | enum reg_class best_class; | |
723 | int best_size = 0; | |
724 | ||
725 | for (class = 1; class < N_REG_CLASSES; class++) | |
726 | { | |
727 | int bad = 0; | |
728 | for (regno = 0; regno < FIRST_PSEUDO_REGISTER && ! bad; regno++) | |
729 | if (TEST_HARD_REG_BIT (reg_class_contents[class], regno) | |
730 | && TEST_HARD_REG_BIT (reg_class_contents[class], regno + n) | |
731 | && ! HARD_REGNO_MODE_OK (regno + n, m1)) | |
732 | bad = 1; | |
733 | ||
734 | if (! bad && reg_class_size[class] > best_size) | |
735 | best_class = class, best_size = reg_class_size[class]; | |
736 | } | |
737 | ||
738 | if (best_size == 0) | |
739 | abort (); | |
740 | ||
741 | return best_class; | |
742 | } | |
743 | \f | |
a8c9daeb | 744 | /* Record one reload that needs to be performed. |
eab89b90 RK |
745 | IN is an rtx saying where the data are to be found before this instruction. |
746 | OUT says where they must be stored after the instruction. | |
747 | (IN is zero for data not read, and OUT is zero for data not written.) | |
748 | INLOC and OUTLOC point to the places in the instructions where | |
749 | IN and OUT were found. | |
a8c9daeb RK |
750 | If IN and OUT are both non-zero, it means the same register must be used |
751 | to reload both IN and OUT. | |
752 | ||
eab89b90 RK |
753 | CLASS is a register class required for the reloaded data. |
754 | INMODE is the machine mode that the instruction requires | |
755 | for the reg that replaces IN and OUTMODE is likewise for OUT. | |
756 | ||
757 | If IN is zero, then OUT's location and mode should be passed as | |
758 | INLOC and INMODE. | |
759 | ||
760 | STRICT_LOW is the 1 if there is a containing STRICT_LOW_PART rtx. | |
761 | ||
762 | OPTIONAL nonzero means this reload does not need to be performed: | |
763 | it can be discarded if that is more convenient. | |
764 | ||
a8c9daeb RK |
765 | OPNUM and TYPE say what the purpose of this reload is. |
766 | ||
eab89b90 RK |
767 | The return value is the reload-number for this reload. |
768 | ||
769 | If both IN and OUT are nonzero, in some rare cases we might | |
770 | want to make two separate reloads. (Actually we never do this now.) | |
771 | Therefore, the reload-number for OUT is stored in | |
772 | output_reloadnum when we return; the return value applies to IN. | |
773 | Usually (presently always), when IN and OUT are nonzero, | |
774 | the two reload-numbers are equal, but the caller should be careful to | |
775 | distinguish them. */ | |
776 | ||
777 | static int | |
778 | push_reload (in, out, inloc, outloc, class, | |
a8c9daeb | 779 | inmode, outmode, strict_low, optional, opnum, type) |
eab89b90 RK |
780 | register rtx in, out; |
781 | rtx *inloc, *outloc; | |
782 | enum reg_class class; | |
783 | enum machine_mode inmode, outmode; | |
784 | int strict_low; | |
785 | int optional; | |
a8c9daeb RK |
786 | int opnum; |
787 | enum reload_type type; | |
eab89b90 RK |
788 | { |
789 | register int i; | |
790 | int dont_share = 0; | |
74347d76 | 791 | int dont_remove_subreg = 0; |
eab89b90 | 792 | rtx *in_subreg_loc = 0, *out_subreg_loc = 0; |
9ec7078b | 793 | int secondary_in_reload = -1, secondary_out_reload = -1; |
a229128d RK |
794 | enum insn_code secondary_in_icode = CODE_FOR_nothing; |
795 | enum insn_code secondary_out_icode = CODE_FOR_nothing; | |
a8c9daeb | 796 | |
eab89b90 RK |
797 | /* INMODE and/or OUTMODE could be VOIDmode if no mode |
798 | has been specified for the operand. In that case, | |
799 | use the operand's mode as the mode to reload. */ | |
800 | if (inmode == VOIDmode && in != 0) | |
801 | inmode = GET_MODE (in); | |
802 | if (outmode == VOIDmode && out != 0) | |
803 | outmode = GET_MODE (out); | |
804 | ||
805 | /* If IN is a pseudo register everywhere-equivalent to a constant, and | |
806 | it is not in a hard register, reload straight from the constant, | |
807 | since we want to get rid of such pseudo registers. | |
808 | Often this is done earlier, but not always in find_reloads_address. */ | |
809 | if (in != 0 && GET_CODE (in) == REG) | |
810 | { | |
811 | register int regno = REGNO (in); | |
812 | ||
813 | if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] < 0 | |
814 | && reg_equiv_constant[regno] != 0) | |
815 | in = reg_equiv_constant[regno]; | |
816 | } | |
817 | ||
818 | /* Likewise for OUT. Of course, OUT will never be equivalent to | |
819 | an actual constant, but it might be equivalent to a memory location | |
820 | (in the case of a parameter). */ | |
821 | if (out != 0 && GET_CODE (out) == REG) | |
822 | { | |
823 | register int regno = REGNO (out); | |
824 | ||
825 | if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] < 0 | |
826 | && reg_equiv_constant[regno] != 0) | |
827 | out = reg_equiv_constant[regno]; | |
828 | } | |
829 | ||
830 | /* If we have a read-write operand with an address side-effect, | |
831 | change either IN or OUT so the side-effect happens only once. */ | |
832 | if (in != 0 && out != 0 && GET_CODE (in) == MEM && rtx_equal_p (in, out)) | |
833 | { | |
834 | if (GET_CODE (XEXP (in, 0)) == POST_INC | |
835 | || GET_CODE (XEXP (in, 0)) == POST_DEC) | |
836 | in = gen_rtx (MEM, GET_MODE (in), XEXP (XEXP (in, 0), 0)); | |
837 | if (GET_CODE (XEXP (in, 0)) == PRE_INC | |
838 | || GET_CODE (XEXP (in, 0)) == PRE_DEC) | |
839 | out = gen_rtx (MEM, GET_MODE (out), XEXP (XEXP (out, 0), 0)); | |
840 | } | |
841 | ||
a61c98cf | 842 | /* If we are reloading a (SUBREG constant ...), really reload just the |
ca769828 | 843 | inside expression in its own mode. Similarly for (SUBREG (PLUS ...)). |
a61c98cf RK |
844 | If we have (SUBREG:M1 (MEM:M2 ...) ...) (or an inner REG that is still |
845 | a pseudo and hence will become a MEM) with M1 wider than M2 and the | |
846 | register is a pseudo, also reload the inside expression. | |
f72ccbe6 | 847 | For machines that extend byte loads, do this for any SUBREG of a pseudo |
486d8509 RK |
848 | where both M1 and M2 are a word or smaller, M1 is wider than M2, and |
849 | M2 is an integral mode that gets extended when loaded. | |
86c31b2d | 850 | Similar issue for (SUBREG:M1 (REG:M2 ...) ...) for a hard register R where |
eab89b90 RK |
851 | either M1 is not valid for R or M2 is wider than a word but we only |
852 | need one word to store an M2-sized quantity in R. | |
86c31b2d RS |
853 | (However, if OUT is nonzero, we need to reload the reg *and* |
854 | the subreg, so do nothing here, and let following statement handle it.) | |
855 | ||
eab89b90 RK |
856 | Note that the case of (SUBREG (CONST_INT...)...) is handled elsewhere; |
857 | we can't handle it here because CONST_INT does not indicate a mode. | |
858 | ||
859 | Similarly, we must reload the inside expression if we have a | |
df62f951 RK |
860 | STRICT_LOW_PART (presumably, in == out in the cas). |
861 | ||
862 | Also reload the inner expression if it does not require a secondary | |
486d8509 RK |
863 | reload but the SUBREG does. |
864 | ||
865 | Finally, reload the inner expression if it is a register that is in | |
866 | the class whose registers cannot be referenced in a different size | |
d030f4b2 RK |
867 | and M1 is not the same size as M2. If SUBREG_WORD is nonzero, we |
868 | cannot reload just the inside since we might end up with the wrong | |
0f41302f | 869 | register class. */ |
eab89b90 | 870 | |
d030f4b2 | 871 | if (in != 0 && GET_CODE (in) == SUBREG && SUBREG_WORD (in) == 0 |
94bafba7 RK |
872 | #ifdef CLASS_CANNOT_CHANGE_SIZE |
873 | && class != CLASS_CANNOT_CHANGE_SIZE | |
874 | #endif | |
a61c98cf | 875 | && (CONSTANT_P (SUBREG_REG (in)) |
ca769828 | 876 | || GET_CODE (SUBREG_REG (in)) == PLUS |
eab89b90 | 877 | || strict_low |
a61c98cf RK |
878 | || (((GET_CODE (SUBREG_REG (in)) == REG |
879 | && REGNO (SUBREG_REG (in)) >= FIRST_PSEUDO_REGISTER) | |
880 | || GET_CODE (SUBREG_REG (in)) == MEM) | |
03b72c86 RK |
881 | && ((GET_MODE_SIZE (inmode) |
882 | > GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))) | |
09bf0250 | 883 | #ifdef LOAD_EXTEND_OP |
03b72c86 RK |
884 | || (GET_MODE_SIZE (inmode) <= UNITS_PER_WORD |
885 | && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (in))) | |
886 | <= UNITS_PER_WORD) | |
887 | && (GET_MODE_SIZE (inmode) | |
486d8509 RK |
888 | > GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))) |
889 | && INTEGRAL_MODE_P (GET_MODE (SUBREG_REG (in))) | |
890 | && LOAD_EXTEND_OP (GET_MODE (SUBREG_REG (in))) != NIL) | |
f72ccbe6 | 891 | #endif |
03b72c86 | 892 | )) |
a61c98cf RK |
893 | || (GET_CODE (SUBREG_REG (in)) == REG |
894 | && REGNO (SUBREG_REG (in)) < FIRST_PSEUDO_REGISTER | |
86c31b2d RS |
895 | /* The case where out is nonzero |
896 | is handled differently in the following statement. */ | |
897 | && (out == 0 || SUBREG_WORD (in) == 0) | |
f72ccbe6 RK |
898 | && ((GET_MODE_SIZE (inmode) <= UNITS_PER_WORD |
899 | && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (in))) | |
900 | > UNITS_PER_WORD) | |
901 | && ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (in))) | |
902 | / UNITS_PER_WORD) | |
903 | != HARD_REGNO_NREGS (REGNO (SUBREG_REG (in)), | |
904 | GET_MODE (SUBREG_REG (in))))) | |
905 | || ! HARD_REGNO_MODE_OK ((REGNO (SUBREG_REG (in)) | |
906 | + SUBREG_WORD (in)), | |
907 | inmode))) | |
df62f951 RK |
908 | #ifdef SECONDARY_INPUT_RELOAD_CLASS |
909 | || (SECONDARY_INPUT_RELOAD_CLASS (class, inmode, in) != NO_REGS | |
910 | && (SECONDARY_INPUT_RELOAD_CLASS (class, | |
911 | GET_MODE (SUBREG_REG (in)), | |
912 | SUBREG_REG (in)) | |
913 | == NO_REGS)) | |
486d8509 RK |
914 | #endif |
915 | #ifdef CLASS_CANNOT_CHANGE_SIZE | |
916 | || (GET_CODE (SUBREG_REG (in)) == REG | |
917 | && REGNO (SUBREG_REG (in)) < FIRST_PSEUDO_REGISTER | |
918 | && (TEST_HARD_REG_BIT | |
919 | (reg_class_contents[(int) CLASS_CANNOT_CHANGE_SIZE], | |
920 | REGNO (SUBREG_REG (in)))) | |
921 | && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (in))) | |
922 | != GET_MODE_SIZE (inmode))) | |
df62f951 RK |
923 | #endif |
924 | )) | |
eab89b90 RK |
925 | { |
926 | in_subreg_loc = inloc; | |
927 | inloc = &SUBREG_REG (in); | |
928 | in = *inloc; | |
09bf0250 | 929 | #ifndef LOAD_EXTEND_OP |
eab89b90 RK |
930 | if (GET_CODE (in) == MEM) |
931 | /* This is supposed to happen only for paradoxical subregs made by | |
932 | combine.c. (SUBREG (MEM)) isn't supposed to occur other ways. */ | |
933 | if (GET_MODE_SIZE (GET_MODE (in)) > GET_MODE_SIZE (inmode)) | |
934 | abort (); | |
e05a9da8 | 935 | #endif |
eab89b90 RK |
936 | inmode = GET_MODE (in); |
937 | } | |
938 | ||
86c31b2d RS |
939 | /* Similar issue for (SUBREG:M1 (REG:M2 ...) ...) for a hard register R where |
940 | either M1 is not valid for R or M2 is wider than a word but we only | |
941 | need one word to store an M2-sized quantity in R. | |
942 | ||
943 | However, we must reload the inner reg *as well as* the subreg in | |
944 | that case. */ | |
945 | ||
6fd5ac08 JW |
946 | /* Similar issue for (SUBREG constant ...) if it was not handled by the |
947 | code above. This can happen if SUBREG_WORD != 0. */ | |
948 | ||
86c31b2d | 949 | if (in != 0 && GET_CODE (in) == SUBREG |
6fd5ac08 JW |
950 | && (CONSTANT_P (SUBREG_REG (in)) |
951 | || (GET_CODE (SUBREG_REG (in)) == REG | |
952 | && REGNO (SUBREG_REG (in)) < FIRST_PSEUDO_REGISTER | |
953 | && (! HARD_REGNO_MODE_OK (REGNO (SUBREG_REG (in)) | |
954 | + SUBREG_WORD (in), | |
955 | inmode) | |
956 | || (GET_MODE_SIZE (inmode) <= UNITS_PER_WORD | |
957 | && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (in))) | |
958 | > UNITS_PER_WORD) | |
959 | && ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (in))) | |
960 | / UNITS_PER_WORD) | |
961 | != HARD_REGNO_NREGS (REGNO (SUBREG_REG (in)), | |
962 | GET_MODE (SUBREG_REG (in))))))))) | |
86c31b2d | 963 | { |
c96d01ab RK |
964 | /* This relies on the fact that emit_reload_insns outputs the |
965 | instructions for input reloads of type RELOAD_OTHER in the same | |
966 | order as the reloads. Thus if the outer reload is also of type | |
967 | RELOAD_OTHER, we are guaranteed that this inner reload will be | |
968 | output before the outer reload. */ | |
86c31b2d | 969 | push_reload (SUBREG_REG (in), NULL_RTX, &SUBREG_REG (in), NULL_PTR, |
c6716840 RK |
970 | find_valid_class (inmode, SUBREG_WORD (in)), |
971 | VOIDmode, VOIDmode, 0, 0, opnum, type); | |
74347d76 | 972 | dont_remove_subreg = 1; |
86c31b2d RS |
973 | } |
974 | ||
eab89b90 RK |
975 | /* Similarly for paradoxical and problematical SUBREGs on the output. |
976 | Note that there is no reason we need worry about the previous value | |
977 | of SUBREG_REG (out); even if wider than out, | |
978 | storing in a subreg is entitled to clobber it all | |
979 | (except in the case of STRICT_LOW_PART, | |
980 | and in that case the constraint should label it input-output.) */ | |
d030f4b2 | 981 | if (out != 0 && GET_CODE (out) == SUBREG && SUBREG_WORD (out) == 0 |
94bafba7 RK |
982 | #ifdef CLASS_CANNOT_CHANGE_SIZE |
983 | && class != CLASS_CANNOT_CHANGE_SIZE | |
984 | #endif | |
a61c98cf | 985 | && (CONSTANT_P (SUBREG_REG (out)) |
eab89b90 | 986 | || strict_low |
a61c98cf RK |
987 | || (((GET_CODE (SUBREG_REG (out)) == REG |
988 | && REGNO (SUBREG_REG (out)) >= FIRST_PSEUDO_REGISTER) | |
989 | || GET_CODE (SUBREG_REG (out)) == MEM) | |
03b72c86 | 990 | && ((GET_MODE_SIZE (outmode) |
486d8509 | 991 | > GET_MODE_SIZE (GET_MODE (SUBREG_REG (out)))))) |
eab89b90 RK |
992 | || (GET_CODE (SUBREG_REG (out)) == REG |
993 | && REGNO (SUBREG_REG (out)) < FIRST_PSEUDO_REGISTER | |
f72ccbe6 RK |
994 | && ((GET_MODE_SIZE (outmode) <= UNITS_PER_WORD |
995 | && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (out))) | |
996 | > UNITS_PER_WORD) | |
997 | && ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (out))) | |
998 | / UNITS_PER_WORD) | |
999 | != HARD_REGNO_NREGS (REGNO (SUBREG_REG (out)), | |
1000 | GET_MODE (SUBREG_REG (out))))) | |
1001 | || ! HARD_REGNO_MODE_OK ((REGNO (SUBREG_REG (out)) | |
1002 | + SUBREG_WORD (out)), | |
1003 | outmode))) | |
df62f951 RK |
1004 | #ifdef SECONDARY_OUTPUT_RELOAD_CLASS |
1005 | || (SECONDARY_OUTPUT_RELOAD_CLASS (class, outmode, out) != NO_REGS | |
1006 | && (SECONDARY_OUTPUT_RELOAD_CLASS (class, | |
1007 | GET_MODE (SUBREG_REG (out)), | |
1008 | SUBREG_REG (out)) | |
1009 | == NO_REGS)) | |
486d8509 RK |
1010 | #endif |
1011 | #ifdef CLASS_CANNOT_CHANGE_SIZE | |
1012 | || (GET_CODE (SUBREG_REG (out)) == REG | |
1013 | && REGNO (SUBREG_REG (out)) < FIRST_PSEUDO_REGISTER | |
1014 | && (TEST_HARD_REG_BIT | |
1015 | (reg_class_contents[(int) CLASS_CANNOT_CHANGE_SIZE], | |
1016 | REGNO (SUBREG_REG (out)))) | |
1017 | && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (out))) | |
1018 | != GET_MODE_SIZE (outmode))) | |
df62f951 RK |
1019 | #endif |
1020 | )) | |
eab89b90 RK |
1021 | { |
1022 | out_subreg_loc = outloc; | |
1023 | outloc = &SUBREG_REG (out); | |
e05a9da8 | 1024 | out = *outloc; |
09bf0250 | 1025 | #ifndef LOAD_EXTEND_OP |
e05a9da8 | 1026 | if (GET_CODE (out) == MEM |
eab89b90 RK |
1027 | && GET_MODE_SIZE (GET_MODE (out)) > GET_MODE_SIZE (outmode)) |
1028 | abort (); | |
e05a9da8 | 1029 | #endif |
eab89b90 RK |
1030 | outmode = GET_MODE (out); |
1031 | } | |
1032 | ||
74347d76 RK |
1033 | /* Similar issue for (SUBREG:M1 (REG:M2 ...) ...) for a hard register R where |
1034 | either M1 is not valid for R or M2 is wider than a word but we only | |
1035 | need one word to store an M2-sized quantity in R. | |
1036 | ||
1037 | However, we must reload the inner reg *as well as* the subreg in | |
1038 | that case. In this case, the inner reg is an in-out reload. */ | |
1039 | ||
1040 | if (out != 0 && GET_CODE (out) == SUBREG | |
1041 | && GET_CODE (SUBREG_REG (out)) == REG | |
1042 | && REGNO (SUBREG_REG (out)) < FIRST_PSEUDO_REGISTER | |
c6716840 RK |
1043 | && (! HARD_REGNO_MODE_OK (REGNO (SUBREG_REG (out)) + SUBREG_WORD (out), |
1044 | outmode) | |
74347d76 RK |
1045 | || (GET_MODE_SIZE (outmode) <= UNITS_PER_WORD |
1046 | && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (out))) | |
1047 | > UNITS_PER_WORD) | |
1048 | && ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (out))) | |
1049 | / UNITS_PER_WORD) | |
1050 | != HARD_REGNO_NREGS (REGNO (SUBREG_REG (out)), | |
1051 | GET_MODE (SUBREG_REG (out))))))) | |
1052 | { | |
c96d01ab RK |
1053 | /* This relies on the fact that emit_reload_insns outputs the |
1054 | instructions for output reloads of type RELOAD_OTHER in reverse | |
1055 | order of the reloads. Thus if the outer reload is also of type | |
1056 | RELOAD_OTHER, we are guaranteed that this inner reload will be | |
1057 | output after the outer reload. */ | |
74347d76 RK |
1058 | dont_remove_subreg = 1; |
1059 | push_reload (SUBREG_REG (out), SUBREG_REG (out), &SUBREG_REG (out), | |
c6716840 RK |
1060 | &SUBREG_REG (out), |
1061 | find_valid_class (outmode, SUBREG_WORD (out)), | |
1062 | VOIDmode, VOIDmode, 0, 0, | |
74347d76 RK |
1063 | opnum, RELOAD_OTHER); |
1064 | } | |
1065 | ||
eab89b90 RK |
1066 | /* If IN appears in OUT, we can't share any input-only reload for IN. */ |
1067 | if (in != 0 && out != 0 && GET_CODE (out) == MEM | |
1068 | && (GET_CODE (in) == REG || GET_CODE (in) == MEM) | |
bfa30b22 | 1069 | && reg_overlap_mentioned_for_reload_p (in, XEXP (out, 0))) |
eab89b90 RK |
1070 | dont_share = 1; |
1071 | ||
0dadecf6 RK |
1072 | /* If IN is a SUBREG of a hard register, make a new REG. This |
1073 | simplifies some of the cases below. */ | |
1074 | ||
1075 | if (in != 0 && GET_CODE (in) == SUBREG && GET_CODE (SUBREG_REG (in)) == REG | |
74347d76 RK |
1076 | && REGNO (SUBREG_REG (in)) < FIRST_PSEUDO_REGISTER |
1077 | && ! dont_remove_subreg) | |
0dadecf6 RK |
1078 | in = gen_rtx (REG, GET_MODE (in), |
1079 | REGNO (SUBREG_REG (in)) + SUBREG_WORD (in)); | |
1080 | ||
1081 | /* Similarly for OUT. */ | |
1082 | if (out != 0 && GET_CODE (out) == SUBREG | |
1083 | && GET_CODE (SUBREG_REG (out)) == REG | |
74347d76 RK |
1084 | && REGNO (SUBREG_REG (out)) < FIRST_PSEUDO_REGISTER |
1085 | && ! dont_remove_subreg) | |
0dadecf6 RK |
1086 | out = gen_rtx (REG, GET_MODE (out), |
1087 | REGNO (SUBREG_REG (out)) + SUBREG_WORD (out)); | |
1088 | ||
eab89b90 RK |
1089 | /* Narrow down the class of register wanted if that is |
1090 | desirable on this machine for efficiency. */ | |
1091 | if (in != 0) | |
1092 | class = PREFERRED_RELOAD_CLASS (in, class); | |
1093 | ||
ac2a9454 | 1094 | /* Output reloads may need analogous treatment, different in detail. */ |
18a53b78 RS |
1095 | #ifdef PREFERRED_OUTPUT_RELOAD_CLASS |
1096 | if (out != 0) | |
1097 | class = PREFERRED_OUTPUT_RELOAD_CLASS (out, class); | |
1098 | #endif | |
1099 | ||
eab89b90 RK |
1100 | /* Make sure we use a class that can handle the actual pseudo |
1101 | inside any subreg. For example, on the 386, QImode regs | |
1102 | can appear within SImode subregs. Although GENERAL_REGS | |
1103 | can handle SImode, QImode needs a smaller class. */ | |
1104 | #ifdef LIMIT_RELOAD_CLASS | |
1105 | if (in_subreg_loc) | |
1106 | class = LIMIT_RELOAD_CLASS (inmode, class); | |
1107 | else if (in != 0 && GET_CODE (in) == SUBREG) | |
1108 | class = LIMIT_RELOAD_CLASS (GET_MODE (SUBREG_REG (in)), class); | |
1109 | ||
1110 | if (out_subreg_loc) | |
1111 | class = LIMIT_RELOAD_CLASS (outmode, class); | |
1112 | if (out != 0 && GET_CODE (out) == SUBREG) | |
1113 | class = LIMIT_RELOAD_CLASS (GET_MODE (SUBREG_REG (out)), class); | |
1114 | #endif | |
1115 | ||
eab89b90 RK |
1116 | /* Verify that this class is at least possible for the mode that |
1117 | is specified. */ | |
1118 | if (this_insn_is_asm) | |
1119 | { | |
1120 | enum machine_mode mode; | |
1121 | if (GET_MODE_SIZE (inmode) > GET_MODE_SIZE (outmode)) | |
1122 | mode = inmode; | |
1123 | else | |
1124 | mode = outmode; | |
5488078f RS |
1125 | if (mode == VOIDmode) |
1126 | { | |
1127 | error_for_asm (this_insn, "cannot reload integer constant operand in `asm'"); | |
1128 | mode = word_mode; | |
1129 | if (in != 0) | |
1130 | inmode = word_mode; | |
1131 | if (out != 0) | |
1132 | outmode = word_mode; | |
1133 | } | |
eab89b90 RK |
1134 | for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) |
1135 | if (HARD_REGNO_MODE_OK (i, mode) | |
1136 | && TEST_HARD_REG_BIT (reg_class_contents[(int) class], i)) | |
1137 | { | |
1138 | int nregs = HARD_REGNO_NREGS (i, mode); | |
1139 | ||
1140 | int j; | |
1141 | for (j = 1; j < nregs; j++) | |
1142 | if (! TEST_HARD_REG_BIT (reg_class_contents[(int) class], i + j)) | |
1143 | break; | |
1144 | if (j == nregs) | |
1145 | break; | |
1146 | } | |
1147 | if (i == FIRST_PSEUDO_REGISTER) | |
1148 | { | |
1149 | error_for_asm (this_insn, "impossible register constraint in `asm'"); | |
1150 | class = ALL_REGS; | |
1151 | } | |
1152 | } | |
1153 | ||
5488078f RS |
1154 | if (class == NO_REGS) |
1155 | abort (); | |
1156 | ||
eab89b90 RK |
1157 | /* We can use an existing reload if the class is right |
1158 | and at least one of IN and OUT is a match | |
1159 | and the other is at worst neutral. | |
a8c9daeb RK |
1160 | (A zero compared against anything is neutral.) |
1161 | ||
1162 | If SMALL_REGISTER_CLASSES, don't use existing reloads unless they are | |
1163 | for the same thing since that can cause us to need more reload registers | |
1164 | than we otherwise would. */ | |
1165 | ||
eab89b90 RK |
1166 | for (i = 0; i < n_reloads; i++) |
1167 | if ((reg_class_subset_p (class, reload_reg_class[i]) | |
1168 | || reg_class_subset_p (reload_reg_class[i], class)) | |
eab89b90 RK |
1169 | /* If the existing reload has a register, it must fit our class. */ |
1170 | && (reload_reg_rtx[i] == 0 | |
1171 | || TEST_HARD_REG_BIT (reg_class_contents[(int) class], | |
1172 | true_regnum (reload_reg_rtx[i]))) | |
1173 | && ((in != 0 && MATCHES (reload_in[i], in) && ! dont_share | |
1174 | && (out == 0 || reload_out[i] == 0 || MATCHES (reload_out[i], out))) | |
1175 | || | |
1176 | (out != 0 && MATCHES (reload_out[i], out) | |
a8c9daeb RK |
1177 | && (in == 0 || reload_in[i] == 0 || MATCHES (reload_in[i], in)))) |
1178 | && (reg_class_size[(int) class] == 1 | |
1179 | #ifdef SMALL_REGISTER_CLASSES | |
f95182a4 | 1180 | || SMALL_REGISTER_CLASSES |
a8c9daeb RK |
1181 | #endif |
1182 | ) | |
1183 | && MERGABLE_RELOADS (type, reload_when_needed[i], | |
1184 | opnum, reload_opnum[i])) | |
eab89b90 RK |
1185 | break; |
1186 | ||
1187 | /* Reloading a plain reg for input can match a reload to postincrement | |
1188 | that reg, since the postincrement's value is the right value. | |
1189 | Likewise, it can match a preincrement reload, since we regard | |
1190 | the preincrementation as happening before any ref in this insn | |
1191 | to that register. */ | |
1192 | if (i == n_reloads) | |
1193 | for (i = 0; i < n_reloads; i++) | |
1194 | if ((reg_class_subset_p (class, reload_reg_class[i]) | |
1195 | || reg_class_subset_p (reload_reg_class[i], class)) | |
1196 | /* If the existing reload has a register, it must fit our class. */ | |
1197 | && (reload_reg_rtx[i] == 0 | |
1198 | || TEST_HARD_REG_BIT (reg_class_contents[(int) class], | |
1199 | true_regnum (reload_reg_rtx[i]))) | |
eab89b90 RK |
1200 | && out == 0 && reload_out[i] == 0 && reload_in[i] != 0 |
1201 | && ((GET_CODE (in) == REG | |
1202 | && (GET_CODE (reload_in[i]) == POST_INC | |
1203 | || GET_CODE (reload_in[i]) == POST_DEC | |
1204 | || GET_CODE (reload_in[i]) == PRE_INC | |
1205 | || GET_CODE (reload_in[i]) == PRE_DEC) | |
1206 | && MATCHES (XEXP (reload_in[i], 0), in)) | |
1207 | || | |
1208 | (GET_CODE (reload_in[i]) == REG | |
1209 | && (GET_CODE (in) == POST_INC | |
1210 | || GET_CODE (in) == POST_DEC | |
1211 | || GET_CODE (in) == PRE_INC | |
1212 | || GET_CODE (in) == PRE_DEC) | |
a8c9daeb RK |
1213 | && MATCHES (XEXP (in, 0), reload_in[i]))) |
1214 | && (reg_class_size[(int) class] == 1 | |
1215 | #ifdef SMALL_REGISTER_CLASSES | |
f95182a4 | 1216 | || SMALL_REGISTER_CLASSES |
a8c9daeb RK |
1217 | #endif |
1218 | ) | |
1219 | && MERGABLE_RELOADS (type, reload_when_needed[i], | |
1220 | opnum, reload_opnum[i])) | |
eab89b90 RK |
1221 | { |
1222 | /* Make sure reload_in ultimately has the increment, | |
1223 | not the plain register. */ | |
1224 | if (GET_CODE (in) == REG) | |
1225 | in = reload_in[i]; | |
1226 | break; | |
1227 | } | |
1228 | ||
1229 | if (i == n_reloads) | |
1230 | { | |
9ec7078b RK |
1231 | /* See if we need a secondary reload register to move between CLASS |
1232 | and IN or CLASS and OUT. Get the icode and push any required reloads | |
1233 | needed for each of them if so. */ | |
eab89b90 RK |
1234 | |
1235 | #ifdef SECONDARY_INPUT_RELOAD_CLASS | |
1236 | if (in != 0) | |
9ec7078b RK |
1237 | secondary_in_reload |
1238 | = push_secondary_reload (1, in, opnum, optional, class, inmode, type, | |
1239 | &secondary_in_icode); | |
eab89b90 RK |
1240 | #endif |
1241 | ||
1242 | #ifdef SECONDARY_OUTPUT_RELOAD_CLASS | |
1243 | if (out != 0 && GET_CODE (out) != SCRATCH) | |
9ec7078b RK |
1244 | secondary_out_reload |
1245 | = push_secondary_reload (0, out, opnum, optional, class, outmode, | |
1246 | type, &secondary_out_icode); | |
eab89b90 RK |
1247 | #endif |
1248 | ||
1249 | /* We found no existing reload suitable for re-use. | |
1250 | So add an additional reload. */ | |
1251 | ||
9ec7078b | 1252 | i = n_reloads; |
eab89b90 RK |
1253 | reload_in[i] = in; |
1254 | reload_out[i] = out; | |
1255 | reload_reg_class[i] = class; | |
1256 | reload_inmode[i] = inmode; | |
1257 | reload_outmode[i] = outmode; | |
1258 | reload_reg_rtx[i] = 0; | |
1259 | reload_optional[i] = optional; | |
1260 | reload_inc[i] = 0; | |
eab89b90 RK |
1261 | reload_nocombine[i] = 0; |
1262 | reload_in_reg[i] = inloc ? *inloc : 0; | |
a8c9daeb RK |
1263 | reload_opnum[i] = opnum; |
1264 | reload_when_needed[i] = type; | |
9ec7078b RK |
1265 | reload_secondary_in_reload[i] = secondary_in_reload; |
1266 | reload_secondary_out_reload[i] = secondary_out_reload; | |
1267 | reload_secondary_in_icode[i] = secondary_in_icode; | |
1268 | reload_secondary_out_icode[i] = secondary_out_icode; | |
eab89b90 RK |
1269 | reload_secondary_p[i] = 0; |
1270 | ||
1271 | n_reloads++; | |
0dadecf6 RK |
1272 | |
1273 | #ifdef SECONDARY_MEMORY_NEEDED | |
1274 | /* If a memory location is needed for the copy, make one. */ | |
1275 | if (in != 0 && GET_CODE (in) == REG | |
1276 | && REGNO (in) < FIRST_PSEUDO_REGISTER | |
1277 | && SECONDARY_MEMORY_NEEDED (REGNO_REG_CLASS (REGNO (in)), | |
1278 | class, inmode)) | |
a8c9daeb | 1279 | get_secondary_mem (in, inmode, opnum, type); |
0dadecf6 RK |
1280 | |
1281 | if (out != 0 && GET_CODE (out) == REG | |
1282 | && REGNO (out) < FIRST_PSEUDO_REGISTER | |
1283 | && SECONDARY_MEMORY_NEEDED (class, REGNO_REG_CLASS (REGNO (out)), | |
1284 | outmode)) | |
a8c9daeb | 1285 | get_secondary_mem (out, outmode, opnum, type); |
0dadecf6 | 1286 | #endif |
eab89b90 RK |
1287 | } |
1288 | else | |
1289 | { | |
1290 | /* We are reusing an existing reload, | |
1291 | but we may have additional information for it. | |
1292 | For example, we may now have both IN and OUT | |
1293 | while the old one may have just one of them. */ | |
1294 | ||
6fd5ac08 JW |
1295 | /* The modes can be different. If they are, we want to reload in |
1296 | the larger mode, so that the value is valid for both modes. */ | |
1297 | if (inmode != VOIDmode | |
1298 | && GET_MODE_SIZE (inmode) > GET_MODE_SIZE (reload_inmode[i])) | |
eab89b90 | 1299 | reload_inmode[i] = inmode; |
6fd5ac08 JW |
1300 | if (outmode != VOIDmode |
1301 | && GET_MODE_SIZE (outmode) > GET_MODE_SIZE (reload_outmode[i])) | |
eab89b90 RK |
1302 | reload_outmode[i] = outmode; |
1303 | if (in != 0) | |
1304 | reload_in[i] = in; | |
1305 | if (out != 0) | |
1306 | reload_out[i] = out; | |
1307 | if (reg_class_subset_p (class, reload_reg_class[i])) | |
1308 | reload_reg_class[i] = class; | |
1309 | reload_optional[i] &= optional; | |
a8c9daeb RK |
1310 | if (MERGE_TO_OTHER (type, reload_when_needed[i], |
1311 | opnum, reload_opnum[i])) | |
1312 | reload_when_needed[i] = RELOAD_OTHER; | |
1313 | reload_opnum[i] = MIN (reload_opnum[i], opnum); | |
eab89b90 RK |
1314 | } |
1315 | ||
1316 | /* If the ostensible rtx being reload differs from the rtx found | |
1317 | in the location to substitute, this reload is not safe to combine | |
1318 | because we cannot reliably tell whether it appears in the insn. */ | |
1319 | ||
1320 | if (in != 0 && in != *inloc) | |
1321 | reload_nocombine[i] = 1; | |
1322 | ||
1323 | #if 0 | |
1324 | /* This was replaced by changes in find_reloads_address_1 and the new | |
1325 | function inc_for_reload, which go with a new meaning of reload_inc. */ | |
1326 | ||
1327 | /* If this is an IN/OUT reload in an insn that sets the CC, | |
1328 | it must be for an autoincrement. It doesn't work to store | |
1329 | the incremented value after the insn because that would clobber the CC. | |
1330 | So we must do the increment of the value reloaded from, | |
1331 | increment it, store it back, then decrement again. */ | |
1332 | if (out != 0 && sets_cc0_p (PATTERN (this_insn))) | |
1333 | { | |
1334 | out = 0; | |
1335 | reload_out[i] = 0; | |
1336 | reload_inc[i] = find_inc_amount (PATTERN (this_insn), in); | |
1337 | /* If we did not find a nonzero amount-to-increment-by, | |
1338 | that contradicts the belief that IN is being incremented | |
1339 | in an address in this insn. */ | |
1340 | if (reload_inc[i] == 0) | |
1341 | abort (); | |
1342 | } | |
1343 | #endif | |
1344 | ||
1345 | /* If we will replace IN and OUT with the reload-reg, | |
1346 | record where they are located so that substitution need | |
1347 | not do a tree walk. */ | |
1348 | ||
1349 | if (replace_reloads) | |
1350 | { | |
1351 | if (inloc != 0) | |
1352 | { | |
1353 | register struct replacement *r = &replacements[n_replacements++]; | |
1354 | r->what = i; | |
1355 | r->subreg_loc = in_subreg_loc; | |
1356 | r->where = inloc; | |
1357 | r->mode = inmode; | |
1358 | } | |
1359 | if (outloc != 0 && outloc != inloc) | |
1360 | { | |
1361 | register struct replacement *r = &replacements[n_replacements++]; | |
1362 | r->what = i; | |
1363 | r->where = outloc; | |
1364 | r->subreg_loc = out_subreg_loc; | |
1365 | r->mode = outmode; | |
1366 | } | |
1367 | } | |
1368 | ||
1369 | /* If this reload is just being introduced and it has both | |
1370 | an incoming quantity and an outgoing quantity that are | |
1371 | supposed to be made to match, see if either one of the two | |
1372 | can serve as the place to reload into. | |
1373 | ||
1374 | If one of them is acceptable, set reload_reg_rtx[i] | |
1375 | to that one. */ | |
1376 | ||
1377 | if (in != 0 && out != 0 && in != out && reload_reg_rtx[i] == 0) | |
1378 | { | |
1379 | reload_reg_rtx[i] = find_dummy_reload (in, out, inloc, outloc, | |
36b50568 | 1380 | inmode, outmode, |
eab89b90 RK |
1381 | reload_reg_class[i], i); |
1382 | ||
1383 | /* If the outgoing register already contains the same value | |
1384 | as the incoming one, we can dispense with loading it. | |
1385 | The easiest way to tell the caller that is to give a phony | |
1386 | value for the incoming operand (same as outgoing one). */ | |
1387 | if (reload_reg_rtx[i] == out | |
1388 | && (GET_CODE (in) == REG || CONSTANT_P (in)) | |
1389 | && 0 != find_equiv_reg (in, this_insn, 0, REGNO (out), | |
1390 | static_reload_reg_p, i, inmode)) | |
1391 | reload_in[i] = out; | |
1392 | } | |
1393 | ||
1394 | /* If this is an input reload and the operand contains a register that | |
1395 | dies in this insn and is used nowhere else, see if it is the right class | |
1396 | to be used for this reload. Use it if so. (This occurs most commonly | |
1397 | in the case of paradoxical SUBREGs and in-out reloads). We cannot do | |
1398 | this if it is also an output reload that mentions the register unless | |
1399 | the output is a SUBREG that clobbers an entire register. | |
1400 | ||
1401 | Note that the operand might be one of the spill regs, if it is a | |
1402 | pseudo reg and we are in a block where spilling has not taken place. | |
1403 | But if there is no spilling in this block, that is OK. | |
1404 | An explicitly used hard reg cannot be a spill reg. */ | |
1405 | ||
1406 | if (reload_reg_rtx[i] == 0 && in != 0) | |
1407 | { | |
1408 | rtx note; | |
1409 | int regno; | |
1410 | ||
1411 | for (note = REG_NOTES (this_insn); note; note = XEXP (note, 1)) | |
1412 | if (REG_NOTE_KIND (note) == REG_DEAD | |
1413 | && GET_CODE (XEXP (note, 0)) == REG | |
1414 | && (regno = REGNO (XEXP (note, 0))) < FIRST_PSEUDO_REGISTER | |
1415 | && reg_mentioned_p (XEXP (note, 0), in) | |
1416 | && ! refers_to_regno_for_reload_p (regno, | |
1417 | (regno | |
1418 | + HARD_REGNO_NREGS (regno, | |
1419 | inmode)), | |
1420 | PATTERN (this_insn), inloc) | |
05b4ec4f RS |
1421 | /* If this is also an output reload, IN cannot be used as |
1422 | the reload register if it is set in this insn unless IN | |
1423 | is also OUT. */ | |
1424 | && (out == 0 || in == out | |
1425 | || ! hard_reg_set_here_p (regno, | |
1426 | (regno | |
1427 | + HARD_REGNO_NREGS (regno, | |
1428 | inmode)), | |
1429 | PATTERN (this_insn))) | |
1430 | /* ??? Why is this code so different from the previous? | |
1431 | Is there any simple coherent way to describe the two together? | |
1432 | What's going on here. */ | |
eab89b90 RK |
1433 | && (in != out |
1434 | || (GET_CODE (in) == SUBREG | |
1435 | && (((GET_MODE_SIZE (GET_MODE (in)) + (UNITS_PER_WORD - 1)) | |
1436 | / UNITS_PER_WORD) | |
1437 | == ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (in))) | |
1438 | + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)))) | |
1439 | /* Make sure the operand fits in the reg that dies. */ | |
1440 | && GET_MODE_SIZE (inmode) <= GET_MODE_SIZE (GET_MODE (XEXP (note, 0))) | |
1441 | && HARD_REGNO_MODE_OK (regno, inmode) | |
1442 | && GET_MODE_SIZE (outmode) <= GET_MODE_SIZE (GET_MODE (XEXP (note, 0))) | |
1443 | && HARD_REGNO_MODE_OK (regno, outmode) | |
1444 | && TEST_HARD_REG_BIT (reg_class_contents[(int) class], regno) | |
1445 | && !fixed_regs[regno]) | |
1446 | { | |
1447 | reload_reg_rtx[i] = gen_rtx (REG, inmode, regno); | |
1448 | break; | |
1449 | } | |
1450 | } | |
1451 | ||
1452 | if (out) | |
1453 | output_reloadnum = i; | |
1454 | ||
1455 | return i; | |
1456 | } | |
1457 | ||
1458 | /* Record an additional place we must replace a value | |
1459 | for which we have already recorded a reload. | |
1460 | RELOADNUM is the value returned by push_reload | |
1461 | when the reload was recorded. | |
1462 | This is used in insn patterns that use match_dup. */ | |
1463 | ||
1464 | static void | |
1465 | push_replacement (loc, reloadnum, mode) | |
1466 | rtx *loc; | |
1467 | int reloadnum; | |
1468 | enum machine_mode mode; | |
1469 | { | |
1470 | if (replace_reloads) | |
1471 | { | |
1472 | register struct replacement *r = &replacements[n_replacements++]; | |
1473 | r->what = reloadnum; | |
1474 | r->where = loc; | |
1475 | r->subreg_loc = 0; | |
1476 | r->mode = mode; | |
1477 | } | |
1478 | } | |
1479 | \f | |
a8c9daeb RK |
1480 | /* Transfer all replacements that used to be in reload FROM to be in |
1481 | reload TO. */ | |
1482 | ||
1483 | void | |
1484 | transfer_replacements (to, from) | |
1485 | int to, from; | |
1486 | { | |
1487 | int i; | |
1488 | ||
1489 | for (i = 0; i < n_replacements; i++) | |
1490 | if (replacements[i].what == from) | |
1491 | replacements[i].what = to; | |
1492 | } | |
1493 | \f | |
eab89b90 RK |
1494 | /* If there is only one output reload, and it is not for an earlyclobber |
1495 | operand, try to combine it with a (logically unrelated) input reload | |
1496 | to reduce the number of reload registers needed. | |
1497 | ||
1498 | This is safe if the input reload does not appear in | |
1499 | the value being output-reloaded, because this implies | |
1500 | it is not needed any more once the original insn completes. | |
1501 | ||
1502 | If that doesn't work, see we can use any of the registers that | |
1503 | die in this insn as a reload register. We can if it is of the right | |
1504 | class and does not appear in the value being output-reloaded. */ | |
1505 | ||
1506 | static void | |
1507 | combine_reloads () | |
1508 | { | |
1509 | int i; | |
1510 | int output_reload = -1; | |
8922eb5b | 1511 | int secondary_out = -1; |
eab89b90 RK |
1512 | rtx note; |
1513 | ||
1514 | /* Find the output reload; return unless there is exactly one | |
1515 | and that one is mandatory. */ | |
1516 | ||
1517 | for (i = 0; i < n_reloads; i++) | |
1518 | if (reload_out[i] != 0) | |
1519 | { | |
1520 | if (output_reload >= 0) | |
1521 | return; | |
1522 | output_reload = i; | |
1523 | } | |
1524 | ||
1525 | if (output_reload < 0 || reload_optional[output_reload]) | |
1526 | return; | |
1527 | ||
1528 | /* An input-output reload isn't combinable. */ | |
1529 | ||
1530 | if (reload_in[output_reload] != 0) | |
1531 | return; | |
1532 | ||
6dc42e49 | 1533 | /* If this reload is for an earlyclobber operand, we can't do anything. */ |
4644aad4 RK |
1534 | if (earlyclobber_operand_p (reload_out[output_reload])) |
1535 | return; | |
eab89b90 RK |
1536 | |
1537 | /* Check each input reload; can we combine it? */ | |
1538 | ||
1539 | for (i = 0; i < n_reloads; i++) | |
1540 | if (reload_in[i] && ! reload_optional[i] && ! reload_nocombine[i] | |
1541 | /* Life span of this reload must not extend past main insn. */ | |
a8c9daeb | 1542 | && reload_when_needed[i] != RELOAD_FOR_OUTPUT_ADDRESS |
47c8cf91 | 1543 | && reload_when_needed[i] != RELOAD_FOR_OUTADDR_ADDRESS |
a8c9daeb RK |
1544 | && reload_when_needed[i] != RELOAD_OTHER |
1545 | && (CLASS_MAX_NREGS (reload_reg_class[i], reload_inmode[i]) | |
1546 | == CLASS_MAX_NREGS (reload_reg_class[output_reload], | |
1547 | reload_outmode[output_reload])) | |
eab89b90 RK |
1548 | && reload_inc[i] == 0 |
1549 | && reload_reg_rtx[i] == 0 | |
a8c9daeb | 1550 | #ifdef SECONDARY_MEMORY_NEEDED |
9ec7078b RK |
1551 | /* Don't combine two reloads with different secondary |
1552 | memory locations. */ | |
77545d45 RK |
1553 | && (secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[i]] == 0 |
1554 | || secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[output_reload]] == 0 | |
1555 | || rtx_equal_p (secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[i]], | |
1556 | secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[output_reload]])) | |
a8c9daeb | 1557 | #endif |
f95182a4 | 1558 | && ( |
a8c9daeb | 1559 | #ifdef SMALL_REGISTER_CLASSES |
f95182a4 | 1560 | SMALL_REGISTER_CLASSES |
a8c9daeb | 1561 | #else |
f95182a4 | 1562 | 0 |
a8c9daeb | 1563 | #endif |
f95182a4 ILT |
1564 | ? reload_reg_class[i] == reload_reg_class[output_reload] |
1565 | : (reg_class_subset_p (reload_reg_class[i], | |
1566 | reload_reg_class[output_reload]) | |
1567 | || reg_class_subset_p (reload_reg_class[output_reload], | |
1568 | reload_reg_class[i]))) | |
eab89b90 RK |
1569 | && (MATCHES (reload_in[i], reload_out[output_reload]) |
1570 | /* Args reversed because the first arg seems to be | |
1571 | the one that we imagine being modified | |
1572 | while the second is the one that might be affected. */ | |
bfa30b22 RK |
1573 | || (! reg_overlap_mentioned_for_reload_p (reload_out[output_reload], |
1574 | reload_in[i]) | |
eab89b90 RK |
1575 | /* However, if the input is a register that appears inside |
1576 | the output, then we also can't share. | |
1577 | Imagine (set (mem (reg 69)) (plus (reg 69) ...)). | |
1578 | If the same reload reg is used for both reg 69 and the | |
1579 | result to be stored in memory, then that result | |
1580 | will clobber the address of the memory ref. */ | |
1581 | && ! (GET_CODE (reload_in[i]) == REG | |
bfa30b22 | 1582 | && reg_overlap_mentioned_for_reload_p (reload_in[i], |
a8c9daeb RK |
1583 | reload_out[output_reload])))) |
1584 | && (reg_class_size[(int) reload_reg_class[i]] | |
1585 | #ifdef SMALL_REGISTER_CLASSES | |
f95182a4 | 1586 | || SMALL_REGISTER_CLASSES |
a8c9daeb RK |
1587 | #endif |
1588 | ) | |
1589 | /* We will allow making things slightly worse by combining an | |
1590 | input and an output, but no worse than that. */ | |
1591 | && (reload_when_needed[i] == RELOAD_FOR_INPUT | |
1592 | || reload_when_needed[i] == RELOAD_FOR_OUTPUT)) | |
eab89b90 RK |
1593 | { |
1594 | int j; | |
1595 | ||
1596 | /* We have found a reload to combine with! */ | |
1597 | reload_out[i] = reload_out[output_reload]; | |
1598 | reload_outmode[i] = reload_outmode[output_reload]; | |
1599 | /* Mark the old output reload as inoperative. */ | |
1600 | reload_out[output_reload] = 0; | |
1601 | /* The combined reload is needed for the entire insn. */ | |
eab89b90 | 1602 | reload_when_needed[i] = RELOAD_OTHER; |
0f41302f | 1603 | /* If the output reload had a secondary reload, copy it. */ |
9ec7078b RK |
1604 | if (reload_secondary_out_reload[output_reload] != -1) |
1605 | { | |
1606 | reload_secondary_out_reload[i] | |
1607 | = reload_secondary_out_reload[output_reload]; | |
1608 | reload_secondary_out_icode[i] | |
1609 | = reload_secondary_out_icode[output_reload]; | |
1610 | } | |
1611 | ||
a8c9daeb RK |
1612 | #ifdef SECONDARY_MEMORY_NEEDED |
1613 | /* Copy any secondary MEM. */ | |
77545d45 RK |
1614 | if (secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[output_reload]] != 0) |
1615 | secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[i]] | |
1616 | = secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[output_reload]]; | |
a8c9daeb | 1617 | #endif |
0f41302f | 1618 | /* If required, minimize the register class. */ |
eab89b90 RK |
1619 | if (reg_class_subset_p (reload_reg_class[output_reload], |
1620 | reload_reg_class[i])) | |
1621 | reload_reg_class[i] = reload_reg_class[output_reload]; | |
1622 | ||
1623 | /* Transfer all replacements from the old reload to the combined. */ | |
1624 | for (j = 0; j < n_replacements; j++) | |
1625 | if (replacements[j].what == output_reload) | |
1626 | replacements[j].what = i; | |
1627 | ||
1628 | return; | |
1629 | } | |
1630 | ||
1631 | /* If this insn has only one operand that is modified or written (assumed | |
1632 | to be the first), it must be the one corresponding to this reload. It | |
1633 | is safe to use anything that dies in this insn for that output provided | |
1634 | that it does not occur in the output (we already know it isn't an | |
1635 | earlyclobber. If this is an asm insn, give up. */ | |
1636 | ||
1637 | if (INSN_CODE (this_insn) == -1) | |
1638 | return; | |
1639 | ||
1640 | for (i = 1; i < insn_n_operands[INSN_CODE (this_insn)]; i++) | |
1641 | if (insn_operand_constraint[INSN_CODE (this_insn)][i][0] == '=' | |
1642 | || insn_operand_constraint[INSN_CODE (this_insn)][i][0] == '+') | |
1643 | return; | |
1644 | ||
1645 | /* See if some hard register that dies in this insn and is not used in | |
1646 | the output is the right class. Only works if the register we pick | |
1647 | up can fully hold our output reload. */ | |
1648 | for (note = REG_NOTES (this_insn); note; note = XEXP (note, 1)) | |
1649 | if (REG_NOTE_KIND (note) == REG_DEAD | |
1650 | && GET_CODE (XEXP (note, 0)) == REG | |
bfa30b22 RK |
1651 | && ! reg_overlap_mentioned_for_reload_p (XEXP (note, 0), |
1652 | reload_out[output_reload]) | |
eab89b90 RK |
1653 | && REGNO (XEXP (note, 0)) < FIRST_PSEUDO_REGISTER |
1654 | && HARD_REGNO_MODE_OK (REGNO (XEXP (note, 0)), reload_outmode[output_reload]) | |
1655 | && TEST_HARD_REG_BIT (reg_class_contents[(int) reload_reg_class[output_reload]], | |
1656 | REGNO (XEXP (note, 0))) | |
1657 | && (HARD_REGNO_NREGS (REGNO (XEXP (note, 0)), reload_outmode[output_reload]) | |
1658 | <= HARD_REGNO_NREGS (REGNO (XEXP (note, 0)), GET_MODE (XEXP (note, 0)))) | |
8922eb5b RK |
1659 | /* Ensure that a secondary or tertiary reload for this output |
1660 | won't want this register. */ | |
1661 | && ((secondary_out = reload_secondary_out_reload[output_reload]) == -1 | |
1662 | || (! (TEST_HARD_REG_BIT | |
1663 | (reg_class_contents[(int) reload_reg_class[secondary_out]], | |
1664 | REGNO (XEXP (note, 0)))) | |
1665 | && ((secondary_out = reload_secondary_out_reload[secondary_out]) == -1 | |
1666 | || ! (TEST_HARD_REG_BIT | |
1667 | (reg_class_contents[(int) reload_reg_class[secondary_out]], | |
1668 | REGNO (XEXP (note, 0))))))) | |
eab89b90 RK |
1669 | && ! fixed_regs[REGNO (XEXP (note, 0))]) |
1670 | { | |
1671 | reload_reg_rtx[output_reload] = gen_rtx (REG, | |
1672 | reload_outmode[output_reload], | |
1673 | REGNO (XEXP (note, 0))); | |
1674 | return; | |
1675 | } | |
1676 | } | |
1677 | \f | |
1678 | /* Try to find a reload register for an in-out reload (expressions IN and OUT). | |
1679 | See if one of IN and OUT is a register that may be used; | |
1680 | this is desirable since a spill-register won't be needed. | |
1681 | If so, return the register rtx that proves acceptable. | |
1682 | ||
1683 | INLOC and OUTLOC are locations where IN and OUT appear in the insn. | |
1684 | CLASS is the register class required for the reload. | |
1685 | ||
1686 | If FOR_REAL is >= 0, it is the number of the reload, | |
1687 | and in some cases when it can be discovered that OUT doesn't need | |
1688 | to be computed, clear out reload_out[FOR_REAL]. | |
1689 | ||
1690 | If FOR_REAL is -1, this should not be done, because this call | |
1691 | is just to see if a register can be found, not to find and install it. */ | |
1692 | ||
1693 | static rtx | |
36b50568 RS |
1694 | find_dummy_reload (real_in, real_out, inloc, outloc, |
1695 | inmode, outmode, class, for_real) | |
eab89b90 RK |
1696 | rtx real_in, real_out; |
1697 | rtx *inloc, *outloc; | |
36b50568 | 1698 | enum machine_mode inmode, outmode; |
eab89b90 RK |
1699 | enum reg_class class; |
1700 | int for_real; | |
1701 | { | |
1702 | rtx in = real_in; | |
1703 | rtx out = real_out; | |
1704 | int in_offset = 0; | |
1705 | int out_offset = 0; | |
1706 | rtx value = 0; | |
1707 | ||
1708 | /* If operands exceed a word, we can't use either of them | |
1709 | unless they have the same size. */ | |
36b50568 RS |
1710 | if (GET_MODE_SIZE (outmode) != GET_MODE_SIZE (inmode) |
1711 | && (GET_MODE_SIZE (outmode) > UNITS_PER_WORD | |
1712 | || GET_MODE_SIZE (inmode) > UNITS_PER_WORD)) | |
eab89b90 RK |
1713 | return 0; |
1714 | ||
1715 | /* Find the inside of any subregs. */ | |
1716 | while (GET_CODE (out) == SUBREG) | |
1717 | { | |
1718 | out_offset = SUBREG_WORD (out); | |
1719 | out = SUBREG_REG (out); | |
1720 | } | |
1721 | while (GET_CODE (in) == SUBREG) | |
1722 | { | |
1723 | in_offset = SUBREG_WORD (in); | |
1724 | in = SUBREG_REG (in); | |
1725 | } | |
1726 | ||
1727 | /* Narrow down the reg class, the same way push_reload will; | |
1728 | otherwise we might find a dummy now, but push_reload won't. */ | |
1729 | class = PREFERRED_RELOAD_CLASS (in, class); | |
1730 | ||
1731 | /* See if OUT will do. */ | |
1732 | if (GET_CODE (out) == REG | |
1733 | && REGNO (out) < FIRST_PSEUDO_REGISTER) | |
1734 | { | |
1735 | register int regno = REGNO (out) + out_offset; | |
36b50568 | 1736 | int nwords = HARD_REGNO_NREGS (regno, outmode); |
d3b9996a | 1737 | rtx saved_rtx; |
eab89b90 RK |
1738 | |
1739 | /* When we consider whether the insn uses OUT, | |
1740 | ignore references within IN. They don't prevent us | |
1741 | from copying IN into OUT, because those refs would | |
1742 | move into the insn that reloads IN. | |
1743 | ||
1744 | However, we only ignore IN in its role as this reload. | |
1745 | If the insn uses IN elsewhere and it contains OUT, | |
1746 | that counts. We can't be sure it's the "same" operand | |
1747 | so it might not go through this reload. */ | |
d3b9996a | 1748 | saved_rtx = *inloc; |
eab89b90 RK |
1749 | *inloc = const0_rtx; |
1750 | ||
1751 | if (regno < FIRST_PSEUDO_REGISTER | |
1752 | /* A fixed reg that can overlap other regs better not be used | |
1753 | for reloading in any way. */ | |
1754 | #ifdef OVERLAPPING_REGNO_P | |
1755 | && ! (fixed_regs[regno] && OVERLAPPING_REGNO_P (regno)) | |
1756 | #endif | |
1757 | && ! refers_to_regno_for_reload_p (regno, regno + nwords, | |
1758 | PATTERN (this_insn), outloc)) | |
1759 | { | |
1760 | int i; | |
1761 | for (i = 0; i < nwords; i++) | |
1762 | if (! TEST_HARD_REG_BIT (reg_class_contents[(int) class], | |
1763 | regno + i)) | |
1764 | break; | |
1765 | ||
1766 | if (i == nwords) | |
1767 | { | |
1768 | if (GET_CODE (real_out) == REG) | |
1769 | value = real_out; | |
1770 | else | |
36b50568 | 1771 | value = gen_rtx (REG, outmode, regno); |
eab89b90 RK |
1772 | } |
1773 | } | |
1774 | ||
d3b9996a | 1775 | *inloc = saved_rtx; |
eab89b90 RK |
1776 | } |
1777 | ||
1778 | /* Consider using IN if OUT was not acceptable | |
1779 | or if OUT dies in this insn (like the quotient in a divmod insn). | |
1780 | We can't use IN unless it is dies in this insn, | |
1781 | which means we must know accurately which hard regs are live. | |
1782 | Also, the result can't go in IN if IN is used within OUT. */ | |
1783 | if (hard_regs_live_known | |
1784 | && GET_CODE (in) == REG | |
1785 | && REGNO (in) < FIRST_PSEUDO_REGISTER | |
1786 | && (value == 0 | |
1787 | || find_reg_note (this_insn, REG_UNUSED, real_out)) | |
1788 | && find_reg_note (this_insn, REG_DEAD, real_in) | |
1789 | && !fixed_regs[REGNO (in)] | |
36b50568 RS |
1790 | && HARD_REGNO_MODE_OK (REGNO (in), |
1791 | /* The only case where out and real_out might | |
1792 | have different modes is where real_out | |
1793 | is a subreg, and in that case, out | |
1794 | has a real mode. */ | |
1795 | (GET_MODE (out) != VOIDmode | |
1796 | ? GET_MODE (out) : outmode))) | |
eab89b90 RK |
1797 | { |
1798 | register int regno = REGNO (in) + in_offset; | |
36b50568 | 1799 | int nwords = HARD_REGNO_NREGS (regno, inmode); |
eab89b90 | 1800 | |
fb3821f7 | 1801 | if (! refers_to_regno_for_reload_p (regno, regno + nwords, out, NULL_PTR) |
eab89b90 RK |
1802 | && ! hard_reg_set_here_p (regno, regno + nwords, |
1803 | PATTERN (this_insn))) | |
1804 | { | |
1805 | int i; | |
1806 | for (i = 0; i < nwords; i++) | |
1807 | if (! TEST_HARD_REG_BIT (reg_class_contents[(int) class], | |
1808 | regno + i)) | |
1809 | break; | |
1810 | ||
1811 | if (i == nwords) | |
1812 | { | |
1813 | /* If we were going to use OUT as the reload reg | |
1814 | and changed our mind, it means OUT is a dummy that | |
1815 | dies here. So don't bother copying value to it. */ | |
1816 | if (for_real >= 0 && value == real_out) | |
1817 | reload_out[for_real] = 0; | |
1818 | if (GET_CODE (real_in) == REG) | |
1819 | value = real_in; | |
1820 | else | |
36b50568 | 1821 | value = gen_rtx (REG, inmode, regno); |
eab89b90 RK |
1822 | } |
1823 | } | |
1824 | } | |
1825 | ||
1826 | return value; | |
1827 | } | |
1828 | \f | |
1829 | /* This page contains subroutines used mainly for determining | |
1830 | whether the IN or an OUT of a reload can serve as the | |
1831 | reload register. */ | |
1832 | ||
4644aad4 RK |
1833 | /* Return 1 if X is an operand of an insn that is being earlyclobbered. */ |
1834 | ||
1835 | static int | |
1836 | earlyclobber_operand_p (x) | |
1837 | rtx x; | |
1838 | { | |
1839 | int i; | |
1840 | ||
1841 | for (i = 0; i < n_earlyclobbers; i++) | |
1842 | if (reload_earlyclobbers[i] == x) | |
1843 | return 1; | |
1844 | ||
1845 | return 0; | |
1846 | } | |
1847 | ||
eab89b90 RK |
1848 | /* Return 1 if expression X alters a hard reg in the range |
1849 | from BEG_REGNO (inclusive) to END_REGNO (exclusive), | |
1850 | either explicitly or in the guise of a pseudo-reg allocated to REGNO. | |
1851 | X should be the body of an instruction. */ | |
1852 | ||
1853 | static int | |
1854 | hard_reg_set_here_p (beg_regno, end_regno, x) | |
1855 | register int beg_regno, end_regno; | |
1856 | rtx x; | |
1857 | { | |
1858 | if (GET_CODE (x) == SET || GET_CODE (x) == CLOBBER) | |
1859 | { | |
1860 | register rtx op0 = SET_DEST (x); | |
1861 | while (GET_CODE (op0) == SUBREG) | |
1862 | op0 = SUBREG_REG (op0); | |
1863 | if (GET_CODE (op0) == REG) | |
1864 | { | |
1865 | register int r = REGNO (op0); | |
1866 | /* See if this reg overlaps range under consideration. */ | |
1867 | if (r < end_regno | |
1868 | && r + HARD_REGNO_NREGS (r, GET_MODE (op0)) > beg_regno) | |
1869 | return 1; | |
1870 | } | |
1871 | } | |
1872 | else if (GET_CODE (x) == PARALLEL) | |
1873 | { | |
1874 | register int i = XVECLEN (x, 0) - 1; | |
1875 | for (; i >= 0; i--) | |
1876 | if (hard_reg_set_here_p (beg_regno, end_regno, XVECEXP (x, 0, i))) | |
1877 | return 1; | |
1878 | } | |
1879 | ||
1880 | return 0; | |
1881 | } | |
1882 | ||
1883 | /* Return 1 if ADDR is a valid memory address for mode MODE, | |
1884 | and check that each pseudo reg has the proper kind of | |
1885 | hard reg. */ | |
1886 | ||
1887 | int | |
1888 | strict_memory_address_p (mode, addr) | |
1889 | enum machine_mode mode; | |
1890 | register rtx addr; | |
1891 | { | |
1892 | GO_IF_LEGITIMATE_ADDRESS (mode, addr, win); | |
1893 | return 0; | |
1894 | ||
1895 | win: | |
1896 | return 1; | |
1897 | } | |
eab89b90 RK |
1898 | \f |
1899 | /* Like rtx_equal_p except that it allows a REG and a SUBREG to match | |
1900 | if they are the same hard reg, and has special hacks for | |
1901 | autoincrement and autodecrement. | |
1902 | This is specifically intended for find_reloads to use | |
1903 | in determining whether two operands match. | |
1904 | X is the operand whose number is the lower of the two. | |
1905 | ||
1906 | The value is 2 if Y contains a pre-increment that matches | |
1907 | a non-incrementing address in X. */ | |
1908 | ||
1909 | /* ??? To be completely correct, we should arrange to pass | |
1910 | for X the output operand and for Y the input operand. | |
1911 | For now, we assume that the output operand has the lower number | |
1912 | because that is natural in (SET output (... input ...)). */ | |
1913 | ||
1914 | int | |
1915 | operands_match_p (x, y) | |
1916 | register rtx x, y; | |
1917 | { | |
1918 | register int i; | |
1919 | register RTX_CODE code = GET_CODE (x); | |
1920 | register char *fmt; | |
1921 | int success_2; | |
1922 | ||
1923 | if (x == y) | |
1924 | return 1; | |
1925 | if ((code == REG || (code == SUBREG && GET_CODE (SUBREG_REG (x)) == REG)) | |
1926 | && (GET_CODE (y) == REG || (GET_CODE (y) == SUBREG | |
1927 | && GET_CODE (SUBREG_REG (y)) == REG))) | |
1928 | { | |
1929 | register int j; | |
1930 | ||
1931 | if (code == SUBREG) | |
1932 | { | |
1933 | i = REGNO (SUBREG_REG (x)); | |
1934 | if (i >= FIRST_PSEUDO_REGISTER) | |
1935 | goto slow; | |
1936 | i += SUBREG_WORD (x); | |
1937 | } | |
1938 | else | |
1939 | i = REGNO (x); | |
1940 | ||
1941 | if (GET_CODE (y) == SUBREG) | |
1942 | { | |
1943 | j = REGNO (SUBREG_REG (y)); | |
1944 | if (j >= FIRST_PSEUDO_REGISTER) | |
1945 | goto slow; | |
1946 | j += SUBREG_WORD (y); | |
1947 | } | |
1948 | else | |
1949 | j = REGNO (y); | |
1950 | ||
dca52d80 JW |
1951 | /* On a WORDS_BIG_ENDIAN machine, point to the last register of a |
1952 | multiple hard register group, so that for example (reg:DI 0) and | |
1953 | (reg:SI 1) will be considered the same register. */ | |
1954 | if (WORDS_BIG_ENDIAN && GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD | |
1955 | && i < FIRST_PSEUDO_REGISTER) | |
1956 | i += (GET_MODE_SIZE (GET_MODE (x)) / UNITS_PER_WORD) - 1; | |
1957 | if (WORDS_BIG_ENDIAN && GET_MODE_SIZE (GET_MODE (y)) > UNITS_PER_WORD | |
1958 | && j < FIRST_PSEUDO_REGISTER) | |
1959 | j += (GET_MODE_SIZE (GET_MODE (y)) / UNITS_PER_WORD) - 1; | |
1960 | ||
eab89b90 RK |
1961 | return i == j; |
1962 | } | |
1963 | /* If two operands must match, because they are really a single | |
1964 | operand of an assembler insn, then two postincrements are invalid | |
1965 | because the assembler insn would increment only once. | |
1966 | On the other hand, an postincrement matches ordinary indexing | |
1967 | if the postincrement is the output operand. */ | |
1968 | if (code == POST_DEC || code == POST_INC) | |
1969 | return operands_match_p (XEXP (x, 0), y); | |
1970 | /* Two preincrements are invalid | |
1971 | because the assembler insn would increment only once. | |
1972 | On the other hand, an preincrement matches ordinary indexing | |
1973 | if the preincrement is the input operand. | |
1974 | In this case, return 2, since some callers need to do special | |
1975 | things when this happens. */ | |
1976 | if (GET_CODE (y) == PRE_DEC || GET_CODE (y) == PRE_INC) | |
1977 | return operands_match_p (x, XEXP (y, 0)) ? 2 : 0; | |
1978 | ||
1979 | slow: | |
1980 | ||
1981 | /* Now we have disposed of all the cases | |
1982 | in which different rtx codes can match. */ | |
1983 | if (code != GET_CODE (y)) | |
1984 | return 0; | |
1985 | if (code == LABEL_REF) | |
1986 | return XEXP (x, 0) == XEXP (y, 0); | |
1987 | if (code == SYMBOL_REF) | |
1988 | return XSTR (x, 0) == XSTR (y, 0); | |
1989 | ||
1990 | /* (MULT:SI x y) and (MULT:HI x y) are NOT equivalent. */ | |
1991 | ||
1992 | if (GET_MODE (x) != GET_MODE (y)) | |
1993 | return 0; | |
1994 | ||
1995 | /* Compare the elements. If any pair of corresponding elements | |
1996 | fail to match, return 0 for the whole things. */ | |
1997 | ||
1998 | success_2 = 0; | |
1999 | fmt = GET_RTX_FORMAT (code); | |
2000 | for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) | |
2001 | { | |
2002 | int val; | |
2003 | switch (fmt[i]) | |
2004 | { | |
fb3821f7 CH |
2005 | case 'w': |
2006 | if (XWINT (x, i) != XWINT (y, i)) | |
2007 | return 0; | |
2008 | break; | |
2009 | ||
eab89b90 RK |
2010 | case 'i': |
2011 | if (XINT (x, i) != XINT (y, i)) | |
2012 | return 0; | |
2013 | break; | |
2014 | ||
2015 | case 'e': | |
2016 | val = operands_match_p (XEXP (x, i), XEXP (y, i)); | |
2017 | if (val == 0) | |
2018 | return 0; | |
2019 | /* If any subexpression returns 2, | |
2020 | we should return 2 if we are successful. */ | |
2021 | if (val == 2) | |
2022 | success_2 = 1; | |
2023 | break; | |
2024 | ||
2025 | case '0': | |
2026 | break; | |
2027 | ||
2028 | /* It is believed that rtx's at this level will never | |
2029 | contain anything but integers and other rtx's, | |
2030 | except for within LABEL_REFs and SYMBOL_REFs. */ | |
2031 | default: | |
2032 | abort (); | |
2033 | } | |
2034 | } | |
2035 | return 1 + success_2; | |
2036 | } | |
2037 | \f | |
2038 | /* Return the number of times character C occurs in string S. */ | |
2039 | ||
e4600702 | 2040 | int |
eab89b90 | 2041 | n_occurrences (c, s) |
d149d5f5 | 2042 | int c; |
eab89b90 RK |
2043 | char *s; |
2044 | { | |
2045 | int n = 0; | |
2046 | while (*s) | |
2047 | n += (*s++ == c); | |
2048 | return n; | |
2049 | } | |
2050 | \f | |
eab89b90 RK |
2051 | /* Describe the range of registers or memory referenced by X. |
2052 | If X is a register, set REG_FLAG and put the first register | |
2053 | number into START and the last plus one into END. | |
2054 | If X is a memory reference, put a base address into BASE | |
2055 | and a range of integer offsets into START and END. | |
2056 | If X is pushing on the stack, we can assume it causes no trouble, | |
2057 | so we set the SAFE field. */ | |
2058 | ||
2059 | static struct decomposition | |
2060 | decompose (x) | |
2061 | rtx x; | |
2062 | { | |
2063 | struct decomposition val; | |
2064 | int all_const = 0; | |
2065 | ||
2066 | val.reg_flag = 0; | |
2067 | val.safe = 0; | |
2068 | if (GET_CODE (x) == MEM) | |
2069 | { | |
2070 | rtx base, offset = 0; | |
2071 | rtx addr = XEXP (x, 0); | |
2072 | ||
2073 | if (GET_CODE (addr) == PRE_DEC || GET_CODE (addr) == PRE_INC | |
2074 | || GET_CODE (addr) == POST_DEC || GET_CODE (addr) == POST_INC) | |
2075 | { | |
2076 | val.base = XEXP (addr, 0); | |
2077 | val.start = - GET_MODE_SIZE (GET_MODE (x)); | |
2078 | val.end = GET_MODE_SIZE (GET_MODE (x)); | |
2079 | val.safe = REGNO (val.base) == STACK_POINTER_REGNUM; | |
2080 | return val; | |
2081 | } | |
2082 | ||
2083 | if (GET_CODE (addr) == CONST) | |
2084 | { | |
2085 | addr = XEXP (addr, 0); | |
2086 | all_const = 1; | |
2087 | } | |
2088 | if (GET_CODE (addr) == PLUS) | |
2089 | { | |
2090 | if (CONSTANT_P (XEXP (addr, 0))) | |
2091 | { | |
2092 | base = XEXP (addr, 1); | |
2093 | offset = XEXP (addr, 0); | |
2094 | } | |
2095 | else if (CONSTANT_P (XEXP (addr, 1))) | |
2096 | { | |
2097 | base = XEXP (addr, 0); | |
2098 | offset = XEXP (addr, 1); | |
2099 | } | |
2100 | } | |
2101 | ||
2102 | if (offset == 0) | |
2103 | { | |
2104 | base = addr; | |
2105 | offset = const0_rtx; | |
2106 | } | |
2107 | if (GET_CODE (offset) == CONST) | |
2108 | offset = XEXP (offset, 0); | |
2109 | if (GET_CODE (offset) == PLUS) | |
2110 | { | |
2111 | if (GET_CODE (XEXP (offset, 0)) == CONST_INT) | |
2112 | { | |
2113 | base = gen_rtx (PLUS, GET_MODE (base), base, XEXP (offset, 1)); | |
2114 | offset = XEXP (offset, 0); | |
2115 | } | |
2116 | else if (GET_CODE (XEXP (offset, 1)) == CONST_INT) | |
2117 | { | |
2118 | base = gen_rtx (PLUS, GET_MODE (base), base, XEXP (offset, 0)); | |
2119 | offset = XEXP (offset, 1); | |
2120 | } | |
2121 | else | |
2122 | { | |
2123 | base = gen_rtx (PLUS, GET_MODE (base), base, offset); | |
2124 | offset = const0_rtx; | |
2125 | } | |
2126 | } | |
2127 | else if (GET_CODE (offset) != CONST_INT) | |
2128 | { | |
2129 | base = gen_rtx (PLUS, GET_MODE (base), base, offset); | |
2130 | offset = const0_rtx; | |
2131 | } | |
2132 | ||
2133 | if (all_const && GET_CODE (base) == PLUS) | |
2134 | base = gen_rtx (CONST, GET_MODE (base), base); | |
2135 | ||
2136 | if (GET_CODE (offset) != CONST_INT) | |
2137 | abort (); | |
2138 | ||
2139 | val.start = INTVAL (offset); | |
2140 | val.end = val.start + GET_MODE_SIZE (GET_MODE (x)); | |
2141 | val.base = base; | |
2142 | return val; | |
2143 | } | |
2144 | else if (GET_CODE (x) == REG) | |
2145 | { | |
2146 | val.reg_flag = 1; | |
2147 | val.start = true_regnum (x); | |
2148 | if (val.start < 0) | |
2149 | { | |
2150 | /* A pseudo with no hard reg. */ | |
2151 | val.start = REGNO (x); | |
2152 | val.end = val.start + 1; | |
2153 | } | |
2154 | else | |
2155 | /* A hard reg. */ | |
2156 | val.end = val.start + HARD_REGNO_NREGS (val.start, GET_MODE (x)); | |
2157 | } | |
2158 | else if (GET_CODE (x) == SUBREG) | |
2159 | { | |
2160 | if (GET_CODE (SUBREG_REG (x)) != REG) | |
2161 | /* This could be more precise, but it's good enough. */ | |
2162 | return decompose (SUBREG_REG (x)); | |
2163 | val.reg_flag = 1; | |
2164 | val.start = true_regnum (x); | |
2165 | if (val.start < 0) | |
2166 | return decompose (SUBREG_REG (x)); | |
2167 | else | |
2168 | /* A hard reg. */ | |
2169 | val.end = val.start + HARD_REGNO_NREGS (val.start, GET_MODE (x)); | |
2170 | } | |
2171 | else if (CONSTANT_P (x) | |
2172 | /* This hasn't been assigned yet, so it can't conflict yet. */ | |
2173 | || GET_CODE (x) == SCRATCH) | |
2174 | val.safe = 1; | |
2175 | else | |
2176 | abort (); | |
2177 | return val; | |
2178 | } | |
2179 | ||
2180 | /* Return 1 if altering Y will not modify the value of X. | |
2181 | Y is also described by YDATA, which should be decompose (Y). */ | |
2182 | ||
2183 | static int | |
2184 | immune_p (x, y, ydata) | |
2185 | rtx x, y; | |
2186 | struct decomposition ydata; | |
2187 | { | |
2188 | struct decomposition xdata; | |
2189 | ||
2190 | if (ydata.reg_flag) | |
fb3821f7 | 2191 | return !refers_to_regno_for_reload_p (ydata.start, ydata.end, x, NULL_PTR); |
eab89b90 RK |
2192 | if (ydata.safe) |
2193 | return 1; | |
2194 | ||
2195 | if (GET_CODE (y) != MEM) | |
2196 | abort (); | |
2197 | /* If Y is memory and X is not, Y can't affect X. */ | |
2198 | if (GET_CODE (x) != MEM) | |
2199 | return 1; | |
2200 | ||
2201 | xdata = decompose (x); | |
2202 | ||
2203 | if (! rtx_equal_p (xdata.base, ydata.base)) | |
2204 | { | |
2205 | /* If bases are distinct symbolic constants, there is no overlap. */ | |
2206 | if (CONSTANT_P (xdata.base) && CONSTANT_P (ydata.base)) | |
2207 | return 1; | |
2208 | /* Constants and stack slots never overlap. */ | |
2209 | if (CONSTANT_P (xdata.base) | |
2210 | && (ydata.base == frame_pointer_rtx | |
a36d4c62 | 2211 | || ydata.base == hard_frame_pointer_rtx |
eab89b90 RK |
2212 | || ydata.base == stack_pointer_rtx)) |
2213 | return 1; | |
2214 | if (CONSTANT_P (ydata.base) | |
2215 | && (xdata.base == frame_pointer_rtx | |
a36d4c62 | 2216 | || xdata.base == hard_frame_pointer_rtx |
eab89b90 RK |
2217 | || xdata.base == stack_pointer_rtx)) |
2218 | return 1; | |
2219 | /* If either base is variable, we don't know anything. */ | |
2220 | return 0; | |
2221 | } | |
2222 | ||
2223 | ||
2224 | return (xdata.start >= ydata.end || ydata.start >= xdata.end); | |
2225 | } | |
44ace968 | 2226 | |
f72aed24 | 2227 | /* Similar, but calls decompose. */ |
44ace968 JW |
2228 | |
2229 | int | |
2230 | safe_from_earlyclobber (op, clobber) | |
2231 | rtx op, clobber; | |
2232 | { | |
2233 | struct decomposition early_data; | |
2234 | ||
2235 | early_data = decompose (clobber); | |
2236 | return immune_p (op, clobber, early_data); | |
2237 | } | |
eab89b90 RK |
2238 | \f |
2239 | /* Main entry point of this file: search the body of INSN | |
2240 | for values that need reloading and record them with push_reload. | |
2241 | REPLACE nonzero means record also where the values occur | |
2242 | so that subst_reloads can be used. | |
2243 | ||
2244 | IND_LEVELS says how many levels of indirection are supported by this | |
2245 | machine; a value of zero means that a memory reference is not a valid | |
2246 | memory address. | |
2247 | ||
2248 | LIVE_KNOWN says we have valid information about which hard | |
2249 | regs are live at each point in the program; this is true when | |
2250 | we are called from global_alloc but false when stupid register | |
2251 | allocation has been done. | |
2252 | ||
2253 | RELOAD_REG_P if nonzero is a vector indexed by hard reg number | |
2254 | which is nonnegative if the reg has been commandeered for reloading into. | |
2255 | It is copied into STATIC_RELOAD_REG_P and referenced from there | |
2256 | by various subroutines. */ | |
2257 | ||
2258 | void | |
2259 | find_reloads (insn, replace, ind_levels, live_known, reload_reg_p) | |
2260 | rtx insn; | |
2261 | int replace, ind_levels; | |
2262 | int live_known; | |
2263 | short *reload_reg_p; | |
2264 | { | |
eab89b90 RK |
2265 | #ifdef REGISTER_CONSTRAINTS |
2266 | ||
eab89b90 | 2267 | register int insn_code_number; |
a8c9daeb | 2268 | register int i, j; |
eab89b90 RK |
2269 | int noperands; |
2270 | /* These are the constraints for the insn. We don't change them. */ | |
2271 | char *constraints1[MAX_RECOG_OPERANDS]; | |
2272 | /* These start out as the constraints for the insn | |
2273 | and they are chewed up as we consider alternatives. */ | |
2274 | char *constraints[MAX_RECOG_OPERANDS]; | |
2275 | /* These are the preferred classes for an operand, or NO_REGS if it isn't | |
2276 | a register. */ | |
2277 | enum reg_class preferred_class[MAX_RECOG_OPERANDS]; | |
2278 | char pref_or_nothing[MAX_RECOG_OPERANDS]; | |
2279 | /* Nonzero for a MEM operand whose entire address needs a reload. */ | |
2280 | int address_reloaded[MAX_RECOG_OPERANDS]; | |
a8c9daeb RK |
2281 | /* Value of enum reload_type to use for operand. */ |
2282 | enum reload_type operand_type[MAX_RECOG_OPERANDS]; | |
2283 | /* Value of enum reload_type to use within address of operand. */ | |
2284 | enum reload_type address_type[MAX_RECOG_OPERANDS]; | |
2285 | /* Save the usage of each operand. */ | |
2286 | enum reload_usage { RELOAD_READ, RELOAD_READ_WRITE, RELOAD_WRITE } modified[MAX_RECOG_OPERANDS]; | |
eab89b90 RK |
2287 | int no_input_reloads = 0, no_output_reloads = 0; |
2288 | int n_alternatives; | |
2289 | int this_alternative[MAX_RECOG_OPERANDS]; | |
2290 | char this_alternative_win[MAX_RECOG_OPERANDS]; | |
2291 | char this_alternative_offmemok[MAX_RECOG_OPERANDS]; | |
2292 | char this_alternative_earlyclobber[MAX_RECOG_OPERANDS]; | |
2293 | int this_alternative_matches[MAX_RECOG_OPERANDS]; | |
2294 | int swapped; | |
2295 | int goal_alternative[MAX_RECOG_OPERANDS]; | |
2296 | int this_alternative_number; | |
2297 | int goal_alternative_number; | |
2298 | int operand_reloadnum[MAX_RECOG_OPERANDS]; | |
2299 | int goal_alternative_matches[MAX_RECOG_OPERANDS]; | |
2300 | int goal_alternative_matched[MAX_RECOG_OPERANDS]; | |
2301 | char goal_alternative_win[MAX_RECOG_OPERANDS]; | |
2302 | char goal_alternative_offmemok[MAX_RECOG_OPERANDS]; | |
2303 | char goal_alternative_earlyclobber[MAX_RECOG_OPERANDS]; | |
2304 | int goal_alternative_swapped; | |
eab89b90 RK |
2305 | int best; |
2306 | int commutative; | |
2307 | char operands_match[MAX_RECOG_OPERANDS][MAX_RECOG_OPERANDS]; | |
2308 | rtx substed_operand[MAX_RECOG_OPERANDS]; | |
2309 | rtx body = PATTERN (insn); | |
2310 | rtx set = single_set (insn); | |
2311 | int goal_earlyclobber, this_earlyclobber; | |
2312 | enum machine_mode operand_mode[MAX_RECOG_OPERANDS]; | |
2313 | ||
2314 | this_insn = insn; | |
2315 | this_insn_is_asm = 0; /* Tentative. */ | |
2316 | n_reloads = 0; | |
2317 | n_replacements = 0; | |
2318 | n_memlocs = 0; | |
2319 | n_earlyclobbers = 0; | |
2320 | replace_reloads = replace; | |
2321 | hard_regs_live_known = live_known; | |
2322 | static_reload_reg_p = reload_reg_p; | |
2323 | ||
2324 | /* JUMP_INSNs and CALL_INSNs are not allowed to have any output reloads; | |
2325 | neither are insns that SET cc0. Insns that use CC0 are not allowed | |
2326 | to have any input reloads. */ | |
2327 | if (GET_CODE (insn) == JUMP_INSN || GET_CODE (insn) == CALL_INSN) | |
2328 | no_output_reloads = 1; | |
2329 | ||
2330 | #ifdef HAVE_cc0 | |
2331 | if (reg_referenced_p (cc0_rtx, PATTERN (insn))) | |
2332 | no_input_reloads = 1; | |
2333 | if (reg_set_p (cc0_rtx, PATTERN (insn))) | |
2334 | no_output_reloads = 1; | |
2335 | #endif | |
2336 | ||
0dadecf6 RK |
2337 | #ifdef SECONDARY_MEMORY_NEEDED |
2338 | /* The eliminated forms of any secondary memory locations are per-insn, so | |
2339 | clear them out here. */ | |
2340 | ||
4c9a05bc | 2341 | bzero ((char *) secondary_memlocs_elim, sizeof secondary_memlocs_elim); |
0dadecf6 RK |
2342 | #endif |
2343 | ||
eab89b90 RK |
2344 | /* Find what kind of insn this is. NOPERANDS gets number of operands. |
2345 | Make OPERANDS point to a vector of operand values. | |
2346 | Make OPERAND_LOCS point to a vector of pointers to | |
2347 | where the operands were found. | |
2348 | Fill CONSTRAINTS and CONSTRAINTS1 with pointers to the | |
2349 | constraint-strings for this insn. | |
2350 | Return if the insn needs no reload processing. */ | |
2351 | ||
2352 | switch (GET_CODE (body)) | |
2353 | { | |
2354 | case USE: | |
2355 | case CLOBBER: | |
2356 | case ASM_INPUT: | |
2357 | case ADDR_VEC: | |
2358 | case ADDR_DIFF_VEC: | |
2359 | return; | |
2360 | ||
2361 | case SET: | |
2362 | /* Dispose quickly of (set (reg..) (reg..)) if both have hard regs and it | |
2363 | is cheap to move between them. If it is not, there may not be an insn | |
2364 | to do the copy, so we may need a reload. */ | |
2365 | if (GET_CODE (SET_DEST (body)) == REG | |
2366 | && REGNO (SET_DEST (body)) < FIRST_PSEUDO_REGISTER | |
2367 | && GET_CODE (SET_SRC (body)) == REG | |
2368 | && REGNO (SET_SRC (body)) < FIRST_PSEUDO_REGISTER | |
2369 | && REGISTER_MOVE_COST (REGNO_REG_CLASS (REGNO (SET_SRC (body))), | |
2370 | REGNO_REG_CLASS (REGNO (SET_DEST (body)))) == 2) | |
2371 | return; | |
2372 | case PARALLEL: | |
2373 | case ASM_OPERANDS: | |
a8c9daeb | 2374 | reload_n_operands = noperands = asm_noperands (body); |
eab89b90 RK |
2375 | if (noperands >= 0) |
2376 | { | |
2377 | /* This insn is an `asm' with operands. */ | |
2378 | ||
2379 | insn_code_number = -1; | |
2380 | this_insn_is_asm = 1; | |
2381 | ||
2382 | /* expand_asm_operands makes sure there aren't too many operands. */ | |
2383 | if (noperands > MAX_RECOG_OPERANDS) | |
2384 | abort (); | |
2385 | ||
2386 | /* Now get the operand values and constraints out of the insn. */ | |
2387 | ||
2388 | decode_asm_operands (body, recog_operand, recog_operand_loc, | |
2389 | constraints, operand_mode); | |
2390 | if (noperands > 0) | |
2391 | { | |
4c9a05bc RK |
2392 | bcopy ((char *) constraints, (char *) constraints1, |
2393 | noperands * sizeof (char *)); | |
eab89b90 RK |
2394 | n_alternatives = n_occurrences (',', constraints[0]) + 1; |
2395 | for (i = 1; i < noperands; i++) | |
d45cf215 | 2396 | if (n_alternatives != n_occurrences (',', constraints[i]) + 1) |
eab89b90 RK |
2397 | { |
2398 | error_for_asm (insn, "operand constraints differ in number of alternatives"); | |
2399 | /* Avoid further trouble with this insn. */ | |
2400 | PATTERN (insn) = gen_rtx (USE, VOIDmode, const0_rtx); | |
2401 | n_reloads = 0; | |
2402 | return; | |
2403 | } | |
2404 | } | |
2405 | break; | |
2406 | } | |
2407 | ||
2408 | default: | |
2409 | /* Ordinary insn: recognize it, get the operands via insn_extract | |
2410 | and get the constraints. */ | |
2411 | ||
2412 | insn_code_number = recog_memoized (insn); | |
2413 | if (insn_code_number < 0) | |
2414 | fatal_insn_not_found (insn); | |
2415 | ||
a8c9daeb | 2416 | reload_n_operands = noperands = insn_n_operands[insn_code_number]; |
eab89b90 RK |
2417 | n_alternatives = insn_n_alternatives[insn_code_number]; |
2418 | /* Just return "no reloads" if insn has no operands with constraints. */ | |
2419 | if (n_alternatives == 0) | |
2420 | return; | |
2421 | insn_extract (insn); | |
2422 | for (i = 0; i < noperands; i++) | |
2423 | { | |
2424 | constraints[i] = constraints1[i] | |
2425 | = insn_operand_constraint[insn_code_number][i]; | |
2426 | operand_mode[i] = insn_operand_mode[insn_code_number][i]; | |
2427 | } | |
2428 | } | |
2429 | ||
2430 | if (noperands == 0) | |
2431 | return; | |
2432 | ||
2433 | commutative = -1; | |
2434 | ||
2435 | /* If we will need to know, later, whether some pair of operands | |
2436 | are the same, we must compare them now and save the result. | |
2437 | Reloading the base and index registers will clobber them | |
2438 | and afterward they will fail to match. */ | |
2439 | ||
2440 | for (i = 0; i < noperands; i++) | |
2441 | { | |
2442 | register char *p; | |
2443 | register int c; | |
2444 | ||
2445 | substed_operand[i] = recog_operand[i]; | |
2446 | p = constraints[i]; | |
2447 | ||
a8c9daeb RK |
2448 | modified[i] = RELOAD_READ; |
2449 | ||
2450 | /* Scan this operand's constraint to see if it is an output operand, | |
2451 | an in-out operand, is commutative, or should match another. */ | |
eab89b90 RK |
2452 | |
2453 | while (c = *p++) | |
a8c9daeb RK |
2454 | { |
2455 | if (c == '=') | |
2456 | modified[i] = RELOAD_WRITE; | |
2457 | else if (c == '+') | |
2458 | modified[i] = RELOAD_READ_WRITE; | |
2459 | else if (c == '%') | |
2460 | { | |
2461 | /* The last operand should not be marked commutative. */ | |
2462 | if (i == noperands - 1) | |
2463 | { | |
2464 | if (this_insn_is_asm) | |
2465 | warning_for_asm (this_insn, | |
2466 | "`%%' constraint used with last operand"); | |
2467 | else | |
2468 | abort (); | |
2469 | } | |
2470 | else | |
2471 | commutative = i; | |
2472 | } | |
2473 | else if (c >= '0' && c <= '9') | |
2474 | { | |
2475 | c -= '0'; | |
2476 | operands_match[c][i] | |
2477 | = operands_match_p (recog_operand[c], recog_operand[i]); | |
ea9c5b9e | 2478 | |
a8c9daeb RK |
2479 | /* An operand may not match itself. */ |
2480 | if (c == i) | |
2481 | { | |
2482 | if (this_insn_is_asm) | |
2483 | warning_for_asm (this_insn, | |
2484 | "operand %d has constraint %d", i, c); | |
2485 | else | |
2486 | abort (); | |
2487 | } | |
ea9c5b9e | 2488 | |
a8c9daeb RK |
2489 | /* If C can be commuted with C+1, and C might need to match I, |
2490 | then C+1 might also need to match I. */ | |
2491 | if (commutative >= 0) | |
2492 | { | |
2493 | if (c == commutative || c == commutative + 1) | |
2494 | { | |
2495 | int other = c + (c == commutative ? 1 : -1); | |
2496 | operands_match[other][i] | |
2497 | = operands_match_p (recog_operand[other], recog_operand[i]); | |
2498 | } | |
2499 | if (i == commutative || i == commutative + 1) | |
2500 | { | |
2501 | int other = i + (i == commutative ? 1 : -1); | |
2502 | operands_match[c][other] | |
2503 | = operands_match_p (recog_operand[c], recog_operand[other]); | |
2504 | } | |
2505 | /* Note that C is supposed to be less than I. | |
2506 | No need to consider altering both C and I because in | |
2507 | that case we would alter one into the other. */ | |
2508 | } | |
2509 | } | |
2510 | } | |
eab89b90 RK |
2511 | } |
2512 | ||
2513 | /* Examine each operand that is a memory reference or memory address | |
2514 | and reload parts of the addresses into index registers. | |
eab89b90 RK |
2515 | Also here any references to pseudo regs that didn't get hard regs |
2516 | but are equivalent to constants get replaced in the insn itself | |
2517 | with those constants. Nobody will ever see them again. | |
2518 | ||
2519 | Finally, set up the preferred classes of each operand. */ | |
2520 | ||
2521 | for (i = 0; i < noperands; i++) | |
2522 | { | |
2523 | register RTX_CODE code = GET_CODE (recog_operand[i]); | |
a8c9daeb | 2524 | |
eab89b90 | 2525 | address_reloaded[i] = 0; |
a8c9daeb RK |
2526 | operand_type[i] = (modified[i] == RELOAD_READ ? RELOAD_FOR_INPUT |
2527 | : modified[i] == RELOAD_WRITE ? RELOAD_FOR_OUTPUT | |
2528 | : RELOAD_OTHER); | |
2529 | address_type[i] | |
2530 | = (modified[i] == RELOAD_READ ? RELOAD_FOR_INPUT_ADDRESS | |
2531 | : modified[i] == RELOAD_WRITE ? RELOAD_FOR_OUTPUT_ADDRESS | |
2532 | : RELOAD_OTHER); | |
eab89b90 | 2533 | |
0d38001f RS |
2534 | if (*constraints[i] == 0) |
2535 | /* Ignore things like match_operator operands. */ | |
2536 | ; | |
2537 | else if (constraints[i][0] == 'p') | |
eab89b90 | 2538 | { |
fb3821f7 | 2539 | find_reloads_address (VOIDmode, NULL_PTR, |
eab89b90 | 2540 | recog_operand[i], recog_operand_loc[i], |
a8c9daeb | 2541 | i, operand_type[i], ind_levels); |
b685dbae RK |
2542 | |
2543 | /* If we now have a simple operand where we used to have a | |
2544 | PLUS or MULT, re-recognize and try again. */ | |
2545 | if ((GET_RTX_CLASS (GET_CODE (*recog_operand_loc[i])) == 'o' | |
2546 | || GET_CODE (*recog_operand_loc[i]) == SUBREG) | |
2547 | && (GET_CODE (recog_operand[i]) == MULT | |
2548 | || GET_CODE (recog_operand[i]) == PLUS)) | |
2549 | { | |
2550 | INSN_CODE (insn) = -1; | |
2551 | find_reloads (insn, replace, ind_levels, live_known, | |
2552 | reload_reg_p); | |
2553 | return; | |
2554 | } | |
2555 | ||
eab89b90 RK |
2556 | substed_operand[i] = recog_operand[i] = *recog_operand_loc[i]; |
2557 | } | |
2558 | else if (code == MEM) | |
2559 | { | |
2560 | if (find_reloads_address (GET_MODE (recog_operand[i]), | |
2561 | recog_operand_loc[i], | |
2562 | XEXP (recog_operand[i], 0), | |
2563 | &XEXP (recog_operand[i], 0), | |
a8c9daeb | 2564 | i, address_type[i], ind_levels)) |
eab89b90 RK |
2565 | address_reloaded[i] = 1; |
2566 | substed_operand[i] = recog_operand[i] = *recog_operand_loc[i]; | |
2567 | } | |
2568 | else if (code == SUBREG) | |
2569 | substed_operand[i] = recog_operand[i] = *recog_operand_loc[i] | |
a8c9daeb RK |
2570 | = find_reloads_toplev (recog_operand[i], i, address_type[i], |
2571 | ind_levels, | |
eab89b90 RK |
2572 | set != 0 |
2573 | && &SET_DEST (set) == recog_operand_loc[i]); | |
ff428c90 ILT |
2574 | else if (code == PLUS || GET_RTX_CLASS (code) == '1') |
2575 | /* We can get a PLUS as an "operand" as a result of register | |
2576 | elimination. See eliminate_regs and gen_reload. We handle | |
2577 | a unary operator by reloading the operand. */ | |
944d7b14 RS |
2578 | substed_operand[i] = recog_operand[i] = *recog_operand_loc[i] |
2579 | = find_reloads_toplev (recog_operand[i], i, address_type[i], | |
2580 | ind_levels, 0); | |
eab89b90 RK |
2581 | else if (code == REG) |
2582 | { | |
2583 | /* This is equivalent to calling find_reloads_toplev. | |
2584 | The code is duplicated for speed. | |
2585 | When we find a pseudo always equivalent to a constant, | |
2586 | we replace it by the constant. We must be sure, however, | |
2587 | that we don't try to replace it in the insn in which it | |
2588 | is being set. */ | |
2589 | register int regno = REGNO (recog_operand[i]); | |
2590 | if (reg_equiv_constant[regno] != 0 | |
2591 | && (set == 0 || &SET_DEST (set) != recog_operand_loc[i])) | |
2592 | substed_operand[i] = recog_operand[i] | |
2593 | = reg_equiv_constant[regno]; | |
2594 | #if 0 /* This might screw code in reload1.c to delete prior output-reload | |
2595 | that feeds this insn. */ | |
2596 | if (reg_equiv_mem[regno] != 0) | |
2597 | substed_operand[i] = recog_operand[i] | |
2598 | = reg_equiv_mem[regno]; | |
2599 | #endif | |
2600 | if (reg_equiv_address[regno] != 0) | |
2601 | { | |
2602 | /* If reg_equiv_address is not a constant address, copy it, | |
2603 | since it may be shared. */ | |
4ffeab02 JW |
2604 | /* We must rerun eliminate_regs, in case the elimination |
2605 | offsets have changed. */ | |
2606 | rtx address = XEXP (eliminate_regs (reg_equiv_memory_loc[regno], | |
2607 | 0, NULL_RTX), | |
2608 | 0); | |
eab89b90 RK |
2609 | |
2610 | if (rtx_varies_p (address)) | |
2611 | address = copy_rtx (address); | |
2612 | ||
2613 | /* If this is an output operand, we must output a CLOBBER | |
a8c9daeb RK |
2614 | after INSN so find_equiv_reg knows REGNO is being written. |
2615 | Mark this insn specially, do we can put our output reloads | |
2616 | after it. */ | |
2617 | ||
2618 | if (modified[i] != RELOAD_READ) | |
2619 | PUT_MODE (emit_insn_after (gen_rtx (CLOBBER, VOIDmode, | |
2620 | recog_operand[i]), | |
2621 | insn), | |
2622 | DImode); | |
eab89b90 RK |
2623 | |
2624 | *recog_operand_loc[i] = recog_operand[i] | |
2625 | = gen_rtx (MEM, GET_MODE (recog_operand[i]), address); | |
2626 | RTX_UNCHANGING_P (recog_operand[i]) | |
2627 | = RTX_UNCHANGING_P (regno_reg_rtx[regno]); | |
2628 | find_reloads_address (GET_MODE (recog_operand[i]), | |
130659a4 | 2629 | recog_operand_loc[i], |
eab89b90 RK |
2630 | XEXP (recog_operand[i], 0), |
2631 | &XEXP (recog_operand[i], 0), | |
a8c9daeb | 2632 | i, address_type[i], ind_levels); |
eab89b90 RK |
2633 | substed_operand[i] = recog_operand[i] = *recog_operand_loc[i]; |
2634 | } | |
2635 | } | |
aaf9712e RS |
2636 | /* If the operand is still a register (we didn't replace it with an |
2637 | equivalent), get the preferred class to reload it into. */ | |
2638 | code = GET_CODE (recog_operand[i]); | |
2639 | preferred_class[i] | |
91f9a6ed | 2640 | = ((code == REG && REGNO (recog_operand[i]) >= FIRST_PSEUDO_REGISTER) |
aaf9712e RS |
2641 | ? reg_preferred_class (REGNO (recog_operand[i])) : NO_REGS); |
2642 | pref_or_nothing[i] | |
91f9a6ed | 2643 | = (code == REG && REGNO (recog_operand[i]) >= FIRST_PSEUDO_REGISTER |
e4600702 | 2644 | && reg_alternate_class (REGNO (recog_operand[i])) == NO_REGS); |
eab89b90 RK |
2645 | } |
2646 | ||
2647 | /* If this is simply a copy from operand 1 to operand 0, merge the | |
2648 | preferred classes for the operands. */ | |
2649 | if (set != 0 && noperands >= 2 && recog_operand[0] == SET_DEST (set) | |
2650 | && recog_operand[1] == SET_SRC (set)) | |
2651 | { | |
2652 | preferred_class[0] = preferred_class[1] | |
2653 | = reg_class_subunion[(int) preferred_class[0]][(int) preferred_class[1]]; | |
2654 | pref_or_nothing[0] |= pref_or_nothing[1]; | |
2655 | pref_or_nothing[1] |= pref_or_nothing[0]; | |
2656 | } | |
2657 | ||
2658 | /* Now see what we need for pseudo-regs that didn't get hard regs | |
2659 | or got the wrong kind of hard reg. For this, we must consider | |
2660 | all the operands together against the register constraints. */ | |
2661 | ||
2662 | best = MAX_RECOG_OPERANDS + 300; | |
2663 | ||
2664 | swapped = 0; | |
2665 | goal_alternative_swapped = 0; | |
2666 | try_swapped: | |
2667 | ||
2668 | /* The constraints are made of several alternatives. | |
2669 | Each operand's constraint looks like foo,bar,... with commas | |
2670 | separating the alternatives. The first alternatives for all | |
2671 | operands go together, the second alternatives go together, etc. | |
2672 | ||
2673 | First loop over alternatives. */ | |
2674 | ||
2675 | for (this_alternative_number = 0; | |
2676 | this_alternative_number < n_alternatives; | |
2677 | this_alternative_number++) | |
2678 | { | |
2679 | /* Loop over operands for one constraint alternative. */ | |
2680 | /* LOSERS counts those that don't fit this alternative | |
2681 | and would require loading. */ | |
2682 | int losers = 0; | |
2683 | /* BAD is set to 1 if it some operand can't fit this alternative | |
2684 | even after reloading. */ | |
2685 | int bad = 0; | |
2686 | /* REJECT is a count of how undesirable this alternative says it is | |
2687 | if any reloading is required. If the alternative matches exactly | |
2688 | then REJECT is ignored, but otherwise it gets this much | |
2689 | counted against it in addition to the reloading needed. Each | |
2690 | ? counts three times here since we want the disparaging caused by | |
2691 | a bad register class to only count 1/3 as much. */ | |
2692 | int reject = 0; | |
2693 | ||
2694 | this_earlyclobber = 0; | |
2695 | ||
2696 | for (i = 0; i < noperands; i++) | |
2697 | { | |
2698 | register char *p = constraints[i]; | |
2699 | register int win = 0; | |
2700 | /* 0 => this operand can be reloaded somehow for this alternative */ | |
2701 | int badop = 1; | |
2702 | /* 0 => this operand can be reloaded if the alternative allows regs. */ | |
2703 | int winreg = 0; | |
2704 | int c; | |
2705 | register rtx operand = recog_operand[i]; | |
2706 | int offset = 0; | |
2707 | /* Nonzero means this is a MEM that must be reloaded into a reg | |
2708 | regardless of what the constraint says. */ | |
2709 | int force_reload = 0; | |
2710 | int offmemok = 0; | |
9d926da5 RK |
2711 | /* Nonzero if a constant forced into memory would be OK for this |
2712 | operand. */ | |
2713 | int constmemok = 0; | |
eab89b90 RK |
2714 | int earlyclobber = 0; |
2715 | ||
ff428c90 ILT |
2716 | /* If the predicate accepts a unary operator, it means that |
2717 | we need to reload the operand. */ | |
2718 | if (GET_RTX_CLASS (GET_CODE (operand)) == '1') | |
2719 | operand = XEXP (operand, 0); | |
2720 | ||
eab89b90 RK |
2721 | /* If the operand is a SUBREG, extract |
2722 | the REG or MEM (or maybe even a constant) within. | |
2723 | (Constants can occur as a result of reg_equiv_constant.) */ | |
2724 | ||
2725 | while (GET_CODE (operand) == SUBREG) | |
2726 | { | |
2727 | offset += SUBREG_WORD (operand); | |
2728 | operand = SUBREG_REG (operand); | |
ca769828 | 2729 | /* Force reload if this is a constant or PLUS or if there may may |
a61c98cf RK |
2730 | be a problem accessing OPERAND in the outer mode. */ |
2731 | if (CONSTANT_P (operand) | |
ca769828 | 2732 | || GET_CODE (operand) == PLUS |
03b72c86 RK |
2733 | /* We must force a reload of paradoxical SUBREGs |
2734 | of a MEM because the alignment of the inner value | |
beb5a9b8 RK |
2735 | may not be enough to do the outer reference. On |
2736 | big-endian machines, it may also reference outside | |
2737 | the object. | |
03b72c86 RK |
2738 | |
2739 | On machines that extend byte operations and we have a | |
486d8509 RK |
2740 | SUBREG where both the inner and outer modes are no wider |
2741 | than a word and the inner mode is narrower, is integral, | |
2742 | and gets extended when loaded from memory, combine.c has | |
2743 | made assumptions about the behavior of the machine in such | |
03b72c86 RK |
2744 | register access. If the data is, in fact, in memory we |
2745 | must always load using the size assumed to be in the | |
2746 | register and let the insn do the different-sized | |
2747 | accesses. */ | |
a61c98cf RK |
2748 | || ((GET_CODE (operand) == MEM |
2749 | || (GET_CODE (operand)== REG | |
2750 | && REGNO (operand) >= FIRST_PSEUDO_REGISTER)) | |
03b72c86 RK |
2751 | && (((GET_MODE_BITSIZE (GET_MODE (operand)) |
2752 | < BIGGEST_ALIGNMENT) | |
2753 | && (GET_MODE_SIZE (operand_mode[i]) | |
2754 | > GET_MODE_SIZE (GET_MODE (operand)))) | |
beb5a9b8 | 2755 | || (GET_CODE (operand) == MEM && BYTES_BIG_ENDIAN) |
03b72c86 RK |
2756 | #ifdef LOAD_EXTEND_OP |
2757 | || (GET_MODE_SIZE (operand_mode[i]) <= UNITS_PER_WORD | |
2758 | && (GET_MODE_SIZE (GET_MODE (operand)) | |
2759 | <= UNITS_PER_WORD) | |
2760 | && (GET_MODE_SIZE (operand_mode[i]) | |
486d8509 RK |
2761 | > GET_MODE_SIZE (GET_MODE (operand))) |
2762 | && INTEGRAL_MODE_P (GET_MODE (operand)) | |
2763 | && LOAD_EXTEND_OP (GET_MODE (operand)) != NIL) | |
46da6b3a | 2764 | #endif |
03b72c86 | 2765 | )) |
eab89b90 RK |
2766 | /* Subreg of a hard reg which can't handle the subreg's mode |
2767 | or which would handle that mode in the wrong number of | |
2768 | registers for subregging to work. */ | |
a61c98cf RK |
2769 | || (GET_CODE (operand) == REG |
2770 | && REGNO (operand) < FIRST_PSEUDO_REGISTER | |
f72ccbe6 RK |
2771 | && ((GET_MODE_SIZE (operand_mode[i]) <= UNITS_PER_WORD |
2772 | && (GET_MODE_SIZE (GET_MODE (operand)) | |
2773 | > UNITS_PER_WORD) | |
2774 | && ((GET_MODE_SIZE (GET_MODE (operand)) | |
2775 | / UNITS_PER_WORD) | |
2776 | != HARD_REGNO_NREGS (REGNO (operand), | |
2777 | GET_MODE (operand)))) | |
2778 | || ! HARD_REGNO_MODE_OK (REGNO (operand) + offset, | |
2779 | operand_mode[i])))) | |
eab89b90 RK |
2780 | force_reload = 1; |
2781 | } | |
2782 | ||
2783 | this_alternative[i] = (int) NO_REGS; | |
2784 | this_alternative_win[i] = 0; | |
2785 | this_alternative_offmemok[i] = 0; | |
2786 | this_alternative_earlyclobber[i] = 0; | |
2787 | this_alternative_matches[i] = -1; | |
2788 | ||
2789 | /* An empty constraint or empty alternative | |
2790 | allows anything which matched the pattern. */ | |
2791 | if (*p == 0 || *p == ',') | |
2792 | win = 1, badop = 0; | |
2793 | ||
2794 | /* Scan this alternative's specs for this operand; | |
2795 | set WIN if the operand fits any letter in this alternative. | |
2796 | Otherwise, clear BADOP if this operand could | |
2797 | fit some letter after reloads, | |
2798 | or set WINREG if this operand could fit after reloads | |
2799 | provided the constraint allows some registers. */ | |
2800 | ||
2801 | while (*p && (c = *p++) != ',') | |
2802 | switch (c) | |
2803 | { | |
2804 | case '=': | |
eab89b90 | 2805 | case '+': |
eab89b90 RK |
2806 | case '*': |
2807 | break; | |
2808 | ||
2809 | case '%': | |
42add480 TW |
2810 | /* The last operand should not be marked commutative. */ |
2811 | if (i != noperands - 1) | |
2812 | commutative = i; | |
eab89b90 RK |
2813 | break; |
2814 | ||
2815 | case '?': | |
2816 | reject += 3; | |
2817 | break; | |
2818 | ||
2819 | case '!': | |
2820 | reject = 300; | |
2821 | break; | |
2822 | ||
2823 | case '#': | |
2824 | /* Ignore rest of this alternative as far as | |
2825 | reloading is concerned. */ | |
2826 | while (*p && *p != ',') p++; | |
2827 | break; | |
2828 | ||
2829 | case '0': | |
2830 | case '1': | |
2831 | case '2': | |
2832 | case '3': | |
2833 | case '4': | |
2834 | c -= '0'; | |
2835 | this_alternative_matches[i] = c; | |
2836 | /* We are supposed to match a previous operand. | |
2837 | If we do, we win if that one did. | |
2838 | If we do not, count both of the operands as losers. | |
2839 | (This is too conservative, since most of the time | |
2840 | only a single reload insn will be needed to make | |
2841 | the two operands win. As a result, this alternative | |
2842 | may be rejected when it is actually desirable.) */ | |
2843 | if ((swapped && (c != commutative || i != commutative + 1)) | |
2844 | /* If we are matching as if two operands were swapped, | |
2845 | also pretend that operands_match had been computed | |
2846 | with swapped. | |
2847 | But if I is the second of those and C is the first, | |
2848 | don't exchange them, because operands_match is valid | |
2849 | only on one side of its diagonal. */ | |
2850 | ? (operands_match | |
2851 | [(c == commutative || c == commutative + 1) | |
2852 | ? 2*commutative + 1 - c : c] | |
2853 | [(i == commutative || i == commutative + 1) | |
2854 | ? 2*commutative + 1 - i : i]) | |
2855 | : operands_match[c][i]) | |
2856 | win = this_alternative_win[c]; | |
2857 | else | |
2858 | { | |
2859 | /* Operands don't match. */ | |
2860 | rtx value; | |
2861 | /* Retroactively mark the operand we had to match | |
2862 | as a loser, if it wasn't already. */ | |
2863 | if (this_alternative_win[c]) | |
2864 | losers++; | |
2865 | this_alternative_win[c] = 0; | |
2866 | if (this_alternative[c] == (int) NO_REGS) | |
2867 | bad = 1; | |
2868 | /* But count the pair only once in the total badness of | |
2869 | this alternative, if the pair can be a dummy reload. */ | |
2870 | value | |
2871 | = find_dummy_reload (recog_operand[i], recog_operand[c], | |
2872 | recog_operand_loc[i], recog_operand_loc[c], | |
adb44af8 | 2873 | operand_mode[i], operand_mode[c], |
eab89b90 RK |
2874 | this_alternative[c], -1); |
2875 | ||
2876 | if (value != 0) | |
2877 | losers--; | |
2878 | } | |
2879 | /* This can be fixed with reloads if the operand | |
2880 | we are supposed to match can be fixed with reloads. */ | |
2881 | badop = 0; | |
2882 | this_alternative[i] = this_alternative[c]; | |
e64c4f9e RK |
2883 | |
2884 | /* If we have to reload this operand and some previous | |
2885 | operand also had to match the same thing as this | |
2886 | operand, we don't know how to do that. So reject this | |
2887 | alternative. */ | |
2888 | if (! win || force_reload) | |
2889 | for (j = 0; j < i; j++) | |
2890 | if (this_alternative_matches[j] | |
2891 | == this_alternative_matches[i]) | |
2892 | badop = 1; | |
2893 | ||
eab89b90 RK |
2894 | break; |
2895 | ||
2896 | case 'p': | |
2897 | /* All necessary reloads for an address_operand | |
2898 | were handled in find_reloads_address. */ | |
5c73e847 | 2899 | this_alternative[i] = (int) BASE_REG_CLASS; |
eab89b90 RK |
2900 | win = 1; |
2901 | break; | |
2902 | ||
2903 | case 'm': | |
2904 | if (force_reload) | |
2905 | break; | |
2906 | if (GET_CODE (operand) == MEM | |
2907 | || (GET_CODE (operand) == REG | |
2908 | && REGNO (operand) >= FIRST_PSEUDO_REGISTER | |
2909 | && reg_renumber[REGNO (operand)] < 0)) | |
2910 | win = 1; | |
2911 | if (CONSTANT_P (operand)) | |
2912 | badop = 0; | |
9d926da5 | 2913 | constmemok = 1; |
eab89b90 RK |
2914 | break; |
2915 | ||
2916 | case '<': | |
2917 | if (GET_CODE (operand) == MEM | |
2918 | && ! address_reloaded[i] | |
2919 | && (GET_CODE (XEXP (operand, 0)) == PRE_DEC | |
2920 | || GET_CODE (XEXP (operand, 0)) == POST_DEC)) | |
2921 | win = 1; | |
2922 | break; | |
2923 | ||
2924 | case '>': | |
2925 | if (GET_CODE (operand) == MEM | |
2926 | && ! address_reloaded[i] | |
2927 | && (GET_CODE (XEXP (operand, 0)) == PRE_INC | |
2928 | || GET_CODE (XEXP (operand, 0)) == POST_INC)) | |
2929 | win = 1; | |
2930 | break; | |
2931 | ||
2932 | /* Memory operand whose address is not offsettable. */ | |
2933 | case 'V': | |
2934 | if (force_reload) | |
2935 | break; | |
2936 | if (GET_CODE (operand) == MEM | |
2937 | && ! (ind_levels ? offsettable_memref_p (operand) | |
2938 | : offsettable_nonstrict_memref_p (operand)) | |
2939 | /* Certain mem addresses will become offsettable | |
2940 | after they themselves are reloaded. This is important; | |
2941 | we don't want our own handling of unoffsettables | |
2942 | to override the handling of reg_equiv_address. */ | |
2943 | && !(GET_CODE (XEXP (operand, 0)) == REG | |
2944 | && (ind_levels == 0 | |
2945 | || reg_equiv_address[REGNO (XEXP (operand, 0))] != 0))) | |
2946 | win = 1; | |
2947 | break; | |
2948 | ||
2949 | /* Memory operand whose address is offsettable. */ | |
2950 | case 'o': | |
2951 | if (force_reload) | |
2952 | break; | |
2953 | if ((GET_CODE (operand) == MEM | |
2954 | /* If IND_LEVELS, find_reloads_address won't reload a | |
2955 | pseudo that didn't get a hard reg, so we have to | |
2956 | reject that case. */ | |
2957 | && (ind_levels ? offsettable_memref_p (operand) | |
2958 | : offsettable_nonstrict_memref_p (operand))) | |
26ba4aee JW |
2959 | /* A reloaded auto-increment address is offsettable, |
2960 | because it is now just a simple register indirect. */ | |
2961 | || (GET_CODE (operand) == MEM | |
2962 | && address_reloaded[i] | |
2963 | && (GET_CODE (XEXP (operand, 0)) == PRE_INC | |
2964 | || GET_CODE (XEXP (operand, 0)) == PRE_DEC | |
2965 | || GET_CODE (XEXP (operand, 0)) == POST_INC | |
2966 | || GET_CODE (XEXP (operand, 0)) == POST_DEC)) | |
eab89b90 RK |
2967 | /* Certain mem addresses will become offsettable |
2968 | after they themselves are reloaded. This is important; | |
2969 | we don't want our own handling of unoffsettables | |
2970 | to override the handling of reg_equiv_address. */ | |
2971 | || (GET_CODE (operand) == MEM | |
2972 | && GET_CODE (XEXP (operand, 0)) == REG | |
2973 | && (ind_levels == 0 | |
2974 | || reg_equiv_address[REGNO (XEXP (operand, 0))] != 0)) | |
2975 | || (GET_CODE (operand) == REG | |
2976 | && REGNO (operand) >= FIRST_PSEUDO_REGISTER | |
3a322c50 RK |
2977 | && reg_renumber[REGNO (operand)] < 0 |
2978 | /* If reg_equiv_address is nonzero, we will be | |
2979 | loading it into a register; hence it will be | |
2980 | offsettable, but we cannot say that reg_equiv_mem | |
2981 | is offsettable without checking. */ | |
2982 | && ((reg_equiv_mem[REGNO (operand)] != 0 | |
2983 | && offsettable_memref_p (reg_equiv_mem[REGNO (operand)])) | |
2984 | || (reg_equiv_address[REGNO (operand)] != 0)))) | |
eab89b90 RK |
2985 | win = 1; |
2986 | if (CONSTANT_P (operand) || GET_CODE (operand) == MEM) | |
2987 | badop = 0; | |
9d926da5 | 2988 | constmemok = 1; |
eab89b90 RK |
2989 | offmemok = 1; |
2990 | break; | |
2991 | ||
2992 | case '&': | |
2993 | /* Output operand that is stored before the need for the | |
2994 | input operands (and their index registers) is over. */ | |
2995 | earlyclobber = 1, this_earlyclobber = 1; | |
2996 | break; | |
2997 | ||
2998 | case 'E': | |
293166be | 2999 | #ifndef REAL_ARITHMETIC |
eab89b90 RK |
3000 | /* Match any floating double constant, but only if |
3001 | we can examine the bits of it reliably. */ | |
3002 | if ((HOST_FLOAT_FORMAT != TARGET_FLOAT_FORMAT | |
fb3821f7 | 3003 | || HOST_BITS_PER_WIDE_INT != BITS_PER_WORD) |
eab89b90 RK |
3004 | && GET_MODE (operand) != VOIDmode && ! flag_pretend_float) |
3005 | break; | |
293166be | 3006 | #endif |
eab89b90 RK |
3007 | if (GET_CODE (operand) == CONST_DOUBLE) |
3008 | win = 1; | |
3009 | break; | |
3010 | ||
3011 | case 'F': | |
3012 | if (GET_CODE (operand) == CONST_DOUBLE) | |
3013 | win = 1; | |
3014 | break; | |
3015 | ||
3016 | case 'G': | |
3017 | case 'H': | |
3018 | if (GET_CODE (operand) == CONST_DOUBLE | |
3019 | && CONST_DOUBLE_OK_FOR_LETTER_P (operand, c)) | |
3020 | win = 1; | |
3021 | break; | |
3022 | ||
3023 | case 's': | |
3024 | if (GET_CODE (operand) == CONST_INT | |
3025 | || (GET_CODE (operand) == CONST_DOUBLE | |
3026 | && GET_MODE (operand) == VOIDmode)) | |
3027 | break; | |
3028 | case 'i': | |
3029 | if (CONSTANT_P (operand) | |
3030 | #ifdef LEGITIMATE_PIC_OPERAND_P | |
3031 | && (! flag_pic || LEGITIMATE_PIC_OPERAND_P (operand)) | |
3032 | #endif | |
3033 | ) | |
3034 | win = 1; | |
3035 | break; | |
3036 | ||
3037 | case 'n': | |
3038 | if (GET_CODE (operand) == CONST_INT | |
3039 | || (GET_CODE (operand) == CONST_DOUBLE | |
3040 | && GET_MODE (operand) == VOIDmode)) | |
3041 | win = 1; | |
3042 | break; | |
3043 | ||
3044 | case 'I': | |
3045 | case 'J': | |
3046 | case 'K': | |
3047 | case 'L': | |
3048 | case 'M': | |
3049 | case 'N': | |
3050 | case 'O': | |
3051 | case 'P': | |
3052 | if (GET_CODE (operand) == CONST_INT | |
3053 | && CONST_OK_FOR_LETTER_P (INTVAL (operand), c)) | |
3054 | win = 1; | |
3055 | break; | |
3056 | ||
3057 | case 'X': | |
3058 | win = 1; | |
3059 | break; | |
3060 | ||
3061 | case 'g': | |
3062 | if (! force_reload | |
3063 | /* A PLUS is never a valid operand, but reload can make | |
3064 | it from a register when eliminating registers. */ | |
3065 | && GET_CODE (operand) != PLUS | |
3066 | /* A SCRATCH is not a valid operand. */ | |
3067 | && GET_CODE (operand) != SCRATCH | |
3068 | #ifdef LEGITIMATE_PIC_OPERAND_P | |
3069 | && (! CONSTANT_P (operand) | |
3070 | || ! flag_pic | |
3071 | || LEGITIMATE_PIC_OPERAND_P (operand)) | |
3072 | #endif | |
3073 | && (GENERAL_REGS == ALL_REGS | |
3074 | || GET_CODE (operand) != REG | |
3075 | || (REGNO (operand) >= FIRST_PSEUDO_REGISTER | |
3076 | && reg_renumber[REGNO (operand)] < 0))) | |
3077 | win = 1; | |
3078 | /* Drop through into 'r' case */ | |
3079 | ||
3080 | case 'r': | |
3081 | this_alternative[i] | |
3082 | = (int) reg_class_subunion[this_alternative[i]][(int) GENERAL_REGS]; | |
3083 | goto reg; | |
3084 | ||
3085 | #ifdef EXTRA_CONSTRAINT | |
3086 | case 'Q': | |
3087 | case 'R': | |
3088 | case 'S': | |
3089 | case 'T': | |
3090 | case 'U': | |
3091 | if (EXTRA_CONSTRAINT (operand, c)) | |
3092 | win = 1; | |
3093 | break; | |
3094 | #endif | |
3095 | ||
3096 | default: | |
3097 | this_alternative[i] | |
3098 | = (int) reg_class_subunion[this_alternative[i]][(int) REG_CLASS_FROM_LETTER (c)]; | |
3099 | ||
3100 | reg: | |
3101 | if (GET_MODE (operand) == BLKmode) | |
3102 | break; | |
3103 | winreg = 1; | |
3104 | if (GET_CODE (operand) == REG | |
3105 | && reg_fits_class_p (operand, this_alternative[i], | |
3106 | offset, GET_MODE (recog_operand[i]))) | |
3107 | win = 1; | |
3108 | break; | |
3109 | } | |
3110 | ||
3111 | constraints[i] = p; | |
3112 | ||
3113 | /* If this operand could be handled with a reg, | |
3114 | and some reg is allowed, then this operand can be handled. */ | |
3115 | if (winreg && this_alternative[i] != (int) NO_REGS) | |
3116 | badop = 0; | |
3117 | ||
3118 | /* Record which operands fit this alternative. */ | |
3119 | this_alternative_earlyclobber[i] = earlyclobber; | |
3120 | if (win && ! force_reload) | |
3121 | this_alternative_win[i] = 1; | |
3122 | else | |
3123 | { | |
9d926da5 RK |
3124 | int const_to_mem = 0; |
3125 | ||
eab89b90 RK |
3126 | this_alternative_offmemok[i] = offmemok; |
3127 | losers++; | |
3128 | if (badop) | |
3129 | bad = 1; | |
3130 | /* Alternative loses if it has no regs for a reg operand. */ | |
3131 | if (GET_CODE (operand) == REG | |
3132 | && this_alternative[i] == (int) NO_REGS | |
3133 | && this_alternative_matches[i] < 0) | |
3134 | bad = 1; | |
3135 | ||
3136 | /* Alternative loses if it requires a type of reload not | |
3137 | permitted for this insn. We can always reload SCRATCH | |
3138 | and objects with a REG_UNUSED note. */ | |
a8c9daeb RK |
3139 | if (GET_CODE (operand) != SCRATCH |
3140 | && modified[i] != RELOAD_READ && no_output_reloads | |
eab89b90 RK |
3141 | && ! find_reg_note (insn, REG_UNUSED, operand)) |
3142 | bad = 1; | |
3143 | else if (modified[i] != RELOAD_WRITE && no_input_reloads) | |
3144 | bad = 1; | |
3145 | ||
3a322c50 RK |
3146 | /* If this is a constant that is reloaded into the desired |
3147 | class by copying it to memory first, count that as another | |
3148 | reload. This is consistent with other code and is | |
293166be | 3149 | required to avoid choosing another alternative when |
3a322c50 RK |
3150 | the constant is moved into memory by this function on |
3151 | an early reload pass. Note that the test here is | |
3152 | precisely the same as in the code below that calls | |
3153 | force_const_mem. */ | |
3154 | if (CONSTANT_P (operand) | |
59f25cf9 RK |
3155 | /* force_const_mem does not accept HIGH. */ |
3156 | && GET_CODE (operand) != HIGH | |
3a322c50 RK |
3157 | && (PREFERRED_RELOAD_CLASS (operand, |
3158 | (enum reg_class) this_alternative[i]) | |
3159 | == NO_REGS) | |
3a322c50 | 3160 | && operand_mode[i] != VOIDmode) |
9d926da5 RK |
3161 | { |
3162 | const_to_mem = 1; | |
3163 | if (this_alternative[i] != (int) NO_REGS) | |
3164 | losers++; | |
3165 | } | |
3a322c50 | 3166 | |
5e6aa513 RK |
3167 | /* If we can't reload this value at all, reject this |
3168 | alternative. Note that we could also lose due to | |
3169 | LIMIT_RELOAD_RELOAD_CLASS, but we don't check that | |
3170 | here. */ | |
3171 | ||
3172 | if (! CONSTANT_P (operand) | |
73b236b5 | 3173 | && (enum reg_class) this_alternative[i] != NO_REGS |
5e6aa513 RK |
3174 | && (PREFERRED_RELOAD_CLASS (operand, |
3175 | (enum reg_class) this_alternative[i]) | |
3176 | == NO_REGS)) | |
3177 | bad = 1; | |
3178 | ||
eab89b90 RK |
3179 | /* We prefer to reload pseudos over reloading other things, |
3180 | since such reloads may be able to be eliminated later. | |
3181 | If we are reloading a SCRATCH, we won't be generating any | |
3182 | insns, just using a register, so it is also preferred. | |
9d926da5 RK |
3183 | So bump REJECT in other cases. Don't do this in the |
3184 | case where we are forcing a constant into memory and | |
3185 | it will then win since we don't want to have a different | |
3186 | alternative match then. */ | |
915bb763 RK |
3187 | if (! (GET_CODE (operand) == REG |
3188 | && REGNO (operand) >= FIRST_PSEUDO_REGISTER) | |
9d926da5 RK |
3189 | && GET_CODE (operand) != SCRATCH |
3190 | && ! (const_to_mem && constmemok)) | |
eab89b90 RK |
3191 | reject++; |
3192 | } | |
3193 | ||
3194 | /* If this operand is a pseudo register that didn't get a hard | |
3195 | reg and this alternative accepts some register, see if the | |
3196 | class that we want is a subset of the preferred class for this | |
3197 | register. If not, but it intersects that class, use the | |
3198 | preferred class instead. If it does not intersect the preferred | |
3199 | class, show that usage of this alternative should be discouraged; | |
3200 | it will be discouraged more still if the register is `preferred | |
3201 | or nothing'. We do this because it increases the chance of | |
3202 | reusing our spill register in a later insn and avoiding a pair | |
3203 | of memory stores and loads. | |
3204 | ||
3205 | Don't bother with this if this alternative will accept this | |
3206 | operand. | |
3207 | ||
a2d353e5 RK |
3208 | Don't do this for a multiword operand, since it is only a |
3209 | small win and has the risk of requiring more spill registers, | |
3210 | which could cause a large loss. | |
5aa14fee | 3211 | |
eab89b90 RK |
3212 | Don't do this if the preferred class has only one register |
3213 | because we might otherwise exhaust the class. */ | |
3214 | ||
3215 | ||
3216 | if (! win && this_alternative[i] != (int) NO_REGS | |
5aa14fee | 3217 | && GET_MODE_SIZE (operand_mode[i]) <= UNITS_PER_WORD |
eab89b90 RK |
3218 | && reg_class_size[(int) preferred_class[i]] > 1) |
3219 | { | |
3220 | if (! reg_class_subset_p (this_alternative[i], | |
3221 | preferred_class[i])) | |
3222 | { | |
3223 | /* Since we don't have a way of forming the intersection, | |
3224 | we just do something special if the preferred class | |
3225 | is a subset of the class we have; that's the most | |
3226 | common case anyway. */ | |
3227 | if (reg_class_subset_p (preferred_class[i], | |
3228 | this_alternative[i])) | |
3229 | this_alternative[i] = (int) preferred_class[i]; | |
3230 | else | |
3231 | reject += (1 + pref_or_nothing[i]); | |
3232 | } | |
3233 | } | |
3234 | } | |
3235 | ||
3236 | /* Now see if any output operands that are marked "earlyclobber" | |
3237 | in this alternative conflict with any input operands | |
3238 | or any memory addresses. */ | |
3239 | ||
3240 | for (i = 0; i < noperands; i++) | |
3241 | if (this_alternative_earlyclobber[i] | |
3242 | && this_alternative_win[i]) | |
3243 | { | |
3244 | struct decomposition early_data; | |
eab89b90 RK |
3245 | |
3246 | early_data = decompose (recog_operand[i]); | |
3247 | ||
3248 | if (modified[i] == RELOAD_READ) | |
3249 | { | |
3250 | if (this_insn_is_asm) | |
3251 | warning_for_asm (this_insn, | |
3252 | "`&' constraint used with input operand"); | |
3253 | else | |
3254 | abort (); | |
3255 | continue; | |
3256 | } | |
3257 | ||
3258 | if (this_alternative[i] == NO_REGS) | |
3259 | { | |
3260 | this_alternative_earlyclobber[i] = 0; | |
3261 | if (this_insn_is_asm) | |
3262 | error_for_asm (this_insn, | |
3263 | "`&' constraint used with no register class"); | |
3264 | else | |
3265 | abort (); | |
3266 | } | |
3267 | ||
3268 | for (j = 0; j < noperands; j++) | |
3269 | /* Is this an input operand or a memory ref? */ | |
3270 | if ((GET_CODE (recog_operand[j]) == MEM | |
3271 | || modified[j] != RELOAD_WRITE) | |
3272 | && j != i | |
3273 | /* Ignore things like match_operator operands. */ | |
3274 | && *constraints1[j] != 0 | |
3275 | /* Don't count an input operand that is constrained to match | |
3276 | the early clobber operand. */ | |
3277 | && ! (this_alternative_matches[j] == i | |
3278 | && rtx_equal_p (recog_operand[i], recog_operand[j])) | |
3279 | /* Is it altered by storing the earlyclobber operand? */ | |
3280 | && !immune_p (recog_operand[j], recog_operand[i], early_data)) | |
3281 | { | |
3282 | /* If the output is in a single-reg class, | |
3283 | it's costly to reload it, so reload the input instead. */ | |
3284 | if (reg_class_size[this_alternative[i]] == 1 | |
3285 | && (GET_CODE (recog_operand[j]) == REG | |
3286 | || GET_CODE (recog_operand[j]) == SUBREG)) | |
3287 | { | |
3288 | losers++; | |
3289 | this_alternative_win[j] = 0; | |
3290 | } | |
3291 | else | |
3292 | break; | |
3293 | } | |
3294 | /* If an earlyclobber operand conflicts with something, | |
3295 | it must be reloaded, so request this and count the cost. */ | |
3296 | if (j != noperands) | |
3297 | { | |
3298 | losers++; | |
3299 | this_alternative_win[i] = 0; | |
3300 | for (j = 0; j < noperands; j++) | |
3301 | if (this_alternative_matches[j] == i | |
3302 | && this_alternative_win[j]) | |
3303 | { | |
3304 | this_alternative_win[j] = 0; | |
3305 | losers++; | |
3306 | } | |
3307 | } | |
3308 | } | |
3309 | ||
3310 | /* If one alternative accepts all the operands, no reload required, | |
3311 | choose that alternative; don't consider the remaining ones. */ | |
3312 | if (losers == 0) | |
3313 | { | |
3314 | /* Unswap these so that they are never swapped at `finish'. */ | |
3315 | if (commutative >= 0) | |
3316 | { | |
3317 | recog_operand[commutative] = substed_operand[commutative]; | |
3318 | recog_operand[commutative + 1] | |
3319 | = substed_operand[commutative + 1]; | |
3320 | } | |
3321 | for (i = 0; i < noperands; i++) | |
3322 | { | |
3323 | goal_alternative_win[i] = 1; | |
3324 | goal_alternative[i] = this_alternative[i]; | |
3325 | goal_alternative_offmemok[i] = this_alternative_offmemok[i]; | |
3326 | goal_alternative_matches[i] = this_alternative_matches[i]; | |
3327 | goal_alternative_earlyclobber[i] | |
3328 | = this_alternative_earlyclobber[i]; | |
3329 | } | |
3330 | goal_alternative_number = this_alternative_number; | |
3331 | goal_alternative_swapped = swapped; | |
3332 | goal_earlyclobber = this_earlyclobber; | |
3333 | goto finish; | |
3334 | } | |
3335 | ||
3336 | /* REJECT, set by the ! and ? constraint characters and when a register | |
3337 | would be reloaded into a non-preferred class, discourages the use of | |
3338 | this alternative for a reload goal. REJECT is incremented by three | |
3339 | for each ? and one for each non-preferred class. */ | |
3340 | losers = losers * 3 + reject; | |
3341 | ||
3342 | /* If this alternative can be made to work by reloading, | |
3343 | and it needs less reloading than the others checked so far, | |
3344 | record it as the chosen goal for reloading. */ | |
3345 | if (! bad && best > losers) | |
3346 | { | |
3347 | for (i = 0; i < noperands; i++) | |
3348 | { | |
3349 | goal_alternative[i] = this_alternative[i]; | |
3350 | goal_alternative_win[i] = this_alternative_win[i]; | |
3351 | goal_alternative_offmemok[i] = this_alternative_offmemok[i]; | |
3352 | goal_alternative_matches[i] = this_alternative_matches[i]; | |
3353 | goal_alternative_earlyclobber[i] | |
3354 | = this_alternative_earlyclobber[i]; | |
3355 | } | |
3356 | goal_alternative_swapped = swapped; | |
3357 | best = losers; | |
3358 | goal_alternative_number = this_alternative_number; | |
3359 | goal_earlyclobber = this_earlyclobber; | |
3360 | } | |
3361 | } | |
3362 | ||
3363 | /* If insn is commutative (it's safe to exchange a certain pair of operands) | |
3364 | then we need to try each alternative twice, | |
3365 | the second time matching those two operands | |
3366 | as if we had exchanged them. | |
3367 | To do this, really exchange them in operands. | |
3368 | ||
3369 | If we have just tried the alternatives the second time, | |
3370 | return operands to normal and drop through. */ | |
3371 | ||
3372 | if (commutative >= 0) | |
3373 | { | |
3374 | swapped = !swapped; | |
3375 | if (swapped) | |
3376 | { | |
3377 | register enum reg_class tclass; | |
3378 | register int t; | |
3379 | ||
3380 | recog_operand[commutative] = substed_operand[commutative + 1]; | |
3381 | recog_operand[commutative + 1] = substed_operand[commutative]; | |
3382 | ||
3383 | tclass = preferred_class[commutative]; | |
3384 | preferred_class[commutative] = preferred_class[commutative + 1]; | |
3385 | preferred_class[commutative + 1] = tclass; | |
3386 | ||
3387 | t = pref_or_nothing[commutative]; | |
3388 | pref_or_nothing[commutative] = pref_or_nothing[commutative + 1]; | |
3389 | pref_or_nothing[commutative + 1] = t; | |
3390 | ||
4c9a05bc RK |
3391 | bcopy ((char *) constraints1, (char *) constraints, |
3392 | noperands * sizeof (char *)); | |
eab89b90 RK |
3393 | goto try_swapped; |
3394 | } | |
3395 | else | |
3396 | { | |
3397 | recog_operand[commutative] = substed_operand[commutative]; | |
3398 | recog_operand[commutative + 1] = substed_operand[commutative + 1]; | |
3399 | } | |
3400 | } | |
3401 | ||
3402 | /* The operands don't meet the constraints. | |
3403 | goal_alternative describes the alternative | |
3404 | that we could reach by reloading the fewest operands. | |
3405 | Reload so as to fit it. */ | |
3406 | ||
3407 | if (best == MAX_RECOG_OPERANDS + 300) | |
3408 | { | |
3409 | /* No alternative works with reloads?? */ | |
3410 | if (insn_code_number >= 0) | |
3411 | abort (); | |
3412 | error_for_asm (insn, "inconsistent operand constraints in an `asm'"); | |
3413 | /* Avoid further trouble with this insn. */ | |
3414 | PATTERN (insn) = gen_rtx (USE, VOIDmode, const0_rtx); | |
3415 | n_reloads = 0; | |
3416 | return; | |
3417 | } | |
3418 | ||
3419 | /* Jump to `finish' from above if all operands are valid already. | |
3420 | In that case, goal_alternative_win is all 1. */ | |
3421 | finish: | |
3422 | ||
3423 | /* Right now, for any pair of operands I and J that are required to match, | |
3424 | with I < J, | |
3425 | goal_alternative_matches[J] is I. | |
3426 | Set up goal_alternative_matched as the inverse function: | |
3427 | goal_alternative_matched[I] = J. */ | |
3428 | ||
3429 | for (i = 0; i < noperands; i++) | |
3430 | goal_alternative_matched[i] = -1; | |
3431 | ||
3432 | for (i = 0; i < noperands; i++) | |
3433 | if (! goal_alternative_win[i] | |
3434 | && goal_alternative_matches[i] >= 0) | |
3435 | goal_alternative_matched[goal_alternative_matches[i]] = i; | |
3436 | ||
3437 | /* If the best alternative is with operands 1 and 2 swapped, | |
a8c9daeb RK |
3438 | consider them swapped before reporting the reloads. Update the |
3439 | operand numbers of any reloads already pushed. */ | |
eab89b90 RK |
3440 | |
3441 | if (goal_alternative_swapped) | |
3442 | { | |
3443 | register rtx tem; | |
3444 | ||
3445 | tem = substed_operand[commutative]; | |
3446 | substed_operand[commutative] = substed_operand[commutative + 1]; | |
3447 | substed_operand[commutative + 1] = tem; | |
3448 | tem = recog_operand[commutative]; | |
3449 | recog_operand[commutative] = recog_operand[commutative + 1]; | |
3450 | recog_operand[commutative + 1] = tem; | |
a8c9daeb RK |
3451 | |
3452 | for (i = 0; i < n_reloads; i++) | |
3453 | { | |
3454 | if (reload_opnum[i] == commutative) | |
3455 | reload_opnum[i] = commutative + 1; | |
3456 | else if (reload_opnum[i] == commutative + 1) | |
3457 | reload_opnum[i] = commutative; | |
3458 | } | |
eab89b90 RK |
3459 | } |
3460 | ||
3461 | /* Perform whatever substitutions on the operands we are supposed | |
3462 | to make due to commutativity or replacement of registers | |
3463 | with equivalent constants or memory slots. */ | |
3464 | ||
3465 | for (i = 0; i < noperands; i++) | |
3466 | { | |
3467 | *recog_operand_loc[i] = substed_operand[i]; | |
3468 | /* While we are looping on operands, initialize this. */ | |
3469 | operand_reloadnum[i] = -1; | |
a8c9daeb RK |
3470 | |
3471 | /* If this is an earlyclobber operand, we need to widen the scope. | |
3472 | The reload must remain valid from the start of the insn being | |
3473 | reloaded until after the operand is stored into its destination. | |
3474 | We approximate this with RELOAD_OTHER even though we know that we | |
3475 | do not conflict with RELOAD_FOR_INPUT_ADDRESS reloads. | |
3476 | ||
3477 | One special case that is worth checking is when we have an | |
3478 | output that is earlyclobber but isn't used past the insn (typically | |
3479 | a SCRATCH). In this case, we only need have the reload live | |
3480 | through the insn itself, but not for any of our input or output | |
3481 | reloads. | |
3482 | ||
3483 | In any case, anything needed to address this operand can remain | |
3484 | however they were previously categorized. */ | |
3485 | ||
3486 | if (goal_alternative_earlyclobber[i]) | |
3487 | operand_type[i] | |
3488 | = (find_reg_note (insn, REG_UNUSED, recog_operand[i]) | |
3489 | ? RELOAD_FOR_INSN : RELOAD_OTHER); | |
eab89b90 RK |
3490 | } |
3491 | ||
3492 | /* Any constants that aren't allowed and can't be reloaded | |
3493 | into registers are here changed into memory references. */ | |
3494 | for (i = 0; i < noperands; i++) | |
3495 | if (! goal_alternative_win[i] | |
3496 | && CONSTANT_P (recog_operand[i]) | |
59f25cf9 RK |
3497 | /* force_const_mem does not accept HIGH. */ |
3498 | && GET_CODE (recog_operand[i]) != HIGH | |
eab89b90 RK |
3499 | && (PREFERRED_RELOAD_CLASS (recog_operand[i], |
3500 | (enum reg_class) goal_alternative[i]) | |
3501 | == NO_REGS) | |
3502 | && operand_mode[i] != VOIDmode) | |
3503 | { | |
3504 | *recog_operand_loc[i] = recog_operand[i] | |
3505 | = find_reloads_toplev (force_const_mem (operand_mode[i], | |
3506 | recog_operand[i]), | |
a8c9daeb | 3507 | i, address_type[i], ind_levels, 0); |
eab89b90 RK |
3508 | if (alternative_allows_memconst (constraints1[i], |
3509 | goal_alternative_number)) | |
3510 | goal_alternative_win[i] = 1; | |
3511 | } | |
3512 | ||
4644aad4 RK |
3513 | /* Record the values of the earlyclobber operands for the caller. */ |
3514 | if (goal_earlyclobber) | |
3515 | for (i = 0; i < noperands; i++) | |
3516 | if (goal_alternative_earlyclobber[i]) | |
3517 | reload_earlyclobbers[n_earlyclobbers++] = recog_operand[i]; | |
3518 | ||
eab89b90 RK |
3519 | /* Now record reloads for all the operands that need them. */ |
3520 | for (i = 0; i < noperands; i++) | |
3521 | if (! goal_alternative_win[i]) | |
3522 | { | |
3523 | /* Operands that match previous ones have already been handled. */ | |
3524 | if (goal_alternative_matches[i] >= 0) | |
3525 | ; | |
3526 | /* Handle an operand with a nonoffsettable address | |
3527 | appearing where an offsettable address will do | |
3a322c50 RK |
3528 | by reloading the address into a base register. |
3529 | ||
3530 | ??? We can also do this when the operand is a register and | |
3531 | reg_equiv_mem is not offsettable, but this is a bit tricky, | |
3532 | so we don't bother with it. It may not be worth doing. */ | |
eab89b90 RK |
3533 | else if (goal_alternative_matched[i] == -1 |
3534 | && goal_alternative_offmemok[i] | |
3535 | && GET_CODE (recog_operand[i]) == MEM) | |
3536 | { | |
3537 | operand_reloadnum[i] | |
fb3821f7 CH |
3538 | = push_reload (XEXP (recog_operand[i], 0), NULL_RTX, |
3539 | &XEXP (recog_operand[i], 0), NULL_PTR, | |
eab89b90 | 3540 | BASE_REG_CLASS, GET_MODE (XEXP (recog_operand[i], 0)), |
a8c9daeb | 3541 | VOIDmode, 0, 0, i, RELOAD_FOR_INPUT); |
eab89b90 RK |
3542 | reload_inc[operand_reloadnum[i]] |
3543 | = GET_MODE_SIZE (GET_MODE (recog_operand[i])); | |
a8c9daeb RK |
3544 | |
3545 | /* If this operand is an output, we will have made any | |
3546 | reloads for its address as RELOAD_FOR_OUTPUT_ADDRESS, but | |
3547 | now we are treating part of the operand as an input, so | |
3548 | we must change these to RELOAD_FOR_INPUT_ADDRESS. */ | |
3549 | ||
2d55b7e8 | 3550 | if (modified[i] == RELOAD_WRITE) |
47c8cf91 ILT |
3551 | { |
3552 | for (j = 0; j < n_reloads; j++) | |
3553 | { | |
3554 | if (reload_opnum[j] == i) | |
3555 | { | |
3556 | if (reload_when_needed[j] == RELOAD_FOR_OUTPUT_ADDRESS) | |
3557 | reload_when_needed[j] = RELOAD_FOR_INPUT_ADDRESS; | |
3558 | else if (reload_when_needed[j] | |
3559 | == RELOAD_FOR_OUTADDR_ADDRESS) | |
3560 | reload_when_needed[j] = RELOAD_FOR_INPADDR_ADDRESS; | |
3561 | } | |
3562 | } | |
3563 | } | |
eab89b90 RK |
3564 | } |
3565 | else if (goal_alternative_matched[i] == -1) | |
3566 | operand_reloadnum[i] = | |
3567 | push_reload (modified[i] != RELOAD_WRITE ? recog_operand[i] : 0, | |
3568 | modified[i] != RELOAD_READ ? recog_operand[i] : 0, | |
a8c9daeb RK |
3569 | (modified[i] != RELOAD_WRITE ? |
3570 | recog_operand_loc[i] : 0), | |
eab89b90 RK |
3571 | modified[i] != RELOAD_READ ? recog_operand_loc[i] : 0, |
3572 | (enum reg_class) goal_alternative[i], | |
a8c9daeb RK |
3573 | (modified[i] == RELOAD_WRITE |
3574 | ? VOIDmode : operand_mode[i]), | |
3575 | (modified[i] == RELOAD_READ | |
3576 | ? VOIDmode : operand_mode[i]), | |
eab89b90 RK |
3577 | (insn_code_number < 0 ? 0 |
3578 | : insn_operand_strict_low[insn_code_number][i]), | |
a8c9daeb | 3579 | 0, i, operand_type[i]); |
eab89b90 RK |
3580 | /* In a matching pair of operands, one must be input only |
3581 | and the other must be output only. | |
3582 | Pass the input operand as IN and the other as OUT. */ | |
3583 | else if (modified[i] == RELOAD_READ | |
3584 | && modified[goal_alternative_matched[i]] == RELOAD_WRITE) | |
3585 | { | |
3586 | operand_reloadnum[i] | |
3587 | = push_reload (recog_operand[i], | |
3588 | recog_operand[goal_alternative_matched[i]], | |
3589 | recog_operand_loc[i], | |
3590 | recog_operand_loc[goal_alternative_matched[i]], | |
3591 | (enum reg_class) goal_alternative[i], | |
3592 | operand_mode[i], | |
3593 | operand_mode[goal_alternative_matched[i]], | |
a8c9daeb | 3594 | 0, 0, i, RELOAD_OTHER); |
eab89b90 RK |
3595 | operand_reloadnum[goal_alternative_matched[i]] = output_reloadnum; |
3596 | } | |
3597 | else if (modified[i] == RELOAD_WRITE | |
3598 | && modified[goal_alternative_matched[i]] == RELOAD_READ) | |
3599 | { | |
3600 | operand_reloadnum[goal_alternative_matched[i]] | |
3601 | = push_reload (recog_operand[goal_alternative_matched[i]], | |
3602 | recog_operand[i], | |
3603 | recog_operand_loc[goal_alternative_matched[i]], | |
3604 | recog_operand_loc[i], | |
3605 | (enum reg_class) goal_alternative[i], | |
3606 | operand_mode[goal_alternative_matched[i]], | |
3607 | operand_mode[i], | |
a8c9daeb | 3608 | 0, 0, i, RELOAD_OTHER); |
eab89b90 RK |
3609 | operand_reloadnum[i] = output_reloadnum; |
3610 | } | |
3611 | else if (insn_code_number >= 0) | |
3612 | abort (); | |
3613 | else | |
3614 | { | |
3615 | error_for_asm (insn, "inconsistent operand constraints in an `asm'"); | |
3616 | /* Avoid further trouble with this insn. */ | |
3617 | PATTERN (insn) = gen_rtx (USE, VOIDmode, const0_rtx); | |
3618 | n_reloads = 0; | |
3619 | return; | |
3620 | } | |
3621 | } | |
3622 | else if (goal_alternative_matched[i] < 0 | |
3623 | && goal_alternative_matches[i] < 0 | |
3624 | && optimize) | |
3625 | { | |
a8c9daeb | 3626 | /* For each non-matching operand that's a MEM or a pseudo-register |
eab89b90 RK |
3627 | that didn't get a hard register, make an optional reload. |
3628 | This may get done even if the insn needs no reloads otherwise. */ | |
a8c9daeb RK |
3629 | |
3630 | rtx operand = recog_operand[i]; | |
3631 | ||
eab89b90 RK |
3632 | while (GET_CODE (operand) == SUBREG) |
3633 | operand = XEXP (operand, 0); | |
a8c9daeb RK |
3634 | if ((GET_CODE (operand) == MEM |
3635 | || (GET_CODE (operand) == REG | |
3636 | && REGNO (operand) >= FIRST_PSEUDO_REGISTER)) | |
eab89b90 | 3637 | && (enum reg_class) goal_alternative[i] != NO_REGS |
a8c9daeb RK |
3638 | && ! no_input_reloads |
3639 | /* Optional output reloads don't do anything and we mustn't | |
3640 | make in-out reloads on insns that are not permitted output | |
3641 | reloads. */ | |
eab89b90 | 3642 | && (modified[i] == RELOAD_READ |
a8c9daeb | 3643 | || (modified[i] == RELOAD_READ_WRITE && ! no_output_reloads))) |
eab89b90 RK |
3644 | operand_reloadnum[i] |
3645 | = push_reload (modified[i] != RELOAD_WRITE ? recog_operand[i] : 0, | |
3646 | modified[i] != RELOAD_READ ? recog_operand[i] : 0, | |
a8c9daeb RK |
3647 | (modified[i] != RELOAD_WRITE |
3648 | ? recog_operand_loc[i] : 0), | |
3649 | (modified[i] != RELOAD_READ | |
3650 | ? recog_operand_loc[i] : 0), | |
eab89b90 | 3651 | (enum reg_class) goal_alternative[i], |
a8c9daeb RK |
3652 | (modified[i] == RELOAD_WRITE |
3653 | ? VOIDmode : operand_mode[i]), | |
3654 | (modified[i] == RELOAD_READ | |
3655 | ? VOIDmode : operand_mode[i]), | |
eab89b90 RK |
3656 | (insn_code_number < 0 ? 0 |
3657 | : insn_operand_strict_low[insn_code_number][i]), | |
a8c9daeb | 3658 | 1, i, operand_type[i]); |
eab89b90 | 3659 | } |
a8c9daeb RK |
3660 | else if (goal_alternative_matches[i] >= 0 |
3661 | && goal_alternative_win[goal_alternative_matches[i]] | |
3662 | && modified[i] == RELOAD_READ | |
3663 | && modified[goal_alternative_matches[i]] == RELOAD_WRITE | |
3664 | && ! no_input_reloads && ! no_output_reloads | |
3665 | && optimize) | |
3666 | { | |
3667 | /* Similarly, make an optional reload for a pair of matching | |
3668 | objects that are in MEM or a pseudo that didn't get a hard reg. */ | |
eab89b90 | 3669 | |
a8c9daeb RK |
3670 | rtx operand = recog_operand[i]; |
3671 | ||
3672 | while (GET_CODE (operand) == SUBREG) | |
3673 | operand = XEXP (operand, 0); | |
3674 | if ((GET_CODE (operand) == MEM | |
3675 | || (GET_CODE (operand) == REG | |
3676 | && REGNO (operand) >= FIRST_PSEUDO_REGISTER)) | |
3677 | && ((enum reg_class) goal_alternative[goal_alternative_matches[i]] | |
3678 | != NO_REGS)) | |
3679 | operand_reloadnum[i] = operand_reloadnum[goal_alternative_matches[i]] | |
3680 | = push_reload (recog_operand[goal_alternative_matches[i]], | |
3681 | recog_operand[i], | |
3682 | recog_operand_loc[goal_alternative_matches[i]], | |
3683 | recog_operand_loc[i], | |
3684 | (enum reg_class) goal_alternative[goal_alternative_matches[i]], | |
3685 | operand_mode[goal_alternative_matches[i]], | |
3686 | operand_mode[i], | |
3687 | 0, 1, goal_alternative_matches[i], RELOAD_OTHER); | |
3688 | } | |
3689 | ||
eab89b90 RK |
3690 | /* If this insn pattern contains any MATCH_DUP's, make sure that |
3691 | they will be substituted if the operands they match are substituted. | |
3692 | Also do now any substitutions we already did on the operands. | |
3693 | ||
3694 | Don't do this if we aren't making replacements because we might be | |
3695 | propagating things allocated by frame pointer elimination into places | |
3696 | it doesn't expect. */ | |
3697 | ||
3698 | if (insn_code_number >= 0 && replace) | |
3699 | for (i = insn_n_dups[insn_code_number] - 1; i >= 0; i--) | |
3700 | { | |
3701 | int opno = recog_dup_num[i]; | |
3702 | *recog_dup_loc[i] = *recog_operand_loc[opno]; | |
3703 | if (operand_reloadnum[opno] >= 0) | |
3704 | push_replacement (recog_dup_loc[i], operand_reloadnum[opno], | |
3705 | insn_operand_mode[insn_code_number][opno]); | |
3706 | } | |
3707 | ||
3708 | #if 0 | |
3709 | /* This loses because reloading of prior insns can invalidate the equivalence | |
3710 | (or at least find_equiv_reg isn't smart enough to find it any more), | |
3711 | causing this insn to need more reload regs than it needed before. | |
3712 | It may be too late to make the reload regs available. | |
3713 | Now this optimization is done safely in choose_reload_regs. */ | |
3714 | ||
3715 | /* For each reload of a reg into some other class of reg, | |
3716 | search for an existing equivalent reg (same value now) in the right class. | |
3717 | We can use it as long as we don't need to change its contents. */ | |
3718 | for (i = 0; i < n_reloads; i++) | |
3719 | if (reload_reg_rtx[i] == 0 | |
3720 | && reload_in[i] != 0 | |
3721 | && GET_CODE (reload_in[i]) == REG | |
3722 | && reload_out[i] == 0) | |
3723 | { | |
3724 | reload_reg_rtx[i] | |
3725 | = find_equiv_reg (reload_in[i], insn, reload_reg_class[i], -1, | |
3726 | static_reload_reg_p, 0, reload_inmode[i]); | |
3727 | /* Prevent generation of insn to load the value | |
3728 | because the one we found already has the value. */ | |
3729 | if (reload_reg_rtx[i]) | |
3730 | reload_in[i] = reload_reg_rtx[i]; | |
3731 | } | |
3732 | #endif | |
3733 | ||
a8c9daeb RK |
3734 | /* Perhaps an output reload can be combined with another |
3735 | to reduce needs by one. */ | |
3736 | if (!goal_earlyclobber) | |
3737 | combine_reloads (); | |
3738 | ||
3739 | /* If we have a pair of reloads for parts of an address, they are reloading | |
3740 | the same object, the operands themselves were not reloaded, and they | |
3741 | are for two operands that are supposed to match, merge the reloads and | |
0f41302f | 3742 | change the type of the surviving reload to RELOAD_FOR_OPERAND_ADDRESS. */ |
a8c9daeb RK |
3743 | |
3744 | for (i = 0; i < n_reloads; i++) | |
3745 | { | |
3746 | int k; | |
3747 | ||
3748 | for (j = i + 1; j < n_reloads; j++) | |
3749 | if ((reload_when_needed[i] == RELOAD_FOR_INPUT_ADDRESS | |
47c8cf91 ILT |
3750 | || reload_when_needed[i] == RELOAD_FOR_OUTPUT_ADDRESS |
3751 | || reload_when_needed[i] == RELOAD_FOR_INPADDR_ADDRESS | |
3752 | || reload_when_needed[i] == RELOAD_FOR_OUTADDR_ADDRESS) | |
a8c9daeb | 3753 | && (reload_when_needed[j] == RELOAD_FOR_INPUT_ADDRESS |
47c8cf91 ILT |
3754 | || reload_when_needed[j] == RELOAD_FOR_OUTPUT_ADDRESS |
3755 | || reload_when_needed[j] == RELOAD_FOR_INPADDR_ADDRESS | |
3756 | || reload_when_needed[j] == RELOAD_FOR_OUTADDR_ADDRESS) | |
a8c9daeb RK |
3757 | && rtx_equal_p (reload_in[i], reload_in[j]) |
3758 | && (operand_reloadnum[reload_opnum[i]] < 0 | |
3759 | || reload_optional[operand_reloadnum[reload_opnum[i]]]) | |
3760 | && (operand_reloadnum[reload_opnum[j]] < 0 | |
3761 | || reload_optional[operand_reloadnum[reload_opnum[j]]]) | |
3762 | && (goal_alternative_matches[reload_opnum[i]] == reload_opnum[j] | |
3763 | || (goal_alternative_matches[reload_opnum[j]] | |
3764 | == reload_opnum[i]))) | |
3765 | { | |
3766 | for (k = 0; k < n_replacements; k++) | |
3767 | if (replacements[k].what == j) | |
3768 | replacements[k].what = i; | |
3769 | ||
47c8cf91 ILT |
3770 | if (reload_when_needed[i] == RELOAD_FOR_INPADDR_ADDRESS |
3771 | || reload_when_needed[i] == RELOAD_FOR_OUTADDR_ADDRESS) | |
3772 | reload_when_needed[i] = RELOAD_FOR_OPADDR_ADDR; | |
3773 | else | |
3774 | reload_when_needed[i] = RELOAD_FOR_OPERAND_ADDRESS; | |
a8c9daeb RK |
3775 | reload_in[j] = 0; |
3776 | } | |
3777 | } | |
3778 | ||
3779 | /* Scan all the reloads and update their type. | |
3780 | If a reload is for the address of an operand and we didn't reload | |
3781 | that operand, change the type. Similarly, change the operand number | |
3782 | of a reload when two operands match. If a reload is optional, treat it | |
3783 | as though the operand isn't reloaded. | |
3784 | ||
3785 | ??? This latter case is somewhat odd because if we do the optional | |
3786 | reload, it means the object is hanging around. Thus we need only | |
3787 | do the address reload if the optional reload was NOT done. | |
3788 | ||
3789 | Change secondary reloads to be the address type of their operand, not | |
3790 | the normal type. | |
3791 | ||
3792 | If an operand's reload is now RELOAD_OTHER, change any | |
3793 | RELOAD_FOR_INPUT_ADDRESS reloads of that operand to | |
3794 | RELOAD_FOR_OTHER_ADDRESS. */ | |
3795 | ||
3796 | for (i = 0; i < n_reloads; i++) | |
3797 | { | |
3798 | if (reload_secondary_p[i] | |
3799 | && reload_when_needed[i] == operand_type[reload_opnum[i]]) | |
3800 | reload_when_needed[i] = address_type[reload_opnum[i]]; | |
3801 | ||
3802 | if ((reload_when_needed[i] == RELOAD_FOR_INPUT_ADDRESS | |
47c8cf91 ILT |
3803 | || reload_when_needed[i] == RELOAD_FOR_OUTPUT_ADDRESS |
3804 | || reload_when_needed[i] == RELOAD_FOR_INPADDR_ADDRESS | |
3805 | || reload_when_needed[i] == RELOAD_FOR_OUTADDR_ADDRESS) | |
a8c9daeb | 3806 | && (operand_reloadnum[reload_opnum[i]] < 0 |
6ded3228 | 3807 | || reload_optional[operand_reloadnum[reload_opnum[i]]])) |
f98bb7d3 RK |
3808 | { |
3809 | /* If we have a secondary reload to go along with this reload, | |
0f41302f | 3810 | change its type to RELOAD_FOR_OPADDR_ADDR. */ |
f98bb7d3 | 3811 | |
47c8cf91 ILT |
3812 | if ((reload_when_needed[i] == RELOAD_FOR_INPUT_ADDRESS |
3813 | || reload_when_needed[i] == RELOAD_FOR_INPADDR_ADDRESS) | |
f98bb7d3 RK |
3814 | && reload_secondary_in_reload[i] != -1) |
3815 | { | |
3816 | int secondary_in_reload = reload_secondary_in_reload[i]; | |
3817 | ||
3818 | reload_when_needed[secondary_in_reload] = | |
3819 | RELOAD_FOR_OPADDR_ADDR; | |
3820 | ||
0f41302f | 3821 | /* If there's a tertiary reload we have to change it also. */ |
f98bb7d3 RK |
3822 | if (secondary_in_reload > 0 |
3823 | && reload_secondary_in_reload[secondary_in_reload] != -1) | |
3824 | reload_when_needed[reload_secondary_in_reload[secondary_in_reload]] | |
3825 | = RELOAD_FOR_OPADDR_ADDR; | |
3826 | } | |
3827 | ||
47c8cf91 ILT |
3828 | if ((reload_when_needed[i] == RELOAD_FOR_OUTPUT_ADDRESS |
3829 | || reload_when_needed[i] == RELOAD_FOR_OUTADDR_ADDRESS) | |
f98bb7d3 RK |
3830 | && reload_secondary_out_reload[i] != -1) |
3831 | { | |
3832 | int secondary_out_reload = reload_secondary_out_reload[i]; | |
3833 | ||
3834 | reload_when_needed[secondary_out_reload] = | |
3835 | RELOAD_FOR_OPADDR_ADDR; | |
3836 | ||
0f41302f | 3837 | /* If there's a tertiary reload we have to change it also. */ |
f98bb7d3 RK |
3838 | if (secondary_out_reload |
3839 | && reload_secondary_out_reload[secondary_out_reload] != -1) | |
3840 | reload_when_needed[reload_secondary_out_reload[secondary_out_reload]] | |
3841 | = RELOAD_FOR_OPADDR_ADDR; | |
3842 | } | |
47c8cf91 ILT |
3843 | if (reload_when_needed[i] == RELOAD_FOR_INPADDR_ADDRESS |
3844 | || reload_when_needed[i] == RELOAD_FOR_OUTADDR_ADDRESS) | |
3845 | reload_when_needed[i] = RELOAD_FOR_OPADDR_ADDR; | |
3846 | else | |
3847 | reload_when_needed[i] = RELOAD_FOR_OPERAND_ADDRESS; | |
f98bb7d3 | 3848 | } |
a8c9daeb | 3849 | |
47c8cf91 ILT |
3850 | if ((reload_when_needed[i] == RELOAD_FOR_INPUT_ADDRESS |
3851 | || reload_when_needed[i] == RELOAD_FOR_INPADDR_ADDRESS) | |
a8c9daeb RK |
3852 | && operand_reloadnum[reload_opnum[i]] >= 0 |
3853 | && (reload_when_needed[operand_reloadnum[reload_opnum[i]]] | |
3854 | == RELOAD_OTHER)) | |
3855 | reload_when_needed[i] = RELOAD_FOR_OTHER_ADDRESS; | |
3856 | ||
3857 | if (goal_alternative_matches[reload_opnum[i]] >= 0) | |
3858 | reload_opnum[i] = goal_alternative_matches[reload_opnum[i]]; | |
3859 | } | |
3860 | ||
3861 | /* See if we have any reloads that are now allowed to be merged | |
3862 | because we've changed when the reload is needed to | |
3863 | RELOAD_FOR_OPERAND_ADDRESS or RELOAD_FOR_OTHER_ADDRESS. Only | |
3864 | check for the most common cases. */ | |
3865 | ||
3866 | for (i = 0; i < n_reloads; i++) | |
3867 | if (reload_in[i] != 0 && reload_out[i] == 0 | |
3868 | && (reload_when_needed[i] == RELOAD_FOR_OPERAND_ADDRESS | |
47c8cf91 | 3869 | || reload_when_needed[i] == RELOAD_FOR_OPADDR_ADDR |
a8c9daeb RK |
3870 | || reload_when_needed[i] == RELOAD_FOR_OTHER_ADDRESS)) |
3871 | for (j = 0; j < n_reloads; j++) | |
3872 | if (i != j && reload_in[j] != 0 && reload_out[j] == 0 | |
3873 | && reload_when_needed[j] == reload_when_needed[i] | |
73f67895 RS |
3874 | && MATCHES (reload_in[i], reload_in[j]) |
3875 | && reload_reg_class[i] == reload_reg_class[j] | |
92b37691 RK |
3876 | && !reload_nocombine[i] && !reload_nocombine[j] |
3877 | && reload_reg_rtx[i] == reload_reg_rtx[j]) | |
a8c9daeb RK |
3878 | { |
3879 | reload_opnum[i] = MIN (reload_opnum[i], reload_opnum[j]); | |
3880 | transfer_replacements (i, j); | |
3881 | reload_in[j] = 0; | |
3882 | } | |
3883 | ||
eab89b90 RK |
3884 | #else /* no REGISTER_CONSTRAINTS */ |
3885 | int noperands; | |
3886 | int insn_code_number; | |
3887 | int goal_earlyclobber = 0; /* Always 0, to make combine_reloads happen. */ | |
3888 | register int i; | |
3889 | rtx body = PATTERN (insn); | |
3890 | ||
3891 | n_reloads = 0; | |
3892 | n_replacements = 0; | |
3893 | n_earlyclobbers = 0; | |
3894 | replace_reloads = replace; | |
3895 | this_insn = insn; | |
3896 | ||
3897 | /* Find what kind of insn this is. NOPERANDS gets number of operands. | |
3898 | Store the operand values in RECOG_OPERAND and the locations | |
3899 | of the words in the insn that point to them in RECOG_OPERAND_LOC. | |
3900 | Return if the insn needs no reload processing. */ | |
3901 | ||
3902 | switch (GET_CODE (body)) | |
3903 | { | |
3904 | case USE: | |
3905 | case CLOBBER: | |
3906 | case ASM_INPUT: | |
3907 | case ADDR_VEC: | |
3908 | case ADDR_DIFF_VEC: | |
3909 | return; | |
3910 | ||
3911 | case PARALLEL: | |
3912 | case SET: | |
3913 | noperands = asm_noperands (body); | |
3914 | if (noperands >= 0) | |
3915 | { | |
3916 | /* This insn is an `asm' with operands. | |
3917 | First, find out how many operands, and allocate space. */ | |
3918 | ||
3919 | insn_code_number = -1; | |
3920 | /* ??? This is a bug! ??? | |
3921 | Give up and delete this insn if it has too many operands. */ | |
3922 | if (noperands > MAX_RECOG_OPERANDS) | |
3923 | abort (); | |
3924 | ||
3925 | /* Now get the operand values out of the insn. */ | |
3926 | ||
fb3821f7 CH |
3927 | decode_asm_operands (body, recog_operand, recog_operand_loc, |
3928 | NULL_PTR, NULL_PTR); | |
eab89b90 RK |
3929 | break; |
3930 | } | |
3931 | ||
3932 | default: | |
3933 | /* Ordinary insn: recognize it, allocate space for operands and | |
3934 | constraints, and get them out via insn_extract. */ | |
3935 | ||
3936 | insn_code_number = recog_memoized (insn); | |
3937 | noperands = insn_n_operands[insn_code_number]; | |
3938 | insn_extract (insn); | |
3939 | } | |
3940 | ||
3941 | if (noperands == 0) | |
3942 | return; | |
3943 | ||
3944 | for (i = 0; i < noperands; i++) | |
3945 | { | |
3946 | register RTX_CODE code = GET_CODE (recog_operand[i]); | |
3947 | int is_set_dest = GET_CODE (body) == SET && (i == 0); | |
3948 | ||
3949 | if (insn_code_number >= 0) | |
3950 | if (insn_operand_address_p[insn_code_number][i]) | |
fb3821f7 | 3951 | find_reloads_address (VOIDmode, NULL_PTR, |
eab89b90 | 3952 | recog_operand[i], recog_operand_loc[i], |
a8c9daeb RK |
3953 | i, RELOAD_FOR_INPUT, ind_levels); |
3954 | ||
3955 | /* In these cases, we can't tell if the operand is an input | |
3956 | or an output, so be conservative. In practice it won't be | |
3957 | problem. */ | |
3958 | ||
eab89b90 RK |
3959 | if (code == MEM) |
3960 | find_reloads_address (GET_MODE (recog_operand[i]), | |
3961 | recog_operand_loc[i], | |
3962 | XEXP (recog_operand[i], 0), | |
3963 | &XEXP (recog_operand[i], 0), | |
a8c9daeb | 3964 | i, RELOAD_OTHER, ind_levels); |
eab89b90 RK |
3965 | if (code == SUBREG) |
3966 | recog_operand[i] = *recog_operand_loc[i] | |
a8c9daeb RK |
3967 | = find_reloads_toplev (recog_operand[i], i, RELOAD_OTHER, |
3968 | ind_levels, is_set_dest); | |
eab89b90 RK |
3969 | if (code == REG) |
3970 | { | |
3971 | register int regno = REGNO (recog_operand[i]); | |
3972 | if (reg_equiv_constant[regno] != 0 && !is_set_dest) | |
3973 | recog_operand[i] = *recog_operand_loc[i] | |
3974 | = reg_equiv_constant[regno]; | |
3975 | #if 0 /* This might screw code in reload1.c to delete prior output-reload | |
3976 | that feeds this insn. */ | |
3977 | if (reg_equiv_mem[regno] != 0) | |
3978 | recog_operand[i] = *recog_operand_loc[i] | |
3979 | = reg_equiv_mem[regno]; | |
3980 | #endif | |
3981 | } | |
eab89b90 RK |
3982 | } |
3983 | ||
3984 | /* Perhaps an output reload can be combined with another | |
3985 | to reduce needs by one. */ | |
3986 | if (!goal_earlyclobber) | |
3987 | combine_reloads (); | |
a8c9daeb | 3988 | #endif /* no REGISTER_CONSTRAINTS */ |
eab89b90 RK |
3989 | } |
3990 | ||
3991 | /* Return 1 if alternative number ALTNUM in constraint-string CONSTRAINT | |
3992 | accepts a memory operand with constant address. */ | |
3993 | ||
3994 | static int | |
3995 | alternative_allows_memconst (constraint, altnum) | |
3996 | char *constraint; | |
3997 | int altnum; | |
3998 | { | |
3999 | register int c; | |
4000 | /* Skip alternatives before the one requested. */ | |
4001 | while (altnum > 0) | |
4002 | { | |
4003 | while (*constraint++ != ','); | |
4004 | altnum--; | |
4005 | } | |
4006 | /* Scan the requested alternative for 'm' or 'o'. | |
4007 | If one of them is present, this alternative accepts memory constants. */ | |
4008 | while ((c = *constraint++) && c != ',' && c != '#') | |
4009 | if (c == 'm' || c == 'o') | |
4010 | return 1; | |
4011 | return 0; | |
4012 | } | |
4013 | \f | |
4014 | /* Scan X for memory references and scan the addresses for reloading. | |
4015 | Also checks for references to "constant" regs that we want to eliminate | |
4016 | and replaces them with the values they stand for. | |
6dc42e49 | 4017 | We may alter X destructively if it contains a reference to such. |
eab89b90 RK |
4018 | If X is just a constant reg, we return the equivalent value |
4019 | instead of X. | |
4020 | ||
4021 | IND_LEVELS says how many levels of indirect addressing this machine | |
4022 | supports. | |
4023 | ||
a8c9daeb RK |
4024 | OPNUM and TYPE identify the purpose of the reload. |
4025 | ||
eab89b90 RK |
4026 | IS_SET_DEST is true if X is the destination of a SET, which is not |
4027 | appropriate to be replaced by a constant. */ | |
4028 | ||
4029 | static rtx | |
a8c9daeb | 4030 | find_reloads_toplev (x, opnum, type, ind_levels, is_set_dest) |
eab89b90 | 4031 | rtx x; |
a8c9daeb RK |
4032 | int opnum; |
4033 | enum reload_type type; | |
eab89b90 RK |
4034 | int ind_levels; |
4035 | int is_set_dest; | |
4036 | { | |
4037 | register RTX_CODE code = GET_CODE (x); | |
4038 | ||
4039 | register char *fmt = GET_RTX_FORMAT (code); | |
4040 | register int i; | |
4041 | ||
4042 | if (code == REG) | |
4043 | { | |
4044 | /* This code is duplicated for speed in find_reloads. */ | |
4045 | register int regno = REGNO (x); | |
4046 | if (reg_equiv_constant[regno] != 0 && !is_set_dest) | |
4047 | x = reg_equiv_constant[regno]; | |
4048 | #if 0 | |
4049 | /* This creates (subreg (mem...)) which would cause an unnecessary | |
4050 | reload of the mem. */ | |
4051 | else if (reg_equiv_mem[regno] != 0) | |
4052 | x = reg_equiv_mem[regno]; | |
4053 | #endif | |
4054 | else if (reg_equiv_address[regno] != 0) | |
4055 | { | |
4056 | /* If reg_equiv_address varies, it may be shared, so copy it. */ | |
4ffeab02 JW |
4057 | /* We must rerun eliminate_regs, in case the elimination |
4058 | offsets have changed. */ | |
4059 | rtx addr = XEXP (eliminate_regs (reg_equiv_memory_loc[regno], 0, | |
4060 | NULL_RTX), | |
4061 | 0); | |
eab89b90 RK |
4062 | |
4063 | if (rtx_varies_p (addr)) | |
4064 | addr = copy_rtx (addr); | |
4065 | ||
4066 | x = gen_rtx (MEM, GET_MODE (x), addr); | |
4067 | RTX_UNCHANGING_P (x) = RTX_UNCHANGING_P (regno_reg_rtx[regno]); | |
fb3821f7 | 4068 | find_reloads_address (GET_MODE (x), NULL_PTR, |
eab89b90 | 4069 | XEXP (x, 0), |
a8c9daeb | 4070 | &XEXP (x, 0), opnum, type, ind_levels); |
eab89b90 RK |
4071 | } |
4072 | return x; | |
4073 | } | |
4074 | if (code == MEM) | |
4075 | { | |
4076 | rtx tem = x; | |
4077 | find_reloads_address (GET_MODE (x), &tem, XEXP (x, 0), &XEXP (x, 0), | |
a8c9daeb | 4078 | opnum, type, ind_levels); |
eab89b90 RK |
4079 | return tem; |
4080 | } | |
4081 | ||
4082 | if (code == SUBREG && GET_CODE (SUBREG_REG (x)) == REG) | |
4083 | { | |
4084 | /* Check for SUBREG containing a REG that's equivalent to a constant. | |
4085 | If the constant has a known value, truncate it right now. | |
4086 | Similarly if we are extracting a single-word of a multi-word | |
4087 | constant. If the constant is symbolic, allow it to be substituted | |
4088 | normally. push_reload will strip the subreg later. If the | |
4089 | constant is VOIDmode, abort because we will lose the mode of | |
4090 | the register (this should never happen because one of the cases | |
4091 | above should handle it). */ | |
4092 | ||
4093 | register int regno = REGNO (SUBREG_REG (x)); | |
4094 | rtx tem; | |
4095 | ||
4096 | if (subreg_lowpart_p (x) | |
4097 | && regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] < 0 | |
4098 | && reg_equiv_constant[regno] != 0 | |
4099 | && (tem = gen_lowpart_common (GET_MODE (x), | |
4100 | reg_equiv_constant[regno])) != 0) | |
4101 | return tem; | |
4102 | ||
4103 | if (GET_MODE_BITSIZE (GET_MODE (x)) == BITS_PER_WORD | |
4104 | && regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] < 0 | |
4105 | && reg_equiv_constant[regno] != 0 | |
4106 | && (tem = operand_subword (reg_equiv_constant[regno], | |
4107 | SUBREG_WORD (x), 0, | |
4108 | GET_MODE (SUBREG_REG (x)))) != 0) | |
4109 | return tem; | |
4110 | ||
4111 | if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] < 0 | |
4112 | && reg_equiv_constant[regno] != 0 | |
4113 | && GET_MODE (reg_equiv_constant[regno]) == VOIDmode) | |
4114 | abort (); | |
4115 | ||
4116 | /* If the subreg contains a reg that will be converted to a mem, | |
4117 | convert the subreg to a narrower memref now. | |
4118 | Otherwise, we would get (subreg (mem ...) ...), | |
4119 | which would force reload of the mem. | |
4120 | ||
4121 | We also need to do this if there is an equivalent MEM that is | |
4122 | not offsettable. In that case, alter_subreg would produce an | |
4123 | invalid address on big-endian machines. | |
4124 | ||
46da6b3a | 4125 | For machines that extend byte loads, we must not reload using |
eab89b90 RK |
4126 | a wider mode if we have a paradoxical SUBREG. find_reloads will |
4127 | force a reload in that case. So we should not do anything here. */ | |
4128 | ||
4129 | else if (regno >= FIRST_PSEUDO_REGISTER | |
fd72420f | 4130 | #ifdef LOAD_EXTEND_OP |
eab89b90 RK |
4131 | && (GET_MODE_SIZE (GET_MODE (x)) |
4132 | <= GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))) | |
4133 | #endif | |
4134 | && (reg_equiv_address[regno] != 0 | |
4135 | || (reg_equiv_mem[regno] != 0 | |
f2fbfe92 JL |
4136 | && (! strict_memory_address_p (GET_MODE (x), |
4137 | XEXP (reg_equiv_mem[regno], 0)) | |
4138 | || ! offsettable_memref_p (reg_equiv_mem[regno]))))) | |
eab89b90 RK |
4139 | { |
4140 | int offset = SUBREG_WORD (x) * UNITS_PER_WORD; | |
4ffeab02 JW |
4141 | /* We must rerun eliminate_regs, in case the elimination |
4142 | offsets have changed. */ | |
4143 | rtx addr = XEXP (eliminate_regs (reg_equiv_memory_loc[regno], 0, | |
4144 | NULL_RTX), | |
4145 | 0); | |
f76b9db2 ILT |
4146 | if (BYTES_BIG_ENDIAN) |
4147 | { | |
4148 | int size; | |
4149 | size = GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))); | |
4150 | offset += MIN (size, UNITS_PER_WORD); | |
4151 | size = GET_MODE_SIZE (GET_MODE (x)); | |
4152 | offset -= MIN (size, UNITS_PER_WORD); | |
4153 | } | |
eab89b90 RK |
4154 | addr = plus_constant (addr, offset); |
4155 | x = gen_rtx (MEM, GET_MODE (x), addr); | |
4156 | RTX_UNCHANGING_P (x) = RTX_UNCHANGING_P (regno_reg_rtx[regno]); | |
fb3821f7 | 4157 | find_reloads_address (GET_MODE (x), NULL_PTR, |
eab89b90 | 4158 | XEXP (x, 0), |
a8c9daeb | 4159 | &XEXP (x, 0), opnum, type, ind_levels); |
eab89b90 RK |
4160 | } |
4161 | ||
4162 | } | |
4163 | ||
4164 | for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) | |
4165 | { | |
4166 | if (fmt[i] == 'e') | |
a8c9daeb | 4167 | XEXP (x, i) = find_reloads_toplev (XEXP (x, i), opnum, type, |
eab89b90 RK |
4168 | ind_levels, is_set_dest); |
4169 | } | |
4170 | return x; | |
4171 | } | |
4172 | ||
dbf85761 RS |
4173 | /* Return a mem ref for the memory equivalent of reg REGNO. |
4174 | This mem ref is not shared with anything. */ | |
4175 | ||
eab89b90 RK |
4176 | static rtx |
4177 | make_memloc (ad, regno) | |
4178 | rtx ad; | |
4179 | int regno; | |
4180 | { | |
4181 | register int i; | |
4ffeab02 JW |
4182 | /* We must rerun eliminate_regs, in case the elimination |
4183 | offsets have changed. */ | |
4184 | rtx tem = XEXP (eliminate_regs (reg_equiv_memory_loc[regno], 0, NULL_RTX), | |
4185 | 0); | |
dbf85761 RS |
4186 | |
4187 | #if 0 /* We cannot safely reuse a memloc made here; | |
4188 | if the pseudo appears twice, and its mem needs a reload, | |
4189 | it gets two separate reloads assigned, but it only | |
4190 | gets substituted with the second of them; | |
4191 | then it can get used before that reload reg gets loaded up. */ | |
eab89b90 RK |
4192 | for (i = 0; i < n_memlocs; i++) |
4193 | if (rtx_equal_p (tem, XEXP (memlocs[i], 0))) | |
4194 | return memlocs[i]; | |
dbf85761 | 4195 | #endif |
eab89b90 RK |
4196 | |
4197 | /* If TEM might contain a pseudo, we must copy it to avoid | |
4198 | modifying it when we do the substitution for the reload. */ | |
4199 | if (rtx_varies_p (tem)) | |
4200 | tem = copy_rtx (tem); | |
4201 | ||
4202 | tem = gen_rtx (MEM, GET_MODE (ad), tem); | |
4203 | RTX_UNCHANGING_P (tem) = RTX_UNCHANGING_P (regno_reg_rtx[regno]); | |
4204 | memlocs[n_memlocs++] = tem; | |
4205 | return tem; | |
4206 | } | |
4207 | ||
4208 | /* Record all reloads needed for handling memory address AD | |
4209 | which appears in *LOC in a memory reference to mode MODE | |
4210 | which itself is found in location *MEMREFLOC. | |
4211 | Note that we take shortcuts assuming that no multi-reg machine mode | |
4212 | occurs as part of an address. | |
4213 | ||
a8c9daeb | 4214 | OPNUM and TYPE specify the purpose of this reload. |
eab89b90 RK |
4215 | |
4216 | IND_LEVELS says how many levels of indirect addressing this machine | |
4217 | supports. | |
4218 | ||
4219 | Value is nonzero if this address is reloaded or replaced as a whole. | |
4220 | This is interesting to the caller if the address is an autoincrement. | |
4221 | ||
4222 | Note that there is no verification that the address will be valid after | |
4223 | this routine does its work. Instead, we rely on the fact that the address | |
4224 | was valid when reload started. So we need only undo things that reload | |
4225 | could have broken. These are wrong register types, pseudos not allocated | |
4226 | to a hard register, and frame pointer elimination. */ | |
4227 | ||
4228 | static int | |
a8c9daeb | 4229 | find_reloads_address (mode, memrefloc, ad, loc, opnum, type, ind_levels) |
eab89b90 RK |
4230 | enum machine_mode mode; |
4231 | rtx *memrefloc; | |
4232 | rtx ad; | |
4233 | rtx *loc; | |
a8c9daeb RK |
4234 | int opnum; |
4235 | enum reload_type type; | |
eab89b90 RK |
4236 | int ind_levels; |
4237 | { | |
4238 | register int regno; | |
4239 | rtx tem; | |
4240 | ||
4241 | /* If the address is a register, see if it is a legitimate address and | |
4242 | reload if not. We first handle the cases where we need not reload | |
4243 | or where we must reload in a non-standard way. */ | |
4244 | ||
4245 | if (GET_CODE (ad) == REG) | |
4246 | { | |
4247 | regno = REGNO (ad); | |
4248 | ||
4249 | if (reg_equiv_constant[regno] != 0 | |
4250 | && strict_memory_address_p (mode, reg_equiv_constant[regno])) | |
4251 | { | |
4252 | *loc = ad = reg_equiv_constant[regno]; | |
4253 | return 1; | |
4254 | } | |
4255 | ||
4256 | else if (reg_equiv_address[regno] != 0) | |
4257 | { | |
4258 | tem = make_memloc (ad, regno); | |
fb3821f7 | 4259 | find_reloads_address (GET_MODE (tem), NULL_PTR, XEXP (tem, 0), |
47c8cf91 ILT |
4260 | &XEXP (tem, 0), opnum, ADDR_TYPE (type), |
4261 | ind_levels); | |
1ba61f4e ILT |
4262 | push_reload (tem, NULL_RTX, loc, NULL_PTR, |
4263 | reload_address_base_reg_class, | |
eab89b90 | 4264 | GET_MODE (ad), VOIDmode, 0, 0, |
a8c9daeb | 4265 | opnum, type); |
eab89b90 RK |
4266 | return 1; |
4267 | } | |
4268 | ||
b39555b4 | 4269 | /* We can avoid a reload if the register's equivalent memory expression |
c1875d66 RS |
4270 | is valid as an indirect memory address. |
4271 | But not all addresses are valid in a mem used as an indirect address: | |
4272 | only reg or reg+constant. */ | |
b39555b4 RS |
4273 | |
4274 | else if (reg_equiv_mem[regno] != 0 && ind_levels > 0 | |
c1875d66 RS |
4275 | && strict_memory_address_p (mode, reg_equiv_mem[regno]) |
4276 | && (GET_CODE (XEXP (reg_equiv_mem[regno], 0)) == REG | |
4277 | || (GET_CODE (XEXP (reg_equiv_mem[regno], 0)) == PLUS | |
4278 | && GET_CODE (XEXP (XEXP (reg_equiv_mem[regno], 0), 0)) == REG | |
75301d68 | 4279 | && CONSTANT_P (XEXP (XEXP (reg_equiv_mem[regno], 0), 1))))) |
b39555b4 | 4280 | return 0; |
eab89b90 RK |
4281 | |
4282 | /* The only remaining case where we can avoid a reload is if this is a | |
4283 | hard register that is valid as a base register and which is not the | |
4284 | subject of a CLOBBER in this insn. */ | |
4285 | ||
858c3c8c ILT |
4286 | else if (regno < FIRST_PSEUDO_REGISTER |
4287 | && REGNO_MODE_OK_FOR_BASE_P (regno, mode) | |
eab89b90 RK |
4288 | && ! regno_clobbered_p (regno, this_insn)) |
4289 | return 0; | |
4290 | ||
4291 | /* If we do not have one of the cases above, we must do the reload. */ | |
1ba61f4e | 4292 | push_reload (ad, NULL_RTX, loc, NULL_PTR, reload_address_base_reg_class, |
a8c9daeb | 4293 | GET_MODE (ad), VOIDmode, 0, 0, opnum, type); |
eab89b90 RK |
4294 | return 1; |
4295 | } | |
4296 | ||
4297 | if (strict_memory_address_p (mode, ad)) | |
4298 | { | |
4299 | /* The address appears valid, so reloads are not needed. | |
4300 | But the address may contain an eliminable register. | |
4301 | This can happen because a machine with indirect addressing | |
4302 | may consider a pseudo register by itself a valid address even when | |
4303 | it has failed to get a hard reg. | |
4304 | So do a tree-walk to find and eliminate all such regs. */ | |
4305 | ||
4306 | /* But first quickly dispose of a common case. */ | |
4307 | if (GET_CODE (ad) == PLUS | |
4308 | && GET_CODE (XEXP (ad, 1)) == CONST_INT | |
4309 | && GET_CODE (XEXP (ad, 0)) == REG | |
4310 | && reg_equiv_constant[REGNO (XEXP (ad, 0))] == 0) | |
4311 | return 0; | |
4312 | ||
4313 | subst_reg_equivs_changed = 0; | |
4314 | *loc = subst_reg_equivs (ad); | |
4315 | ||
4316 | if (! subst_reg_equivs_changed) | |
4317 | return 0; | |
4318 | ||
4319 | /* Check result for validity after substitution. */ | |
4320 | if (strict_memory_address_p (mode, ad)) | |
4321 | return 0; | |
4322 | } | |
4323 | ||
4324 | /* The address is not valid. We have to figure out why. One possibility | |
4325 | is that it is itself a MEM. This can happen when the frame pointer is | |
4326 | being eliminated, a pseudo is not allocated to a hard register, and the | |
4327 | offset between the frame and stack pointers is not its initial value. | |
d45cf215 | 4328 | In that case the pseudo will have been replaced by a MEM referring to |
eab89b90 RK |
4329 | the stack pointer. */ |
4330 | if (GET_CODE (ad) == MEM) | |
4331 | { | |
4332 | /* First ensure that the address in this MEM is valid. Then, unless | |
4333 | indirect addresses are valid, reload the MEM into a register. */ | |
4334 | tem = ad; | |
4335 | find_reloads_address (GET_MODE (ad), &tem, XEXP (ad, 0), &XEXP (ad, 0), | |
47c8cf91 ILT |
4336 | opnum, ADDR_TYPE (type), |
4337 | ind_levels == 0 ? 0 : ind_levels - 1); | |
d2555454 RS |
4338 | |
4339 | /* If tem was changed, then we must create a new memory reference to | |
4340 | hold it and store it back into memrefloc. */ | |
4341 | if (tem != ad && memrefloc) | |
ca3e4a2f | 4342 | { |
ca3e4a2f | 4343 | *memrefloc = copy_rtx (*memrefloc); |
3c80f7ed | 4344 | copy_replacements (tem, XEXP (*memrefloc, 0)); |
ca3e4a2f | 4345 | loc = &XEXP (*memrefloc, 0); |
ca3e4a2f | 4346 | } |
d2555454 | 4347 | |
eab89b90 RK |
4348 | /* Check similar cases as for indirect addresses as above except |
4349 | that we can allow pseudos and a MEM since they should have been | |
4350 | taken care of above. */ | |
4351 | ||
4352 | if (ind_levels == 0 | |
4353 | || (GET_CODE (XEXP (tem, 0)) == SYMBOL_REF && ! indirect_symref_ok) | |
4354 | || GET_CODE (XEXP (tem, 0)) == MEM | |
4355 | || ! (GET_CODE (XEXP (tem, 0)) == REG | |
4356 | || (GET_CODE (XEXP (tem, 0)) == PLUS | |
4357 | && GET_CODE (XEXP (XEXP (tem, 0), 0)) == REG | |
4358 | && GET_CODE (XEXP (XEXP (tem, 0), 1)) == CONST_INT))) | |
4359 | { | |
4360 | /* Must use TEM here, not AD, since it is the one that will | |
4361 | have any subexpressions reloaded, if needed. */ | |
fb3821f7 | 4362 | push_reload (tem, NULL_RTX, loc, NULL_PTR, |
1ba61f4e ILT |
4363 | reload_address_base_reg_class, GET_MODE (tem), |
4364 | VOIDmode, 0, | |
a8c9daeb | 4365 | 0, opnum, type); |
eab89b90 RK |
4366 | return 1; |
4367 | } | |
4368 | else | |
4369 | return 0; | |
4370 | } | |
4371 | ||
1b4d2764 RK |
4372 | /* If we have address of a stack slot but it's not valid because the |
4373 | displacement is too large, compute the sum in a register. | |
4374 | Handle all base registers here, not just fp/ap/sp, because on some | |
4375 | targets (namely SH) we can also get too large displacements from | |
4376 | big-endian corrections. */ | |
eab89b90 | 4377 | else if (GET_CODE (ad) == PLUS |
1b4d2764 RK |
4378 | && GET_CODE (XEXP (ad, 0)) == REG |
4379 | && REGNO (XEXP (ad, 0)) < FIRST_PSEUDO_REGISTER | |
858c3c8c | 4380 | && REG_MODE_OK_FOR_BASE_P (XEXP (ad, 0), mode) |
eab89b90 RK |
4381 | && GET_CODE (XEXP (ad, 1)) == CONST_INT) |
4382 | { | |
4383 | /* Unshare the MEM rtx so we can safely alter it. */ | |
4384 | if (memrefloc) | |
4385 | { | |
eab89b90 RK |
4386 | *memrefloc = copy_rtx (*memrefloc); |
4387 | loc = &XEXP (*memrefloc, 0); | |
eab89b90 RK |
4388 | } |
4389 | if (double_reg_address_ok) | |
4390 | { | |
4391 | /* Unshare the sum as well. */ | |
4392 | *loc = ad = copy_rtx (ad); | |
4393 | /* Reload the displacement into an index reg. | |
4394 | We assume the frame pointer or arg pointer is a base reg. */ | |
4395 | find_reloads_address_part (XEXP (ad, 1), &XEXP (ad, 1), | |
1ba61f4e ILT |
4396 | reload_address_index_reg_class, |
4397 | GET_MODE (ad), opnum, type, ind_levels); | |
eab89b90 RK |
4398 | } |
4399 | else | |
4400 | { | |
4401 | /* If the sum of two regs is not necessarily valid, | |
4402 | reload the sum into a base reg. | |
4403 | That will at least work. */ | |
1ba61f4e ILT |
4404 | find_reloads_address_part (ad, loc, reload_address_base_reg_class, |
4405 | Pmode, opnum, type, ind_levels); | |
eab89b90 RK |
4406 | } |
4407 | return 1; | |
4408 | } | |
4409 | ||
4410 | /* If we have an indexed stack slot, there are three possible reasons why | |
4411 | it might be invalid: The index might need to be reloaded, the address | |
4412 | might have been made by frame pointer elimination and hence have a | |
a12f68f4 DE |
4413 | constant out of range, or the address is the result of register |
4414 | elimination and (plus (plus reg reg) const), which has been | |
4415 | canonicalized from (plus (plus reg const) reg), isn't a valid address. | |
eab89b90 RK |
4416 | |
4417 | We can easily check for an index needing reload, but even if that is the | |
4418 | case, we might also have an invalid constant. To avoid making the | |
4419 | conservative assumption and requiring two reloads, we see if this address | |
4420 | is valid when not interpreted strictly. If it is, the only problem is | |
4421 | that the index needs a reload and find_reloads_address_1 will take care | |
4422 | of it. | |
4423 | ||
4424 | There is still a case when we might generate an extra reload, | |
4425 | however. In certain cases eliminate_regs will return a MEM for a REG | |
4426 | (see the code there for details). In those cases, memory_address_p | |
4427 | applied to our address will return 0 so we will think that our offset | |
4428 | must be too large. But it might indeed be valid and the only problem | |
4429 | is that a MEM is present where a REG should be. This case should be | |
4430 | very rare and there doesn't seem to be any way to avoid it. | |
4431 | ||
4432 | If we decide to do something here, it must be that | |
4433 | `double_reg_address_ok' is true and that this address rtl was made by | |
4434 | eliminate_regs. We generate a reload of the fp/sp/ap + constant and | |
4435 | rework the sum so that the reload register will be added to the index. | |
4436 | This is safe because we know the address isn't shared. | |
4437 | ||
4438 | We check for fp/ap/sp as both the first and second operand of the | |
4439 | innermost PLUS. */ | |
4440 | ||
4441 | else if (GET_CODE (ad) == PLUS && GET_CODE (XEXP (ad, 1)) == CONST_INT | |
a12f68f4 DE |
4442 | && (GET_CODE (XEXP (ad, 0)) == PLUS |
4443 | /* MINUS can happen as a result of register elimination of | |
4444 | (minus eliminable reg) which gets canonicalized as | |
4445 | (plus (minus reg reg) const). */ | |
4446 | || GET_CODE (XEXP (ad, 0)) == MINUS) | |
eab89b90 | 4447 | && (XEXP (XEXP (ad, 0), 0) == frame_pointer_rtx |
a36d4c62 DE |
4448 | #if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM |
4449 | || XEXP (XEXP (ad, 0), 0) == hard_frame_pointer_rtx | |
4450 | #endif | |
eab89b90 RK |
4451 | #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM |
4452 | || XEXP (XEXP (ad, 0), 0) == arg_pointer_rtx | |
4453 | #endif | |
4454 | || XEXP (XEXP (ad, 0), 0) == stack_pointer_rtx) | |
4455 | && ! memory_address_p (mode, ad)) | |
4456 | { | |
a12f68f4 | 4457 | *loc = ad = gen_rtx (GET_CODE (XEXP (ad, 0)), GET_MODE (ad), |
eab89b90 RK |
4458 | plus_constant (XEXP (XEXP (ad, 0), 0), |
4459 | INTVAL (XEXP (ad, 1))), | |
4460 | XEXP (XEXP (ad, 0), 1)); | |
1ba61f4e ILT |
4461 | find_reloads_address_part (XEXP (ad, 0), &XEXP (ad, 0), |
4462 | reload_address_base_reg_class, | |
a8c9daeb | 4463 | GET_MODE (ad), opnum, type, ind_levels); |
858c3c8c ILT |
4464 | find_reloads_address_1 (mode, XEXP (ad, 1), 1, &XEXP (ad, 1), opnum, |
4465 | type, 0); | |
eab89b90 RK |
4466 | |
4467 | return 1; | |
4468 | } | |
4469 | ||
4470 | else if (GET_CODE (ad) == PLUS && GET_CODE (XEXP (ad, 1)) == CONST_INT | |
4471 | && GET_CODE (XEXP (ad, 0)) == PLUS | |
4472 | && (XEXP (XEXP (ad, 0), 1) == frame_pointer_rtx | |
a36d4c62 DE |
4473 | #if HARD_FRAME_POINTER_REGNUM != FRAME_POINTER_REGNUM |
4474 | || XEXP (XEXP (ad, 0), 1) == hard_frame_pointer_rtx | |
4475 | #endif | |
eab89b90 RK |
4476 | #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM |
4477 | || XEXP (XEXP (ad, 0), 1) == arg_pointer_rtx | |
4478 | #endif | |
4479 | || XEXP (XEXP (ad, 0), 1) == stack_pointer_rtx) | |
4480 | && ! memory_address_p (mode, ad)) | |
4481 | { | |
4482 | *loc = ad = gen_rtx (PLUS, GET_MODE (ad), | |
ace53910 | 4483 | XEXP (XEXP (ad, 0), 0), |
eab89b90 | 4484 | plus_constant (XEXP (XEXP (ad, 0), 1), |
ace53910 | 4485 | INTVAL (XEXP (ad, 1)))); |
1ba61f4e ILT |
4486 | find_reloads_address_part (XEXP (ad, 1), &XEXP (ad, 1), |
4487 | reload_address_base_reg_class, | |
a8c9daeb | 4488 | GET_MODE (ad), opnum, type, ind_levels); |
858c3c8c ILT |
4489 | find_reloads_address_1 (mode, XEXP (ad, 0), 1, &XEXP (ad, 0), opnum, |
4490 | type, 0); | |
eab89b90 RK |
4491 | |
4492 | return 1; | |
4493 | } | |
4494 | ||
4495 | /* See if address becomes valid when an eliminable register | |
4496 | in a sum is replaced. */ | |
4497 | ||
4498 | tem = ad; | |
4499 | if (GET_CODE (ad) == PLUS) | |
4500 | tem = subst_indexed_address (ad); | |
4501 | if (tem != ad && strict_memory_address_p (mode, tem)) | |
4502 | { | |
4503 | /* Ok, we win that way. Replace any additional eliminable | |
4504 | registers. */ | |
4505 | ||
4506 | subst_reg_equivs_changed = 0; | |
4507 | tem = subst_reg_equivs (tem); | |
4508 | ||
4509 | /* Make sure that didn't make the address invalid again. */ | |
4510 | ||
4511 | if (! subst_reg_equivs_changed || strict_memory_address_p (mode, tem)) | |
4512 | { | |
4513 | *loc = tem; | |
4514 | return 0; | |
4515 | } | |
4516 | } | |
4517 | ||
4518 | /* If constants aren't valid addresses, reload the constant address | |
4519 | into a register. */ | |
191b18e9 | 4520 | if (CONSTANT_P (ad) && ! strict_memory_address_p (mode, ad)) |
eab89b90 RK |
4521 | { |
4522 | /* If AD is in address in the constant pool, the MEM rtx may be shared. | |
4523 | Unshare it so we can safely alter it. */ | |
4524 | if (memrefloc && GET_CODE (ad) == SYMBOL_REF | |
4525 | && CONSTANT_POOL_ADDRESS_P (ad)) | |
4526 | { | |
eab89b90 RK |
4527 | *memrefloc = copy_rtx (*memrefloc); |
4528 | loc = &XEXP (*memrefloc, 0); | |
eab89b90 RK |
4529 | } |
4530 | ||
1ba61f4e ILT |
4531 | find_reloads_address_part (ad, loc, reload_address_base_reg_class, |
4532 | Pmode, opnum, type, | |
eab89b90 RK |
4533 | ind_levels); |
4534 | return 1; | |
4535 | } | |
4536 | ||
858c3c8c | 4537 | return find_reloads_address_1 (mode, ad, 0, loc, opnum, type, ind_levels); |
eab89b90 RK |
4538 | } |
4539 | \f | |
4540 | /* Find all pseudo regs appearing in AD | |
4541 | that are eliminable in favor of equivalent values | |
4542 | and do not have hard regs; replace them by their equivalents. */ | |
4543 | ||
4544 | static rtx | |
4545 | subst_reg_equivs (ad) | |
4546 | rtx ad; | |
4547 | { | |
4548 | register RTX_CODE code = GET_CODE (ad); | |
4549 | register int i; | |
4550 | register char *fmt; | |
4551 | ||
4552 | switch (code) | |
4553 | { | |
4554 | case HIGH: | |
4555 | case CONST_INT: | |
4556 | case CONST: | |
4557 | case CONST_DOUBLE: | |
4558 | case SYMBOL_REF: | |
4559 | case LABEL_REF: | |
4560 | case PC: | |
4561 | case CC0: | |
4562 | return ad; | |
4563 | ||
4564 | case REG: | |
4565 | { | |
4566 | register int regno = REGNO (ad); | |
4567 | ||
4568 | if (reg_equiv_constant[regno] != 0) | |
4569 | { | |
4570 | subst_reg_equivs_changed = 1; | |
4571 | return reg_equiv_constant[regno]; | |
4572 | } | |
4573 | } | |
4574 | return ad; | |
4575 | ||
4576 | case PLUS: | |
4577 | /* Quickly dispose of a common case. */ | |
4578 | if (XEXP (ad, 0) == frame_pointer_rtx | |
4579 | && GET_CODE (XEXP (ad, 1)) == CONST_INT) | |
4580 | return ad; | |
4581 | } | |
4582 | ||
4583 | fmt = GET_RTX_FORMAT (code); | |
4584 | for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) | |
4585 | if (fmt[i] == 'e') | |
4586 | XEXP (ad, i) = subst_reg_equivs (XEXP (ad, i)); | |
4587 | return ad; | |
4588 | } | |
4589 | \f | |
4590 | /* Compute the sum of X and Y, making canonicalizations assumed in an | |
4591 | address, namely: sum constant integers, surround the sum of two | |
4592 | constants with a CONST, put the constant as the second operand, and | |
4593 | group the constant on the outermost sum. | |
4594 | ||
4595 | This routine assumes both inputs are already in canonical form. */ | |
4596 | ||
4597 | rtx | |
4598 | form_sum (x, y) | |
4599 | rtx x, y; | |
4600 | { | |
4601 | rtx tem; | |
2c0623e8 RK |
4602 | enum machine_mode mode = GET_MODE (x); |
4603 | ||
4604 | if (mode == VOIDmode) | |
4605 | mode = GET_MODE (y); | |
4606 | ||
4607 | if (mode == VOIDmode) | |
4608 | mode = Pmode; | |
eab89b90 RK |
4609 | |
4610 | if (GET_CODE (x) == CONST_INT) | |
4611 | return plus_constant (y, INTVAL (x)); | |
4612 | else if (GET_CODE (y) == CONST_INT) | |
4613 | return plus_constant (x, INTVAL (y)); | |
4614 | else if (CONSTANT_P (x)) | |
4615 | tem = x, x = y, y = tem; | |
4616 | ||
4617 | if (GET_CODE (x) == PLUS && CONSTANT_P (XEXP (x, 1))) | |
4618 | return form_sum (XEXP (x, 0), form_sum (XEXP (x, 1), y)); | |
4619 | ||
4620 | /* Note that if the operands of Y are specified in the opposite | |
4621 | order in the recursive calls below, infinite recursion will occur. */ | |
d9771f62 | 4622 | if (GET_CODE (y) == PLUS && CONSTANT_P (XEXP (y, 1))) |
eab89b90 RK |
4623 | return form_sum (form_sum (x, XEXP (y, 0)), XEXP (y, 1)); |
4624 | ||
4625 | /* If both constant, encapsulate sum. Otherwise, just form sum. A | |
4626 | constant will have been placed second. */ | |
4627 | if (CONSTANT_P (x) && CONSTANT_P (y)) | |
4628 | { | |
4629 | if (GET_CODE (x) == CONST) | |
4630 | x = XEXP (x, 0); | |
4631 | if (GET_CODE (y) == CONST) | |
4632 | y = XEXP (y, 0); | |
4633 | ||
2c0623e8 | 4634 | return gen_rtx (CONST, VOIDmode, gen_rtx (PLUS, mode, x, y)); |
eab89b90 RK |
4635 | } |
4636 | ||
2c0623e8 | 4637 | return gen_rtx (PLUS, mode, x, y); |
eab89b90 RK |
4638 | } |
4639 | \f | |
4640 | /* If ADDR is a sum containing a pseudo register that should be | |
4641 | replaced with a constant (from reg_equiv_constant), | |
4642 | return the result of doing so, and also apply the associative | |
4643 | law so that the result is more likely to be a valid address. | |
4644 | (But it is not guaranteed to be one.) | |
4645 | ||
4646 | Note that at most one register is replaced, even if more are | |
4647 | replaceable. Also, we try to put the result into a canonical form | |
4648 | so it is more likely to be a valid address. | |
4649 | ||
4650 | In all other cases, return ADDR. */ | |
4651 | ||
4652 | static rtx | |
4653 | subst_indexed_address (addr) | |
4654 | rtx addr; | |
4655 | { | |
4656 | rtx op0 = 0, op1 = 0, op2 = 0; | |
4657 | rtx tem; | |
4658 | int regno; | |
4659 | ||
4660 | if (GET_CODE (addr) == PLUS) | |
4661 | { | |
4662 | /* Try to find a register to replace. */ | |
4663 | op0 = XEXP (addr, 0), op1 = XEXP (addr, 1), op2 = 0; | |
4664 | if (GET_CODE (op0) == REG | |
4665 | && (regno = REGNO (op0)) >= FIRST_PSEUDO_REGISTER | |
4666 | && reg_renumber[regno] < 0 | |
4667 | && reg_equiv_constant[regno] != 0) | |
4668 | op0 = reg_equiv_constant[regno]; | |
4669 | else if (GET_CODE (op1) == REG | |
4670 | && (regno = REGNO (op1)) >= FIRST_PSEUDO_REGISTER | |
4671 | && reg_renumber[regno] < 0 | |
4672 | && reg_equiv_constant[regno] != 0) | |
4673 | op1 = reg_equiv_constant[regno]; | |
4674 | else if (GET_CODE (op0) == PLUS | |
4675 | && (tem = subst_indexed_address (op0)) != op0) | |
4676 | op0 = tem; | |
4677 | else if (GET_CODE (op1) == PLUS | |
4678 | && (tem = subst_indexed_address (op1)) != op1) | |
4679 | op1 = tem; | |
4680 | else | |
4681 | return addr; | |
4682 | ||
4683 | /* Pick out up to three things to add. */ | |
4684 | if (GET_CODE (op1) == PLUS) | |
4685 | op2 = XEXP (op1, 1), op1 = XEXP (op1, 0); | |
4686 | else if (GET_CODE (op0) == PLUS) | |
4687 | op2 = op1, op1 = XEXP (op0, 1), op0 = XEXP (op0, 0); | |
4688 | ||
4689 | /* Compute the sum. */ | |
4690 | if (op2 != 0) | |
4691 | op1 = form_sum (op1, op2); | |
4692 | if (op1 != 0) | |
4693 | op0 = form_sum (op0, op1); | |
4694 | ||
4695 | return op0; | |
4696 | } | |
4697 | return addr; | |
4698 | } | |
4699 | \f | |
858c3c8c ILT |
4700 | /* Record the pseudo registers we must reload into hard registers in a |
4701 | subexpression of a would-be memory address, X referring to a value | |
4702 | in mode MODE. (This function is not called if the address we find | |
4703 | is strictly valid.) | |
4704 | ||
eab89b90 RK |
4705 | CONTEXT = 1 means we are considering regs as index regs, |
4706 | = 0 means we are considering them as base regs. | |
4707 | ||
a8c9daeb | 4708 | OPNUM and TYPE specify the purpose of any reloads made. |
eab89b90 RK |
4709 | |
4710 | IND_LEVELS says how many levels of indirect addressing are | |
4711 | supported at this point in the address. | |
4712 | ||
4713 | We return nonzero if X, as a whole, is reloaded or replaced. */ | |
4714 | ||
4715 | /* Note that we take shortcuts assuming that no multi-reg machine mode | |
4716 | occurs as part of an address. | |
4717 | Also, this is not fully machine-customizable; it works for machines | |
4718 | such as vaxes and 68000's and 32000's, but other possible machines | |
4719 | could have addressing modes that this does not handle right. */ | |
4720 | ||
4721 | static int | |
858c3c8c ILT |
4722 | find_reloads_address_1 (mode, x, context, loc, opnum, type, ind_levels) |
4723 | enum machine_mode mode; | |
eab89b90 RK |
4724 | rtx x; |
4725 | int context; | |
4726 | rtx *loc; | |
a8c9daeb RK |
4727 | int opnum; |
4728 | enum reload_type type; | |
eab89b90 RK |
4729 | int ind_levels; |
4730 | { | |
4731 | register RTX_CODE code = GET_CODE (x); | |
4732 | ||
a2d353e5 | 4733 | switch (code) |
eab89b90 | 4734 | { |
a2d353e5 RK |
4735 | case PLUS: |
4736 | { | |
4737 | register rtx orig_op0 = XEXP (x, 0); | |
4738 | register rtx orig_op1 = XEXP (x, 1); | |
4739 | register RTX_CODE code0 = GET_CODE (orig_op0); | |
4740 | register RTX_CODE code1 = GET_CODE (orig_op1); | |
4741 | register rtx op0 = orig_op0; | |
4742 | register rtx op1 = orig_op1; | |
4743 | ||
4744 | if (GET_CODE (op0) == SUBREG) | |
4745 | { | |
4746 | op0 = SUBREG_REG (op0); | |
4747 | code0 = GET_CODE (op0); | |
922db4bb RK |
4748 | if (code0 == REG && REGNO (op0) < FIRST_PSEUDO_REGISTER) |
4749 | op0 = gen_rtx (REG, word_mode, | |
4750 | REGNO (op0) + SUBREG_WORD (orig_op0)); | |
a2d353e5 | 4751 | } |
87935f60 | 4752 | |
a2d353e5 RK |
4753 | if (GET_CODE (op1) == SUBREG) |
4754 | { | |
4755 | op1 = SUBREG_REG (op1); | |
4756 | code1 = GET_CODE (op1); | |
922db4bb RK |
4757 | if (code1 == REG && REGNO (op1) < FIRST_PSEUDO_REGISTER) |
4758 | op1 = gen_rtx (REG, GET_MODE (op1), | |
4759 | REGNO (op1) + SUBREG_WORD (orig_op1)); | |
a2d353e5 RK |
4760 | } |
4761 | ||
5f8997b9 SC |
4762 | if (code0 == MULT || code0 == SIGN_EXTEND || code0 == TRUNCATE |
4763 | || code0 == ZERO_EXTEND || code1 == MEM) | |
a2d353e5 | 4764 | { |
858c3c8c ILT |
4765 | find_reloads_address_1 (mode, orig_op0, 1, &XEXP (x, 0), opnum, |
4766 | type, ind_levels); | |
4767 | find_reloads_address_1 (mode, orig_op1, 0, &XEXP (x, 1), opnum, | |
4768 | type, ind_levels); | |
a2d353e5 RK |
4769 | } |
4770 | ||
5f8997b9 SC |
4771 | else if (code1 == MULT || code1 == SIGN_EXTEND || code1 == TRUNCATE |
4772 | || code1 == ZERO_EXTEND || code0 == MEM) | |
a2d353e5 | 4773 | { |
858c3c8c ILT |
4774 | find_reloads_address_1 (mode, orig_op0, 0, &XEXP (x, 0), opnum, |
4775 | type, ind_levels); | |
4776 | find_reloads_address_1 (mode, orig_op1, 1, &XEXP (x, 1), opnum, | |
4777 | type, ind_levels); | |
a2d353e5 RK |
4778 | } |
4779 | ||
4780 | else if (code0 == CONST_INT || code0 == CONST | |
4781 | || code0 == SYMBOL_REF || code0 == LABEL_REF) | |
858c3c8c ILT |
4782 | find_reloads_address_1 (mode, orig_op1, 0, &XEXP (x, 1), opnum, |
4783 | type, ind_levels); | |
a2d353e5 RK |
4784 | |
4785 | else if (code1 == CONST_INT || code1 == CONST | |
4786 | || code1 == SYMBOL_REF || code1 == LABEL_REF) | |
858c3c8c ILT |
4787 | find_reloads_address_1 (mode, orig_op0, 0, &XEXP (x, 0), opnum, |
4788 | type, ind_levels); | |
a2d353e5 RK |
4789 | |
4790 | else if (code0 == REG && code1 == REG) | |
4791 | { | |
4792 | if (REG_OK_FOR_INDEX_P (op0) | |
858c3c8c | 4793 | && REG_MODE_OK_FOR_BASE_P (op1, mode)) |
a2d353e5 RK |
4794 | return 0; |
4795 | else if (REG_OK_FOR_INDEX_P (op1) | |
858c3c8c | 4796 | && REG_MODE_OK_FOR_BASE_P (op0, mode)) |
a2d353e5 | 4797 | return 0; |
858c3c8c ILT |
4798 | else if (REG_MODE_OK_FOR_BASE_P (op1, mode)) |
4799 | find_reloads_address_1 (mode, orig_op0, 1, &XEXP (x, 0), opnum, | |
4800 | type, ind_levels); | |
4801 | else if (REG_MODE_OK_FOR_BASE_P (op0, mode)) | |
4802 | find_reloads_address_1 (mode, orig_op1, 1, &XEXP (x, 1), opnum, | |
4803 | type, ind_levels); | |
a2d353e5 | 4804 | else if (REG_OK_FOR_INDEX_P (op1)) |
858c3c8c ILT |
4805 | find_reloads_address_1 (mode, orig_op0, 0, &XEXP (x, 0), opnum, |
4806 | type, ind_levels); | |
a2d353e5 | 4807 | else if (REG_OK_FOR_INDEX_P (op0)) |
858c3c8c ILT |
4808 | find_reloads_address_1 (mode, orig_op1, 0, &XEXP (x, 1), opnum, |
4809 | type, ind_levels); | |
a2d353e5 RK |
4810 | else |
4811 | { | |
858c3c8c ILT |
4812 | find_reloads_address_1 (mode, orig_op0, 1, &XEXP (x, 0), opnum, |
4813 | type, ind_levels); | |
4814 | find_reloads_address_1 (mode, orig_op1, 0, &XEXP (x, 1), opnum, | |
4815 | type, ind_levels); | |
a2d353e5 RK |
4816 | } |
4817 | } | |
4818 | ||
4819 | else if (code0 == REG) | |
4820 | { | |
858c3c8c ILT |
4821 | find_reloads_address_1 (mode, orig_op0, 1, &XEXP (x, 0), opnum, |
4822 | type, ind_levels); | |
4823 | find_reloads_address_1 (mode, orig_op1, 0, &XEXP (x, 1), opnum, | |
4824 | type, ind_levels); | |
a2d353e5 RK |
4825 | } |
4826 | ||
4827 | else if (code1 == REG) | |
4828 | { | |
858c3c8c ILT |
4829 | find_reloads_address_1 (mode, orig_op1, 1, &XEXP (x, 1), opnum, |
4830 | type, ind_levels); | |
4831 | find_reloads_address_1 (mode, orig_op0, 0, &XEXP (x, 0), opnum, | |
4832 | type, ind_levels); | |
a2d353e5 RK |
4833 | } |
4834 | } | |
4835 | ||
4836 | return 0; | |
4837 | ||
4838 | case POST_INC: | |
4839 | case POST_DEC: | |
4840 | case PRE_INC: | |
4841 | case PRE_DEC: | |
eab89b90 RK |
4842 | if (GET_CODE (XEXP (x, 0)) == REG) |
4843 | { | |
4844 | register int regno = REGNO (XEXP (x, 0)); | |
4845 | int value = 0; | |
4846 | rtx x_orig = x; | |
4847 | ||
4848 | /* A register that is incremented cannot be constant! */ | |
4849 | if (regno >= FIRST_PSEUDO_REGISTER | |
4850 | && reg_equiv_constant[regno] != 0) | |
4851 | abort (); | |
4852 | ||
4853 | /* Handle a register that is equivalent to a memory location | |
4854 | which cannot be addressed directly. */ | |
4855 | if (reg_equiv_address[regno] != 0) | |
4856 | { | |
4857 | rtx tem = make_memloc (XEXP (x, 0), regno); | |
4858 | /* First reload the memory location's address. */ | |
4859 | find_reloads_address (GET_MODE (tem), 0, XEXP (tem, 0), | |
47c8cf91 ILT |
4860 | &XEXP (tem, 0), opnum, ADDR_TYPE (type), |
4861 | ind_levels); | |
eab89b90 RK |
4862 | /* Put this inside a new increment-expression. */ |
4863 | x = gen_rtx (GET_CODE (x), GET_MODE (x), tem); | |
4864 | /* Proceed to reload that, as if it contained a register. */ | |
4865 | } | |
4866 | ||
4867 | /* If we have a hard register that is ok as an index, | |
4868 | don't make a reload. If an autoincrement of a nice register | |
4869 | isn't "valid", it must be that no autoincrement is "valid". | |
4870 | If that is true and something made an autoincrement anyway, | |
4871 | this must be a special context where one is allowed. | |
4872 | (For example, a "push" instruction.) | |
4873 | We can't improve this address, so leave it alone. */ | |
4874 | ||
4875 | /* Otherwise, reload the autoincrement into a suitable hard reg | |
4876 | and record how much to increment by. */ | |
4877 | ||
4878 | if (reg_renumber[regno] >= 0) | |
4879 | regno = reg_renumber[regno]; | |
4880 | if ((regno >= FIRST_PSEUDO_REGISTER | |
4881 | || !(context ? REGNO_OK_FOR_INDEX_P (regno) | |
858c3c8c | 4882 | : REGNO_MODE_OK_FOR_BASE_P (regno, mode)))) |
eab89b90 RK |
4883 | { |
4884 | register rtx link; | |
4885 | ||
4886 | int reloadnum | |
fb3821f7 | 4887 | = push_reload (x, NULL_RTX, loc, NULL_PTR, |
1ba61f4e ILT |
4888 | (context |
4889 | ? reload_address_index_reg_class | |
4890 | : reload_address_base_reg_class), | |
a8c9daeb RK |
4891 | GET_MODE (x), GET_MODE (x), VOIDmode, 0, |
4892 | opnum, type); | |
eab89b90 RK |
4893 | reload_inc[reloadnum] |
4894 | = find_inc_amount (PATTERN (this_insn), XEXP (x_orig, 0)); | |
4895 | ||
4896 | value = 1; | |
4897 | ||
4898 | #ifdef AUTO_INC_DEC | |
4899 | /* Update the REG_INC notes. */ | |
4900 | ||
4901 | for (link = REG_NOTES (this_insn); | |
4902 | link; link = XEXP (link, 1)) | |
4903 | if (REG_NOTE_KIND (link) == REG_INC | |
4904 | && REGNO (XEXP (link, 0)) == REGNO (XEXP (x_orig, 0))) | |
4905 | push_replacement (&XEXP (link, 0), reloadnum, VOIDmode); | |
4906 | #endif | |
4907 | } | |
4908 | return value; | |
4909 | } | |
a2d353e5 | 4910 | |
eab89b90 RK |
4911 | else if (GET_CODE (XEXP (x, 0)) == MEM) |
4912 | { | |
4913 | /* This is probably the result of a substitution, by eliminate_regs, | |
4914 | of an equivalent address for a pseudo that was not allocated to a | |
4915 | hard register. Verify that the specified address is valid and | |
4916 | reload it into a register. */ | |
4917 | rtx tem = XEXP (x, 0); | |
4918 | register rtx link; | |
4919 | int reloadnum; | |
4920 | ||
4921 | /* Since we know we are going to reload this item, don't decrement | |
4922 | for the indirection level. | |
4923 | ||
4924 | Note that this is actually conservative: it would be slightly | |
4925 | more efficient to use the value of SPILL_INDIRECT_LEVELS from | |
4926 | reload1.c here. */ | |
4927 | find_reloads_address (GET_MODE (x), &XEXP (x, 0), | |
4928 | XEXP (XEXP (x, 0), 0), &XEXP (XEXP (x, 0), 0), | |
47c8cf91 | 4929 | opnum, ADDR_TYPE (type), ind_levels); |
eab89b90 | 4930 | |
fb3821f7 | 4931 | reloadnum = push_reload (x, NULL_RTX, loc, NULL_PTR, |
1ba61f4e ILT |
4932 | (context |
4933 | ? reload_address_index_reg_class | |
4934 | : reload_address_base_reg_class), | |
a8c9daeb | 4935 | GET_MODE (x), VOIDmode, 0, 0, opnum, type); |
eab89b90 RK |
4936 | reload_inc[reloadnum] |
4937 | = find_inc_amount (PATTERN (this_insn), XEXP (x, 0)); | |
4938 | ||
4939 | link = FIND_REG_INC_NOTE (this_insn, tem); | |
4940 | if (link != 0) | |
4941 | push_replacement (&XEXP (link, 0), reloadnum, VOIDmode); | |
4942 | ||
4943 | return 1; | |
4944 | } | |
a2d353e5 RK |
4945 | return 0; |
4946 | ||
4947 | case MEM: | |
4948 | /* This is probably the result of a substitution, by eliminate_regs, of | |
4949 | an equivalent address for a pseudo that was not allocated to a hard | |
4950 | register. Verify that the specified address is valid and reload it | |
4951 | into a register. | |
eab89b90 | 4952 | |
a2d353e5 RK |
4953 | Since we know we are going to reload this item, don't decrement for |
4954 | the indirection level. | |
eab89b90 RK |
4955 | |
4956 | Note that this is actually conservative: it would be slightly more | |
4957 | efficient to use the value of SPILL_INDIRECT_LEVELS from | |
4958 | reload1.c here. */ | |
4959 | ||
4960 | find_reloads_address (GET_MODE (x), loc, XEXP (x, 0), &XEXP (x, 0), | |
47c8cf91 | 4961 | opnum, ADDR_TYPE (type), ind_levels); |
fb3821f7 | 4962 | push_reload (*loc, NULL_RTX, loc, NULL_PTR, |
1ba61f4e ILT |
4963 | (context ? reload_address_index_reg_class |
4964 | : reload_address_base_reg_class), | |
a8c9daeb | 4965 | GET_MODE (x), VOIDmode, 0, 0, opnum, type); |
eab89b90 | 4966 | return 1; |
eab89b90 | 4967 | |
a2d353e5 RK |
4968 | case REG: |
4969 | { | |
4970 | register int regno = REGNO (x); | |
4971 | ||
4972 | if (reg_equiv_constant[regno] != 0) | |
4973 | { | |
4974 | find_reloads_address_part (reg_equiv_constant[regno], loc, | |
1ba61f4e ILT |
4975 | (context |
4976 | ? reload_address_index_reg_class | |
4977 | : reload_address_base_reg_class), | |
a2d353e5 RK |
4978 | GET_MODE (x), opnum, type, ind_levels); |
4979 | return 1; | |
4980 | } | |
eab89b90 RK |
4981 | |
4982 | #if 0 /* This might screw code in reload1.c to delete prior output-reload | |
4983 | that feeds this insn. */ | |
a2d353e5 RK |
4984 | if (reg_equiv_mem[regno] != 0) |
4985 | { | |
4986 | push_reload (reg_equiv_mem[regno], NULL_RTX, loc, NULL_PTR, | |
1ba61f4e ILT |
4987 | (context |
4988 | ? reload_address_index_reg_class | |
4989 | : reload_address_base_reg_class), | |
a2d353e5 RK |
4990 | GET_MODE (x), VOIDmode, 0, 0, opnum, type); |
4991 | return 1; | |
4992 | } | |
eab89b90 | 4993 | #endif |
eab89b90 | 4994 | |
a2d353e5 RK |
4995 | if (reg_equiv_address[regno] != 0) |
4996 | { | |
4997 | x = make_memloc (x, regno); | |
4998 | find_reloads_address (GET_MODE (x), 0, XEXP (x, 0), &XEXP (x, 0), | |
47c8cf91 | 4999 | opnum, ADDR_TYPE (type), ind_levels); |
a2d353e5 | 5000 | } |
eab89b90 | 5001 | |
a2d353e5 RK |
5002 | if (reg_renumber[regno] >= 0) |
5003 | regno = reg_renumber[regno]; | |
5004 | ||
5005 | if ((regno >= FIRST_PSEUDO_REGISTER | |
5006 | || !(context ? REGNO_OK_FOR_INDEX_P (regno) | |
858c3c8c | 5007 | : REGNO_MODE_OK_FOR_BASE_P (regno, mode)))) |
a2d353e5 RK |
5008 | { |
5009 | push_reload (x, NULL_RTX, loc, NULL_PTR, | |
1ba61f4e ILT |
5010 | (context |
5011 | ? reload_address_index_reg_class | |
5012 | : reload_address_base_reg_class), | |
a2d353e5 RK |
5013 | GET_MODE (x), VOIDmode, 0, 0, opnum, type); |
5014 | return 1; | |
5015 | } | |
5016 | ||
5017 | /* If a register appearing in an address is the subject of a CLOBBER | |
5018 | in this insn, reload it into some other register to be safe. | |
5019 | The CLOBBER is supposed to make the register unavailable | |
5020 | from before this insn to after it. */ | |
5021 | if (regno_clobbered_p (regno, this_insn)) | |
5022 | { | |
5023 | push_reload (x, NULL_RTX, loc, NULL_PTR, | |
1ba61f4e ILT |
5024 | (context |
5025 | ? reload_address_index_reg_class | |
5026 | : reload_address_base_reg_class), | |
a2d353e5 RK |
5027 | GET_MODE (x), VOIDmode, 0, 0, opnum, type); |
5028 | return 1; | |
5029 | } | |
5030 | } | |
5031 | return 0; | |
5032 | ||
5033 | case SUBREG: | |
922db4bb | 5034 | if (GET_CODE (SUBREG_REG (x)) == REG) |
eab89b90 | 5035 | { |
922db4bb RK |
5036 | /* If this is a SUBREG of a hard register and the resulting register |
5037 | is of the wrong class, reload the whole SUBREG. This avoids | |
5038 | needless copies if SUBREG_REG is multi-word. */ | |
5039 | if (REGNO (SUBREG_REG (x)) < FIRST_PSEUDO_REGISTER) | |
5040 | { | |
5041 | int regno = REGNO (SUBREG_REG (x)) + SUBREG_WORD (x); | |
a2d353e5 | 5042 | |
922db4bb | 5043 | if (! (context ? REGNO_OK_FOR_INDEX_P (regno) |
858c3c8c | 5044 | : REGNO_MODE_OK_FOR_BASE_P (regno, mode))) |
922db4bb RK |
5045 | { |
5046 | push_reload (x, NULL_RTX, loc, NULL_PTR, | |
1ba61f4e ILT |
5047 | (context |
5048 | ? reload_address_index_reg_class | |
5049 | : reload_address_base_reg_class), | |
922db4bb RK |
5050 | GET_MODE (x), VOIDmode, 0, 0, opnum, type); |
5051 | return 1; | |
5052 | } | |
5053 | } | |
abc95ed3 | 5054 | /* If this is a SUBREG of a pseudo-register, and the pseudo-register |
922db4bb RK |
5055 | is larger than the class size, then reload the whole SUBREG. */ |
5056 | else | |
a2d353e5 | 5057 | { |
922db4bb | 5058 | enum reg_class class = (context |
1ba61f4e ILT |
5059 | ? reload_address_index_reg_class |
5060 | : reload_address_base_reg_class); | |
922db4bb RK |
5061 | if (CLASS_MAX_NREGS (class, GET_MODE (SUBREG_REG (x))) |
5062 | > reg_class_size[class]) | |
5063 | { | |
5064 | push_reload (x, NULL_RTX, loc, NULL_PTR, class, | |
5065 | GET_MODE (x), VOIDmode, 0, 0, opnum, type); | |
5066 | return 1; | |
5067 | } | |
a2d353e5 | 5068 | } |
eab89b90 | 5069 | } |
a2d353e5 | 5070 | break; |
eab89b90 RK |
5071 | } |
5072 | ||
a2d353e5 RK |
5073 | { |
5074 | register char *fmt = GET_RTX_FORMAT (code); | |
5075 | register int i; | |
5076 | ||
5077 | for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) | |
5078 | { | |
5079 | if (fmt[i] == 'e') | |
858c3c8c | 5080 | find_reloads_address_1 (mode, XEXP (x, i), context, &XEXP (x, i), |
a2d353e5 RK |
5081 | opnum, type, ind_levels); |
5082 | } | |
5083 | } | |
5084 | ||
eab89b90 RK |
5085 | return 0; |
5086 | } | |
5087 | \f | |
5088 | /* X, which is found at *LOC, is a part of an address that needs to be | |
5089 | reloaded into a register of class CLASS. If X is a constant, or if | |
5090 | X is a PLUS that contains a constant, check that the constant is a | |
5091 | legitimate operand and that we are supposed to be able to load | |
5092 | it into the register. | |
5093 | ||
5094 | If not, force the constant into memory and reload the MEM instead. | |
5095 | ||
5096 | MODE is the mode to use, in case X is an integer constant. | |
5097 | ||
a8c9daeb | 5098 | OPNUM and TYPE describe the purpose of any reloads made. |
eab89b90 RK |
5099 | |
5100 | IND_LEVELS says how many levels of indirect addressing this machine | |
5101 | supports. */ | |
5102 | ||
5103 | static void | |
a8c9daeb | 5104 | find_reloads_address_part (x, loc, class, mode, opnum, type, ind_levels) |
eab89b90 RK |
5105 | rtx x; |
5106 | rtx *loc; | |
5107 | enum reg_class class; | |
5108 | enum machine_mode mode; | |
a8c9daeb RK |
5109 | int opnum; |
5110 | enum reload_type type; | |
eab89b90 RK |
5111 | int ind_levels; |
5112 | { | |
5113 | if (CONSTANT_P (x) | |
5114 | && (! LEGITIMATE_CONSTANT_P (x) | |
5115 | || PREFERRED_RELOAD_CLASS (x, class) == NO_REGS)) | |
5116 | { | |
5117 | rtx tem = x = force_const_mem (mode, x); | |
5118 | find_reloads_address (mode, &tem, XEXP (tem, 0), &XEXP (tem, 0), | |
a8c9daeb | 5119 | opnum, type, ind_levels); |
eab89b90 RK |
5120 | } |
5121 | ||
5122 | else if (GET_CODE (x) == PLUS | |
5123 | && CONSTANT_P (XEXP (x, 1)) | |
5124 | && (! LEGITIMATE_CONSTANT_P (XEXP (x, 1)) | |
5125 | || PREFERRED_RELOAD_CLASS (XEXP (x, 1), class) == NO_REGS)) | |
5126 | { | |
5127 | rtx tem = force_const_mem (GET_MODE (x), XEXP (x, 1)); | |
5128 | ||
5129 | x = gen_rtx (PLUS, GET_MODE (x), XEXP (x, 0), tem); | |
5130 | find_reloads_address (mode, &tem, XEXP (tem, 0), &XEXP (tem, 0), | |
a8c9daeb | 5131 | opnum, type, ind_levels); |
eab89b90 RK |
5132 | } |
5133 | ||
fb3821f7 | 5134 | push_reload (x, NULL_RTX, loc, NULL_PTR, class, |
a8c9daeb | 5135 | mode, VOIDmode, 0, 0, opnum, type); |
eab89b90 RK |
5136 | } |
5137 | \f | |
a8c9daeb | 5138 | /* Substitute into the current INSN the registers into which we have reloaded |
eab89b90 RK |
5139 | the things that need reloading. The array `replacements' |
5140 | says contains the locations of all pointers that must be changed | |
5141 | and says what to replace them with. | |
5142 | ||
5143 | Return the rtx that X translates into; usually X, but modified. */ | |
5144 | ||
5145 | void | |
5146 | subst_reloads () | |
5147 | { | |
5148 | register int i; | |
5149 | ||
5150 | for (i = 0; i < n_replacements; i++) | |
5151 | { | |
5152 | register struct replacement *r = &replacements[i]; | |
5153 | register rtx reloadreg = reload_reg_rtx[r->what]; | |
5154 | if (reloadreg) | |
5155 | { | |
5156 | /* Encapsulate RELOADREG so its machine mode matches what | |
26f1a00e RK |
5157 | used to be there. Note that gen_lowpart_common will |
5158 | do the wrong thing if RELOADREG is multi-word. RELOADREG | |
5159 | will always be a REG here. */ | |
eab89b90 | 5160 | if (GET_MODE (reloadreg) != r->mode && r->mode != VOIDmode) |
26f1a00e | 5161 | reloadreg = gen_rtx (REG, r->mode, REGNO (reloadreg)); |
eab89b90 RK |
5162 | |
5163 | /* If we are putting this into a SUBREG and RELOADREG is a | |
5164 | SUBREG, we would be making nested SUBREGs, so we have to fix | |
5165 | this up. Note that r->where == &SUBREG_REG (*r->subreg_loc). */ | |
5166 | ||
5167 | if (r->subreg_loc != 0 && GET_CODE (reloadreg) == SUBREG) | |
5168 | { | |
5169 | if (GET_MODE (*r->subreg_loc) | |
5170 | == GET_MODE (SUBREG_REG (reloadreg))) | |
5171 | *r->subreg_loc = SUBREG_REG (reloadreg); | |
5172 | else | |
5173 | { | |
5174 | *r->where = SUBREG_REG (reloadreg); | |
5175 | SUBREG_WORD (*r->subreg_loc) += SUBREG_WORD (reloadreg); | |
5176 | } | |
5177 | } | |
5178 | else | |
5179 | *r->where = reloadreg; | |
5180 | } | |
5181 | /* If reload got no reg and isn't optional, something's wrong. */ | |
5182 | else if (! reload_optional[r->what]) | |
5183 | abort (); | |
5184 | } | |
5185 | } | |
5186 | \f | |
5187 | /* Make a copy of any replacements being done into X and move those copies | |
5188 | to locations in Y, a copy of X. We only look at the highest level of | |
5189 | the RTL. */ | |
5190 | ||
5191 | void | |
5192 | copy_replacements (x, y) | |
5193 | rtx x; | |
5194 | rtx y; | |
5195 | { | |
5196 | int i, j; | |
5197 | enum rtx_code code = GET_CODE (x); | |
5198 | char *fmt = GET_RTX_FORMAT (code); | |
5199 | struct replacement *r; | |
5200 | ||
5201 | /* We can't support X being a SUBREG because we might then need to know its | |
5202 | location if something inside it was replaced. */ | |
5203 | if (code == SUBREG) | |
5204 | abort (); | |
5205 | ||
5206 | for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) | |
5207 | if (fmt[i] == 'e') | |
5208 | for (j = 0; j < n_replacements; j++) | |
5209 | { | |
5210 | if (replacements[j].subreg_loc == &XEXP (x, i)) | |
5211 | { | |
5212 | r = &replacements[n_replacements++]; | |
5213 | r->where = replacements[j].where; | |
5214 | r->subreg_loc = &XEXP (y, i); | |
5215 | r->what = replacements[j].what; | |
5216 | r->mode = replacements[j].mode; | |
5217 | } | |
5218 | else if (replacements[j].where == &XEXP (x, i)) | |
5219 | { | |
5220 | r = &replacements[n_replacements++]; | |
5221 | r->where = &XEXP (y, i); | |
5222 | r->subreg_loc = 0; | |
5223 | r->what = replacements[j].what; | |
5224 | r->mode = replacements[j].mode; | |
5225 | } | |
5226 | } | |
5227 | } | |
5228 | \f | |
af929c62 RK |
5229 | /* If LOC was scheduled to be replaced by something, return the replacement. |
5230 | Otherwise, return *LOC. */ | |
5231 | ||
5232 | rtx | |
5233 | find_replacement (loc) | |
5234 | rtx *loc; | |
5235 | { | |
5236 | struct replacement *r; | |
5237 | ||
5238 | for (r = &replacements[0]; r < &replacements[n_replacements]; r++) | |
5239 | { | |
5240 | rtx reloadreg = reload_reg_rtx[r->what]; | |
5241 | ||
5242 | if (reloadreg && r->where == loc) | |
5243 | { | |
5244 | if (r->mode != VOIDmode && GET_MODE (reloadreg) != r->mode) | |
5245 | reloadreg = gen_rtx (REG, r->mode, REGNO (reloadreg)); | |
5246 | ||
5247 | return reloadreg; | |
5248 | } | |
5249 | else if (reloadreg && r->subreg_loc == loc) | |
5250 | { | |
5251 | /* RELOADREG must be either a REG or a SUBREG. | |
5252 | ||
5253 | ??? Is it actually still ever a SUBREG? If so, why? */ | |
5254 | ||
5255 | if (GET_CODE (reloadreg) == REG) | |
5256 | return gen_rtx (REG, GET_MODE (*loc), | |
5257 | REGNO (reloadreg) + SUBREG_WORD (*loc)); | |
5258 | else if (GET_MODE (reloadreg) == GET_MODE (*loc)) | |
5259 | return reloadreg; | |
5260 | else | |
5261 | return gen_rtx (SUBREG, GET_MODE (*loc), SUBREG_REG (reloadreg), | |
5262 | SUBREG_WORD (reloadreg) + SUBREG_WORD (*loc)); | |
5263 | } | |
5264 | } | |
5265 | ||
5266 | return *loc; | |
5267 | } | |
5268 | \f | |
eab89b90 RK |
5269 | /* Return nonzero if register in range [REGNO, ENDREGNO) |
5270 | appears either explicitly or implicitly in X | |
4644aad4 | 5271 | other than being stored into (except for earlyclobber operands). |
eab89b90 RK |
5272 | |
5273 | References contained within the substructure at LOC do not count. | |
5274 | LOC may be zero, meaning don't ignore anything. | |
5275 | ||
5276 | This is similar to refers_to_regno_p in rtlanal.c except that we | |
5277 | look at equivalences for pseudos that didn't get hard registers. */ | |
5278 | ||
5279 | int | |
5280 | refers_to_regno_for_reload_p (regno, endregno, x, loc) | |
5281 | int regno, endregno; | |
5282 | rtx x; | |
5283 | rtx *loc; | |
5284 | { | |
5285 | register int i; | |
5286 | register RTX_CODE code; | |
5287 | register char *fmt; | |
5288 | ||
5289 | if (x == 0) | |
5290 | return 0; | |
5291 | ||
5292 | repeat: | |
5293 | code = GET_CODE (x); | |
5294 | ||
5295 | switch (code) | |
5296 | { | |
5297 | case REG: | |
5298 | i = REGNO (x); | |
5299 | ||
4803a34a RK |
5300 | /* If this is a pseudo, a hard register must not have been allocated. |
5301 | X must therefore either be a constant or be in memory. */ | |
5302 | if (i >= FIRST_PSEUDO_REGISTER) | |
5303 | { | |
5304 | if (reg_equiv_memory_loc[i]) | |
5305 | return refers_to_regno_for_reload_p (regno, endregno, | |
fb3821f7 CH |
5306 | reg_equiv_memory_loc[i], |
5307 | NULL_PTR); | |
4803a34a RK |
5308 | |
5309 | if (reg_equiv_constant[i]) | |
5310 | return 0; | |
5311 | ||
5312 | abort (); | |
5313 | } | |
eab89b90 RK |
5314 | |
5315 | return (endregno > i | |
5316 | && regno < i + (i < FIRST_PSEUDO_REGISTER | |
5317 | ? HARD_REGNO_NREGS (i, GET_MODE (x)) | |
5318 | : 1)); | |
5319 | ||
5320 | case SUBREG: | |
5321 | /* If this is a SUBREG of a hard reg, we can see exactly which | |
5322 | registers are being modified. Otherwise, handle normally. */ | |
5323 | if (GET_CODE (SUBREG_REG (x)) == REG | |
5324 | && REGNO (SUBREG_REG (x)) < FIRST_PSEUDO_REGISTER) | |
5325 | { | |
5326 | int inner_regno = REGNO (SUBREG_REG (x)) + SUBREG_WORD (x); | |
5327 | int inner_endregno | |
5328 | = inner_regno + (inner_regno < FIRST_PSEUDO_REGISTER | |
5329 | ? HARD_REGNO_NREGS (regno, GET_MODE (x)) : 1); | |
5330 | ||
5331 | return endregno > inner_regno && regno < inner_endregno; | |
5332 | } | |
5333 | break; | |
5334 | ||
5335 | case CLOBBER: | |
5336 | case SET: | |
5337 | if (&SET_DEST (x) != loc | |
5338 | /* Note setting a SUBREG counts as referring to the REG it is in for | |
5339 | a pseudo but not for hard registers since we can | |
5340 | treat each word individually. */ | |
5341 | && ((GET_CODE (SET_DEST (x)) == SUBREG | |
5342 | && loc != &SUBREG_REG (SET_DEST (x)) | |
5343 | && GET_CODE (SUBREG_REG (SET_DEST (x))) == REG | |
5344 | && REGNO (SUBREG_REG (SET_DEST (x))) >= FIRST_PSEUDO_REGISTER | |
5345 | && refers_to_regno_for_reload_p (regno, endregno, | |
5346 | SUBREG_REG (SET_DEST (x)), | |
5347 | loc)) | |
abc95ed3 | 5348 | /* If the output is an earlyclobber operand, this is |
4644aad4 RK |
5349 | a conflict. */ |
5350 | || ((GET_CODE (SET_DEST (x)) != REG | |
5351 | || earlyclobber_operand_p (SET_DEST (x))) | |
eab89b90 RK |
5352 | && refers_to_regno_for_reload_p (regno, endregno, |
5353 | SET_DEST (x), loc)))) | |
5354 | return 1; | |
5355 | ||
5356 | if (code == CLOBBER || loc == &SET_SRC (x)) | |
5357 | return 0; | |
5358 | x = SET_SRC (x); | |
5359 | goto repeat; | |
5360 | } | |
5361 | ||
5362 | /* X does not match, so try its subexpressions. */ | |
5363 | ||
5364 | fmt = GET_RTX_FORMAT (code); | |
5365 | for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) | |
5366 | { | |
5367 | if (fmt[i] == 'e' && loc != &XEXP (x, i)) | |
5368 | { | |
5369 | if (i == 0) | |
5370 | { | |
5371 | x = XEXP (x, 0); | |
5372 | goto repeat; | |
5373 | } | |
5374 | else | |
5375 | if (refers_to_regno_for_reload_p (regno, endregno, | |
5376 | XEXP (x, i), loc)) | |
5377 | return 1; | |
5378 | } | |
5379 | else if (fmt[i] == 'E') | |
5380 | { | |
5381 | register int j; | |
5382 | for (j = XVECLEN (x, i) - 1; j >=0; j--) | |
5383 | if (loc != &XVECEXP (x, i, j) | |
5384 | && refers_to_regno_for_reload_p (regno, endregno, | |
5385 | XVECEXP (x, i, j), loc)) | |
5386 | return 1; | |
5387 | } | |
5388 | } | |
5389 | return 0; | |
5390 | } | |
bfa30b22 RK |
5391 | |
5392 | /* Nonzero if modifying X will affect IN. If X is a register or a SUBREG, | |
5393 | we check if any register number in X conflicts with the relevant register | |
5394 | numbers. If X is a constant, return 0. If X is a MEM, return 1 iff IN | |
5395 | contains a MEM (we don't bother checking for memory addresses that can't | |
5396 | conflict because we expect this to be a rare case. | |
5397 | ||
5398 | This function is similar to reg_overlap_mention_p in rtlanal.c except | |
5399 | that we look at equivalences for pseudos that didn't get hard registers. */ | |
5400 | ||
5401 | int | |
5402 | reg_overlap_mentioned_for_reload_p (x, in) | |
5403 | rtx x, in; | |
5404 | { | |
5405 | int regno, endregno; | |
5406 | ||
5407 | if (GET_CODE (x) == SUBREG) | |
5408 | { | |
5409 | regno = REGNO (SUBREG_REG (x)); | |
5410 | if (regno < FIRST_PSEUDO_REGISTER) | |
5411 | regno += SUBREG_WORD (x); | |
5412 | } | |
5413 | else if (GET_CODE (x) == REG) | |
5414 | { | |
5415 | regno = REGNO (x); | |
4803a34a RK |
5416 | |
5417 | /* If this is a pseudo, it must not have been assigned a hard register. | |
5418 | Therefore, it must either be in memory or be a constant. */ | |
5419 | ||
5420 | if (regno >= FIRST_PSEUDO_REGISTER) | |
5421 | { | |
5422 | if (reg_equiv_memory_loc[regno]) | |
5423 | return refers_to_mem_for_reload_p (in); | |
5424 | else if (reg_equiv_constant[regno]) | |
5425 | return 0; | |
5426 | abort (); | |
5427 | } | |
bfa30b22 RK |
5428 | } |
5429 | else if (CONSTANT_P (x)) | |
5430 | return 0; | |
5431 | else if (GET_CODE (x) == MEM) | |
4803a34a | 5432 | return refers_to_mem_for_reload_p (in); |
bfa30b22 RK |
5433 | else if (GET_CODE (x) == SCRATCH || GET_CODE (x) == PC |
5434 | || GET_CODE (x) == CC0) | |
5435 | return reg_mentioned_p (x, in); | |
5436 | else | |
5437 | abort (); | |
5438 | ||
5439 | endregno = regno + (regno < FIRST_PSEUDO_REGISTER | |
5440 | ? HARD_REGNO_NREGS (regno, GET_MODE (x)) : 1); | |
5441 | ||
fb3821f7 | 5442 | return refers_to_regno_for_reload_p (regno, endregno, in, NULL_PTR); |
bfa30b22 | 5443 | } |
4803a34a RK |
5444 | |
5445 | /* Return nonzero if anything in X contains a MEM. Look also for pseudo | |
5446 | registers. */ | |
5447 | ||
5448 | int | |
5449 | refers_to_mem_for_reload_p (x) | |
5450 | rtx x; | |
5451 | { | |
5452 | char *fmt; | |
5453 | int i; | |
5454 | ||
5455 | if (GET_CODE (x) == MEM) | |
5456 | return 1; | |
5457 | ||
5458 | if (GET_CODE (x) == REG) | |
5459 | return (REGNO (x) >= FIRST_PSEUDO_REGISTER | |
5460 | && reg_equiv_memory_loc[REGNO (x)]); | |
5461 | ||
5462 | fmt = GET_RTX_FORMAT (GET_CODE (x)); | |
5463 | for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--) | |
5464 | if (fmt[i] == 'e' | |
5465 | && (GET_CODE (XEXP (x, i)) == MEM | |
5466 | || refers_to_mem_for_reload_p (XEXP (x, i)))) | |
5467 | return 1; | |
5468 | ||
5469 | return 0; | |
5470 | } | |
eab89b90 | 5471 | \f |
eab89b90 RK |
5472 | /* Check the insns before INSN to see if there is a suitable register |
5473 | containing the same value as GOAL. | |
5474 | If OTHER is -1, look for a register in class CLASS. | |
5475 | Otherwise, just see if register number OTHER shares GOAL's value. | |
5476 | ||
5477 | Return an rtx for the register found, or zero if none is found. | |
5478 | ||
5479 | If RELOAD_REG_P is (short *)1, | |
5480 | we reject any hard reg that appears in reload_reg_rtx | |
5481 | because such a hard reg is also needed coming into this insn. | |
5482 | ||
5483 | If RELOAD_REG_P is any other nonzero value, | |
5484 | it is a vector indexed by hard reg number | |
5485 | and we reject any hard reg whose element in the vector is nonnegative | |
5486 | as well as any that appears in reload_reg_rtx. | |
5487 | ||
5488 | If GOAL is zero, then GOALREG is a register number; we look | |
5489 | for an equivalent for that register. | |
5490 | ||
5491 | MODE is the machine mode of the value we want an equivalence for. | |
5492 | If GOAL is nonzero and not VOIDmode, then it must have mode MODE. | |
5493 | ||
5494 | This function is used by jump.c as well as in the reload pass. | |
5495 | ||
5496 | If GOAL is the sum of the stack pointer and a constant, we treat it | |
5497 | as if it were a constant except that sp is required to be unchanging. */ | |
5498 | ||
5499 | rtx | |
5500 | find_equiv_reg (goal, insn, class, other, reload_reg_p, goalreg, mode) | |
5501 | register rtx goal; | |
5502 | rtx insn; | |
5503 | enum reg_class class; | |
5504 | register int other; | |
5505 | short *reload_reg_p; | |
5506 | int goalreg; | |
5507 | enum machine_mode mode; | |
5508 | { | |
5509 | register rtx p = insn; | |
f55b1d97 | 5510 | rtx goaltry, valtry, value, where; |
eab89b90 RK |
5511 | register rtx pat; |
5512 | register int regno = -1; | |
5513 | int valueno; | |
5514 | int goal_mem = 0; | |
5515 | int goal_const = 0; | |
5516 | int goal_mem_addr_varies = 0; | |
5517 | int need_stable_sp = 0; | |
5518 | int nregs; | |
5519 | int valuenregs; | |
5520 | ||
5521 | if (goal == 0) | |
5522 | regno = goalreg; | |
5523 | else if (GET_CODE (goal) == REG) | |
5524 | regno = REGNO (goal); | |
5525 | else if (GET_CODE (goal) == MEM) | |
5526 | { | |
5527 | enum rtx_code code = GET_CODE (XEXP (goal, 0)); | |
5528 | if (MEM_VOLATILE_P (goal)) | |
5529 | return 0; | |
5530 | if (flag_float_store && GET_MODE_CLASS (GET_MODE (goal)) == MODE_FLOAT) | |
5531 | return 0; | |
5532 | /* An address with side effects must be reexecuted. */ | |
5533 | switch (code) | |
5534 | { | |
5535 | case POST_INC: | |
5536 | case PRE_INC: | |
5537 | case POST_DEC: | |
5538 | case PRE_DEC: | |
5539 | return 0; | |
5540 | } | |
5541 | goal_mem = 1; | |
5542 | } | |
5543 | else if (CONSTANT_P (goal)) | |
5544 | goal_const = 1; | |
5545 | else if (GET_CODE (goal) == PLUS | |
5546 | && XEXP (goal, 0) == stack_pointer_rtx | |
5547 | && CONSTANT_P (XEXP (goal, 1))) | |
5548 | goal_const = need_stable_sp = 1; | |
5549 | else | |
5550 | return 0; | |
5551 | ||
5552 | /* On some machines, certain regs must always be rejected | |
5553 | because they don't behave the way ordinary registers do. */ | |
5554 | ||
5555 | #ifdef OVERLAPPING_REGNO_P | |
5556 | if (regno >= 0 && regno < FIRST_PSEUDO_REGISTER | |
5557 | && OVERLAPPING_REGNO_P (regno)) | |
5558 | return 0; | |
5559 | #endif | |
5560 | ||
5561 | /* Scan insns back from INSN, looking for one that copies | |
5562 | a value into or out of GOAL. | |
5563 | Stop and give up if we reach a label. */ | |
5564 | ||
5565 | while (1) | |
5566 | { | |
5567 | p = PREV_INSN (p); | |
5568 | if (p == 0 || GET_CODE (p) == CODE_LABEL) | |
5569 | return 0; | |
5570 | if (GET_CODE (p) == INSN | |
0f41302f | 5571 | /* If we don't want spill regs ... */ |
a8c9daeb RK |
5572 | && (! (reload_reg_p != 0 |
5573 | && reload_reg_p != (short *) (HOST_WIDE_INT) 1) | |
eab89b90 RK |
5574 | /* ... then ignore insns introduced by reload; they aren't useful |
5575 | and can cause results in reload_as_needed to be different | |
5576 | from what they were when calculating the need for spills. | |
5577 | If we notice an input-reload insn here, we will reject it below, | |
5578 | but it might hide a usable equivalent. That makes bad code. | |
5579 | It may even abort: perhaps no reg was spilled for this insn | |
5580 | because it was assumed we would find that equivalent. */ | |
5581 | || INSN_UID (p) < reload_first_uid)) | |
5582 | { | |
e8094962 | 5583 | rtx tem; |
eab89b90 RK |
5584 | pat = single_set (p); |
5585 | /* First check for something that sets some reg equal to GOAL. */ | |
5586 | if (pat != 0 | |
5587 | && ((regno >= 0 | |
5588 | && true_regnum (SET_SRC (pat)) == regno | |
5589 | && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0) | |
5590 | || | |
5591 | (regno >= 0 | |
5592 | && true_regnum (SET_DEST (pat)) == regno | |
5593 | && (valueno = true_regnum (valtry = SET_SRC (pat))) >= 0) | |
5594 | || | |
5595 | (goal_const && rtx_equal_p (SET_SRC (pat), goal) | |
5596 | && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0) | |
5597 | || (goal_mem | |
5598 | && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0 | |
5599 | && rtx_renumbered_equal_p (goal, SET_SRC (pat))) | |
5600 | || (goal_mem | |
5601 | && (valueno = true_regnum (valtry = SET_SRC (pat))) >= 0 | |
e8094962 RK |
5602 | && rtx_renumbered_equal_p (goal, SET_DEST (pat))) |
5603 | /* If we are looking for a constant, | |
5604 | and something equivalent to that constant was copied | |
5605 | into a reg, we can use that reg. */ | |
fb3821f7 CH |
5606 | || (goal_const && (tem = find_reg_note (p, REG_EQUIV, |
5607 | NULL_RTX)) | |
e8094962 | 5608 | && rtx_equal_p (XEXP (tem, 0), goal) |
95d3562b | 5609 | && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0) |
fb3821f7 CH |
5610 | || (goal_const && (tem = find_reg_note (p, REG_EQUIV, |
5611 | NULL_RTX)) | |
e8094962 RK |
5612 | && GET_CODE (SET_DEST (pat)) == REG |
5613 | && GET_CODE (XEXP (tem, 0)) == CONST_DOUBLE | |
5614 | && GET_MODE_CLASS (GET_MODE (XEXP (tem, 0))) == MODE_FLOAT | |
5615 | && GET_CODE (goal) == CONST_INT | |
f55b1d97 RK |
5616 | && 0 != (goaltry = operand_subword (XEXP (tem, 0), 0, 0, |
5617 | VOIDmode)) | |
5618 | && rtx_equal_p (goal, goaltry) | |
e8094962 RK |
5619 | && (valtry = operand_subword (SET_DEST (pat), 0, 0, |
5620 | VOIDmode)) | |
95d3562b | 5621 | && (valueno = true_regnum (valtry)) >= 0) |
fb3821f7 CH |
5622 | || (goal_const && (tem = find_reg_note (p, REG_EQUIV, |
5623 | NULL_RTX)) | |
e8094962 RK |
5624 | && GET_CODE (SET_DEST (pat)) == REG |
5625 | && GET_CODE (XEXP (tem, 0)) == CONST_DOUBLE | |
5626 | && GET_MODE_CLASS (GET_MODE (XEXP (tem, 0))) == MODE_FLOAT | |
5627 | && GET_CODE (goal) == CONST_INT | |
f55b1d97 RK |
5628 | && 0 != (goaltry = operand_subword (XEXP (tem, 0), 1, 0, |
5629 | VOIDmode)) | |
5630 | && rtx_equal_p (goal, goaltry) | |
e8094962 RK |
5631 | && (valtry |
5632 | = operand_subword (SET_DEST (pat), 1, 0, VOIDmode)) | |
95d3562b | 5633 | && (valueno = true_regnum (valtry)) >= 0))) |
eab89b90 RK |
5634 | if (other >= 0 |
5635 | ? valueno == other | |
5636 | : ((unsigned) valueno < FIRST_PSEUDO_REGISTER | |
5637 | && TEST_HARD_REG_BIT (reg_class_contents[(int) class], | |
5638 | valueno))) | |
5639 | { | |
5640 | value = valtry; | |
5641 | where = p; | |
5642 | break; | |
5643 | } | |
5644 | } | |
5645 | } | |
5646 | ||
5647 | /* We found a previous insn copying GOAL into a suitable other reg VALUE | |
5648 | (or copying VALUE into GOAL, if GOAL is also a register). | |
5649 | Now verify that VALUE is really valid. */ | |
5650 | ||
5651 | /* VALUENO is the register number of VALUE; a hard register. */ | |
5652 | ||
5653 | /* Don't try to re-use something that is killed in this insn. We want | |
5654 | to be able to trust REG_UNUSED notes. */ | |
5655 | if (find_reg_note (where, REG_UNUSED, value)) | |
5656 | return 0; | |
5657 | ||
5658 | /* If we propose to get the value from the stack pointer or if GOAL is | |
5659 | a MEM based on the stack pointer, we need a stable SP. */ | |
d5a1d1c7 | 5660 | if (valueno == STACK_POINTER_REGNUM || regno == STACK_POINTER_REGNUM |
bfa30b22 RK |
5661 | || (goal_mem && reg_overlap_mentioned_for_reload_p (stack_pointer_rtx, |
5662 | goal))) | |
eab89b90 RK |
5663 | need_stable_sp = 1; |
5664 | ||
5665 | /* Reject VALUE if the copy-insn moved the wrong sort of datum. */ | |
5666 | if (GET_MODE (value) != mode) | |
5667 | return 0; | |
5668 | ||
5669 | /* Reject VALUE if it was loaded from GOAL | |
5670 | and is also a register that appears in the address of GOAL. */ | |
5671 | ||
bd5f6d44 | 5672 | if (goal_mem && value == SET_DEST (single_set (where)) |
bfa30b22 RK |
5673 | && refers_to_regno_for_reload_p (valueno, |
5674 | (valueno | |
5675 | + HARD_REGNO_NREGS (valueno, mode)), | |
fb3821f7 | 5676 | goal, NULL_PTR)) |
eab89b90 RK |
5677 | return 0; |
5678 | ||
5679 | /* Reject registers that overlap GOAL. */ | |
5680 | ||
5681 | if (!goal_mem && !goal_const | |
5682 | && regno + HARD_REGNO_NREGS (regno, mode) > valueno | |
5683 | && regno < valueno + HARD_REGNO_NREGS (valueno, mode)) | |
5684 | return 0; | |
5685 | ||
5686 | /* Reject VALUE if it is one of the regs reserved for reloads. | |
5687 | Reload1 knows how to reuse them anyway, and it would get | |
5688 | confused if we allocated one without its knowledge. | |
5689 | (Now that insns introduced by reload are ignored above, | |
5690 | this case shouldn't happen, but I'm not positive.) */ | |
5691 | ||
a8c9daeb | 5692 | if (reload_reg_p != 0 && reload_reg_p != (short *) (HOST_WIDE_INT) 1 |
eab89b90 RK |
5693 | && reload_reg_p[valueno] >= 0) |
5694 | return 0; | |
5695 | ||
5696 | /* On some machines, certain regs must always be rejected | |
5697 | because they don't behave the way ordinary registers do. */ | |
5698 | ||
5699 | #ifdef OVERLAPPING_REGNO_P | |
5700 | if (OVERLAPPING_REGNO_P (valueno)) | |
5701 | return 0; | |
5702 | #endif | |
5703 | ||
5704 | nregs = HARD_REGNO_NREGS (regno, mode); | |
5705 | valuenregs = HARD_REGNO_NREGS (valueno, mode); | |
5706 | ||
5707 | /* Reject VALUE if it is a register being used for an input reload | |
5708 | even if it is not one of those reserved. */ | |
5709 | ||
5710 | if (reload_reg_p != 0) | |
5711 | { | |
5712 | int i; | |
5713 | for (i = 0; i < n_reloads; i++) | |
5714 | if (reload_reg_rtx[i] != 0 && reload_in[i]) | |
5715 | { | |
5716 | int regno1 = REGNO (reload_reg_rtx[i]); | |
5717 | int nregs1 = HARD_REGNO_NREGS (regno1, | |
5718 | GET_MODE (reload_reg_rtx[i])); | |
5719 | if (regno1 < valueno + valuenregs | |
5720 | && regno1 + nregs1 > valueno) | |
5721 | return 0; | |
5722 | } | |
5723 | } | |
5724 | ||
5725 | if (goal_mem) | |
54b5ffe9 RS |
5726 | /* We must treat frame pointer as varying here, |
5727 | since it can vary--in a nonlocal goto as generated by expand_goto. */ | |
5728 | goal_mem_addr_varies = !CONSTANT_ADDRESS_P (XEXP (goal, 0)); | |
eab89b90 RK |
5729 | |
5730 | /* Now verify that the values of GOAL and VALUE remain unaltered | |
5731 | until INSN is reached. */ | |
5732 | ||
5733 | p = insn; | |
5734 | while (1) | |
5735 | { | |
5736 | p = PREV_INSN (p); | |
5737 | if (p == where) | |
5738 | return value; | |
5739 | ||
5740 | /* Don't trust the conversion past a function call | |
5741 | if either of the two is in a call-clobbered register, or memory. */ | |
5742 | if (GET_CODE (p) == CALL_INSN | |
5743 | && ((regno >= 0 && regno < FIRST_PSEUDO_REGISTER | |
5744 | && call_used_regs[regno]) | |
5745 | || | |
5746 | (valueno >= 0 && valueno < FIRST_PSEUDO_REGISTER | |
5747 | && call_used_regs[valueno]) | |
5748 | || | |
5749 | goal_mem | |
5750 | || need_stable_sp)) | |
5751 | return 0; | |
5752 | ||
41fe17ab RK |
5753 | #ifdef NON_SAVING_SETJMP |
5754 | if (NON_SAVING_SETJMP && GET_CODE (p) == NOTE | |
5755 | && NOTE_LINE_NUMBER (p) == NOTE_INSN_SETJMP) | |
5756 | return 0; | |
5757 | #endif | |
5758 | ||
eab89b90 RK |
5759 | #ifdef INSN_CLOBBERS_REGNO_P |
5760 | if ((valueno >= 0 && valueno < FIRST_PSEUDO_REGISTER | |
5761 | && INSN_CLOBBERS_REGNO_P (p, valueno)) | |
5762 | || (regno >= 0 && regno < FIRST_PSEUDO_REGISTER | |
5763 | && INSN_CLOBBERS_REGNO_P (p, regno))) | |
5764 | return 0; | |
5765 | #endif | |
5766 | ||
5767 | if (GET_RTX_CLASS (GET_CODE (p)) == 'i') | |
5768 | { | |
5769 | /* If this insn P stores in either GOAL or VALUE, return 0. | |
5770 | If GOAL is a memory ref and this insn writes memory, return 0. | |
5771 | If GOAL is a memory ref and its address is not constant, | |
5772 | and this insn P changes a register used in GOAL, return 0. */ | |
5773 | ||
5774 | pat = PATTERN (p); | |
5775 | if (GET_CODE (pat) == SET || GET_CODE (pat) == CLOBBER) | |
5776 | { | |
5777 | register rtx dest = SET_DEST (pat); | |
5778 | while (GET_CODE (dest) == SUBREG | |
5779 | || GET_CODE (dest) == ZERO_EXTRACT | |
5780 | || GET_CODE (dest) == SIGN_EXTRACT | |
5781 | || GET_CODE (dest) == STRICT_LOW_PART) | |
5782 | dest = XEXP (dest, 0); | |
5783 | if (GET_CODE (dest) == REG) | |
5784 | { | |
5785 | register int xregno = REGNO (dest); | |
5786 | int xnregs; | |
5787 | if (REGNO (dest) < FIRST_PSEUDO_REGISTER) | |
5788 | xnregs = HARD_REGNO_NREGS (xregno, GET_MODE (dest)); | |
5789 | else | |
5790 | xnregs = 1; | |
5791 | if (xregno < regno + nregs && xregno + xnregs > regno) | |
5792 | return 0; | |
5793 | if (xregno < valueno + valuenregs | |
5794 | && xregno + xnregs > valueno) | |
5795 | return 0; | |
5796 | if (goal_mem_addr_varies | |
bfa30b22 | 5797 | && reg_overlap_mentioned_for_reload_p (dest, goal)) |
eab89b90 RK |
5798 | return 0; |
5799 | } | |
5800 | else if (goal_mem && GET_CODE (dest) == MEM | |
5801 | && ! push_operand (dest, GET_MODE (dest))) | |
5802 | return 0; | |
9fac9680 RK |
5803 | else if (GET_CODE (dest) == MEM && regno >= FIRST_PSEUDO_REGISTER |
5804 | && reg_equiv_memory_loc[regno] != 0) | |
5805 | return 0; | |
eab89b90 RK |
5806 | else if (need_stable_sp && push_operand (dest, GET_MODE (dest))) |
5807 | return 0; | |
5808 | } | |
5809 | else if (GET_CODE (pat) == PARALLEL) | |
5810 | { | |
5811 | register int i; | |
5812 | for (i = XVECLEN (pat, 0) - 1; i >= 0; i--) | |
5813 | { | |
5814 | register rtx v1 = XVECEXP (pat, 0, i); | |
5815 | if (GET_CODE (v1) == SET || GET_CODE (v1) == CLOBBER) | |
5816 | { | |
5817 | register rtx dest = SET_DEST (v1); | |
5818 | while (GET_CODE (dest) == SUBREG | |
5819 | || GET_CODE (dest) == ZERO_EXTRACT | |
5820 | || GET_CODE (dest) == SIGN_EXTRACT | |
5821 | || GET_CODE (dest) == STRICT_LOW_PART) | |
5822 | dest = XEXP (dest, 0); | |
5823 | if (GET_CODE (dest) == REG) | |
5824 | { | |
5825 | register int xregno = REGNO (dest); | |
5826 | int xnregs; | |
5827 | if (REGNO (dest) < FIRST_PSEUDO_REGISTER) | |
5828 | xnregs = HARD_REGNO_NREGS (xregno, GET_MODE (dest)); | |
5829 | else | |
5830 | xnregs = 1; | |
5831 | if (xregno < regno + nregs | |
5832 | && xregno + xnregs > regno) | |
5833 | return 0; | |
5834 | if (xregno < valueno + valuenregs | |
5835 | && xregno + xnregs > valueno) | |
5836 | return 0; | |
5837 | if (goal_mem_addr_varies | |
bfa30b22 RK |
5838 | && reg_overlap_mentioned_for_reload_p (dest, |
5839 | goal)) | |
eab89b90 RK |
5840 | return 0; |
5841 | } | |
5842 | else if (goal_mem && GET_CODE (dest) == MEM | |
5843 | && ! push_operand (dest, GET_MODE (dest))) | |
5844 | return 0; | |
369c7ab6 JW |
5845 | else if (need_stable_sp |
5846 | && push_operand (dest, GET_MODE (dest))) | |
5847 | return 0; | |
5848 | } | |
5849 | } | |
5850 | } | |
5851 | ||
5852 | if (GET_CODE (p) == CALL_INSN && CALL_INSN_FUNCTION_USAGE (p)) | |
5853 | { | |
5854 | rtx link; | |
5855 | ||
5856 | for (link = CALL_INSN_FUNCTION_USAGE (p); XEXP (link, 1) != 0; | |
5857 | link = XEXP (link, 1)) | |
5858 | { | |
5859 | pat = XEXP (link, 0); | |
5860 | if (GET_CODE (pat) == CLOBBER) | |
5861 | { | |
5862 | register rtx dest = SET_DEST (pat); | |
5863 | while (GET_CODE (dest) == SUBREG | |
5864 | || GET_CODE (dest) == ZERO_EXTRACT | |
5865 | || GET_CODE (dest) == SIGN_EXTRACT | |
5866 | || GET_CODE (dest) == STRICT_LOW_PART) | |
5867 | dest = XEXP (dest, 0); | |
5868 | if (GET_CODE (dest) == REG) | |
5869 | { | |
5870 | register int xregno = REGNO (dest); | |
5871 | int xnregs; | |
5872 | if (REGNO (dest) < FIRST_PSEUDO_REGISTER) | |
5873 | xnregs = HARD_REGNO_NREGS (xregno, GET_MODE (dest)); | |
5874 | else | |
5875 | xnregs = 1; | |
5876 | if (xregno < regno + nregs | |
5877 | && xregno + xnregs > regno) | |
5878 | return 0; | |
5879 | if (xregno < valueno + valuenregs | |
5880 | && xregno + xnregs > valueno) | |
5881 | return 0; | |
5882 | if (goal_mem_addr_varies | |
5883 | && reg_overlap_mentioned_for_reload_p (dest, | |
5884 | goal)) | |
5885 | return 0; | |
5886 | } | |
5887 | else if (goal_mem && GET_CODE (dest) == MEM | |
5888 | && ! push_operand (dest, GET_MODE (dest))) | |
5889 | return 0; | |
eab89b90 RK |
5890 | else if (need_stable_sp |
5891 | && push_operand (dest, GET_MODE (dest))) | |
5892 | return 0; | |
5893 | } | |
5894 | } | |
5895 | } | |
5896 | ||
5897 | #ifdef AUTO_INC_DEC | |
5898 | /* If this insn auto-increments or auto-decrements | |
5899 | either regno or valueno, return 0 now. | |
5900 | If GOAL is a memory ref and its address is not constant, | |
5901 | and this insn P increments a register used in GOAL, return 0. */ | |
5902 | { | |
5903 | register rtx link; | |
5904 | ||
5905 | for (link = REG_NOTES (p); link; link = XEXP (link, 1)) | |
5906 | if (REG_NOTE_KIND (link) == REG_INC | |
5907 | && GET_CODE (XEXP (link, 0)) == REG) | |
5908 | { | |
5909 | register int incno = REGNO (XEXP (link, 0)); | |
5910 | if (incno < regno + nregs && incno >= regno) | |
5911 | return 0; | |
5912 | if (incno < valueno + valuenregs && incno >= valueno) | |
5913 | return 0; | |
5914 | if (goal_mem_addr_varies | |
bfa30b22 RK |
5915 | && reg_overlap_mentioned_for_reload_p (XEXP (link, 0), |
5916 | goal)) | |
eab89b90 RK |
5917 | return 0; |
5918 | } | |
5919 | } | |
5920 | #endif | |
5921 | } | |
5922 | } | |
5923 | } | |
5924 | \f | |
5925 | /* Find a place where INCED appears in an increment or decrement operator | |
5926 | within X, and return the amount INCED is incremented or decremented by. | |
5927 | The value is always positive. */ | |
5928 | ||
5929 | static int | |
5930 | find_inc_amount (x, inced) | |
5931 | rtx x, inced; | |
5932 | { | |
5933 | register enum rtx_code code = GET_CODE (x); | |
5934 | register char *fmt; | |
5935 | register int i; | |
5936 | ||
5937 | if (code == MEM) | |
5938 | { | |
5939 | register rtx addr = XEXP (x, 0); | |
5940 | if ((GET_CODE (addr) == PRE_DEC | |
5941 | || GET_CODE (addr) == POST_DEC | |
5942 | || GET_CODE (addr) == PRE_INC | |
5943 | || GET_CODE (addr) == POST_INC) | |
5944 | && XEXP (addr, 0) == inced) | |
5945 | return GET_MODE_SIZE (GET_MODE (x)); | |
5946 | } | |
5947 | ||
5948 | fmt = GET_RTX_FORMAT (code); | |
5949 | for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) | |
5950 | { | |
5951 | if (fmt[i] == 'e') | |
5952 | { | |
5953 | register int tem = find_inc_amount (XEXP (x, i), inced); | |
5954 | if (tem != 0) | |
5955 | return tem; | |
5956 | } | |
5957 | if (fmt[i] == 'E') | |
5958 | { | |
5959 | register int j; | |
5960 | for (j = XVECLEN (x, i) - 1; j >= 0; j--) | |
5961 | { | |
5962 | register int tem = find_inc_amount (XVECEXP (x, i, j), inced); | |
5963 | if (tem != 0) | |
5964 | return tem; | |
5965 | } | |
5966 | } | |
5967 | } | |
5968 | ||
5969 | return 0; | |
5970 | } | |
5971 | \f | |
5972 | /* Return 1 if register REGNO is the subject of a clobber in insn INSN. */ | |
5973 | ||
5974 | int | |
5975 | regno_clobbered_p (regno, insn) | |
5976 | int regno; | |
5977 | rtx insn; | |
5978 | { | |
5979 | if (GET_CODE (PATTERN (insn)) == CLOBBER | |
5980 | && GET_CODE (XEXP (PATTERN (insn), 0)) == REG) | |
5981 | return REGNO (XEXP (PATTERN (insn), 0)) == regno; | |
5982 | ||
5983 | if (GET_CODE (PATTERN (insn)) == PARALLEL) | |
5984 | { | |
5985 | int i = XVECLEN (PATTERN (insn), 0) - 1; | |
5986 | ||
5987 | for (; i >= 0; i--) | |
5988 | { | |
5989 | rtx elt = XVECEXP (PATTERN (insn), 0, i); | |
5990 | if (GET_CODE (elt) == CLOBBER && GET_CODE (XEXP (elt, 0)) == REG | |
5991 | && REGNO (XEXP (elt, 0)) == regno) | |
5992 | return 1; | |
5993 | } | |
5994 | } | |
5995 | ||
5996 | return 0; | |
5997 | } | |
10bcde0d RK |
5998 | |
5999 | static char *reload_when_needed_name[] = | |
6000 | { | |
6001 | "RELOAD_FOR_INPUT", | |
6002 | "RELOAD_FOR_OUTPUT", | |
6003 | "RELOAD_FOR_INSN", | |
47c8cf91 ILT |
6004 | "RELOAD_FOR_INPUT_ADDRESS", |
6005 | "RELOAD_FOR_INPADDR_ADDRESS", | |
10bcde0d | 6006 | "RELOAD_FOR_OUTPUT_ADDRESS", |
47c8cf91 | 6007 | "RELOAD_FOR_OUTADDR_ADDRESS", |
10bcde0d RK |
6008 | "RELOAD_FOR_OPERAND_ADDRESS", |
6009 | "RELOAD_FOR_OPADDR_ADDR", | |
6010 | "RELOAD_OTHER", | |
6011 | "RELOAD_FOR_OTHER_ADDRESS" | |
6012 | }; | |
6013 | ||
6014 | static char *reg_class_names[] = REG_CLASS_NAMES; | |
6015 | ||
6016 | /* This function is used to print the variables set by 'find_reloads' */ | |
6017 | ||
6018 | void | |
6019 | debug_reload() | |
6020 | { | |
6021 | int r; | |
6022 | ||
6023 | fprintf (stderr, "\nn_reloads = %d\n", n_reloads); | |
6024 | ||
6025 | for (r = 0; r < n_reloads; r++) | |
6026 | { | |
6027 | fprintf (stderr, "\nRELOAD %d\n", r); | |
6028 | ||
6029 | if (reload_in[r]) | |
6030 | { | |
f7393e85 RK |
6031 | fprintf (stderr, "\nreload_in (%s) = ", |
6032 | GET_MODE_NAME (reload_inmode[r])); | |
10bcde0d RK |
6033 | debug_rtx (reload_in[r]); |
6034 | } | |
6035 | ||
6036 | if (reload_out[r]) | |
6037 | { | |
f7393e85 RK |
6038 | fprintf (stderr, "\nreload_out (%s) = ", |
6039 | GET_MODE_NAME (reload_outmode[r])); | |
10bcde0d RK |
6040 | debug_rtx (reload_out[r]); |
6041 | } | |
6042 | ||
6043 | fprintf (stderr, "%s, ", reg_class_names[(int) reload_reg_class[r]]); | |
6044 | ||
f7393e85 RK |
6045 | fprintf (stderr, "%s (opnum = %d)", |
6046 | reload_when_needed_name[(int)reload_when_needed[r]], | |
10bcde0d RK |
6047 | reload_opnum[r]); |
6048 | ||
6049 | if (reload_optional[r]) | |
6050 | fprintf (stderr, ", optional"); | |
6051 | ||
6052 | if (reload_in[r]) | |
6053 | fprintf (stderr, ", inc by %d\n", reload_inc[r]); | |
6054 | ||
6055 | if (reload_nocombine[r]) | |
a3aafe2b | 6056 | fprintf (stderr, ", can't combine", reload_nocombine[r]); |
10bcde0d RK |
6057 | |
6058 | if (reload_secondary_p[r]) | |
6059 | fprintf (stderr, ", secondary_reload_p"); | |
6060 | ||
6061 | if (reload_in_reg[r]) | |
6062 | { | |
6063 | fprintf (stderr, "\nreload_in_reg:\t\t\t"); | |
6064 | debug_rtx (reload_in_reg[r]); | |
6065 | } | |
6066 | ||
6067 | if (reload_reg_rtx[r]) | |
6068 | { | |
6069 | fprintf (stderr, "\nreload_reg_rtx:\t\t\t"); | |
6070 | debug_rtx (reload_reg_rtx[r]); | |
6071 | } | |
6072 | ||
6073 | if (reload_secondary_in_reload[r] != -1) | |
6074 | { | |
6075 | fprintf (stderr, "\nsecondary_in_reload = "); | |
6076 | fprintf (stderr, "%d ", reload_secondary_in_reload[r]); | |
6077 | } | |
6078 | ||
6079 | if (reload_secondary_out_reload[r] != -1) | |
6080 | { | |
6081 | if (reload_secondary_in_reload[r] != -1) | |
6082 | fprintf (stderr, ", secondary_out_reload = "); | |
6083 | else | |
6084 | fprintf (stderr, "\nsecondary_out_reload = "); | |
6085 | ||
6086 | fprintf (stderr, "%d", reload_secondary_out_reload[r]); | |
6087 | } | |
6088 | ||
6089 | ||
6090 | if (reload_secondary_in_icode[r] != CODE_FOR_nothing) | |
6091 | { | |
6092 | fprintf (stderr, "\nsecondary_in_icode = "); | |
6093 | fprintf (stderr, "%s", insn_name[r]); | |
6094 | } | |
6095 | ||
6096 | if (reload_secondary_out_icode[r] != CODE_FOR_nothing) | |
6097 | { | |
6098 | if (reload_secondary_in_icode[r] != CODE_FOR_nothing) | |
6099 | fprintf (stderr, ", secondary_out_icode = "); | |
6100 | else | |
6101 | fprintf (stderr, "\nsecondary_out_icode = "); | |
6102 | ||
6103 | fprintf (stderr, "%s ", insn_name[r]); | |
6104 | } | |
6105 | fprintf (stderr, "\n"); | |
6106 | } | |
6107 | ||
6108 | fprintf (stderr, "\n"); | |
6109 | } |