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