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 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* This is the final pass of the compiler.
23 It looks at the rtl code for a function and outputs assembler code.
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'.
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.)
36 Instructions to set the condition codes are omitted when it can be
37 seen that the condition codes already had the desired values.
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.
43 The code for the function prologue and epilogue are generated
44 directly as assembler code by the macros FUNCTION_PROLOGUE and
45 FUNCTION_EPILOGUE. Those instructions never exist as rtl. */
54 #include "insn-config.h"
55 #include "insn-attr.h"
57 #include "conditions.h"
60 #include "hard-reg-set.h"
67 #include "basic-block.h"
69 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
71 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
73 #ifdef XCOFF_DEBUGGING_INFO
77 #ifdef DWARF_DEBUGGING_INFO
81 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
82 #include "dwarf2out.h"
85 #ifdef SDB_DEBUGGING_INFO
89 /* If we aren't using cc0, CC_STATUS_INIT shouldn't exist. So define a
90 null default for it to save conditionalization later. */
91 #ifndef CC_STATUS_INIT
92 #define CC_STATUS_INIT
95 /* How to start an assembler comment. */
96 #ifndef ASM_COMMENT_START
97 #define ASM_COMMENT_START ";#"
100 /* Is the given character a logical line separator for the assembler? */
101 #ifndef IS_ASM_LOGICAL_LINE_SEPARATOR
102 #define IS_ASM_LOGICAL_LINE_SEPARATOR(C) ((C) == ';')
105 #ifndef JUMP_TABLES_IN_TEXT_SECTION
106 #define JUMP_TABLES_IN_TEXT_SECTION 0
109 /* Last insn processed by final_scan_insn. */
110 static rtx debug_insn
;
111 rtx current_output_insn
;
113 /* Line number of last NOTE. */
114 static int last_linenum
;
116 /* Highest line number in current block. */
117 static int high_block_linenum
;
119 /* Likewise for function. */
120 static int high_function_linenum
;
122 /* Filename of last NOTE. */
123 static const char *last_filename
;
125 /* Number of basic blocks seen so far;
126 used if profile_block_flag is set. */
127 static int count_basic_blocks
;
129 /* Number of instrumented arcs when profile_arc_flag is set. */
130 extern int count_instrumented_edges
;
132 extern int length_unit_log
; /* This is defined in insn-attrtab.c. */
134 /* Nonzero while outputting an `asm' with operands.
135 This means that inconsistencies are the user's fault, so don't abort.
136 The precise value is the insn being output, to pass to error_for_asm. */
137 static rtx this_is_asm_operands
;
139 /* Number of operands of this insn, for an `asm' with operands. */
140 static unsigned int insn_noperands
;
142 /* Compare optimization flag. */
144 static rtx last_ignored_compare
= 0;
146 /* Flag indicating this insn is the start of a new basic block. */
148 static int new_block
= 1;
150 /* Assign a unique number to each insn that is output.
151 This can be used to generate unique local labels. */
153 static int insn_counter
= 0;
156 /* This variable contains machine-dependent flags (defined in tm.h)
157 set and examined by output routines
158 that describe how to interpret the condition codes properly. */
162 /* During output of an insn, this contains a copy of cc_status
163 from before the insn. */
165 CC_STATUS cc_prev_status
;
168 /* Indexed by hardware reg number, is 1 if that register is ever
169 used in the current function.
171 In life_analysis, or in stupid_life_analysis, this is set
172 up to record the hard regs used explicitly. Reload adds
173 in the hard regs used for holding pseudo regs. Final uses
174 it to generate the code in the function prologue and epilogue
175 to save and restore registers as needed. */
177 char regs_ever_live
[FIRST_PSEUDO_REGISTER
];
179 /* Nonzero means current function must be given a frame pointer.
180 Set in stmt.c if anything is allocated on the stack there.
181 Set in reload1.c if anything is allocated on the stack there. */
183 int frame_pointer_needed
;
185 /* Assign unique numbers to labels generated for profiling. */
187 int profile_label_no
;
189 /* Number of unmatched NOTE_INSN_BLOCK_BEG notes we have seen. */
191 static int block_depth
;
193 /* Nonzero if have enabled APP processing of our assembler output. */
197 /* If we are outputting an insn sequence, this contains the sequence rtx.
202 #ifdef ASSEMBLER_DIALECT
204 /* Number of the assembler dialect to use, starting at 0. */
205 static int dialect_number
;
208 /* Indexed by line number, nonzero if there is a note for that line. */
210 static char *line_note_exists
;
212 #ifdef HAVE_conditional_execution
213 /* Nonnull if the insn currently being emitted was a COND_EXEC pattern. */
214 rtx current_insn_predicate
;
217 /* Linked list to hold line numbers for each basic block. */
221 struct bb_list
*next
; /* pointer to next basic block */
222 int line_num
; /* line number */
223 int file_label_num
; /* LPBC<n> label # for stored filename */
224 int func_label_num
; /* LPBC<n> label # for stored function name */
227 static struct bb_list
*bb_head
= 0; /* Head of basic block list */
228 static struct bb_list
**bb_tail
= &bb_head
; /* Ptr to store next bb ptr */
229 static int bb_file_label_num
= -1; /* Current label # for file */
230 static int bb_func_label_num
= -1; /* Current label # for func */
232 /* Linked list to hold the strings for each file and function name output. */
236 struct bb_str
*next
; /* pointer to next string */
237 const char *string
; /* string */
238 int label_num
; /* label number */
239 int length
; /* string length */
242 static struct bb_str
*sbb_head
= 0; /* Head of string list. */
243 static struct bb_str
**sbb_tail
= &sbb_head
; /* Ptr to store next bb str */
244 static int sbb_label_num
= 0; /* Last label used */
246 #ifdef HAVE_ATTR_length
247 static int asm_insn_count
PARAMS ((rtx
));
249 static void profile_function
PARAMS ((FILE *));
250 static void profile_after_prologue
PARAMS ((FILE *));
251 static void add_bb
PARAMS ((FILE *));
252 static int add_bb_string
PARAMS ((const char *, int));
253 static void output_source_line
PARAMS ((FILE *, rtx
));
254 static rtx walk_alter_subreg
PARAMS ((rtx
));
255 static void output_asm_name
PARAMS ((void));
256 static void output_operand
PARAMS ((rtx
, int));
257 #ifdef LEAF_REGISTERS
258 static void leaf_renumber_regs
PARAMS ((rtx
));
261 static int alter_cond
PARAMS ((rtx
));
263 #ifndef ADDR_VEC_ALIGN
264 static int final_addr_vec_align
PARAMS ((rtx
));
266 #ifdef HAVE_ATTR_length
267 static int align_fuzz
PARAMS ((rtx
, rtx
, int, unsigned));
270 /* Initialize data in final at the beginning of a compilation. */
273 init_final (filename
)
274 const char *filename ATTRIBUTE_UNUSED
;
279 #ifdef ASSEMBLER_DIALECT
280 dialect_number
= ASSEMBLER_DIALECT
;
284 /* Called at end of source file,
285 to output the block-profiling table for this entire compilation. */
289 const char *filename
;
293 if (profile_block_flag
|| profile_arc_flag
)
296 int align
= exact_log2 (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
);
300 int long_bytes
= LONG_TYPE_SIZE
/ BITS_PER_UNIT
;
301 int pointer_bytes
= POINTER_SIZE
/ BITS_PER_UNIT
;
303 if (profile_block_flag
)
304 size
= long_bytes
* count_basic_blocks
;
306 size
= long_bytes
* count_instrumented_edges
;
309 rounded
+= (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
) - 1;
310 rounded
= (rounded
/ (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
311 * (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
));
315 /* Output the main header, of 11 words:
316 0: 1 if this file is initialized, else 0.
317 1: address of file name (LPBX1).
318 2: address of table of counts (LPBX2).
319 3: number of counts in the table.
320 4: always 0, for compatibility with Sun.
322 The following are GNU extensions:
324 5: address of table of start addrs of basic blocks (LPBX3).
325 6: Number of bytes in this header.
326 7: address of table of function names (LPBX4).
327 8: address of table of line numbers (LPBX5) or 0.
328 9: address of table of file names (LPBX6) or 0.
329 10: space reserved for basic block profiling. */
331 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
333 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LPBX", 0);
335 assemble_integer (const0_rtx
, long_bytes
, 1);
337 /* address of filename */
338 ASM_GENERATE_INTERNAL_LABEL (name
, "LPBX", 1);
339 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, name
), pointer_bytes
, 1);
341 /* address of count table */
342 ASM_GENERATE_INTERNAL_LABEL (name
, "LPBX", 2);
343 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, name
), pointer_bytes
, 1);
345 /* count of the # of basic blocks or # of instrumented arcs */
346 if (profile_block_flag
)
347 assemble_integer (GEN_INT (count_basic_blocks
), long_bytes
, 1);
349 assemble_integer (GEN_INT (count_instrumented_edges
), long_bytes
, 1);
351 /* zero word (link field) */
352 assemble_integer (const0_rtx
, pointer_bytes
, 1);
354 /* address of basic block start address table */
355 if (profile_block_flag
)
357 ASM_GENERATE_INTERNAL_LABEL (name
, "LPBX", 3);
358 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, name
), pointer_bytes
,
362 assemble_integer (const0_rtx
, pointer_bytes
, 1);
364 /* byte count for extended structure. */
365 assemble_integer (GEN_INT (11 * UNITS_PER_WORD
), long_bytes
, 1);
367 /* address of function name table */
368 if (profile_block_flag
)
370 ASM_GENERATE_INTERNAL_LABEL (name
, "LPBX", 4);
371 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, name
), pointer_bytes
,
375 assemble_integer (const0_rtx
, pointer_bytes
, 1);
377 /* address of line number and filename tables if debugging. */
378 if (write_symbols
!= NO_DEBUG
&& profile_block_flag
)
380 ASM_GENERATE_INTERNAL_LABEL (name
, "LPBX", 5);
381 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, name
),
383 ASM_GENERATE_INTERNAL_LABEL (name
, "LPBX", 6);
384 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, name
),
389 assemble_integer (const0_rtx
, pointer_bytes
, 1);
390 assemble_integer (const0_rtx
, pointer_bytes
, 1);
393 /* space for extension ptr (link field) */
394 assemble_integer (const0_rtx
, UNITS_PER_WORD
, 1);
396 /* Output the file name changing the suffix to .d for Sun tcov
398 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LPBX", 1);
400 char *cwd
= getpwd ();
401 int len
= strlen (filename
) + strlen (cwd
) + 1;
402 char *data_file
= (char *) alloca (len
+ 4);
404 strcpy (data_file
, cwd
);
405 strcat (data_file
, "/");
406 strcat (data_file
, filename
);
407 strip_off_ending (data_file
, len
);
408 if (profile_block_flag
)
409 strcat (data_file
, ".d");
411 strcat (data_file
, ".da");
412 assemble_string (data_file
, strlen (data_file
) + 1);
415 /* Make space for the table of counts. */
418 /* Realign data section. */
419 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
420 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LPBX", 2);
422 assemble_zeros (size
);
426 ASM_GENERATE_INTERNAL_LABEL (name
, "LPBX", 2);
427 #ifdef ASM_OUTPUT_SHARED_LOCAL
428 if (flag_shared_data
)
429 ASM_OUTPUT_SHARED_LOCAL (asm_out_file
, name
, size
, rounded
);
432 #ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL
433 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file
, NULL_TREE
, name
,
434 size
, BIGGEST_ALIGNMENT
);
436 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
437 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file
, name
, size
,
440 ASM_OUTPUT_LOCAL (asm_out_file
, name
, size
, rounded
);
445 /* Output any basic block strings */
446 if (profile_block_flag
)
448 readonly_data_section ();
451 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
452 for (sptr
= sbb_head
; sptr
!= 0; sptr
= sptr
->next
)
454 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LPBC",
456 assemble_string (sptr
->string
, sptr
->length
);
461 /* Output the table of addresses. */
462 if (profile_block_flag
)
464 /* Realign in new section */
465 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
466 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LPBX", 3);
467 for (i
= 0; i
< count_basic_blocks
; i
++)
469 ASM_GENERATE_INTERNAL_LABEL (name
, "LPB", i
);
470 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, name
),
475 /* Output the table of function names. */
476 if (profile_block_flag
)
478 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LPBX", 4);
479 for ((ptr
= bb_head
), (i
= 0); ptr
!= 0; (ptr
= ptr
->next
), i
++)
481 if (ptr
->func_label_num
>= 0)
483 ASM_GENERATE_INTERNAL_LABEL (name
, "LPBC",
484 ptr
->func_label_num
);
485 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, name
),
489 assemble_integer (const0_rtx
, pointer_bytes
, 1);
492 for (; i
< count_basic_blocks
; i
++)
493 assemble_integer (const0_rtx
, pointer_bytes
, 1);
496 if (write_symbols
!= NO_DEBUG
&& profile_block_flag
)
498 /* Output the table of line numbers. */
499 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LPBX", 5);
500 for ((ptr
= bb_head
), (i
= 0); ptr
!= 0; (ptr
= ptr
->next
), i
++)
501 assemble_integer (GEN_INT (ptr
->line_num
), long_bytes
, 1);
503 for (; i
< count_basic_blocks
; i
++)
504 assemble_integer (const0_rtx
, long_bytes
, 1);
506 /* Output the table of file names. */
507 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LPBX", 6);
508 for ((ptr
= bb_head
), (i
= 0); ptr
!= 0; (ptr
= ptr
->next
), i
++)
510 if (ptr
->file_label_num
>= 0)
512 ASM_GENERATE_INTERNAL_LABEL (name
, "LPBC",
513 ptr
->file_label_num
);
514 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, name
),
518 assemble_integer (const0_rtx
, pointer_bytes
, 1);
521 for (; i
< count_basic_blocks
; i
++)
522 assemble_integer (const0_rtx
, pointer_bytes
, 1);
525 /* End with the address of the table of addresses,
526 so we can find it easily, as the last word in the file's text. */
527 if (profile_block_flag
)
529 ASM_GENERATE_INTERNAL_LABEL (name
, "LPBX", 3);
530 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, name
), pointer_bytes
,
536 /* Enable APP processing of subsequent output.
537 Used before the output from an `asm' statement. */
544 fputs (ASM_APP_ON
, asm_out_file
);
549 /* Disable APP processing of subsequent output.
550 Called from varasm.c before most kinds of output. */
557 fputs (ASM_APP_OFF
, asm_out_file
);
562 /* Return the number of slots filled in the current
563 delayed branch sequence (we don't count the insn needing the
564 delay slot). Zero if not in a delayed branch sequence. */
568 dbr_sequence_length ()
570 if (final_sequence
!= 0)
571 return XVECLEN (final_sequence
, 0) - 1;
577 /* The next two pages contain routines used to compute the length of an insn
578 and to shorten branches. */
580 /* Arrays for insn lengths, and addresses. The latter is referenced by
581 `insn_current_length'. */
583 static short *insn_lengths
;
585 #ifdef HAVE_ATTR_length
586 varray_type insn_addresses_
;
589 /* Max uid for which the above arrays are valid. */
590 static int insn_lengths_max_uid
;
592 /* Address of insn being processed. Used by `insn_current_length'. */
593 int insn_current_address
;
595 /* Address of insn being processed in previous iteration. */
596 int insn_last_address
;
598 /* konwn invariant alignment of insn being processed. */
599 int insn_current_align
;
601 /* After shorten_branches, for any insn, uid_align[INSN_UID (insn)]
602 gives the next following alignment insn that increases the known
603 alignment, or NULL_RTX if there is no such insn.
604 For any alignment obtained this way, we can again index uid_align with
605 its uid to obtain the next following align that in turn increases the
606 alignment, till we reach NULL_RTX; the sequence obtained this way
607 for each insn we'll call the alignment chain of this insn in the following
610 struct label_alignment
616 static rtx
*uid_align
;
617 static int *uid_shuid
;
618 static struct label_alignment
*label_align
;
620 /* Indicate that branch shortening hasn't yet been done. */
639 insn_lengths_max_uid
= 0;
641 #ifdef HAVE_ATTR_length
642 INSN_ADDRESSES_FREE ();
651 /* Obtain the current length of an insn. If branch shortening has been done,
652 get its actual length. Otherwise, get its maximum length. */
655 get_attr_length (insn
)
656 rtx insn ATTRIBUTE_UNUSED
;
658 #ifdef HAVE_ATTR_length
663 if (insn_lengths_max_uid
> INSN_UID (insn
))
664 return insn_lengths
[INSN_UID (insn
)];
666 switch (GET_CODE (insn
))
674 length
= insn_default_length (insn
);
678 body
= PATTERN (insn
);
679 if (GET_CODE (body
) == ADDR_VEC
|| GET_CODE (body
) == ADDR_DIFF_VEC
)
681 /* Alignment is machine-dependent and should be handled by
685 length
= insn_default_length (insn
);
689 body
= PATTERN (insn
);
690 if (GET_CODE (body
) == USE
|| GET_CODE (body
) == CLOBBER
)
693 else if (GET_CODE (body
) == ASM_INPUT
|| asm_noperands (body
) >= 0)
694 length
= asm_insn_count (body
) * insn_default_length (insn
);
695 else if (GET_CODE (body
) == SEQUENCE
)
696 for (i
= 0; i
< XVECLEN (body
, 0); i
++)
697 length
+= get_attr_length (XVECEXP (body
, 0, i
));
699 length
= insn_default_length (insn
);
706 #ifdef ADJUST_INSN_LENGTH
707 ADJUST_INSN_LENGTH (insn
, length
);
710 #else /* not HAVE_ATTR_length */
712 #endif /* not HAVE_ATTR_length */
715 /* Code to handle alignment inside shorten_branches. */
717 /* Here is an explanation how the algorithm in align_fuzz can give
720 Call a sequence of instructions beginning with alignment point X
721 and continuing until the next alignment point `block X'. When `X'
722 is used in an expression, it means the alignment value of the
725 Call the distance between the start of the first insn of block X, and
726 the end of the last insn of block X `IX', for the `inner size of X'.
727 This is clearly the sum of the instruction lengths.
729 Likewise with the next alignment-delimited block following X, which we
732 Call the distance between the start of the first insn of block X, and
733 the start of the first insn of block Y `OX', for the `outer size of X'.
735 The estimated padding is then OX - IX.
737 OX can be safely estimated as
742 OX = round_up(IX, X) + Y - X
744 Clearly est(IX) >= real(IX), because that only depends on the
745 instruction lengths, and those being overestimated is a given.
747 Clearly round_up(foo, Z) >= round_up(bar, Z) if foo >= bar, so
748 we needn't worry about that when thinking about OX.
750 When X >= Y, the alignment provided by Y adds no uncertainty factor
751 for branch ranges starting before X, so we can just round what we have.
752 But when X < Y, we don't know anything about the, so to speak,
753 `middle bits', so we have to assume the worst when aligning up from an
754 address mod X to one mod Y, which is Y - X. */
757 #define LABEL_ALIGN(LABEL) align_labels_log
760 #ifndef LABEL_ALIGN_MAX_SKIP
761 #define LABEL_ALIGN_MAX_SKIP (align_labels-1)
765 #define LOOP_ALIGN(LABEL) align_loops_log
768 #ifndef LOOP_ALIGN_MAX_SKIP
769 #define LOOP_ALIGN_MAX_SKIP (align_loops-1)
772 #ifndef LABEL_ALIGN_AFTER_BARRIER
773 #define LABEL_ALIGN_AFTER_BARRIER(LABEL) align_jumps_log
776 #ifndef LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP
777 #define LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP (align_jumps-1)
780 #ifndef ADDR_VEC_ALIGN
782 final_addr_vec_align (addr_vec
)
785 int align
= GET_MODE_SIZE (GET_MODE (PATTERN (addr_vec
)));
787 if (align
> BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
788 align
= BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
;
789 return exact_log2 (align
);
793 #define ADDR_VEC_ALIGN(ADDR_VEC) final_addr_vec_align (ADDR_VEC)
796 #ifndef INSN_LENGTH_ALIGNMENT
797 #define INSN_LENGTH_ALIGNMENT(INSN) length_unit_log
800 #define INSN_SHUID(INSN) (uid_shuid[INSN_UID (INSN)])
802 static int min_labelno
, max_labelno
;
804 #define LABEL_TO_ALIGNMENT(LABEL) \
805 (label_align[CODE_LABEL_NUMBER (LABEL) - min_labelno].alignment)
807 #define LABEL_TO_MAX_SKIP(LABEL) \
808 (label_align[CODE_LABEL_NUMBER (LABEL) - min_labelno].max_skip)
810 /* For the benefit of port specific code do this also as a function. */
813 label_to_alignment (label
)
816 return LABEL_TO_ALIGNMENT (label
);
819 #ifdef HAVE_ATTR_length
820 /* The differences in addresses
821 between a branch and its target might grow or shrink depending on
822 the alignment the start insn of the range (the branch for a forward
823 branch or the label for a backward branch) starts out on; if these
824 differences are used naively, they can even oscillate infinitely.
825 We therefore want to compute a 'worst case' address difference that
826 is independent of the alignment the start insn of the range end
827 up on, and that is at least as large as the actual difference.
828 The function align_fuzz calculates the amount we have to add to the
829 naively computed difference, by traversing the part of the alignment
830 chain of the start insn of the range that is in front of the end insn
831 of the range, and considering for each alignment the maximum amount
832 that it might contribute to a size increase.
834 For casesi tables, we also want to know worst case minimum amounts of
835 address difference, in case a machine description wants to introduce
836 some common offset that is added to all offsets in a table.
837 For this purpose, align_fuzz with a growth argument of 0 comuptes the
838 appropriate adjustment. */
840 /* Compute the maximum delta by which the difference of the addresses of
841 START and END might grow / shrink due to a different address for start
842 which changes the size of alignment insns between START and END.
843 KNOWN_ALIGN_LOG is the alignment known for START.
844 GROWTH should be ~0 if the objective is to compute potential code size
845 increase, and 0 if the objective is to compute potential shrink.
846 The return value is undefined for any other value of GROWTH. */
849 align_fuzz (start
, end
, known_align_log
, growth
)
854 int uid
= INSN_UID (start
);
856 int known_align
= 1 << known_align_log
;
857 int end_shuid
= INSN_SHUID (end
);
860 for (align_label
= uid_align
[uid
]; align_label
; align_label
= uid_align
[uid
])
862 int align_addr
, new_align
;
864 uid
= INSN_UID (align_label
);
865 align_addr
= INSN_ADDRESSES (uid
) - insn_lengths
[uid
];
866 if (uid_shuid
[uid
] > end_shuid
)
868 known_align_log
= LABEL_TO_ALIGNMENT (align_label
);
869 new_align
= 1 << known_align_log
;
870 if (new_align
< known_align
)
872 fuzz
+= (-align_addr
^ growth
) & (new_align
- known_align
);
873 known_align
= new_align
;
878 /* Compute a worst-case reference address of a branch so that it
879 can be safely used in the presence of aligned labels. Since the
880 size of the branch itself is unknown, the size of the branch is
881 not included in the range. I.e. for a forward branch, the reference
882 address is the end address of the branch as known from the previous
883 branch shortening pass, minus a value to account for possible size
884 increase due to alignment. For a backward branch, it is the start
885 address of the branch as known from the current pass, plus a value
886 to account for possible size increase due to alignment.
887 NB.: Therefore, the maximum offset allowed for backward branches needs
888 to exclude the branch size. */
891 insn_current_reference_address (branch
)
897 if (! INSN_ADDRESSES_SET_P ())
900 seq
= NEXT_INSN (PREV_INSN (branch
));
901 seq_uid
= INSN_UID (seq
);
902 if (GET_CODE (branch
) != JUMP_INSN
)
903 /* This can happen for example on the PA; the objective is to know the
904 offset to address something in front of the start of the function.
905 Thus, we can treat it like a backward branch.
906 We assume here that FUNCTION_BOUNDARY / BITS_PER_UNIT is larger than
907 any alignment we'd encounter, so we skip the call to align_fuzz. */
908 return insn_current_address
;
909 dest
= JUMP_LABEL (branch
);
911 /* BRANCH has no proper alignment chain set, so use SEQ.
912 BRANCH also has no INSN_SHUID. */
913 if (INSN_SHUID (seq
) < INSN_SHUID (dest
))
915 /* Forward branch. */
916 return (insn_last_address
+ insn_lengths
[seq_uid
]
917 - align_fuzz (seq
, dest
, length_unit_log
, ~0));
921 /* Backward branch. */
922 return (insn_current_address
923 + align_fuzz (dest
, seq
, length_unit_log
, ~0));
926 #endif /* HAVE_ATTR_length */
928 /* Make a pass over all insns and compute their actual lengths by shortening
929 any branches of variable length if possible. */
931 /* Give a default value for the lowest address in a function. */
933 #ifndef FIRST_INSN_ADDRESS
934 #define FIRST_INSN_ADDRESS 0
937 /* shorten_branches might be called multiple times: for example, the SH
938 port splits out-of-range conditional branches in MACHINE_DEPENDENT_REORG.
939 In order to do this, it needs proper length information, which it obtains
940 by calling shorten_branches. This cannot be collapsed with
941 shorten_branches itself into a single pass unless we also want to intergate
942 reorg.c, since the branch splitting exposes new instructions with delay
946 shorten_branches (first
)
947 rtx first ATTRIBUTE_UNUSED
;
954 #ifdef HAVE_ATTR_length
955 #define MAX_CODE_ALIGN 16
957 int something_changed
= 1;
958 char *varying_length
;
961 rtx align_tab
[MAX_CODE_ALIGN
];
963 /* In order to make sure that all instructions have valid length info,
964 we must split them before we compute the address/length info. */
966 for (insn
= NEXT_INSN (first
); insn
; insn
= NEXT_INSN (insn
))
970 /* Don't split the insn if it has been deleted. */
971 if (! INSN_DELETED_P (old
))
972 insn
= try_split (PATTERN (old
), old
, 1);
973 /* When not optimizing, the old insn will be still left around
974 with only the 'deleted' bit set. Transform it into a note
975 to avoid confusion of subsequent processing. */
976 if (INSN_DELETED_P (old
))
978 PUT_CODE (old
, NOTE
);
979 NOTE_LINE_NUMBER (old
) = NOTE_INSN_DELETED
;
980 NOTE_SOURCE_FILE (old
) = 0;
985 /* We must do some computations even when not actually shortening, in
986 order to get the alignment information for the labels. */
988 init_insn_lengths ();
990 /* Compute maximum UID and allocate label_align / uid_shuid. */
991 max_uid
= get_max_uid ();
993 max_labelno
= max_label_num ();
994 min_labelno
= get_first_label_num ();
995 label_align
= (struct label_alignment
*)
996 xcalloc ((max_labelno
- min_labelno
+ 1), sizeof (struct label_alignment
));
998 uid_shuid
= (int *) xmalloc (max_uid
* sizeof *uid_shuid
);
1000 /* Initialize label_align and set up uid_shuid to be strictly
1001 monotonically rising with insn order. */
1002 /* We use max_log here to keep track of the maximum alignment we want to
1003 impose on the next CODE_LABEL (or the current one if we are processing
1004 the CODE_LABEL itself). */
1009 for (insn
= get_insns (), i
= 1; insn
; insn
= NEXT_INSN (insn
))
1013 INSN_SHUID (insn
) = i
++;
1016 /* reorg might make the first insn of a loop being run once only,
1017 and delete the label in front of it. Then we want to apply
1018 the loop alignment to the new label created by reorg, which
1019 is separated by the former loop start insn from the
1020 NOTE_INSN_LOOP_BEG. */
1022 else if (GET_CODE (insn
) == CODE_LABEL
)
1026 log
= LABEL_ALIGN (insn
);
1030 max_skip
= LABEL_ALIGN_MAX_SKIP
;
1032 next
= NEXT_INSN (insn
);
1033 /* ADDR_VECs only take room if read-only data goes into the text
1035 if (JUMP_TABLES_IN_TEXT_SECTION
1036 #if !defined(READONLY_DATA_SECTION)
1040 if (next
&& GET_CODE (next
) == JUMP_INSN
)
1042 rtx nextbody
= PATTERN (next
);
1043 if (GET_CODE (nextbody
) == ADDR_VEC
1044 || GET_CODE (nextbody
) == ADDR_DIFF_VEC
)
1046 log
= ADDR_VEC_ALIGN (next
);
1050 max_skip
= LABEL_ALIGN_MAX_SKIP
;
1054 LABEL_TO_ALIGNMENT (insn
) = max_log
;
1055 LABEL_TO_MAX_SKIP (insn
) = max_skip
;
1059 else if (GET_CODE (insn
) == BARRIER
)
1063 for (label
= insn
; label
&& ! INSN_P (label
);
1064 label
= NEXT_INSN (label
))
1065 if (GET_CODE (label
) == CODE_LABEL
)
1067 log
= LABEL_ALIGN_AFTER_BARRIER (insn
);
1071 max_skip
= LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP
;
1076 /* Again, we allow NOTE_INSN_LOOP_BEG - INSN - CODE_LABEL
1077 sequences in order to handle reorg output efficiently. */
1078 else if (GET_CODE (insn
) == NOTE
1079 && NOTE_LINE_NUMBER (insn
) == NOTE_INSN_LOOP_BEG
)
1084 /* Search for the label that starts the loop.
1085 Don't skip past the end of the loop, since that could
1086 lead to putting an alignment where it does not belong.
1087 However, a label after a nested (non-)loop would be OK. */
1088 for (label
= insn
; label
; label
= NEXT_INSN (label
))
1090 if (GET_CODE (label
) == NOTE
1091 && NOTE_LINE_NUMBER (label
) == NOTE_INSN_LOOP_BEG
)
1093 else if (GET_CODE (label
) == NOTE
1094 && NOTE_LINE_NUMBER (label
) == NOTE_INSN_LOOP_END
1097 else if (GET_CODE (label
) == CODE_LABEL
)
1099 log
= LOOP_ALIGN (label
);
1103 max_skip
= LOOP_ALIGN_MAX_SKIP
;
1112 #ifdef HAVE_ATTR_length
1114 /* Allocate the rest of the arrays. */
1115 insn_lengths
= (short *) xmalloc (max_uid
* sizeof (short));
1116 insn_lengths_max_uid
= max_uid
;
1117 /* Syntax errors can lead to labels being outside of the main insn stream.
1118 Initialize insn_addresses, so that we get reproducible results. */
1119 INSN_ADDRESSES_ALLOC (max_uid
);
1121 varying_length
= (char *) xcalloc (max_uid
, sizeof (char));
1123 /* Initialize uid_align. We scan instructions
1124 from end to start, and keep in align_tab[n] the last seen insn
1125 that does an alignment of at least n+1, i.e. the successor
1126 in the alignment chain for an insn that does / has a known
1128 uid_align
= (rtx
*) xcalloc (max_uid
, sizeof *uid_align
);
1130 for (i
= MAX_CODE_ALIGN
; --i
>= 0;)
1131 align_tab
[i
] = NULL_RTX
;
1132 seq
= get_last_insn ();
1133 for (; seq
; seq
= PREV_INSN (seq
))
1135 int uid
= INSN_UID (seq
);
1137 log
= (GET_CODE (seq
) == CODE_LABEL
? LABEL_TO_ALIGNMENT (seq
) : 0);
1138 uid_align
[uid
] = align_tab
[0];
1141 /* Found an alignment label. */
1142 uid_align
[uid
] = align_tab
[log
];
1143 for (i
= log
- 1; i
>= 0; i
--)
1147 #ifdef CASE_VECTOR_SHORTEN_MODE
1150 /* Look for ADDR_DIFF_VECs, and initialize their minimum and maximum
1153 int min_shuid
= INSN_SHUID (get_insns ()) - 1;
1154 int max_shuid
= INSN_SHUID (get_last_insn ()) + 1;
1157 for (insn
= first
; insn
!= 0; insn
= NEXT_INSN (insn
))
1159 rtx min_lab
= NULL_RTX
, max_lab
= NULL_RTX
, pat
;
1160 int len
, i
, min
, max
, insn_shuid
;
1162 addr_diff_vec_flags flags
;
1164 if (GET_CODE (insn
) != JUMP_INSN
1165 || GET_CODE (PATTERN (insn
)) != ADDR_DIFF_VEC
)
1167 pat
= PATTERN (insn
);
1168 len
= XVECLEN (pat
, 1);
1171 min_align
= MAX_CODE_ALIGN
;
1172 for (min
= max_shuid
, max
= min_shuid
, i
= len
- 1; i
>= 0; i
--)
1174 rtx lab
= XEXP (XVECEXP (pat
, 1, i
), 0);
1175 int shuid
= INSN_SHUID (lab
);
1186 if (min_align
> LABEL_TO_ALIGNMENT (lab
))
1187 min_align
= LABEL_TO_ALIGNMENT (lab
);
1189 XEXP (pat
, 2) = gen_rtx_LABEL_REF (VOIDmode
, min_lab
);
1190 XEXP (pat
, 3) = gen_rtx_LABEL_REF (VOIDmode
, max_lab
);
1191 insn_shuid
= INSN_SHUID (insn
);
1192 rel
= INSN_SHUID (XEXP (XEXP (pat
, 0), 0));
1193 flags
.min_align
= min_align
;
1194 flags
.base_after_vec
= rel
> insn_shuid
;
1195 flags
.min_after_vec
= min
> insn_shuid
;
1196 flags
.max_after_vec
= max
> insn_shuid
;
1197 flags
.min_after_base
= min
> rel
;
1198 flags
.max_after_base
= max
> rel
;
1199 ADDR_DIFF_VEC_FLAGS (pat
) = flags
;
1202 #endif /* CASE_VECTOR_SHORTEN_MODE */
1204 /* Compute initial lengths, addresses, and varying flags for each insn. */
1205 for (insn_current_address
= FIRST_INSN_ADDRESS
, insn
= first
;
1207 insn_current_address
+= insn_lengths
[uid
], insn
= NEXT_INSN (insn
))
1209 uid
= INSN_UID (insn
);
1211 insn_lengths
[uid
] = 0;
1213 if (GET_CODE (insn
) == CODE_LABEL
)
1215 int log
= LABEL_TO_ALIGNMENT (insn
);
1218 int align
= 1 << log
;
1219 int new_address
= (insn_current_address
+ align
- 1) & -align
;
1220 insn_lengths
[uid
] = new_address
- insn_current_address
;
1224 INSN_ADDRESSES (uid
) = insn_current_address
;
1226 if (GET_CODE (insn
) == NOTE
|| GET_CODE (insn
) == BARRIER
1227 || GET_CODE (insn
) == CODE_LABEL
)
1229 if (INSN_DELETED_P (insn
))
1232 body
= PATTERN (insn
);
1233 if (GET_CODE (body
) == ADDR_VEC
|| GET_CODE (body
) == ADDR_DIFF_VEC
)
1235 /* This only takes room if read-only data goes into the text
1237 if (JUMP_TABLES_IN_TEXT_SECTION
1238 #if !defined(READONLY_DATA_SECTION)
1242 insn_lengths
[uid
] = (XVECLEN (body
,
1243 GET_CODE (body
) == ADDR_DIFF_VEC
)
1244 * GET_MODE_SIZE (GET_MODE (body
)));
1245 /* Alignment is handled by ADDR_VEC_ALIGN. */
1247 else if (GET_CODE (body
) == ASM_INPUT
|| asm_noperands (body
) >= 0)
1248 insn_lengths
[uid
] = asm_insn_count (body
) * insn_default_length (insn
);
1249 else if (GET_CODE (body
) == SEQUENCE
)
1252 int const_delay_slots
;
1254 const_delay_slots
= const_num_delay_slots (XVECEXP (body
, 0, 0));
1256 const_delay_slots
= 0;
1258 /* Inside a delay slot sequence, we do not do any branch shortening
1259 if the shortening could change the number of delay slots
1261 for (i
= 0; i
< XVECLEN (body
, 0); i
++)
1263 rtx inner_insn
= XVECEXP (body
, 0, i
);
1264 int inner_uid
= INSN_UID (inner_insn
);
1267 if (GET_CODE (body
) == ASM_INPUT
1268 || asm_noperands (PATTERN (XVECEXP (body
, 0, i
))) >= 0)
1269 inner_length
= (asm_insn_count (PATTERN (inner_insn
))
1270 * insn_default_length (inner_insn
));
1272 inner_length
= insn_default_length (inner_insn
);
1274 insn_lengths
[inner_uid
] = inner_length
;
1275 if (const_delay_slots
)
1277 if ((varying_length
[inner_uid
]
1278 = insn_variable_length_p (inner_insn
)) != 0)
1279 varying_length
[uid
] = 1;
1280 INSN_ADDRESSES (inner_uid
) = (insn_current_address
1281 + insn_lengths
[uid
]);
1284 varying_length
[inner_uid
] = 0;
1285 insn_lengths
[uid
] += inner_length
;
1288 else if (GET_CODE (body
) != USE
&& GET_CODE (body
) != CLOBBER
)
1290 insn_lengths
[uid
] = insn_default_length (insn
);
1291 varying_length
[uid
] = insn_variable_length_p (insn
);
1294 /* If needed, do any adjustment. */
1295 #ifdef ADJUST_INSN_LENGTH
1296 ADJUST_INSN_LENGTH (insn
, insn_lengths
[uid
]);
1297 if (insn_lengths
[uid
] < 0)
1298 fatal_insn ("Negative insn length", insn
);
1302 /* Now loop over all the insns finding varying length insns. For each,
1303 get the current insn length. If it has changed, reflect the change.
1304 When nothing changes for a full pass, we are done. */
1306 while (something_changed
)
1308 something_changed
= 0;
1309 insn_current_align
= MAX_CODE_ALIGN
- 1;
1310 for (insn_current_address
= FIRST_INSN_ADDRESS
, insn
= first
;
1312 insn
= NEXT_INSN (insn
))
1315 #ifdef ADJUST_INSN_LENGTH
1320 uid
= INSN_UID (insn
);
1322 if (GET_CODE (insn
) == CODE_LABEL
)
1324 int log
= LABEL_TO_ALIGNMENT (insn
);
1325 if (log
> insn_current_align
)
1327 int align
= 1 << log
;
1328 int new_address
= (insn_current_address
+ align
- 1) & -align
;
1329 insn_lengths
[uid
] = new_address
- insn_current_address
;
1330 insn_current_align
= log
;
1331 insn_current_address
= new_address
;
1334 insn_lengths
[uid
] = 0;
1335 INSN_ADDRESSES (uid
) = insn_current_address
;
1339 length_align
= INSN_LENGTH_ALIGNMENT (insn
);
1340 if (length_align
< insn_current_align
)
1341 insn_current_align
= length_align
;
1343 insn_last_address
= INSN_ADDRESSES (uid
);
1344 INSN_ADDRESSES (uid
) = insn_current_address
;
1346 #ifdef CASE_VECTOR_SHORTEN_MODE
1347 if (optimize
&& GET_CODE (insn
) == JUMP_INSN
1348 && GET_CODE (PATTERN (insn
)) == ADDR_DIFF_VEC
)
1350 rtx body
= PATTERN (insn
);
1351 int old_length
= insn_lengths
[uid
];
1352 rtx rel_lab
= XEXP (XEXP (body
, 0), 0);
1353 rtx min_lab
= XEXP (XEXP (body
, 2), 0);
1354 rtx max_lab
= XEXP (XEXP (body
, 3), 0);
1355 addr_diff_vec_flags flags
= ADDR_DIFF_VEC_FLAGS (body
);
1356 int rel_addr
= INSN_ADDRESSES (INSN_UID (rel_lab
));
1357 int min_addr
= INSN_ADDRESSES (INSN_UID (min_lab
));
1358 int max_addr
= INSN_ADDRESSES (INSN_UID (max_lab
));
1362 /* Try to find a known alignment for rel_lab. */
1363 for (prev
= rel_lab
;
1365 && ! insn_lengths
[INSN_UID (prev
)]
1366 && ! (varying_length
[INSN_UID (prev
)] & 1);
1367 prev
= PREV_INSN (prev
))
1368 if (varying_length
[INSN_UID (prev
)] & 2)
1370 rel_align
= LABEL_TO_ALIGNMENT (prev
);
1374 /* See the comment on addr_diff_vec_flags in rtl.h for the
1375 meaning of the flags values. base: REL_LAB vec: INSN */
1376 /* Anything after INSN has still addresses from the last
1377 pass; adjust these so that they reflect our current
1378 estimate for this pass. */
1379 if (flags
.base_after_vec
)
1380 rel_addr
+= insn_current_address
- insn_last_address
;
1381 if (flags
.min_after_vec
)
1382 min_addr
+= insn_current_address
- insn_last_address
;
1383 if (flags
.max_after_vec
)
1384 max_addr
+= insn_current_address
- insn_last_address
;
1385 /* We want to know the worst case, i.e. lowest possible value
1386 for the offset of MIN_LAB. If MIN_LAB is after REL_LAB,
1387 its offset is positive, and we have to be wary of code shrink;
1388 otherwise, it is negative, and we have to be vary of code
1390 if (flags
.min_after_base
)
1392 /* If INSN is between REL_LAB and MIN_LAB, the size
1393 changes we are about to make can change the alignment
1394 within the observed offset, therefore we have to break
1395 it up into two parts that are independent. */
1396 if (! flags
.base_after_vec
&& flags
.min_after_vec
)
1398 min_addr
-= align_fuzz (rel_lab
, insn
, rel_align
, 0);
1399 min_addr
-= align_fuzz (insn
, min_lab
, 0, 0);
1402 min_addr
-= align_fuzz (rel_lab
, min_lab
, rel_align
, 0);
1406 if (flags
.base_after_vec
&& ! flags
.min_after_vec
)
1408 min_addr
-= align_fuzz (min_lab
, insn
, 0, ~0);
1409 min_addr
-= align_fuzz (insn
, rel_lab
, 0, ~0);
1412 min_addr
-= align_fuzz (min_lab
, rel_lab
, 0, ~0);
1414 /* Likewise, determine the highest lowest possible value
1415 for the offset of MAX_LAB. */
1416 if (flags
.max_after_base
)
1418 if (! flags
.base_after_vec
&& flags
.max_after_vec
)
1420 max_addr
+= align_fuzz (rel_lab
, insn
, rel_align
, ~0);
1421 max_addr
+= align_fuzz (insn
, max_lab
, 0, ~0);
1424 max_addr
+= align_fuzz (rel_lab
, max_lab
, rel_align
, ~0);
1428 if (flags
.base_after_vec
&& ! flags
.max_after_vec
)
1430 max_addr
+= align_fuzz (max_lab
, insn
, 0, 0);
1431 max_addr
+= align_fuzz (insn
, rel_lab
, 0, 0);
1434 max_addr
+= align_fuzz (max_lab
, rel_lab
, 0, 0);
1436 PUT_MODE (body
, CASE_VECTOR_SHORTEN_MODE (min_addr
- rel_addr
,
1437 max_addr
- rel_addr
,
1439 if (JUMP_TABLES_IN_TEXT_SECTION
1440 #if !defined(READONLY_DATA_SECTION)
1446 = (XVECLEN (body
, 1) * GET_MODE_SIZE (GET_MODE (body
)));
1447 insn_current_address
+= insn_lengths
[uid
];
1448 if (insn_lengths
[uid
] != old_length
)
1449 something_changed
= 1;
1454 #endif /* CASE_VECTOR_SHORTEN_MODE */
1456 if (! (varying_length
[uid
]))
1458 insn_current_address
+= insn_lengths
[uid
];
1461 if (GET_CODE (insn
) == INSN
&& GET_CODE (PATTERN (insn
)) == SEQUENCE
)
1465 body
= PATTERN (insn
);
1467 for (i
= 0; i
< XVECLEN (body
, 0); i
++)
1469 rtx inner_insn
= XVECEXP (body
, 0, i
);
1470 int inner_uid
= INSN_UID (inner_insn
);
1473 INSN_ADDRESSES (inner_uid
) = insn_current_address
;
1475 /* insn_current_length returns 0 for insns with a
1476 non-varying length. */
1477 if (! varying_length
[inner_uid
])
1478 inner_length
= insn_lengths
[inner_uid
];
1480 inner_length
= insn_current_length (inner_insn
);
1482 if (inner_length
!= insn_lengths
[inner_uid
])
1484 insn_lengths
[inner_uid
] = inner_length
;
1485 something_changed
= 1;
1487 insn_current_address
+= insn_lengths
[inner_uid
];
1488 new_length
+= inner_length
;
1493 new_length
= insn_current_length (insn
);
1494 insn_current_address
+= new_length
;
1497 #ifdef ADJUST_INSN_LENGTH
1498 /* If needed, do any adjustment. */
1499 tmp_length
= new_length
;
1500 ADJUST_INSN_LENGTH (insn
, new_length
);
1501 insn_current_address
+= (new_length
- tmp_length
);
1504 if (new_length
!= insn_lengths
[uid
])
1506 insn_lengths
[uid
] = new_length
;
1507 something_changed
= 1;
1510 /* For a non-optimizing compile, do only a single pass. */
1515 free (varying_length
);
1517 #endif /* HAVE_ATTR_length */
1520 #ifdef HAVE_ATTR_length
1521 /* Given the body of an INSN known to be generated by an ASM statement, return
1522 the number of machine instructions likely to be generated for this insn.
1523 This is used to compute its length. */
1526 asm_insn_count (body
)
1529 const char *template;
1532 if (GET_CODE (body
) == ASM_INPUT
)
1533 template = XSTR (body
, 0);
1535 template = decode_asm_operands (body
, NULL
, NULL
, NULL
, NULL
);
1537 for (; *template; template++)
1538 if (IS_ASM_LOGICAL_LINE_SEPARATOR (*template) || *template == '\n')
1545 /* Output assembler code for the start of a function,
1546 and initialize some of the variables in this file
1547 for the new function. The label for the function and associated
1548 assembler pseudo-ops have already been output in `assemble_start_function'.
1550 FIRST is the first insn of the rtl for the function being compiled.
1551 FILE is the file to write assembler code to.
1552 OPTIMIZE is nonzero if we should eliminate redundant
1553 test and compare insns. */
1556 final_start_function (first
, file
, optimize
)
1559 int optimize ATTRIBUTE_UNUSED
;
1563 this_is_asm_operands
= 0;
1565 #ifdef NON_SAVING_SETJMP
1566 /* A function that calls setjmp should save and restore all the
1567 call-saved registers on a system where longjmp clobbers them. */
1568 if (NON_SAVING_SETJMP
&& current_function_calls_setjmp
)
1572 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
1573 if (!call_used_regs
[i
])
1574 regs_ever_live
[i
] = 1;
1578 /* Initial line number is supposed to be output
1579 before the function's prologue and label
1580 so that the function's address will not appear to be
1581 in the last statement of the preceding function. */
1582 if (NOTE_LINE_NUMBER (first
) != NOTE_INSN_DELETED
)
1583 last_linenum
= high_block_linenum
= high_function_linenum
1584 = NOTE_LINE_NUMBER (first
);
1586 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
1587 /* Output DWARF definition of the function. */
1588 if (dwarf2out_do_frame ())
1589 dwarf2out_begin_prologue ();
1591 current_function_func_begin_label
= 0;
1594 /* For SDB and XCOFF, the function beginning must be marked between
1595 the function label and the prologue. We always need this, even when
1596 -g1 was used. Defer on MIPS systems so that parameter descriptions
1597 follow function entry. */
1598 #if defined(SDB_DEBUGGING_INFO) && !defined(MIPS_DEBUGGING_INFO)
1599 if (write_symbols
== SDB_DEBUG
)
1600 sdbout_begin_function (last_linenum
);
1603 #ifdef XCOFF_DEBUGGING_INFO
1604 if (write_symbols
== XCOFF_DEBUG
)
1605 xcoffout_begin_function (file
, last_linenum
);
1608 /* But only output line number for other debug info types if -g2
1610 if (NOTE_LINE_NUMBER (first
) != NOTE_INSN_DELETED
)
1611 output_source_line (file
, first
);
1613 #ifdef LEAF_REG_REMAP
1614 if (current_function_uses_only_leaf_regs
)
1615 leaf_renumber_regs (first
);
1618 /* The Sun386i and perhaps other machines don't work right
1619 if the profiling code comes after the prologue. */
1620 #ifdef PROFILE_BEFORE_PROLOGUE
1622 profile_function (file
);
1623 #endif /* PROFILE_BEFORE_PROLOGUE */
1625 #if defined (DWARF2_UNWIND_INFO) && defined (HAVE_prologue)
1626 if (dwarf2out_do_frame ())
1627 dwarf2out_frame_debug (NULL_RTX
);
1630 /* If debugging, assign block numbers to all of the blocks in this
1634 number_blocks (current_function_decl
);
1635 remove_unnecessary_notes ();
1636 /* We never actually put out begin/end notes for the top-level
1637 block in the function. But, conceptually, that block is
1639 TREE_ASM_WRITTEN (DECL_INITIAL (current_function_decl
)) = 1;
1642 #ifdef FUNCTION_PROLOGUE
1643 /* First output the function prologue: code to set up the stack frame. */
1644 FUNCTION_PROLOGUE (file
, get_frame_size ());
1647 /* If the machine represents the prologue as RTL, the profiling code must
1648 be emitted when NOTE_INSN_PROLOGUE_END is scanned. */
1649 #ifdef HAVE_prologue
1650 if (! HAVE_prologue
)
1652 profile_after_prologue (file
);
1656 /* If we are doing basic block profiling, remember a printable version
1657 of the function name. */
1658 if (profile_block_flag
)
1661 add_bb_string ((*decl_printable_name
) (current_function_decl
, 2),
1667 profile_after_prologue (file
)
1668 FILE *file ATTRIBUTE_UNUSED
;
1670 #ifdef FUNCTION_BLOCK_PROFILER
1671 if (profile_block_flag
)
1673 FUNCTION_BLOCK_PROFILER (file
, count_basic_blocks
);
1675 #endif /* FUNCTION_BLOCK_PROFILER */
1677 #ifndef PROFILE_BEFORE_PROLOGUE
1679 profile_function (file
);
1680 #endif /* not PROFILE_BEFORE_PROLOGUE */
1684 profile_function (file
)
1687 #ifndef NO_PROFILE_COUNTERS
1688 int align
= MIN (BIGGEST_ALIGNMENT
, LONG_TYPE_SIZE
);
1690 #if defined(ASM_OUTPUT_REG_PUSH)
1691 #if defined(STRUCT_VALUE_INCOMING_REGNUM) || defined(STRUCT_VALUE_REGNUM)
1692 int sval
= current_function_returns_struct
;
1694 #if defined(STATIC_CHAIN_INCOMING_REGNUM) || defined(STATIC_CHAIN_REGNUM)
1695 int cxt
= current_function_needs_context
;
1697 #endif /* ASM_OUTPUT_REG_PUSH */
1699 #ifndef NO_PROFILE_COUNTERS
1701 ASM_OUTPUT_ALIGN (file
, floor_log2 (align
/ BITS_PER_UNIT
));
1702 ASM_OUTPUT_INTERNAL_LABEL (file
, "LP", profile_label_no
);
1703 assemble_integer (const0_rtx
, LONG_TYPE_SIZE
/ BITS_PER_UNIT
, 1);
1706 function_section (current_function_decl
);
1708 #if defined(STRUCT_VALUE_INCOMING_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
1710 ASM_OUTPUT_REG_PUSH (file
, STRUCT_VALUE_INCOMING_REGNUM
);
1712 #if defined(STRUCT_VALUE_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
1715 ASM_OUTPUT_REG_PUSH (file
, STRUCT_VALUE_REGNUM
);
1720 #if defined(STATIC_CHAIN_INCOMING_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
1722 ASM_OUTPUT_REG_PUSH (file
, STATIC_CHAIN_INCOMING_REGNUM
);
1724 #if defined(STATIC_CHAIN_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
1727 ASM_OUTPUT_REG_PUSH (file
, STATIC_CHAIN_REGNUM
);
1732 FUNCTION_PROFILER (file
, profile_label_no
);
1734 #if defined(STATIC_CHAIN_INCOMING_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
1736 ASM_OUTPUT_REG_POP (file
, STATIC_CHAIN_INCOMING_REGNUM
);
1738 #if defined(STATIC_CHAIN_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
1741 ASM_OUTPUT_REG_POP (file
, STATIC_CHAIN_REGNUM
);
1746 #if defined(STRUCT_VALUE_INCOMING_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
1748 ASM_OUTPUT_REG_POP (file
, STRUCT_VALUE_INCOMING_REGNUM
);
1750 #if defined(STRUCT_VALUE_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
1753 ASM_OUTPUT_REG_POP (file
, STRUCT_VALUE_REGNUM
);
1759 /* Output assembler code for the end of a function.
1760 For clarity, args are same as those of `final_start_function'
1761 even though not all of them are needed. */
1764 final_end_function (first
, file
, optimize
)
1765 rtx first ATTRIBUTE_UNUSED
;
1766 FILE *file ATTRIBUTE_UNUSED
;
1767 int optimize ATTRIBUTE_UNUSED
;
1771 #ifdef SDB_DEBUGGING_INFO
1772 if (write_symbols
== SDB_DEBUG
)
1773 sdbout_end_function (high_function_linenum
);
1776 #ifdef DWARF_DEBUGGING_INFO
1777 if (write_symbols
== DWARF_DEBUG
)
1778 dwarfout_end_function ();
1781 #ifdef XCOFF_DEBUGGING_INFO
1782 if (write_symbols
== XCOFF_DEBUG
)
1783 xcoffout_end_function (file
, high_function_linenum
);
1786 #ifdef FUNCTION_EPILOGUE
1787 /* Finally, output the function epilogue:
1788 code to restore the stack frame and return to the caller. */
1789 FUNCTION_EPILOGUE (file
, get_frame_size ());
1792 #ifdef SDB_DEBUGGING_INFO
1793 if (write_symbols
== SDB_DEBUG
)
1794 sdbout_end_epilogue ();
1797 #ifdef DWARF_DEBUGGING_INFO
1798 if (write_symbols
== DWARF_DEBUG
)
1799 dwarfout_end_epilogue ();
1802 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
1803 if (dwarf2out_do_frame ())
1804 dwarf2out_end_epilogue ();
1807 #ifdef XCOFF_DEBUGGING_INFO
1808 if (write_symbols
== XCOFF_DEBUG
)
1809 xcoffout_end_epilogue (file
);
1812 bb_func_label_num
= -1; /* not in function, nuke label # */
1814 #ifdef IA64_UNWIND_INFO
1815 output_function_exception_table ();
1818 /* If FUNCTION_EPILOGUE is not defined, then the function body
1819 itself contains return instructions wherever needed. */
1822 /* Add a block to the linked list that remembers the current line/file/function
1823 for basic block profiling. Emit the label in front of the basic block and
1824 the instructions that increment the count field. */
1830 struct bb_list
*ptr
=
1831 (struct bb_list
*) permalloc (sizeof (struct bb_list
));
1833 /* Add basic block to linked list. */
1835 ptr
->line_num
= last_linenum
;
1836 ptr
->file_label_num
= bb_file_label_num
;
1837 ptr
->func_label_num
= bb_func_label_num
;
1839 bb_tail
= &ptr
->next
;
1841 /* Enable the table of basic-block use counts
1842 to point at the code it applies to. */
1843 ASM_OUTPUT_INTERNAL_LABEL (file
, "LPB", count_basic_blocks
);
1845 /* Before first insn of this basic block, increment the
1846 count of times it was entered. */
1847 #ifdef BLOCK_PROFILER
1848 BLOCK_PROFILER (file
, count_basic_blocks
);
1855 count_basic_blocks
++;
1858 /* Add a string to be used for basic block profiling. */
1861 add_bb_string (string
, perm_p
)
1866 struct bb_str
*ptr
= 0;
1870 string
= "<unknown>";
1874 /* Allocate a new string if the current string isn't permanent. If
1875 the string is permanent search for the same string in other
1878 len
= strlen (string
) + 1;
1881 char *p
= (char *) permalloc (len
);
1882 memcpy (p
, string
, len
);
1886 for (ptr
= sbb_head
; ptr
!= (struct bb_str
*) 0; ptr
= ptr
->next
)
1887 if (ptr
->string
== string
)
1890 /* Allocate a new string block if we need to. */
1893 ptr
= (struct bb_str
*) permalloc (sizeof (*ptr
));
1896 ptr
->label_num
= sbb_label_num
++;
1897 ptr
->string
= string
;
1899 sbb_tail
= &ptr
->next
;
1902 return ptr
->label_num
;
1905 /* Output assembler code for some insns: all or part of a function.
1906 For description of args, see `final_start_function', above.
1908 PRESCAN is 1 if we are not really outputting,
1909 just scanning as if we were outputting.
1910 Prescanning deletes and rearranges insns just like ordinary output.
1911 PRESCAN is -2 if we are outputting after having prescanned.
1912 In this case, don't try to delete or rearrange insns
1913 because that has already been done.
1914 Prescanning is done only on certain machines. */
1917 final (first
, file
, optimize
, prescan
)
1927 last_ignored_compare
= 0;
1930 /* Make a map indicating which line numbers appear in this function.
1931 When producing SDB debugging info, delete troublesome line number
1932 notes from inlined functions in other files as well as duplicate
1933 line number notes. */
1934 #ifdef SDB_DEBUGGING_INFO
1935 if (write_symbols
== SDB_DEBUG
)
1938 for (insn
= first
; insn
; insn
= NEXT_INSN (insn
))
1939 if (GET_CODE (insn
) == NOTE
&& NOTE_LINE_NUMBER (insn
) > 0)
1941 if ((RTX_INTEGRATED_P (insn
)
1942 && strcmp (NOTE_SOURCE_FILE (insn
), main_input_filename
) != 0)
1944 && NOTE_LINE_NUMBER (insn
) == NOTE_LINE_NUMBER (last
)
1945 && NOTE_SOURCE_FILE (insn
) == NOTE_SOURCE_FILE (last
)))
1947 NOTE_LINE_NUMBER (insn
) = NOTE_INSN_DELETED
;
1948 NOTE_SOURCE_FILE (insn
) = 0;
1952 if (NOTE_LINE_NUMBER (insn
) > max_line
)
1953 max_line
= NOTE_LINE_NUMBER (insn
);
1959 for (insn
= first
; insn
; insn
= NEXT_INSN (insn
))
1960 if (GET_CODE (insn
) == NOTE
&& NOTE_LINE_NUMBER (insn
) > max_line
)
1961 max_line
= NOTE_LINE_NUMBER (insn
);
1964 line_note_exists
= (char *) xcalloc (max_line
+ 1, sizeof (char));
1966 for (insn
= first
; insn
; insn
= NEXT_INSN (insn
))
1968 if (INSN_UID (insn
) > max_uid
) /* find largest UID */
1969 max_uid
= INSN_UID (insn
);
1970 if (GET_CODE (insn
) == NOTE
&& NOTE_LINE_NUMBER (insn
) > 0)
1971 line_note_exists
[NOTE_LINE_NUMBER (insn
)] = 1;
1973 /* If CC tracking across branches is enabled, record the insn which
1974 jumps to each branch only reached from one place. */
1975 if (optimize
&& GET_CODE (insn
) == JUMP_INSN
)
1977 rtx lab
= JUMP_LABEL (insn
);
1978 if (lab
&& LABEL_NUSES (lab
) == 1)
1980 LABEL_REFS (lab
) = insn
;
1990 /* Output the insns. */
1991 for (insn
= NEXT_INSN (first
); insn
;)
1993 #ifdef HAVE_ATTR_length
1994 if (INSN_UID (insn
) >= INSN_ADDRESSES_SIZE ())
1997 /* Irritatingly, the reg-stack pass is creating new instructions
1998 and because of REG_DEAD note abuse it has to run after
1999 shorten_branches. Fake address of -1 then. */
2000 insn_current_address
= -1;
2002 /* This can be triggered by bugs elsewhere in the compiler if
2003 new insns are created after init_insn_lengths is called. */
2008 insn_current_address
= INSN_ADDRESSES (INSN_UID (insn
));
2009 #endif /* HAVE_ATTR_length */
2011 insn
= final_scan_insn (insn
, file
, optimize
, prescan
, 0);
2014 /* Do basic-block profiling here
2015 if the last insn was a conditional branch. */
2016 if (profile_block_flag
&& new_block
)
2019 free (line_note_exists
);
2020 line_note_exists
= NULL
;
2024 get_insn_template (code
, insn
)
2028 const void *output
= insn_data
[code
].output
;
2029 switch (insn_data
[code
].output_format
)
2031 case INSN_OUTPUT_FORMAT_SINGLE
:
2032 return (const char *) output
;
2033 case INSN_OUTPUT_FORMAT_MULTI
:
2034 return ((const char *const *) output
)[which_alternative
];
2035 case INSN_OUTPUT_FORMAT_FUNCTION
:
2038 return (*(insn_output_fn
) output
) (recog_data
.operand
, insn
);
2045 /* The final scan for one insn, INSN.
2046 Args are same as in `final', except that INSN
2047 is the insn being scanned.
2048 Value returned is the next insn to be scanned.
2050 NOPEEPHOLES is the flag to disallow peephole processing (currently
2051 used for within delayed branch sequence output). */
2054 final_scan_insn (insn
, file
, optimize
, prescan
, nopeepholes
)
2057 int optimize ATTRIBUTE_UNUSED
;
2059 int nopeepholes ATTRIBUTE_UNUSED
;
2067 /* Ignore deleted insns. These can occur when we split insns (due to a
2068 template of "#") while not optimizing. */
2069 if (INSN_DELETED_P (insn
))
2070 return NEXT_INSN (insn
);
2072 switch (GET_CODE (insn
))
2078 switch (NOTE_LINE_NUMBER (insn
))
2080 case NOTE_INSN_DELETED
:
2081 case NOTE_INSN_LOOP_BEG
:
2082 case NOTE_INSN_LOOP_END
:
2083 case NOTE_INSN_LOOP_CONT
:
2084 case NOTE_INSN_LOOP_VTOP
:
2085 case NOTE_INSN_FUNCTION_END
:
2086 case NOTE_INSN_SETJMP
:
2087 case NOTE_INSN_REPEATED_LINE_NUMBER
:
2088 case NOTE_INSN_RANGE_BEG
:
2089 case NOTE_INSN_RANGE_END
:
2090 case NOTE_INSN_LIVE
:
2091 case NOTE_INSN_EXPECTED_VALUE
:
2094 case NOTE_INSN_BASIC_BLOCK
:
2095 #ifdef IA64_UNWIND_INFO
2096 IA64_UNWIND_EMIT (asm_out_file
, insn
);
2099 fprintf (asm_out_file
, "\t%s basic block %d\n",
2100 ASM_COMMENT_START
, NOTE_BASIC_BLOCK (insn
)->index
);
2103 case NOTE_INSN_EH_REGION_BEG
:
2104 ASM_OUTPUT_DEBUG_LABEL (asm_out_file
, "LEHB",
2105 NOTE_EH_HANDLER (insn
));
2108 case NOTE_INSN_EH_REGION_END
:
2109 ASM_OUTPUT_DEBUG_LABEL (asm_out_file
, "LEHE",
2110 NOTE_EH_HANDLER (insn
));
2113 case NOTE_INSN_PROLOGUE_END
:
2114 #ifdef FUNCTION_END_PROLOGUE
2115 FUNCTION_END_PROLOGUE (file
);
2117 profile_after_prologue (file
);
2120 case NOTE_INSN_EPILOGUE_BEG
:
2121 #ifdef FUNCTION_BEGIN_EPILOGUE
2122 FUNCTION_BEGIN_EPILOGUE (file
);
2126 case NOTE_INSN_FUNCTION_BEG
:
2127 #if defined(SDB_DEBUGGING_INFO) && defined(MIPS_DEBUGGING_INFO)
2128 /* MIPS stabs require the parameter descriptions to be after the
2129 function entry point rather than before. */
2130 if (write_symbols
== SDB_DEBUG
)
2133 sdbout_begin_function (last_linenum
);
2136 #ifdef DWARF_DEBUGGING_INFO
2137 /* This outputs a marker where the function body starts, so it
2138 must be after the prologue. */
2139 if (write_symbols
== DWARF_DEBUG
)
2142 dwarfout_begin_function ();
2147 case NOTE_INSN_BLOCK_BEG
:
2148 if (debug_info_level
== DINFO_LEVEL_NORMAL
2149 || debug_info_level
== DINFO_LEVEL_VERBOSE
2150 || write_symbols
== DWARF_DEBUG
2151 || write_symbols
== DWARF2_DEBUG
)
2153 int n
= BLOCK_NUMBER (NOTE_BLOCK (insn
));
2157 high_block_linenum
= last_linenum
;
2159 /* Output debugging info about the symbol-block beginning. */
2160 #ifdef SDB_DEBUGGING_INFO
2161 if (write_symbols
== SDB_DEBUG
)
2162 sdbout_begin_block (file
, last_linenum
, n
);
2164 #ifdef XCOFF_DEBUGGING_INFO
2165 if (write_symbols
== XCOFF_DEBUG
)
2166 xcoffout_begin_block (file
, last_linenum
, n
);
2168 #ifdef DBX_DEBUGGING_INFO
2169 if (write_symbols
== DBX_DEBUG
)
2170 ASM_OUTPUT_INTERNAL_LABEL (file
, "LBB", n
);
2172 #ifdef DWARF_DEBUGGING_INFO
2173 if (write_symbols
== DWARF_DEBUG
)
2174 dwarfout_begin_block (n
);
2176 #ifdef DWARF2_DEBUGGING_INFO
2177 if (write_symbols
== DWARF2_DEBUG
)
2178 dwarf2out_begin_block (n
);
2181 /* Mark this block as output. */
2182 TREE_ASM_WRITTEN (NOTE_BLOCK (insn
)) = 1;
2186 case NOTE_INSN_BLOCK_END
:
2187 if (debug_info_level
== DINFO_LEVEL_NORMAL
2188 || debug_info_level
== DINFO_LEVEL_VERBOSE
2189 || write_symbols
== DWARF_DEBUG
2190 || write_symbols
== DWARF2_DEBUG
)
2192 int n
= BLOCK_NUMBER (NOTE_BLOCK (insn
));
2196 /* End of a symbol-block. */
2198 if (block_depth
< 0)
2201 #ifdef XCOFF_DEBUGGING_INFO
2202 if (write_symbols
== XCOFF_DEBUG
)
2203 xcoffout_end_block (file
, high_block_linenum
, n
);
2205 #ifdef DBX_DEBUGGING_INFO
2206 if (write_symbols
== DBX_DEBUG
)
2207 ASM_OUTPUT_INTERNAL_LABEL (file
, "LBE", n
);
2209 #ifdef SDB_DEBUGGING_INFO
2210 if (write_symbols
== SDB_DEBUG
)
2211 sdbout_end_block (file
, high_block_linenum
, n
);
2213 #ifdef DWARF_DEBUGGING_INFO
2214 if (write_symbols
== DWARF_DEBUG
)
2215 dwarfout_end_block (n
);
2217 #ifdef DWARF2_DEBUGGING_INFO
2218 if (write_symbols
== DWARF2_DEBUG
)
2219 dwarf2out_end_block (n
);
2224 case NOTE_INSN_DELETED_LABEL
:
2225 /* Emit the label. We may have deleted the CODE_LABEL because
2226 the label could be proved to be unreachable, though still
2227 referenced (in the form of having its address taken. */
2228 ASM_OUTPUT_DEBUG_LABEL (file
, "L", CODE_LABEL_NUMBER (insn
));
2235 if (NOTE_LINE_NUMBER (insn
) <= 0)
2238 /* This note is a line-number. */
2243 /* If there is anything real after this note, output it.
2244 If another line note follows, omit this one. */
2245 for (note
= NEXT_INSN (insn
); note
; note
= NEXT_INSN (note
))
2247 if (GET_CODE (note
) != NOTE
&& GET_CODE (note
) != CODE_LABEL
)
2250 /* These types of notes can be significant
2251 so make sure the preceding line number stays. */
2252 else if (GET_CODE (note
) == NOTE
2253 && (NOTE_LINE_NUMBER (note
) == NOTE_INSN_BLOCK_BEG
2254 || NOTE_LINE_NUMBER (note
) == NOTE_INSN_BLOCK_END
2255 || NOTE_LINE_NUMBER (note
) == NOTE_INSN_FUNCTION_BEG
))
2257 else if (GET_CODE (note
) == NOTE
&& NOTE_LINE_NUMBER (note
) > 0)
2259 /* Another line note follows; we can delete this note
2260 if no intervening line numbers have notes elsewhere. */
2262 for (num
= NOTE_LINE_NUMBER (insn
) + 1;
2263 num
< NOTE_LINE_NUMBER (note
);
2265 if (line_note_exists
[num
])
2268 if (num
>= NOTE_LINE_NUMBER (note
))
2274 /* Output this line note if it is the first or the last line
2277 output_source_line (file
, insn
);
2284 #if defined (DWARF2_UNWIND_INFO)
2285 if (dwarf2out_do_frame ())
2286 dwarf2out_frame_debug (insn
);
2291 /* The target port might emit labels in the output function for
2292 some insn, e.g. sh.c output_branchy_insn. */
2293 if (CODE_LABEL_NUMBER (insn
) <= max_labelno
)
2295 int align
= LABEL_TO_ALIGNMENT (insn
);
2296 #ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
2297 int max_skip
= LABEL_TO_MAX_SKIP (insn
);
2300 if (align
&& NEXT_INSN (insn
))
2301 #ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
2302 ASM_OUTPUT_MAX_SKIP_ALIGN (file
, align
, max_skip
);
2304 ASM_OUTPUT_ALIGN (file
, align
);
2309 /* If this label is reached from only one place, set the condition
2310 codes from the instruction just before the branch. */
2312 /* Disabled because some insns set cc_status in the C output code
2313 and NOTICE_UPDATE_CC alone can set incorrect status. */
2314 if (0 /* optimize && LABEL_NUSES (insn) == 1*/)
2316 rtx jump
= LABEL_REFS (insn
);
2317 rtx barrier
= prev_nonnote_insn (insn
);
2319 /* If the LABEL_REFS field of this label has been set to point
2320 at a branch, the predecessor of the branch is a regular
2321 insn, and that branch is the only way to reach this label,
2322 set the condition codes based on the branch and its
2324 if (barrier
&& GET_CODE (barrier
) == BARRIER
2325 && jump
&& GET_CODE (jump
) == JUMP_INSN
2326 && (prev
= prev_nonnote_insn (jump
))
2327 && GET_CODE (prev
) == INSN
)
2329 NOTICE_UPDATE_CC (PATTERN (prev
), prev
);
2330 NOTICE_UPDATE_CC (PATTERN (jump
), jump
);
2338 #ifdef FINAL_PRESCAN_LABEL
2339 FINAL_PRESCAN_INSN (insn
, NULL
, 0);
2342 #ifdef SDB_DEBUGGING_INFO
2343 if (write_symbols
== SDB_DEBUG
&& LABEL_NAME (insn
))
2344 sdbout_label (insn
);
2348 fputs (ASM_APP_OFF
, file
);
2351 if (NEXT_INSN (insn
) != 0
2352 && GET_CODE (NEXT_INSN (insn
)) == JUMP_INSN
)
2354 rtx nextbody
= PATTERN (NEXT_INSN (insn
));
2356 /* If this label is followed by a jump-table,
2357 make sure we put the label in the read-only section. Also
2358 possibly write the label and jump table together. */
2360 if (GET_CODE (nextbody
) == ADDR_VEC
2361 || GET_CODE (nextbody
) == ADDR_DIFF_VEC
)
2363 #if defined(ASM_OUTPUT_ADDR_VEC) || defined(ASM_OUTPUT_ADDR_DIFF_VEC)
2364 /* In this case, the case vector is being moved by the
2365 target, so don't output the label at all. Leave that
2366 to the back end macros. */
2368 if (! JUMP_TABLES_IN_TEXT_SECTION
)
2370 readonly_data_section ();
2371 #ifdef READONLY_DATA_SECTION
2372 ASM_OUTPUT_ALIGN (file
,
2373 exact_log2 (BIGGEST_ALIGNMENT
2375 #endif /* READONLY_DATA_SECTION */
2378 function_section (current_function_decl
);
2380 #ifdef ASM_OUTPUT_CASE_LABEL
2381 ASM_OUTPUT_CASE_LABEL (file
, "L", CODE_LABEL_NUMBER (insn
),
2384 if (LABEL_ALTERNATE_NAME (insn
))
2385 ASM_OUTPUT_ALTERNATE_LABEL_NAME (file
, insn
);
2387 ASM_OUTPUT_INTERNAL_LABEL (file
, "L", CODE_LABEL_NUMBER (insn
));
2393 if (LABEL_ALTERNATE_NAME (insn
))
2394 ASM_OUTPUT_ALTERNATE_LABEL_NAME (file
, insn
);
2396 ASM_OUTPUT_INTERNAL_LABEL (file
, "L", CODE_LABEL_NUMBER (insn
));
2401 register rtx body
= PATTERN (insn
);
2402 int insn_code_number
;
2403 const char *template;
2408 /* An INSN, JUMP_INSN or CALL_INSN.
2409 First check for special kinds that recog doesn't recognize. */
2411 if (GET_CODE (body
) == USE
/* These are just declarations */
2412 || GET_CODE (body
) == CLOBBER
)
2416 /* If there is a REG_CC_SETTER note on this insn, it means that
2417 the setting of the condition code was done in the delay slot
2418 of the insn that branched here. So recover the cc status
2419 from the insn that set it. */
2421 note
= find_reg_note (insn
, REG_CC_SETTER
, NULL_RTX
);
2424 NOTICE_UPDATE_CC (PATTERN (XEXP (note
, 0)), XEXP (note
, 0));
2425 cc_prev_status
= cc_status
;
2429 /* Detect insns that are really jump-tables
2430 and output them as such. */
2432 if (GET_CODE (body
) == ADDR_VEC
|| GET_CODE (body
) == ADDR_DIFF_VEC
)
2434 #if !(defined(ASM_OUTPUT_ADDR_VEC) || defined(ASM_OUTPUT_ADDR_DIFF_VEC))
2435 register int vlen
, idx
;
2443 fputs (ASM_APP_OFF
, file
);
2447 #if defined(ASM_OUTPUT_ADDR_VEC) || defined(ASM_OUTPUT_ADDR_DIFF_VEC)
2448 if (GET_CODE (body
) == ADDR_VEC
)
2450 #ifdef ASM_OUTPUT_ADDR_VEC
2451 ASM_OUTPUT_ADDR_VEC (PREV_INSN (insn
), body
);
2458 #ifdef ASM_OUTPUT_ADDR_DIFF_VEC
2459 ASM_OUTPUT_ADDR_DIFF_VEC (PREV_INSN (insn
), body
);
2465 vlen
= XVECLEN (body
, GET_CODE (body
) == ADDR_DIFF_VEC
);
2466 for (idx
= 0; idx
< vlen
; idx
++)
2468 if (GET_CODE (body
) == ADDR_VEC
)
2470 #ifdef ASM_OUTPUT_ADDR_VEC_ELT
2471 ASM_OUTPUT_ADDR_VEC_ELT
2472 (file
, CODE_LABEL_NUMBER (XEXP (XVECEXP (body
, 0, idx
), 0)));
2479 #ifdef ASM_OUTPUT_ADDR_DIFF_ELT
2480 ASM_OUTPUT_ADDR_DIFF_ELT
2483 CODE_LABEL_NUMBER (XEXP (XVECEXP (body
, 1, idx
), 0)),
2484 CODE_LABEL_NUMBER (XEXP (XEXP (body
, 0), 0)));
2490 #ifdef ASM_OUTPUT_CASE_END
2491 ASM_OUTPUT_CASE_END (file
,
2492 CODE_LABEL_NUMBER (PREV_INSN (insn
)),
2497 function_section (current_function_decl
);
2502 /* Do basic-block profiling when we reach a new block.
2503 Done here to avoid jump tables. */
2504 if (profile_block_flag
&& new_block
)
2507 if (GET_CODE (body
) == ASM_INPUT
)
2509 /* There's no telling what that did to the condition codes. */
2515 fputs (ASM_APP_ON
, file
);
2518 fprintf (asm_out_file
, "\t%s\n", XSTR (body
, 0));
2522 /* Detect `asm' construct with operands. */
2523 if (asm_noperands (body
) >= 0)
2525 unsigned int noperands
= asm_noperands (body
);
2526 rtx
*ops
= (rtx
*) alloca (noperands
* sizeof (rtx
));
2529 /* There's no telling what that did to the condition codes. */
2536 fputs (ASM_APP_ON
, file
);
2540 /* Get out the operand values. */
2541 string
= decode_asm_operands (body
, ops
, NULL
, NULL
, NULL
);
2542 /* Inhibit aborts on what would otherwise be compiler bugs. */
2543 insn_noperands
= noperands
;
2544 this_is_asm_operands
= insn
;
2546 /* Output the insn using them. */
2547 output_asm_insn (string
, ops
);
2548 this_is_asm_operands
= 0;
2552 if (prescan
<= 0 && app_on
)
2554 fputs (ASM_APP_OFF
, file
);
2558 if (GET_CODE (body
) == SEQUENCE
)
2560 /* A delayed-branch sequence */
2566 final_sequence
= body
;
2568 /* The first insn in this SEQUENCE might be a JUMP_INSN that will
2569 force the restoration of a comparison that was previously
2570 thought unnecessary. If that happens, cancel this sequence
2571 and cause that insn to be restored. */
2573 next
= final_scan_insn (XVECEXP (body
, 0, 0), file
, 0, prescan
, 1);
2574 if (next
!= XVECEXP (body
, 0, 1))
2580 for (i
= 1; i
< XVECLEN (body
, 0); i
++)
2582 rtx insn
= XVECEXP (body
, 0, i
);
2583 rtx next
= NEXT_INSN (insn
);
2584 /* We loop in case any instruction in a delay slot gets
2587 insn
= final_scan_insn (insn
, file
, 0, prescan
, 1);
2588 while (insn
!= next
);
2590 #ifdef DBR_OUTPUT_SEQEND
2591 DBR_OUTPUT_SEQEND (file
);
2595 /* If the insn requiring the delay slot was a CALL_INSN, the
2596 insns in the delay slot are actually executed before the
2597 called function. Hence we don't preserve any CC-setting
2598 actions in these insns and the CC must be marked as being
2599 clobbered by the function. */
2600 if (GET_CODE (XVECEXP (body
, 0, 0)) == CALL_INSN
)
2605 /* Following a conditional branch sequence, we have a new basic
2607 if (profile_block_flag
)
2609 rtx insn
= XVECEXP (body
, 0, 0);
2610 rtx body
= PATTERN (insn
);
2612 if ((GET_CODE (insn
) == JUMP_INSN
&& GET_CODE (body
) == SET
2613 && GET_CODE (SET_SRC (body
)) != LABEL_REF
)
2614 || (GET_CODE (insn
) == JUMP_INSN
2615 && GET_CODE (body
) == PARALLEL
2616 && GET_CODE (XVECEXP (body
, 0, 0)) == SET
2617 && GET_CODE (SET_SRC (XVECEXP (body
, 0, 0))) != LABEL_REF
))
2623 /* We have a real machine instruction as rtl. */
2625 body
= PATTERN (insn
);
2628 set
= single_set (insn
);
2630 /* Check for redundant test and compare instructions
2631 (when the condition codes are already set up as desired).
2632 This is done only when optimizing; if not optimizing,
2633 it should be possible for the user to alter a variable
2634 with the debugger in between statements
2635 and the next statement should reexamine the variable
2636 to compute the condition codes. */
2641 rtx set
= single_set (insn
);
2645 && GET_CODE (SET_DEST (set
)) == CC0
2646 && insn
!= last_ignored_compare
)
2648 if (GET_CODE (SET_SRC (set
)) == SUBREG
)
2649 SET_SRC (set
) = alter_subreg (SET_SRC (set
));
2650 else if (GET_CODE (SET_SRC (set
)) == COMPARE
)
2652 if (GET_CODE (XEXP (SET_SRC (set
), 0)) == SUBREG
)
2653 XEXP (SET_SRC (set
), 0)
2654 = alter_subreg (XEXP (SET_SRC (set
), 0));
2655 if (GET_CODE (XEXP (SET_SRC (set
), 1)) == SUBREG
)
2656 XEXP (SET_SRC (set
), 1)
2657 = alter_subreg (XEXP (SET_SRC (set
), 1));
2659 if ((cc_status
.value1
!= 0
2660 && rtx_equal_p (SET_SRC (set
), cc_status
.value1
))
2661 || (cc_status
.value2
!= 0
2662 && rtx_equal_p (SET_SRC (set
), cc_status
.value2
)))
2664 /* Don't delete insn if it has an addressing side-effect. */
2665 if (! FIND_REG_INC_NOTE (insn
, 0)
2666 /* or if anything in it is volatile. */
2667 && ! volatile_refs_p (PATTERN (insn
)))
2669 /* We don't really delete the insn; just ignore it. */
2670 last_ignored_compare
= insn
;
2678 /* Following a conditional branch, we have a new basic block.
2679 But if we are inside a sequence, the new block starts after the
2680 last insn of the sequence. */
2681 if (profile_block_flag
&& final_sequence
== 0
2682 && ((GET_CODE (insn
) == JUMP_INSN
&& GET_CODE (body
) == SET
2683 && GET_CODE (SET_SRC (body
)) != LABEL_REF
)
2684 || (GET_CODE (insn
) == JUMP_INSN
&& GET_CODE (body
) == PARALLEL
2685 && GET_CODE (XVECEXP (body
, 0, 0)) == SET
2686 && GET_CODE (SET_SRC (XVECEXP (body
, 0, 0))) != LABEL_REF
)))
2690 /* Don't bother outputting obvious no-ops, even without -O.
2691 This optimization is fast and doesn't interfere with debugging.
2692 Don't do this if the insn is in a delay slot, since this
2693 will cause an improper number of delay insns to be written. */
2694 if (final_sequence
== 0
2696 && GET_CODE (insn
) == INSN
&& GET_CODE (body
) == SET
2697 && GET_CODE (SET_SRC (body
)) == REG
2698 && GET_CODE (SET_DEST (body
)) == REG
2699 && REGNO (SET_SRC (body
)) == REGNO (SET_DEST (body
)))
2704 /* If this is a conditional branch, maybe modify it
2705 if the cc's are in a nonstandard state
2706 so that it accomplishes the same thing that it would
2707 do straightforwardly if the cc's were set up normally. */
2709 if (cc_status
.flags
!= 0
2710 && GET_CODE (insn
) == JUMP_INSN
2711 && GET_CODE (body
) == SET
2712 && SET_DEST (body
) == pc_rtx
2713 && GET_CODE (SET_SRC (body
)) == IF_THEN_ELSE
2714 && GET_RTX_CLASS (GET_CODE (XEXP (SET_SRC (body
), 0))) == '<'
2715 && XEXP (XEXP (SET_SRC (body
), 0), 0) == cc0_rtx
2716 /* This is done during prescan; it is not done again
2717 in final scan when prescan has been done. */
2720 /* This function may alter the contents of its argument
2721 and clear some of the cc_status.flags bits.
2722 It may also return 1 meaning condition now always true
2723 or -1 meaning condition now always false
2724 or 2 meaning condition nontrivial but altered. */
2725 register int result
= alter_cond (XEXP (SET_SRC (body
), 0));
2726 /* If condition now has fixed value, replace the IF_THEN_ELSE
2727 with its then-operand or its else-operand. */
2729 SET_SRC (body
) = XEXP (SET_SRC (body
), 1);
2731 SET_SRC (body
) = XEXP (SET_SRC (body
), 2);
2733 /* The jump is now either unconditional or a no-op.
2734 If it has become a no-op, don't try to output it.
2735 (It would not be recognized.) */
2736 if (SET_SRC (body
) == pc_rtx
)
2738 PUT_CODE (insn
, NOTE
);
2739 NOTE_LINE_NUMBER (insn
) = NOTE_INSN_DELETED
;
2740 NOTE_SOURCE_FILE (insn
) = 0;
2743 else if (GET_CODE (SET_SRC (body
)) == RETURN
)
2744 /* Replace (set (pc) (return)) with (return). */
2745 PATTERN (insn
) = body
= SET_SRC (body
);
2747 /* Rerecognize the instruction if it has changed. */
2749 INSN_CODE (insn
) = -1;
2752 /* Make same adjustments to instructions that examine the
2753 condition codes without jumping and instructions that
2754 handle conditional moves (if this machine has either one). */
2756 if (cc_status
.flags
!= 0
2759 rtx cond_rtx
, then_rtx
, else_rtx
;
2761 if (GET_CODE (insn
) != JUMP_INSN
2762 && GET_CODE (SET_SRC (set
)) == IF_THEN_ELSE
)
2764 cond_rtx
= XEXP (SET_SRC (set
), 0);
2765 then_rtx
= XEXP (SET_SRC (set
), 1);
2766 else_rtx
= XEXP (SET_SRC (set
), 2);
2770 cond_rtx
= SET_SRC (set
);
2771 then_rtx
= const_true_rtx
;
2772 else_rtx
= const0_rtx
;
2775 switch (GET_CODE (cond_rtx
))
2788 register int result
;
2789 if (XEXP (cond_rtx
, 0) != cc0_rtx
)
2791 result
= alter_cond (cond_rtx
);
2793 validate_change (insn
, &SET_SRC (set
), then_rtx
, 0);
2794 else if (result
== -1)
2795 validate_change (insn
, &SET_SRC (set
), else_rtx
, 0);
2796 else if (result
== 2)
2797 INSN_CODE (insn
) = -1;
2798 if (SET_DEST (set
) == SET_SRC (set
))
2800 PUT_CODE (insn
, NOTE
);
2801 NOTE_LINE_NUMBER (insn
) = NOTE_INSN_DELETED
;
2802 NOTE_SOURCE_FILE (insn
) = 0;
2814 #ifdef HAVE_peephole
2815 /* Do machine-specific peephole optimizations if desired. */
2817 if (optimize
&& !flag_no_peephole
&& !nopeepholes
)
2819 rtx next
= peephole (insn
);
2820 /* When peepholing, if there were notes within the peephole,
2821 emit them before the peephole. */
2822 if (next
!= 0 && next
!= NEXT_INSN (insn
))
2824 rtx prev
= PREV_INSN (insn
);
2827 for (note
= NEXT_INSN (insn
); note
!= next
;
2828 note
= NEXT_INSN (note
))
2829 final_scan_insn (note
, file
, optimize
, prescan
, nopeepholes
);
2831 /* In case this is prescan, put the notes
2832 in proper position for later rescan. */
2833 note
= NEXT_INSN (insn
);
2834 PREV_INSN (note
) = prev
;
2835 NEXT_INSN (prev
) = note
;
2836 NEXT_INSN (PREV_INSN (next
)) = insn
;
2837 PREV_INSN (insn
) = PREV_INSN (next
);
2838 NEXT_INSN (insn
) = next
;
2839 PREV_INSN (next
) = insn
;
2842 /* PEEPHOLE might have changed this. */
2843 body
= PATTERN (insn
);
2847 /* Try to recognize the instruction.
2848 If successful, verify that the operands satisfy the
2849 constraints for the instruction. Crash if they don't,
2850 since `reload' should have changed them so that they do. */
2852 insn_code_number
= recog_memoized (insn
);
2853 cleanup_subreg_operands (insn
);
2855 /* Dump the insn in the assembly for debugging. */
2856 if (flag_dump_rtl_in_asm
)
2858 print_rtx_head
= ASM_COMMENT_START
;
2859 print_rtl_single (asm_out_file
, insn
);
2860 print_rtx_head
= "";
2863 if (! constrain_operands_cached (1))
2864 fatal_insn_not_found (insn
);
2866 /* Some target machines need to prescan each insn before
2869 #ifdef FINAL_PRESCAN_INSN
2870 FINAL_PRESCAN_INSN (insn
, recog_data
.operand
, recog_data
.n_operands
);
2873 #ifdef HAVE_conditional_execution
2874 if (GET_CODE (PATTERN (insn
)) == COND_EXEC
)
2875 current_insn_predicate
= COND_EXEC_TEST (PATTERN (insn
));
2877 current_insn_predicate
= NULL_RTX
;
2881 cc_prev_status
= cc_status
;
2883 /* Update `cc_status' for this instruction.
2884 The instruction's output routine may change it further.
2885 If the output routine for a jump insn needs to depend
2886 on the cc status, it should look at cc_prev_status. */
2888 NOTICE_UPDATE_CC (body
, insn
);
2891 current_output_insn
= debug_insn
= insn
;
2893 #if defined (DWARF2_UNWIND_INFO)
2894 if (GET_CODE (insn
) == CALL_INSN
&& dwarf2out_do_frame ())
2895 dwarf2out_frame_debug (insn
);
2898 /* Find the proper template for this insn. */
2899 template = get_insn_template (insn_code_number
, insn
);
2901 /* If the C code returns 0, it means that it is a jump insn
2902 which follows a deleted test insn, and that test insn
2903 needs to be reinserted. */
2908 if (prev_nonnote_insn (insn
) != last_ignored_compare
)
2912 /* We have already processed the notes between the setter and
2913 the user. Make sure we don't process them again, this is
2914 particularly important if one of the notes is a block
2915 scope note or an EH note. */
2917 prev
!= last_ignored_compare
;
2918 prev
= PREV_INSN (prev
))
2920 if (GET_CODE (prev
) == NOTE
)
2922 NOTE_LINE_NUMBER (prev
) = NOTE_INSN_DELETED
;
2923 NOTE_SOURCE_FILE (prev
) = 0;
2930 /* If the template is the string "#", it means that this insn must
2932 if (template[0] == '#' && template[1] == '\0')
2934 rtx
new = try_split (body
, insn
, 0);
2936 /* If we didn't split the insn, go away. */
2937 if (new == insn
&& PATTERN (new) == body
)
2938 fatal_insn ("Could not split insn", insn
);
2940 #ifdef HAVE_ATTR_length
2941 /* This instruction should have been split in shorten_branches,
2942 to ensure that we would have valid length info for the
2954 #ifdef IA64_UNWIND_INFO
2955 IA64_UNWIND_EMIT (asm_out_file
, insn
);
2957 /* Output assembler code from the template. */
2959 output_asm_insn (template, recog_data
.operand
);
2961 #if defined (DWARF2_UNWIND_INFO)
2962 #if defined (HAVE_prologue)
2963 if (GET_CODE (insn
) == INSN
&& dwarf2out_do_frame ())
2964 dwarf2out_frame_debug (insn
);
2966 if (!ACCUMULATE_OUTGOING_ARGS
2967 && GET_CODE (insn
) == INSN
2968 && dwarf2out_do_frame ())
2969 dwarf2out_frame_debug (insn
);
2974 /* It's not at all clear why we did this and doing so interferes
2975 with tests we'd like to do to use REG_WAS_0 notes, so let's try
2978 /* Mark this insn as having been output. */
2979 INSN_DELETED_P (insn
) = 1;
2982 current_output_insn
= debug_insn
= 0;
2985 return NEXT_INSN (insn
);
2988 /* Output debugging info to the assembler file FILE
2989 based on the NOTE-insn INSN, assumed to be a line number. */
2992 output_source_line (file
, insn
)
2993 FILE *file ATTRIBUTE_UNUSED
;
2996 register const char *filename
= NOTE_SOURCE_FILE (insn
);
2998 /* Remember filename for basic block profiling.
2999 Filenames are allocated on the permanent obstack
3000 or are passed in ARGV, so we don't have to save
3003 if (profile_block_flag
&& last_filename
!= filename
)
3004 bb_file_label_num
= add_bb_string (filename
, TRUE
);
3006 last_filename
= filename
;
3007 last_linenum
= NOTE_LINE_NUMBER (insn
);
3008 high_block_linenum
= MAX (last_linenum
, high_block_linenum
);
3009 high_function_linenum
= MAX (last_linenum
, high_function_linenum
);
3011 if (write_symbols
!= NO_DEBUG
)
3013 #ifdef SDB_DEBUGGING_INFO
3014 if (write_symbols
== SDB_DEBUG
3015 #if 0 /* People like having line numbers even in wrong file! */
3016 /* COFF can't handle multiple source files--lose, lose. */
3017 && !strcmp (filename
, main_input_filename
)
3019 /* COFF relative line numbers must be positive. */
3020 && last_linenum
> sdb_begin_function_line
)
3022 #ifdef ASM_OUTPUT_SOURCE_LINE
3023 ASM_OUTPUT_SOURCE_LINE (file
, last_linenum
);
3025 fprintf (file
, "\t.ln\t%d\n",
3026 ((sdb_begin_function_line
> -1)
3027 ? last_linenum
- sdb_begin_function_line
: 1));
3032 #if defined (DBX_DEBUGGING_INFO)
3033 if (write_symbols
== DBX_DEBUG
)
3034 dbxout_source_line (file
, filename
, NOTE_LINE_NUMBER (insn
));
3037 #if defined (XCOFF_DEBUGGING_INFO)
3038 if (write_symbols
== XCOFF_DEBUG
)
3039 xcoffout_source_line (file
, filename
, insn
);
3042 #ifdef DWARF_DEBUGGING_INFO
3043 if (write_symbols
== DWARF_DEBUG
)
3044 dwarfout_line (filename
, NOTE_LINE_NUMBER (insn
));
3047 #ifdef DWARF2_DEBUGGING_INFO
3048 if (write_symbols
== DWARF2_DEBUG
)
3049 dwarf2out_line (filename
, NOTE_LINE_NUMBER (insn
));
3054 /* For each operand in INSN, simplify (subreg (reg)) so that it refers
3055 directly to the desired hard register. */
3058 cleanup_subreg_operands (insn
)
3062 extract_insn_cached (insn
);
3063 for (i
= 0; i
< recog_data
.n_operands
; i
++)
3065 if (GET_CODE (recog_data
.operand
[i
]) == SUBREG
)
3066 recog_data
.operand
[i
] = alter_subreg (recog_data
.operand
[i
]);
3067 else if (GET_CODE (recog_data
.operand
[i
]) == PLUS
3068 || GET_CODE (recog_data
.operand
[i
]) == MULT
3069 || GET_CODE (recog_data
.operand
[i
]) == MEM
)
3070 recog_data
.operand
[i
] = walk_alter_subreg (recog_data
.operand
[i
]);
3073 for (i
= 0; i
< recog_data
.n_dups
; i
++)
3075 if (GET_CODE (*recog_data
.dup_loc
[i
]) == SUBREG
)
3076 *recog_data
.dup_loc
[i
] = alter_subreg (*recog_data
.dup_loc
[i
]);
3077 else if (GET_CODE (*recog_data
.dup_loc
[i
]) == PLUS
3078 || GET_CODE (*recog_data
.dup_loc
[i
]) == MULT
3079 || GET_CODE (*recog_data
.dup_loc
[i
]) == MEM
)
3080 *recog_data
.dup_loc
[i
] = walk_alter_subreg (*recog_data
.dup_loc
[i
]);
3084 /* If X is a SUBREG, replace it with a REG or a MEM,
3085 based on the thing it is a subreg of. */
3091 register rtx y
= SUBREG_REG (x
);
3093 if (GET_CODE (y
) == SUBREG
)
3094 y
= alter_subreg (y
);
3096 /* If reload is operating, we may be replacing inside this SUBREG.
3097 Check for that and make a new one if so. */
3098 if (reload_in_progress
&& find_replacement (&SUBREG_REG (x
)) != 0)
3101 if (GET_CODE (y
) == REG
)
3103 int regno
= subreg_hard_regno (x
, 1);
3107 ORIGINAL_REGNO (x
) = ORIGINAL_REGNO (y
);
3108 /* This field has a different meaning for REGs and SUBREGs. Make sure
3112 else if (GET_CODE (y
) == MEM
)
3114 register int offset
= SUBREG_BYTE (x
);
3116 /* Catch these instead of generating incorrect code. */
3117 if ((offset
% GET_MODE_SIZE (GET_MODE (x
))) != 0)
3121 MEM_COPY_ATTRIBUTES (x
, y
);
3122 XEXP (x
, 0) = plus_constant (XEXP (y
, 0), offset
);
3128 /* Do alter_subreg on all the SUBREGs contained in X. */
3131 walk_alter_subreg (x
)
3134 switch (GET_CODE (x
))
3138 XEXP (x
, 0) = walk_alter_subreg (XEXP (x
, 0));
3139 XEXP (x
, 1) = walk_alter_subreg (XEXP (x
, 1));
3143 XEXP (x
, 0) = walk_alter_subreg (XEXP (x
, 0));
3147 return alter_subreg (x
);
3158 /* Given BODY, the body of a jump instruction, alter the jump condition
3159 as required by the bits that are set in cc_status.flags.
3160 Not all of the bits there can be handled at this level in all cases.
3162 The value is normally 0.
3163 1 means that the condition has become always true.
3164 -1 means that the condition has become always false.
3165 2 means that COND has been altered. */
3173 if (cc_status
.flags
& CC_REVERSED
)
3176 PUT_CODE (cond
, swap_condition (GET_CODE (cond
)));
3179 if (cc_status
.flags
& CC_INVERTED
)
3182 PUT_CODE (cond
, reverse_condition (GET_CODE (cond
)));
3185 if (cc_status
.flags
& CC_NOT_POSITIVE
)
3186 switch (GET_CODE (cond
))
3191 /* Jump becomes unconditional. */
3197 /* Jump becomes no-op. */
3201 PUT_CODE (cond
, EQ
);
3206 PUT_CODE (cond
, NE
);
3214 if (cc_status
.flags
& CC_NOT_NEGATIVE
)
3215 switch (GET_CODE (cond
))
3219 /* Jump becomes unconditional. */
3224 /* Jump becomes no-op. */
3229 PUT_CODE (cond
, EQ
);
3235 PUT_CODE (cond
, NE
);
3243 if (cc_status
.flags
& CC_NO_OVERFLOW
)
3244 switch (GET_CODE (cond
))
3247 /* Jump becomes unconditional. */
3251 PUT_CODE (cond
, EQ
);
3256 PUT_CODE (cond
, NE
);
3261 /* Jump becomes no-op. */
3268 if (cc_status
.flags
& (CC_Z_IN_NOT_N
| CC_Z_IN_N
))
3269 switch (GET_CODE (cond
))
3275 PUT_CODE (cond
, cc_status
.flags
& CC_Z_IN_N
? GE
: LT
);
3280 PUT_CODE (cond
, cc_status
.flags
& CC_Z_IN_N
? LT
: GE
);
3285 if (cc_status
.flags
& CC_NOT_SIGNED
)
3286 /* The flags are valid if signed condition operators are converted
3288 switch (GET_CODE (cond
))
3291 PUT_CODE (cond
, LEU
);
3296 PUT_CODE (cond
, LTU
);
3301 PUT_CODE (cond
, GTU
);
3306 PUT_CODE (cond
, GEU
);
3318 /* Report inconsistency between the assembler template and the operands.
3319 In an `asm', it's the user's fault; otherwise, the compiler's fault. */
3322 output_operand_lossage (msgid
)
3325 if (this_is_asm_operands
)
3326 error_for_asm (this_is_asm_operands
, "invalid `asm': %s", _(msgid
));
3328 internal_error ("output_operand: %s", _(msgid
));
3331 /* Output of assembler code from a template, and its subroutines. */
3333 /* Output text from TEMPLATE to the assembler output file,
3334 obeying %-directions to substitute operands taken from
3335 the vector OPERANDS.
3337 %N (for N a digit) means print operand N in usual manner.
3338 %lN means require operand N to be a CODE_LABEL or LABEL_REF
3339 and print the label name with no punctuation.
3340 %cN means require operand N to be a constant
3341 and print the constant expression with no punctuation.
3342 %aN means expect operand N to be a memory address
3343 (not a memory reference!) and print a reference
3345 %nN means expect operand N to be a constant
3346 and print a constant expression for minus the value
3347 of the operand, with no other punctuation. */
3352 if (flag_print_asm_name
)
3354 /* Annotate the assembly with a comment describing the pattern and
3355 alternative used. */
3358 register int num
= INSN_CODE (debug_insn
);
3359 fprintf (asm_out_file
, "\t%s %d\t%s",
3360 ASM_COMMENT_START
, INSN_UID (debug_insn
),
3361 insn_data
[num
].name
);
3362 if (insn_data
[num
].n_alternatives
> 1)
3363 fprintf (asm_out_file
, "/%d", which_alternative
+ 1);
3364 #ifdef HAVE_ATTR_length
3365 fprintf (asm_out_file
, "\t[length = %d]",
3366 get_attr_length (debug_insn
));
3368 /* Clear this so only the first assembler insn
3369 of any rtl insn will get the special comment for -dp. */
3376 output_asm_insn (template, operands
)
3377 const char *template;
3380 register const char *p
;
3383 /* An insn may return a null string template
3384 in a case where no assembler code is needed. */
3389 putc ('\t', asm_out_file
);
3391 #ifdef ASM_OUTPUT_OPCODE
3392 ASM_OUTPUT_OPCODE (asm_out_file
, p
);
3400 putc (c
, asm_out_file
);
3401 #ifdef ASM_OUTPUT_OPCODE
3402 while ((c
= *p
) == '\t')
3404 putc (c
, asm_out_file
);
3407 ASM_OUTPUT_OPCODE (asm_out_file
, p
);
3411 #ifdef ASSEMBLER_DIALECT
3416 /* If we want the first dialect, do nothing. Otherwise, skip
3417 DIALECT_NUMBER of strings ending with '|'. */
3418 for (i
= 0; i
< dialect_number
; i
++)
3420 while (*p
&& *p
!= '}' && *p
++ != '|')
3431 /* Skip to close brace. */
3432 while (*p
&& *p
++ != '}')
3441 /* %% outputs a single %. */
3445 putc (c
, asm_out_file
);
3447 /* %= outputs a number which is unique to each insn in the entire
3448 compilation. This is useful for making local labels that are
3449 referred to more than once in a given insn. */
3453 fprintf (asm_out_file
, "%d", insn_counter
);
3455 /* % followed by a letter and some digits
3456 outputs an operand in a special way depending on the letter.
3457 Letters `acln' are implemented directly.
3458 Other letters are passed to `output_operand' so that
3459 the PRINT_OPERAND macro can define them. */
3460 else if (ISLOWER (*p
) || ISUPPER (*p
))
3465 if (! (*p
>= '0' && *p
<= '9'))
3466 output_operand_lossage ("operand number missing after %-letter");
3467 else if (this_is_asm_operands
&& (c
< 0 || (unsigned int) c
>= insn_noperands
))
3468 output_operand_lossage ("operand number out of range");
3469 else if (letter
== 'l')
3470 output_asm_label (operands
[c
]);
3471 else if (letter
== 'a')
3472 output_address (operands
[c
]);
3473 else if (letter
== 'c')
3475 if (CONSTANT_ADDRESS_P (operands
[c
]))
3476 output_addr_const (asm_out_file
, operands
[c
]);
3478 output_operand (operands
[c
], 'c');
3480 else if (letter
== 'n')
3482 if (GET_CODE (operands
[c
]) == CONST_INT
)
3483 fprintf (asm_out_file
, HOST_WIDE_INT_PRINT_DEC
,
3484 - INTVAL (operands
[c
]));
3487 putc ('-', asm_out_file
);
3488 output_addr_const (asm_out_file
, operands
[c
]);
3492 output_operand (operands
[c
], letter
);
3494 while ((c
= *p
) >= '0' && c
<= '9')
3497 /* % followed by a digit outputs an operand the default way. */
3498 else if (*p
>= '0' && *p
<= '9')
3501 if (this_is_asm_operands
3502 && (c
< 0 || (unsigned int) c
>= insn_noperands
))
3503 output_operand_lossage ("operand number out of range");
3505 output_operand (operands
[c
], 0);
3506 while ((c
= *p
) >= '0' && c
<= '9')
3509 /* % followed by punctuation: output something for that
3510 punctuation character alone, with no operand.
3511 The PRINT_OPERAND macro decides what is actually done. */
3512 #ifdef PRINT_OPERAND_PUNCT_VALID_P
3513 else if (PRINT_OPERAND_PUNCT_VALID_P ((unsigned char) *p
))
3514 output_operand (NULL_RTX
, *p
++);
3517 output_operand_lossage ("invalid %%-code");
3521 putc (c
, asm_out_file
);
3526 putc ('\n', asm_out_file
);
3529 /* Output a LABEL_REF, or a bare CODE_LABEL, as an assembler symbol. */
3532 output_asm_label (x
)
3537 if (GET_CODE (x
) == LABEL_REF
)
3539 if (GET_CODE (x
) == CODE_LABEL
3540 || (GET_CODE (x
) == NOTE
3541 && NOTE_LINE_NUMBER (x
) == NOTE_INSN_DELETED_LABEL
))
3542 ASM_GENERATE_INTERNAL_LABEL (buf
, "L", CODE_LABEL_NUMBER (x
));
3544 output_operand_lossage ("`%l' operand isn't a label");
3546 assemble_name (asm_out_file
, buf
);
3549 /* Print operand X using machine-dependent assembler syntax.
3550 The macro PRINT_OPERAND is defined just to control this function.
3551 CODE is a non-digit that preceded the operand-number in the % spec,
3552 such as 'z' if the spec was `%z3'. CODE is 0 if there was no char
3553 between the % and the digits.
3554 When CODE is a non-letter, X is 0.
3556 The meanings of the letters are machine-dependent and controlled
3557 by PRINT_OPERAND. */
3560 output_operand (x
, code
)
3562 int code ATTRIBUTE_UNUSED
;
3564 if (x
&& GET_CODE (x
) == SUBREG
)
3565 x
= alter_subreg (x
);
3567 /* If X is a pseudo-register, abort now rather than writing trash to the
3570 if (x
&& GET_CODE (x
) == REG
&& REGNO (x
) >= FIRST_PSEUDO_REGISTER
)
3573 PRINT_OPERAND (asm_out_file
, x
, code
);
3576 /* Print a memory reference operand for address X
3577 using machine-dependent assembler syntax.
3578 The macro PRINT_OPERAND_ADDRESS exists just to control this function. */
3584 walk_alter_subreg (x
);
3585 PRINT_OPERAND_ADDRESS (asm_out_file
, x
);
3588 /* Print an integer constant expression in assembler syntax.
3589 Addition and subtraction are the only arithmetic
3590 that may appear in these expressions. */
3593 output_addr_const (file
, x
)
3600 switch (GET_CODE (x
))
3610 #ifdef ASM_OUTPUT_SYMBOL_REF
3611 ASM_OUTPUT_SYMBOL_REF (file
, x
);
3613 assemble_name (file
, XSTR (x
, 0));
3621 ASM_GENERATE_INTERNAL_LABEL (buf
, "L", CODE_LABEL_NUMBER (x
));
3622 assemble_name (file
, buf
);
3626 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, INTVAL (x
));
3630 /* This used to output parentheses around the expression,
3631 but that does not work on the 386 (either ATT or BSD assembler). */
3632 output_addr_const (file
, XEXP (x
, 0));
3636 if (GET_MODE (x
) == VOIDmode
)
3638 /* We can use %d if the number is one word and positive. */
3639 if (CONST_DOUBLE_HIGH (x
))
3640 fprintf (file
, HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
3641 CONST_DOUBLE_HIGH (x
), CONST_DOUBLE_LOW (x
));
3642 else if (CONST_DOUBLE_LOW (x
) < 0)
3643 fprintf (file
, HOST_WIDE_INT_PRINT_HEX
, CONST_DOUBLE_LOW (x
));
3645 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, CONST_DOUBLE_LOW (x
));
3648 /* We can't handle floating point constants;
3649 PRINT_OPERAND must handle them. */
3650 output_operand_lossage ("floating constant misused");
3654 /* Some assemblers need integer constants to appear last (eg masm). */
3655 if (GET_CODE (XEXP (x
, 0)) == CONST_INT
)
3657 output_addr_const (file
, XEXP (x
, 1));
3658 if (INTVAL (XEXP (x
, 0)) >= 0)
3659 fprintf (file
, "+");
3660 output_addr_const (file
, XEXP (x
, 0));
3664 output_addr_const (file
, XEXP (x
, 0));
3665 if (GET_CODE (XEXP (x
, 1)) != CONST_INT
3666 || INTVAL (XEXP (x
, 1)) >= 0)
3667 fprintf (file
, "+");
3668 output_addr_const (file
, XEXP (x
, 1));
3673 /* Avoid outputting things like x-x or x+5-x,
3674 since some assemblers can't handle that. */
3675 x
= simplify_subtraction (x
);
3676 if (GET_CODE (x
) != MINUS
)
3679 output_addr_const (file
, XEXP (x
, 0));
3680 fprintf (file
, "-");
3681 if ((GET_CODE (XEXP (x
, 1)) == CONST_INT
3682 && INTVAL (XEXP (x
, 1)) < 0)
3683 || GET_CODE (XEXP (x
, 1)) != CONST_INT
)
3685 fprintf (file
, "%s", ASM_OPEN_PAREN
);
3686 output_addr_const (file
, XEXP (x
, 1));
3687 fprintf (file
, "%s", ASM_CLOSE_PAREN
);
3690 output_addr_const (file
, XEXP (x
, 1));
3695 output_addr_const (file
, XEXP (x
, 0));
3699 #ifdef OUTPUT_ADDR_CONST_EXTRA
3700 OUTPUT_ADDR_CONST_EXTRA (file
, x
, fail
);
3705 output_operand_lossage ("invalid expression as operand");
3709 /* A poor man's fprintf, with the added features of %I, %R, %L, and %U.
3710 %R prints the value of REGISTER_PREFIX.
3711 %L prints the value of LOCAL_LABEL_PREFIX.
3712 %U prints the value of USER_LABEL_PREFIX.
3713 %I prints the value of IMMEDIATE_PREFIX.
3714 %O runs ASM_OUTPUT_OPCODE to transform what follows in the string.
3715 Also supported are %d, %x, %s, %e, %f, %g and %%.
3717 We handle alternate assembler dialects here, just like output_asm_insn. */
3720 asm_fprintf
VPARAMS ((FILE *file
, const char *p
, ...))
3722 #ifndef ANSI_PROTOTYPES
3730 VA_START (argptr
, p
);
3732 #ifndef ANSI_PROTOTYPES
3733 file
= va_arg (argptr
, FILE *);
3734 p
= va_arg (argptr
, const char *);
3742 #ifdef ASSEMBLER_DIALECT
3747 /* If we want the first dialect, do nothing. Otherwise, skip
3748 DIALECT_NUMBER of strings ending with '|'. */
3749 for (i
= 0; i
< dialect_number
; i
++)
3751 while (*p
&& *p
++ != '|')
3761 /* Skip to close brace. */
3762 while (*p
&& *p
++ != '}')
3773 while ((c
>= '0' && c
<= '9') || c
== '.')
3781 fprintf (file
, "%%");
3784 case 'd': case 'i': case 'u':
3785 case 'x': case 'p': case 'X':
3789 fprintf (file
, buf
, va_arg (argptr
, int));
3793 /* This is a prefix to the 'd', 'i', 'u', 'x', 'p', and 'X' cases,
3794 but we do not check for those cases. It means that the value
3795 is a HOST_WIDE_INT, which may be either `int' or `long'. */
3797 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
3799 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
3809 fprintf (file
, buf
, va_arg (argptr
, HOST_WIDE_INT
));
3816 fprintf (file
, buf
, va_arg (argptr
, long));
3824 fprintf (file
, buf
, va_arg (argptr
, double));
3830 fprintf (file
, buf
, va_arg (argptr
, char *));
3834 #ifdef ASM_OUTPUT_OPCODE
3835 ASM_OUTPUT_OPCODE (asm_out_file
, p
);
3840 #ifdef REGISTER_PREFIX
3841 fprintf (file
, "%s", REGISTER_PREFIX
);
3846 #ifdef IMMEDIATE_PREFIX
3847 fprintf (file
, "%s", IMMEDIATE_PREFIX
);
3852 #ifdef LOCAL_LABEL_PREFIX
3853 fprintf (file
, "%s", LOCAL_LABEL_PREFIX
);
3858 fputs (user_label_prefix
, file
);
3861 #ifdef ASM_FPRINTF_EXTENSIONS
3862 /* Upper case letters are reserved for general use by asm_fprintf
3863 and so are not available to target specific code. In order to
3864 prevent the ASM_FPRINTF_EXTENSIONS macro from using them then,
3865 they are defined here. As they get turned into real extensions
3866 to asm_fprintf they should be removed from this list. */
3867 case 'A': case 'B': case 'C': case 'D': case 'E':
3868 case 'F': case 'G': case 'H': case 'J': case 'K':
3869 case 'M': case 'N': case 'P': case 'Q': case 'S':
3870 case 'T': case 'V': case 'W': case 'Y': case 'Z':
3873 ASM_FPRINTF_EXTENSIONS (file
, argptr
, p
)
3886 /* Split up a CONST_DOUBLE or integer constant rtx
3887 into two rtx's for single words,
3888 storing in *FIRST the word that comes first in memory in the target
3889 and in *SECOND the other. */
3892 split_double (value
, first
, second
)
3894 rtx
*first
, *second
;
3896 if (GET_CODE (value
) == CONST_INT
)
3898 if (HOST_BITS_PER_WIDE_INT
>= (2 * BITS_PER_WORD
))
3900 /* In this case the CONST_INT holds both target words.
3901 Extract the bits from it into two word-sized pieces.
3902 Sign extend each half to HOST_WIDE_INT. */
3903 unsigned HOST_WIDE_INT low
, high
;
3904 unsigned HOST_WIDE_INT mask
, sign_bit
, sign_extend
;
3906 /* Set sign_bit to the most significant bit of a word. */
3908 sign_bit
<<= BITS_PER_WORD
- 1;
3910 /* Set mask so that all bits of the word are set. We could
3911 have used 1 << BITS_PER_WORD instead of basing the
3912 calculation on sign_bit. However, on machines where
3913 HOST_BITS_PER_WIDE_INT == BITS_PER_WORD, it could cause a
3914 compiler warning, even though the code would never be
3916 mask
= sign_bit
<< 1;
3919 /* Set sign_extend as any remaining bits. */
3920 sign_extend
= ~mask
;
3922 /* Pick the lower word and sign-extend it. */
3923 low
= INTVAL (value
);
3928 /* Pick the higher word, shifted to the least significant
3929 bits, and sign-extend it. */
3930 high
= INTVAL (value
);
3931 high
>>= BITS_PER_WORD
- 1;
3934 if (high
& sign_bit
)
3935 high
|= sign_extend
;
3937 /* Store the words in the target machine order. */
3938 if (WORDS_BIG_ENDIAN
)
3940 *first
= GEN_INT (high
);
3941 *second
= GEN_INT (low
);
3945 *first
= GEN_INT (low
);
3946 *second
= GEN_INT (high
);
3951 /* The rule for using CONST_INT for a wider mode
3952 is that we regard the value as signed.
3953 So sign-extend it. */
3954 rtx high
= (INTVAL (value
) < 0 ? constm1_rtx
: const0_rtx
);
3955 if (WORDS_BIG_ENDIAN
)
3967 else if (GET_CODE (value
) != CONST_DOUBLE
)
3969 if (WORDS_BIG_ENDIAN
)
3971 *first
= const0_rtx
;
3977 *second
= const0_rtx
;
3980 else if (GET_MODE (value
) == VOIDmode
3981 /* This is the old way we did CONST_DOUBLE integers. */
3982 || GET_MODE_CLASS (GET_MODE (value
)) == MODE_INT
)
3984 /* In an integer, the words are defined as most and least significant.
3985 So order them by the target's convention. */
3986 if (WORDS_BIG_ENDIAN
)
3988 *first
= GEN_INT (CONST_DOUBLE_HIGH (value
));
3989 *second
= GEN_INT (CONST_DOUBLE_LOW (value
));
3993 *first
= GEN_INT (CONST_DOUBLE_LOW (value
));
3994 *second
= GEN_INT (CONST_DOUBLE_HIGH (value
));
3999 #ifdef REAL_ARITHMETIC
4002 REAL_VALUE_FROM_CONST_DOUBLE (r
, value
);
4004 /* Note, this converts the REAL_VALUE_TYPE to the target's
4005 format, splits up the floating point double and outputs
4006 exactly 32 bits of it into each of l[0] and l[1] --
4007 not necessarily BITS_PER_WORD bits. */
4008 REAL_VALUE_TO_TARGET_DOUBLE (r
, l
);
4010 /* If 32 bits is an entire word for the target, but not for the host,
4011 then sign-extend on the host so that the number will look the same
4012 way on the host that it would on the target. See for instance
4013 simplify_unary_operation. The #if is needed to avoid compiler
4016 #if HOST_BITS_PER_LONG > 32
4017 if (BITS_PER_WORD
< HOST_BITS_PER_LONG
&& BITS_PER_WORD
== 32)
4019 if (l
[0] & ((long) 1 << 31))
4020 l
[0] |= ((long) (-1) << 32);
4021 if (l
[1] & ((long) 1 << 31))
4022 l
[1] |= ((long) (-1) << 32);
4026 *first
= GEN_INT ((HOST_WIDE_INT
) l
[0]);
4027 *second
= GEN_INT ((HOST_WIDE_INT
) l
[1]);
4029 if ((HOST_FLOAT_FORMAT
!= TARGET_FLOAT_FORMAT
4030 || HOST_BITS_PER_WIDE_INT
!= BITS_PER_WORD
)
4031 && ! flag_pretend_float
)
4035 #ifdef HOST_WORDS_BIG_ENDIAN
4042 /* Host and target agree => no need to swap. */
4043 *first
= GEN_INT (CONST_DOUBLE_LOW (value
));
4044 *second
= GEN_INT (CONST_DOUBLE_HIGH (value
));
4048 *second
= GEN_INT (CONST_DOUBLE_LOW (value
));
4049 *first
= GEN_INT (CONST_DOUBLE_HIGH (value
));
4051 #endif /* no REAL_ARITHMETIC */
4055 /* Return nonzero if this function has no function calls. */
4063 if (profile_flag
|| profile_block_flag
|| profile_arc_flag
)
4066 for (insn
= get_insns (); insn
; insn
= NEXT_INSN (insn
))
4068 if (GET_CODE (insn
) == CALL_INSN
4069 && ! SIBLING_CALL_P (insn
))
4071 if (GET_CODE (insn
) == INSN
4072 && GET_CODE (PATTERN (insn
)) == SEQUENCE
4073 && GET_CODE (XVECEXP (PATTERN (insn
), 0, 0)) == CALL_INSN
4074 && ! SIBLING_CALL_P (XVECEXP (PATTERN (insn
), 0, 0)))
4077 for (link
= current_function_epilogue_delay_list
;
4079 link
= XEXP (link
, 1))
4081 insn
= XEXP (link
, 0);
4083 if (GET_CODE (insn
) == CALL_INSN
4084 && ! SIBLING_CALL_P (insn
))
4086 if (GET_CODE (insn
) == INSN
4087 && GET_CODE (PATTERN (insn
)) == SEQUENCE
4088 && GET_CODE (XVECEXP (PATTERN (insn
), 0, 0)) == CALL_INSN
4089 && ! SIBLING_CALL_P (XVECEXP (PATTERN (insn
), 0, 0)))
4096 /* On some machines, a function with no call insns
4097 can run faster if it doesn't create its own register window.
4098 When output, the leaf function should use only the "output"
4099 registers. Ordinarily, the function would be compiled to use
4100 the "input" registers to find its arguments; it is a candidate
4101 for leaf treatment if it uses only the "input" registers.
4102 Leaf function treatment means renumbering so the function
4103 uses the "output" registers instead. */
4105 #ifdef LEAF_REGISTERS
4107 /* Return 1 if this function uses only the registers that can be
4108 safely renumbered. */
4111 only_leaf_regs_used ()
4114 char *permitted_reg_in_leaf_functions
= LEAF_REGISTERS
;
4116 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
4117 if ((regs_ever_live
[i
] || global_regs
[i
])
4118 && ! permitted_reg_in_leaf_functions
[i
])
4121 if (current_function_uses_pic_offset_table
4122 && pic_offset_table_rtx
!= 0
4123 && GET_CODE (pic_offset_table_rtx
) == REG
4124 && ! permitted_reg_in_leaf_functions
[REGNO (pic_offset_table_rtx
)])
4130 /* Scan all instructions and renumber all registers into those
4131 available in leaf functions. */
4134 leaf_renumber_regs (first
)
4139 /* Renumber only the actual patterns.
4140 The reg-notes can contain frame pointer refs,
4141 and renumbering them could crash, and should not be needed. */
4142 for (insn
= first
; insn
; insn
= NEXT_INSN (insn
))
4144 leaf_renumber_regs_insn (PATTERN (insn
));
4145 for (insn
= current_function_epilogue_delay_list
;
4147 insn
= XEXP (insn
, 1))
4148 if (INSN_P (XEXP (insn
, 0)))
4149 leaf_renumber_regs_insn (PATTERN (XEXP (insn
, 0)));
4152 /* Scan IN_RTX and its subexpressions, and renumber all regs into those
4153 available in leaf functions. */
4156 leaf_renumber_regs_insn (in_rtx
)
4157 register rtx in_rtx
;
4160 register const char *format_ptr
;
4165 /* Renumber all input-registers into output-registers.
4166 renumbered_regs would be 1 for an output-register;
4169 if (GET_CODE (in_rtx
) == REG
)
4173 /* Don't renumber the same reg twice. */
4177 newreg
= REGNO (in_rtx
);
4178 /* Don't try to renumber pseudo regs. It is possible for a pseudo reg
4179 to reach here as part of a REG_NOTE. */
4180 if (newreg
>= FIRST_PSEUDO_REGISTER
)
4185 newreg
= LEAF_REG_REMAP (newreg
);
4188 regs_ever_live
[REGNO (in_rtx
)] = 0;
4189 regs_ever_live
[newreg
] = 1;
4190 REGNO (in_rtx
) = newreg
;
4194 if (INSN_P (in_rtx
))
4196 /* Inside a SEQUENCE, we find insns.
4197 Renumber just the patterns of these insns,
4198 just as we do for the top-level insns. */
4199 leaf_renumber_regs_insn (PATTERN (in_rtx
));
4203 format_ptr
= GET_RTX_FORMAT (GET_CODE (in_rtx
));
4205 for (i
= 0; i
< GET_RTX_LENGTH (GET_CODE (in_rtx
)); i
++)
4206 switch (*format_ptr
++)
4209 leaf_renumber_regs_insn (XEXP (in_rtx
, i
));
4213 if (NULL
!= XVEC (in_rtx
, i
))
4215 for (j
= 0; j
< XVECLEN (in_rtx
, i
); j
++)
4216 leaf_renumber_regs_insn (XVECEXP (in_rtx
, i
, j
));