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