]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/final.c
arc-protos.h (arc_select_cc_mode, gen_compare_reg): Wrap in RTX_CODE macro guard.
[thirdparty/gcc.git] / gcc / final.c
1 /* Convert RTL to assembler code and output it, for GNU compiler.
2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
4 Free Software Foundation, Inc.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
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 in assembler by the target functions function_prologue and
45 function_epilogue. Those instructions never exist as rtl. */
46
47 #include "config.h"
48 #include "system.h"
49 #include "coretypes.h"
50 #include "tm.h"
51
52 #include "tree.h"
53 #include "rtl.h"
54 #include "tm_p.h"
55 #include "regs.h"
56 #include "insn-config.h"
57 #include "insn-attr.h"
58 #include "recog.h"
59 #include "conditions.h"
60 #include "flags.h"
61 #include "real.h"
62 #include "hard-reg-set.h"
63 #include "output.h"
64 #include "except.h"
65 #include "function.h"
66 #include "toplev.h"
67 #include "reload.h"
68 #include "intl.h"
69 #include "basic-block.h"
70 #include "target.h"
71 #include "debug.h"
72 #include "expr.h"
73 #include "cfglayout.h"
74 #include "tree-pass.h"
75 #include "timevar.h"
76 #include "cgraph.h"
77 #include "coverage.h"
78 #include "df.h"
79 #include "vecprim.h"
80 #include "ggc.h"
81
82 #ifdef XCOFF_DEBUGGING_INFO
83 #include "xcoffout.h" /* Needed for external data
84 declarations for e.g. AIX 4.x. */
85 #endif
86
87 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
88 #include "dwarf2out.h"
89 #endif
90
91 #ifdef DBX_DEBUGGING_INFO
92 #include "dbxout.h"
93 #endif
94
95 #ifdef SDB_DEBUGGING_INFO
96 #include "sdbout.h"
97 #endif
98
99 /* If we aren't using cc0, CC_STATUS_INIT shouldn't exist. So define a
100 null default for it to save conditionalization later. */
101 #ifndef CC_STATUS_INIT
102 #define CC_STATUS_INIT
103 #endif
104
105 /* How to start an assembler comment. */
106 #ifndef ASM_COMMENT_START
107 #define ASM_COMMENT_START ";#"
108 #endif
109
110 /* Is the given character a logical line separator for the assembler? */
111 #ifndef IS_ASM_LOGICAL_LINE_SEPARATOR
112 #define IS_ASM_LOGICAL_LINE_SEPARATOR(C) ((C) == ';')
113 #endif
114
115 #ifndef JUMP_TABLES_IN_TEXT_SECTION
116 #define JUMP_TABLES_IN_TEXT_SECTION 0
117 #endif
118
119 /* Bitflags used by final_scan_insn. */
120 #define SEEN_BB 1
121 #define SEEN_NOTE 2
122 #define SEEN_EMITTED 4
123
124 /* Last insn processed by final_scan_insn. */
125 static rtx debug_insn;
126 rtx current_output_insn;
127
128 /* Line number of last NOTE. */
129 static int last_linenum;
130
131 /* Highest line number in current block. */
132 static int high_block_linenum;
133
134 /* Likewise for function. */
135 static int high_function_linenum;
136
137 /* Filename of last NOTE. */
138 static const char *last_filename;
139
140 /* Whether to force emission of a line note before the next insn. */
141 static bool force_source_line = false;
142
143 extern const int length_unit_log; /* This is defined in insn-attrtab.c. */
144
145 /* Nonzero while outputting an `asm' with operands.
146 This means that inconsistencies are the user's fault, so don't die.
147 The precise value is the insn being output, to pass to error_for_asm. */
148 rtx this_is_asm_operands;
149
150 /* Number of operands of this insn, for an `asm' with operands. */
151 static unsigned int insn_noperands;
152
153 /* Compare optimization flag. */
154
155 static rtx last_ignored_compare = 0;
156
157 /* Assign a unique number to each insn that is output.
158 This can be used to generate unique local labels. */
159
160 static int insn_counter = 0;
161
162 #ifdef HAVE_cc0
163 /* This variable contains machine-dependent flags (defined in tm.h)
164 set and examined by output routines
165 that describe how to interpret the condition codes properly. */
166
167 CC_STATUS cc_status;
168
169 /* During output of an insn, this contains a copy of cc_status
170 from before the insn. */
171
172 CC_STATUS cc_prev_status;
173 #endif
174
175 /* Nonzero means current function must be given a frame pointer.
176 Initialized in function.c to 0. Set only in reload1.c as per
177 the needs of the function. */
178
179 int frame_pointer_needed;
180
181 /* Number of unmatched NOTE_INSN_BLOCK_BEG notes we have seen. */
182
183 static int block_depth;
184
185 /* Nonzero if have enabled APP processing of our assembler output. */
186
187 static int app_on;
188
189 /* If we are outputting an insn sequence, this contains the sequence rtx.
190 Zero otherwise. */
191
192 rtx final_sequence;
193
194 #ifdef ASSEMBLER_DIALECT
195
196 /* Number of the assembler dialect to use, starting at 0. */
197 static int dialect_number;
198 #endif
199
200 #ifdef HAVE_conditional_execution
201 /* Nonnull if the insn currently being emitted was a COND_EXEC pattern. */
202 rtx current_insn_predicate;
203 #endif
204
205 #ifdef HAVE_ATTR_length
206 static int asm_insn_count (rtx);
207 #endif
208 static void profile_function (FILE *);
209 static void profile_after_prologue (FILE *);
210 static bool notice_source_line (rtx);
211 static rtx walk_alter_subreg (rtx *, bool *);
212 static void output_asm_name (void);
213 static void output_alternate_entry_point (FILE *, rtx);
214 static tree get_mem_expr_from_op (rtx, int *);
215 static void output_asm_operand_names (rtx *, int *, int);
216 static void output_operand (rtx, int);
217 #ifdef LEAF_REGISTERS
218 static void leaf_renumber_regs (rtx);
219 #endif
220 #ifdef HAVE_cc0
221 static int alter_cond (rtx);
222 #endif
223 #ifndef ADDR_VEC_ALIGN
224 static int final_addr_vec_align (rtx);
225 #endif
226 #ifdef HAVE_ATTR_length
227 static int align_fuzz (rtx, rtx, int, unsigned);
228 #endif
229 \f
230 /* Initialize data in final at the beginning of a compilation. */
231
232 void
233 init_final (const char *filename ATTRIBUTE_UNUSED)
234 {
235 app_on = 0;
236 final_sequence = 0;
237
238 #ifdef ASSEMBLER_DIALECT
239 dialect_number = ASSEMBLER_DIALECT;
240 #endif
241 }
242
243 /* Default target function prologue and epilogue assembler output.
244
245 If not overridden for epilogue code, then the function body itself
246 contains return instructions wherever needed. */
247 void
248 default_function_pro_epilogue (FILE *file ATTRIBUTE_UNUSED,
249 HOST_WIDE_INT size ATTRIBUTE_UNUSED)
250 {
251 }
252
253 /* Default target hook that outputs nothing to a stream. */
254 void
255 no_asm_to_stream (FILE *file ATTRIBUTE_UNUSED)
256 {
257 }
258
259 /* Enable APP processing of subsequent output.
260 Used before the output from an `asm' statement. */
261
262 void
263 app_enable (void)
264 {
265 if (! app_on)
266 {
267 fputs (ASM_APP_ON, asm_out_file);
268 app_on = 1;
269 }
270 }
271
272 /* Disable APP processing of subsequent output.
273 Called from varasm.c before most kinds of output. */
274
275 void
276 app_disable (void)
277 {
278 if (app_on)
279 {
280 fputs (ASM_APP_OFF, asm_out_file);
281 app_on = 0;
282 }
283 }
284 \f
285 /* Return the number of slots filled in the current
286 delayed branch sequence (we don't count the insn needing the
287 delay slot). Zero if not in a delayed branch sequence. */
288
289 #ifdef DELAY_SLOTS
290 int
291 dbr_sequence_length (void)
292 {
293 if (final_sequence != 0)
294 return XVECLEN (final_sequence, 0) - 1;
295 else
296 return 0;
297 }
298 #endif
299 \f
300 /* The next two pages contain routines used to compute the length of an insn
301 and to shorten branches. */
302
303 /* Arrays for insn lengths, and addresses. The latter is referenced by
304 `insn_current_length'. */
305
306 static int *insn_lengths;
307
308 VEC(int,heap) *insn_addresses_;
309
310 /* Max uid for which the above arrays are valid. */
311 static int insn_lengths_max_uid;
312
313 /* Address of insn being processed. Used by `insn_current_length'. */
314 int insn_current_address;
315
316 /* Address of insn being processed in previous iteration. */
317 int insn_last_address;
318
319 /* known invariant alignment of insn being processed. */
320 int insn_current_align;
321
322 /* After shorten_branches, for any insn, uid_align[INSN_UID (insn)]
323 gives the next following alignment insn that increases the known
324 alignment, or NULL_RTX if there is no such insn.
325 For any alignment obtained this way, we can again index uid_align with
326 its uid to obtain the next following align that in turn increases the
327 alignment, till we reach NULL_RTX; the sequence obtained this way
328 for each insn we'll call the alignment chain of this insn in the following
329 comments. */
330
331 struct label_alignment
332 {
333 short alignment;
334 short max_skip;
335 };
336
337 static rtx *uid_align;
338 static int *uid_shuid;
339 static struct label_alignment *label_align;
340
341 /* Indicate that branch shortening hasn't yet been done. */
342
343 void
344 init_insn_lengths (void)
345 {
346 if (uid_shuid)
347 {
348 free (uid_shuid);
349 uid_shuid = 0;
350 }
351 if (insn_lengths)
352 {
353 free (insn_lengths);
354 insn_lengths = 0;
355 insn_lengths_max_uid = 0;
356 }
357 #ifdef HAVE_ATTR_length
358 INSN_ADDRESSES_FREE ();
359 #endif
360 if (uid_align)
361 {
362 free (uid_align);
363 uid_align = 0;
364 }
365 }
366
367 /* Obtain the current length of an insn. If branch shortening has been done,
368 get its actual length. Otherwise, use FALLBACK_FN to calculate the
369 length. */
370 static inline int
371 get_attr_length_1 (rtx insn ATTRIBUTE_UNUSED,
372 int (*fallback_fn) (rtx) ATTRIBUTE_UNUSED)
373 {
374 #ifdef HAVE_ATTR_length
375 rtx body;
376 int i;
377 int length = 0;
378
379 if (insn_lengths_max_uid > INSN_UID (insn))
380 return insn_lengths[INSN_UID (insn)];
381 else
382 switch (GET_CODE (insn))
383 {
384 case NOTE:
385 case BARRIER:
386 case CODE_LABEL:
387 return 0;
388
389 case CALL_INSN:
390 length = fallback_fn (insn);
391 break;
392
393 case JUMP_INSN:
394 body = PATTERN (insn);
395 if (GET_CODE (body) == ADDR_VEC || GET_CODE (body) == ADDR_DIFF_VEC)
396 {
397 /* Alignment is machine-dependent and should be handled by
398 ADDR_VEC_ALIGN. */
399 }
400 else
401 length = fallback_fn (insn);
402 break;
403
404 case INSN:
405 body = PATTERN (insn);
406 if (GET_CODE (body) == USE || GET_CODE (body) == CLOBBER)
407 return 0;
408
409 else if (GET_CODE (body) == ASM_INPUT || asm_noperands (body) >= 0)
410 length = asm_insn_count (body) * fallback_fn (insn);
411 else if (GET_CODE (body) == SEQUENCE)
412 for (i = 0; i < XVECLEN (body, 0); i++)
413 length += get_attr_length (XVECEXP (body, 0, i));
414 else
415 length = fallback_fn (insn);
416 break;
417
418 default:
419 break;
420 }
421
422 #ifdef ADJUST_INSN_LENGTH
423 ADJUST_INSN_LENGTH (insn, length);
424 #endif
425 return length;
426 #else /* not HAVE_ATTR_length */
427 return 0;
428 #define insn_default_length 0
429 #define insn_min_length 0
430 #endif /* not HAVE_ATTR_length */
431 }
432
433 /* Obtain the current length of an insn. If branch shortening has been done,
434 get its actual length. Otherwise, get its maximum length. */
435 int
436 get_attr_length (rtx insn)
437 {
438 return get_attr_length_1 (insn, insn_default_length);
439 }
440
441 /* Obtain the current length of an insn. If branch shortening has been done,
442 get its actual length. Otherwise, get its minimum length. */
443 int
444 get_attr_min_length (rtx insn)
445 {
446 return get_attr_length_1 (insn, insn_min_length);
447 }
448 \f
449 /* Code to handle alignment inside shorten_branches. */
450
451 /* Here is an explanation how the algorithm in align_fuzz can give
452 proper results:
453
454 Call a sequence of instructions beginning with alignment point X
455 and continuing until the next alignment point `block X'. When `X'
456 is used in an expression, it means the alignment value of the
457 alignment point.
458
459 Call the distance between the start of the first insn of block X, and
460 the end of the last insn of block X `IX', for the `inner size of X'.
461 This is clearly the sum of the instruction lengths.
462
463 Likewise with the next alignment-delimited block following X, which we
464 shall call block Y.
465
466 Call the distance between the start of the first insn of block X, and
467 the start of the first insn of block Y `OX', for the `outer size of X'.
468
469 The estimated padding is then OX - IX.
470
471 OX can be safely estimated as
472
473 if (X >= Y)
474 OX = round_up(IX, Y)
475 else
476 OX = round_up(IX, X) + Y - X
477
478 Clearly est(IX) >= real(IX), because that only depends on the
479 instruction lengths, and those being overestimated is a given.
480
481 Clearly round_up(foo, Z) >= round_up(bar, Z) if foo >= bar, so
482 we needn't worry about that when thinking about OX.
483
484 When X >= Y, the alignment provided by Y adds no uncertainty factor
485 for branch ranges starting before X, so we can just round what we have.
486 But when X < Y, we don't know anything about the, so to speak,
487 `middle bits', so we have to assume the worst when aligning up from an
488 address mod X to one mod Y, which is Y - X. */
489
490 #ifndef LABEL_ALIGN
491 #define LABEL_ALIGN(LABEL) align_labels_log
492 #endif
493
494 #ifndef LABEL_ALIGN_MAX_SKIP
495 #define LABEL_ALIGN_MAX_SKIP align_labels_max_skip
496 #endif
497
498 #ifndef LOOP_ALIGN
499 #define LOOP_ALIGN(LABEL) align_loops_log
500 #endif
501
502 #ifndef LOOP_ALIGN_MAX_SKIP
503 #define LOOP_ALIGN_MAX_SKIP align_loops_max_skip
504 #endif
505
506 #ifndef LABEL_ALIGN_AFTER_BARRIER
507 #define LABEL_ALIGN_AFTER_BARRIER(LABEL) 0
508 #endif
509
510 #ifndef LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP
511 #define LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP 0
512 #endif
513
514 #ifndef JUMP_ALIGN
515 #define JUMP_ALIGN(LABEL) align_jumps_log
516 #endif
517
518 #ifndef JUMP_ALIGN_MAX_SKIP
519 #define JUMP_ALIGN_MAX_SKIP align_jumps_max_skip
520 #endif
521
522 #ifndef ADDR_VEC_ALIGN
523 static int
524 final_addr_vec_align (rtx addr_vec)
525 {
526 int align = GET_MODE_SIZE (GET_MODE (PATTERN (addr_vec)));
527
528 if (align > BIGGEST_ALIGNMENT / BITS_PER_UNIT)
529 align = BIGGEST_ALIGNMENT / BITS_PER_UNIT;
530 return exact_log2 (align);
531
532 }
533
534 #define ADDR_VEC_ALIGN(ADDR_VEC) final_addr_vec_align (ADDR_VEC)
535 #endif
536
537 #ifndef INSN_LENGTH_ALIGNMENT
538 #define INSN_LENGTH_ALIGNMENT(INSN) length_unit_log
539 #endif
540
541 #define INSN_SHUID(INSN) (uid_shuid[INSN_UID (INSN)])
542
543 static int min_labelno, max_labelno;
544
545 #define LABEL_TO_ALIGNMENT(LABEL) \
546 (label_align[CODE_LABEL_NUMBER (LABEL) - min_labelno].alignment)
547
548 #define LABEL_TO_MAX_SKIP(LABEL) \
549 (label_align[CODE_LABEL_NUMBER (LABEL) - min_labelno].max_skip)
550
551 /* For the benefit of port specific code do this also as a function. */
552
553 int
554 label_to_alignment (rtx label)
555 {
556 return LABEL_TO_ALIGNMENT (label);
557 }
558
559 #ifdef HAVE_ATTR_length
560 /* The differences in addresses
561 between a branch and its target might grow or shrink depending on
562 the alignment the start insn of the range (the branch for a forward
563 branch or the label for a backward branch) starts out on; if these
564 differences are used naively, they can even oscillate infinitely.
565 We therefore want to compute a 'worst case' address difference that
566 is independent of the alignment the start insn of the range end
567 up on, and that is at least as large as the actual difference.
568 The function align_fuzz calculates the amount we have to add to the
569 naively computed difference, by traversing the part of the alignment
570 chain of the start insn of the range that is in front of the end insn
571 of the range, and considering for each alignment the maximum amount
572 that it might contribute to a size increase.
573
574 For casesi tables, we also want to know worst case minimum amounts of
575 address difference, in case a machine description wants to introduce
576 some common offset that is added to all offsets in a table.
577 For this purpose, align_fuzz with a growth argument of 0 computes the
578 appropriate adjustment. */
579
580 /* Compute the maximum delta by which the difference of the addresses of
581 START and END might grow / shrink due to a different address for start
582 which changes the size of alignment insns between START and END.
583 KNOWN_ALIGN_LOG is the alignment known for START.
584 GROWTH should be ~0 if the objective is to compute potential code size
585 increase, and 0 if the objective is to compute potential shrink.
586 The return value is undefined for any other value of GROWTH. */
587
588 static int
589 align_fuzz (rtx start, rtx end, int known_align_log, unsigned int growth)
590 {
591 int uid = INSN_UID (start);
592 rtx align_label;
593 int known_align = 1 << known_align_log;
594 int end_shuid = INSN_SHUID (end);
595 int fuzz = 0;
596
597 for (align_label = uid_align[uid]; align_label; align_label = uid_align[uid])
598 {
599 int align_addr, new_align;
600
601 uid = INSN_UID (align_label);
602 align_addr = INSN_ADDRESSES (uid) - insn_lengths[uid];
603 if (uid_shuid[uid] > end_shuid)
604 break;
605 known_align_log = LABEL_TO_ALIGNMENT (align_label);
606 new_align = 1 << known_align_log;
607 if (new_align < known_align)
608 continue;
609 fuzz += (-align_addr ^ growth) & (new_align - known_align);
610 known_align = new_align;
611 }
612 return fuzz;
613 }
614
615 /* Compute a worst-case reference address of a branch so that it
616 can be safely used in the presence of aligned labels. Since the
617 size of the branch itself is unknown, the size of the branch is
618 not included in the range. I.e. for a forward branch, the reference
619 address is the end address of the branch as known from the previous
620 branch shortening pass, minus a value to account for possible size
621 increase due to alignment. For a backward branch, it is the start
622 address of the branch as known from the current pass, plus a value
623 to account for possible size increase due to alignment.
624 NB.: Therefore, the maximum offset allowed for backward branches needs
625 to exclude the branch size. */
626
627 int
628 insn_current_reference_address (rtx branch)
629 {
630 rtx dest, seq;
631 int seq_uid;
632
633 if (! INSN_ADDRESSES_SET_P ())
634 return 0;
635
636 seq = NEXT_INSN (PREV_INSN (branch));
637 seq_uid = INSN_UID (seq);
638 if (!JUMP_P (branch))
639 /* This can happen for example on the PA; the objective is to know the
640 offset to address something in front of the start of the function.
641 Thus, we can treat it like a backward branch.
642 We assume here that FUNCTION_BOUNDARY / BITS_PER_UNIT is larger than
643 any alignment we'd encounter, so we skip the call to align_fuzz. */
644 return insn_current_address;
645 dest = JUMP_LABEL (branch);
646
647 /* BRANCH has no proper alignment chain set, so use SEQ.
648 BRANCH also has no INSN_SHUID. */
649 if (INSN_SHUID (seq) < INSN_SHUID (dest))
650 {
651 /* Forward branch. */
652 return (insn_last_address + insn_lengths[seq_uid]
653 - align_fuzz (seq, dest, length_unit_log, ~0));
654 }
655 else
656 {
657 /* Backward branch. */
658 return (insn_current_address
659 + align_fuzz (dest, seq, length_unit_log, ~0));
660 }
661 }
662 #endif /* HAVE_ATTR_length */
663 \f
664 /* Compute branch alignments based on frequency information in the
665 CFG. */
666
667 static unsigned int
668 compute_alignments (void)
669 {
670 int log, max_skip, max_log;
671 basic_block bb;
672
673 if (label_align)
674 {
675 free (label_align);
676 label_align = 0;
677 }
678
679 max_labelno = max_label_num ();
680 min_labelno = get_first_label_num ();
681 label_align = XCNEWVEC (struct label_alignment, max_labelno - min_labelno + 1);
682
683 /* If not optimizing or optimizing for size, don't assign any alignments. */
684 if (! optimize || optimize_size)
685 return 0;
686
687 FOR_EACH_BB (bb)
688 {
689 rtx label = BB_HEAD (bb);
690 int fallthru_frequency = 0, branch_frequency = 0, has_fallthru = 0;
691 edge e;
692 edge_iterator ei;
693
694 if (!LABEL_P (label)
695 || probably_never_executed_bb_p (bb))
696 continue;
697 max_log = LABEL_ALIGN (label);
698 max_skip = LABEL_ALIGN_MAX_SKIP;
699
700 FOR_EACH_EDGE (e, ei, bb->preds)
701 {
702 if (e->flags & EDGE_FALLTHRU)
703 has_fallthru = 1, fallthru_frequency += EDGE_FREQUENCY (e);
704 else
705 branch_frequency += EDGE_FREQUENCY (e);
706 }
707
708 /* There are two purposes to align block with no fallthru incoming edge:
709 1) to avoid fetch stalls when branch destination is near cache boundary
710 2) to improve cache efficiency in case the previous block is not executed
711 (so it does not need to be in the cache).
712
713 We to catch first case, we align frequently executed blocks.
714 To catch the second, we align blocks that are executed more frequently
715 than the predecessor and the predecessor is likely to not be executed
716 when function is called. */
717
718 if (!has_fallthru
719 && (branch_frequency > BB_FREQ_MAX / 10
720 || (bb->frequency > bb->prev_bb->frequency * 10
721 && (bb->prev_bb->frequency
722 <= ENTRY_BLOCK_PTR->frequency / 2))))
723 {
724 log = JUMP_ALIGN (label);
725 if (max_log < log)
726 {
727 max_log = log;
728 max_skip = JUMP_ALIGN_MAX_SKIP;
729 }
730 }
731 /* In case block is frequent and reached mostly by non-fallthru edge,
732 align it. It is most likely a first block of loop. */
733 if (has_fallthru
734 && maybe_hot_bb_p (bb)
735 && branch_frequency + fallthru_frequency > BB_FREQ_MAX / 10
736 && branch_frequency > fallthru_frequency * 2)
737 {
738 log = LOOP_ALIGN (label);
739 if (max_log < log)
740 {
741 max_log = log;
742 max_skip = LOOP_ALIGN_MAX_SKIP;
743 }
744 }
745 LABEL_TO_ALIGNMENT (label) = max_log;
746 LABEL_TO_MAX_SKIP (label) = max_skip;
747 }
748 return 0;
749 }
750
751 struct tree_opt_pass pass_compute_alignments =
752 {
753 NULL, /* name */
754 NULL, /* gate */
755 compute_alignments, /* execute */
756 NULL, /* sub */
757 NULL, /* next */
758 0, /* static_pass_number */
759 0, /* tv_id */
760 0, /* properties_required */
761 0, /* properties_provided */
762 0, /* properties_destroyed */
763 0, /* todo_flags_start */
764 0, /* todo_flags_finish */
765 0 /* letter */
766 };
767
768 \f
769 /* Make a pass over all insns and compute their actual lengths by shortening
770 any branches of variable length if possible. */
771
772 /* shorten_branches might be called multiple times: for example, the SH
773 port splits out-of-range conditional branches in MACHINE_DEPENDENT_REORG.
774 In order to do this, it needs proper length information, which it obtains
775 by calling shorten_branches. This cannot be collapsed with
776 shorten_branches itself into a single pass unless we also want to integrate
777 reorg.c, since the branch splitting exposes new instructions with delay
778 slots. */
779
780 void
781 shorten_branches (rtx first ATTRIBUTE_UNUSED)
782 {
783 rtx insn;
784 int max_uid;
785 int i;
786 int max_log;
787 int max_skip;
788 #ifdef HAVE_ATTR_length
789 #define MAX_CODE_ALIGN 16
790 rtx seq;
791 int something_changed = 1;
792 char *varying_length;
793 rtx body;
794 int uid;
795 rtx align_tab[MAX_CODE_ALIGN];
796
797 #endif
798
799 /* Compute maximum UID and allocate label_align / uid_shuid. */
800 max_uid = get_max_uid ();
801
802 /* Free uid_shuid before reallocating it. */
803 free (uid_shuid);
804
805 uid_shuid = XNEWVEC (int, max_uid);
806
807 if (max_labelno != max_label_num ())
808 {
809 int old = max_labelno;
810 int n_labels;
811 int n_old_labels;
812
813 max_labelno = max_label_num ();
814
815 n_labels = max_labelno - min_labelno + 1;
816 n_old_labels = old - min_labelno + 1;
817
818 label_align = xrealloc (label_align,
819 n_labels * sizeof (struct label_alignment));
820
821 /* Range of labels grows monotonically in the function. Failing here
822 means that the initialization of array got lost. */
823 gcc_assert (n_old_labels <= n_labels);
824
825 memset (label_align + n_old_labels, 0,
826 (n_labels - n_old_labels) * sizeof (struct label_alignment));
827 }
828
829 /* Initialize label_align and set up uid_shuid to be strictly
830 monotonically rising with insn order. */
831 /* We use max_log here to keep track of the maximum alignment we want to
832 impose on the next CODE_LABEL (or the current one if we are processing
833 the CODE_LABEL itself). */
834
835 max_log = 0;
836 max_skip = 0;
837
838 for (insn = get_insns (), i = 1; insn; insn = NEXT_INSN (insn))
839 {
840 int log;
841
842 INSN_SHUID (insn) = i++;
843 if (INSN_P (insn))
844 continue;
845
846 if (LABEL_P (insn))
847 {
848 rtx next;
849
850 /* Merge in alignments computed by compute_alignments. */
851 log = LABEL_TO_ALIGNMENT (insn);
852 if (max_log < log)
853 {
854 max_log = log;
855 max_skip = LABEL_TO_MAX_SKIP (insn);
856 }
857
858 log = LABEL_ALIGN (insn);
859 if (max_log < log)
860 {
861 max_log = log;
862 max_skip = LABEL_ALIGN_MAX_SKIP;
863 }
864 next = next_nonnote_insn (insn);
865 /* ADDR_VECs only take room if read-only data goes into the text
866 section. */
867 if (JUMP_TABLES_IN_TEXT_SECTION
868 || readonly_data_section == text_section)
869 if (next && JUMP_P (next))
870 {
871 rtx nextbody = PATTERN (next);
872 if (GET_CODE (nextbody) == ADDR_VEC
873 || GET_CODE (nextbody) == ADDR_DIFF_VEC)
874 {
875 log = ADDR_VEC_ALIGN (next);
876 if (max_log < log)
877 {
878 max_log = log;
879 max_skip = LABEL_ALIGN_MAX_SKIP;
880 }
881 }
882 }
883 LABEL_TO_ALIGNMENT (insn) = max_log;
884 LABEL_TO_MAX_SKIP (insn) = max_skip;
885 max_log = 0;
886 max_skip = 0;
887 }
888 else if (BARRIER_P (insn))
889 {
890 rtx label;
891
892 for (label = insn; label && ! INSN_P (label);
893 label = NEXT_INSN (label))
894 if (LABEL_P (label))
895 {
896 log = LABEL_ALIGN_AFTER_BARRIER (insn);
897 if (max_log < log)
898 {
899 max_log = log;
900 max_skip = LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP;
901 }
902 break;
903 }
904 }
905 }
906 #ifdef HAVE_ATTR_length
907
908 /* Allocate the rest of the arrays. */
909 insn_lengths = XNEWVEC (int, max_uid);
910 insn_lengths_max_uid = max_uid;
911 /* Syntax errors can lead to labels being outside of the main insn stream.
912 Initialize insn_addresses, so that we get reproducible results. */
913 INSN_ADDRESSES_ALLOC (max_uid);
914
915 varying_length = XCNEWVEC (char, max_uid);
916
917 /* Initialize uid_align. We scan instructions
918 from end to start, and keep in align_tab[n] the last seen insn
919 that does an alignment of at least n+1, i.e. the successor
920 in the alignment chain for an insn that does / has a known
921 alignment of n. */
922 uid_align = XCNEWVEC (rtx, max_uid);
923
924 for (i = MAX_CODE_ALIGN; --i >= 0;)
925 align_tab[i] = NULL_RTX;
926 seq = get_last_insn ();
927 for (; seq; seq = PREV_INSN (seq))
928 {
929 int uid = INSN_UID (seq);
930 int log;
931 log = (LABEL_P (seq) ? LABEL_TO_ALIGNMENT (seq) : 0);
932 uid_align[uid] = align_tab[0];
933 if (log)
934 {
935 /* Found an alignment label. */
936 uid_align[uid] = align_tab[log];
937 for (i = log - 1; i >= 0; i--)
938 align_tab[i] = seq;
939 }
940 }
941 #ifdef CASE_VECTOR_SHORTEN_MODE
942 if (optimize)
943 {
944 /* Look for ADDR_DIFF_VECs, and initialize their minimum and maximum
945 label fields. */
946
947 int min_shuid = INSN_SHUID (get_insns ()) - 1;
948 int max_shuid = INSN_SHUID (get_last_insn ()) + 1;
949 int rel;
950
951 for (insn = first; insn != 0; insn = NEXT_INSN (insn))
952 {
953 rtx min_lab = NULL_RTX, max_lab = NULL_RTX, pat;
954 int len, i, min, max, insn_shuid;
955 int min_align;
956 addr_diff_vec_flags flags;
957
958 if (!JUMP_P (insn)
959 || GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC)
960 continue;
961 pat = PATTERN (insn);
962 len = XVECLEN (pat, 1);
963 gcc_assert (len > 0);
964 min_align = MAX_CODE_ALIGN;
965 for (min = max_shuid, max = min_shuid, i = len - 1; i >= 0; i--)
966 {
967 rtx lab = XEXP (XVECEXP (pat, 1, i), 0);
968 int shuid = INSN_SHUID (lab);
969 if (shuid < min)
970 {
971 min = shuid;
972 min_lab = lab;
973 }
974 if (shuid > max)
975 {
976 max = shuid;
977 max_lab = lab;
978 }
979 if (min_align > LABEL_TO_ALIGNMENT (lab))
980 min_align = LABEL_TO_ALIGNMENT (lab);
981 }
982 XEXP (pat, 2) = gen_rtx_LABEL_REF (Pmode, min_lab);
983 XEXP (pat, 3) = gen_rtx_LABEL_REF (Pmode, max_lab);
984 insn_shuid = INSN_SHUID (insn);
985 rel = INSN_SHUID (XEXP (XEXP (pat, 0), 0));
986 memset (&flags, 0, sizeof (flags));
987 flags.min_align = min_align;
988 flags.base_after_vec = rel > insn_shuid;
989 flags.min_after_vec = min > insn_shuid;
990 flags.max_after_vec = max > insn_shuid;
991 flags.min_after_base = min > rel;
992 flags.max_after_base = max > rel;
993 ADDR_DIFF_VEC_FLAGS (pat) = flags;
994 }
995 }
996 #endif /* CASE_VECTOR_SHORTEN_MODE */
997
998 /* Compute initial lengths, addresses, and varying flags for each insn. */
999 for (insn_current_address = 0, insn = first;
1000 insn != 0;
1001 insn_current_address += insn_lengths[uid], insn = NEXT_INSN (insn))
1002 {
1003 uid = INSN_UID (insn);
1004
1005 insn_lengths[uid] = 0;
1006
1007 if (LABEL_P (insn))
1008 {
1009 int log = LABEL_TO_ALIGNMENT (insn);
1010 if (log)
1011 {
1012 int align = 1 << log;
1013 int new_address = (insn_current_address + align - 1) & -align;
1014 insn_lengths[uid] = new_address - insn_current_address;
1015 }
1016 }
1017
1018 INSN_ADDRESSES (uid) = insn_current_address + insn_lengths[uid];
1019
1020 if (NOTE_P (insn) || BARRIER_P (insn)
1021 || LABEL_P (insn))
1022 continue;
1023 if (INSN_DELETED_P (insn))
1024 continue;
1025
1026 body = PATTERN (insn);
1027 if (GET_CODE (body) == ADDR_VEC || GET_CODE (body) == ADDR_DIFF_VEC)
1028 {
1029 /* This only takes room if read-only data goes into the text
1030 section. */
1031 if (JUMP_TABLES_IN_TEXT_SECTION
1032 || readonly_data_section == text_section)
1033 insn_lengths[uid] = (XVECLEN (body,
1034 GET_CODE (body) == ADDR_DIFF_VEC)
1035 * GET_MODE_SIZE (GET_MODE (body)));
1036 /* Alignment is handled by ADDR_VEC_ALIGN. */
1037 }
1038 else if (GET_CODE (body) == ASM_INPUT || asm_noperands (body) >= 0)
1039 insn_lengths[uid] = asm_insn_count (body) * insn_default_length (insn);
1040 else if (GET_CODE (body) == SEQUENCE)
1041 {
1042 int i;
1043 int const_delay_slots;
1044 #ifdef DELAY_SLOTS
1045 const_delay_slots = const_num_delay_slots (XVECEXP (body, 0, 0));
1046 #else
1047 const_delay_slots = 0;
1048 #endif
1049 /* Inside a delay slot sequence, we do not do any branch shortening
1050 if the shortening could change the number of delay slots
1051 of the branch. */
1052 for (i = 0; i < XVECLEN (body, 0); i++)
1053 {
1054 rtx inner_insn = XVECEXP (body, 0, i);
1055 int inner_uid = INSN_UID (inner_insn);
1056 int inner_length;
1057
1058 if (GET_CODE (body) == ASM_INPUT
1059 || asm_noperands (PATTERN (XVECEXP (body, 0, i))) >= 0)
1060 inner_length = (asm_insn_count (PATTERN (inner_insn))
1061 * insn_default_length (inner_insn));
1062 else
1063 inner_length = insn_default_length (inner_insn);
1064
1065 insn_lengths[inner_uid] = inner_length;
1066 if (const_delay_slots)
1067 {
1068 if ((varying_length[inner_uid]
1069 = insn_variable_length_p (inner_insn)) != 0)
1070 varying_length[uid] = 1;
1071 INSN_ADDRESSES (inner_uid) = (insn_current_address
1072 + insn_lengths[uid]);
1073 }
1074 else
1075 varying_length[inner_uid] = 0;
1076 insn_lengths[uid] += inner_length;
1077 }
1078 }
1079 else if (GET_CODE (body) != USE && GET_CODE (body) != CLOBBER)
1080 {
1081 insn_lengths[uid] = insn_default_length (insn);
1082 varying_length[uid] = insn_variable_length_p (insn);
1083 }
1084
1085 /* If needed, do any adjustment. */
1086 #ifdef ADJUST_INSN_LENGTH
1087 ADJUST_INSN_LENGTH (insn, insn_lengths[uid]);
1088 if (insn_lengths[uid] < 0)
1089 fatal_insn ("negative insn length", insn);
1090 #endif
1091 }
1092
1093 /* Now loop over all the insns finding varying length insns. For each,
1094 get the current insn length. If it has changed, reflect the change.
1095 When nothing changes for a full pass, we are done. */
1096
1097 while (something_changed)
1098 {
1099 something_changed = 0;
1100 insn_current_align = MAX_CODE_ALIGN - 1;
1101 for (insn_current_address = 0, insn = first;
1102 insn != 0;
1103 insn = NEXT_INSN (insn))
1104 {
1105 int new_length;
1106 #ifdef ADJUST_INSN_LENGTH
1107 int tmp_length;
1108 #endif
1109 int length_align;
1110
1111 uid = INSN_UID (insn);
1112
1113 if (LABEL_P (insn))
1114 {
1115 int log = LABEL_TO_ALIGNMENT (insn);
1116 if (log > insn_current_align)
1117 {
1118 int align = 1 << log;
1119 int new_address= (insn_current_address + align - 1) & -align;
1120 insn_lengths[uid] = new_address - insn_current_address;
1121 insn_current_align = log;
1122 insn_current_address = new_address;
1123 }
1124 else
1125 insn_lengths[uid] = 0;
1126 INSN_ADDRESSES (uid) = insn_current_address;
1127 continue;
1128 }
1129
1130 length_align = INSN_LENGTH_ALIGNMENT (insn);
1131 if (length_align < insn_current_align)
1132 insn_current_align = length_align;
1133
1134 insn_last_address = INSN_ADDRESSES (uid);
1135 INSN_ADDRESSES (uid) = insn_current_address;
1136
1137 #ifdef CASE_VECTOR_SHORTEN_MODE
1138 if (optimize && JUMP_P (insn)
1139 && GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC)
1140 {
1141 rtx body = PATTERN (insn);
1142 int old_length = insn_lengths[uid];
1143 rtx rel_lab = XEXP (XEXP (body, 0), 0);
1144 rtx min_lab = XEXP (XEXP (body, 2), 0);
1145 rtx max_lab = XEXP (XEXP (body, 3), 0);
1146 int rel_addr = INSN_ADDRESSES (INSN_UID (rel_lab));
1147 int min_addr = INSN_ADDRESSES (INSN_UID (min_lab));
1148 int max_addr = INSN_ADDRESSES (INSN_UID (max_lab));
1149 rtx prev;
1150 int rel_align = 0;
1151 addr_diff_vec_flags flags;
1152
1153 /* Avoid automatic aggregate initialization. */
1154 flags = ADDR_DIFF_VEC_FLAGS (body);
1155
1156 /* Try to find a known alignment for rel_lab. */
1157 for (prev = rel_lab;
1158 prev
1159 && ! insn_lengths[INSN_UID (prev)]
1160 && ! (varying_length[INSN_UID (prev)] & 1);
1161 prev = PREV_INSN (prev))
1162 if (varying_length[INSN_UID (prev)] & 2)
1163 {
1164 rel_align = LABEL_TO_ALIGNMENT (prev);
1165 break;
1166 }
1167
1168 /* See the comment on addr_diff_vec_flags in rtl.h for the
1169 meaning of the flags values. base: REL_LAB vec: INSN */
1170 /* Anything after INSN has still addresses from the last
1171 pass; adjust these so that they reflect our current
1172 estimate for this pass. */
1173 if (flags.base_after_vec)
1174 rel_addr += insn_current_address - insn_last_address;
1175 if (flags.min_after_vec)
1176 min_addr += insn_current_address - insn_last_address;
1177 if (flags.max_after_vec)
1178 max_addr += insn_current_address - insn_last_address;
1179 /* We want to know the worst case, i.e. lowest possible value
1180 for the offset of MIN_LAB. If MIN_LAB is after REL_LAB,
1181 its offset is positive, and we have to be wary of code shrink;
1182 otherwise, it is negative, and we have to be vary of code
1183 size increase. */
1184 if (flags.min_after_base)
1185 {
1186 /* If INSN is between REL_LAB and MIN_LAB, the size
1187 changes we are about to make can change the alignment
1188 within the observed offset, therefore we have to break
1189 it up into two parts that are independent. */
1190 if (! flags.base_after_vec && flags.min_after_vec)
1191 {
1192 min_addr -= align_fuzz (rel_lab, insn, rel_align, 0);
1193 min_addr -= align_fuzz (insn, min_lab, 0, 0);
1194 }
1195 else
1196 min_addr -= align_fuzz (rel_lab, min_lab, rel_align, 0);
1197 }
1198 else
1199 {
1200 if (flags.base_after_vec && ! flags.min_after_vec)
1201 {
1202 min_addr -= align_fuzz (min_lab, insn, 0, ~0);
1203 min_addr -= align_fuzz (insn, rel_lab, 0, ~0);
1204 }
1205 else
1206 min_addr -= align_fuzz (min_lab, rel_lab, 0, ~0);
1207 }
1208 /* Likewise, determine the highest lowest possible value
1209 for the offset of MAX_LAB. */
1210 if (flags.max_after_base)
1211 {
1212 if (! flags.base_after_vec && flags.max_after_vec)
1213 {
1214 max_addr += align_fuzz (rel_lab, insn, rel_align, ~0);
1215 max_addr += align_fuzz (insn, max_lab, 0, ~0);
1216 }
1217 else
1218 max_addr += align_fuzz (rel_lab, max_lab, rel_align, ~0);
1219 }
1220 else
1221 {
1222 if (flags.base_after_vec && ! flags.max_after_vec)
1223 {
1224 max_addr += align_fuzz (max_lab, insn, 0, 0);
1225 max_addr += align_fuzz (insn, rel_lab, 0, 0);
1226 }
1227 else
1228 max_addr += align_fuzz (max_lab, rel_lab, 0, 0);
1229 }
1230 PUT_MODE (body, CASE_VECTOR_SHORTEN_MODE (min_addr - rel_addr,
1231 max_addr - rel_addr,
1232 body));
1233 if (JUMP_TABLES_IN_TEXT_SECTION
1234 || readonly_data_section == text_section)
1235 {
1236 insn_lengths[uid]
1237 = (XVECLEN (body, 1) * GET_MODE_SIZE (GET_MODE (body)));
1238 insn_current_address += insn_lengths[uid];
1239 if (insn_lengths[uid] != old_length)
1240 something_changed = 1;
1241 }
1242
1243 continue;
1244 }
1245 #endif /* CASE_VECTOR_SHORTEN_MODE */
1246
1247 if (! (varying_length[uid]))
1248 {
1249 if (NONJUMP_INSN_P (insn)
1250 && GET_CODE (PATTERN (insn)) == SEQUENCE)
1251 {
1252 int i;
1253
1254 body = PATTERN (insn);
1255 for (i = 0; i < XVECLEN (body, 0); i++)
1256 {
1257 rtx inner_insn = XVECEXP (body, 0, i);
1258 int inner_uid = INSN_UID (inner_insn);
1259
1260 INSN_ADDRESSES (inner_uid) = insn_current_address;
1261
1262 insn_current_address += insn_lengths[inner_uid];
1263 }
1264 }
1265 else
1266 insn_current_address += insn_lengths[uid];
1267
1268 continue;
1269 }
1270
1271 if (NONJUMP_INSN_P (insn) && GET_CODE (PATTERN (insn)) == SEQUENCE)
1272 {
1273 int i;
1274
1275 body = PATTERN (insn);
1276 new_length = 0;
1277 for (i = 0; i < XVECLEN (body, 0); i++)
1278 {
1279 rtx inner_insn = XVECEXP (body, 0, i);
1280 int inner_uid = INSN_UID (inner_insn);
1281 int inner_length;
1282
1283 INSN_ADDRESSES (inner_uid) = insn_current_address;
1284
1285 /* insn_current_length returns 0 for insns with a
1286 non-varying length. */
1287 if (! varying_length[inner_uid])
1288 inner_length = insn_lengths[inner_uid];
1289 else
1290 inner_length = insn_current_length (inner_insn);
1291
1292 if (inner_length != insn_lengths[inner_uid])
1293 {
1294 insn_lengths[inner_uid] = inner_length;
1295 something_changed = 1;
1296 }
1297 insn_current_address += insn_lengths[inner_uid];
1298 new_length += inner_length;
1299 }
1300 }
1301 else
1302 {
1303 new_length = insn_current_length (insn);
1304 insn_current_address += new_length;
1305 }
1306
1307 #ifdef ADJUST_INSN_LENGTH
1308 /* If needed, do any adjustment. */
1309 tmp_length = new_length;
1310 ADJUST_INSN_LENGTH (insn, new_length);
1311 insn_current_address += (new_length - tmp_length);
1312 #endif
1313
1314 if (new_length != insn_lengths[uid])
1315 {
1316 insn_lengths[uid] = new_length;
1317 something_changed = 1;
1318 }
1319 }
1320 /* For a non-optimizing compile, do only a single pass. */
1321 if (!optimize)
1322 break;
1323 }
1324
1325 free (varying_length);
1326
1327 #endif /* HAVE_ATTR_length */
1328 }
1329
1330 #ifdef HAVE_ATTR_length
1331 /* Given the body of an INSN known to be generated by an ASM statement, return
1332 the number of machine instructions likely to be generated for this insn.
1333 This is used to compute its length. */
1334
1335 static int
1336 asm_insn_count (rtx body)
1337 {
1338 const char *template;
1339 int count = 1;
1340
1341 if (GET_CODE (body) == ASM_INPUT)
1342 template = XSTR (body, 0);
1343 else
1344 template = decode_asm_operands (body, NULL, NULL, NULL, NULL, NULL);
1345
1346 for (; *template; template++)
1347 if (IS_ASM_LOGICAL_LINE_SEPARATOR (*template) || *template == '\n')
1348 count++;
1349
1350 return count;
1351 }
1352 #endif
1353 \f
1354 /* ??? This is probably the wrong place for these. */
1355 /* Structure recording the mapping from source file and directory
1356 names at compile time to those to be embedded in debug
1357 information. */
1358 typedef struct debug_prefix_map
1359 {
1360 const char *old_prefix;
1361 const char *new_prefix;
1362 size_t old_len;
1363 size_t new_len;
1364 struct debug_prefix_map *next;
1365 } debug_prefix_map;
1366
1367 /* Linked list of such structures. */
1368 debug_prefix_map *debug_prefix_maps;
1369
1370
1371 /* Record a debug file prefix mapping. ARG is the argument to
1372 -fdebug-prefix-map and must be of the form OLD=NEW. */
1373
1374 void
1375 add_debug_prefix_map (const char *arg)
1376 {
1377 debug_prefix_map *map;
1378 const char *p;
1379
1380 p = strchr (arg, '=');
1381 if (!p)
1382 {
1383 error ("invalid argument %qs to -fdebug-prefix-map", arg);
1384 return;
1385 }
1386 map = XNEW (debug_prefix_map);
1387 map->old_prefix = ggc_alloc_string (arg, p - arg);
1388 map->old_len = p - arg;
1389 p++;
1390 map->new_prefix = ggc_strdup (p);
1391 map->new_len = strlen (p);
1392 map->next = debug_prefix_maps;
1393 debug_prefix_maps = map;
1394 }
1395
1396 /* Perform user-specified mapping of debug filename prefixes. Return
1397 the new name corresponding to FILENAME. */
1398
1399 const char *
1400 remap_debug_filename (const char *filename)
1401 {
1402 debug_prefix_map *map;
1403 char *s;
1404 const char *name;
1405 size_t name_len;
1406
1407 for (map = debug_prefix_maps; map; map = map->next)
1408 if (strncmp (filename, map->old_prefix, map->old_len) == 0)
1409 break;
1410 if (!map)
1411 return filename;
1412 name = filename + map->old_len;
1413 name_len = strlen (name) + 1;
1414 s = (char *) alloca (name_len + map->new_len);
1415 memcpy (s, map->new_prefix, map->new_len);
1416 memcpy (s + map->new_len, name, name_len);
1417 return ggc_strdup (s);
1418 }
1419 \f
1420 /* Output assembler code for the start of a function,
1421 and initialize some of the variables in this file
1422 for the new function. The label for the function and associated
1423 assembler pseudo-ops have already been output in `assemble_start_function'.
1424
1425 FIRST is the first insn of the rtl for the function being compiled.
1426 FILE is the file to write assembler code to.
1427 OPTIMIZE is nonzero if we should eliminate redundant
1428 test and compare insns. */
1429
1430 void
1431 final_start_function (rtx first ATTRIBUTE_UNUSED, FILE *file,
1432 int optimize ATTRIBUTE_UNUSED)
1433 {
1434 block_depth = 0;
1435
1436 this_is_asm_operands = 0;
1437
1438 last_filename = locator_file (prologue_locator);
1439 last_linenum = locator_line (prologue_locator);
1440
1441 high_block_linenum = high_function_linenum = last_linenum;
1442
1443 (*debug_hooks->begin_prologue) (last_linenum, last_filename);
1444
1445 #if defined (DWARF2_UNWIND_INFO) || defined (TARGET_UNWIND_INFO)
1446 if (write_symbols != DWARF2_DEBUG && write_symbols != VMS_AND_DWARF2_DEBUG)
1447 dwarf2out_begin_prologue (0, NULL);
1448 #endif
1449
1450 #ifdef LEAF_REG_REMAP
1451 if (current_function_uses_only_leaf_regs)
1452 leaf_renumber_regs (first);
1453 #endif
1454
1455 /* The Sun386i and perhaps other machines don't work right
1456 if the profiling code comes after the prologue. */
1457 #ifdef PROFILE_BEFORE_PROLOGUE
1458 if (current_function_profile)
1459 profile_function (file);
1460 #endif /* PROFILE_BEFORE_PROLOGUE */
1461
1462 #if defined (DWARF2_UNWIND_INFO) && defined (HAVE_prologue)
1463 if (dwarf2out_do_frame ())
1464 dwarf2out_frame_debug (NULL_RTX, false);
1465 #endif
1466
1467 /* If debugging, assign block numbers to all of the blocks in this
1468 function. */
1469 if (write_symbols)
1470 {
1471 reemit_insn_block_notes ();
1472 number_blocks (current_function_decl);
1473 /* We never actually put out begin/end notes for the top-level
1474 block in the function. But, conceptually, that block is
1475 always needed. */
1476 TREE_ASM_WRITTEN (DECL_INITIAL (current_function_decl)) = 1;
1477 }
1478
1479 /* First output the function prologue: code to set up the stack frame. */
1480 targetm.asm_out.function_prologue (file, get_frame_size ());
1481
1482 /* If the machine represents the prologue as RTL, the profiling code must
1483 be emitted when NOTE_INSN_PROLOGUE_END is scanned. */
1484 #ifdef HAVE_prologue
1485 if (! HAVE_prologue)
1486 #endif
1487 profile_after_prologue (file);
1488 }
1489
1490 static void
1491 profile_after_prologue (FILE *file ATTRIBUTE_UNUSED)
1492 {
1493 #ifndef PROFILE_BEFORE_PROLOGUE
1494 if (current_function_profile)
1495 profile_function (file);
1496 #endif /* not PROFILE_BEFORE_PROLOGUE */
1497 }
1498
1499 static void
1500 profile_function (FILE *file ATTRIBUTE_UNUSED)
1501 {
1502 #ifndef NO_PROFILE_COUNTERS
1503 # define NO_PROFILE_COUNTERS 0
1504 #endif
1505 #if defined(ASM_OUTPUT_REG_PUSH)
1506 int sval = current_function_returns_struct;
1507 rtx svrtx = targetm.calls.struct_value_rtx (TREE_TYPE (current_function_decl), 1);
1508 #if defined(STATIC_CHAIN_INCOMING_REGNUM) || defined(STATIC_CHAIN_REGNUM)
1509 int cxt = cfun->static_chain_decl != NULL;
1510 #endif
1511 #endif /* ASM_OUTPUT_REG_PUSH */
1512
1513 if (! NO_PROFILE_COUNTERS)
1514 {
1515 int align = MIN (BIGGEST_ALIGNMENT, LONG_TYPE_SIZE);
1516 switch_to_section (data_section);
1517 ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT));
1518 targetm.asm_out.internal_label (file, "LP", current_function_funcdef_no);
1519 assemble_integer (const0_rtx, LONG_TYPE_SIZE / BITS_PER_UNIT, align, 1);
1520 }
1521
1522 switch_to_section (current_function_section ());
1523
1524 #if defined(ASM_OUTPUT_REG_PUSH)
1525 if (sval && svrtx != NULL_RTX && REG_P (svrtx))
1526 {
1527 ASM_OUTPUT_REG_PUSH (file, REGNO (svrtx));
1528 }
1529 #endif
1530
1531 #if defined(STATIC_CHAIN_INCOMING_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
1532 if (cxt)
1533 ASM_OUTPUT_REG_PUSH (file, STATIC_CHAIN_INCOMING_REGNUM);
1534 #else
1535 #if defined(STATIC_CHAIN_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
1536 if (cxt)
1537 {
1538 ASM_OUTPUT_REG_PUSH (file, STATIC_CHAIN_REGNUM);
1539 }
1540 #endif
1541 #endif
1542
1543 FUNCTION_PROFILER (file, current_function_funcdef_no);
1544
1545 #if defined(STATIC_CHAIN_INCOMING_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
1546 if (cxt)
1547 ASM_OUTPUT_REG_POP (file, STATIC_CHAIN_INCOMING_REGNUM);
1548 #else
1549 #if defined(STATIC_CHAIN_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
1550 if (cxt)
1551 {
1552 ASM_OUTPUT_REG_POP (file, STATIC_CHAIN_REGNUM);
1553 }
1554 #endif
1555 #endif
1556
1557 #if defined(ASM_OUTPUT_REG_PUSH)
1558 if (sval && svrtx != NULL_RTX && REG_P (svrtx))
1559 {
1560 ASM_OUTPUT_REG_POP (file, REGNO (svrtx));
1561 }
1562 #endif
1563 }
1564
1565 /* Output assembler code for the end of a function.
1566 For clarity, args are same as those of `final_start_function'
1567 even though not all of them are needed. */
1568
1569 void
1570 final_end_function (void)
1571 {
1572 app_disable ();
1573
1574 (*debug_hooks->end_function) (high_function_linenum);
1575
1576 /* Finally, output the function epilogue:
1577 code to restore the stack frame and return to the caller. */
1578 targetm.asm_out.function_epilogue (asm_out_file, get_frame_size ());
1579
1580 /* And debug output. */
1581 (*debug_hooks->end_epilogue) (last_linenum, last_filename);
1582
1583 #if defined (DWARF2_UNWIND_INFO)
1584 if (write_symbols != DWARF2_DEBUG && write_symbols != VMS_AND_DWARF2_DEBUG
1585 && dwarf2out_do_frame ())
1586 dwarf2out_end_epilogue (last_linenum, last_filename);
1587 #endif
1588 }
1589 \f
1590 /* Output assembler code for some insns: all or part of a function.
1591 For description of args, see `final_start_function', above. */
1592
1593 void
1594 final (rtx first, FILE *file, int optimize)
1595 {
1596 rtx insn;
1597 int max_uid = 0;
1598 int seen = 0;
1599
1600 last_ignored_compare = 0;
1601
1602 for (insn = first; insn; insn = NEXT_INSN (insn))
1603 {
1604 if (INSN_UID (insn) > max_uid) /* Find largest UID. */
1605 max_uid = INSN_UID (insn);
1606 #ifdef HAVE_cc0
1607 /* If CC tracking across branches is enabled, record the insn which
1608 jumps to each branch only reached from one place. */
1609 if (optimize && JUMP_P (insn))
1610 {
1611 rtx lab = JUMP_LABEL (insn);
1612 if (lab && LABEL_NUSES (lab) == 1)
1613 {
1614 LABEL_REFS (lab) = insn;
1615 }
1616 }
1617 #endif
1618 }
1619
1620 init_recog ();
1621
1622 CC_STATUS_INIT;
1623
1624 /* Output the insns. */
1625 for (insn = first; insn;)
1626 {
1627 #ifdef HAVE_ATTR_length
1628 if ((unsigned) INSN_UID (insn) >= INSN_ADDRESSES_SIZE ())
1629 {
1630 /* This can be triggered by bugs elsewhere in the compiler if
1631 new insns are created after init_insn_lengths is called. */
1632 gcc_assert (NOTE_P (insn));
1633 insn_current_address = -1;
1634 }
1635 else
1636 insn_current_address = INSN_ADDRESSES (INSN_UID (insn));
1637 #endif /* HAVE_ATTR_length */
1638
1639 insn = final_scan_insn (insn, file, optimize, 0, &seen);
1640 }
1641 }
1642 \f
1643 const char *
1644 get_insn_template (int code, rtx insn)
1645 {
1646 switch (insn_data[code].output_format)
1647 {
1648 case INSN_OUTPUT_FORMAT_SINGLE:
1649 return insn_data[code].output.single;
1650 case INSN_OUTPUT_FORMAT_MULTI:
1651 return insn_data[code].output.multi[which_alternative];
1652 case INSN_OUTPUT_FORMAT_FUNCTION:
1653 gcc_assert (insn);
1654 return (*insn_data[code].output.function) (recog_data.operand, insn);
1655
1656 default:
1657 gcc_unreachable ();
1658 }
1659 }
1660
1661 /* Emit the appropriate declaration for an alternate-entry-point
1662 symbol represented by INSN, to FILE. INSN is a CODE_LABEL with
1663 LABEL_KIND != LABEL_NORMAL.
1664
1665 The case fall-through in this function is intentional. */
1666 static void
1667 output_alternate_entry_point (FILE *file, rtx insn)
1668 {
1669 const char *name = LABEL_NAME (insn);
1670
1671 switch (LABEL_KIND (insn))
1672 {
1673 case LABEL_WEAK_ENTRY:
1674 #ifdef ASM_WEAKEN_LABEL
1675 ASM_WEAKEN_LABEL (file, name);
1676 #endif
1677 case LABEL_GLOBAL_ENTRY:
1678 targetm.asm_out.globalize_label (file, name);
1679 case LABEL_STATIC_ENTRY:
1680 #ifdef ASM_OUTPUT_TYPE_DIRECTIVE
1681 ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "function");
1682 #endif
1683 ASM_OUTPUT_LABEL (file, name);
1684 break;
1685
1686 case LABEL_NORMAL:
1687 default:
1688 gcc_unreachable ();
1689 }
1690 }
1691
1692 /* The final scan for one insn, INSN.
1693 Args are same as in `final', except that INSN
1694 is the insn being scanned.
1695 Value returned is the next insn to be scanned.
1696
1697 NOPEEPHOLES is the flag to disallow peephole processing (currently
1698 used for within delayed branch sequence output).
1699
1700 SEEN is used to track the end of the prologue, for emitting
1701 debug information. We force the emission of a line note after
1702 both NOTE_INSN_PROLOGUE_END and NOTE_INSN_FUNCTION_BEG, or
1703 at the beginning of the second basic block, whichever comes
1704 first. */
1705
1706 rtx
1707 final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
1708 int nopeepholes ATTRIBUTE_UNUSED, int *seen)
1709 {
1710 #ifdef HAVE_cc0
1711 rtx set;
1712 #endif
1713 rtx next;
1714
1715 insn_counter++;
1716
1717 /* Ignore deleted insns. These can occur when we split insns (due to a
1718 template of "#") while not optimizing. */
1719 if (INSN_DELETED_P (insn))
1720 return NEXT_INSN (insn);
1721
1722 switch (GET_CODE (insn))
1723 {
1724 case NOTE:
1725 switch (NOTE_KIND (insn))
1726 {
1727 case NOTE_INSN_DELETED:
1728 break;
1729
1730 case NOTE_INSN_SWITCH_TEXT_SECTIONS:
1731 in_cold_section_p = !in_cold_section_p;
1732 (*debug_hooks->switch_text_section) ();
1733 switch_to_section (current_function_section ());
1734 break;
1735
1736 case NOTE_INSN_BASIC_BLOCK:
1737 #ifdef TARGET_UNWIND_INFO
1738 targetm.asm_out.unwind_emit (asm_out_file, insn);
1739 #endif
1740
1741 if (flag_debug_asm)
1742 fprintf (asm_out_file, "\t%s basic block %d\n",
1743 ASM_COMMENT_START, NOTE_BASIC_BLOCK (insn)->index);
1744
1745 if ((*seen & (SEEN_EMITTED | SEEN_BB)) == SEEN_BB)
1746 {
1747 *seen |= SEEN_EMITTED;
1748 force_source_line = true;
1749 }
1750 else
1751 *seen |= SEEN_BB;
1752
1753 break;
1754
1755 case NOTE_INSN_EH_REGION_BEG:
1756 ASM_OUTPUT_DEBUG_LABEL (asm_out_file, "LEHB",
1757 NOTE_EH_HANDLER (insn));
1758 break;
1759
1760 case NOTE_INSN_EH_REGION_END:
1761 ASM_OUTPUT_DEBUG_LABEL (asm_out_file, "LEHE",
1762 NOTE_EH_HANDLER (insn));
1763 break;
1764
1765 case NOTE_INSN_PROLOGUE_END:
1766 targetm.asm_out.function_end_prologue (file);
1767 profile_after_prologue (file);
1768
1769 if ((*seen & (SEEN_EMITTED | SEEN_NOTE)) == SEEN_NOTE)
1770 {
1771 *seen |= SEEN_EMITTED;
1772 force_source_line = true;
1773 }
1774 else
1775 *seen |= SEEN_NOTE;
1776
1777 break;
1778
1779 case NOTE_INSN_EPILOGUE_BEG:
1780 targetm.asm_out.function_begin_epilogue (file);
1781 break;
1782
1783 case NOTE_INSN_FUNCTION_BEG:
1784 app_disable ();
1785 (*debug_hooks->end_prologue) (last_linenum, last_filename);
1786
1787 if ((*seen & (SEEN_EMITTED | SEEN_NOTE)) == SEEN_NOTE)
1788 {
1789 *seen |= SEEN_EMITTED;
1790 force_source_line = true;
1791 }
1792 else
1793 *seen |= SEEN_NOTE;
1794
1795 break;
1796
1797 case NOTE_INSN_BLOCK_BEG:
1798 if (debug_info_level == DINFO_LEVEL_NORMAL
1799 || debug_info_level == DINFO_LEVEL_VERBOSE
1800 || write_symbols == DWARF2_DEBUG
1801 || write_symbols == VMS_AND_DWARF2_DEBUG
1802 || write_symbols == VMS_DEBUG)
1803 {
1804 int n = BLOCK_NUMBER (NOTE_BLOCK (insn));
1805
1806 app_disable ();
1807 ++block_depth;
1808 high_block_linenum = last_linenum;
1809
1810 /* Output debugging info about the symbol-block beginning. */
1811 (*debug_hooks->begin_block) (last_linenum, n);
1812
1813 /* Mark this block as output. */
1814 TREE_ASM_WRITTEN (NOTE_BLOCK (insn)) = 1;
1815 }
1816 break;
1817
1818 case NOTE_INSN_BLOCK_END:
1819 if (debug_info_level == DINFO_LEVEL_NORMAL
1820 || debug_info_level == DINFO_LEVEL_VERBOSE
1821 || write_symbols == DWARF2_DEBUG
1822 || write_symbols == VMS_AND_DWARF2_DEBUG
1823 || write_symbols == VMS_DEBUG)
1824 {
1825 int n = BLOCK_NUMBER (NOTE_BLOCK (insn));
1826
1827 app_disable ();
1828
1829 /* End of a symbol-block. */
1830 --block_depth;
1831 gcc_assert (block_depth >= 0);
1832
1833 (*debug_hooks->end_block) (high_block_linenum, n);
1834 }
1835 break;
1836
1837 case NOTE_INSN_DELETED_LABEL:
1838 /* Emit the label. We may have deleted the CODE_LABEL because
1839 the label could be proved to be unreachable, though still
1840 referenced (in the form of having its address taken. */
1841 ASM_OUTPUT_DEBUG_LABEL (file, "L", CODE_LABEL_NUMBER (insn));
1842 break;
1843
1844 case NOTE_INSN_VAR_LOCATION:
1845 (*debug_hooks->var_location) (insn);
1846 break;
1847
1848 default:
1849 gcc_unreachable ();
1850 break;
1851 }
1852 break;
1853
1854 case BARRIER:
1855 #if defined (DWARF2_UNWIND_INFO)
1856 if (dwarf2out_do_frame ())
1857 dwarf2out_frame_debug (insn, false);
1858 #endif
1859 break;
1860
1861 case CODE_LABEL:
1862 /* The target port might emit labels in the output function for
1863 some insn, e.g. sh.c output_branchy_insn. */
1864 if (CODE_LABEL_NUMBER (insn) <= max_labelno)
1865 {
1866 int align = LABEL_TO_ALIGNMENT (insn);
1867 #ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
1868 int max_skip = LABEL_TO_MAX_SKIP (insn);
1869 #endif
1870
1871 if (align && NEXT_INSN (insn))
1872 {
1873 #ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
1874 ASM_OUTPUT_MAX_SKIP_ALIGN (file, align, max_skip);
1875 #else
1876 #ifdef ASM_OUTPUT_ALIGN_WITH_NOP
1877 ASM_OUTPUT_ALIGN_WITH_NOP (file, align);
1878 #else
1879 ASM_OUTPUT_ALIGN (file, align);
1880 #endif
1881 #endif
1882 }
1883 }
1884 #ifdef HAVE_cc0
1885 CC_STATUS_INIT;
1886 /* If this label is reached from only one place, set the condition
1887 codes from the instruction just before the branch. */
1888
1889 /* Disabled because some insns set cc_status in the C output code
1890 and NOTICE_UPDATE_CC alone can set incorrect status. */
1891 if (0 /* optimize && LABEL_NUSES (insn) == 1*/)
1892 {
1893 rtx jump = LABEL_REFS (insn);
1894 rtx barrier = prev_nonnote_insn (insn);
1895 rtx prev;
1896 /* If the LABEL_REFS field of this label has been set to point
1897 at a branch, the predecessor of the branch is a regular
1898 insn, and that branch is the only way to reach this label,
1899 set the condition codes based on the branch and its
1900 predecessor. */
1901 if (barrier && BARRIER_P (barrier)
1902 && jump && JUMP_P (jump)
1903 && (prev = prev_nonnote_insn (jump))
1904 && NONJUMP_INSN_P (prev))
1905 {
1906 NOTICE_UPDATE_CC (PATTERN (prev), prev);
1907 NOTICE_UPDATE_CC (PATTERN (jump), jump);
1908 }
1909 }
1910 #endif
1911
1912 if (LABEL_NAME (insn))
1913 (*debug_hooks->label) (insn);
1914
1915 if (app_on)
1916 {
1917 fputs (ASM_APP_OFF, file);
1918 app_on = 0;
1919 }
1920
1921 next = next_nonnote_insn (insn);
1922 if (next != 0 && JUMP_P (next))
1923 {
1924 rtx nextbody = PATTERN (next);
1925
1926 /* If this label is followed by a jump-table,
1927 make sure we put the label in the read-only section. Also
1928 possibly write the label and jump table together. */
1929
1930 if (GET_CODE (nextbody) == ADDR_VEC
1931 || GET_CODE (nextbody) == ADDR_DIFF_VEC)
1932 {
1933 #if defined(ASM_OUTPUT_ADDR_VEC) || defined(ASM_OUTPUT_ADDR_DIFF_VEC)
1934 /* In this case, the case vector is being moved by the
1935 target, so don't output the label at all. Leave that
1936 to the back end macros. */
1937 #else
1938 if (! JUMP_TABLES_IN_TEXT_SECTION)
1939 {
1940 int log_align;
1941
1942 switch_to_section (targetm.asm_out.function_rodata_section
1943 (current_function_decl));
1944
1945 #ifdef ADDR_VEC_ALIGN
1946 log_align = ADDR_VEC_ALIGN (next);
1947 #else
1948 log_align = exact_log2 (BIGGEST_ALIGNMENT / BITS_PER_UNIT);
1949 #endif
1950 ASM_OUTPUT_ALIGN (file, log_align);
1951 }
1952 else
1953 switch_to_section (current_function_section ());
1954
1955 #ifdef ASM_OUTPUT_CASE_LABEL
1956 ASM_OUTPUT_CASE_LABEL (file, "L", CODE_LABEL_NUMBER (insn),
1957 next);
1958 #else
1959 targetm.asm_out.internal_label (file, "L", CODE_LABEL_NUMBER (insn));
1960 #endif
1961 #endif
1962 break;
1963 }
1964 }
1965 if (LABEL_ALT_ENTRY_P (insn))
1966 output_alternate_entry_point (file, insn);
1967 else
1968 targetm.asm_out.internal_label (file, "L", CODE_LABEL_NUMBER (insn));
1969 break;
1970
1971 default:
1972 {
1973 rtx body = PATTERN (insn);
1974 int insn_code_number;
1975 const char *template;
1976
1977 #ifdef HAVE_conditional_execution
1978 /* Reset this early so it is correct for ASM statements. */
1979 current_insn_predicate = NULL_RTX;
1980 #endif
1981 /* An INSN, JUMP_INSN or CALL_INSN.
1982 First check for special kinds that recog doesn't recognize. */
1983
1984 if (GET_CODE (body) == USE /* These are just declarations. */
1985 || GET_CODE (body) == CLOBBER)
1986 break;
1987
1988 #ifdef HAVE_cc0
1989 {
1990 /* If there is a REG_CC_SETTER note on this insn, it means that
1991 the setting of the condition code was done in the delay slot
1992 of the insn that branched here. So recover the cc status
1993 from the insn that set it. */
1994
1995 rtx note = find_reg_note (insn, REG_CC_SETTER, NULL_RTX);
1996 if (note)
1997 {
1998 NOTICE_UPDATE_CC (PATTERN (XEXP (note, 0)), XEXP (note, 0));
1999 cc_prev_status = cc_status;
2000 }
2001 }
2002 #endif
2003
2004 /* Detect insns that are really jump-tables
2005 and output them as such. */
2006
2007 if (GET_CODE (body) == ADDR_VEC || GET_CODE (body) == ADDR_DIFF_VEC)
2008 {
2009 #if !(defined(ASM_OUTPUT_ADDR_VEC) || defined(ASM_OUTPUT_ADDR_DIFF_VEC))
2010 int vlen, idx;
2011 #endif
2012
2013 if (! JUMP_TABLES_IN_TEXT_SECTION)
2014 switch_to_section (targetm.asm_out.function_rodata_section
2015 (current_function_decl));
2016 else
2017 switch_to_section (current_function_section ());
2018
2019 if (app_on)
2020 {
2021 fputs (ASM_APP_OFF, file);
2022 app_on = 0;
2023 }
2024
2025 #if defined(ASM_OUTPUT_ADDR_VEC) || defined(ASM_OUTPUT_ADDR_DIFF_VEC)
2026 if (GET_CODE (body) == ADDR_VEC)
2027 {
2028 #ifdef ASM_OUTPUT_ADDR_VEC
2029 ASM_OUTPUT_ADDR_VEC (PREV_INSN (insn), body);
2030 #else
2031 gcc_unreachable ();
2032 #endif
2033 }
2034 else
2035 {
2036 #ifdef ASM_OUTPUT_ADDR_DIFF_VEC
2037 ASM_OUTPUT_ADDR_DIFF_VEC (PREV_INSN (insn), body);
2038 #else
2039 gcc_unreachable ();
2040 #endif
2041 }
2042 #else
2043 vlen = XVECLEN (body, GET_CODE (body) == ADDR_DIFF_VEC);
2044 for (idx = 0; idx < vlen; idx++)
2045 {
2046 if (GET_CODE (body) == ADDR_VEC)
2047 {
2048 #ifdef ASM_OUTPUT_ADDR_VEC_ELT
2049 ASM_OUTPUT_ADDR_VEC_ELT
2050 (file, CODE_LABEL_NUMBER (XEXP (XVECEXP (body, 0, idx), 0)));
2051 #else
2052 gcc_unreachable ();
2053 #endif
2054 }
2055 else
2056 {
2057 #ifdef ASM_OUTPUT_ADDR_DIFF_ELT
2058 ASM_OUTPUT_ADDR_DIFF_ELT
2059 (file,
2060 body,
2061 CODE_LABEL_NUMBER (XEXP (XVECEXP (body, 1, idx), 0)),
2062 CODE_LABEL_NUMBER (XEXP (XEXP (body, 0), 0)));
2063 #else
2064 gcc_unreachable ();
2065 #endif
2066 }
2067 }
2068 #ifdef ASM_OUTPUT_CASE_END
2069 ASM_OUTPUT_CASE_END (file,
2070 CODE_LABEL_NUMBER (PREV_INSN (insn)),
2071 insn);
2072 #endif
2073 #endif
2074
2075 switch_to_section (current_function_section ());
2076
2077 break;
2078 }
2079 /* Output this line note if it is the first or the last line
2080 note in a row. */
2081 if (notice_source_line (insn))
2082 {
2083 (*debug_hooks->source_line) (last_linenum, last_filename);
2084 }
2085
2086 if (GET_CODE (body) == ASM_INPUT)
2087 {
2088 const char *string = XSTR (body, 0);
2089
2090 /* There's no telling what that did to the condition codes. */
2091 CC_STATUS_INIT;
2092
2093 if (string[0])
2094 {
2095 location_t loc;
2096
2097 if (! app_on)
2098 {
2099 fputs (ASM_APP_ON, file);
2100 app_on = 1;
2101 }
2102 #ifdef USE_MAPPED_LOCATION
2103 loc = ASM_INPUT_SOURCE_LOCATION (body);
2104 #else
2105 loc.file = ASM_INPUT_SOURCE_FILE (body);
2106 loc.line = ASM_INPUT_SOURCE_LINE (body);
2107 #endif
2108 if (*loc.file && loc.line)
2109 fprintf (asm_out_file, "%s %i \"%s\" 1\n",
2110 ASM_COMMENT_START, loc.line, loc.file);
2111 fprintf (asm_out_file, "\t%s\n", string);
2112 #if HAVE_AS_LINE_ZERO
2113 if (*loc.file && loc.line)
2114 fprintf (asm_out_file, "%s 0 \"\" 2\n", ASM_COMMENT_START);
2115 #endif
2116 }
2117 break;
2118 }
2119
2120 /* Detect `asm' construct with operands. */
2121 if (asm_noperands (body) >= 0)
2122 {
2123 unsigned int noperands = asm_noperands (body);
2124 rtx *ops = alloca (noperands * sizeof (rtx));
2125 const char *string;
2126 location_t loc;
2127
2128 /* There's no telling what that did to the condition codes. */
2129 CC_STATUS_INIT;
2130
2131 /* Get out the operand values. */
2132 string = decode_asm_operands (body, ops, NULL, NULL, NULL, &loc);
2133 /* Inhibit dieing on what would otherwise be compiler bugs. */
2134 insn_noperands = noperands;
2135 this_is_asm_operands = insn;
2136
2137 #ifdef FINAL_PRESCAN_INSN
2138 FINAL_PRESCAN_INSN (insn, ops, insn_noperands);
2139 #endif
2140
2141 /* Output the insn using them. */
2142 if (string[0])
2143 {
2144 if (! app_on)
2145 {
2146 fputs (ASM_APP_ON, file);
2147 app_on = 1;
2148 }
2149 if (loc.file && loc.line)
2150 fprintf (asm_out_file, "%s %i \"%s\" 1\n",
2151 ASM_COMMENT_START, loc.line, loc.file);
2152 output_asm_insn (string, ops);
2153 #if HAVE_AS_LINE_ZERO
2154 if (loc.file && loc.line)
2155 fprintf (asm_out_file, "%s 0 \"\" 2\n", ASM_COMMENT_START);
2156 #endif
2157 }
2158
2159 this_is_asm_operands = 0;
2160 break;
2161 }
2162
2163 if (app_on)
2164 {
2165 fputs (ASM_APP_OFF, file);
2166 app_on = 0;
2167 }
2168
2169 if (GET_CODE (body) == SEQUENCE)
2170 {
2171 /* A delayed-branch sequence */
2172 int i;
2173
2174 final_sequence = body;
2175
2176 /* Record the delay slots' frame information before the branch.
2177 This is needed for delayed calls: see execute_cfa_program(). */
2178 #if defined (DWARF2_UNWIND_INFO)
2179 if (dwarf2out_do_frame ())
2180 for (i = 1; i < XVECLEN (body, 0); i++)
2181 dwarf2out_frame_debug (XVECEXP (body, 0, i), false);
2182 #endif
2183
2184 /* The first insn in this SEQUENCE might be a JUMP_INSN that will
2185 force the restoration of a comparison that was previously
2186 thought unnecessary. If that happens, cancel this sequence
2187 and cause that insn to be restored. */
2188
2189 next = final_scan_insn (XVECEXP (body, 0, 0), file, 0, 1, seen);
2190 if (next != XVECEXP (body, 0, 1))
2191 {
2192 final_sequence = 0;
2193 return next;
2194 }
2195
2196 for (i = 1; i < XVECLEN (body, 0); i++)
2197 {
2198 rtx insn = XVECEXP (body, 0, i);
2199 rtx next = NEXT_INSN (insn);
2200 /* We loop in case any instruction in a delay slot gets
2201 split. */
2202 do
2203 insn = final_scan_insn (insn, file, 0, 1, seen);
2204 while (insn != next);
2205 }
2206 #ifdef DBR_OUTPUT_SEQEND
2207 DBR_OUTPUT_SEQEND (file);
2208 #endif
2209 final_sequence = 0;
2210
2211 /* If the insn requiring the delay slot was a CALL_INSN, the
2212 insns in the delay slot are actually executed before the
2213 called function. Hence we don't preserve any CC-setting
2214 actions in these insns and the CC must be marked as being
2215 clobbered by the function. */
2216 if (CALL_P (XVECEXP (body, 0, 0)))
2217 {
2218 CC_STATUS_INIT;
2219 }
2220 break;
2221 }
2222
2223 /* We have a real machine instruction as rtl. */
2224
2225 body = PATTERN (insn);
2226
2227 #ifdef HAVE_cc0
2228 set = single_set (insn);
2229
2230 /* Check for redundant test and compare instructions
2231 (when the condition codes are already set up as desired).
2232 This is done only when optimizing; if not optimizing,
2233 it should be possible for the user to alter a variable
2234 with the debugger in between statements
2235 and the next statement should reexamine the variable
2236 to compute the condition codes. */
2237
2238 if (optimize)
2239 {
2240 if (set
2241 && GET_CODE (SET_DEST (set)) == CC0
2242 && insn != last_ignored_compare)
2243 {
2244 if (GET_CODE (SET_SRC (set)) == SUBREG)
2245 SET_SRC (set) = alter_subreg (&SET_SRC (set));
2246 else if (GET_CODE (SET_SRC (set)) == COMPARE)
2247 {
2248 if (GET_CODE (XEXP (SET_SRC (set), 0)) == SUBREG)
2249 XEXP (SET_SRC (set), 0)
2250 = alter_subreg (&XEXP (SET_SRC (set), 0));
2251 if (GET_CODE (XEXP (SET_SRC (set), 1)) == SUBREG)
2252 XEXP (SET_SRC (set), 1)
2253 = alter_subreg (&XEXP (SET_SRC (set), 1));
2254 }
2255 if ((cc_status.value1 != 0
2256 && rtx_equal_p (SET_SRC (set), cc_status.value1))
2257 || (cc_status.value2 != 0
2258 && rtx_equal_p (SET_SRC (set), cc_status.value2)))
2259 {
2260 /* Don't delete insn if it has an addressing side-effect. */
2261 if (! FIND_REG_INC_NOTE (insn, NULL_RTX)
2262 /* or if anything in it is volatile. */
2263 && ! volatile_refs_p (PATTERN (insn)))
2264 {
2265 /* We don't really delete the insn; just ignore it. */
2266 last_ignored_compare = insn;
2267 break;
2268 }
2269 }
2270 }
2271 }
2272 #endif
2273
2274 #ifdef HAVE_cc0
2275 /* If this is a conditional branch, maybe modify it
2276 if the cc's are in a nonstandard state
2277 so that it accomplishes the same thing that it would
2278 do straightforwardly if the cc's were set up normally. */
2279
2280 if (cc_status.flags != 0
2281 && JUMP_P (insn)
2282 && GET_CODE (body) == SET
2283 && SET_DEST (body) == pc_rtx
2284 && GET_CODE (SET_SRC (body)) == IF_THEN_ELSE
2285 && COMPARISON_P (XEXP (SET_SRC (body), 0))
2286 && XEXP (XEXP (SET_SRC (body), 0), 0) == cc0_rtx)
2287 {
2288 /* This function may alter the contents of its argument
2289 and clear some of the cc_status.flags bits.
2290 It may also return 1 meaning condition now always true
2291 or -1 meaning condition now always false
2292 or 2 meaning condition nontrivial but altered. */
2293 int result = alter_cond (XEXP (SET_SRC (body), 0));
2294 /* If condition now has fixed value, replace the IF_THEN_ELSE
2295 with its then-operand or its else-operand. */
2296 if (result == 1)
2297 SET_SRC (body) = XEXP (SET_SRC (body), 1);
2298 if (result == -1)
2299 SET_SRC (body) = XEXP (SET_SRC (body), 2);
2300
2301 /* The jump is now either unconditional or a no-op.
2302 If it has become a no-op, don't try to output it.
2303 (It would not be recognized.) */
2304 if (SET_SRC (body) == pc_rtx)
2305 {
2306 delete_insn (insn);
2307 break;
2308 }
2309 else if (GET_CODE (SET_SRC (body)) == RETURN)
2310 /* Replace (set (pc) (return)) with (return). */
2311 PATTERN (insn) = body = SET_SRC (body);
2312
2313 /* Rerecognize the instruction if it has changed. */
2314 if (result != 0)
2315 INSN_CODE (insn) = -1;
2316 }
2317
2318 /* If this is a conditional trap, maybe modify it if the cc's
2319 are in a nonstandard state so that it accomplishes the same
2320 thing that it would do straightforwardly if the cc's were
2321 set up normally. */
2322 if (cc_status.flags != 0
2323 && NONJUMP_INSN_P (insn)
2324 && GET_CODE (body) == TRAP_IF
2325 && COMPARISON_P (TRAP_CONDITION (body))
2326 && XEXP (TRAP_CONDITION (body), 0) == cc0_rtx)
2327 {
2328 /* This function may alter the contents of its argument
2329 and clear some of the cc_status.flags bits.
2330 It may also return 1 meaning condition now always true
2331 or -1 meaning condition now always false
2332 or 2 meaning condition nontrivial but altered. */
2333 int result = alter_cond (TRAP_CONDITION (body));
2334
2335 /* If TRAP_CONDITION has become always false, delete the
2336 instruction. */
2337 if (result == -1)
2338 {
2339 delete_insn (insn);
2340 break;
2341 }
2342
2343 /* If TRAP_CONDITION has become always true, replace
2344 TRAP_CONDITION with const_true_rtx. */
2345 if (result == 1)
2346 TRAP_CONDITION (body) = const_true_rtx;
2347
2348 /* Rerecognize the instruction if it has changed. */
2349 if (result != 0)
2350 INSN_CODE (insn) = -1;
2351 }
2352
2353 /* If this is a conditional trap, maybe modify it if the cc's
2354 are in a nonstandard state so that it accomplishes the same
2355 thing that it would do straightforwardly if the cc's were
2356 set up normally. */
2357 if (cc_status.flags != 0
2358 && NONJUMP_INSN_P (insn)
2359 && GET_CODE (body) == TRAP_IF
2360 && COMPARISON_P (TRAP_CONDITION (body))
2361 && XEXP (TRAP_CONDITION (body), 0) == cc0_rtx)
2362 {
2363 /* This function may alter the contents of its argument
2364 and clear some of the cc_status.flags bits.
2365 It may also return 1 meaning condition now always true
2366 or -1 meaning condition now always false
2367 or 2 meaning condition nontrivial but altered. */
2368 int result = alter_cond (TRAP_CONDITION (body));
2369
2370 /* If TRAP_CONDITION has become always false, delete the
2371 instruction. */
2372 if (result == -1)
2373 {
2374 delete_insn (insn);
2375 break;
2376 }
2377
2378 /* If TRAP_CONDITION has become always true, replace
2379 TRAP_CONDITION with const_true_rtx. */
2380 if (result == 1)
2381 TRAP_CONDITION (body) = const_true_rtx;
2382
2383 /* Rerecognize the instruction if it has changed. */
2384 if (result != 0)
2385 INSN_CODE (insn) = -1;
2386 }
2387
2388 /* Make same adjustments to instructions that examine the
2389 condition codes without jumping and instructions that
2390 handle conditional moves (if this machine has either one). */
2391
2392 if (cc_status.flags != 0
2393 && set != 0)
2394 {
2395 rtx cond_rtx, then_rtx, else_rtx;
2396
2397 if (!JUMP_P (insn)
2398 && GET_CODE (SET_SRC (set)) == IF_THEN_ELSE)
2399 {
2400 cond_rtx = XEXP (SET_SRC (set), 0);
2401 then_rtx = XEXP (SET_SRC (set), 1);
2402 else_rtx = XEXP (SET_SRC (set), 2);
2403 }
2404 else
2405 {
2406 cond_rtx = SET_SRC (set);
2407 then_rtx = const_true_rtx;
2408 else_rtx = const0_rtx;
2409 }
2410
2411 switch (GET_CODE (cond_rtx))
2412 {
2413 case GTU:
2414 case GT:
2415 case LTU:
2416 case LT:
2417 case GEU:
2418 case GE:
2419 case LEU:
2420 case LE:
2421 case EQ:
2422 case NE:
2423 {
2424 int result;
2425 if (XEXP (cond_rtx, 0) != cc0_rtx)
2426 break;
2427 result = alter_cond (cond_rtx);
2428 if (result == 1)
2429 validate_change (insn, &SET_SRC (set), then_rtx, 0);
2430 else if (result == -1)
2431 validate_change (insn, &SET_SRC (set), else_rtx, 0);
2432 else if (result == 2)
2433 INSN_CODE (insn) = -1;
2434 if (SET_DEST (set) == SET_SRC (set))
2435 delete_insn (insn);
2436 }
2437 break;
2438
2439 default:
2440 break;
2441 }
2442 }
2443
2444 #endif
2445
2446 #ifdef HAVE_peephole
2447 /* Do machine-specific peephole optimizations if desired. */
2448
2449 if (optimize && !flag_no_peephole && !nopeepholes)
2450 {
2451 rtx next = peephole (insn);
2452 /* When peepholing, if there were notes within the peephole,
2453 emit them before the peephole. */
2454 if (next != 0 && next != NEXT_INSN (insn))
2455 {
2456 rtx note, prev = PREV_INSN (insn);
2457
2458 for (note = NEXT_INSN (insn); note != next;
2459 note = NEXT_INSN (note))
2460 final_scan_insn (note, file, optimize, nopeepholes, seen);
2461
2462 /* Put the notes in the proper position for a later
2463 rescan. For example, the SH target can do this
2464 when generating a far jump in a delayed branch
2465 sequence. */
2466 note = NEXT_INSN (insn);
2467 PREV_INSN (note) = prev;
2468 NEXT_INSN (prev) = note;
2469 NEXT_INSN (PREV_INSN (next)) = insn;
2470 PREV_INSN (insn) = PREV_INSN (next);
2471 NEXT_INSN (insn) = next;
2472 PREV_INSN (next) = insn;
2473 }
2474
2475 /* PEEPHOLE might have changed this. */
2476 body = PATTERN (insn);
2477 }
2478 #endif
2479
2480 /* Try to recognize the instruction.
2481 If successful, verify that the operands satisfy the
2482 constraints for the instruction. Crash if they don't,
2483 since `reload' should have changed them so that they do. */
2484
2485 insn_code_number = recog_memoized (insn);
2486 cleanup_subreg_operands (insn);
2487
2488 /* Dump the insn in the assembly for debugging. */
2489 if (flag_dump_rtl_in_asm)
2490 {
2491 print_rtx_head = ASM_COMMENT_START;
2492 print_rtl_single (asm_out_file, insn);
2493 print_rtx_head = "";
2494 }
2495
2496 if (! constrain_operands_cached (1))
2497 fatal_insn_not_found (insn);
2498
2499 /* Some target machines need to prescan each insn before
2500 it is output. */
2501
2502 #ifdef FINAL_PRESCAN_INSN
2503 FINAL_PRESCAN_INSN (insn, recog_data.operand, recog_data.n_operands);
2504 #endif
2505
2506 #ifdef HAVE_conditional_execution
2507 if (GET_CODE (PATTERN (insn)) == COND_EXEC)
2508 current_insn_predicate = COND_EXEC_TEST (PATTERN (insn));
2509 #endif
2510
2511 #ifdef HAVE_cc0
2512 cc_prev_status = cc_status;
2513
2514 /* Update `cc_status' for this instruction.
2515 The instruction's output routine may change it further.
2516 If the output routine for a jump insn needs to depend
2517 on the cc status, it should look at cc_prev_status. */
2518
2519 NOTICE_UPDATE_CC (body, insn);
2520 #endif
2521
2522 current_output_insn = debug_insn = insn;
2523
2524 #if defined (DWARF2_UNWIND_INFO)
2525 if (CALL_P (insn) && dwarf2out_do_frame ())
2526 dwarf2out_frame_debug (insn, false);
2527 #endif
2528
2529 /* Find the proper template for this insn. */
2530 template = get_insn_template (insn_code_number, insn);
2531
2532 /* If the C code returns 0, it means that it is a jump insn
2533 which follows a deleted test insn, and that test insn
2534 needs to be reinserted. */
2535 if (template == 0)
2536 {
2537 rtx prev;
2538
2539 gcc_assert (prev_nonnote_insn (insn) == last_ignored_compare);
2540
2541 /* We have already processed the notes between the setter and
2542 the user. Make sure we don't process them again, this is
2543 particularly important if one of the notes is a block
2544 scope note or an EH note. */
2545 for (prev = insn;
2546 prev != last_ignored_compare;
2547 prev = PREV_INSN (prev))
2548 {
2549 if (NOTE_P (prev))
2550 delete_insn (prev); /* Use delete_note. */
2551 }
2552
2553 return prev;
2554 }
2555
2556 /* If the template is the string "#", it means that this insn must
2557 be split. */
2558 if (template[0] == '#' && template[1] == '\0')
2559 {
2560 rtx new = try_split (body, insn, 0);
2561
2562 /* If we didn't split the insn, go away. */
2563 if (new == insn && PATTERN (new) == body)
2564 fatal_insn ("could not split insn", insn);
2565
2566 #ifdef HAVE_ATTR_length
2567 /* This instruction should have been split in shorten_branches,
2568 to ensure that we would have valid length info for the
2569 splitees. */
2570 gcc_unreachable ();
2571 #endif
2572
2573 return new;
2574 }
2575
2576 #ifdef TARGET_UNWIND_INFO
2577 /* ??? This will put the directives in the wrong place if
2578 get_insn_template outputs assembly directly. However calling it
2579 before get_insn_template breaks if the insns is split. */
2580 targetm.asm_out.unwind_emit (asm_out_file, insn);
2581 #endif
2582
2583 /* Output assembler code from the template. */
2584 output_asm_insn (template, recog_data.operand);
2585
2586 /* If necessary, report the effect that the instruction has on
2587 the unwind info. We've already done this for delay slots
2588 and call instructions. */
2589 #if defined (DWARF2_UNWIND_INFO)
2590 if (final_sequence == 0
2591 #if !defined (HAVE_prologue)
2592 && !ACCUMULATE_OUTGOING_ARGS
2593 #endif
2594 && dwarf2out_do_frame ())
2595 dwarf2out_frame_debug (insn, true);
2596 #endif
2597
2598 current_output_insn = debug_insn = 0;
2599 }
2600 }
2601 return NEXT_INSN (insn);
2602 }
2603 \f
2604 /* Return whether a source line note needs to be emitted before INSN. */
2605
2606 static bool
2607 notice_source_line (rtx insn)
2608 {
2609 const char *filename = insn_file (insn);
2610 int linenum = insn_line (insn);
2611
2612 if (filename
2613 && (force_source_line
2614 || filename != last_filename
2615 || last_linenum != linenum))
2616 {
2617 force_source_line = false;
2618 last_filename = filename;
2619 last_linenum = linenum;
2620 high_block_linenum = MAX (last_linenum, high_block_linenum);
2621 high_function_linenum = MAX (last_linenum, high_function_linenum);
2622 return true;
2623 }
2624 return false;
2625 }
2626 \f
2627 /* For each operand in INSN, simplify (subreg (reg)) so that it refers
2628 directly to the desired hard register. */
2629
2630 void
2631 cleanup_subreg_operands (rtx insn)
2632 {
2633 int i;
2634 bool changed = false;
2635 extract_insn_cached (insn);
2636 for (i = 0; i < recog_data.n_operands; i++)
2637 {
2638 /* The following test cannot use recog_data.operand when testing
2639 for a SUBREG: the underlying object might have been changed
2640 already if we are inside a match_operator expression that
2641 matches the else clause. Instead we test the underlying
2642 expression directly. */
2643 if (GET_CODE (*recog_data.operand_loc[i]) == SUBREG)
2644 {
2645 recog_data.operand[i] = alter_subreg (recog_data.operand_loc[i]);
2646 changed = true;
2647 }
2648 else if (GET_CODE (recog_data.operand[i]) == PLUS
2649 || GET_CODE (recog_data.operand[i]) == MULT
2650 || MEM_P (recog_data.operand[i]))
2651 recog_data.operand[i] = walk_alter_subreg (recog_data.operand_loc[i], &changed);
2652 }
2653
2654 for (i = 0; i < recog_data.n_dups; i++)
2655 {
2656 if (GET_CODE (*recog_data.dup_loc[i]) == SUBREG)
2657 {
2658 *recog_data.dup_loc[i] = alter_subreg (recog_data.dup_loc[i]);
2659 changed = true;
2660 }
2661 else if (GET_CODE (*recog_data.dup_loc[i]) == PLUS
2662 || GET_CODE (*recog_data.dup_loc[i]) == MULT
2663 || MEM_P (*recog_data.dup_loc[i]))
2664 *recog_data.dup_loc[i] = walk_alter_subreg (recog_data.dup_loc[i], &changed);
2665 }
2666 if (changed)
2667 df_insn_rescan (insn);
2668 }
2669
2670 /* If X is a SUBREG, replace it with a REG or a MEM,
2671 based on the thing it is a subreg of. */
2672
2673 rtx
2674 alter_subreg (rtx *xp)
2675 {
2676 rtx x = *xp;
2677 rtx y = SUBREG_REG (x);
2678
2679 /* simplify_subreg does not remove subreg from volatile references.
2680 We are required to. */
2681 if (MEM_P (y))
2682 {
2683 int offset = SUBREG_BYTE (x);
2684
2685 /* For paradoxical subregs on big-endian machines, SUBREG_BYTE
2686 contains 0 instead of the proper offset. See simplify_subreg. */
2687 if (offset == 0
2688 && GET_MODE_SIZE (GET_MODE (y)) < GET_MODE_SIZE (GET_MODE (x)))
2689 {
2690 int difference = GET_MODE_SIZE (GET_MODE (y))
2691 - GET_MODE_SIZE (GET_MODE (x));
2692 if (WORDS_BIG_ENDIAN)
2693 offset += (difference / UNITS_PER_WORD) * UNITS_PER_WORD;
2694 if (BYTES_BIG_ENDIAN)
2695 offset += difference % UNITS_PER_WORD;
2696 }
2697
2698 *xp = adjust_address (y, GET_MODE (x), offset);
2699 }
2700 else
2701 {
2702 rtx new = simplify_subreg (GET_MODE (x), y, GET_MODE (y),
2703 SUBREG_BYTE (x));
2704
2705 if (new != 0)
2706 *xp = new;
2707 else if (REG_P (y))
2708 {
2709 /* Simplify_subreg can't handle some REG cases, but we have to. */
2710 unsigned int regno = subreg_regno (x);
2711 *xp = gen_rtx_REG_offset (y, GET_MODE (x), regno, SUBREG_BYTE (x));
2712 }
2713 }
2714
2715 return *xp;
2716 }
2717
2718 /* Do alter_subreg on all the SUBREGs contained in X. */
2719
2720 static rtx
2721 walk_alter_subreg (rtx *xp, bool *changed)
2722 {
2723 rtx x = *xp;
2724 switch (GET_CODE (x))
2725 {
2726 case PLUS:
2727 case MULT:
2728 case AND:
2729 XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0), changed);
2730 XEXP (x, 1) = walk_alter_subreg (&XEXP (x, 1), changed);
2731 break;
2732
2733 case MEM:
2734 case ZERO_EXTEND:
2735 XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0), changed);
2736 break;
2737
2738 case SUBREG:
2739 *changed = true;
2740 return alter_subreg (xp);
2741
2742 default:
2743 break;
2744 }
2745
2746 return *xp;
2747 }
2748 \f
2749 #ifdef HAVE_cc0
2750
2751 /* Given BODY, the body of a jump instruction, alter the jump condition
2752 as required by the bits that are set in cc_status.flags.
2753 Not all of the bits there can be handled at this level in all cases.
2754
2755 The value is normally 0.
2756 1 means that the condition has become always true.
2757 -1 means that the condition has become always false.
2758 2 means that COND has been altered. */
2759
2760 static int
2761 alter_cond (rtx cond)
2762 {
2763 int value = 0;
2764
2765 if (cc_status.flags & CC_REVERSED)
2766 {
2767 value = 2;
2768 PUT_CODE (cond, swap_condition (GET_CODE (cond)));
2769 }
2770
2771 if (cc_status.flags & CC_INVERTED)
2772 {
2773 value = 2;
2774 PUT_CODE (cond, reverse_condition (GET_CODE (cond)));
2775 }
2776
2777 if (cc_status.flags & CC_NOT_POSITIVE)
2778 switch (GET_CODE (cond))
2779 {
2780 case LE:
2781 case LEU:
2782 case GEU:
2783 /* Jump becomes unconditional. */
2784 return 1;
2785
2786 case GT:
2787 case GTU:
2788 case LTU:
2789 /* Jump becomes no-op. */
2790 return -1;
2791
2792 case GE:
2793 PUT_CODE (cond, EQ);
2794 value = 2;
2795 break;
2796
2797 case LT:
2798 PUT_CODE (cond, NE);
2799 value = 2;
2800 break;
2801
2802 default:
2803 break;
2804 }
2805
2806 if (cc_status.flags & CC_NOT_NEGATIVE)
2807 switch (GET_CODE (cond))
2808 {
2809 case GE:
2810 case GEU:
2811 /* Jump becomes unconditional. */
2812 return 1;
2813
2814 case LT:
2815 case LTU:
2816 /* Jump becomes no-op. */
2817 return -1;
2818
2819 case LE:
2820 case LEU:
2821 PUT_CODE (cond, EQ);
2822 value = 2;
2823 break;
2824
2825 case GT:
2826 case GTU:
2827 PUT_CODE (cond, NE);
2828 value = 2;
2829 break;
2830
2831 default:
2832 break;
2833 }
2834
2835 if (cc_status.flags & CC_NO_OVERFLOW)
2836 switch (GET_CODE (cond))
2837 {
2838 case GEU:
2839 /* Jump becomes unconditional. */
2840 return 1;
2841
2842 case LEU:
2843 PUT_CODE (cond, EQ);
2844 value = 2;
2845 break;
2846
2847 case GTU:
2848 PUT_CODE (cond, NE);
2849 value = 2;
2850 break;
2851
2852 case LTU:
2853 /* Jump becomes no-op. */
2854 return -1;
2855
2856 default:
2857 break;
2858 }
2859
2860 if (cc_status.flags & (CC_Z_IN_NOT_N | CC_Z_IN_N))
2861 switch (GET_CODE (cond))
2862 {
2863 default:
2864 gcc_unreachable ();
2865
2866 case NE:
2867 PUT_CODE (cond, cc_status.flags & CC_Z_IN_N ? GE : LT);
2868 value = 2;
2869 break;
2870
2871 case EQ:
2872 PUT_CODE (cond, cc_status.flags & CC_Z_IN_N ? LT : GE);
2873 value = 2;
2874 break;
2875 }
2876
2877 if (cc_status.flags & CC_NOT_SIGNED)
2878 /* The flags are valid if signed condition operators are converted
2879 to unsigned. */
2880 switch (GET_CODE (cond))
2881 {
2882 case LE:
2883 PUT_CODE (cond, LEU);
2884 value = 2;
2885 break;
2886
2887 case LT:
2888 PUT_CODE (cond, LTU);
2889 value = 2;
2890 break;
2891
2892 case GT:
2893 PUT_CODE (cond, GTU);
2894 value = 2;
2895 break;
2896
2897 case GE:
2898 PUT_CODE (cond, GEU);
2899 value = 2;
2900 break;
2901
2902 default:
2903 break;
2904 }
2905
2906 return value;
2907 }
2908 #endif
2909 \f
2910 /* Report inconsistency between the assembler template and the operands.
2911 In an `asm', it's the user's fault; otherwise, the compiler's fault. */
2912
2913 void
2914 output_operand_lossage (const char *cmsgid, ...)
2915 {
2916 char *fmt_string;
2917 char *new_message;
2918 const char *pfx_str;
2919 va_list ap;
2920
2921 va_start (ap, cmsgid);
2922
2923 pfx_str = this_is_asm_operands ? _("invalid 'asm': ") : "output_operand: ";
2924 asprintf (&fmt_string, "%s%s", pfx_str, _(cmsgid));
2925 vasprintf (&new_message, fmt_string, ap);
2926
2927 if (this_is_asm_operands)
2928 error_for_asm (this_is_asm_operands, "%s", new_message);
2929 else
2930 internal_error ("%s", new_message);
2931
2932 free (fmt_string);
2933 free (new_message);
2934 va_end (ap);
2935 }
2936 \f
2937 /* Output of assembler code from a template, and its subroutines. */
2938
2939 /* Annotate the assembly with a comment describing the pattern and
2940 alternative used. */
2941
2942 static void
2943 output_asm_name (void)
2944 {
2945 if (debug_insn)
2946 {
2947 int num = INSN_CODE (debug_insn);
2948 fprintf (asm_out_file, "\t%s %d\t%s",
2949 ASM_COMMENT_START, INSN_UID (debug_insn),
2950 insn_data[num].name);
2951 if (insn_data[num].n_alternatives > 1)
2952 fprintf (asm_out_file, "/%d", which_alternative + 1);
2953 #ifdef HAVE_ATTR_length
2954 fprintf (asm_out_file, "\t[length = %d]",
2955 get_attr_length (debug_insn));
2956 #endif
2957 /* Clear this so only the first assembler insn
2958 of any rtl insn will get the special comment for -dp. */
2959 debug_insn = 0;
2960 }
2961 }
2962
2963 /* If OP is a REG or MEM and we can find a MEM_EXPR corresponding to it
2964 or its address, return that expr . Set *PADDRESSP to 1 if the expr
2965 corresponds to the address of the object and 0 if to the object. */
2966
2967 static tree
2968 get_mem_expr_from_op (rtx op, int *paddressp)
2969 {
2970 tree expr;
2971 int inner_addressp;
2972
2973 *paddressp = 0;
2974
2975 if (REG_P (op))
2976 return REG_EXPR (op);
2977 else if (!MEM_P (op))
2978 return 0;
2979
2980 if (MEM_EXPR (op) != 0)
2981 return MEM_EXPR (op);
2982
2983 /* Otherwise we have an address, so indicate it and look at the address. */
2984 *paddressp = 1;
2985 op = XEXP (op, 0);
2986
2987 /* First check if we have a decl for the address, then look at the right side
2988 if it is a PLUS. Otherwise, strip off arithmetic and keep looking.
2989 But don't allow the address to itself be indirect. */
2990 if ((expr = get_mem_expr_from_op (op, &inner_addressp)) && ! inner_addressp)
2991 return expr;
2992 else if (GET_CODE (op) == PLUS
2993 && (expr = get_mem_expr_from_op (XEXP (op, 1), &inner_addressp)))
2994 return expr;
2995
2996 while (GET_RTX_CLASS (GET_CODE (op)) == RTX_UNARY
2997 || GET_RTX_CLASS (GET_CODE (op)) == RTX_BIN_ARITH)
2998 op = XEXP (op, 0);
2999
3000 expr = get_mem_expr_from_op (op, &inner_addressp);
3001 return inner_addressp ? 0 : expr;
3002 }
3003
3004 /* Output operand names for assembler instructions. OPERANDS is the
3005 operand vector, OPORDER is the order to write the operands, and NOPS
3006 is the number of operands to write. */
3007
3008 static void
3009 output_asm_operand_names (rtx *operands, int *oporder, int nops)
3010 {
3011 int wrote = 0;
3012 int i;
3013
3014 for (i = 0; i < nops; i++)
3015 {
3016 int addressp;
3017 rtx op = operands[oporder[i]];
3018 tree expr = get_mem_expr_from_op (op, &addressp);
3019
3020 fprintf (asm_out_file, "%c%s",
3021 wrote ? ',' : '\t', wrote ? "" : ASM_COMMENT_START);
3022 wrote = 1;
3023 if (expr)
3024 {
3025 fprintf (asm_out_file, "%s",
3026 addressp ? "*" : "");
3027 print_mem_expr (asm_out_file, expr);
3028 wrote = 1;
3029 }
3030 else if (REG_P (op) && ORIGINAL_REGNO (op)
3031 && ORIGINAL_REGNO (op) != REGNO (op))
3032 fprintf (asm_out_file, " tmp%i", ORIGINAL_REGNO (op));
3033 }
3034 }
3035
3036 /* Output text from TEMPLATE to the assembler output file,
3037 obeying %-directions to substitute operands taken from
3038 the vector OPERANDS.
3039
3040 %N (for N a digit) means print operand N in usual manner.
3041 %lN means require operand N to be a CODE_LABEL or LABEL_REF
3042 and print the label name with no punctuation.
3043 %cN means require operand N to be a constant
3044 and print the constant expression with no punctuation.
3045 %aN means expect operand N to be a memory address
3046 (not a memory reference!) and print a reference
3047 to that address.
3048 %nN means expect operand N to be a constant
3049 and print a constant expression for minus the value
3050 of the operand, with no other punctuation. */
3051
3052 void
3053 output_asm_insn (const char *template, rtx *operands)
3054 {
3055 const char *p;
3056 int c;
3057 #ifdef ASSEMBLER_DIALECT
3058 int dialect = 0;
3059 #endif
3060 int oporder[MAX_RECOG_OPERANDS];
3061 char opoutput[MAX_RECOG_OPERANDS];
3062 int ops = 0;
3063
3064 /* An insn may return a null string template
3065 in a case where no assembler code is needed. */
3066 if (*template == 0)
3067 return;
3068
3069 memset (opoutput, 0, sizeof opoutput);
3070 p = template;
3071 putc ('\t', asm_out_file);
3072
3073 #ifdef ASM_OUTPUT_OPCODE
3074 ASM_OUTPUT_OPCODE (asm_out_file, p);
3075 #endif
3076
3077 while ((c = *p++))
3078 switch (c)
3079 {
3080 case '\n':
3081 if (flag_verbose_asm)
3082 output_asm_operand_names (operands, oporder, ops);
3083 if (flag_print_asm_name)
3084 output_asm_name ();
3085
3086 ops = 0;
3087 memset (opoutput, 0, sizeof opoutput);
3088
3089 putc (c, asm_out_file);
3090 #ifdef ASM_OUTPUT_OPCODE
3091 while ((c = *p) == '\t')
3092 {
3093 putc (c, asm_out_file);
3094 p++;
3095 }
3096 ASM_OUTPUT_OPCODE (asm_out_file, p);
3097 #endif
3098 break;
3099
3100 #ifdef ASSEMBLER_DIALECT
3101 case '{':
3102 {
3103 int i;
3104
3105 if (dialect)
3106 output_operand_lossage ("nested assembly dialect alternatives");
3107 else
3108 dialect = 1;
3109
3110 /* If we want the first dialect, do nothing. Otherwise, skip
3111 DIALECT_NUMBER of strings ending with '|'. */
3112 for (i = 0; i < dialect_number; i++)
3113 {
3114 while (*p && *p != '}' && *p++ != '|')
3115 ;
3116 if (*p == '}')
3117 break;
3118 if (*p == '|')
3119 p++;
3120 }
3121
3122 if (*p == '\0')
3123 output_operand_lossage ("unterminated assembly dialect alternative");
3124 }
3125 break;
3126
3127 case '|':
3128 if (dialect)
3129 {
3130 /* Skip to close brace. */
3131 do
3132 {
3133 if (*p == '\0')
3134 {
3135 output_operand_lossage ("unterminated assembly dialect alternative");
3136 break;
3137 }
3138 }
3139 while (*p++ != '}');
3140 dialect = 0;
3141 }
3142 else
3143 putc (c, asm_out_file);
3144 break;
3145
3146 case '}':
3147 if (! dialect)
3148 putc (c, asm_out_file);
3149 dialect = 0;
3150 break;
3151 #endif
3152
3153 case '%':
3154 /* %% outputs a single %. */
3155 if (*p == '%')
3156 {
3157 p++;
3158 putc (c, asm_out_file);
3159 }
3160 /* %= outputs a number which is unique to each insn in the entire
3161 compilation. This is useful for making local labels that are
3162 referred to more than once in a given insn. */
3163 else if (*p == '=')
3164 {
3165 p++;
3166 fprintf (asm_out_file, "%d", insn_counter);
3167 }
3168 /* % followed by a letter and some digits
3169 outputs an operand in a special way depending on the letter.
3170 Letters `acln' are implemented directly.
3171 Other letters are passed to `output_operand' so that
3172 the PRINT_OPERAND macro can define them. */
3173 else if (ISALPHA (*p))
3174 {
3175 int letter = *p++;
3176 unsigned long opnum;
3177 char *endptr;
3178
3179 opnum = strtoul (p, &endptr, 10);
3180
3181 if (endptr == p)
3182 output_operand_lossage ("operand number missing "
3183 "after %%-letter");
3184 else if (this_is_asm_operands && opnum >= insn_noperands)
3185 output_operand_lossage ("operand number out of range");
3186 else if (letter == 'l')
3187 output_asm_label (operands[opnum]);
3188 else if (letter == 'a')
3189 output_address (operands[opnum]);
3190 else if (letter == 'c')
3191 {
3192 if (CONSTANT_ADDRESS_P (operands[opnum]))
3193 output_addr_const (asm_out_file, operands[opnum]);
3194 else
3195 output_operand (operands[opnum], 'c');
3196 }
3197 else if (letter == 'n')
3198 {
3199 if (GET_CODE (operands[opnum]) == CONST_INT)
3200 fprintf (asm_out_file, HOST_WIDE_INT_PRINT_DEC,
3201 - INTVAL (operands[opnum]));
3202 else
3203 {
3204 putc ('-', asm_out_file);
3205 output_addr_const (asm_out_file, operands[opnum]);
3206 }
3207 }
3208 else
3209 output_operand (operands[opnum], letter);
3210
3211 if (!opoutput[opnum])
3212 oporder[ops++] = opnum;
3213 opoutput[opnum] = 1;
3214
3215 p = endptr;
3216 c = *p;
3217 }
3218 /* % followed by a digit outputs an operand the default way. */
3219 else if (ISDIGIT (*p))
3220 {
3221 unsigned long opnum;
3222 char *endptr;
3223
3224 opnum = strtoul (p, &endptr, 10);
3225 if (this_is_asm_operands && opnum >= insn_noperands)
3226 output_operand_lossage ("operand number out of range");
3227 else
3228 output_operand (operands[opnum], 0);
3229
3230 if (!opoutput[opnum])
3231 oporder[ops++] = opnum;
3232 opoutput[opnum] = 1;
3233
3234 p = endptr;
3235 c = *p;
3236 }
3237 /* % followed by punctuation: output something for that
3238 punctuation character alone, with no operand.
3239 The PRINT_OPERAND macro decides what is actually done. */
3240 #ifdef PRINT_OPERAND_PUNCT_VALID_P
3241 else if (PRINT_OPERAND_PUNCT_VALID_P ((unsigned char) *p))
3242 output_operand (NULL_RTX, *p++);
3243 #endif
3244 else
3245 output_operand_lossage ("invalid %%-code");
3246 break;
3247
3248 default:
3249 putc (c, asm_out_file);
3250 }
3251
3252 /* Write out the variable names for operands, if we know them. */
3253 if (flag_verbose_asm)
3254 output_asm_operand_names (operands, oporder, ops);
3255 if (flag_print_asm_name)
3256 output_asm_name ();
3257
3258 putc ('\n', asm_out_file);
3259 }
3260 \f
3261 /* Output a LABEL_REF, or a bare CODE_LABEL, as an assembler symbol. */
3262
3263 void
3264 output_asm_label (rtx x)
3265 {
3266 char buf[256];
3267
3268 if (GET_CODE (x) == LABEL_REF)
3269 x = XEXP (x, 0);
3270 if (LABEL_P (x)
3271 || (NOTE_P (x)
3272 && NOTE_KIND (x) == NOTE_INSN_DELETED_LABEL))
3273 ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (x));
3274 else
3275 output_operand_lossage ("'%%l' operand isn't a label");
3276
3277 assemble_name (asm_out_file, buf);
3278 }
3279
3280 /* Print operand X using machine-dependent assembler syntax.
3281 The macro PRINT_OPERAND is defined just to control this function.
3282 CODE is a non-digit that preceded the operand-number in the % spec,
3283 such as 'z' if the spec was `%z3'. CODE is 0 if there was no char
3284 between the % and the digits.
3285 When CODE is a non-letter, X is 0.
3286
3287 The meanings of the letters are machine-dependent and controlled
3288 by PRINT_OPERAND. */
3289
3290 static void
3291 output_operand (rtx x, int code ATTRIBUTE_UNUSED)
3292 {
3293 if (x && GET_CODE (x) == SUBREG)
3294 x = alter_subreg (&x);
3295
3296 /* X must not be a pseudo reg. */
3297 gcc_assert (!x || !REG_P (x) || REGNO (x) < FIRST_PSEUDO_REGISTER);
3298
3299 PRINT_OPERAND (asm_out_file, x, code);
3300 }
3301
3302 /* Print a memory reference operand for address X
3303 using machine-dependent assembler syntax.
3304 The macro PRINT_OPERAND_ADDRESS exists just to control this function. */
3305
3306 void
3307 output_address (rtx x)
3308 {
3309 bool changed = false;
3310 walk_alter_subreg (&x, &changed);
3311 PRINT_OPERAND_ADDRESS (asm_out_file, x);
3312 }
3313 \f
3314 /* Print an integer constant expression in assembler syntax.
3315 Addition and subtraction are the only arithmetic
3316 that may appear in these expressions. */
3317
3318 void
3319 output_addr_const (FILE *file, rtx x)
3320 {
3321 char buf[256];
3322
3323 restart:
3324 switch (GET_CODE (x))
3325 {
3326 case PC:
3327 putc ('.', file);
3328 break;
3329
3330 case SYMBOL_REF:
3331 if (SYMBOL_REF_DECL (x))
3332 mark_decl_referenced (SYMBOL_REF_DECL (x));
3333 #ifdef ASM_OUTPUT_SYMBOL_REF
3334 ASM_OUTPUT_SYMBOL_REF (file, x);
3335 #else
3336 assemble_name (file, XSTR (x, 0));
3337 #endif
3338 break;
3339
3340 case LABEL_REF:
3341 x = XEXP (x, 0);
3342 /* Fall through. */
3343 case CODE_LABEL:
3344 ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (x));
3345 #ifdef ASM_OUTPUT_LABEL_REF
3346 ASM_OUTPUT_LABEL_REF (file, buf);
3347 #else
3348 assemble_name (file, buf);
3349 #endif
3350 break;
3351
3352 case CONST_INT:
3353 fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (x));
3354 break;
3355
3356 case CONST:
3357 /* This used to output parentheses around the expression,
3358 but that does not work on the 386 (either ATT or BSD assembler). */
3359 output_addr_const (file, XEXP (x, 0));
3360 break;
3361
3362 case CONST_DOUBLE:
3363 if (GET_MODE (x) == VOIDmode)
3364 {
3365 /* We can use %d if the number is one word and positive. */
3366 if (CONST_DOUBLE_HIGH (x))
3367 fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3368 CONST_DOUBLE_HIGH (x), CONST_DOUBLE_LOW (x));
3369 else if (CONST_DOUBLE_LOW (x) < 0)
3370 fprintf (file, HOST_WIDE_INT_PRINT_HEX, CONST_DOUBLE_LOW (x));
3371 else
3372 fprintf (file, HOST_WIDE_INT_PRINT_DEC, CONST_DOUBLE_LOW (x));
3373 }
3374 else
3375 /* We can't handle floating point constants;
3376 PRINT_OPERAND must handle them. */
3377 output_operand_lossage ("floating constant misused");
3378 break;
3379
3380 case PLUS:
3381 /* Some assemblers need integer constants to appear last (eg masm). */
3382 if (GET_CODE (XEXP (x, 0)) == CONST_INT)
3383 {
3384 output_addr_const (file, XEXP (x, 1));
3385 if (INTVAL (XEXP (x, 0)) >= 0)
3386 fprintf (file, "+");
3387 output_addr_const (file, XEXP (x, 0));
3388 }
3389 else
3390 {
3391 output_addr_const (file, XEXP (x, 0));
3392 if (GET_CODE (XEXP (x, 1)) != CONST_INT
3393 || INTVAL (XEXP (x, 1)) >= 0)
3394 fprintf (file, "+");
3395 output_addr_const (file, XEXP (x, 1));
3396 }
3397 break;
3398
3399 case MINUS:
3400 /* Avoid outputting things like x-x or x+5-x,
3401 since some assemblers can't handle that. */
3402 x = simplify_subtraction (x);
3403 if (GET_CODE (x) != MINUS)
3404 goto restart;
3405
3406 output_addr_const (file, XEXP (x, 0));
3407 fprintf (file, "-");
3408 if ((GET_CODE (XEXP (x, 1)) == CONST_INT && INTVAL (XEXP (x, 1)) >= 0)
3409 || GET_CODE (XEXP (x, 1)) == PC
3410 || GET_CODE (XEXP (x, 1)) == SYMBOL_REF)
3411 output_addr_const (file, XEXP (x, 1));
3412 else
3413 {
3414 fputs (targetm.asm_out.open_paren, file);
3415 output_addr_const (file, XEXP (x, 1));
3416 fputs (targetm.asm_out.close_paren, file);
3417 }
3418 break;
3419
3420 case ZERO_EXTEND:
3421 case SIGN_EXTEND:
3422 case SUBREG:
3423 output_addr_const (file, XEXP (x, 0));
3424 break;
3425
3426 default:
3427 #ifdef OUTPUT_ADDR_CONST_EXTRA
3428 OUTPUT_ADDR_CONST_EXTRA (file, x, fail);
3429 break;
3430
3431 fail:
3432 #endif
3433 output_operand_lossage ("invalid expression as operand");
3434 }
3435 }
3436 \f
3437 /* A poor man's fprintf, with the added features of %I, %R, %L, and %U.
3438 %R prints the value of REGISTER_PREFIX.
3439 %L prints the value of LOCAL_LABEL_PREFIX.
3440 %U prints the value of USER_LABEL_PREFIX.
3441 %I prints the value of IMMEDIATE_PREFIX.
3442 %O runs ASM_OUTPUT_OPCODE to transform what follows in the string.
3443 Also supported are %d, %i, %u, %x, %X, %o, %c, %s and %%.
3444
3445 We handle alternate assembler dialects here, just like output_asm_insn. */
3446
3447 void
3448 asm_fprintf (FILE *file, const char *p, ...)
3449 {
3450 char buf[10];
3451 char *q, c;
3452 va_list argptr;
3453
3454 va_start (argptr, p);
3455
3456 buf[0] = '%';
3457
3458 while ((c = *p++))
3459 switch (c)
3460 {
3461 #ifdef ASSEMBLER_DIALECT
3462 case '{':
3463 {
3464 int i;
3465
3466 /* If we want the first dialect, do nothing. Otherwise, skip
3467 DIALECT_NUMBER of strings ending with '|'. */
3468 for (i = 0; i < dialect_number; i++)
3469 {
3470 while (*p && *p++ != '|')
3471 ;
3472
3473 if (*p == '|')
3474 p++;
3475 }
3476 }
3477 break;
3478
3479 case '|':
3480 /* Skip to close brace. */
3481 while (*p && *p++ != '}')
3482 ;
3483 break;
3484
3485 case '}':
3486 break;
3487 #endif
3488
3489 case '%':
3490 c = *p++;
3491 q = &buf[1];
3492 while (strchr ("-+ #0", c))
3493 {
3494 *q++ = c;
3495 c = *p++;
3496 }
3497 while (ISDIGIT (c) || c == '.')
3498 {
3499 *q++ = c;
3500 c = *p++;
3501 }
3502 switch (c)
3503 {
3504 case '%':
3505 putc ('%', file);
3506 break;
3507
3508 case 'd': case 'i': case 'u':
3509 case 'x': case 'X': case 'o':
3510 case 'c':
3511 *q++ = c;
3512 *q = 0;
3513 fprintf (file, buf, va_arg (argptr, int));
3514 break;
3515
3516 case 'w':
3517 /* This is a prefix to the 'd', 'i', 'u', 'x', 'X', and
3518 'o' cases, but we do not check for those cases. It
3519 means that the value is a HOST_WIDE_INT, which may be
3520 either `long' or `long long'. */
3521 memcpy (q, HOST_WIDE_INT_PRINT, strlen (HOST_WIDE_INT_PRINT));
3522 q += strlen (HOST_WIDE_INT_PRINT);
3523 *q++ = *p++;
3524 *q = 0;
3525 fprintf (file, buf, va_arg (argptr, HOST_WIDE_INT));
3526 break;
3527
3528 case 'l':
3529 *q++ = c;
3530 #ifdef HAVE_LONG_LONG
3531 if (*p == 'l')
3532 {
3533 *q++ = *p++;
3534 *q++ = *p++;
3535 *q = 0;
3536 fprintf (file, buf, va_arg (argptr, long long));
3537 }
3538 else
3539 #endif
3540 {
3541 *q++ = *p++;
3542 *q = 0;
3543 fprintf (file, buf, va_arg (argptr, long));
3544 }
3545
3546 break;
3547
3548 case 's':
3549 *q++ = c;
3550 *q = 0;
3551 fprintf (file, buf, va_arg (argptr, char *));
3552 break;
3553
3554 case 'O':
3555 #ifdef ASM_OUTPUT_OPCODE
3556 ASM_OUTPUT_OPCODE (asm_out_file, p);
3557 #endif
3558 break;
3559
3560 case 'R':
3561 #ifdef REGISTER_PREFIX
3562 fprintf (file, "%s", REGISTER_PREFIX);
3563 #endif
3564 break;
3565
3566 case 'I':
3567 #ifdef IMMEDIATE_PREFIX
3568 fprintf (file, "%s", IMMEDIATE_PREFIX);
3569 #endif
3570 break;
3571
3572 case 'L':
3573 #ifdef LOCAL_LABEL_PREFIX
3574 fprintf (file, "%s", LOCAL_LABEL_PREFIX);
3575 #endif
3576 break;
3577
3578 case 'U':
3579 fputs (user_label_prefix, file);
3580 break;
3581
3582 #ifdef ASM_FPRINTF_EXTENSIONS
3583 /* Uppercase letters are reserved for general use by asm_fprintf
3584 and so are not available to target specific code. In order to
3585 prevent the ASM_FPRINTF_EXTENSIONS macro from using them then,
3586 they are defined here. As they get turned into real extensions
3587 to asm_fprintf they should be removed from this list. */
3588 case 'A': case 'B': case 'C': case 'D': case 'E':
3589 case 'F': case 'G': case 'H': case 'J': case 'K':
3590 case 'M': case 'N': case 'P': case 'Q': case 'S':
3591 case 'T': case 'V': case 'W': case 'Y': case 'Z':
3592 break;
3593
3594 ASM_FPRINTF_EXTENSIONS (file, argptr, p)
3595 #endif
3596 default:
3597 gcc_unreachable ();
3598 }
3599 break;
3600
3601 default:
3602 putc (c, file);
3603 }
3604 va_end (argptr);
3605 }
3606 \f
3607 /* Split up a CONST_DOUBLE or integer constant rtx
3608 into two rtx's for single words,
3609 storing in *FIRST the word that comes first in memory in the target
3610 and in *SECOND the other. */
3611
3612 void
3613 split_double (rtx value, rtx *first, rtx *second)
3614 {
3615 if (GET_CODE (value) == CONST_INT)
3616 {
3617 if (HOST_BITS_PER_WIDE_INT >= (2 * BITS_PER_WORD))
3618 {
3619 /* In this case the CONST_INT holds both target words.
3620 Extract the bits from it into two word-sized pieces.
3621 Sign extend each half to HOST_WIDE_INT. */
3622 unsigned HOST_WIDE_INT low, high;
3623 unsigned HOST_WIDE_INT mask, sign_bit, sign_extend;
3624
3625 /* Set sign_bit to the most significant bit of a word. */
3626 sign_bit = 1;
3627 sign_bit <<= BITS_PER_WORD - 1;
3628
3629 /* Set mask so that all bits of the word are set. We could
3630 have used 1 << BITS_PER_WORD instead of basing the
3631 calculation on sign_bit. However, on machines where
3632 HOST_BITS_PER_WIDE_INT == BITS_PER_WORD, it could cause a
3633 compiler warning, even though the code would never be
3634 executed. */
3635 mask = sign_bit << 1;
3636 mask--;
3637
3638 /* Set sign_extend as any remaining bits. */
3639 sign_extend = ~mask;
3640
3641 /* Pick the lower word and sign-extend it. */
3642 low = INTVAL (value);
3643 low &= mask;
3644 if (low & sign_bit)
3645 low |= sign_extend;
3646
3647 /* Pick the higher word, shifted to the least significant
3648 bits, and sign-extend it. */
3649 high = INTVAL (value);
3650 high >>= BITS_PER_WORD - 1;
3651 high >>= 1;
3652 high &= mask;
3653 if (high & sign_bit)
3654 high |= sign_extend;
3655
3656 /* Store the words in the target machine order. */
3657 if (WORDS_BIG_ENDIAN)
3658 {
3659 *first = GEN_INT (high);
3660 *second = GEN_INT (low);
3661 }
3662 else
3663 {
3664 *first = GEN_INT (low);
3665 *second = GEN_INT (high);
3666 }
3667 }
3668 else
3669 {
3670 /* The rule for using CONST_INT for a wider mode
3671 is that we regard the value as signed.
3672 So sign-extend it. */
3673 rtx high = (INTVAL (value) < 0 ? constm1_rtx : const0_rtx);
3674 if (WORDS_BIG_ENDIAN)
3675 {
3676 *first = high;
3677 *second = value;
3678 }
3679 else
3680 {
3681 *first = value;
3682 *second = high;
3683 }
3684 }
3685 }
3686 else if (GET_CODE (value) != CONST_DOUBLE)
3687 {
3688 if (WORDS_BIG_ENDIAN)
3689 {
3690 *first = const0_rtx;
3691 *second = value;
3692 }
3693 else
3694 {
3695 *first = value;
3696 *second = const0_rtx;
3697 }
3698 }
3699 else if (GET_MODE (value) == VOIDmode
3700 /* This is the old way we did CONST_DOUBLE integers. */
3701 || GET_MODE_CLASS (GET_MODE (value)) == MODE_INT)
3702 {
3703 /* In an integer, the words are defined as most and least significant.
3704 So order them by the target's convention. */
3705 if (WORDS_BIG_ENDIAN)
3706 {
3707 *first = GEN_INT (CONST_DOUBLE_HIGH (value));
3708 *second = GEN_INT (CONST_DOUBLE_LOW (value));
3709 }
3710 else
3711 {
3712 *first = GEN_INT (CONST_DOUBLE_LOW (value));
3713 *second = GEN_INT (CONST_DOUBLE_HIGH (value));
3714 }
3715 }
3716 else
3717 {
3718 REAL_VALUE_TYPE r;
3719 long l[2];
3720 REAL_VALUE_FROM_CONST_DOUBLE (r, value);
3721
3722 /* Note, this converts the REAL_VALUE_TYPE to the target's
3723 format, splits up the floating point double and outputs
3724 exactly 32 bits of it into each of l[0] and l[1] --
3725 not necessarily BITS_PER_WORD bits. */
3726 REAL_VALUE_TO_TARGET_DOUBLE (r, l);
3727
3728 /* If 32 bits is an entire word for the target, but not for the host,
3729 then sign-extend on the host so that the number will look the same
3730 way on the host that it would on the target. See for instance
3731 simplify_unary_operation. The #if is needed to avoid compiler
3732 warnings. */
3733
3734 #if HOST_BITS_PER_LONG > 32
3735 if (BITS_PER_WORD < HOST_BITS_PER_LONG && BITS_PER_WORD == 32)
3736 {
3737 if (l[0] & ((long) 1 << 31))
3738 l[0] |= ((long) (-1) << 32);
3739 if (l[1] & ((long) 1 << 31))
3740 l[1] |= ((long) (-1) << 32);
3741 }
3742 #endif
3743
3744 *first = GEN_INT (l[0]);
3745 *second = GEN_INT (l[1]);
3746 }
3747 }
3748 \f
3749 /* Return nonzero if this function has no function calls. */
3750
3751 int
3752 leaf_function_p (void)
3753 {
3754 rtx insn;
3755 rtx link;
3756
3757 if (current_function_profile || profile_arc_flag)
3758 return 0;
3759
3760 for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
3761 {
3762 if (CALL_P (insn)
3763 && ! SIBLING_CALL_P (insn))
3764 return 0;
3765 if (NONJUMP_INSN_P (insn)
3766 && GET_CODE (PATTERN (insn)) == SEQUENCE
3767 && CALL_P (XVECEXP (PATTERN (insn), 0, 0))
3768 && ! SIBLING_CALL_P (XVECEXP (PATTERN (insn), 0, 0)))
3769 return 0;
3770 }
3771 for (link = current_function_epilogue_delay_list;
3772 link;
3773 link = XEXP (link, 1))
3774 {
3775 insn = XEXP (link, 0);
3776
3777 if (CALL_P (insn)
3778 && ! SIBLING_CALL_P (insn))
3779 return 0;
3780 if (NONJUMP_INSN_P (insn)
3781 && GET_CODE (PATTERN (insn)) == SEQUENCE
3782 && CALL_P (XVECEXP (PATTERN (insn), 0, 0))
3783 && ! SIBLING_CALL_P (XVECEXP (PATTERN (insn), 0, 0)))
3784 return 0;
3785 }
3786
3787 return 1;
3788 }
3789
3790 /* Return 1 if branch is a forward branch.
3791 Uses insn_shuid array, so it works only in the final pass. May be used by
3792 output templates to customary add branch prediction hints.
3793 */
3794 int
3795 final_forward_branch_p (rtx insn)
3796 {
3797 int insn_id, label_id;
3798
3799 gcc_assert (uid_shuid);
3800 insn_id = INSN_SHUID (insn);
3801 label_id = INSN_SHUID (JUMP_LABEL (insn));
3802 /* We've hit some insns that does not have id information available. */
3803 gcc_assert (insn_id && label_id);
3804 return insn_id < label_id;
3805 }
3806
3807 /* On some machines, a function with no call insns
3808 can run faster if it doesn't create its own register window.
3809 When output, the leaf function should use only the "output"
3810 registers. Ordinarily, the function would be compiled to use
3811 the "input" registers to find its arguments; it is a candidate
3812 for leaf treatment if it uses only the "input" registers.
3813 Leaf function treatment means renumbering so the function
3814 uses the "output" registers instead. */
3815
3816 #ifdef LEAF_REGISTERS
3817
3818 /* Return 1 if this function uses only the registers that can be
3819 safely renumbered. */
3820
3821 int
3822 only_leaf_regs_used (void)
3823 {
3824 int i;
3825 const char *const permitted_reg_in_leaf_functions = LEAF_REGISTERS;
3826
3827 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
3828 if ((df_regs_ever_live_p (i) || global_regs[i])
3829 && ! permitted_reg_in_leaf_functions[i])
3830 return 0;
3831
3832 if (current_function_uses_pic_offset_table
3833 && pic_offset_table_rtx != 0
3834 && REG_P (pic_offset_table_rtx)
3835 && ! permitted_reg_in_leaf_functions[REGNO (pic_offset_table_rtx)])
3836 return 0;
3837
3838 return 1;
3839 }
3840
3841 /* Scan all instructions and renumber all registers into those
3842 available in leaf functions. */
3843
3844 static void
3845 leaf_renumber_regs (rtx first)
3846 {
3847 rtx insn;
3848
3849 /* Renumber only the actual patterns.
3850 The reg-notes can contain frame pointer refs,
3851 and renumbering them could crash, and should not be needed. */
3852 for (insn = first; insn; insn = NEXT_INSN (insn))
3853 if (INSN_P (insn))
3854 leaf_renumber_regs_insn (PATTERN (insn));
3855 for (insn = current_function_epilogue_delay_list;
3856 insn;
3857 insn = XEXP (insn, 1))
3858 if (INSN_P (XEXP (insn, 0)))
3859 leaf_renumber_regs_insn (PATTERN (XEXP (insn, 0)));
3860 }
3861
3862 /* Scan IN_RTX and its subexpressions, and renumber all regs into those
3863 available in leaf functions. */
3864
3865 void
3866 leaf_renumber_regs_insn (rtx in_rtx)
3867 {
3868 int i, j;
3869 const char *format_ptr;
3870
3871 if (in_rtx == 0)
3872 return;
3873
3874 /* Renumber all input-registers into output-registers.
3875 renumbered_regs would be 1 for an output-register;
3876 they */
3877
3878 if (REG_P (in_rtx))
3879 {
3880 int newreg;
3881
3882 /* Don't renumber the same reg twice. */
3883 if (in_rtx->used)
3884 return;
3885
3886 newreg = REGNO (in_rtx);
3887 /* Don't try to renumber pseudo regs. It is possible for a pseudo reg
3888 to reach here as part of a REG_NOTE. */
3889 if (newreg >= FIRST_PSEUDO_REGISTER)
3890 {
3891 in_rtx->used = 1;
3892 return;
3893 }
3894 newreg = LEAF_REG_REMAP (newreg);
3895 gcc_assert (newreg >= 0);
3896 df_set_regs_ever_live (REGNO (in_rtx), false);
3897 df_set_regs_ever_live (newreg, true);
3898 SET_REGNO (in_rtx, newreg);
3899 in_rtx->used = 1;
3900 }
3901
3902 if (INSN_P (in_rtx))
3903 {
3904 /* Inside a SEQUENCE, we find insns.
3905 Renumber just the patterns of these insns,
3906 just as we do for the top-level insns. */
3907 leaf_renumber_regs_insn (PATTERN (in_rtx));
3908 return;
3909 }
3910
3911 format_ptr = GET_RTX_FORMAT (GET_CODE (in_rtx));
3912
3913 for (i = 0; i < GET_RTX_LENGTH (GET_CODE (in_rtx)); i++)
3914 switch (*format_ptr++)
3915 {
3916 case 'e':
3917 leaf_renumber_regs_insn (XEXP (in_rtx, i));
3918 break;
3919
3920 case 'E':
3921 if (NULL != XVEC (in_rtx, i))
3922 {
3923 for (j = 0; j < XVECLEN (in_rtx, i); j++)
3924 leaf_renumber_regs_insn (XVECEXP (in_rtx, i, j));
3925 }
3926 break;
3927
3928 case 'S':
3929 case 's':
3930 case '0':
3931 case 'i':
3932 case 'w':
3933 case 'n':
3934 case 'u':
3935 break;
3936
3937 default:
3938 gcc_unreachable ();
3939 }
3940 }
3941 #endif
3942
3943
3944 /* When -gused is used, emit debug info for only used symbols. But in
3945 addition to the standard intercepted debug_hooks there are some direct
3946 calls into this file, i.e., dbxout_symbol, dbxout_parms, and dbxout_reg_params.
3947 Those routines may also be called from a higher level intercepted routine. So
3948 to prevent recording data for an inner call to one of these for an intercept,
3949 we maintain an intercept nesting counter (debug_nesting). We only save the
3950 intercepted arguments if the nesting is 1. */
3951 int debug_nesting = 0;
3952
3953 static tree *symbol_queue;
3954 int symbol_queue_index = 0;
3955 static int symbol_queue_size = 0;
3956
3957 /* Generate the symbols for any queued up type symbols we encountered
3958 while generating the type info for some originally used symbol.
3959 This might generate additional entries in the queue. Only when
3960 the nesting depth goes to 0 is this routine called. */
3961
3962 void
3963 debug_flush_symbol_queue (void)
3964 {
3965 int i;
3966
3967 /* Make sure that additionally queued items are not flushed
3968 prematurely. */
3969
3970 ++debug_nesting;
3971
3972 for (i = 0; i < symbol_queue_index; ++i)
3973 {
3974 /* If we pushed queued symbols then such symbols must be
3975 output no matter what anyone else says. Specifically,
3976 we need to make sure dbxout_symbol() thinks the symbol was
3977 used and also we need to override TYPE_DECL_SUPPRESS_DEBUG
3978 which may be set for outside reasons. */
3979 int saved_tree_used = TREE_USED (symbol_queue[i]);
3980 int saved_suppress_debug = TYPE_DECL_SUPPRESS_DEBUG (symbol_queue[i]);
3981 TREE_USED (symbol_queue[i]) = 1;
3982 TYPE_DECL_SUPPRESS_DEBUG (symbol_queue[i]) = 0;
3983
3984 #ifdef DBX_DEBUGGING_INFO
3985 dbxout_symbol (symbol_queue[i], 0);
3986 #endif
3987
3988 TREE_USED (symbol_queue[i]) = saved_tree_used;
3989 TYPE_DECL_SUPPRESS_DEBUG (symbol_queue[i]) = saved_suppress_debug;
3990 }
3991
3992 symbol_queue_index = 0;
3993 --debug_nesting;
3994 }
3995
3996 /* Queue a type symbol needed as part of the definition of a decl
3997 symbol. These symbols are generated when debug_flush_symbol_queue()
3998 is called. */
3999
4000 void
4001 debug_queue_symbol (tree decl)
4002 {
4003 if (symbol_queue_index >= symbol_queue_size)
4004 {
4005 symbol_queue_size += 10;
4006 symbol_queue = xrealloc (symbol_queue,
4007 symbol_queue_size * sizeof (tree));
4008 }
4009
4010 symbol_queue[symbol_queue_index++] = decl;
4011 }
4012
4013 /* Free symbol queue. */
4014 void
4015 debug_free_queue (void)
4016 {
4017 if (symbol_queue)
4018 {
4019 free (symbol_queue);
4020 symbol_queue = NULL;
4021 symbol_queue_size = 0;
4022 }
4023 }
4024 \f
4025 /* Turn the RTL into assembly. */
4026 static unsigned int
4027 rest_of_handle_final (void)
4028 {
4029 rtx x;
4030 const char *fnname;
4031
4032 /* Get the function's name, as described by its RTL. This may be
4033 different from the DECL_NAME name used in the source file. */
4034
4035 x = DECL_RTL (current_function_decl);
4036 gcc_assert (MEM_P (x));
4037 x = XEXP (x, 0);
4038 gcc_assert (GET_CODE (x) == SYMBOL_REF);
4039 fnname = XSTR (x, 0);
4040
4041 assemble_start_function (current_function_decl, fnname);
4042 final_start_function (get_insns (), asm_out_file, optimize);
4043 final (get_insns (), asm_out_file, optimize);
4044 final_end_function ();
4045
4046 #ifdef TARGET_UNWIND_INFO
4047 /* ??? The IA-64 ".handlerdata" directive must be issued before
4048 the ".endp" directive that closes the procedure descriptor. */
4049 output_function_exception_table (fnname);
4050 #endif
4051
4052 assemble_end_function (current_function_decl, fnname);
4053
4054 #ifndef TARGET_UNWIND_INFO
4055 /* Otherwise, it feels unclean to switch sections in the middle. */
4056 output_function_exception_table (fnname);
4057 #endif
4058
4059 user_defined_section_attribute = false;
4060
4061 /* Free up reg info memory. */
4062 free_reg_info ();
4063
4064 if (! quiet_flag)
4065 fflush (asm_out_file);
4066
4067 /* Write DBX symbols if requested. */
4068
4069 /* Note that for those inline functions where we don't initially
4070 know for certain that we will be generating an out-of-line copy,
4071 the first invocation of this routine (rest_of_compilation) will
4072 skip over this code by doing a `goto exit_rest_of_compilation;'.
4073 Later on, wrapup_global_declarations will (indirectly) call
4074 rest_of_compilation again for those inline functions that need
4075 to have out-of-line copies generated. During that call, we
4076 *will* be routed past here. */
4077
4078 timevar_push (TV_SYMOUT);
4079 (*debug_hooks->function_decl) (current_function_decl);
4080 timevar_pop (TV_SYMOUT);
4081 if (DECL_STATIC_CONSTRUCTOR (current_function_decl)
4082 && targetm.have_ctors_dtors)
4083 targetm.asm_out.constructor (XEXP (DECL_RTL (current_function_decl), 0),
4084 decl_init_priority_lookup
4085 (current_function_decl));
4086 if (DECL_STATIC_DESTRUCTOR (current_function_decl)
4087 && targetm.have_ctors_dtors)
4088 targetm.asm_out.destructor (XEXP (DECL_RTL (current_function_decl), 0),
4089 decl_fini_priority_lookup
4090 (current_function_decl));
4091 return 0;
4092 }
4093
4094 struct tree_opt_pass pass_final =
4095 {
4096 NULL, /* name */
4097 NULL, /* gate */
4098 rest_of_handle_final, /* execute */
4099 NULL, /* sub */
4100 NULL, /* next */
4101 0, /* static_pass_number */
4102 TV_FINAL, /* tv_id */
4103 0, /* properties_required */
4104 0, /* properties_provided */
4105 0, /* properties_destroyed */
4106 0, /* todo_flags_start */
4107 TODO_ggc_collect, /* todo_flags_finish */
4108 0 /* letter */
4109 };
4110
4111
4112 static unsigned int
4113 rest_of_handle_shorten_branches (void)
4114 {
4115 /* Shorten branches. */
4116 shorten_branches (get_insns ());
4117 return 0;
4118 }
4119
4120 struct tree_opt_pass pass_shorten_branches =
4121 {
4122 "shorten", /* name */
4123 NULL, /* gate */
4124 rest_of_handle_shorten_branches, /* execute */
4125 NULL, /* sub */
4126 NULL, /* next */
4127 0, /* static_pass_number */
4128 TV_FINAL, /* tv_id */
4129 0, /* properties_required */
4130 0, /* properties_provided */
4131 0, /* properties_destroyed */
4132 0, /* todo_flags_start */
4133 TODO_dump_func, /* todo_flags_finish */
4134 0 /* letter */
4135 };
4136
4137
4138 static unsigned int
4139 rest_of_clean_state (void)
4140 {
4141 rtx insn, next;
4142
4143 /* It is very important to decompose the RTL instruction chain here:
4144 debug information keeps pointing into CODE_LABEL insns inside the function
4145 body. If these remain pointing to the other insns, we end up preserving
4146 whole RTL chain and attached detailed debug info in memory. */
4147 for (insn = get_insns (); insn; insn = next)
4148 {
4149 next = NEXT_INSN (insn);
4150 NEXT_INSN (insn) = NULL;
4151 PREV_INSN (insn) = NULL;
4152 }
4153
4154 /* In case the function was not output,
4155 don't leave any temporary anonymous types
4156 queued up for sdb output. */
4157 #ifdef SDB_DEBUGGING_INFO
4158 if (write_symbols == SDB_DEBUG)
4159 sdbout_types (NULL_TREE);
4160 #endif
4161
4162 reload_completed = 0;
4163 epilogue_completed = 0;
4164 #ifdef STACK_REGS
4165 regstack_completed = 0;
4166 #endif
4167
4168 /* Clear out the insn_length contents now that they are no
4169 longer valid. */
4170 init_insn_lengths ();
4171
4172 /* Show no temporary slots allocated. */
4173 init_temp_slots ();
4174
4175 free_bb_for_insn ();
4176
4177 if (targetm.binds_local_p (current_function_decl))
4178 {
4179 int pref = cfun->preferred_stack_boundary;
4180 if (cfun->stack_alignment_needed > cfun->preferred_stack_boundary)
4181 pref = cfun->stack_alignment_needed;
4182 cgraph_rtl_info (current_function_decl)->preferred_incoming_stack_boundary
4183 = pref;
4184 }
4185
4186 /* Make sure volatile mem refs aren't considered valid operands for
4187 arithmetic insns. We must call this here if this is a nested inline
4188 function, since the above code leaves us in the init_recog state,
4189 and the function context push/pop code does not save/restore volatile_ok.
4190
4191 ??? Maybe it isn't necessary for expand_start_function to call this
4192 anymore if we do it here? */
4193
4194 init_recog_no_volatile ();
4195
4196 /* We're done with this function. Free up memory if we can. */
4197 free_after_parsing (cfun);
4198 free_after_compilation (cfun);
4199 return 0;
4200 }
4201
4202 struct tree_opt_pass pass_clean_state =
4203 {
4204 NULL, /* name */
4205 NULL, /* gate */
4206 rest_of_clean_state, /* execute */
4207 NULL, /* sub */
4208 NULL, /* next */
4209 0, /* static_pass_number */
4210 TV_FINAL, /* tv_id */
4211 0, /* properties_required */
4212 0, /* properties_provided */
4213 PROP_rtl, /* properties_destroyed */
4214 0, /* todo_flags_start */
4215 0, /* todo_flags_finish */
4216 0 /* letter */
4217 };
4218