--with-gnu-ld uses different x- fiile under aix 4.1
[official-gcc.git] / gcc / reg-stack.c
bloba0f48fa1e56234699ce6c3e314b6cdde31277c33
1 /* Register to Stack convert for GNU compiler.
2 Copyright (C) 1992, 93-98, 1999 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* This pass converts stack-like registers from the "flat register
22 file" model that gcc uses, to a stack convention that the 387 uses.
24 * The form of the input:
26 On input, the function consists of insn that have had their
27 registers fully allocated to a set of "virtual" registers. Note that
28 the word "virtual" is used differently here than elsewhere in gcc: for
29 each virtual stack reg, there is a hard reg, but the mapping between
30 them is not known until this pass is run. On output, hard register
31 numbers have been substituted, and various pop and exchange insns have
32 been emitted. The hard register numbers and the virtual register
33 numbers completely overlap - before this pass, all stack register
34 numbers are virtual, and afterward they are all hard.
36 The virtual registers can be manipulated normally by gcc, and their
37 semantics are the same as for normal registers. After the hard
38 register numbers are substituted, the semantics of an insn containing
39 stack-like regs are not the same as for an insn with normal regs: for
40 instance, it is not safe to delete an insn that appears to be a no-op
41 move. In general, no insn containing hard regs should be changed
42 after this pass is done.
44 * The form of the output:
46 After this pass, hard register numbers represent the distance from
47 the current top of stack to the desired register. A reference to
48 FIRST_STACK_REG references the top of stack, FIRST_STACK_REG + 1,
49 represents the register just below that, and so forth. Also, REG_DEAD
50 notes indicate whether or not a stack register should be popped.
52 A "swap" insn looks like a parallel of two patterns, where each
53 pattern is a SET: one sets A to B, the other B to A.
55 A "push" or "load" insn is a SET whose SET_DEST is FIRST_STACK_REG
56 and whose SET_DEST is REG or MEM. Any other SET_DEST, such as PLUS,
57 will replace the existing stack top, not push a new value.
59 A store insn is a SET whose SET_DEST is FIRST_STACK_REG, and whose
60 SET_SRC is REG or MEM.
62 The case where the SET_SRC and SET_DEST are both FIRST_STACK_REG
63 appears ambiguous. As a special case, the presence of a REG_DEAD note
64 for FIRST_STACK_REG differentiates between a load insn and a pop.
66 If a REG_DEAD is present, the insn represents a "pop" that discards
67 the top of the register stack. If there is no REG_DEAD note, then the
68 insn represents a "dup" or a push of the current top of stack onto the
69 stack.
71 * Methodology:
73 Existing REG_DEAD and REG_UNUSED notes for stack registers are
74 deleted and recreated from scratch. REG_DEAD is never created for a
75 SET_DEST, only REG_UNUSED.
77 Before life analysis, the mode of each insn is set based on whether
78 or not any stack registers are mentioned within that insn. VOIDmode
79 means that no regs are mentioned anyway, and QImode means that at
80 least one pattern within the insn mentions stack registers. This
81 information is valid until after reg_to_stack returns, and is used
82 from jump_optimize.
84 * asm_operands:
86 There are several rules on the usage of stack-like regs in
87 asm_operands insns. These rules apply only to the operands that are
88 stack-like regs:
90 1. Given a set of input regs that die in an asm_operands, it is
91 necessary to know which are implicitly popped by the asm, and
92 which must be explicitly popped by gcc.
94 An input reg that is implicitly popped by the asm must be
95 explicitly clobbered, unless it is constrained to match an
96 output operand.
98 2. For any input reg that is implicitly popped by an asm, it is
99 necessary to know how to adjust the stack to compensate for the pop.
100 If any non-popped input is closer to the top of the reg-stack than
101 the implicitly popped reg, it would not be possible to know what the
102 stack looked like - it's not clear how the rest of the stack "slides
103 up".
105 All implicitly popped input regs must be closer to the top of
106 the reg-stack than any input that is not implicitly popped.
108 3. It is possible that if an input dies in an insn, reload might
109 use the input reg for an output reload. Consider this example:
111 asm ("foo" : "=t" (a) : "f" (b));
113 This asm says that input B is not popped by the asm, and that
114 the asm pushes a result onto the reg-stack, ie, the stack is one
115 deeper after the asm than it was before. But, it is possible that
116 reload will think that it can use the same reg for both the input and
117 the output, if input B dies in this insn.
119 If any input operand uses the "f" constraint, all output reg
120 constraints must use the "&" earlyclobber.
122 The asm above would be written as
124 asm ("foo" : "=&t" (a) : "f" (b));
126 4. Some operands need to be in particular places on the stack. All
127 output operands fall in this category - there is no other way to
128 know which regs the outputs appear in unless the user indicates
129 this in the constraints.
131 Output operands must specifically indicate which reg an output
132 appears in after an asm. "=f" is not allowed: the operand
133 constraints must select a class with a single reg.
135 5. Output operands may not be "inserted" between existing stack regs.
136 Since no 387 opcode uses a read/write operand, all output operands
137 are dead before the asm_operands, and are pushed by the asm_operands.
138 It makes no sense to push anywhere but the top of the reg-stack.
140 Output operands must start at the top of the reg-stack: output
141 operands may not "skip" a reg.
143 6. Some asm statements may need extra stack space for internal
144 calculations. This can be guaranteed by clobbering stack registers
145 unrelated to the inputs and outputs.
147 Here are a couple of reasonable asms to want to write. This asm
148 takes one input, which is internally popped, and produces two outputs.
150 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
152 This asm takes two inputs, which are popped by the fyl2xp1 opcode,
153 and replaces them with one output. The user must code the "st(1)"
154 clobber for reg-stack.c to know that fyl2xp1 pops both inputs.
156 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
160 #include "config.h"
161 #include "system.h"
162 #include "tree.h"
163 #include "rtl.h"
164 #include "insn-config.h"
165 #include "regs.h"
166 #include "hard-reg-set.h"
167 #include "flags.h"
168 #include "insn-flags.h"
169 #include "recog.h"
170 #include "toplev.h"
172 #ifdef STACK_REGS
174 #define REG_STACK_SIZE (LAST_STACK_REG - FIRST_STACK_REG + 1)
176 /* This is the basic stack record. TOP is an index into REG[] such
177 that REG[TOP] is the top of stack. If TOP is -1 the stack is empty.
179 If TOP is -2, REG[] is not yet initialized. Stack initialization
180 consists of placing each live reg in array `reg' and setting `top'
181 appropriately.
183 REG_SET indicates which registers are live. */
185 typedef struct stack_def
187 int top; /* index to top stack element */
188 HARD_REG_SET reg_set; /* set of live registers */
189 char reg[REG_STACK_SIZE]; /* register - stack mapping */
190 } *stack;
192 /* highest instruction uid */
193 static int max_uid = 0;
195 /* Number of basic blocks in the current function. */
196 static int blocks;
198 /* Element N is first insn in basic block N.
199 This info lasts until we finish compiling the function. */
200 static rtx *block_begin;
202 /* Element N is last insn in basic block N.
203 This info lasts until we finish compiling the function. */
204 static rtx *block_end;
206 /* Element N is nonzero if control can drop into basic block N */
207 static char *block_drops_in;
209 /* Element N says all about the stack at entry block N */
210 static stack block_stack_in;
212 /* Element N says all about the stack life at the end of block N */
213 static HARD_REG_SET *block_out_reg_set;
215 /* This is where the BLOCK_NUM values are really stored. This is set
216 up by find_blocks and used there and in life_analysis. It can be used
217 later, but only to look up an insn that is the head or tail of some
218 block. life_analysis and the stack register conversion process can
219 add insns within a block. */
220 static int *block_number;
222 /* This is the register file for all register after conversion */
223 static rtx
224 FP_mode_reg[LAST_STACK_REG+1-FIRST_STACK_REG][(int) MAX_MACHINE_MODE];
226 #define FP_MODE_REG(regno,mode) \
227 (FP_mode_reg[(regno)-FIRST_STACK_REG][(int)(mode)])
229 /* Get the basic block number of an insn. See note at block_number
230 definition are validity of this information. */
232 #define BLOCK_NUM(INSN) \
233 ((INSN_UID (INSN) > max_uid) \
234 ? (abort() , -1) : block_number[INSN_UID (INSN)])
236 extern rtx forced_labels;
238 /* Forward declarations */
240 static void mark_regs_pat PROTO((rtx, HARD_REG_SET *));
241 static void straighten_stack PROTO((rtx, stack));
242 static void pop_stack PROTO((stack, int));
243 static void record_label_references PROTO((rtx, rtx));
244 static rtx *get_true_reg PROTO((rtx *));
246 static void record_asm_reg_life PROTO((rtx, stack));
247 static void record_reg_life_pat PROTO((rtx, HARD_REG_SET *,
248 HARD_REG_SET *, int));
249 static int get_asm_operand_n_inputs PROTO((rtx));
250 static void record_reg_life PROTO((rtx, int, stack));
251 static void find_blocks PROTO((rtx));
252 static rtx stack_result PROTO((tree));
253 static void stack_reg_life_analysis PROTO((rtx, HARD_REG_SET *));
254 static void replace_reg PROTO((rtx *, int));
255 static void remove_regno_note PROTO((rtx, enum reg_note, int));
256 static int get_hard_regnum PROTO((stack, rtx));
257 static void delete_insn_for_stacker PROTO((rtx));
258 static rtx emit_pop_insn PROTO((rtx, stack, rtx, rtx (*) ()));
259 static void emit_swap_insn PROTO((rtx, stack, rtx));
260 static void move_for_stack_reg PROTO((rtx, stack, rtx));
261 static void swap_rtx_condition PROTO((rtx));
262 static void compare_for_stack_reg PROTO((rtx, stack, rtx));
263 static void subst_stack_regs_pat PROTO((rtx, stack, rtx));
264 static void subst_asm_stack_regs PROTO((rtx, stack));
265 static void subst_stack_regs PROTO((rtx, stack));
266 static void change_stack PROTO((rtx, stack, stack, rtx (*) ()));
268 static void goto_block_pat PROTO((rtx, stack, rtx));
269 static void convert_regs PROTO((void));
270 static void print_blocks PROTO((FILE *, rtx, rtx));
271 static void dump_stack_info PROTO((FILE *));
273 /* Mark all registers needed for this pattern. */
275 static void
276 mark_regs_pat (pat, set)
277 rtx pat;
278 HARD_REG_SET *set;
280 enum machine_mode mode;
281 register int regno;
282 register int count;
284 if (GET_CODE (pat) == SUBREG)
286 mode = GET_MODE (pat);
287 regno = SUBREG_WORD (pat);
288 regno += REGNO (SUBREG_REG (pat));
290 else
291 regno = REGNO (pat), mode = GET_MODE (pat);
293 for (count = HARD_REGNO_NREGS (regno, mode);
294 count; count--, regno++)
295 SET_HARD_REG_BIT (*set, regno);
298 /* Reorganise the stack into ascending numbers,
299 after this insn. */
301 static void
302 straighten_stack (insn, regstack)
303 rtx insn;
304 stack regstack;
306 struct stack_def temp_stack;
307 int top;
309 /* If there is only a single register on the stack, then the stack is
310 already in increasing order and no reorganization is needed.
312 Similarly if the stack is empty. */
313 if (regstack->top <= 0)
314 return;
316 temp_stack.reg_set = regstack->reg_set;
318 for (top = temp_stack.top = regstack->top; top >= 0; top--)
319 temp_stack.reg[top] = FIRST_STACK_REG + temp_stack.top - top;
321 change_stack (insn, regstack, &temp_stack, emit_insn_after);
324 /* Pop a register from the stack */
326 static void
327 pop_stack (regstack, regno)
328 stack regstack;
329 int regno;
331 int top = regstack->top;
333 CLEAR_HARD_REG_BIT (regstack->reg_set, regno);
334 regstack->top--;
335 /* If regno was not at the top of stack then adjust stack */
336 if (regstack->reg [top] != regno)
338 int i;
339 for (i = regstack->top; i >= 0; i--)
340 if (regstack->reg [i] == regno)
342 int j;
343 for (j = i; j < top; j++)
344 regstack->reg [j] = regstack->reg [j + 1];
345 break;
350 /* Return non-zero if any stack register is mentioned somewhere within PAT. */
353 stack_regs_mentioned_p (pat)
354 rtx pat;
356 register char *fmt;
357 register int i;
359 if (STACK_REG_P (pat))
360 return 1;
362 fmt = GET_RTX_FORMAT (GET_CODE (pat));
363 for (i = GET_RTX_LENGTH (GET_CODE (pat)) - 1; i >= 0; i--)
365 if (fmt[i] == 'E')
367 register int j;
369 for (j = XVECLEN (pat, i) - 1; j >= 0; j--)
370 if (stack_regs_mentioned_p (XVECEXP (pat, i, j)))
371 return 1;
373 else if (fmt[i] == 'e' && stack_regs_mentioned_p (XEXP (pat, i)))
374 return 1;
377 return 0;
380 /* Convert register usage from "flat" register file usage to a "stack
381 register file. FIRST is the first insn in the function, FILE is the
382 dump file, if used.
384 First compute the beginning and end of each basic block. Do a
385 register life analysis on the stack registers, recording the result
386 for the head and tail of each basic block. The convert each insn one
387 by one. Run a last jump_optimize() pass, if optimizing, to eliminate
388 any cross-jumping created when the converter inserts pop insns.*/
390 void
391 reg_to_stack (first, file)
392 rtx first;
393 FILE *file;
395 register rtx insn;
396 register int i;
397 int stack_reg_seen = 0;
398 enum machine_mode mode;
399 HARD_REG_SET stackentry;
401 CLEAR_HARD_REG_SET (stackentry);
404 static int initialised;
405 if (!initialised)
407 #if 0
408 initialised = 1; /* This array can not have been previously
409 initialised, because the rtx's are
410 thrown away between compilations of
411 functions. */
412 #endif
413 for (i = FIRST_STACK_REG; i <= LAST_STACK_REG; i++)
415 for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT); mode != VOIDmode;
416 mode = GET_MODE_WIDER_MODE (mode))
417 FP_MODE_REG (i, mode) = gen_rtx_REG (mode, i);
418 for (mode = GET_CLASS_NARROWEST_MODE (MODE_COMPLEX_FLOAT); mode != VOIDmode;
419 mode = GET_MODE_WIDER_MODE (mode))
420 FP_MODE_REG (i, mode) = gen_rtx_REG (mode, i);
425 /* Count the basic blocks. Also find maximum insn uid. */
427 register RTX_CODE prev_code = BARRIER;
428 register RTX_CODE code;
429 register int before_function_beg = 1;
431 max_uid = 0;
432 blocks = 0;
433 for (insn = first; insn; insn = NEXT_INSN (insn))
435 /* Note that this loop must select the same block boundaries
436 as code in find_blocks. Also note that this code is not the
437 same as that used in flow.c. */
439 if (INSN_UID (insn) > max_uid)
440 max_uid = INSN_UID (insn);
442 code = GET_CODE (insn);
444 if (code == CODE_LABEL
445 || (prev_code != INSN
446 && prev_code != CALL_INSN
447 && prev_code != CODE_LABEL
448 && GET_RTX_CLASS (code) == 'i'))
449 blocks++;
451 if (code == NOTE && NOTE_LINE_NUMBER (insn) == NOTE_INSN_FUNCTION_BEG)
452 before_function_beg = 0;
454 /* Remember whether or not this insn mentions an FP regs.
455 Check JUMP_INSNs too, in case someone creates a funny PARALLEL. */
457 if (GET_RTX_CLASS (code) == 'i'
458 && stack_regs_mentioned_p (PATTERN (insn)))
460 stack_reg_seen = 1;
461 PUT_MODE (insn, QImode);
463 /* Note any register passing parameters. */
465 if (before_function_beg && code == INSN
466 && GET_CODE (PATTERN (insn)) == USE)
467 record_reg_life_pat (PATTERN (insn), (HARD_REG_SET *) 0,
468 &stackentry, 1);
470 else
471 PUT_MODE (insn, VOIDmode);
473 if (code == CODE_LABEL)
474 LABEL_REFS (insn) = insn; /* delete old chain */
476 if (code != NOTE)
477 prev_code = code;
481 /* If no stack register reference exists in this insn, there isn't
482 anything to convert. */
484 if (! stack_reg_seen)
485 return;
487 /* If there are stack registers, there must be at least one block. */
489 if (! blocks)
490 abort ();
492 /* Allocate some tables that last till end of compiling this function
493 and some needed only in find_blocks and life_analysis. */
495 block_begin = (rtx *) alloca (blocks * sizeof (rtx));
496 block_end = (rtx *) alloca (blocks * sizeof (rtx));
497 block_drops_in = (char *) alloca (blocks);
499 block_stack_in = (stack) alloca (blocks * sizeof (struct stack_def));
500 block_out_reg_set = (HARD_REG_SET *) alloca (blocks * sizeof (HARD_REG_SET));
501 bzero ((char *) block_stack_in, blocks * sizeof (struct stack_def));
502 bzero ((char *) block_out_reg_set, blocks * sizeof (HARD_REG_SET));
504 block_number = (int *) alloca ((max_uid + 1) * sizeof (int));
506 find_blocks (first);
507 stack_reg_life_analysis (first, &stackentry);
509 /* Dump the life analysis debug information before jump
510 optimization, as that will destroy the LABEL_REFS we keep the
511 information in. */
513 if (file)
514 dump_stack_info (file);
516 convert_regs ();
518 if (optimize)
519 jump_optimize (first, 2, 0, 0);
522 /* Check PAT, which is in INSN, for LABEL_REFs. Add INSN to the
523 label's chain of references, and note which insn contains each
524 reference. */
526 static void
527 record_label_references (insn, pat)
528 rtx insn, pat;
530 register enum rtx_code code = GET_CODE (pat);
531 register int i;
532 register char *fmt;
534 if (code == LABEL_REF)
536 register rtx label = XEXP (pat, 0);
537 register rtx ref;
539 if (GET_CODE (label) != CODE_LABEL)
540 abort ();
542 /* If this is an undefined label, LABEL_REFS (label) contains
543 garbage. */
544 if (INSN_UID (label) == 0)
545 return;
547 /* Don't make a duplicate in the code_label's chain. */
549 for (ref = LABEL_REFS (label);
550 ref && ref != label;
551 ref = LABEL_NEXTREF (ref))
552 if (CONTAINING_INSN (ref) == insn)
553 return;
555 CONTAINING_INSN (pat) = insn;
556 LABEL_NEXTREF (pat) = LABEL_REFS (label);
557 LABEL_REFS (label) = pat;
559 return;
562 fmt = GET_RTX_FORMAT (code);
563 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
565 if (fmt[i] == 'e')
566 record_label_references (insn, XEXP (pat, i));
567 if (fmt[i] == 'E')
569 register int j;
570 for (j = 0; j < XVECLEN (pat, i); j++)
571 record_label_references (insn, XVECEXP (pat, i, j));
576 /* Return a pointer to the REG expression within PAT. If PAT is not a
577 REG, possible enclosed by a conversion rtx, return the inner part of
578 PAT that stopped the search. */
580 static rtx *
581 get_true_reg (pat)
582 rtx *pat;
584 for (;;)
585 switch (GET_CODE (*pat))
587 case SUBREG:
588 /* eliminate FP subregister accesses in favour of the
589 actual FP register in use. */
591 rtx subreg;
592 if (FP_REG_P (subreg = SUBREG_REG (*pat)))
594 *pat = FP_MODE_REG (REGNO (subreg) + SUBREG_WORD (*pat),
595 GET_MODE (subreg));
596 default:
597 return pat;
600 case FLOAT:
601 case FIX:
602 case FLOAT_EXTEND:
603 pat = & XEXP (*pat, 0);
607 /* Record the life info of each stack reg in INSN, updating REGSTACK.
608 N_INPUTS is the number of inputs; N_OUTPUTS the outputs.
609 OPERANDS is an array of all operands for the insn, and is assumed to
610 contain all output operands, then all inputs operands.
612 There are many rules that an asm statement for stack-like regs must
613 follow. Those rules are explained at the top of this file: the rule
614 numbers below refer to that explanation. */
616 static void
617 record_asm_reg_life (insn, regstack)
618 rtx insn;
619 stack regstack;
621 int i;
622 int n_clobbers;
623 int malformed_asm = 0;
624 rtx body = PATTERN (insn);
626 int reg_used_as_output[FIRST_PSEUDO_REGISTER];
627 int implicitly_dies[FIRST_PSEUDO_REGISTER];
628 int alt;
630 rtx *clobber_reg;
631 int n_inputs, n_outputs;
633 /* Find out what the constraints require. If no constraint
634 alternative matches, this asm is malformed. */
635 extract_insn (insn);
636 constrain_operands (1);
637 alt = which_alternative;
639 preprocess_constraints ();
641 n_inputs = get_asm_operand_n_inputs (body);
642 n_outputs = recog_n_operands - n_inputs;
644 if (alt < 0)
646 malformed_asm = 1;
647 /* Avoid further trouble with this insn. */
648 PATTERN (insn) = gen_rtx_USE (VOIDmode, const0_rtx);
649 PUT_MODE (insn, VOIDmode);
650 return;
653 /* Strip SUBREGs here to make the following code simpler. */
654 for (i = 0; i < recog_n_operands; i++)
655 if (GET_CODE (recog_operand[i]) == SUBREG
656 && GET_CODE (SUBREG_REG (recog_operand[i])) == REG)
657 recog_operand[i] = SUBREG_REG (recog_operand[i]);
659 /* Set up CLOBBER_REG. */
661 n_clobbers = 0;
663 if (GET_CODE (body) == PARALLEL)
665 clobber_reg = (rtx *) alloca (XVECLEN (body, 0) * sizeof (rtx));
667 for (i = 0; i < XVECLEN (body, 0); i++)
668 if (GET_CODE (XVECEXP (body, 0, i)) == CLOBBER)
670 rtx clobber = XVECEXP (body, 0, i);
671 rtx reg = XEXP (clobber, 0);
673 if (GET_CODE (reg) == SUBREG && GET_CODE (SUBREG_REG (reg)) == REG)
674 reg = SUBREG_REG (reg);
676 if (STACK_REG_P (reg))
678 clobber_reg[n_clobbers] = reg;
679 n_clobbers++;
684 /* Enforce rule #4: Output operands must specifically indicate which
685 reg an output appears in after an asm. "=f" is not allowed: the
686 operand constraints must select a class with a single reg.
688 Also enforce rule #5: Output operands must start at the top of
689 the reg-stack: output operands may not "skip" a reg. */
691 bzero ((char *) reg_used_as_output, sizeof (reg_used_as_output));
692 for (i = 0; i < n_outputs; i++)
693 if (STACK_REG_P (recog_operand[i]))
695 if (reg_class_size[(int) recog_op_alt[i][alt].class] != 1)
697 error_for_asm (insn, "Output constraint %d must specify a single register", i);
698 malformed_asm = 1;
700 else
701 reg_used_as_output[REGNO (recog_operand[i])] = 1;
705 /* Search for first non-popped reg. */
706 for (i = FIRST_STACK_REG; i < LAST_STACK_REG + 1; i++)
707 if (! reg_used_as_output[i])
708 break;
710 /* If there are any other popped regs, that's an error. */
711 for (; i < LAST_STACK_REG + 1; i++)
712 if (reg_used_as_output[i])
713 break;
715 if (i != LAST_STACK_REG + 1)
717 error_for_asm (insn, "Output regs must be grouped at top of stack");
718 malformed_asm = 1;
721 /* Enforce rule #2: All implicitly popped input regs must be closer
722 to the top of the reg-stack than any input that is not implicitly
723 popped. */
725 bzero ((char *) implicitly_dies, sizeof (implicitly_dies));
726 for (i = n_outputs; i < n_outputs + n_inputs; i++)
727 if (STACK_REG_P (recog_operand[i]))
729 /* An input reg is implicitly popped if it is tied to an
730 output, or if there is a CLOBBER for it. */
731 int j;
733 for (j = 0; j < n_clobbers; j++)
734 if (operands_match_p (clobber_reg[j], recog_operand[i]))
735 break;
737 if (j < n_clobbers || recog_op_alt[i][alt].matches >= 0)
738 implicitly_dies[REGNO (recog_operand[i])] = 1;
741 /* Search for first non-popped reg. */
742 for (i = FIRST_STACK_REG; i < LAST_STACK_REG + 1; i++)
743 if (! implicitly_dies[i])
744 break;
746 /* If there are any other popped regs, that's an error. */
747 for (; i < LAST_STACK_REG + 1; i++)
748 if (implicitly_dies[i])
749 break;
751 if (i != LAST_STACK_REG + 1)
753 error_for_asm (insn,
754 "Implicitly popped regs must be grouped at top of stack");
755 malformed_asm = 1;
758 /* Enfore rule #3: If any input operand uses the "f" constraint, all
759 output constraints must use the "&" earlyclobber.
761 ??? Detect this more deterministically by having constraint_asm_operands
762 record any earlyclobber. */
764 for (i = n_outputs; i < n_outputs + n_inputs; i++)
765 if (recog_op_alt[i][alt].matches == -1)
767 int j;
769 for (j = 0; j < n_outputs; j++)
770 if (operands_match_p (recog_operand[j], recog_operand[i]))
772 error_for_asm (insn,
773 "Output operand %d must use `&' constraint", j);
774 malformed_asm = 1;
778 if (malformed_asm)
780 /* Avoid further trouble with this insn. */
781 PATTERN (insn) = gen_rtx_USE (VOIDmode, const0_rtx);
782 PUT_MODE (insn, VOIDmode);
783 return;
786 /* Process all outputs */
787 for (i = 0; i < n_outputs; i++)
789 rtx op = recog_operand[i];
791 if (! STACK_REG_P (op))
793 if (stack_regs_mentioned_p (op))
794 abort ();
795 else
796 continue;
799 /* Each destination is dead before this insn. If the
800 destination is not used after this insn, record this with
801 REG_UNUSED. */
803 if (! TEST_HARD_REG_BIT (regstack->reg_set, REGNO (op)))
804 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_UNUSED, op,
805 REG_NOTES (insn));
807 CLEAR_HARD_REG_BIT (regstack->reg_set, REGNO (op));
810 /* Process all inputs */
811 for (i = n_outputs; i < n_outputs + n_inputs; i++)
813 rtx op = recog_operand[i];
814 if (! STACK_REG_P (op))
816 if (stack_regs_mentioned_p (op))
817 abort ();
818 else
819 continue;
822 /* If an input is dead after the insn, record a death note.
823 But don't record a death note if there is already a death note,
824 or if the input is also an output. */
826 if (! TEST_HARD_REG_BIT (regstack->reg_set, REGNO (op))
827 && recog_op_alt[i][alt].matches == -1
828 && find_regno_note (insn, REG_DEAD, REGNO (op)) == NULL_RTX)
829 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_DEAD, op, REG_NOTES (insn));
831 SET_HARD_REG_BIT (regstack->reg_set, REGNO (op));
835 /* Scan PAT, which is part of INSN, and record registers appearing in
836 a SET_DEST in DEST, and other registers in SRC.
838 This function does not know about SET_DESTs that are both input and
839 output (such as ZERO_EXTRACT) - this cannot happen on a 387. */
841 static void
842 record_reg_life_pat (pat, src, dest, douse)
843 rtx pat;
844 HARD_REG_SET *src, *dest;
845 int douse;
847 register char *fmt;
848 register int i;
850 if (STACK_REG_P (pat)
851 || (GET_CODE (pat) == SUBREG && STACK_REG_P (SUBREG_REG (pat))))
853 if (src)
854 mark_regs_pat (pat, src);
856 if (dest)
857 mark_regs_pat (pat, dest);
859 return;
862 if (GET_CODE (pat) == SET)
864 record_reg_life_pat (XEXP (pat, 0), NULL_PTR, dest, 0);
865 record_reg_life_pat (XEXP (pat, 1), src, NULL_PTR, 0);
866 return;
869 /* We don't need to consider either of these cases. */
870 if ((GET_CODE (pat) == USE && !douse) || GET_CODE (pat) == CLOBBER)
871 return;
873 fmt = GET_RTX_FORMAT (GET_CODE (pat));
874 for (i = GET_RTX_LENGTH (GET_CODE (pat)) - 1; i >= 0; i--)
876 if (fmt[i] == 'E')
878 register int j;
880 for (j = XVECLEN (pat, i) - 1; j >= 0; j--)
881 record_reg_life_pat (XVECEXP (pat, i, j), src, dest, 0);
883 else if (fmt[i] == 'e')
884 record_reg_life_pat (XEXP (pat, i), src, dest, 0);
888 /* Calculate the number of inputs and outputs in BODY, an
889 asm_operands. N_OPERANDS is the total number of operands, and
890 N_INPUTS and N_OUTPUTS are pointers to ints into which the results are
891 placed. */
893 static int
894 get_asm_operand_n_inputs (body)
895 rtx body;
897 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
898 return ASM_OPERANDS_INPUT_LENGTH (SET_SRC (body));
900 else if (GET_CODE (body) == ASM_OPERANDS)
901 return ASM_OPERANDS_INPUT_LENGTH (body);
903 else if (GET_CODE (body) == PARALLEL
904 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
905 return ASM_OPERANDS_INPUT_LENGTH (SET_SRC (XVECEXP (body, 0, 0)));
907 else if (GET_CODE (body) == PARALLEL
908 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
909 return ASM_OPERANDS_INPUT_LENGTH (XVECEXP (body, 0, 0));
911 abort ();
914 /* Scan INSN, which is in BLOCK, and record the life & death of stack
915 registers in REGSTACK. This function is called to process insns from
916 the last insn in a block to the first. The actual scanning is done in
917 record_reg_life_pat.
919 If a register is live after a CALL_INSN, but is not a value return
920 register for that CALL_INSN, then code is emitted to initialize that
921 register. The block_end[] data is kept accurate.
923 Existing death and unset notes for stack registers are deleted
924 before processing the insn. */
926 static void
927 record_reg_life (insn, block, regstack)
928 rtx insn;
929 int block;
930 stack regstack;
932 rtx note, *note_link;
933 int n_operands;
935 if ((GET_CODE (insn) != INSN && GET_CODE (insn) != CALL_INSN)
936 || INSN_DELETED_P (insn))
937 return;
939 /* Strip death notes for stack regs from this insn */
941 note_link = &REG_NOTES(insn);
942 for (note = *note_link; note; note = XEXP (note, 1))
943 if (STACK_REG_P (XEXP (note, 0))
944 && (REG_NOTE_KIND (note) == REG_DEAD
945 || REG_NOTE_KIND (note) == REG_UNUSED))
946 *note_link = XEXP (note, 1);
947 else
948 note_link = &XEXP (note, 1);
950 /* Process all patterns in the insn. */
952 n_operands = asm_noperands (PATTERN (insn));
953 if (n_operands >= 0)
955 record_asm_reg_life (insn, regstack);
956 return;
960 HARD_REG_SET src, dest;
961 int regno;
963 CLEAR_HARD_REG_SET (src);
964 CLEAR_HARD_REG_SET (dest);
966 if (GET_CODE (insn) == CALL_INSN)
967 for (note = CALL_INSN_FUNCTION_USAGE (insn);
968 note;
969 note = XEXP (note, 1))
970 if (GET_CODE (XEXP (note, 0)) == USE)
971 record_reg_life_pat (SET_DEST (XEXP (note, 0)), &src, NULL_PTR, 0);
973 record_reg_life_pat (PATTERN (insn), &src, &dest, 0);
974 for (regno = FIRST_STACK_REG; regno <= LAST_STACK_REG; regno++)
975 if (! TEST_HARD_REG_BIT (regstack->reg_set, regno))
977 if (TEST_HARD_REG_BIT (src, regno)
978 && ! TEST_HARD_REG_BIT (dest, regno))
979 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_DEAD,
980 FP_MODE_REG (regno, DFmode),
981 REG_NOTES (insn));
982 else if (TEST_HARD_REG_BIT (dest, regno))
983 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_UNUSED,
984 FP_MODE_REG (regno, DFmode),
985 REG_NOTES (insn));
988 if (GET_CODE (insn) == CALL_INSN)
990 int reg;
992 /* There might be a reg that is live after a function call.
993 Initialize it to zero so that the program does not crash. See
994 comment towards the end of stack_reg_life_analysis(). */
996 for (reg = FIRST_STACK_REG; reg <= LAST_STACK_REG; reg++)
997 if (! TEST_HARD_REG_BIT (dest, reg)
998 && TEST_HARD_REG_BIT (regstack->reg_set, reg))
1000 rtx init, pat;
1002 /* The insn will use virtual register numbers, and so
1003 convert_regs is expected to process these. But BLOCK_NUM
1004 cannot be used on these insns, because they do not appear in
1005 block_number[]. */
1007 pat = gen_rtx_SET (VOIDmode, FP_MODE_REG (reg, DFmode),
1008 CONST0_RTX (DFmode));
1009 init = emit_insn_after (pat, insn);
1010 PUT_MODE (init, QImode);
1012 CLEAR_HARD_REG_BIT (regstack->reg_set, reg);
1014 /* If the CALL_INSN was the end of a block, move the
1015 block_end to point to the new insn. */
1017 if (block_end[block] == insn)
1018 block_end[block] = init;
1021 /* Some regs do not survive a CALL */
1022 AND_COMPL_HARD_REG_SET (regstack->reg_set, call_used_reg_set);
1025 AND_COMPL_HARD_REG_SET (regstack->reg_set, dest);
1026 IOR_HARD_REG_SET (regstack->reg_set, src);
1030 /* Find all basic blocks of the function, which starts with FIRST.
1031 For each JUMP_INSN, build the chain of LABEL_REFS on each CODE_LABEL. */
1033 static void
1034 find_blocks (first)
1035 rtx first;
1037 register rtx insn;
1038 register int block;
1039 register RTX_CODE prev_code = BARRIER;
1040 register RTX_CODE code;
1041 rtx label_value_list = 0;
1043 /* Record where all the blocks start and end.
1044 Record which basic blocks control can drop in to. */
1046 block = -1;
1047 for (insn = first; insn; insn = NEXT_INSN (insn))
1049 /* Note that this loop must select the same block boundaries
1050 as code in reg_to_stack, but that these are not the same
1051 as those selected in flow.c. */
1053 code = GET_CODE (insn);
1055 if (code == CODE_LABEL
1056 || (prev_code != INSN
1057 && prev_code != CALL_INSN
1058 && prev_code != CODE_LABEL
1059 && GET_RTX_CLASS (code) == 'i'))
1061 block_begin[++block] = insn;
1062 block_end[block] = insn;
1063 block_drops_in[block] = prev_code != BARRIER;
1065 else if (GET_RTX_CLASS (code) == 'i')
1066 block_end[block] = insn;
1068 if (GET_RTX_CLASS (code) == 'i')
1070 rtx note;
1072 /* Make a list of all labels referred to other than by jumps. */
1073 for (note = REG_NOTES (insn); note; note = XEXP (note, 1))
1074 if (REG_NOTE_KIND (note) == REG_LABEL)
1075 label_value_list = gen_rtx_EXPR_LIST (VOIDmode, XEXP (note, 0),
1076 label_value_list);
1079 block_number[INSN_UID (insn)] = block;
1081 if (code != NOTE)
1082 prev_code = code;
1085 if (block + 1 != blocks)
1086 abort ();
1088 /* generate all label references to the corresponding jump insn */
1089 for (block = 0; block < blocks; block++)
1091 insn = block_end[block];
1093 if (GET_CODE (insn) == JUMP_INSN)
1095 rtx pat = PATTERN (insn);
1096 rtx x;
1098 if (computed_jump_p (insn))
1100 for (x = label_value_list; x; x = XEXP (x, 1))
1101 record_label_references (insn,
1102 gen_rtx_LABEL_REF (VOIDmode,
1103 XEXP (x, 0)));
1105 for (x = forced_labels; x; x = XEXP (x, 1))
1106 record_label_references (insn,
1107 gen_rtx_LABEL_REF (VOIDmode,
1108 XEXP (x, 0)));
1111 record_label_references (insn, pat);
1116 /* If current function returns its result in an fp stack register,
1117 return the REG. Otherwise, return 0. */
1119 static rtx
1120 stack_result (decl)
1121 tree decl;
1123 rtx result = DECL_RTL (DECL_RESULT (decl));
1125 if (result != 0
1126 && ! (GET_CODE (result) == REG
1127 && REGNO (result) < FIRST_PSEUDO_REGISTER))
1129 #ifdef FUNCTION_OUTGOING_VALUE
1130 result
1131 = FUNCTION_OUTGOING_VALUE (TREE_TYPE (DECL_RESULT (decl)), decl);
1132 #else
1133 result = FUNCTION_VALUE (TREE_TYPE (DECL_RESULT (decl)), decl);
1134 #endif
1137 return result != 0 && STACK_REG_P (result) ? result : 0;
1140 /* Determine the which registers are live at the start of each basic
1141 block of the function whose first insn is FIRST.
1143 First, if the function returns a real_type, mark the function
1144 return type as live at each return point, as the RTL may not give any
1145 hint that the register is live.
1147 Then, start with the last block and work back to the first block.
1148 Similarly, work backwards within each block, insn by insn, recording
1149 which regs are dead and which are used (and therefore live) in the
1150 hard reg set of block_stack_in[].
1152 After processing each basic block, if there is a label at the start
1153 of the block, propagate the live registers to all jumps to this block.
1155 As a special case, if there are regs live in this block, that are
1156 not live in a block containing a jump to this label, and the block
1157 containing the jump has already been processed, we must propagate this
1158 block's entry register life back to the block containing the jump, and
1159 restart life analysis from there.
1161 In the worst case, this function may traverse the insns
1162 REG_STACK_SIZE times. This is necessary, since a jump towards the end
1163 of the insns may not know that a reg is live at a target that is early
1164 in the insns. So we back up and start over with the new reg live.
1166 If there are registers that are live at the start of the function,
1167 insns are emitted to initialize these registers. Something similar is
1168 done after CALL_INSNs in record_reg_life. */
1170 static void
1171 stack_reg_life_analysis (first, stackentry)
1172 rtx first;
1173 HARD_REG_SET *stackentry;
1175 int reg, block;
1176 struct stack_def regstack;
1179 rtx retvalue;
1181 if ((retvalue = stack_result (current_function_decl)))
1183 /* Find all RETURN insns and mark them. */
1185 for (block = blocks - 1; --block >= 0;)
1186 if (GET_CODE (block_end[block]) == JUMP_INSN
1187 && GET_CODE (PATTERN (block_end[block])) == RETURN)
1188 mark_regs_pat (retvalue, block_out_reg_set+block);
1190 /* Mark off the end of last block if we "fall off" the end of the
1191 function into the epilogue. */
1193 if (GET_CODE (block_end[blocks-1]) != JUMP_INSN
1194 || GET_CODE (PATTERN (block_end[blocks-1])) == RETURN)
1195 mark_regs_pat (retvalue, block_out_reg_set+blocks-1);
1199 /* now scan all blocks backward for stack register use */
1201 block = blocks - 1;
1202 while (block >= 0)
1204 register rtx insn, prev;
1206 /* current register status at last instruction */
1208 COPY_HARD_REG_SET (regstack.reg_set, block_out_reg_set[block]);
1210 prev = block_end[block];
1213 insn = prev;
1214 prev = PREV_INSN (insn);
1216 /* If the insn is a CALL_INSN, we need to ensure that
1217 everything dies. But otherwise don't process unless there
1218 are some stack regs present. */
1220 if (GET_MODE (insn) == QImode || GET_CODE (insn) == CALL_INSN)
1221 record_reg_life (insn, block, &regstack);
1223 } while (insn != block_begin[block]);
1225 /* Set the state at the start of the block. Mark that no
1226 register mapping information known yet. */
1228 COPY_HARD_REG_SET (block_stack_in[block].reg_set, regstack.reg_set);
1229 block_stack_in[block].top = -2;
1231 /* If there is a label, propagate our register life to all jumps
1232 to this label. */
1234 if (GET_CODE (insn) == CODE_LABEL)
1236 register rtx label;
1237 int must_restart = 0;
1239 for (label = LABEL_REFS (insn); label != insn;
1240 label = LABEL_NEXTREF (label))
1242 int jump_block = BLOCK_NUM (CONTAINING_INSN (label));
1244 if (jump_block < block)
1245 IOR_HARD_REG_SET (block_out_reg_set[jump_block],
1246 block_stack_in[block].reg_set);
1247 else
1249 /* The block containing the jump has already been
1250 processed. If there are registers that were not known
1251 to be live then, but are live now, we must back up
1252 and restart life analysis from that point with the new
1253 life information. */
1255 GO_IF_HARD_REG_SUBSET (block_stack_in[block].reg_set,
1256 block_out_reg_set[jump_block],
1257 win);
1259 IOR_HARD_REG_SET (block_out_reg_set[jump_block],
1260 block_stack_in[block].reg_set);
1262 block = jump_block;
1263 must_restart = 1;
1264 break;
1266 win:
1270 if (must_restart)
1271 continue;
1274 if (block_drops_in[block])
1275 IOR_HARD_REG_SET (block_out_reg_set[block-1],
1276 block_stack_in[block].reg_set);
1278 block -= 1;
1281 /* If any reg is live at the start of the first block of a
1282 function, then we must guarantee that the reg holds some value by
1283 generating our own "load" of that register. Otherwise a 387 would
1284 fault trying to access an empty register. */
1286 /* Load zero into each live register. The fact that a register
1287 appears live at the function start necessarily implies an error
1288 in the user program: it means that (unless the offending code is *never*
1289 executed) this program is using uninitialised floating point
1290 variables. In order to keep broken code like this happy, we initialise
1291 those variables with zero.
1293 Note that we are inserting virtual register references here:
1294 these insns must be processed by convert_regs later. Also, these
1295 insns will not be in block_number, so BLOCK_NUM() will fail for them. */
1297 for (reg = LAST_STACK_REG; reg >= FIRST_STACK_REG; reg--)
1298 if (TEST_HARD_REG_BIT (block_stack_in[0].reg_set, reg)
1299 && ! TEST_HARD_REG_BIT (*stackentry, reg))
1301 rtx init_rtx;
1303 init_rtx = gen_rtx_SET (VOIDmode, FP_MODE_REG(reg, DFmode),
1304 CONST0_RTX (DFmode));
1305 block_begin[0] = emit_insn_after (init_rtx, first);
1306 PUT_MODE (block_begin[0], QImode);
1308 CLEAR_HARD_REG_BIT (block_stack_in[0].reg_set, reg);
1312 /*****************************************************************************
1313 This section deals with stack register substitution, and forms the second
1314 pass over the RTL.
1315 *****************************************************************************/
1317 /* Replace REG, which is a pointer to a stack reg RTX, with an RTX for
1318 the desired hard REGNO. */
1320 static void
1321 replace_reg (reg, regno)
1322 rtx *reg;
1323 int regno;
1325 if (regno < FIRST_STACK_REG || regno > LAST_STACK_REG
1326 || ! STACK_REG_P (*reg))
1327 abort ();
1329 switch (GET_MODE_CLASS (GET_MODE (*reg)))
1331 default: abort ();
1332 case MODE_FLOAT:
1333 case MODE_COMPLEX_FLOAT:;
1336 *reg = FP_MODE_REG (regno, GET_MODE (*reg));
1339 /* Remove a note of type NOTE, which must be found, for register
1340 number REGNO from INSN. Remove only one such note. */
1342 static void
1343 remove_regno_note (insn, note, regno)
1344 rtx insn;
1345 enum reg_note note;
1346 int regno;
1348 register rtx *note_link, this;
1350 note_link = &REG_NOTES(insn);
1351 for (this = *note_link; this; this = XEXP (this, 1))
1352 if (REG_NOTE_KIND (this) == note
1353 && REG_P (XEXP (this, 0)) && REGNO (XEXP (this, 0)) == regno)
1355 *note_link = XEXP (this, 1);
1356 return;
1358 else
1359 note_link = &XEXP (this, 1);
1361 abort ();
1364 /* Find the hard register number of virtual register REG in REGSTACK.
1365 The hard register number is relative to the top of the stack. -1 is
1366 returned if the register is not found. */
1368 static int
1369 get_hard_regnum (regstack, reg)
1370 stack regstack;
1371 rtx reg;
1373 int i;
1375 if (! STACK_REG_P (reg))
1376 abort ();
1378 for (i = regstack->top; i >= 0; i--)
1379 if (regstack->reg[i] == REGNO (reg))
1380 break;
1382 return i >= 0 ? (FIRST_STACK_REG + regstack->top - i) : -1;
1385 /* Delete INSN from the RTL. Mark the insn, but don't remove it from
1386 the chain of insns. Doing so could confuse block_begin and block_end
1387 if this were the only insn in the block. */
1389 static void
1390 delete_insn_for_stacker (insn)
1391 rtx insn;
1393 PUT_CODE (insn, NOTE);
1394 NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
1395 NOTE_SOURCE_FILE (insn) = 0;
1398 /* Emit an insn to pop virtual register REG before or after INSN.
1399 REGSTACK is the stack state after INSN and is updated to reflect this
1400 pop. WHEN is either emit_insn_before or emit_insn_after. A pop insn
1401 is represented as a SET whose destination is the register to be popped
1402 and source is the top of stack. A death note for the top of stack
1403 cases the movdf pattern to pop. */
1405 static rtx
1406 emit_pop_insn (insn, regstack, reg, when)
1407 rtx insn;
1408 stack regstack;
1409 rtx reg;
1410 rtx (*when)();
1412 rtx pop_insn, pop_rtx;
1413 int hard_regno;
1415 hard_regno = get_hard_regnum (regstack, reg);
1417 if (hard_regno < FIRST_STACK_REG)
1418 abort ();
1420 pop_rtx = gen_rtx_SET (VOIDmode, FP_MODE_REG (hard_regno, DFmode),
1421 FP_MODE_REG (FIRST_STACK_REG, DFmode));
1423 pop_insn = (*when) (pop_rtx, insn);
1424 /* ??? This used to be VOIDmode, but that seems wrong. */
1425 PUT_MODE (pop_insn, QImode);
1427 REG_NOTES (pop_insn) = gen_rtx_EXPR_LIST (REG_DEAD,
1428 FP_MODE_REG (FIRST_STACK_REG, DFmode),
1429 REG_NOTES (pop_insn));
1431 regstack->reg[regstack->top - (hard_regno - FIRST_STACK_REG)]
1432 = regstack->reg[regstack->top];
1433 regstack->top -= 1;
1434 CLEAR_HARD_REG_BIT (regstack->reg_set, REGNO (reg));
1436 return pop_insn;
1439 /* Emit an insn before or after INSN to swap virtual register REG with the
1440 top of stack. WHEN should be `emit_insn_before' or `emit_insn_before'
1441 REGSTACK is the stack state before the swap, and is updated to reflect
1442 the swap. A swap insn is represented as a PARALLEL of two patterns:
1443 each pattern moves one reg to the other.
1445 If REG is already at the top of the stack, no insn is emitted. */
1447 static void
1448 emit_swap_insn (insn, regstack, reg)
1449 rtx insn;
1450 stack regstack;
1451 rtx reg;
1453 int hard_regno;
1454 rtx gen_swapdf();
1455 rtx swap_rtx, swap_insn;
1456 int tmp, other_reg; /* swap regno temps */
1457 rtx i1; /* the stack-reg insn prior to INSN */
1458 rtx i1set = NULL_RTX; /* the SET rtx within I1 */
1460 hard_regno = get_hard_regnum (regstack, reg);
1462 if (hard_regno < FIRST_STACK_REG)
1463 abort ();
1464 if (hard_regno == FIRST_STACK_REG)
1465 return;
1467 other_reg = regstack->top - (hard_regno - FIRST_STACK_REG);
1469 tmp = regstack->reg[other_reg];
1470 regstack->reg[other_reg] = regstack->reg[regstack->top];
1471 regstack->reg[regstack->top] = tmp;
1473 /* Find the previous insn involving stack regs, but don't go past
1474 any labels, calls or jumps. */
1475 i1 = prev_nonnote_insn (insn);
1476 while (i1 && GET_CODE (i1) == INSN && GET_MODE (i1) != QImode)
1477 i1 = prev_nonnote_insn (i1);
1479 if (i1)
1480 i1set = single_set (i1);
1482 if (i1set)
1484 rtx i1src = *get_true_reg (&SET_SRC (i1set));
1485 rtx i1dest = *get_true_reg (&SET_DEST (i1set));
1487 /* If the previous register stack push was from the reg we are to
1488 swap with, omit the swap. */
1490 if (GET_CODE (i1dest) == REG && REGNO (i1dest) == FIRST_STACK_REG
1491 && GET_CODE (i1src) == REG && REGNO (i1src) == hard_regno - 1
1492 && find_regno_note (i1, REG_DEAD, FIRST_STACK_REG) == NULL_RTX)
1493 return;
1495 /* If the previous insn wrote to the reg we are to swap with,
1496 omit the swap. */
1498 if (GET_CODE (i1dest) == REG && REGNO (i1dest) == hard_regno
1499 && GET_CODE (i1src) == REG && REGNO (i1src) == FIRST_STACK_REG
1500 && find_regno_note (i1, REG_DEAD, FIRST_STACK_REG) == NULL_RTX)
1501 return;
1504 if (GET_RTX_CLASS (GET_CODE (i1)) == 'i' && sets_cc0_p (PATTERN (i1)))
1506 i1 = next_nonnote_insn (i1);
1507 if (i1 == insn)
1508 abort ();
1511 swap_rtx = gen_swapdf (FP_MODE_REG (hard_regno, DFmode),
1512 FP_MODE_REG (FIRST_STACK_REG, DFmode));
1513 swap_insn = emit_insn_after (swap_rtx, i1);
1514 /* ??? This used to be VOIDmode, but that seems wrong. */
1515 PUT_MODE (swap_insn, QImode);
1518 /* Handle a move to or from a stack register in PAT, which is in INSN.
1519 REGSTACK is the current stack. */
1521 static void
1522 move_for_stack_reg (insn, regstack, pat)
1523 rtx insn;
1524 stack regstack;
1525 rtx pat;
1527 rtx *psrc = get_true_reg (&SET_SRC (pat));
1528 rtx *pdest = get_true_reg (&SET_DEST (pat));
1529 rtx src, dest;
1530 rtx note;
1532 src = *psrc; dest = *pdest;
1534 if (STACK_REG_P (src) && STACK_REG_P (dest))
1536 /* Write from one stack reg to another. If SRC dies here, then
1537 just change the register mapping and delete the insn. */
1539 note = find_regno_note (insn, REG_DEAD, REGNO (src));
1540 if (note)
1542 int i;
1544 /* If this is a no-op move, there must not be a REG_DEAD note. */
1545 if (REGNO (src) == REGNO (dest))
1546 abort ();
1548 for (i = regstack->top; i >= 0; i--)
1549 if (regstack->reg[i] == REGNO (src))
1550 break;
1552 /* The source must be live, and the dest must be dead. */
1553 if (i < 0 || get_hard_regnum (regstack, dest) >= FIRST_STACK_REG)
1554 abort ();
1556 /* It is possible that the dest is unused after this insn.
1557 If so, just pop the src. */
1559 if (find_regno_note (insn, REG_UNUSED, REGNO (dest)))
1561 emit_pop_insn (insn, regstack, src, emit_insn_after);
1563 delete_insn_for_stacker (insn);
1564 return;
1567 regstack->reg[i] = REGNO (dest);
1569 SET_HARD_REG_BIT (regstack->reg_set, REGNO (dest));
1570 CLEAR_HARD_REG_BIT (regstack->reg_set, REGNO (src));
1572 delete_insn_for_stacker (insn);
1574 return;
1577 /* The source reg does not die. */
1579 /* If this appears to be a no-op move, delete it, or else it
1580 will confuse the machine description output patterns. But if
1581 it is REG_UNUSED, we must pop the reg now, as per-insn processing
1582 for REG_UNUSED will not work for deleted insns. */
1584 if (REGNO (src) == REGNO (dest))
1586 if (find_regno_note (insn, REG_UNUSED, REGNO (dest)))
1587 emit_pop_insn (insn, regstack, dest, emit_insn_after);
1589 delete_insn_for_stacker (insn);
1590 return;
1593 /* The destination ought to be dead */
1594 if (get_hard_regnum (regstack, dest) >= FIRST_STACK_REG)
1595 abort ();
1597 replace_reg (psrc, get_hard_regnum (regstack, src));
1599 regstack->reg[++regstack->top] = REGNO (dest);
1600 SET_HARD_REG_BIT (regstack->reg_set, REGNO (dest));
1601 replace_reg (pdest, FIRST_STACK_REG);
1603 else if (STACK_REG_P (src))
1605 /* Save from a stack reg to MEM, or possibly integer reg. Since
1606 only top of stack may be saved, emit an exchange first if
1607 needs be. */
1609 emit_swap_insn (insn, regstack, src);
1611 note = find_regno_note (insn, REG_DEAD, REGNO (src));
1612 if (note)
1614 replace_reg (&XEXP (note, 0), FIRST_STACK_REG);
1615 regstack->top--;
1616 CLEAR_HARD_REG_BIT (regstack->reg_set, REGNO (src));
1618 else if (GET_MODE (src) == XFmode && regstack->top < REG_STACK_SIZE - 1)
1620 /* A 387 cannot write an XFmode value to a MEM without
1621 clobbering the source reg. The output code can handle
1622 this by reading back the value from the MEM.
1623 But it is more efficient to use a temp register if one is
1624 available. Push the source value here if the register
1625 stack is not full, and then write the value to memory via
1626 a pop. */
1627 rtx push_rtx, push_insn;
1628 rtx top_stack_reg = FP_MODE_REG (FIRST_STACK_REG, XFmode);
1630 push_rtx = gen_movxf (top_stack_reg, top_stack_reg);
1631 push_insn = emit_insn_before (push_rtx, insn);
1632 PUT_MODE (push_insn, QImode);
1633 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_DEAD, top_stack_reg,
1634 REG_NOTES (insn));
1637 replace_reg (psrc, FIRST_STACK_REG);
1639 else if (STACK_REG_P (dest))
1641 /* Load from MEM, or possibly integer REG or constant, into the
1642 stack regs. The actual target is always the top of the
1643 stack. The stack mapping is changed to reflect that DEST is
1644 now at top of stack. */
1646 /* The destination ought to be dead */
1647 if (get_hard_regnum (regstack, dest) >= FIRST_STACK_REG)
1648 abort ();
1650 if (regstack->top >= REG_STACK_SIZE)
1651 abort ();
1653 regstack->reg[++regstack->top] = REGNO (dest);
1654 SET_HARD_REG_BIT (regstack->reg_set, REGNO (dest));
1655 replace_reg (pdest, FIRST_STACK_REG);
1657 else
1658 abort ();
1661 static void
1662 swap_rtx_condition (pat)
1663 rtx pat;
1665 register char *fmt;
1666 register int i;
1668 if (GET_RTX_CLASS (GET_CODE (pat)) == '<')
1670 PUT_CODE (pat, swap_condition (GET_CODE (pat)));
1671 return;
1674 fmt = GET_RTX_FORMAT (GET_CODE (pat));
1675 for (i = GET_RTX_LENGTH (GET_CODE (pat)) - 1; i >= 0; i--)
1677 if (fmt[i] == 'E')
1679 register int j;
1681 for (j = XVECLEN (pat, i) - 1; j >= 0; j--)
1682 swap_rtx_condition (XVECEXP (pat, i, j));
1684 else if (fmt[i] == 'e')
1685 swap_rtx_condition (XEXP (pat, i));
1689 /* Handle a comparison. Special care needs to be taken to avoid
1690 causing comparisons that a 387 cannot do correctly, such as EQ.
1692 Also, a pop insn may need to be emitted. The 387 does have an
1693 `fcompp' insn that can pop two regs, but it is sometimes too expensive
1694 to do this - a `fcomp' followed by a `fstpl %st(0)' may be easier to
1695 set up. */
1697 static void
1698 compare_for_stack_reg (insn, regstack, pat)
1699 rtx insn;
1700 stack regstack;
1701 rtx pat;
1703 rtx *src1, *src2;
1704 rtx src1_note, src2_note;
1705 rtx cc0_user;
1706 int have_cmove;
1708 src1 = get_true_reg (&XEXP (SET_SRC (pat), 0));
1709 src2 = get_true_reg (&XEXP (SET_SRC (pat), 1));
1710 cc0_user = next_cc0_user (insn);
1712 /* If the insn that uses cc0 is an FP-conditional move, then the destination
1713 must be the top of stack */
1714 if (GET_CODE (PATTERN (cc0_user)) == SET
1715 && SET_DEST (PATTERN (cc0_user)) != pc_rtx
1716 && GET_CODE (SET_SRC (PATTERN (cc0_user))) == IF_THEN_ELSE
1717 && (GET_MODE_CLASS (GET_MODE (SET_DEST (PATTERN (cc0_user))))
1718 == MODE_FLOAT))
1720 rtx *dest;
1722 dest = get_true_reg (&SET_DEST (PATTERN (cc0_user)));
1724 have_cmove = 1;
1725 if (get_hard_regnum (regstack, *dest) >= FIRST_STACK_REG
1726 && REGNO (*dest) != regstack->reg[regstack->top])
1728 emit_swap_insn (insn, regstack, *dest);
1731 else
1732 have_cmove = 0;
1734 /* ??? If fxch turns out to be cheaper than fstp, give priority to
1735 registers that die in this insn - move those to stack top first. */
1736 if (! STACK_REG_P (*src1)
1737 || (STACK_REG_P (*src2)
1738 && get_hard_regnum (regstack, *src2) == FIRST_STACK_REG))
1740 rtx temp, next;
1742 temp = XEXP (SET_SRC (pat), 0);
1743 XEXP (SET_SRC (pat), 0) = XEXP (SET_SRC (pat), 1);
1744 XEXP (SET_SRC (pat), 1) = temp;
1746 src1 = get_true_reg (&XEXP (SET_SRC (pat), 0));
1747 src2 = get_true_reg (&XEXP (SET_SRC (pat), 1));
1749 next = next_cc0_user (insn);
1750 if (next == NULL_RTX)
1751 abort ();
1753 swap_rtx_condition (PATTERN (next));
1754 INSN_CODE (next) = -1;
1755 INSN_CODE (insn) = -1;
1758 /* We will fix any death note later. */
1760 src1_note = find_regno_note (insn, REG_DEAD, REGNO (*src1));
1762 if (STACK_REG_P (*src2))
1763 src2_note = find_regno_note (insn, REG_DEAD, REGNO (*src2));
1764 else
1765 src2_note = NULL_RTX;
1767 if (! have_cmove)
1768 emit_swap_insn (insn, regstack, *src1);
1770 replace_reg (src1, FIRST_STACK_REG);
1772 if (STACK_REG_P (*src2))
1773 replace_reg (src2, get_hard_regnum (regstack, *src2));
1775 if (src1_note)
1777 pop_stack (regstack, REGNO (XEXP (src1_note, 0)));
1778 replace_reg (&XEXP (src1_note, 0), FIRST_STACK_REG);
1781 /* If the second operand dies, handle that. But if the operands are
1782 the same stack register, don't bother, because only one death is
1783 needed, and it was just handled. */
1785 if (src2_note
1786 && ! (STACK_REG_P (*src1) && STACK_REG_P (*src2)
1787 && REGNO (*src1) == REGNO (*src2)))
1789 /* As a special case, two regs may die in this insn if src2 is
1790 next to top of stack and the top of stack also dies. Since
1791 we have already popped src1, "next to top of stack" is really
1792 at top (FIRST_STACK_REG) now. */
1794 if (get_hard_regnum (regstack, XEXP (src2_note, 0)) == FIRST_STACK_REG
1795 && src1_note)
1797 pop_stack (regstack, REGNO (XEXP (src2_note, 0)));
1798 replace_reg (&XEXP (src2_note, 0), FIRST_STACK_REG + 1);
1800 else
1802 /* The 386 can only represent death of the first operand in
1803 the case handled above. In all other cases, emit a separate
1804 pop and remove the death note from here. */
1806 link_cc0_insns (insn);
1808 remove_regno_note (insn, REG_DEAD, REGNO (XEXP (src2_note, 0)));
1810 emit_pop_insn (insn, regstack, XEXP (src2_note, 0),
1811 emit_insn_after);
1816 /* Substitute new registers in PAT, which is part of INSN. REGSTACK
1817 is the current register layout. */
1819 static void
1820 subst_stack_regs_pat (insn, regstack, pat)
1821 rtx insn;
1822 stack regstack;
1823 rtx pat;
1825 rtx *dest, *src;
1826 rtx *src1 = (rtx *) NULL_PTR, *src2;
1827 rtx src1_note, src2_note;
1829 if (GET_CODE (pat) != SET)
1830 return;
1832 dest = get_true_reg (&SET_DEST (pat));
1833 src = get_true_reg (&SET_SRC (pat));
1835 /* See if this is a `movM' pattern, and handle elsewhere if so. */
1837 if (*dest != cc0_rtx
1838 && (STACK_REG_P (*src)
1839 || (STACK_REG_P (*dest)
1840 && (GET_CODE (*src) == REG || GET_CODE (*src) == MEM
1841 || GET_CODE (*src) == CONST_DOUBLE))))
1842 move_for_stack_reg (insn, regstack, pat);
1843 else
1844 switch (GET_CODE (SET_SRC (pat)))
1846 case COMPARE:
1847 compare_for_stack_reg (insn, regstack, pat);
1848 break;
1850 case CALL:
1852 int count;
1853 for (count = HARD_REGNO_NREGS (REGNO (*dest), GET_MODE (*dest));
1854 --count >= 0;)
1856 regstack->reg[++regstack->top] = REGNO (*dest) + count;
1857 SET_HARD_REG_BIT (regstack->reg_set, REGNO (*dest) + count);
1860 replace_reg (dest, FIRST_STACK_REG);
1861 break;
1863 case REG:
1864 /* This is a `tstM2' case. */
1865 if (*dest != cc0_rtx)
1866 abort ();
1868 src1 = src;
1870 /* Fall through. */
1872 case FLOAT_TRUNCATE:
1873 case SQRT:
1874 case ABS:
1875 case NEG:
1876 /* These insns only operate on the top of the stack. DEST might
1877 be cc0_rtx if we're processing a tstM pattern. Also, it's
1878 possible that the tstM case results in a REG_DEAD note on the
1879 source. */
1881 if (src1 == 0)
1882 src1 = get_true_reg (&XEXP (SET_SRC (pat), 0));
1884 emit_swap_insn (insn, regstack, *src1);
1886 src1_note = find_regno_note (insn, REG_DEAD, REGNO (*src1));
1888 if (STACK_REG_P (*dest))
1889 replace_reg (dest, FIRST_STACK_REG);
1891 if (src1_note)
1893 replace_reg (&XEXP (src1_note, 0), FIRST_STACK_REG);
1894 regstack->top--;
1895 CLEAR_HARD_REG_BIT (regstack->reg_set, REGNO (*src1));
1898 replace_reg (src1, FIRST_STACK_REG);
1900 break;
1902 case MINUS:
1903 case DIV:
1904 /* On i386, reversed forms of subM3 and divM3 exist for
1905 MODE_FLOAT, so the same code that works for addM3 and mulM3
1906 can be used. */
1907 case MULT:
1908 case PLUS:
1909 /* These insns can accept the top of stack as a destination
1910 from a stack reg or mem, or can use the top of stack as a
1911 source and some other stack register (possibly top of stack)
1912 as a destination. */
1914 src1 = get_true_reg (&XEXP (SET_SRC (pat), 0));
1915 src2 = get_true_reg (&XEXP (SET_SRC (pat), 1));
1917 /* We will fix any death note later. */
1919 if (STACK_REG_P (*src1))
1920 src1_note = find_regno_note (insn, REG_DEAD, REGNO (*src1));
1921 else
1922 src1_note = NULL_RTX;
1923 if (STACK_REG_P (*src2))
1924 src2_note = find_regno_note (insn, REG_DEAD, REGNO (*src2));
1925 else
1926 src2_note = NULL_RTX;
1928 /* If either operand is not a stack register, then the dest
1929 must be top of stack. */
1931 if (! STACK_REG_P (*src1) || ! STACK_REG_P (*src2))
1932 emit_swap_insn (insn, regstack, *dest);
1933 else
1935 /* Both operands are REG. If neither operand is already
1936 at the top of stack, choose to make the one that is the dest
1937 the new top of stack. */
1939 int src1_hard_regnum, src2_hard_regnum;
1941 src1_hard_regnum = get_hard_regnum (regstack, *src1);
1942 src2_hard_regnum = get_hard_regnum (regstack, *src2);
1943 if (src1_hard_regnum == -1 || src2_hard_regnum == -1)
1944 abort ();
1946 if (src1_hard_regnum != FIRST_STACK_REG
1947 && src2_hard_regnum != FIRST_STACK_REG)
1948 emit_swap_insn (insn, regstack, *dest);
1951 if (STACK_REG_P (*src1))
1952 replace_reg (src1, get_hard_regnum (regstack, *src1));
1953 if (STACK_REG_P (*src2))
1954 replace_reg (src2, get_hard_regnum (regstack, *src2));
1956 if (src1_note)
1958 /* If the register that dies is at the top of stack, then
1959 the destination is somewhere else - merely substitute it.
1960 But if the reg that dies is not at top of stack, then
1961 move the top of stack to the dead reg, as though we had
1962 done the insn and then a store-with-pop. */
1964 if (REGNO (XEXP (src1_note, 0)) == regstack->reg[regstack->top])
1966 SET_HARD_REG_BIT (regstack->reg_set, REGNO (*dest));
1967 replace_reg (dest, get_hard_regnum (regstack, *dest));
1969 else
1971 int regno = get_hard_regnum (regstack, XEXP (src1_note, 0));
1973 SET_HARD_REG_BIT (regstack->reg_set, REGNO (*dest));
1974 replace_reg (dest, regno);
1976 regstack->reg[regstack->top - (regno - FIRST_STACK_REG)]
1977 = regstack->reg[regstack->top];
1980 CLEAR_HARD_REG_BIT (regstack->reg_set,
1981 REGNO (XEXP (src1_note, 0)));
1982 replace_reg (&XEXP (src1_note, 0), FIRST_STACK_REG);
1983 regstack->top--;
1985 else if (src2_note)
1987 if (REGNO (XEXP (src2_note, 0)) == regstack->reg[regstack->top])
1989 SET_HARD_REG_BIT (regstack->reg_set, REGNO (*dest));
1990 replace_reg (dest, get_hard_regnum (regstack, *dest));
1992 else
1994 int regno = get_hard_regnum (regstack, XEXP (src2_note, 0));
1996 SET_HARD_REG_BIT (regstack->reg_set, REGNO (*dest));
1997 replace_reg (dest, regno);
1999 regstack->reg[regstack->top - (regno - FIRST_STACK_REG)]
2000 = regstack->reg[regstack->top];
2003 CLEAR_HARD_REG_BIT (regstack->reg_set,
2004 REGNO (XEXP (src2_note, 0)));
2005 replace_reg (&XEXP (src2_note, 0), FIRST_STACK_REG);
2006 regstack->top--;
2008 else
2010 SET_HARD_REG_BIT (regstack->reg_set, REGNO (*dest));
2011 replace_reg (dest, get_hard_regnum (regstack, *dest));
2014 break;
2016 case UNSPEC:
2017 switch (XINT (SET_SRC (pat), 1))
2019 case 1: /* sin */
2020 case 2: /* cos */
2021 /* These insns only operate on the top of the stack. */
2023 src1 = get_true_reg (&XVECEXP (SET_SRC (pat), 0, 0));
2025 emit_swap_insn (insn, regstack, *src1);
2027 src1_note = find_regno_note (insn, REG_DEAD, REGNO (*src1));
2029 if (STACK_REG_P (*dest))
2030 replace_reg (dest, FIRST_STACK_REG);
2032 if (src1_note)
2034 replace_reg (&XEXP (src1_note, 0), FIRST_STACK_REG);
2035 regstack->top--;
2036 CLEAR_HARD_REG_BIT (regstack->reg_set, REGNO (*src1));
2039 replace_reg (src1, FIRST_STACK_REG);
2041 break;
2043 default:
2044 abort ();
2046 break;
2048 case IF_THEN_ELSE:
2049 /* dest has to be on stack. */
2050 if (get_hard_regnum (regstack, *dest) < FIRST_STACK_REG)
2051 abort ();
2053 /* This insn requires the top of stack to be the destination. */
2055 /* If the comparison operator is an FP comparison operator,
2056 it is handled correctly by compare_for_stack_reg () who
2057 will move the destination to the top of stack. But if the
2058 comparison operator is not an FP comparison operator, we
2059 have to handle it here. */
2060 if (get_hard_regnum (regstack, *dest) >= FIRST_STACK_REG
2061 && REGNO (*dest) != regstack->reg[regstack->top])
2062 emit_swap_insn (insn, regstack, *dest);
2064 src1 = get_true_reg (&XEXP (SET_SRC (pat), 1));
2065 src2 = get_true_reg (&XEXP (SET_SRC (pat), 2));
2067 src1_note = find_regno_note (insn, REG_DEAD, REGNO (*src1));
2068 src2_note = find_regno_note (insn, REG_DEAD, REGNO (*src2));
2071 rtx src_note [3];
2072 int i;
2074 src_note[0] = 0;
2075 src_note[1] = src1_note;
2076 src_note[2] = src2_note;
2078 if (STACK_REG_P (*src1))
2079 replace_reg (src1, get_hard_regnum (regstack, *src1));
2080 if (STACK_REG_P (*src2))
2081 replace_reg (src2, get_hard_regnum (regstack, *src2));
2083 for (i = 1; i <= 2; i++)
2084 if (src_note [i])
2086 /* If the register that dies is not at the top of stack, then
2087 move the top of stack to the dead reg */
2088 if (REGNO (XEXP (src_note[i], 0))
2089 != regstack->reg[regstack->top])
2091 remove_regno_note (insn, REG_DEAD,
2092 REGNO (XEXP (src_note [i], 0)));
2093 emit_pop_insn (insn, regstack, XEXP (src_note[i], 0),
2094 emit_insn_after);
2096 else
2098 CLEAR_HARD_REG_BIT (regstack->reg_set,
2099 REGNO (XEXP (src_note[i], 0)));
2100 replace_reg (&XEXP (src_note[i], 0), FIRST_STACK_REG);
2101 regstack->top--;
2106 /* Make dest the top of stack. */
2107 SET_HARD_REG_BIT (regstack->reg_set, REGNO (*dest));
2108 replace_reg (dest, FIRST_STACK_REG);
2110 break;
2112 default:
2113 abort ();
2117 /* Substitute hard regnums for any stack regs in INSN, which has
2118 N_INPUTS inputs and N_OUTPUTS outputs. REGSTACK is the stack info
2119 before the insn, and is updated with changes made here.
2121 There are several requirements and assumptions about the use of
2122 stack-like regs in asm statements. These rules are enforced by
2123 record_asm_stack_regs; see comments there for details. Any
2124 asm_operands left in the RTL at this point may be assume to meet the
2125 requirements, since record_asm_stack_regs removes any problem asm. */
2127 static void
2128 subst_asm_stack_regs (insn, regstack)
2129 rtx insn;
2130 stack regstack;
2132 rtx body = PATTERN (insn);
2133 int alt;
2135 rtx *note_reg; /* Array of note contents */
2136 rtx **note_loc; /* Address of REG field of each note */
2137 enum reg_note *note_kind; /* The type of each note */
2139 rtx *clobber_reg;
2140 rtx **clobber_loc;
2142 struct stack_def temp_stack;
2143 int n_notes;
2144 int n_clobbers;
2145 rtx note;
2146 int i;
2147 int n_inputs, n_outputs;
2149 /* Find out what the constraints required. If no constraint
2150 alternative matches, that is a compiler bug: we should have caught
2151 such an insn during the life analysis pass (and reload should have
2152 caught it regardless). */
2153 extract_insn (insn);
2154 constrain_operands (1);
2155 alt = which_alternative;
2157 preprocess_constraints ();
2159 n_inputs = get_asm_operand_n_inputs (body);
2160 n_outputs = recog_n_operands - n_inputs;
2162 if (alt < 0)
2163 abort ();
2165 /* Strip SUBREGs here to make the following code simpler. */
2166 for (i = 0; i < recog_n_operands; i++)
2167 if (GET_CODE (recog_operand[i]) == SUBREG
2168 && GET_CODE (SUBREG_REG (recog_operand[i])) == REG)
2170 recog_operand_loc[i] = & SUBREG_REG (recog_operand[i]);
2171 recog_operand[i] = SUBREG_REG (recog_operand[i]);
2174 /* Set up NOTE_REG, NOTE_LOC and NOTE_KIND. */
2176 for (i = 0, note = REG_NOTES (insn); note; note = XEXP (note, 1))
2177 i++;
2179 note_reg = (rtx *) alloca (i * sizeof (rtx));
2180 note_loc = (rtx **) alloca (i * sizeof (rtx *));
2181 note_kind = (enum reg_note *) alloca (i * sizeof (enum reg_note));
2183 n_notes = 0;
2184 for (note = REG_NOTES (insn); note; note = XEXP (note, 1))
2186 rtx reg = XEXP (note, 0);
2187 rtx *loc = & XEXP (note, 0);
2189 if (GET_CODE (reg) == SUBREG && GET_CODE (SUBREG_REG (reg)) == REG)
2191 loc = & SUBREG_REG (reg);
2192 reg = SUBREG_REG (reg);
2195 if (STACK_REG_P (reg)
2196 && (REG_NOTE_KIND (note) == REG_DEAD
2197 || REG_NOTE_KIND (note) == REG_UNUSED))
2199 note_reg[n_notes] = reg;
2200 note_loc[n_notes] = loc;
2201 note_kind[n_notes] = REG_NOTE_KIND (note);
2202 n_notes++;
2206 /* Set up CLOBBER_REG and CLOBBER_LOC. */
2208 n_clobbers = 0;
2210 if (GET_CODE (body) == PARALLEL)
2212 clobber_reg = (rtx *) alloca (XVECLEN (body, 0) * sizeof (rtx));
2213 clobber_loc = (rtx **) alloca (XVECLEN (body, 0) * sizeof (rtx *));
2215 for (i = 0; i < XVECLEN (body, 0); i++)
2216 if (GET_CODE (XVECEXP (body, 0, i)) == CLOBBER)
2218 rtx clobber = XVECEXP (body, 0, i);
2219 rtx reg = XEXP (clobber, 0);
2220 rtx *loc = & XEXP (clobber, 0);
2222 if (GET_CODE (reg) == SUBREG && GET_CODE (SUBREG_REG (reg)) == REG)
2224 loc = & SUBREG_REG (reg);
2225 reg = SUBREG_REG (reg);
2228 if (STACK_REG_P (reg))
2230 clobber_reg[n_clobbers] = reg;
2231 clobber_loc[n_clobbers] = loc;
2232 n_clobbers++;
2237 bcopy ((char *) regstack, (char *) &temp_stack, sizeof (temp_stack));
2239 /* Put the input regs into the desired place in TEMP_STACK. */
2241 for (i = n_outputs; i < n_outputs + n_inputs; i++)
2242 if (STACK_REG_P (recog_operand[i])
2243 && reg_class_subset_p (recog_op_alt[i][alt].class,
2244 FLOAT_REGS)
2245 && recog_op_alt[i][alt].class != FLOAT_REGS)
2247 /* If an operand needs to be in a particular reg in
2248 FLOAT_REGS, the constraint was either 't' or 'u'. Since
2249 these constraints are for single register classes, and reload
2250 guaranteed that operand[i] is already in that class, we can
2251 just use REGNO (recog_operand[i]) to know which actual reg this
2252 operand needs to be in. */
2254 int regno = get_hard_regnum (&temp_stack, recog_operand[i]);
2256 if (regno < 0)
2257 abort ();
2259 if (regno != REGNO (recog_operand[i]))
2261 /* recog_operand[i] is not in the right place. Find it
2262 and swap it with whatever is already in I's place.
2263 K is where recog_operand[i] is now. J is where it should
2264 be. */
2265 int j, k, temp;
2267 k = temp_stack.top - (regno - FIRST_STACK_REG);
2268 j = (temp_stack.top
2269 - (REGNO (recog_operand[i]) - FIRST_STACK_REG));
2271 temp = temp_stack.reg[k];
2272 temp_stack.reg[k] = temp_stack.reg[j];
2273 temp_stack.reg[j] = temp;
2277 /* emit insns before INSN to make sure the reg-stack is in the right
2278 order. */
2280 change_stack (insn, regstack, &temp_stack, emit_insn_before);
2282 /* Make the needed input register substitutions. Do death notes and
2283 clobbers too, because these are for inputs, not outputs. */
2285 for (i = n_outputs; i < n_outputs + n_inputs; i++)
2286 if (STACK_REG_P (recog_operand[i]))
2288 int regnum = get_hard_regnum (regstack, recog_operand[i]);
2290 if (regnum < 0)
2291 abort ();
2293 replace_reg (recog_operand_loc[i], regnum);
2296 for (i = 0; i < n_notes; i++)
2297 if (note_kind[i] == REG_DEAD)
2299 int regnum = get_hard_regnum (regstack, note_reg[i]);
2301 if (regnum < 0)
2302 abort ();
2304 replace_reg (note_loc[i], regnum);
2307 for (i = 0; i < n_clobbers; i++)
2309 /* It's OK for a CLOBBER to reference a reg that is not live.
2310 Don't try to replace it in that case. */
2311 int regnum = get_hard_regnum (regstack, clobber_reg[i]);
2313 if (regnum >= 0)
2315 /* Sigh - clobbers always have QImode. But replace_reg knows
2316 that these regs can't be MODE_INT and will abort. Just put
2317 the right reg there without calling replace_reg. */
2319 *clobber_loc[i] = FP_MODE_REG (regnum, DFmode);
2323 /* Now remove from REGSTACK any inputs that the asm implicitly popped. */
2325 for (i = n_outputs; i < n_outputs + n_inputs; i++)
2326 if (STACK_REG_P (recog_operand[i]))
2328 /* An input reg is implicitly popped if it is tied to an
2329 output, or if there is a CLOBBER for it. */
2330 int j;
2332 for (j = 0; j < n_clobbers; j++)
2333 if (operands_match_p (clobber_reg[j], recog_operand[i]))
2334 break;
2336 if (j < n_clobbers || recog_op_alt[i][alt].matches >= 0)
2338 /* recog_operand[i] might not be at the top of stack. But that's
2339 OK, because all we need to do is pop the right number of regs
2340 off of the top of the reg-stack. record_asm_stack_regs
2341 guaranteed that all implicitly popped regs were grouped
2342 at the top of the reg-stack. */
2344 CLEAR_HARD_REG_BIT (regstack->reg_set,
2345 regstack->reg[regstack->top]);
2346 regstack->top--;
2350 /* Now add to REGSTACK any outputs that the asm implicitly pushed.
2351 Note that there isn't any need to substitute register numbers.
2352 ??? Explain why this is true. */
2354 for (i = LAST_STACK_REG; i >= FIRST_STACK_REG; i--)
2356 /* See if there is an output for this hard reg. */
2357 int j;
2359 for (j = 0; j < n_outputs; j++)
2360 if (STACK_REG_P (recog_operand[j]) && REGNO (recog_operand[j]) == i)
2362 regstack->reg[++regstack->top] = i;
2363 SET_HARD_REG_BIT (regstack->reg_set, i);
2364 break;
2368 /* Now emit a pop insn for any REG_UNUSED output, or any REG_DEAD
2369 input that the asm didn't implicitly pop. If the asm didn't
2370 implicitly pop an input reg, that reg will still be live.
2372 Note that we can't use find_regno_note here: the register numbers
2373 in the death notes have already been substituted. */
2375 for (i = 0; i < n_outputs; i++)
2376 if (STACK_REG_P (recog_operand[i]))
2378 int j;
2380 for (j = 0; j < n_notes; j++)
2381 if (REGNO (recog_operand[i]) == REGNO (note_reg[j])
2382 && note_kind[j] == REG_UNUSED)
2384 insn = emit_pop_insn (insn, regstack, recog_operand[i],
2385 emit_insn_after);
2386 break;
2390 for (i = n_outputs; i < n_outputs + n_inputs; i++)
2391 if (STACK_REG_P (recog_operand[i]))
2393 int j;
2395 for (j = 0; j < n_notes; j++)
2396 if (REGNO (recog_operand[i]) == REGNO (note_reg[j])
2397 && note_kind[j] == REG_DEAD
2398 && TEST_HARD_REG_BIT (regstack->reg_set,
2399 REGNO (recog_operand[i])))
2401 insn = emit_pop_insn (insn, regstack, recog_operand[i],
2402 emit_insn_after);
2403 break;
2408 /* Substitute stack hard reg numbers for stack virtual registers in
2409 INSN. Non-stack register numbers are not changed. REGSTACK is the
2410 current stack content. Insns may be emitted as needed to arrange the
2411 stack for the 387 based on the contents of the insn. */
2413 static void
2414 subst_stack_regs (insn, regstack)
2415 rtx insn;
2416 stack regstack;
2418 register rtx *note_link, note;
2419 register int i;
2421 if (GET_CODE (insn) == CALL_INSN)
2423 int top = regstack->top;
2425 /* If there are any floating point parameters to be passed in
2426 registers for this call, make sure they are in the right
2427 order. */
2429 if (top >= 0)
2431 straighten_stack (PREV_INSN (insn), regstack);
2433 /* Now mark the arguments as dead after the call. */
2435 while (regstack->top >= 0)
2437 CLEAR_HARD_REG_BIT (regstack->reg_set, FIRST_STACK_REG + regstack->top);
2438 regstack->top--;
2443 /* Do the actual substitution if any stack regs are mentioned.
2444 Since we only record whether entire insn mentions stack regs, and
2445 subst_stack_regs_pat only works for patterns that contain stack regs,
2446 we must check each pattern in a parallel here. A call_value_pop could
2447 fail otherwise. */
2449 if (GET_MODE (insn) == QImode)
2451 int n_operands = asm_noperands (PATTERN (insn));
2452 if (n_operands >= 0)
2454 /* This insn is an `asm' with operands. Decode the operands,
2455 decide how many are inputs, and do register substitution.
2456 Any REG_UNUSED notes will be handled by subst_asm_stack_regs. */
2458 subst_asm_stack_regs (insn, regstack);
2459 return;
2462 if (GET_CODE (PATTERN (insn)) == PARALLEL)
2463 for (i = 0; i < XVECLEN (PATTERN (insn), 0); i++)
2465 if (stack_regs_mentioned_p (XVECEXP (PATTERN (insn), 0, i)))
2466 subst_stack_regs_pat (insn, regstack,
2467 XVECEXP (PATTERN (insn), 0, i));
2469 else
2470 subst_stack_regs_pat (insn, regstack, PATTERN (insn));
2473 /* subst_stack_regs_pat may have deleted a no-op insn. If so, any
2474 REG_UNUSED will already have been dealt with, so just return. */
2476 if (GET_CODE (insn) == NOTE)
2477 return;
2479 /* If there is a REG_UNUSED note on a stack register on this insn,
2480 the indicated reg must be popped. The REG_UNUSED note is removed,
2481 since the form of the newly emitted pop insn references the reg,
2482 making it no longer `unset'. */
2484 note_link = &REG_NOTES(insn);
2485 for (note = *note_link; note; note = XEXP (note, 1))
2486 if (REG_NOTE_KIND (note) == REG_UNUSED && STACK_REG_P (XEXP (note, 0)))
2488 *note_link = XEXP (note, 1);
2489 insn = emit_pop_insn (insn, regstack, XEXP (note, 0), emit_insn_after);
2491 else
2492 note_link = &XEXP (note, 1);
2495 /* Change the organization of the stack so that it fits a new basic
2496 block. Some registers might have to be popped, but there can never be
2497 a register live in the new block that is not now live.
2499 Insert any needed insns before or after INSN. WHEN is emit_insn_before
2500 or emit_insn_after. OLD is the original stack layout, and NEW is
2501 the desired form. OLD is updated to reflect the code emitted, ie, it
2502 will be the same as NEW upon return.
2504 This function will not preserve block_end[]. But that information
2505 is no longer needed once this has executed. */
2507 static void
2508 change_stack (insn, old, new, when)
2509 rtx insn;
2510 stack old;
2511 stack new;
2512 rtx (*when)();
2514 int reg;
2516 /* We will be inserting new insns "backwards", by calling emit_insn_before.
2517 If we are to insert after INSN, find the next insn, and insert before
2518 it. */
2520 if (when == emit_insn_after)
2521 insn = NEXT_INSN (insn);
2523 /* Pop any registers that are not needed in the new block. */
2525 for (reg = old->top; reg >= 0; reg--)
2526 if (! TEST_HARD_REG_BIT (new->reg_set, old->reg[reg]))
2527 emit_pop_insn (insn, old, FP_MODE_REG (old->reg[reg], DFmode),
2528 emit_insn_before);
2530 if (new->top == -2)
2532 /* If the new block has never been processed, then it can inherit
2533 the old stack order. */
2535 new->top = old->top;
2536 bcopy (old->reg, new->reg, sizeof (new->reg));
2538 else
2540 /* This block has been entered before, and we must match the
2541 previously selected stack order. */
2543 /* By now, the only difference should be the order of the stack,
2544 not their depth or liveliness. */
2546 GO_IF_HARD_REG_EQUAL (old->reg_set, new->reg_set, win);
2548 abort ();
2550 win:
2552 if (old->top != new->top)
2553 abort ();
2555 /* Loop here emitting swaps until the stack is correct. The
2556 worst case number of swaps emitted is N + 2, where N is the
2557 depth of the stack. In some cases, the reg at the top of
2558 stack may be correct, but swapped anyway in order to fix
2559 other regs. But since we never swap any other reg away from
2560 its correct slot, this algorithm will converge. */
2564 /* Swap the reg at top of stack into the position it is
2565 supposed to be in, until the correct top of stack appears. */
2567 while (old->reg[old->top] != new->reg[new->top])
2569 for (reg = new->top; reg >= 0; reg--)
2570 if (new->reg[reg] == old->reg[old->top])
2571 break;
2573 if (reg == -1)
2574 abort ();
2576 emit_swap_insn (insn, old,
2577 FP_MODE_REG (old->reg[reg], DFmode));
2580 /* See if any regs remain incorrect. If so, bring an
2581 incorrect reg to the top of stack, and let the while loop
2582 above fix it. */
2584 for (reg = new->top; reg >= 0; reg--)
2585 if (new->reg[reg] != old->reg[reg])
2587 emit_swap_insn (insn, old,
2588 FP_MODE_REG (old->reg[reg], DFmode));
2589 break;
2591 } while (reg >= 0);
2593 /* At this point there must be no differences. */
2595 for (reg = old->top; reg >= 0; reg--)
2596 if (old->reg[reg] != new->reg[reg])
2597 abort ();
2601 /* Check PAT, which points to RTL in INSN, for a LABEL_REF. If it is
2602 found, ensure that a jump from INSN to the code_label to which the
2603 label_ref points ends up with the same stack as that at the
2604 code_label. Do this by inserting insns just before the code_label to
2605 pop and rotate the stack until it is in the correct order. REGSTACK
2606 is the order of the register stack in INSN.
2608 Any code that is emitted here must not be later processed as part
2609 of any block, as it will already contain hard register numbers. */
2611 static void
2612 goto_block_pat (insn, regstack, pat)
2613 rtx insn;
2614 stack regstack;
2615 rtx pat;
2617 rtx label;
2618 rtx new_jump, new_label, new_barrier;
2619 rtx *ref;
2620 stack label_stack;
2621 struct stack_def temp_stack;
2622 int reg;
2624 switch (GET_CODE (pat))
2626 case RETURN:
2627 straighten_stack (PREV_INSN (insn), regstack);
2628 return;
2629 default:
2631 int i, j;
2632 char *fmt = GET_RTX_FORMAT (GET_CODE (pat));
2634 for (i = GET_RTX_LENGTH (GET_CODE (pat)) - 1; i >= 0; i--)
2636 if (fmt[i] == 'e')
2637 goto_block_pat (insn, regstack, XEXP (pat, i));
2638 if (fmt[i] == 'E')
2639 for (j = 0; j < XVECLEN (pat, i); j++)
2640 goto_block_pat (insn, regstack, XVECEXP (pat, i, j));
2642 return;
2644 case LABEL_REF:;
2647 label = XEXP (pat, 0);
2648 if (GET_CODE (label) != CODE_LABEL)
2649 abort ();
2651 /* First, see if in fact anything needs to be done to the stack at all. */
2652 if (INSN_UID (label) <= 0)
2653 return;
2655 label_stack = &block_stack_in[BLOCK_NUM (label)];
2657 if (label_stack->top == -2)
2659 /* If the target block hasn't had a stack order selected, then
2660 we need merely ensure that no pops are needed. */
2662 for (reg = regstack->top; reg >= 0; reg--)
2663 if (! TEST_HARD_REG_BIT (label_stack->reg_set, regstack->reg[reg]))
2664 break;
2666 if (reg == -1)
2668 /* change_stack will not emit any code in this case. */
2670 change_stack (label, regstack, label_stack, emit_insn_after);
2671 return;
2674 else if (label_stack->top == regstack->top)
2676 for (reg = label_stack->top; reg >= 0; reg--)
2677 if (label_stack->reg[reg] != regstack->reg[reg])
2678 break;
2680 if (reg == -1)
2681 return;
2684 /* At least one insn will need to be inserted before label. Insert
2685 a jump around the code we are about to emit. Emit a label for the new
2686 code, and point the original insn at this new label. We can't use
2687 redirect_jump here, because we're using fld[4] of the code labels as
2688 LABEL_REF chains, no NUSES counters. */
2690 new_jump = emit_jump_insn_before (gen_jump (label), label);
2691 record_label_references (new_jump, PATTERN (new_jump));
2692 JUMP_LABEL (new_jump) = label;
2694 new_barrier = emit_barrier_after (new_jump);
2696 new_label = gen_label_rtx ();
2697 emit_label_after (new_label, new_barrier);
2698 LABEL_REFS (new_label) = new_label;
2700 /* The old label_ref will no longer point to the code_label if now uses,
2701 so strip the label_ref from the code_label's chain of references. */
2703 for (ref = &LABEL_REFS (label); *ref != label; ref = &LABEL_NEXTREF (*ref))
2704 if (*ref == pat)
2705 break;
2707 if (*ref == label)
2708 abort ();
2710 *ref = LABEL_NEXTREF (*ref);
2712 XEXP (pat, 0) = new_label;
2713 record_label_references (insn, PATTERN (insn));
2715 if (JUMP_LABEL (insn) == label)
2716 JUMP_LABEL (insn) = new_label;
2718 /* Now emit the needed code. */
2720 temp_stack = *regstack;
2722 change_stack (new_label, &temp_stack, label_stack, emit_insn_after);
2725 /* Traverse all basic blocks in a function, converting the register
2726 references in each insn from the "flat" register file that gcc uses, to
2727 the stack-like registers the 387 uses. */
2729 static void
2730 convert_regs ()
2732 register int block, reg;
2733 register rtx insn, next;
2734 struct stack_def regstack;
2736 for (block = 0; block < blocks; block++)
2738 if (block_stack_in[block].top == -2)
2740 /* This block has not been previously encountered. Choose a
2741 default mapping for any stack regs live on entry */
2743 block_stack_in[block].top = -1;
2745 for (reg = LAST_STACK_REG; reg >= FIRST_STACK_REG; reg--)
2746 if (TEST_HARD_REG_BIT (block_stack_in[block].reg_set, reg))
2747 block_stack_in[block].reg[++block_stack_in[block].top] = reg;
2750 /* Process all insns in this block. Keep track of `next' here,
2751 so that we don't process any insns emitted while making
2752 substitutions in INSN. */
2754 next = block_begin[block];
2755 regstack = block_stack_in[block];
2758 insn = next;
2759 next = NEXT_INSN (insn);
2761 /* Don't bother processing unless there is a stack reg
2762 mentioned or if it's a CALL_INSN (register passing of
2763 floating point values). */
2765 if (GET_MODE (insn) == QImode || GET_CODE (insn) == CALL_INSN)
2766 subst_stack_regs (insn, &regstack);
2768 } while (insn != block_end[block]);
2770 /* For all further actions, INSN needs to be the last insn in
2771 this basic block. If subst_stack_regs inserted additional
2772 instructions after INSN, it is no longer the last one at
2773 this point. */
2774 next = PREV_INSN (next);
2776 /* If subst_stack_regs inserted something after a JUMP_INSN, that
2777 is almost certainly a bug. */
2778 if (GET_CODE (insn) == JUMP_INSN && insn != next)
2779 abort ();
2780 insn = next;
2782 /* Something failed if the stack life doesn't match. */
2784 GO_IF_HARD_REG_EQUAL (regstack.reg_set, block_out_reg_set[block], win);
2786 abort ();
2788 win:
2790 /* Adjust the stack of this block on exit to match the stack of
2791 the target block, or copy stack information into stack of
2792 jump target if the target block's stack order hasn't been set
2793 yet. */
2795 if (GET_CODE (insn) == JUMP_INSN)
2796 goto_block_pat (insn, &regstack, PATTERN (insn));
2798 /* Likewise handle the case where we fall into the next block. */
2800 if ((block < blocks - 1) && block_drops_in[block+1])
2801 change_stack (insn, &regstack, &block_stack_in[block+1],
2802 emit_insn_after);
2805 /* If the last basic block is the end of a loop, and that loop has
2806 regs live at its start, then the last basic block will have regs live
2807 at its end that need to be popped before the function returns. */
2810 int value_reg_low, value_reg_high;
2811 value_reg_low = value_reg_high = -1;
2813 rtx retvalue;
2814 if ((retvalue = stack_result (current_function_decl)))
2816 value_reg_low = REGNO (retvalue);
2817 value_reg_high = value_reg_low +
2818 HARD_REGNO_NREGS (value_reg_low, GET_MODE (retvalue)) - 1;
2822 for (reg = regstack.top; reg >= 0; reg--)
2823 if (regstack.reg[reg] < value_reg_low
2824 || regstack.reg[reg] > value_reg_high)
2825 insn = emit_pop_insn (insn, &regstack,
2826 FP_MODE_REG (regstack.reg[reg], DFmode),
2827 emit_insn_after);
2829 straighten_stack (insn, &regstack);
2832 /* Check expression PAT, which is in INSN, for label references. if
2833 one is found, print the block number of destination to FILE. */
2835 static void
2836 print_blocks (file, insn, pat)
2837 FILE *file;
2838 rtx insn, pat;
2840 register RTX_CODE code = GET_CODE (pat);
2841 register int i;
2842 register char *fmt;
2844 if (code == LABEL_REF)
2846 register rtx label = XEXP (pat, 0);
2848 if (GET_CODE (label) != CODE_LABEL)
2849 abort ();
2851 fprintf (file, " %d", BLOCK_NUM (label));
2853 return;
2856 fmt = GET_RTX_FORMAT (code);
2857 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
2859 if (fmt[i] == 'e')
2860 print_blocks (file, insn, XEXP (pat, i));
2861 if (fmt[i] == 'E')
2863 register int j;
2864 for (j = 0; j < XVECLEN (pat, i); j++)
2865 print_blocks (file, insn, XVECEXP (pat, i, j));
2870 /* Write information about stack registers and stack blocks into FILE.
2871 This is part of making a debugging dump. */
2873 static void
2874 dump_stack_info (file)
2875 FILE *file;
2877 register int block;
2879 fprintf (file, "\n%d stack blocks.\n", blocks);
2880 for (block = 0; block < blocks; block++)
2882 register rtx head, jump, end;
2883 register int regno;
2885 fprintf (file, "\nStack block %d: first insn %d, last %d.\n",
2886 block, INSN_UID (block_begin[block]),
2887 INSN_UID (block_end[block]));
2889 head = block_begin[block];
2891 fprintf (file, "Reached from blocks: ");
2892 if (GET_CODE (head) == CODE_LABEL)
2893 for (jump = LABEL_REFS (head);
2894 jump != head;
2895 jump = LABEL_NEXTREF (jump))
2897 register int from_block = BLOCK_NUM (CONTAINING_INSN (jump));
2898 fprintf (file, " %d", from_block);
2900 if (block_drops_in[block])
2901 fprintf (file, " previous");
2903 fprintf (file, "\nlive stack registers on block entry: ");
2904 for (regno = FIRST_STACK_REG; regno <= LAST_STACK_REG; regno++)
2906 if (TEST_HARD_REG_BIT (block_stack_in[block].reg_set, regno))
2907 fprintf (file, "%d ", regno);
2910 fprintf (file, "\nlive stack registers on block exit: ");
2911 for (regno = FIRST_STACK_REG; regno <= LAST_STACK_REG; regno++)
2913 if (TEST_HARD_REG_BIT (block_out_reg_set[block], regno))
2914 fprintf (file, "%d ", regno);
2917 end = block_end[block];
2919 fprintf (file, "\nJumps to blocks: ");
2920 if (GET_CODE (end) == JUMP_INSN)
2921 print_blocks (file, end, PATTERN (end));
2923 if (block + 1 < blocks && block_drops_in[block+1])
2924 fprintf (file, " next");
2925 else if (block + 1 == blocks
2926 || (GET_CODE (end) == JUMP_INSN
2927 && GET_CODE (PATTERN (end)) == RETURN))
2928 fprintf (file, " return");
2930 fprintf (file, "\n");
2933 #endif /* STACK_REGS */