OSDN Git Service

Include <stdarg.h> instead of "gstdarg.h"; similarly for varargs.
[pf3gnuchains/gcc-fork.git] / gcc / final.c
1 /* Convert RTL to assembler code and output it, for GNU compiler.
2    Copyright (C) 1987, 88, 89, 92, 93, 1994 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING.  If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
19
20
21 /* This is the final pass of the compiler.
22    It looks at the rtl code for a function and outputs assembler code.
23
24    Call `final_start_function' to output the assembler code for function entry,
25    `final' to output assembler code for some RTL code,
26    `final_end_function' to output assembler code for function exit.
27    If a function is compiled in several pieces, each piece is
28    output separately with `final'.
29
30    Some optimizations are also done at this level.
31    Move instructions that were made unnecessary by good register allocation
32    are detected and omitted from the output.  (Though most of these
33    are removed by the last jump pass.)
34
35    Instructions to set the condition codes are omitted when it can be
36    seen that the condition codes already had the desired values.
37
38    In some cases it is sufficient if the inherited condition codes
39    have related values, but this may require the following insn
40    (the one that tests the condition codes) to be modified.
41
42    The code for the function prologue and epilogue are generated
43    directly as assembler code by the macros FUNCTION_PROLOGUE and
44    FUNCTION_EPILOGUE.  Those instructions never exist as rtl.  */
45
46 #include "config.h"
47 #ifdef __STDC__
48 #include <stdarg.h>
49 #else
50 #include <varargs.h>
51 #endif
52 #include "tree.h"
53 #include "rtl.h"
54 #include "regs.h"
55 #include "insn-config.h"
56 #include "insn-flags.h"
57 #include "insn-attr.h"
58 #include "insn-codes.h"
59 #include "recog.h"
60 #include "conditions.h"
61 #include "flags.h"
62 #include "real.h"
63 #include "hard-reg-set.h"
64 #include "defaults.h"
65
66 #include <stdio.h>
67 #include <ctype.h>
68
69 #include "output.h"
70
71 /* Get N_SLINE and N_SOL from stab.h if we can expect the file to exist.  */
72 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
73 #if defined (USG) || defined (NO_STAB_H)
74 #include "gstab.h"  /* If doing DBX on sysV, use our own stab.h.  */
75 #else
76 #include <stab.h>  /* On BSD, use the system's stab.h.  */
77 #endif /* not USG */
78 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
79
80 #ifdef XCOFF_DEBUGGING_INFO
81 #include "xcoffout.h"
82 #endif
83
84 /* .stabd code for line number.  */
85 #ifndef N_SLINE
86 #define N_SLINE 0x44
87 #endif
88
89 /* .stabs code for included file name.  */
90 #ifndef N_SOL
91 #define N_SOL 0x84
92 #endif
93
94 #ifndef INT_TYPE_SIZE
95 #define INT_TYPE_SIZE BITS_PER_WORD
96 #endif
97
98 /* If we aren't using cc0, CC_STATUS_INIT shouldn't exist.  So define a
99    null default for it to save conditionalization later.  */
100 #ifndef CC_STATUS_INIT
101 #define CC_STATUS_INIT
102 #endif
103
104 /* How to start an assembler comment.  */
105 #ifndef ASM_COMMENT_START
106 #define ASM_COMMENT_START ";#"
107 #endif
108
109 /* Is the given character a logical line separator for the assembler?  */
110 #ifndef IS_ASM_LOGICAL_LINE_SEPARATOR
111 #define IS_ASM_LOGICAL_LINE_SEPARATOR(C) ((C) == ';')
112 #endif
113
114 rtx peephole ();
115 void output_asm_insn ();
116 rtx alter_subreg ();
117 static rtx walk_alter_subreg ();
118 static int alter_cond ();
119 void output_asm_label ();
120 static void output_operand ();
121 void output_address ();
122 void output_addr_const ();
123 static void output_source_line ();
124 rtx final_scan_insn ();
125 void profile_function ();
126 static void profile_after_prologue ();
127
128 #ifdef HAVE_ATTR_length
129 static int asm_insn_count ();
130 #endif
131
132 /* Nonzero means this function is a leaf function, with no function calls. 
133    This variable exists to be examined in FUNCTION_PROLOGUE
134    and FUNCTION_EPILOGUE.  Always zero, unless set by some action.  */
135 int leaf_function;
136
137 int leaf_function_p ();
138
139 #ifdef LEAF_REGISTERS
140 int only_leaf_regs_used ();
141 static void leaf_renumber_regs ();
142 void leaf_renumber_regs_insn ();
143 #endif
144
145 /* Last insn processed by final_scan_insn.  */
146 static rtx debug_insn = 0;
147
148 /* Line number of last NOTE.  */
149 static int last_linenum;
150
151 /* Filename of last NOTE.  */
152 static char *last_filename;
153
154 /* Number of basic blocks seen so far;
155    used if profile_block_flag is set.  */
156 static int count_basic_blocks;
157
158 /* Nonzero while outputting an `asm' with operands.
159    This means that inconsistencies are the user's fault, so don't abort.
160    The precise value is the insn being output, to pass to error_for_asm.  */
161 static rtx this_is_asm_operands;
162
163 /* Number of operands of this insn, for an `asm' with operands.  */
164 static int insn_noperands;
165
166 /* Compare optimization flag.  */
167
168 static rtx last_ignored_compare = 0;
169
170 /* Flag indicating this insn is the start of a new basic block.  */
171
172 static int new_block = 1;
173
174 /* All the symbol-blocks (levels of scoping) in the compilation
175    are assigned sequence numbers in order of appearance of the
176    beginnings of the symbol-blocks.  Both final and dbxout do this,
177    and assume that they will both give the same number to each block.
178    Final uses these sequence numbers to generate assembler label names
179    LBBnnn and LBEnnn for the beginning and end of the symbol-block.
180    Dbxout uses the sequence numbers to generate references to the same labels
181    from the dbx debugging information.
182
183    Sdb records this level at the beginning of each function,
184    in order to find the current level when recursing down declarations.
185    It outputs the block beginning and endings
186    at the point in the asm file where the blocks would begin and end.  */
187
188 int next_block_index;
189
190 /* Assign a unique number to each insn that is output.
191    This can be used to generate unique local labels.  */
192
193 static int insn_counter = 0;
194
195 #ifdef HAVE_cc0
196 /* This variable contains machine-dependent flags (defined in tm.h)
197    set and examined by output routines
198    that describe how to interpret the condition codes properly.  */
199
200 CC_STATUS cc_status;
201
202 /* During output of an insn, this contains a copy of cc_status
203    from before the insn.  */
204
205 CC_STATUS cc_prev_status;
206 #endif
207
208 /* Indexed by hardware reg number, is 1 if that register is ever
209    used in the current function.
210
211    In life_analysis, or in stupid_life_analysis, this is set
212    up to record the hard regs used explicitly.  Reload adds
213    in the hard regs used for holding pseudo regs.  Final uses
214    it to generate the code in the function prologue and epilogue
215    to save and restore registers as needed.  */
216
217 char regs_ever_live[FIRST_PSEUDO_REGISTER];
218
219 /* Nonzero means current function must be given a frame pointer.
220    Set in stmt.c if anything is allocated on the stack there.
221    Set in reload1.c if anything is allocated on the stack there.  */
222
223 int frame_pointer_needed;
224
225 /* Assign unique numbers to labels generated for profiling.  */
226
227 int profile_label_no;
228
229 /* Length so far allocated in PENDING_BLOCKS.  */
230
231 static int max_block_depth;
232
233 /* Stack of sequence numbers of symbol-blocks of which we have seen the
234    beginning but not yet the end.  Sequence numbers are assigned at
235    the beginning; this stack allows us to find the sequence number
236    of a block that is ending.  */
237
238 static int *pending_blocks;
239
240 /* Number of elements currently in use in PENDING_BLOCKS.  */
241
242 static int block_depth;
243
244 /* Nonzero if have enabled APP processing of our assembler output.  */
245
246 static int app_on;
247
248 /* If we are outputting an insn sequence, this contains the sequence rtx.
249    Zero otherwise.  */
250
251 rtx final_sequence;
252
253 #ifdef ASSEMBLER_DIALECT
254
255 /* Number of the assembler dialect to use, starting at 0.  */
256 static int dialect_number;
257 #endif
258
259 /* Indexed by line number, nonzero if there is a note for that line.  */
260
261 static char *line_note_exists;
262
263 /* Linked list to hold line numbers for each basic block.  */
264
265 struct bb_list {
266   struct bb_list *next;         /* pointer to next basic block */
267   int line_num;                 /* line number */
268   int file_label_num;           /* LPBC<n> label # for stored filename */
269   int func_label_num;           /* LPBC<n> label # for stored function name */
270 };
271
272 static struct bb_list *bb_head  = 0;            /* Head of basic block list */
273 static struct bb_list **bb_tail = &bb_head;     /* Ptr to store next bb ptr */
274 static int bb_file_label_num    = -1;           /* Current label # for file */
275 static int bb_func_label_num    = -1;           /* Current label # for func */
276
277 /* Linked list to hold the strings for each file and function name output.  */
278
279 struct bb_str {
280   struct bb_str *next;          /* pointer to next string */
281   char *string;                 /* string */
282   int label_num;                /* label number */
283   int length;                   /* string length */
284 };
285
286 static struct bb_str *sbb_head  = 0;            /* Head of string list.  */
287 static struct bb_str **sbb_tail = &sbb_head;    /* Ptr to store next bb str */
288 static int sbb_label_num        = 0;            /* Last label used */
289
290 static int add_bb_string PROTO((char *, int));
291 static void add_bb PROTO((FILE *));
292
293 \f
294 /* Initialize data in final at the beginning of a compilation.  */
295
296 void
297 init_final (filename)
298      char *filename;
299 {
300   next_block_index = 2;
301   app_on = 0;
302   max_block_depth = 20;
303   pending_blocks = (int *) xmalloc (20 * sizeof *pending_blocks);
304   final_sequence = 0;
305
306 #ifdef ASSEMBLER_DIALECT
307   dialect_number = ASSEMBLER_DIALECT;
308 #endif
309 }
310
311 /* Called at end of source file,
312    to output the block-profiling table for this entire compilation.  */
313
314 void
315 end_final (filename)
316      char *filename;
317 {
318   int i;
319
320   if (profile_block_flag)
321     {
322       char name[20];
323       int align = exact_log2 (BIGGEST_ALIGNMENT / BITS_PER_UNIT);
324       int size = (INT_TYPE_SIZE / BITS_PER_UNIT) * count_basic_blocks;
325       int rounded = size;
326       struct bb_list *ptr;
327       struct bb_str *sptr;
328
329       rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;
330       rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
331                  * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
332
333       data_section ();
334
335       /* Output the main header, of 10 words:
336          0:  1 if this file's initialized, else 0.
337          1:  address of file name (LPBX1).
338          2:  address of table of counts (LPBX2).
339          3:  number of counts in the table.
340          4:  always 0, for compatibility with Sun.
341
342          The following are GNU extensions:
343
344          5:  address of table of start addrs of basic blocks (LPBX3).
345          6:  Number of bytes in this header.
346          7:  address of table of function names (LPBX4).
347          8:  address of table of line numbers (LPBX5) or 0.
348          9:  address of table of file names (LPBX6) or 0.  */
349
350       ASM_OUTPUT_ALIGN (asm_out_file, align);
351
352       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 0);
353       /* zero word */
354       assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
355
356       /* address of filename */
357       ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 1);
358       assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name), UNITS_PER_WORD, 1);
359
360       /* address of count table */
361       ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 2);
362       assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name), UNITS_PER_WORD, 1);
363
364       /* count of the # of basic blocks */
365       assemble_integer (GEN_INT (count_basic_blocks), UNITS_PER_WORD, 1);
366
367       /* zero word (link field) */
368       assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
369
370       /* address of basic block start address table */
371       ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 3);
372       assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name), UNITS_PER_WORD, 1);
373
374       /* byte count for extended structure.  */
375       assemble_integer (GEN_INT (10 * UNITS_PER_WORD), UNITS_PER_WORD, 1);
376
377       /* address of function name table */
378       ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 4);
379       assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name), UNITS_PER_WORD, 1);
380
381       /* address of line number and filename tables if debugging.  */
382       if (write_symbols != NO_DEBUG)
383         {
384           ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 5);
385           assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name), UNITS_PER_WORD, 1);
386           ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 6);
387           assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name), UNITS_PER_WORD, 1);
388         }
389       else
390         {
391           assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
392           assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
393         }
394
395       /* Output the file name changing the suffix to .d for Sun tcov
396          compatibility.  */
397       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 1);
398       {
399         int len = strlen (filename);
400         char *data_file = (char *) alloca (len + 3);
401         strcpy (data_file, filename);
402         strip_off_ending (data_file, len);
403         strcat (data_file, ".d");
404         assemble_string (data_file, strlen (data_file) + 1);
405       }
406
407       /* Make space for the table of counts.  */
408       if (flag_no_common || size == 0)
409         {
410           /* Realign data section.  */
411           ASM_OUTPUT_ALIGN (asm_out_file, align);
412           ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 2);
413           if (size != 0)
414             assemble_zeros (size);
415         }
416       else
417         {
418           ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 2);
419 #ifdef ASM_OUTPUT_SHARED_LOCAL
420           if (flag_shared_data)
421             ASM_OUTPUT_SHARED_LOCAL (asm_out_file, name, size, rounded);
422           else
423 #endif
424 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
425             ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size,
426                                       BIGGEST_ALIGNMENT);
427 #else
428             ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
429 #endif
430         }
431
432       /* Output any basic block strings */
433       readonly_data_section ();
434       if (sbb_head)
435         {
436           ASM_OUTPUT_ALIGN (asm_out_file, align);
437           for (sptr = sbb_head; sptr != 0; sptr = sptr->next)
438             {
439               ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBC", sptr->label_num);
440               assemble_string (sptr->string, sptr->length);
441             }
442         }
443
444       /* Output the table of addresses.  */
445       /* Realign in new section */
446       ASM_OUTPUT_ALIGN (asm_out_file, align);
447       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 3);
448       for (i = 0; i < count_basic_blocks; i++)
449         {
450           ASM_GENERATE_INTERNAL_LABEL (name, "LPB", i);
451           assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name),
452                             UNITS_PER_WORD, 1);
453         }
454
455       /* Output the table of function names.  */
456       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 4);
457       for ((ptr = bb_head), (i = 0); ptr != 0; (ptr = ptr->next), i++)
458         {
459           if (ptr->func_label_num >= 0)
460             {
461               ASM_GENERATE_INTERNAL_LABEL (name, "LPBC", ptr->func_label_num);
462               assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name),
463                                 UNITS_PER_WORD, 1);
464             }
465           else
466             assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
467         }
468
469       for ( ; i < count_basic_blocks; i++)
470         assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
471
472       if (write_symbols != NO_DEBUG)
473         {
474           /* Output the table of line numbers.  */
475           ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 5);
476           for ((ptr = bb_head), (i = 0); ptr != 0; (ptr = ptr->next), i++)
477             assemble_integer (GEN_INT (ptr->line_num), UNITS_PER_WORD, 1);
478
479           for ( ; i < count_basic_blocks; i++)
480             assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
481
482           /* Output the table of file names.  */
483           ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 6);
484           for ((ptr = bb_head), (i = 0); ptr != 0; (ptr = ptr->next), i++)
485             {
486               if (ptr->file_label_num >= 0)
487                 {
488                   ASM_GENERATE_INTERNAL_LABEL (name, "LPBC", ptr->file_label_num);
489                   assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name),
490                                     UNITS_PER_WORD, 1);
491                 }
492               else
493                 assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
494             }
495
496           for ( ; i < count_basic_blocks; i++)
497             assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
498         }
499
500       /* End with the address of the table of addresses,
501          so we can find it easily, as the last word in the file's text.  */
502       ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 3);
503       assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name), UNITS_PER_WORD, 1);
504     }
505 }
506
507 /* Enable APP processing of subsequent output.
508    Used before the output from an `asm' statement.  */
509
510 void
511 app_enable ()
512 {
513   if (! app_on)
514     {
515       fprintf (asm_out_file, ASM_APP_ON);
516       app_on = 1;
517     }
518 }
519
520 /* Enable APP processing of subsequent output.
521    Called from varasm.c before most kinds of output.  */
522
523 void
524 app_disable ()
525 {
526   if (app_on)
527     {
528       fprintf (asm_out_file, ASM_APP_OFF);
529       app_on = 0;
530     }
531 }
532 \f
533 /* Return the number of slots filled in the current 
534    delayed branch sequence (we don't count the insn needing the
535    delay slot).   Zero if not in a delayed branch sequence.  */
536
537 #ifdef DELAY_SLOTS
538 int
539 dbr_sequence_length ()
540 {
541   if (final_sequence != 0)
542     return XVECLEN (final_sequence, 0) - 1;
543   else
544     return 0;
545 }
546 #endif
547 \f
548 /* The next two pages contain routines used to compute the length of an insn
549    and to shorten branches.  */
550
551 /* Arrays for insn lengths, and addresses.  The latter is referenced by
552    `insn_current_length'.  */
553
554 static short *insn_lengths;
555 int *insn_addresses;
556
557 /* Address of insn being processed.  Used by `insn_current_length'.  */
558 int insn_current_address;
559
560 /* Indicate the branch shortening hasn't yet been done.  */
561
562 void
563 init_insn_lengths ()
564 {
565   insn_lengths = 0;
566 }
567
568 /* Obtain the current length of an insn.  If branch shortening has been done,
569    get its actual length.  Otherwise, get its maximum length.  */
570
571 int
572 get_attr_length (insn)
573      rtx insn;
574 {
575 #ifdef HAVE_ATTR_length
576   rtx body;
577   int i;
578   int length = 0;
579
580   if (insn_lengths)
581     return insn_lengths[INSN_UID (insn)];
582   else
583     switch (GET_CODE (insn))
584       {
585       case NOTE:
586       case BARRIER:
587       case CODE_LABEL:
588         return 0;
589
590       case CALL_INSN:
591         length = insn_default_length (insn);
592         break;
593
594       case JUMP_INSN:
595         body = PATTERN (insn);
596         if (GET_CODE (body) == ADDR_VEC || GET_CODE (body) == ADDR_DIFF_VEC)
597           {
598             /* This only takes room if jump tables go into the text section.  */
599 #if !defined(READONLY_DATA_SECTION) || defined(JUMP_TABLES_IN_TEXT_SECTION)
600             length = (XVECLEN (body, GET_CODE (body) == ADDR_DIFF_VEC)
601                       * GET_MODE_SIZE (GET_MODE (body)));
602
603             /* Be pessimistic and assume worst-case alignment.  */
604             length += (GET_MODE_SIZE (GET_MODE (body)) - 1);
605 #else
606             return 0;
607 #endif
608           }
609         else
610           length = insn_default_length (insn);
611         break;
612
613       case INSN:
614         body = PATTERN (insn);
615         if (GET_CODE (body) == USE || GET_CODE (body) == CLOBBER)
616           return 0;
617
618         else if (GET_CODE (body) == ASM_INPUT || asm_noperands (body) >= 0)
619           length = asm_insn_count (body) * insn_default_length (insn);
620         else if (GET_CODE (body) == SEQUENCE)
621           for (i = 0; i < XVECLEN (body, 0); i++)
622             length += get_attr_length (XVECEXP (body, 0, i));
623         else
624           length = insn_default_length (insn);
625       }
626
627 #ifdef ADJUST_INSN_LENGTH
628   ADJUST_INSN_LENGTH (insn, length);
629 #endif
630   return length;
631 #else /* not HAVE_ATTR_length */
632   return 0;
633 #endif /* not HAVE_ATTR_length */
634 }
635 \f
636 /* Make a pass over all insns and compute their actual lengths by shortening
637    any branches of variable length if possible.  */
638
639 /* Give a default value for the lowest address in a function.  */
640
641 #ifndef FIRST_INSN_ADDRESS
642 #define FIRST_INSN_ADDRESS 0
643 #endif
644
645 void
646 shorten_branches (first)
647      rtx first;
648 {
649 #ifdef HAVE_ATTR_length
650   rtx insn;
651   int something_changed = 1;
652   int max_uid = 0;
653   char *varying_length;
654   rtx body;
655   int uid;
656
657   /* Compute maximum UID and allocate arrays.  */
658   for (insn = first; insn; insn = NEXT_INSN (insn))
659     if (INSN_UID (insn) > max_uid)
660       max_uid = INSN_UID (insn);
661
662   max_uid++;
663   insn_lengths = (short *) oballoc (max_uid * sizeof (short));
664   insn_addresses = (int *) oballoc (max_uid * sizeof (int));
665   varying_length = (char *) oballoc (max_uid * sizeof (char));
666
667   /* Compute initial lengths, addresses, and varying flags for each insn.  */
668   for (insn_current_address = FIRST_INSN_ADDRESS, insn = first;
669        insn != 0;
670        insn_current_address += insn_lengths[uid], insn = NEXT_INSN (insn))
671     {
672       uid = INSN_UID (insn);
673       insn_addresses[uid] = insn_current_address;
674       insn_lengths[uid] = 0;
675       varying_length[uid] = 0;
676       
677       if (GET_CODE (insn) == NOTE || GET_CODE (insn) == BARRIER
678           || GET_CODE (insn) == CODE_LABEL)
679         continue;
680
681       body = PATTERN (insn);
682       if (GET_CODE (body) == ADDR_VEC || GET_CODE (body) == ADDR_DIFF_VEC)
683         {
684           /* This only takes room if read-only data goes into the text
685              section.  */
686 #if !defined(READONLY_DATA_SECTION) || defined(JUMP_TABLES_IN_TEXT_SECTION)
687           int unitsize = GET_MODE_SIZE (GET_MODE (body));
688
689           insn_lengths[uid] = (XVECLEN (body, GET_CODE (body) == ADDR_DIFF_VEC)
690                                * GET_MODE_SIZE (GET_MODE (body)));
691
692           /* Account for possible alignment.  */
693           insn_lengths[uid]
694             += unitsize - (insn_current_address & (unitsize - 1));
695 #else
696           ;
697 #endif
698         }
699       else if (asm_noperands (body) >= 0)
700         insn_lengths[uid] = asm_insn_count (body) * insn_default_length (insn);
701       else if (GET_CODE (body) == SEQUENCE)
702         {
703           int i;
704           int const_delay_slots;
705 #ifdef DELAY_SLOTS
706           const_delay_slots = const_num_delay_slots (XVECEXP (body, 0, 0));
707 #else
708           const_delay_slots = 0;
709 #endif
710           /* Inside a delay slot sequence, we do not do any branch shortening
711              if the shortening could change the number of delay slots
712              of the branch. */
713           for (i = 0; i < XVECLEN (body, 0); i++)
714             {
715               rtx inner_insn = XVECEXP (body, 0, i);
716               int inner_uid = INSN_UID (inner_insn);
717               int inner_length;
718
719               if (asm_noperands (PATTERN (XVECEXP (body, 0, i))) >= 0)
720                 inner_length = (asm_insn_count (PATTERN (inner_insn))
721                                 * insn_default_length (inner_insn));
722               else
723                 inner_length = insn_default_length (inner_insn);
724               
725               insn_lengths[inner_uid] = inner_length;
726               if (const_delay_slots)
727                 {
728                   if ((varying_length[inner_uid]
729                        = insn_variable_length_p (inner_insn)) != 0)
730                     varying_length[uid] = 1;
731                   insn_addresses[inner_uid] = (insn_current_address +
732                                                insn_lengths[uid]);
733                 }
734               else
735                 varying_length[inner_uid] = 0;
736               insn_lengths[uid] += inner_length;
737             }
738         }
739       else if (GET_CODE (body) != USE && GET_CODE (body) != CLOBBER)
740         {
741           insn_lengths[uid] = insn_default_length (insn);
742           varying_length[uid] = insn_variable_length_p (insn);
743         }
744
745       /* If needed, do any adjustment.  */
746 #ifdef ADJUST_INSN_LENGTH
747       ADJUST_INSN_LENGTH (insn, insn_lengths[uid]);
748 #endif
749     }
750
751   /* Now loop over all the insns finding varying length insns.  For each,
752      get the current insn length.  If it has changed, reflect the change.
753      When nothing changes for a full pass, we are done.  */
754
755   while (something_changed)
756     {
757       something_changed = 0;
758       for (insn_current_address = FIRST_INSN_ADDRESS, insn = first;
759            insn != 0;
760            insn = NEXT_INSN (insn))
761         {
762           int new_length;
763           int tmp_length;
764
765           uid = INSN_UID (insn);
766           insn_addresses[uid] = insn_current_address;
767           if (! varying_length[uid])
768             {
769               insn_current_address += insn_lengths[uid];
770               continue;
771             }
772           if (GET_CODE (insn) == INSN && GET_CODE (PATTERN (insn)) == SEQUENCE)
773             {
774               int i;
775               
776               body = PATTERN (insn);
777               new_length = 0;
778               for (i = 0; i < XVECLEN (body, 0); i++)
779                 {
780                   rtx inner_insn = XVECEXP (body, 0, i);
781                   int inner_uid = INSN_UID (inner_insn);
782                   int inner_length;
783
784                   insn_addresses[inner_uid] = insn_current_address;
785
786                   /* insn_current_length returns 0 for insns with a
787                      non-varying length.  */
788                   if (! varying_length[inner_uid])
789                     inner_length = insn_lengths[inner_uid];
790                   else
791                     inner_length = insn_current_length (inner_insn);
792
793                   if (inner_length != insn_lengths[inner_uid])
794                     {
795                       insn_lengths[inner_uid] = inner_length;
796                       something_changed = 1;
797                     }
798                   insn_current_address += insn_lengths[inner_uid];
799                   new_length += inner_length;
800                 }
801             }
802           else
803             {
804               new_length = insn_current_length (insn);
805               insn_current_address += new_length;
806             }
807
808 #ifdef SHORTEN_WITH_ADJUST_INSN_LENGTH
809 #ifdef ADJUST_INSN_LENGTH
810           /* If needed, do any adjustment.  */
811           tmp_length = new_length;
812           ADJUST_INSN_LENGTH (insn, new_length);
813           insn_current_address += (new_length - tmp_length);
814 #endif
815 #endif
816
817           if (new_length != insn_lengths[uid])
818             {
819               insn_lengths[uid] = new_length;
820               something_changed = 1;
821             }
822         }
823     }
824 #endif /* HAVE_ATTR_length */
825 }
826
827 #ifdef HAVE_ATTR_length
828 /* Given the body of an INSN known to be generated by an ASM statement, return
829    the number of machine instructions likely to be generated for this insn.
830    This is used to compute its length.  */
831
832 static int
833 asm_insn_count (body)
834      rtx body;
835 {
836   char *template;
837   int count = 1;
838
839   for (template = decode_asm_operands (body, NULL_PTR, NULL_PTR,
840                                        NULL_PTR, NULL_PTR);
841        *template; template++)
842     if (IS_ASM_LOGICAL_LINE_SEPARATOR(*template) || *template == '\n')
843       count++;
844
845   return count;
846 }
847 #endif
848 \f
849 /* Output assembler code for the start of a function,
850    and initialize some of the variables in this file
851    for the new function.  The label for the function and associated
852    assembler pseudo-ops have already been output in `assemble_start_function'.
853
854    FIRST is the first insn of the rtl for the function being compiled.
855    FILE is the file to write assembler code to.
856    OPTIMIZE is nonzero if we should eliminate redundant
857      test and compare insns.  */
858
859 void
860 final_start_function (first, file, optimize)
861      rtx first;
862      FILE *file;
863      int optimize;
864 {
865   block_depth = 0;
866
867   this_is_asm_operands = 0;
868
869 #ifdef NON_SAVING_SETJMP
870   /* A function that calls setjmp should save and restore all the
871      call-saved registers on a system where longjmp clobbers them.  */
872   if (NON_SAVING_SETJMP && current_function_calls_setjmp)
873     {
874       int i;
875
876       for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
877         if (!call_used_regs[i] && !call_fixed_regs[i])
878           regs_ever_live[i] = 1;
879     }
880 #endif
881   
882   /* Initial line number is supposed to be output
883      before the function's prologue and label
884      so that the function's address will not appear to be
885      in the last statement of the preceding function.  */
886   if (NOTE_LINE_NUMBER (first) != NOTE_INSN_DELETED)
887     {
888       if (write_symbols == SDB_DEBUG)
889         /* For sdb, let's not, but say we did.
890            We need to set last_linenum for sdbout_function_begin,
891            but we can't have an actual line number before the .bf symbol.
892            (sdb_begin_function_line is not set,
893            and other compilers don't do it.)  */
894         last_linenum = NOTE_LINE_NUMBER (first);
895 #ifdef XCOFF_DEBUGGING_INFO
896       else if (write_symbols == XCOFF_DEBUG)
897         {
898           last_linenum = NOTE_LINE_NUMBER (first);
899           xcoffout_output_first_source_line (file, last_linenum);
900         }
901 #endif    
902       else
903         output_source_line (file, first);
904     }
905
906 #ifdef LEAF_REG_REMAP
907   if (leaf_function)
908     leaf_renumber_regs (first);
909 #endif
910
911   /* The Sun386i and perhaps other machines don't work right
912      if the profiling code comes after the prologue.  */
913 #ifdef PROFILE_BEFORE_PROLOGUE
914   if (profile_flag)
915     profile_function (file);
916 #endif /* PROFILE_BEFORE_PROLOGUE */
917
918 #ifdef FUNCTION_PROLOGUE
919   /* First output the function prologue: code to set up the stack frame.  */
920   FUNCTION_PROLOGUE (file, get_frame_size ());
921 #endif
922
923 #if defined (SDB_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
924   if (write_symbols == SDB_DEBUG || write_symbols == XCOFF_DEBUG)
925     next_block_index = 1;
926 #endif
927
928   /* If the machine represents the prologue as RTL, the profiling code must
929      be emitted when NOTE_INSN_PROLOGUE_END is scanned.  */
930 #ifdef HAVE_prologue
931   if (! HAVE_prologue)
932 #endif
933     profile_after_prologue (file);
934
935   profile_label_no++;
936
937   /* If we are doing basic block profiling, remember a printable version
938      of the function name.  */
939   if (profile_block_flag)
940     {
941       char *junk = "function";
942       bb_func_label_num =
943         add_bb_string ((*decl_printable_name) (current_function_decl, &junk), FALSE);
944     }
945 }
946
947 static void
948 profile_after_prologue (file)
949      FILE *file;
950 {
951 #ifdef FUNCTION_BLOCK_PROFILER
952   if (profile_block_flag)
953     {
954       FUNCTION_BLOCK_PROFILER (file, profile_label_no);
955     }
956 #endif /* FUNCTION_BLOCK_PROFILER */
957
958 #ifndef PROFILE_BEFORE_PROLOGUE
959   if (profile_flag)
960     profile_function (file);
961 #endif /* not PROFILE_BEFORE_PROLOGUE */
962 }
963
964 void
965 profile_function (file)
966      FILE *file;
967 {
968   int align = MIN (BIGGEST_ALIGNMENT, BITS_PER_WORD);
969   int sval = current_function_returns_struct;
970   int cxt = current_function_needs_context;
971
972   data_section ();
973   ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT));
974   ASM_OUTPUT_INTERNAL_LABEL (file, "LP", profile_label_no);
975   assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
976
977   text_section ();
978
979 #ifdef STRUCT_VALUE_INCOMING_REGNUM
980   if (sval)
981     ASM_OUTPUT_REG_PUSH (file, STRUCT_VALUE_INCOMING_REGNUM);
982 #else
983 #ifdef STRUCT_VALUE_REGNUM
984   if (sval)
985     ASM_OUTPUT_REG_PUSH (file, STRUCT_VALUE_REGNUM);
986 #endif
987 #endif
988
989 #if 0
990 #ifdef STATIC_CHAIN_INCOMING_REGNUM
991   if (cxt)
992     ASM_OUTPUT_REG_PUSH (file, STATIC_CHAIN_INCOMING_REGNUM);
993 #else
994 #ifdef STATIC_CHAIN_REGNUM
995   if (cxt)
996     ASM_OUTPUT_REG_PUSH (file, STATIC_CHAIN_REGNUM);
997 #endif
998 #endif
999 #endif                          /* 0 */
1000
1001   FUNCTION_PROFILER (file, profile_label_no);
1002
1003 #if 0
1004 #ifdef STATIC_CHAIN_INCOMING_REGNUM
1005   if (cxt)
1006     ASM_OUTPUT_REG_POP (file, STATIC_CHAIN_INCOMING_REGNUM);
1007 #else
1008 #ifdef STATIC_CHAIN_REGNUM
1009   if (cxt)
1010     ASM_OUTPUT_REG_POP (file, STATIC_CHAIN_REGNUM);
1011 #endif
1012 #endif
1013 #endif                          /* 0 */
1014
1015 #ifdef STRUCT_VALUE_INCOMING_REGNUM
1016   if (sval)
1017     ASM_OUTPUT_REG_POP (file, STRUCT_VALUE_INCOMING_REGNUM);
1018 #else
1019 #ifdef STRUCT_VALUE_REGNUM
1020   if (sval)
1021     ASM_OUTPUT_REG_POP (file, STRUCT_VALUE_REGNUM);
1022 #endif
1023 #endif
1024 }
1025
1026 /* Output assembler code for the end of a function.
1027    For clarity, args are same as those of `final_start_function'
1028    even though not all of them are needed.  */
1029
1030 void
1031 final_end_function (first, file, optimize)
1032      rtx first;
1033      FILE *file;
1034      int optimize;
1035 {
1036   if (app_on)
1037     {
1038       fprintf (file, ASM_APP_OFF);
1039       app_on = 0;
1040     }
1041
1042 #ifdef SDB_DEBUGGING_INFO
1043   if (write_symbols == SDB_DEBUG)
1044     sdbout_end_function (last_linenum);
1045 #endif
1046
1047 #ifdef DWARF_DEBUGGING_INFO
1048   if (write_symbols == DWARF_DEBUG)
1049     dwarfout_end_function ();
1050 #endif
1051
1052 #ifdef XCOFF_DEBUGGING_INFO
1053   if (write_symbols == XCOFF_DEBUG)
1054     xcoffout_end_function (file, last_linenum);
1055 #endif
1056
1057 #ifdef FUNCTION_EPILOGUE
1058   /* Finally, output the function epilogue:
1059      code to restore the stack frame and return to the caller.  */
1060   FUNCTION_EPILOGUE (file, get_frame_size ());
1061 #endif
1062
1063 #ifdef SDB_DEBUGGING_INFO
1064   if (write_symbols == SDB_DEBUG)
1065     sdbout_end_epilogue ();
1066 #endif
1067
1068 #ifdef DWARF_DEBUGGING_INFO
1069   if (write_symbols == DWARF_DEBUG)
1070     dwarfout_end_epilogue ();
1071 #endif
1072
1073 #ifdef XCOFF_DEBUGGING_INFO
1074   if (write_symbols == XCOFF_DEBUG)
1075     xcoffout_end_epilogue (file);
1076 #endif
1077
1078   bb_func_label_num = -1;       /* not in function, nuke label # */
1079
1080   /* If FUNCTION_EPILOGUE is not defined, then the function body
1081      itself contains return instructions wherever needed.  */
1082 }
1083 \f
1084 /* Add a block to the linked list that remembers the current line/file/function
1085    for basic block profiling.  Emit the label in front of the basic block and
1086    the instructions that increment the count field.  */
1087
1088 static void
1089 add_bb (file)
1090      FILE *file;
1091 {
1092   struct bb_list *ptr = (struct bb_list *) permalloc (sizeof (struct bb_list));
1093
1094   /* Add basic block to linked list.  */
1095   ptr->next = 0;
1096   ptr->line_num = last_linenum;
1097   ptr->file_label_num = bb_file_label_num;
1098   ptr->func_label_num = bb_func_label_num;
1099   *bb_tail = ptr;
1100   bb_tail = &ptr->next;
1101
1102   /* Enable the table of basic-block use counts
1103      to point at the code it applies to.  */
1104   ASM_OUTPUT_INTERNAL_LABEL (file, "LPB", count_basic_blocks);
1105
1106   /* Before first insn of this basic block, increment the
1107      count of times it was entered.  */
1108 #ifdef BLOCK_PROFILER
1109   BLOCK_PROFILER (file, count_basic_blocks);
1110   CC_STATUS_INIT;
1111 #endif
1112
1113   new_block = 0;
1114   count_basic_blocks++;
1115 }
1116
1117 /* Add a string to be used for basic block profiling.  */
1118
1119 static int
1120 add_bb_string (string, perm_p)
1121      char *string;
1122      int perm_p;
1123 {
1124   int len;
1125   struct bb_str *ptr = 0;
1126
1127   if (!string)
1128     {
1129       string = "<unknown>";
1130       perm_p = TRUE;
1131     }
1132
1133   /* Allocate a new string if the current string isn't permanent.  If
1134      the string is permanent search for the same string in other
1135      allocations.  */
1136
1137   len = strlen (string) + 1;
1138   if (!perm_p)
1139     {
1140       char *p = (char *) permalloc (len);
1141       bcopy (string, p, len);
1142       string = p;
1143     }
1144   else
1145     for (ptr = sbb_head; ptr != (struct bb_str *)0; ptr = ptr->next)
1146       if (ptr->string == string)
1147         break;
1148
1149   /* Allocate a new string block if we need to.  */
1150   if (!ptr)
1151     {
1152       ptr = (struct bb_str *) permalloc (sizeof (*ptr));
1153       ptr->next = 0;
1154       ptr->length = len;
1155       ptr->label_num = sbb_label_num++;
1156       ptr->string = string;
1157       *sbb_tail = ptr;
1158       sbb_tail = &ptr->next;
1159     }
1160
1161   return ptr->label_num;
1162 }
1163
1164 \f
1165 /* Output assembler code for some insns: all or part of a function.
1166    For description of args, see `final_start_function', above.
1167
1168    PRESCAN is 1 if we are not really outputting,
1169      just scanning as if we were outputting.
1170    Prescanning deletes and rearranges insns just like ordinary output.
1171    PRESCAN is -2 if we are outputting after having prescanned.
1172    In this case, don't try to delete or rearrange insns
1173    because that has already been done.
1174    Prescanning is done only on certain machines.  */
1175
1176 void
1177 final (first, file, optimize, prescan)
1178      rtx first;
1179      FILE *file;
1180      int optimize;
1181      int prescan;
1182 {
1183   register rtx insn;
1184   int max_line = 0;
1185
1186   last_ignored_compare = 0;
1187   new_block = 1;
1188
1189   /* Make a map indicating which line numbers appear in this function.
1190      When producing SDB debugging info, delete troublesome line number
1191      notes from inlined functions in other files as well as duplicate
1192      line number notes.  */
1193 #ifdef SDB_DEBUGGING_INFO
1194   if (write_symbols == SDB_DEBUG)
1195     {
1196       rtx last = 0;
1197       for (insn = first; insn; insn = NEXT_INSN (insn))
1198         if (GET_CODE (insn) == NOTE && NOTE_LINE_NUMBER (insn) > 0)
1199           {
1200             if ((RTX_INTEGRATED_P (insn)
1201                  && strcmp (NOTE_SOURCE_FILE (insn), main_input_filename) != 0)
1202                  || (last != 0
1203                      && NOTE_LINE_NUMBER (insn) == NOTE_LINE_NUMBER (last)
1204                      && NOTE_SOURCE_FILE (insn) == NOTE_SOURCE_FILE (last)))
1205               {
1206                 NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
1207                 NOTE_SOURCE_FILE (insn) = 0;
1208                 continue;
1209               }
1210             last = insn;
1211             if (NOTE_LINE_NUMBER (insn) > max_line)
1212               max_line = NOTE_LINE_NUMBER (insn);
1213           }
1214     }
1215   else
1216 #endif
1217     {
1218       for (insn = first; insn; insn = NEXT_INSN (insn))
1219         if (GET_CODE (insn) == NOTE && NOTE_LINE_NUMBER (insn) > max_line)
1220           max_line = NOTE_LINE_NUMBER (insn);
1221     }
1222
1223   line_note_exists = (char *) oballoc (max_line + 1);
1224   bzero (line_note_exists, max_line + 1);
1225
1226   for (insn = first; insn; insn = NEXT_INSN (insn))
1227     if (GET_CODE (insn) == NOTE && NOTE_LINE_NUMBER (insn) > 0)
1228       line_note_exists[NOTE_LINE_NUMBER (insn)] = 1;
1229
1230   init_recog ();
1231
1232   CC_STATUS_INIT;
1233
1234   /* Output the insns.  */
1235   for (insn = NEXT_INSN (first); insn;)
1236     insn = final_scan_insn (insn, file, optimize, prescan, 0);
1237
1238   /* Do basic-block profiling here
1239      if the last insn was a conditional branch.  */
1240   if (profile_block_flag && new_block)
1241     add_bb (file);
1242 }
1243 \f
1244 /* The final scan for one insn, INSN.
1245    Args are same as in `final', except that INSN
1246    is the insn being scanned.
1247    Value returned is the next insn to be scanned.
1248
1249    NOPEEPHOLES is the flag to disallow peephole processing (currently
1250    used for within delayed branch sequence output).  */
1251
1252 rtx
1253 final_scan_insn (insn, file, optimize, prescan, nopeepholes)
1254      rtx insn;
1255      FILE *file;
1256      int optimize;
1257      int prescan;
1258      int nopeepholes;
1259 {
1260   register int i;
1261   insn_counter++;
1262
1263   /* Ignore deleted insns.  These can occur when we split insns (due to a
1264      template of "#") while not optimizing.  */
1265   if (INSN_DELETED_P (insn))
1266     return NEXT_INSN (insn);
1267
1268   switch (GET_CODE (insn))
1269     {
1270     case NOTE:
1271       if (prescan > 0)
1272         break;
1273
1274       /* Align the beginning of a loop, for higher speed
1275          on certain machines.  */
1276
1277       if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_BEG && optimize > 0)
1278         {
1279 #ifdef ASM_OUTPUT_LOOP_ALIGN
1280           rtx next = next_nonnote_insn (insn);
1281           if (next && GET_CODE (next) == CODE_LABEL)
1282             {
1283               ASM_OUTPUT_LOOP_ALIGN (asm_out_file);
1284             }
1285 #endif
1286           break;
1287         }
1288       if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_END)
1289         break;
1290
1291       if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_PROLOGUE_END)
1292         {
1293 #ifdef FUNCTION_END_PROLOGUE
1294           FUNCTION_END_PROLOGUE (file);
1295 #endif
1296           profile_after_prologue (file);
1297           break;
1298         }
1299
1300 #ifdef FUNCTION_BEGIN_EPILOGUE
1301       if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_EPILOGUE_BEG)
1302         {
1303           FUNCTION_BEGIN_EPILOGUE (file);
1304           break;
1305         }
1306 #endif
1307
1308       if (write_symbols == NO_DEBUG)
1309         break;
1310       if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_FUNCTION_BEG)
1311         {
1312 #ifdef SDB_DEBUGGING_INFO
1313           if (write_symbols == SDB_DEBUG)
1314             sdbout_begin_function (last_linenum);
1315 #endif
1316 #ifdef XCOFF_DEBUGGING_INFO
1317           if (write_symbols == XCOFF_DEBUG)
1318             xcoffout_begin_function (file, last_linenum);
1319 #endif
1320 #ifdef DWARF_DEBUGGING_INFO
1321           if (write_symbols == DWARF_DEBUG)
1322             dwarfout_begin_function ();
1323 #endif
1324           break;
1325         }
1326       if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_DELETED)
1327         break;                  /* An insn that was "deleted" */
1328       if (app_on)
1329         {
1330           fprintf (file, ASM_APP_OFF);
1331           app_on = 0;
1332         }
1333       if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_BEG
1334           && (debug_info_level == DINFO_LEVEL_NORMAL
1335               || debug_info_level == DINFO_LEVEL_VERBOSE
1336 #ifdef DWARF_DEBUGGING_INFO
1337               || write_symbols == DWARF_DEBUG
1338 #endif
1339              )
1340          )
1341         {
1342           /* Beginning of a symbol-block.  Assign it a sequence number
1343              and push the number onto the stack PENDING_BLOCKS.  */
1344
1345           if (block_depth == max_block_depth)
1346             {
1347               /* PENDING_BLOCKS is full; make it longer.  */
1348               max_block_depth *= 2;
1349               pending_blocks
1350                 = (int *) xrealloc (pending_blocks,
1351                                     max_block_depth * sizeof (int));
1352             }
1353           pending_blocks[block_depth++] = next_block_index;
1354
1355           /* Output debugging info about the symbol-block beginning.  */
1356
1357 #ifdef SDB_DEBUGGING_INFO
1358           if (write_symbols == SDB_DEBUG)
1359             sdbout_begin_block (file, last_linenum, next_block_index);
1360 #endif
1361 #ifdef XCOFF_DEBUGGING_INFO
1362           if (write_symbols == XCOFF_DEBUG)
1363             xcoffout_begin_block (file, last_linenum, next_block_index);
1364 #endif
1365 #ifdef DBX_DEBUGGING_INFO
1366           if (write_symbols == DBX_DEBUG)
1367             ASM_OUTPUT_INTERNAL_LABEL (file, "LBB", next_block_index);
1368 #endif
1369 #ifdef DWARF_DEBUGGING_INFO
1370           if (write_symbols == DWARF_DEBUG && block_depth > 1)
1371             dwarfout_begin_block (next_block_index);
1372 #endif
1373
1374           next_block_index++;
1375         }
1376       else if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_END
1377                && (debug_info_level == DINFO_LEVEL_NORMAL
1378                    || debug_info_level == DINFO_LEVEL_VERBOSE
1379 #ifdef DWARF_DEBUGGING_INFO
1380                    || write_symbols == DWARF_DEBUG
1381 #endif
1382                   )
1383               )
1384         {
1385           /* End of a symbol-block.  Pop its sequence number off
1386              PENDING_BLOCKS and output debugging info based on that.  */
1387
1388           --block_depth;
1389
1390 #ifdef XCOFF_DEBUGGING_INFO
1391           if (write_symbols == XCOFF_DEBUG && block_depth >= 0)
1392             xcoffout_end_block (file, last_linenum, pending_blocks[block_depth]);
1393 #endif
1394 #ifdef DBX_DEBUGGING_INFO
1395           if (write_symbols == DBX_DEBUG && block_depth >= 0)
1396             ASM_OUTPUT_INTERNAL_LABEL (file, "LBE",
1397                                        pending_blocks[block_depth]);
1398 #endif
1399 #ifdef SDB_DEBUGGING_INFO
1400           if (write_symbols == SDB_DEBUG && block_depth >= 0)
1401             sdbout_end_block (file, last_linenum);
1402 #endif
1403 #ifdef DWARF_DEBUGGING_INFO
1404           if (write_symbols == DWARF_DEBUG && block_depth >= 1)
1405             dwarfout_end_block (pending_blocks[block_depth]);
1406 #endif
1407         }
1408       else if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_DELETED_LABEL
1409                && (debug_info_level == DINFO_LEVEL_NORMAL
1410                    || debug_info_level == DINFO_LEVEL_VERBOSE))
1411         {
1412 #ifdef DWARF_DEBUGGING_INFO
1413           if (write_symbols == DWARF_DEBUG)
1414             dwarfout_label (insn);
1415 #endif
1416         }
1417       else if (NOTE_LINE_NUMBER (insn) > 0)
1418         /* This note is a line-number.  */
1419         {
1420           register rtx note;
1421
1422 #if 0 /* This is what we used to do.  */
1423           output_source_line (file, insn);
1424 #endif
1425           int note_after = 0;
1426
1427           /* If there is anything real after this note,
1428              output it.  If another line note follows, omit this one.  */
1429           for (note = NEXT_INSN (insn); note; note = NEXT_INSN (note))
1430             {
1431               if (GET_CODE (note) != NOTE && GET_CODE (note) != CODE_LABEL)
1432                 break;
1433               /* These types of notes can be significant
1434                  so make sure the preceding line number stays.  */
1435               else if (GET_CODE (note) == NOTE
1436                        && (NOTE_LINE_NUMBER (note) == NOTE_INSN_BLOCK_BEG
1437                            || NOTE_LINE_NUMBER (note) == NOTE_INSN_BLOCK_END
1438                            || NOTE_LINE_NUMBER (note) == NOTE_INSN_FUNCTION_BEG))
1439                 break;
1440               else if (GET_CODE (note) == NOTE && NOTE_LINE_NUMBER (note) > 0)
1441                 {
1442                   /* Another line note follows; we can delete this note
1443                      if no intervening line numbers have notes elsewhere.  */
1444                   int num;
1445                   for (num = NOTE_LINE_NUMBER (insn) + 1;
1446                        num < NOTE_LINE_NUMBER (note);
1447                        num++)
1448                     if (line_note_exists[num])
1449                       break;
1450
1451                   if (num >= NOTE_LINE_NUMBER (note))
1452                     note_after = 1;
1453                   break;
1454                 }
1455             }
1456
1457           /* Output this line note
1458              if it is the first or the last line note in a row.  */
1459           if (!note_after)
1460             output_source_line (file, insn);
1461         }
1462       break;
1463
1464     case BARRIER:
1465 #ifdef ASM_OUTPUT_ALIGN_CODE
1466       /* Don't litter the assembler output with needless alignments.  A
1467          BARRIER will be placed at the end of every function if HAVE_epilogue
1468          is true.  */    
1469       if (NEXT_INSN (insn))
1470         ASM_OUTPUT_ALIGN_CODE (file);
1471 #endif
1472       break;
1473
1474     case CODE_LABEL:
1475       CC_STATUS_INIT;
1476       if (prescan > 0)
1477         break;
1478       new_block = 1;
1479 #ifdef SDB_DEBUGGING_INFO
1480       if (write_symbols == SDB_DEBUG && LABEL_NAME (insn))
1481         sdbout_label (insn);
1482 #endif
1483 #ifdef DWARF_DEBUGGING_INFO
1484       if (write_symbols == DWARF_DEBUG && LABEL_NAME (insn))
1485         dwarfout_label (insn);
1486 #endif
1487       if (app_on)
1488         {
1489           fprintf (file, ASM_APP_OFF);
1490           app_on = 0;
1491         }
1492       if (NEXT_INSN (insn) != 0
1493           && GET_CODE (NEXT_INSN (insn)) == JUMP_INSN)
1494         {
1495           rtx nextbody = PATTERN (NEXT_INSN (insn));
1496
1497           /* If this label is followed by a jump-table,
1498              make sure we put the label in the read-only section.  Also
1499              possibly write the label and jump table together.  */
1500
1501           if (GET_CODE (nextbody) == ADDR_VEC
1502               || GET_CODE (nextbody) == ADDR_DIFF_VEC)
1503             {
1504 #ifndef JUMP_TABLES_IN_TEXT_SECTION
1505               readonly_data_section ();
1506 #ifdef READONLY_DATA_SECTION
1507               ASM_OUTPUT_ALIGN (file,
1508                                 exact_log2 (BIGGEST_ALIGNMENT
1509                                             / BITS_PER_UNIT));
1510 #endif /* READONLY_DATA_SECTION */
1511 #else /* JUMP_TABLES_IN_TEXT_SECTION */
1512               text_section ();
1513 #endif /* JUMP_TABLES_IN_TEXT_SECTION */
1514 #ifdef ASM_OUTPUT_CASE_LABEL
1515               ASM_OUTPUT_CASE_LABEL (file, "L", CODE_LABEL_NUMBER (insn),
1516                                      NEXT_INSN (insn));
1517 #else
1518               ASM_OUTPUT_INTERNAL_LABEL (file, "L", CODE_LABEL_NUMBER (insn));
1519 #endif
1520               break;
1521             }
1522         }
1523
1524       ASM_OUTPUT_INTERNAL_LABEL (file, "L", CODE_LABEL_NUMBER (insn));
1525       break;
1526
1527     default:
1528       {
1529         register rtx body = PATTERN (insn);
1530         int insn_code_number;
1531         char *template;
1532         rtx note;
1533
1534         /* An INSN, JUMP_INSN or CALL_INSN.
1535            First check for special kinds that recog doesn't recognize.  */
1536
1537         if (GET_CODE (body) == USE /* These are just declarations */
1538             || GET_CODE (body) == CLOBBER)
1539           break;
1540
1541 #ifdef HAVE_cc0
1542         /* If there is a REG_CC_SETTER note on this insn, it means that
1543            the setting of the condition code was done in the delay slot
1544            of the insn that branched here.  So recover the cc status
1545            from the insn that set it.  */
1546
1547         note = find_reg_note (insn, REG_CC_SETTER, NULL_RTX);
1548         if (note)
1549           {
1550             NOTICE_UPDATE_CC (PATTERN (XEXP (note, 0)), XEXP (note, 0));
1551             cc_prev_status = cc_status;
1552           }
1553 #endif
1554
1555         /* Detect insns that are really jump-tables
1556            and output them as such.  */
1557
1558         if (GET_CODE (body) == ADDR_VEC || GET_CODE (body) == ADDR_DIFF_VEC)
1559           {
1560             register int vlen, idx;
1561
1562             if (prescan > 0)
1563               break;
1564
1565             if (app_on)
1566               {
1567                 fprintf (file, ASM_APP_OFF);
1568                 app_on = 0;
1569               }
1570
1571             vlen = XVECLEN (body, GET_CODE (body) == ADDR_DIFF_VEC);
1572             for (idx = 0; idx < vlen; idx++)
1573               {
1574                 if (GET_CODE (body) == ADDR_VEC)
1575                   {
1576 #ifdef ASM_OUTPUT_ADDR_VEC_ELT
1577                     ASM_OUTPUT_ADDR_VEC_ELT
1578                       (file, CODE_LABEL_NUMBER (XEXP (XVECEXP (body, 0, idx), 0)));
1579 #else
1580                     abort ();
1581 #endif
1582                   }
1583                 else
1584                   {
1585 #ifdef ASM_OUTPUT_ADDR_DIFF_ELT
1586                     ASM_OUTPUT_ADDR_DIFF_ELT
1587                       (file,
1588                        CODE_LABEL_NUMBER (XEXP (XVECEXP (body, 1, idx), 0)),
1589                        CODE_LABEL_NUMBER (XEXP (XEXP (body, 0), 0)));
1590 #else
1591                     abort ();
1592 #endif
1593                   }
1594               }
1595 #ifdef ASM_OUTPUT_CASE_END
1596             ASM_OUTPUT_CASE_END (file,
1597                                  CODE_LABEL_NUMBER (PREV_INSN (insn)),
1598                                  insn);
1599 #endif
1600
1601             text_section ();
1602
1603             break;
1604           }
1605
1606         /* Do basic-block profiling when we reach a new block.
1607            Done here to avoid jump tables.  */
1608         if (profile_block_flag && new_block)
1609           add_bb (file);
1610
1611         if (GET_CODE (body) == ASM_INPUT)
1612           {
1613             /* There's no telling what that did to the condition codes.  */
1614             CC_STATUS_INIT;
1615             if (prescan > 0)
1616               break;
1617             if (! app_on)
1618               {
1619                 fprintf (file, ASM_APP_ON);
1620                 app_on = 1;
1621               }
1622             fprintf (asm_out_file, "\t%s\n", XSTR (body, 0));
1623             break;
1624           }
1625
1626         /* Detect `asm' construct with operands.  */
1627         if (asm_noperands (body) >= 0)
1628           {
1629             int noperands = asm_noperands (body);
1630             rtx *ops = (rtx *) alloca (noperands * sizeof (rtx));
1631             char *string;
1632
1633             /* There's no telling what that did to the condition codes.  */
1634             CC_STATUS_INIT;
1635             if (prescan > 0)
1636               break;
1637
1638             if (! app_on)
1639               {
1640                 fprintf (file, ASM_APP_ON);
1641                 app_on = 1;
1642               }
1643
1644             /* Get out the operand values.  */
1645             string = decode_asm_operands (body, ops, NULL_PTR,
1646                                           NULL_PTR, NULL_PTR);
1647             /* Inhibit aborts on what would otherwise be compiler bugs.  */
1648             insn_noperands = noperands;
1649             this_is_asm_operands = insn;
1650
1651             /* Output the insn using them.  */
1652             output_asm_insn (string, ops);
1653             this_is_asm_operands = 0;
1654             break;
1655           }
1656
1657         if (prescan <= 0 && app_on)
1658           {
1659             fprintf (file, ASM_APP_OFF);
1660             app_on = 0;
1661           }
1662
1663         if (GET_CODE (body) == SEQUENCE)
1664           {
1665             /* A delayed-branch sequence */
1666             register int i;
1667             rtx next;
1668
1669             if (prescan > 0)
1670               break;
1671             final_sequence = body;
1672
1673             /* The first insn in this SEQUENCE might be a JUMP_INSN that will
1674                force the restoration of a comparison that was previously
1675                thought unnecessary.  If that happens, cancel this sequence
1676                and cause that insn to be restored.  */
1677
1678             next = final_scan_insn (XVECEXP (body, 0, 0), file, 0, prescan, 1);
1679             if (next != XVECEXP (body, 0, 1))
1680               {
1681                 final_sequence = 0;
1682                 return next;
1683               }
1684
1685             for (i = 1; i < XVECLEN (body, 0); i++)
1686               final_scan_insn (XVECEXP (body, 0, i), file, 0, prescan, 1);
1687 #ifdef DBR_OUTPUT_SEQEND
1688             DBR_OUTPUT_SEQEND (file);
1689 #endif
1690             final_sequence = 0;
1691
1692             /* If the insn requiring the delay slot was a CALL_INSN, the
1693                insns in the delay slot are actually executed before the
1694                called function.  Hence we don't preserve any CC-setting
1695                actions in these insns and the CC must be marked as being
1696                clobbered by the function.  */
1697             if (GET_CODE (XVECEXP (body, 0, 0)) == CALL_INSN)
1698               CC_STATUS_INIT;
1699
1700             /* Following a conditional branch sequence, we have a new basic
1701                block.  */
1702             if (profile_block_flag)
1703               {
1704                 rtx insn = XVECEXP (body, 0, 0);
1705                 rtx body = PATTERN (insn);
1706
1707                 if ((GET_CODE (insn) == JUMP_INSN && GET_CODE (body) == SET
1708                      && GET_CODE (SET_SRC (body)) != LABEL_REF)
1709                     || (GET_CODE (insn) == JUMP_INSN
1710                         && GET_CODE (body) == PARALLEL
1711                         && GET_CODE (XVECEXP (body, 0, 0)) == SET
1712                         && GET_CODE (SET_SRC (XVECEXP (body, 0, 0))) != LABEL_REF))
1713                   new_block = 1;
1714               }
1715             break;
1716           }
1717
1718         /* We have a real machine instruction as rtl.  */
1719
1720         body = PATTERN (insn);
1721
1722 #ifdef HAVE_cc0
1723         /* Check for redundant test and compare instructions
1724            (when the condition codes are already set up as desired).
1725            This is done only when optimizing; if not optimizing,
1726            it should be possible for the user to alter a variable
1727            with the debugger in between statements
1728            and the next statement should reexamine the variable
1729            to compute the condition codes.  */
1730
1731         if (optimize
1732             && GET_CODE (body) == SET
1733             && GET_CODE (SET_DEST (body)) == CC0
1734             && insn != last_ignored_compare)
1735           {
1736             if (GET_CODE (SET_SRC (body)) == SUBREG)
1737               SET_SRC (body) = alter_subreg (SET_SRC (body));
1738             else if (GET_CODE (SET_SRC (body)) == COMPARE)
1739               {
1740                 if (GET_CODE (XEXP (SET_SRC (body), 0)) == SUBREG)
1741                   XEXP (SET_SRC (body), 0)
1742                     = alter_subreg (XEXP (SET_SRC (body), 0));
1743                 if (GET_CODE (XEXP (SET_SRC (body), 1)) == SUBREG)
1744                   XEXP (SET_SRC (body), 1)
1745                     = alter_subreg (XEXP (SET_SRC (body), 1));
1746               }
1747             if ((cc_status.value1 != 0
1748                  && rtx_equal_p (SET_SRC (body), cc_status.value1))
1749                 || (cc_status.value2 != 0
1750                     && rtx_equal_p (SET_SRC (body), cc_status.value2)))
1751               {
1752                 /* Don't delete insn if it has an addressing side-effect.  */
1753                 if (! FIND_REG_INC_NOTE (insn, 0)
1754                     /* or if anything in it is volatile.  */
1755                     && ! volatile_refs_p (PATTERN (insn)))
1756                   {
1757                     /* We don't really delete the insn; just ignore it.  */
1758                     last_ignored_compare = insn;
1759                     break;
1760                   }
1761               }
1762           }
1763 #endif
1764
1765         /* Following a conditional branch, we have a new basic block.
1766            But if we are inside a sequence, the new block starts after the
1767            last insn of the sequence.  */
1768         if (profile_block_flag && final_sequence == 0
1769             && ((GET_CODE (insn) == JUMP_INSN && GET_CODE (body) == SET
1770                  && GET_CODE (SET_SRC (body)) != LABEL_REF)
1771                 || (GET_CODE (insn) == JUMP_INSN && GET_CODE (body) == PARALLEL
1772                     && GET_CODE (XVECEXP (body, 0, 0)) == SET
1773                     && GET_CODE (SET_SRC (XVECEXP (body, 0, 0))) != LABEL_REF)))
1774           new_block = 1;
1775
1776 #ifndef STACK_REGS
1777         /* Don't bother outputting obvious no-ops, even without -O.
1778            This optimization is fast and doesn't interfere with debugging.
1779            Don't do this if the insn is in a delay slot, since this
1780            will cause an improper number of delay insns to be written.  */
1781         if (final_sequence == 0
1782             && prescan >= 0
1783             && GET_CODE (insn) == INSN && GET_CODE (body) == SET
1784             && GET_CODE (SET_SRC (body)) == REG
1785             && GET_CODE (SET_DEST (body)) == REG
1786             && REGNO (SET_SRC (body)) == REGNO (SET_DEST (body)))
1787           break;
1788 #endif
1789
1790 #ifdef HAVE_cc0
1791         /* If this is a conditional branch, maybe modify it
1792            if the cc's are in a nonstandard state
1793            so that it accomplishes the same thing that it would
1794            do straightforwardly if the cc's were set up normally.  */
1795
1796         if (cc_status.flags != 0
1797             && GET_CODE (insn) == JUMP_INSN
1798             && GET_CODE (body) == SET
1799             && SET_DEST (body) == pc_rtx
1800             && GET_CODE (SET_SRC (body)) == IF_THEN_ELSE
1801             /* This is done during prescan; it is not done again
1802                in final scan when prescan has been done.  */
1803             && prescan >= 0)
1804           {
1805             /* This function may alter the contents of its argument
1806                and clear some of the cc_status.flags bits.
1807                It may also return 1 meaning condition now always true
1808                or -1 meaning condition now always false
1809                or 2 meaning condition nontrivial but altered.  */
1810             register int result = alter_cond (XEXP (SET_SRC (body), 0));
1811             /* If condition now has fixed value, replace the IF_THEN_ELSE
1812                with its then-operand or its else-operand.  */
1813             if (result == 1)
1814               SET_SRC (body) = XEXP (SET_SRC (body), 1);
1815             if (result == -1)
1816               SET_SRC (body) = XEXP (SET_SRC (body), 2);
1817
1818             /* The jump is now either unconditional or a no-op.
1819                If it has become a no-op, don't try to output it.
1820                (It would not be recognized.)  */
1821             if (SET_SRC (body) == pc_rtx)
1822               {
1823                 PUT_CODE (insn, NOTE);
1824                 NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
1825                 NOTE_SOURCE_FILE (insn) = 0;
1826                 break;
1827               }
1828             else if (GET_CODE (SET_SRC (body)) == RETURN)
1829               /* Replace (set (pc) (return)) with (return).  */
1830               PATTERN (insn) = body = SET_SRC (body);
1831
1832             /* Rerecognize the instruction if it has changed.  */
1833             if (result != 0)
1834               INSN_CODE (insn) = -1;
1835           }
1836
1837         /* Make same adjustments to instructions that examine the
1838            condition codes without jumping (if this machine has them).  */
1839
1840         if (cc_status.flags != 0
1841             && GET_CODE (body) == SET)
1842           {
1843             switch (GET_CODE (SET_SRC (body)))
1844               {
1845               case GTU:
1846               case GT:
1847               case LTU:
1848               case LT:
1849               case GEU:
1850               case GE:
1851               case LEU:
1852               case LE:
1853               case EQ:
1854               case NE:
1855                 {
1856                   register int result;
1857                   if (XEXP (SET_SRC (body), 0) != cc0_rtx)
1858                     break;
1859                   result = alter_cond (SET_SRC (body));
1860                   if (result == 1)
1861                     validate_change (insn, &SET_SRC (body), const_true_rtx, 0);
1862                   else if (result == -1)
1863                     validate_change (insn, &SET_SRC (body), const0_rtx, 0);
1864                   else if (result == 2)
1865                     INSN_CODE (insn) = -1;
1866                 }
1867               }
1868           }
1869 #endif
1870
1871         /* Do machine-specific peephole optimizations if desired.  */
1872
1873         if (optimize && !flag_no_peephole && !nopeepholes)
1874           {
1875             rtx next = peephole (insn);
1876             /* When peepholing, if there were notes within the peephole,
1877                emit them before the peephole.  */
1878             if (next != 0 && next != NEXT_INSN (insn))
1879               {
1880                 rtx prev = PREV_INSN (insn);
1881                 rtx note;
1882
1883                 for (note = NEXT_INSN (insn); note != next;
1884                      note = NEXT_INSN (note))
1885                   final_scan_insn (note, file, optimize, prescan, nopeepholes);
1886
1887                 /* In case this is prescan, put the notes
1888                    in proper position for later rescan.  */
1889                 note = NEXT_INSN (insn);
1890                 PREV_INSN (note) = prev;
1891                 NEXT_INSN (prev) = note;
1892                 NEXT_INSN (PREV_INSN (next)) = insn;
1893                 PREV_INSN (insn) = PREV_INSN (next);
1894                 NEXT_INSN (insn) = next;
1895                 PREV_INSN (next) = insn;
1896               }
1897
1898             /* PEEPHOLE might have changed this.  */
1899             body = PATTERN (insn);
1900           }
1901
1902         /* Try to recognize the instruction.
1903            If successful, verify that the operands satisfy the
1904            constraints for the instruction.  Crash if they don't,
1905            since `reload' should have changed them so that they do.  */
1906
1907         insn_code_number = recog_memoized (insn);
1908         insn_extract (insn);
1909         for (i = 0; i < insn_n_operands[insn_code_number]; i++)
1910           {
1911             if (GET_CODE (recog_operand[i]) == SUBREG)
1912               recog_operand[i] = alter_subreg (recog_operand[i]);
1913             else if (GET_CODE (recog_operand[i]) == PLUS
1914                      || GET_CODE (recog_operand[i]) == MULT)
1915               recog_operand[i] = walk_alter_subreg (recog_operand[i]);
1916           }
1917
1918         for (i = 0; i < insn_n_dups[insn_code_number]; i++)
1919           {
1920             if (GET_CODE (*recog_dup_loc[i]) == SUBREG)
1921               *recog_dup_loc[i] = alter_subreg (*recog_dup_loc[i]);
1922             else if (GET_CODE (*recog_dup_loc[i]) == PLUS
1923                      || GET_CODE (*recog_dup_loc[i]) == MULT)
1924               *recog_dup_loc[i] = walk_alter_subreg (*recog_dup_loc[i]);
1925           }
1926
1927 #ifdef REGISTER_CONSTRAINTS
1928         if (! constrain_operands (insn_code_number, 1))
1929           fatal_insn_not_found (insn);
1930 #endif
1931
1932         /* Some target machines need to prescan each insn before
1933            it is output.  */
1934
1935 #ifdef FINAL_PRESCAN_INSN
1936         FINAL_PRESCAN_INSN (insn, recog_operand,
1937                             insn_n_operands[insn_code_number]);
1938 #endif
1939
1940 #ifdef HAVE_cc0
1941         cc_prev_status = cc_status;
1942
1943         /* Update `cc_status' for this instruction.
1944            The instruction's output routine may change it further.
1945            If the output routine for a jump insn needs to depend
1946            on the cc status, it should look at cc_prev_status.  */
1947
1948         NOTICE_UPDATE_CC (body, insn);
1949 #endif
1950
1951         debug_insn = insn;
1952
1953         /* If the proper template needs to be chosen by some C code,
1954            run that code and get the real template.  */
1955
1956         template = insn_template[insn_code_number];
1957         if (template == 0)
1958           {
1959             template = (*insn_outfun[insn_code_number]) (recog_operand, insn);
1960
1961             /* If the C code returns 0, it means that it is a jump insn
1962                which follows a deleted test insn, and that test insn
1963                needs to be reinserted.  */
1964             if (template == 0)
1965               {
1966                 if (prev_nonnote_insn (insn) != last_ignored_compare)
1967                   abort ();
1968                 new_block = 0;
1969                 return prev_nonnote_insn (insn);
1970               }
1971           }
1972
1973         /* If the template is the string "#", it means that this insn must
1974            be split.  */
1975         if (template[0] == '#' && template[1] == '\0')
1976           {
1977             rtx new = try_split (body, insn, 0);
1978
1979             /* If we didn't split the insn, go away.  */
1980             if (new == insn && PATTERN (new) == body)
1981               abort ();
1982               
1983             new_block = 0;
1984             return new;
1985           }
1986         
1987         if (prescan > 0)
1988           break;
1989
1990         /* Output assembler code from the template.  */
1991
1992         output_asm_insn (template, recog_operand);
1993
1994 #if 0
1995         /* It's not at all clear why we did this and doing so interferes
1996            with tests we'd like to do to use REG_WAS_0 notes, so let's try
1997            with this out.  */
1998
1999         /* Mark this insn as having been output.  */
2000         INSN_DELETED_P (insn) = 1;
2001 #endif
2002
2003         debug_insn = 0;
2004       }
2005     }
2006   return NEXT_INSN (insn);
2007 }
2008 \f
2009 /* Output debugging info to the assembler file FILE
2010    based on the NOTE-insn INSN, assumed to be a line number.  */
2011
2012 static void
2013 output_source_line (file, insn)
2014      FILE *file;
2015      rtx insn;
2016 {
2017   register char *filename = NOTE_SOURCE_FILE (insn);
2018
2019   /* Remember filename for basic block profiling.
2020      Filenames are allocated on the permanent obstack
2021      or are passed in ARGV, so we don't have to save
2022      the string.  */
2023
2024   if (profile_block_flag && last_filename != filename)
2025     bb_file_label_num = add_bb_string (filename, TRUE);
2026
2027   last_filename = filename;
2028   last_linenum = NOTE_LINE_NUMBER (insn);
2029
2030   if (write_symbols != NO_DEBUG)
2031     {
2032 #ifdef SDB_DEBUGGING_INFO
2033       if (write_symbols == SDB_DEBUG
2034 #if 0 /* People like having line numbers even in wrong file!  */
2035           /* COFF can't handle multiple source files--lose, lose.  */
2036           && !strcmp (filename, main_input_filename)
2037 #endif
2038           /* COFF relative line numbers must be positive.  */
2039           && last_linenum > sdb_begin_function_line)
2040         {
2041 #ifdef ASM_OUTPUT_SOURCE_LINE
2042           ASM_OUTPUT_SOURCE_LINE (file, last_linenum);
2043 #else
2044           fprintf (file, "\t.ln\t%d\n",
2045                    ((sdb_begin_function_line > -1)
2046                     ? last_linenum - sdb_begin_function_line : 1));
2047 #endif
2048         }
2049 #endif
2050
2051 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
2052       if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
2053         dbxout_source_line (file, filename, NOTE_LINE_NUMBER (insn));
2054 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
2055
2056 #ifdef DWARF_DEBUGGING_INFO
2057       if (write_symbols == DWARF_DEBUG)
2058         dwarfout_line (filename, NOTE_LINE_NUMBER (insn));
2059 #endif
2060     }
2061 }
2062 \f
2063 /* If X is a SUBREG, replace it with a REG or a MEM,
2064    based on the thing it is a subreg of.  */
2065
2066 rtx
2067 alter_subreg (x)
2068      register rtx x;
2069 {
2070   register rtx y = SUBREG_REG (x);
2071   if (GET_CODE (y) == SUBREG)
2072     y = alter_subreg (y);
2073
2074   if (GET_CODE (y) == REG)
2075     {
2076       /* If the containing reg really gets a hard reg, so do we.  */
2077       PUT_CODE (x, REG);
2078       REGNO (x) = REGNO (y) + SUBREG_WORD (x);
2079     }
2080   else if (GET_CODE (y) == MEM)
2081     {
2082       register int offset = SUBREG_WORD (x) * UNITS_PER_WORD;
2083 #if BYTES_BIG_ENDIAN
2084       offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x)))
2085                  - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (y))));
2086 #endif
2087       PUT_CODE (x, MEM);
2088       MEM_VOLATILE_P (x) = MEM_VOLATILE_P (y);
2089       XEXP (x, 0) = plus_constant (XEXP (y, 0), offset);
2090     }
2091
2092   return x;
2093 }
2094
2095 /* Do alter_subreg on all the SUBREGs contained in X.  */
2096
2097 static rtx
2098 walk_alter_subreg (x)
2099      rtx x;
2100 {
2101   switch (GET_CODE (x))
2102     {
2103     case PLUS:
2104     case MULT:
2105       XEXP (x, 0) = walk_alter_subreg (XEXP (x, 0));
2106       XEXP (x, 1) = walk_alter_subreg (XEXP (x, 1));
2107       break;
2108
2109     case MEM:
2110       XEXP (x, 0) = walk_alter_subreg (XEXP (x, 0));
2111       break;
2112
2113     case SUBREG:
2114       return alter_subreg (x);
2115     }
2116
2117   return x;
2118 }
2119 \f
2120 #ifdef HAVE_cc0
2121
2122 /* Given BODY, the body of a jump instruction, alter the jump condition
2123    as required by the bits that are set in cc_status.flags.
2124    Not all of the bits there can be handled at this level in all cases.
2125
2126    The value is normally 0.
2127    1 means that the condition has become always true.
2128    -1 means that the condition has become always false.
2129    2 means that COND has been altered.  */
2130
2131 static int
2132 alter_cond (cond)
2133      register rtx cond;
2134 {
2135   int value = 0;
2136
2137   if (cc_status.flags & CC_REVERSED)
2138     {
2139       value = 2;
2140       PUT_CODE (cond, swap_condition (GET_CODE (cond)));
2141     }
2142
2143   if (cc_status.flags & CC_INVERTED)
2144     {
2145       value = 2;
2146       PUT_CODE (cond, reverse_condition (GET_CODE (cond)));
2147     }
2148
2149   if (cc_status.flags & CC_NOT_POSITIVE)
2150     switch (GET_CODE (cond))
2151       {
2152       case LE:
2153       case LEU:
2154       case GEU:
2155         /* Jump becomes unconditional.  */
2156         return 1;
2157
2158       case GT:
2159       case GTU:
2160       case LTU:
2161         /* Jump becomes no-op.  */
2162         return -1;
2163
2164       case GE:
2165         PUT_CODE (cond, EQ);
2166         value = 2;
2167         break;
2168
2169       case LT:
2170         PUT_CODE (cond, NE);
2171         value = 2;
2172         break;
2173       }
2174
2175   if (cc_status.flags & CC_NOT_NEGATIVE)
2176     switch (GET_CODE (cond))
2177       {
2178       case GE:
2179       case GEU:
2180         /* Jump becomes unconditional.  */
2181         return 1;
2182
2183       case LT:
2184       case LTU:
2185         /* Jump becomes no-op.  */
2186         return -1;
2187
2188       case LE:
2189       case LEU:
2190         PUT_CODE (cond, EQ);
2191         value = 2;
2192         break;
2193
2194       case GT:
2195       case GTU:
2196         PUT_CODE (cond, NE);
2197         value = 2;
2198         break;
2199       }
2200
2201   if (cc_status.flags & CC_NO_OVERFLOW)
2202     switch (GET_CODE (cond))
2203       {
2204       case GEU:
2205         /* Jump becomes unconditional.  */
2206         return 1;
2207
2208       case LEU:
2209         PUT_CODE (cond, EQ);
2210         value = 2;
2211         break;
2212
2213       case GTU:
2214         PUT_CODE (cond, NE);
2215         value = 2;
2216         break;
2217
2218       case LTU:
2219         /* Jump becomes no-op.  */
2220         return -1;
2221       }
2222
2223   if (cc_status.flags & (CC_Z_IN_NOT_N | CC_Z_IN_N))
2224     switch (GET_CODE (cond))
2225       {
2226       case LE:
2227       case LEU:
2228       case GE:
2229       case GEU:
2230       case LT:
2231       case LTU:
2232       case GT:
2233       case GTU:
2234         abort ();
2235
2236       case NE:
2237         PUT_CODE (cond, cc_status.flags & CC_Z_IN_N ? GE : LT);
2238         value = 2;
2239         break;
2240
2241       case EQ:
2242         PUT_CODE (cond, cc_status.flags & CC_Z_IN_N ? LT : GE);
2243         value = 2;
2244         break;
2245       }
2246
2247   if (cc_status.flags & CC_NOT_SIGNED)
2248     /* The flags are valid if signed condition operators are converted
2249        to unsigned.  */
2250     switch (GET_CODE (cond))
2251       {
2252       case LE:
2253         PUT_CODE (cond, LEU);
2254         value = 2;
2255         break;
2256
2257       case LT:
2258         PUT_CODE (cond, LTU);
2259         value = 2;
2260         break;
2261
2262       case GT:
2263         PUT_CODE (cond, GTU);
2264         value = 2;
2265         break;
2266
2267       case GE:
2268         PUT_CODE (cond, GEU);
2269         value = 2;
2270         break;
2271       }
2272
2273   return value;
2274 }
2275 #endif
2276 \f
2277 /* Report inconsistency between the assembler template and the operands.
2278    In an `asm', it's the user's fault; otherwise, the compiler's fault.  */
2279
2280 void
2281 output_operand_lossage (str)
2282      char *str;
2283 {
2284   if (this_is_asm_operands)
2285     error_for_asm (this_is_asm_operands, "invalid `asm': %s", str);
2286   else
2287     abort ();
2288 }
2289 \f
2290 /* Output of assembler code from a template, and its subroutines.  */
2291
2292 /* Output text from TEMPLATE to the assembler output file,
2293    obeying %-directions to substitute operands taken from
2294    the vector OPERANDS.
2295
2296    %N (for N a digit) means print operand N in usual manner.
2297    %lN means require operand N to be a CODE_LABEL or LABEL_REF
2298       and print the label name with no punctuation.
2299    %cN means require operand N to be a constant
2300       and print the constant expression with no punctuation.
2301    %aN means expect operand N to be a memory address
2302       (not a memory reference!) and print a reference
2303       to that address.
2304    %nN means expect operand N to be a constant
2305       and print a constant expression for minus the value
2306       of the operand, with no other punctuation.  */
2307
2308 void
2309 output_asm_insn (template, operands)
2310      char *template;
2311      rtx *operands;
2312 {
2313   register char *p;
2314   register int c, i;
2315
2316   /* An insn may return a null string template
2317      in a case where no assembler code is needed.  */
2318   if (*template == 0)
2319     return;
2320
2321   p = template;
2322   putc ('\t', asm_out_file);
2323
2324 #ifdef ASM_OUTPUT_OPCODE
2325   ASM_OUTPUT_OPCODE (asm_out_file, p);
2326 #endif
2327
2328   while (c = *p++)
2329     switch (c)
2330       {
2331 #ifdef ASM_OUTPUT_OPCODE
2332       case '\n':
2333         putc (c, asm_out_file);
2334         while ((c = *p) == '\t')
2335           {
2336             putc (c, asm_out_file);
2337             p++;
2338           }
2339         ASM_OUTPUT_OPCODE (asm_out_file, p);
2340         break;
2341 #endif
2342
2343 #ifdef ASSEMBLER_DIALECT
2344       case '{':
2345         /* If we want the first dialect, do nothing.  Otherwise, skip
2346            DIALECT_NUMBER of strings ending with '|'.  */
2347         for (i = 0; i < dialect_number; i++)
2348           {
2349             while (*p && *p++ != '|')
2350               ;
2351
2352             if (*p == '|')
2353               p++;
2354           }
2355         break;
2356
2357       case '|':
2358         /* Skip to close brace.  */
2359         while (*p && *p++ != '}')
2360           ;
2361         break;
2362
2363       case '}':
2364         break;
2365 #endif
2366
2367       case '%':
2368         /* %% outputs a single %.  */
2369         if (*p == '%')
2370           {
2371             p++;
2372             putc (c, asm_out_file);
2373           }
2374         /* %= outputs a number which is unique to each insn in the entire
2375            compilation.  This is useful for making local labels that are
2376            referred to more than once in a given insn.  */
2377         else if (*p == '=')
2378           {
2379             p++;
2380             fprintf (asm_out_file, "%d", insn_counter);
2381           }
2382         /* % followed by a letter and some digits
2383            outputs an operand in a special way depending on the letter.
2384            Letters `acln' are implemented directly.
2385            Other letters are passed to `output_operand' so that
2386            the PRINT_OPERAND macro can define them.  */
2387         else if ((*p >= 'a' && *p <= 'z')
2388                  || (*p >= 'A' && *p <= 'Z'))
2389           {
2390             int letter = *p++;
2391             c = atoi (p);
2392
2393             if (! (*p >= '0' && *p <= '9'))
2394               output_operand_lossage ("operand number missing after %-letter");
2395             else if (this_is_asm_operands && c >= (unsigned) insn_noperands)
2396               output_operand_lossage ("operand number out of range");
2397             else if (letter == 'l')
2398               output_asm_label (operands[c]);
2399             else if (letter == 'a')
2400               output_address (operands[c]);
2401             else if (letter == 'c')
2402               {
2403                 if (CONSTANT_ADDRESS_P (operands[c]))
2404                   output_addr_const (asm_out_file, operands[c]);
2405                 else
2406                   output_operand (operands[c], 'c');
2407               }
2408             else if (letter == 'n')
2409               {
2410                 if (GET_CODE (operands[c]) == CONST_INT)
2411                   fprintf (asm_out_file,
2412 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
2413                            "%d",
2414 #else
2415                            "%ld",
2416 #endif
2417                            - INTVAL (operands[c]));
2418                 else
2419                   {
2420                     putc ('-', asm_out_file);
2421                     output_addr_const (asm_out_file, operands[c]);
2422                   }
2423               }
2424             else
2425               output_operand (operands[c], letter);
2426             
2427             while ((c = *p) >= '0' && c <= '9') p++;
2428           }
2429         /* % followed by a digit outputs an operand the default way.  */
2430         else if (*p >= '0' && *p <= '9')
2431           {
2432             c = atoi (p);
2433             if (this_is_asm_operands && c >= (unsigned) insn_noperands)
2434               output_operand_lossage ("operand number out of range");
2435             else
2436               output_operand (operands[c], 0);
2437             while ((c = *p) >= '0' && c <= '9') p++;
2438           }
2439         /* % followed by punctuation: output something for that
2440            punctuation character alone, with no operand.
2441            The PRINT_OPERAND macro decides what is actually done.  */
2442 #ifdef PRINT_OPERAND_PUNCT_VALID_P
2443         else if (PRINT_OPERAND_PUNCT_VALID_P (*p))
2444           output_operand (NULL_RTX, *p++);
2445 #endif
2446         else
2447           output_operand_lossage ("invalid %%-code");
2448         break;
2449
2450       default:
2451         putc (c, asm_out_file);
2452       }
2453
2454   if (flag_print_asm_name)
2455     {
2456       /* Annotate the assembly with a comment describing the pattern and
2457          alternative used.  */
2458       if (debug_insn)
2459         {
2460           register int num = INSN_CODE (debug_insn);
2461           fprintf (asm_out_file, " %s %d %s", 
2462                    ASM_COMMENT_START, INSN_UID (debug_insn), insn_name[num]);
2463           if (insn_n_alternatives[num] > 1)
2464             fprintf (asm_out_file, "/%d", which_alternative + 1);
2465
2466           /* Clear this so only the first assembler insn
2467              of any rtl insn will get the special comment for -dp.  */
2468           debug_insn = 0;
2469         }
2470     }
2471
2472   putc ('\n', asm_out_file);
2473 }
2474 \f
2475 /* Output a LABEL_REF, or a bare CODE_LABEL, as an assembler symbol.  */
2476
2477 void
2478 output_asm_label (x)
2479      rtx x;
2480 {
2481   char buf[256];
2482
2483   if (GET_CODE (x) == LABEL_REF)
2484     ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (XEXP (x, 0)));
2485   else if (GET_CODE (x) == CODE_LABEL)
2486     ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (x));
2487   else
2488     output_operand_lossage ("`%l' operand isn't a label");
2489
2490   assemble_name (asm_out_file, buf);
2491 }
2492
2493 /* Print operand X using machine-dependent assembler syntax.
2494    The macro PRINT_OPERAND is defined just to control this function.
2495    CODE is a non-digit that preceded the operand-number in the % spec,
2496    such as 'z' if the spec was `%z3'.  CODE is 0 if there was no char
2497    between the % and the digits.
2498    When CODE is a non-letter, X is 0.
2499
2500    The meanings of the letters are machine-dependent and controlled
2501    by PRINT_OPERAND.  */
2502
2503 static void
2504 output_operand (x, code)
2505      rtx x;
2506      int code;
2507 {
2508   if (x && GET_CODE (x) == SUBREG)
2509     x = alter_subreg (x);
2510
2511   /* If X is a pseudo-register, abort now rather than writing trash to the
2512      assembler file.  */
2513
2514   if (x && GET_CODE (x) == REG && REGNO (x) >= FIRST_PSEUDO_REGISTER)
2515     abort ();
2516
2517   PRINT_OPERAND (asm_out_file, x, code);
2518 }
2519
2520 /* Print a memory reference operand for address X
2521    using machine-dependent assembler syntax.
2522    The macro PRINT_OPERAND_ADDRESS exists just to control this function.  */
2523
2524 void
2525 output_address (x)
2526      rtx x;
2527 {
2528   walk_alter_subreg (x);
2529   PRINT_OPERAND_ADDRESS (asm_out_file, x);
2530 }
2531 \f
2532 /* Print an integer constant expression in assembler syntax.
2533    Addition and subtraction are the only arithmetic
2534    that may appear in these expressions.  */
2535
2536 void
2537 output_addr_const (file, x)
2538      FILE *file;
2539      rtx x;
2540 {
2541   char buf[256];
2542
2543  restart:
2544   switch (GET_CODE (x))
2545     {
2546     case PC:
2547       if (flag_pic)
2548         putc ('.', file);
2549       else
2550         abort ();
2551       break;
2552
2553     case SYMBOL_REF:
2554       assemble_name (file, XSTR (x, 0));
2555       break;
2556
2557     case LABEL_REF:
2558       ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (XEXP (x, 0)));
2559       assemble_name (file, buf);
2560       break;
2561
2562     case CODE_LABEL:
2563       ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (x));
2564       assemble_name (file, buf);
2565       break;
2566
2567     case CONST_INT:
2568       fprintf (file,
2569 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
2570                "%d",
2571 #else
2572                "%ld",
2573 #endif
2574                INTVAL (x));
2575       break;
2576
2577     case CONST:
2578       /* This used to output parentheses around the expression,
2579          but that does not work on the 386 (either ATT or BSD assembler).  */
2580       output_addr_const (file, XEXP (x, 0));
2581       break;
2582
2583     case CONST_DOUBLE:
2584       if (GET_MODE (x) == VOIDmode)
2585         {
2586           /* We can use %d if the number is one word and positive.  */
2587           if (CONST_DOUBLE_HIGH (x))
2588             fprintf (file,
2589 #if HOST_BITS_PER_WIDE_INT == 64
2590 #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
2591                      "0x%lx%016lx",
2592 #else
2593                      "0x%x%016x",
2594 #endif
2595 #else
2596 #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
2597                      "0x%lx%08lx",
2598 #else
2599                      "0x%x%08x",
2600 #endif
2601 #endif
2602                      CONST_DOUBLE_HIGH (x), CONST_DOUBLE_LOW (x));
2603           else if  (CONST_DOUBLE_LOW (x) < 0)
2604             fprintf (file,
2605 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
2606                      "0x%x",
2607 #else
2608                      "0x%lx",
2609 #endif
2610                      CONST_DOUBLE_LOW (x));
2611           else
2612             fprintf (file,
2613 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
2614                      "%d",
2615 #else
2616                      "%ld",
2617 #endif
2618                      CONST_DOUBLE_LOW (x));
2619         }
2620       else
2621         /* We can't handle floating point constants;
2622            PRINT_OPERAND must handle them.  */
2623         output_operand_lossage ("floating constant misused");
2624       break;
2625
2626     case PLUS:
2627       /* Some assemblers need integer constants to appear last (eg masm).  */
2628       if (GET_CODE (XEXP (x, 0)) == CONST_INT)
2629         {
2630           output_addr_const (file, XEXP (x, 1));
2631           if (INTVAL (XEXP (x, 0)) >= 0)
2632             fprintf (file, "+");
2633           output_addr_const (file, XEXP (x, 0));
2634         }
2635       else
2636         {
2637           output_addr_const (file, XEXP (x, 0));
2638           if (INTVAL (XEXP (x, 1)) >= 0)
2639             fprintf (file, "+");
2640           output_addr_const (file, XEXP (x, 1));
2641         }
2642       break;
2643
2644     case MINUS:
2645       /* Avoid outputting things like x-x or x+5-x,
2646          since some assemblers can't handle that.  */
2647       x = simplify_subtraction (x);
2648       if (GET_CODE (x) != MINUS)
2649         goto restart;
2650
2651       output_addr_const (file, XEXP (x, 0));
2652       fprintf (file, "-");
2653       if (GET_CODE (XEXP (x, 1)) == CONST_INT
2654           && INTVAL (XEXP (x, 1)) < 0)
2655         {
2656           fprintf (file, ASM_OPEN_PAREN);
2657           output_addr_const (file, XEXP (x, 1));
2658           fprintf (file, ASM_CLOSE_PAREN);
2659         }
2660       else
2661         output_addr_const (file, XEXP (x, 1));
2662       break;
2663
2664     case ZERO_EXTEND:
2665     case SIGN_EXTEND:
2666       output_addr_const (file, XEXP (x, 0));
2667       break;
2668
2669     default:
2670       output_operand_lossage ("invalid expression as operand");
2671     }
2672 }
2673 \f
2674 /* A poor man's fprintf, with the added features of %I, %R, %L, and %U.
2675    %R prints the value of REGISTER_PREFIX.
2676    %L prints the value of LOCAL_LABEL_PREFIX.
2677    %U prints the value of USER_LABEL_PREFIX.
2678    %I prints the value of IMMEDIATE_PREFIX.
2679    %O runs ASM_OUTPUT_OPCODE to transform what follows in the string.
2680    Also supported are %d, %x, %s, %e, %f, %g and %%.
2681
2682    We handle alternate assembler dialects here, just like output_asm_insn.  */
2683
2684 void
2685 asm_fprintf VPROTO((FILE *file, char *p, ...))
2686 {
2687 #ifndef __STDC__
2688   FILE *file;
2689   char *p;
2690 #endif
2691   va_list argptr;
2692   char buf[10];
2693   char *q, c;
2694   int i;
2695
2696   VA_START (argptr, p);
2697
2698 #ifndef __STDC__
2699   file = va_arg (argptr, FILE*);
2700   p = va_arg (argptr, char*);
2701 #endif
2702
2703   buf[0] = '%';
2704
2705   while (c = *p++)
2706     switch (c)
2707       {
2708 #ifdef ASSEMBLER_DIALECT
2709       case '{':
2710         /* If we want the first dialect, do nothing.  Otherwise, skip
2711            DIALECT_NUMBER of strings ending with '|'.  */
2712         for (i = 0; i < dialect_number; i++)
2713           {
2714             while (*p && *p++ != '|')
2715               ;
2716
2717             if (*p == '|')
2718               p++;
2719           }
2720         break;
2721
2722       case '|':
2723         /* Skip to close brace.  */
2724         while (*p && *p++ != '}')
2725           ;
2726         break;
2727
2728       case '}':
2729         break;
2730 #endif
2731
2732       case '%':
2733         c = *p++;
2734         q = &buf[1];
2735         while ((c >= '0' && c <= '9') || c == '.')
2736           {
2737             *q++ = c;
2738             c = *p++;
2739           }
2740         switch (c)
2741           {
2742           case '%':
2743             fprintf (file, "%%");
2744             break;
2745
2746           case 'd':  case 'i':  case 'u':
2747           case 'x':  case 'p':  case 'X':
2748           case 'o':
2749             *q++ = c;
2750             *q = 0;
2751             fprintf (file, buf, va_arg (argptr, int));
2752             break;
2753
2754           case 'w':
2755             /* This is a prefix to the 'd', 'i', 'u', 'x', 'p', and 'X' cases,
2756                but we do not check for those cases.  It means that the value
2757                is a HOST_WIDE_INT, which may be either `int' or `long'.  */
2758
2759 #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
2760             *q++ = 'l';
2761 #endif
2762
2763             *q++ = *p++;
2764             *q = 0;
2765             fprintf (file, buf, va_arg (argptr, HOST_WIDE_INT));
2766             break;
2767
2768           case 'l':
2769             *q++ = c;
2770             *q++ = *p++;
2771             *q = 0;
2772             fprintf (file, buf, va_arg (argptr, long));
2773             break;
2774
2775           case 'e':
2776           case 'f':
2777           case 'g':
2778             *q++ = c;
2779             *q = 0;
2780             fprintf (file, buf, va_arg (argptr, double));
2781             break;
2782
2783           case 's':
2784             *q++ = c;
2785             *q = 0;
2786             fprintf (file, buf, va_arg (argptr, char *));
2787             break;
2788
2789           case 'O':
2790 #ifdef ASM_OUTPUT_OPCODE
2791             ASM_OUTPUT_OPCODE (asm_out_file, p);
2792 #endif
2793             break;
2794
2795           case 'R':
2796 #ifdef REGISTER_PREFIX
2797             fprintf (file, "%s", REGISTER_PREFIX);
2798 #endif
2799             break;
2800
2801           case 'I':
2802 #ifdef IMMEDIATE_PREFIX
2803             fprintf (file, "%s", IMMEDIATE_PREFIX);
2804 #endif
2805             break;
2806
2807           case 'L':
2808 #ifdef LOCAL_LABEL_PREFIX
2809             fprintf (file, "%s", LOCAL_LABEL_PREFIX);
2810 #endif
2811             break;
2812
2813           case 'U':
2814 #ifdef USER_LABEL_PREFIX
2815             fprintf (file, "%s", USER_LABEL_PREFIX);
2816 #endif
2817             break;
2818
2819           default:
2820             abort ();
2821           }
2822         break;
2823
2824       default:
2825         fputc (c, file);
2826       }
2827 }
2828 \f
2829 /* Split up a CONST_DOUBLE or integer constant rtx
2830    into two rtx's for single words,
2831    storing in *FIRST the word that comes first in memory in the target
2832    and in *SECOND the other.  */
2833
2834 void
2835 split_double (value, first, second)
2836      rtx value;
2837      rtx *first, *second;
2838 {
2839   if (GET_CODE (value) == CONST_INT)
2840     {
2841       /* The rule for using CONST_INT for a wider mode
2842          is that we regard the value as signed.
2843          So sign-extend it.  */
2844       rtx high = (INTVAL (value) < 0 ? constm1_rtx : const0_rtx);
2845 #if WORDS_BIG_ENDIAN
2846       *first = high;
2847       *second = value;
2848 #else
2849       *first = value;
2850       *second = high;
2851 #endif
2852     }
2853   else if (GET_CODE (value) != CONST_DOUBLE)
2854     {
2855 #if WORDS_BIG_ENDIAN
2856       *first = const0_rtx;
2857       *second = value;
2858 #else
2859       *first = value;
2860       *second = const0_rtx;
2861 #endif
2862     }
2863   else if (GET_MODE (value) == VOIDmode
2864            /* This is the old way we did CONST_DOUBLE integers.  */
2865            || GET_MODE_CLASS (GET_MODE (value)) == MODE_INT)
2866     {
2867       /* In an integer, the words are defined as most and least significant.
2868          So order them by the target's convention.  */
2869 #if WORDS_BIG_ENDIAN
2870       *first = GEN_INT (CONST_DOUBLE_HIGH (value));
2871       *second = GEN_INT (CONST_DOUBLE_LOW (value));
2872 #else
2873       *first = GEN_INT (CONST_DOUBLE_LOW (value));
2874       *second = GEN_INT (CONST_DOUBLE_HIGH (value));
2875 #endif
2876     }
2877   else
2878     {
2879 #ifdef REAL_ARITHMETIC
2880       REAL_VALUE_TYPE r; HOST_WIDE_INT l[2];
2881       REAL_VALUE_FROM_CONST_DOUBLE (r, value);
2882       REAL_VALUE_TO_TARGET_DOUBLE (r, l);
2883       *first = GEN_INT (l[0]);
2884       *second = GEN_INT (l[1]);
2885 #else
2886       if ((HOST_FLOAT_FORMAT != TARGET_FLOAT_FORMAT
2887            || HOST_BITS_PER_WIDE_INT != BITS_PER_WORD)
2888           && ! flag_pretend_float)
2889       abort ();
2890
2891 #if defined (HOST_WORDS_BIG_ENDIAN) == WORDS_BIG_ENDIAN
2892       /* Host and target agree => no need to swap.  */
2893       *first = GEN_INT (CONST_DOUBLE_LOW (value));
2894       *second = GEN_INT (CONST_DOUBLE_HIGH (value));
2895 #else
2896       *second = GEN_INT (CONST_DOUBLE_LOW (value));
2897       *first = GEN_INT (CONST_DOUBLE_HIGH (value));
2898 #endif
2899 #endif /* no REAL_ARITHMETIC */
2900     }
2901 }
2902 \f
2903 /* Return nonzero if this function has no function calls.  */
2904
2905 int
2906 leaf_function_p ()
2907 {
2908   rtx insn;
2909
2910   if (profile_flag || profile_block_flag)
2911     return 0;
2912
2913   for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
2914     {
2915       if (GET_CODE (insn) == CALL_INSN)
2916         return 0;
2917       if (GET_CODE (insn) == INSN
2918           && GET_CODE (PATTERN (insn)) == SEQUENCE
2919           && GET_CODE (XVECEXP (PATTERN (insn), 0, 0)) == CALL_INSN)
2920         return 0;
2921     }
2922   for (insn = current_function_epilogue_delay_list; insn; insn = XEXP (insn, 1))
2923     {
2924       if (GET_CODE (XEXP (insn, 0)) == CALL_INSN)
2925         return 0;
2926       if (GET_CODE (XEXP (insn, 0)) == INSN
2927           && GET_CODE (PATTERN (XEXP (insn, 0))) == SEQUENCE
2928           && GET_CODE (XVECEXP (PATTERN (XEXP (insn, 0)), 0, 0)) == CALL_INSN)
2929         return 0;
2930     }
2931
2932   return 1;
2933 }
2934
2935 /* On some machines, a function with no call insns
2936    can run faster if it doesn't create its own register window.
2937    When output, the leaf function should use only the "output"
2938    registers.  Ordinarily, the function would be compiled to use
2939    the "input" registers to find its arguments; it is a candidate
2940    for leaf treatment if it uses only the "input" registers.
2941    Leaf function treatment means renumbering so the function
2942    uses the "output" registers instead.  */
2943
2944 #ifdef LEAF_REGISTERS
2945
2946 static char permitted_reg_in_leaf_functions[] = LEAF_REGISTERS;
2947
2948 /* Return 1 if this function uses only the registers that can be
2949    safely renumbered.  */
2950
2951 int
2952 only_leaf_regs_used ()
2953 {
2954   int i;
2955
2956   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
2957     {
2958       if ((regs_ever_live[i] || global_regs[i])
2959           && ! permitted_reg_in_leaf_functions[i])
2960         return 0;
2961     }
2962   return 1;
2963 }
2964
2965 /* Scan all instructions and renumber all registers into those
2966    available in leaf functions.  */
2967
2968 static void
2969 leaf_renumber_regs (first)
2970      rtx first;
2971 {
2972   rtx insn;
2973
2974   /* Renumber only the actual patterns.
2975      The reg-notes can contain frame pointer refs,
2976      and renumbering them could crash, and should not be needed.  */
2977   for (insn = first; insn; insn = NEXT_INSN (insn))
2978     if (GET_RTX_CLASS (GET_CODE (insn)) == 'i')
2979       leaf_renumber_regs_insn (PATTERN (insn));
2980   for (insn = current_function_epilogue_delay_list; insn; insn = XEXP (insn, 1))
2981     if (GET_RTX_CLASS (GET_CODE (XEXP (insn, 0))) == 'i')
2982       leaf_renumber_regs_insn (PATTERN (XEXP (insn, 0)));
2983 }
2984
2985 /* Scan IN_RTX and its subexpressions, and renumber all regs into those
2986    available in leaf functions.  */
2987
2988 void
2989 leaf_renumber_regs_insn (in_rtx)
2990      register rtx in_rtx;
2991 {
2992   register int i, j;
2993   register char *format_ptr;
2994
2995   if (in_rtx == 0)
2996     return;
2997
2998   /* Renumber all input-registers into output-registers.
2999      renumbered_regs would be 1 for an output-register;
3000      they  */
3001
3002   if (GET_CODE (in_rtx) == REG)
3003     {
3004       int newreg;
3005
3006       /* Don't renumber the same reg twice.  */
3007       if (in_rtx->used)
3008         return;
3009
3010       newreg = REGNO (in_rtx);
3011       /* Don't try to renumber pseudo regs.  It is possible for a pseudo reg
3012          to reach here as part of a REG_NOTE.  */
3013       if (newreg >= FIRST_PSEUDO_REGISTER)
3014         {
3015           in_rtx->used = 1;
3016           return;
3017         }
3018       newreg = LEAF_REG_REMAP (newreg);
3019       if (newreg < 0)
3020         abort ();
3021       regs_ever_live[REGNO (in_rtx)] = 0;
3022       regs_ever_live[newreg] = 1;
3023       REGNO (in_rtx) = newreg;
3024       in_rtx->used = 1;
3025     }
3026
3027   if (GET_RTX_CLASS (GET_CODE (in_rtx)) == 'i')
3028     {
3029       /* Inside a SEQUENCE, we find insns.
3030          Renumber just the patterns of these insns,
3031          just as we do for the top-level insns.  */
3032       leaf_renumber_regs_insn (PATTERN (in_rtx));
3033       return;
3034     }
3035
3036   format_ptr = GET_RTX_FORMAT (GET_CODE (in_rtx));
3037
3038   for (i = 0; i < GET_RTX_LENGTH (GET_CODE (in_rtx)); i++)
3039     switch (*format_ptr++)
3040       {
3041       case 'e':
3042         leaf_renumber_regs_insn (XEXP (in_rtx, i));
3043         break;
3044
3045       case 'E':
3046         if (NULL != XVEC (in_rtx, i))
3047           {
3048             for (j = 0; j < XVECLEN (in_rtx, i); j++)
3049               leaf_renumber_regs_insn (XVECEXP (in_rtx, i, j));
3050           }
3051         break;
3052
3053       case 'S':
3054       case 's':
3055       case '0':
3056       case 'i':
3057       case 'w':
3058       case 'n':
3059       case 'u':
3060         break;
3061
3062       default:
3063         abort ();
3064       }
3065 }
3066 #endif