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 gcov_type_bytes
= GCOV_TYPE_SIZE
/ BITS_PER_UNIT
;
302 int pointer_bytes
= POINTER_SIZE
/ BITS_PER_UNIT
;
304 if (profile_block_flag
)
305 size
= long_bytes
* count_basic_blocks
;
307 size
= gcov_type_bytes
* count_instrumented_edges
;
310 rounded
+= (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
) - 1;
311 rounded
= (rounded
/ (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
312 * (BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
));
316 /* Output the main header, of 11 words:
317 0: 1 if this file is initialized, else 0.
318 1: address of file name (LPBX1).
319 2: address of table of counts (LPBX2).
320 3: number of counts in the table.
321 4: always 0, for compatibility with Sun.
323 The following are GNU extensions:
325 5: address of table of start addrs of basic blocks (LPBX3).
326 6: Number of bytes in this header.
327 7: address of table of function names (LPBX4).
328 8: address of table of line numbers (LPBX5) or 0.
329 9: address of table of file names (LPBX6) or 0.
330 10: space reserved for basic block profiling. */
332 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
334 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LPBX", 0);
336 assemble_integer (const0_rtx
, long_bytes
, 1);
338 /* address of filename */
339 ASM_GENERATE_INTERNAL_LABEL (name
, "LPBX", 1);
340 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, name
), pointer_bytes
, 1);
342 /* address of count table */
343 ASM_GENERATE_INTERNAL_LABEL (name
, "LPBX", 2);
344 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, name
), pointer_bytes
, 1);
346 /* count of the # of basic blocks or # of instrumented arcs */
347 if (profile_block_flag
)
348 assemble_integer (GEN_INT (count_basic_blocks
), long_bytes
, 1);
350 assemble_integer (GEN_INT (count_instrumented_edges
), long_bytes
, 1);
352 /* zero word (link field) */
353 assemble_integer (const0_rtx
, pointer_bytes
, 1);
355 /* address of basic block start address table */
356 if (profile_block_flag
)
358 ASM_GENERATE_INTERNAL_LABEL (name
, "LPBX", 3);
359 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, name
), pointer_bytes
,
363 assemble_integer (const0_rtx
, pointer_bytes
, 1);
365 /* byte count for extended structure. */
366 assemble_integer (GEN_INT (11 * UNITS_PER_WORD
), long_bytes
, 1);
368 /* address of function name table */
369 if (profile_block_flag
)
371 ASM_GENERATE_INTERNAL_LABEL (name
, "LPBX", 4);
372 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, name
), pointer_bytes
,
376 assemble_integer (const0_rtx
, pointer_bytes
, 1);
378 /* address of line number and filename tables if debugging. */
379 if (write_symbols
!= NO_DEBUG
&& profile_block_flag
)
381 ASM_GENERATE_INTERNAL_LABEL (name
, "LPBX", 5);
382 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, name
),
384 ASM_GENERATE_INTERNAL_LABEL (name
, "LPBX", 6);
385 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, name
),
390 assemble_integer (const0_rtx
, pointer_bytes
, 1);
391 assemble_integer (const0_rtx
, pointer_bytes
, 1);
394 /* space for extension ptr (link field) */
395 assemble_integer (const0_rtx
, UNITS_PER_WORD
, 1);
397 /* Output the file name changing the suffix to .d for Sun tcov
399 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LPBX", 1);
401 char *cwd
= getpwd ();
402 int len
= strlen (filename
) + strlen (cwd
) + 1;
403 char *data_file
= (char *) alloca (len
+ 4);
405 strcpy (data_file
, cwd
);
406 strcat (data_file
, "/");
407 strcat (data_file
, filename
);
408 strip_off_ending (data_file
, len
);
409 if (profile_block_flag
)
410 strcat (data_file
, ".d");
412 strcat (data_file
, ".da");
413 assemble_string (data_file
, strlen (data_file
) + 1);
416 /* Make space for the table of counts. */
419 /* Realign data section. */
420 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
421 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LPBX", 2);
423 assemble_zeros (size
);
427 ASM_GENERATE_INTERNAL_LABEL (name
, "LPBX", 2);
428 #ifdef ASM_OUTPUT_SHARED_LOCAL
429 if (flag_shared_data
)
430 ASM_OUTPUT_SHARED_LOCAL (asm_out_file
, name
, size
, rounded
);
433 #ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL
434 ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file
, NULL_TREE
, name
,
435 size
, BIGGEST_ALIGNMENT
);
437 #ifdef ASM_OUTPUT_ALIGNED_LOCAL
438 ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file
, name
, size
,
441 ASM_OUTPUT_LOCAL (asm_out_file
, name
, size
, rounded
);
446 /* Output any basic block strings */
447 if (profile_block_flag
)
449 readonly_data_section ();
452 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
453 for (sptr
= sbb_head
; sptr
!= 0; sptr
= sptr
->next
)
455 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LPBC",
457 assemble_string (sptr
->string
, sptr
->length
);
462 /* Output the table of addresses. */
463 if (profile_block_flag
)
465 /* Realign in new section */
466 ASM_OUTPUT_ALIGN (asm_out_file
, align
);
467 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LPBX", 3);
468 for (i
= 0; i
< count_basic_blocks
; i
++)
470 ASM_GENERATE_INTERNAL_LABEL (name
, "LPB", i
);
471 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, name
),
476 /* Output the table of function names. */
477 if (profile_block_flag
)
479 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LPBX", 4);
480 for ((ptr
= bb_head
), (i
= 0); ptr
!= 0; (ptr
= ptr
->next
), i
++)
482 if (ptr
->func_label_num
>= 0)
484 ASM_GENERATE_INTERNAL_LABEL (name
, "LPBC",
485 ptr
->func_label_num
);
486 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, name
),
490 assemble_integer (const0_rtx
, pointer_bytes
, 1);
493 for (; i
< count_basic_blocks
; i
++)
494 assemble_integer (const0_rtx
, pointer_bytes
, 1);
497 if (write_symbols
!= NO_DEBUG
&& profile_block_flag
)
499 /* Output the table of line numbers. */
500 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LPBX", 5);
501 for ((ptr
= bb_head
), (i
= 0); ptr
!= 0; (ptr
= ptr
->next
), i
++)
502 assemble_integer (GEN_INT (ptr
->line_num
), long_bytes
, 1);
504 for (; i
< count_basic_blocks
; i
++)
505 assemble_integer (const0_rtx
, long_bytes
, 1);
507 /* Output the table of file names. */
508 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "LPBX", 6);
509 for ((ptr
= bb_head
), (i
= 0); ptr
!= 0; (ptr
= ptr
->next
), i
++)
511 if (ptr
->file_label_num
>= 0)
513 ASM_GENERATE_INTERNAL_LABEL (name
, "LPBC",
514 ptr
->file_label_num
);
515 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, name
),
519 assemble_integer (const0_rtx
, pointer_bytes
, 1);
522 for (; i
< count_basic_blocks
; i
++)
523 assemble_integer (const0_rtx
, pointer_bytes
, 1);
526 /* End with the address of the table of addresses,
527 so we can find it easily, as the last word in the file's text. */
528 if (profile_block_flag
)
530 ASM_GENERATE_INTERNAL_LABEL (name
, "LPBX", 3);
531 assemble_integer (gen_rtx_SYMBOL_REF (Pmode
, name
), pointer_bytes
,
537 /* Enable APP processing of subsequent output.
538 Used before the output from an `asm' statement. */
545 fputs (ASM_APP_ON
, asm_out_file
);
550 /* Disable APP processing of subsequent output.
551 Called from varasm.c before most kinds of output. */
558 fputs (ASM_APP_OFF
, asm_out_file
);
563 /* Return the number of slots filled in the current
564 delayed branch sequence (we don't count the insn needing the
565 delay slot). Zero if not in a delayed branch sequence. */
569 dbr_sequence_length ()
571 if (final_sequence
!= 0)
572 return XVECLEN (final_sequence
, 0) - 1;
578 /* The next two pages contain routines used to compute the length of an insn
579 and to shorten branches. */
581 /* Arrays for insn lengths, and addresses. The latter is referenced by
582 `insn_current_length'. */
584 static short *insn_lengths
;
586 #ifdef HAVE_ATTR_length
587 varray_type insn_addresses_
;
590 /* Max uid for which the above arrays are valid. */
591 static int insn_lengths_max_uid
;
593 /* Address of insn being processed. Used by `insn_current_length'. */
594 int insn_current_address
;
596 /* Address of insn being processed in previous iteration. */
597 int insn_last_address
;
599 /* konwn invariant alignment of insn being processed. */
600 int insn_current_align
;
602 /* After shorten_branches, for any insn, uid_align[INSN_UID (insn)]
603 gives the next following alignment insn that increases the known
604 alignment, or NULL_RTX if there is no such insn.
605 For any alignment obtained this way, we can again index uid_align with
606 its uid to obtain the next following align that in turn increases the
607 alignment, till we reach NULL_RTX; the sequence obtained this way
608 for each insn we'll call the alignment chain of this insn in the following
611 struct label_alignment
617 static rtx
*uid_align
;
618 static int *uid_shuid
;
619 static struct label_alignment
*label_align
;
621 /* Indicate that branch shortening hasn't yet been done. */
640 insn_lengths_max_uid
= 0;
642 #ifdef HAVE_ATTR_length
643 INSN_ADDRESSES_FREE ();
652 /* Obtain the current length of an insn. If branch shortening has been done,
653 get its actual length. Otherwise, get its maximum length. */
656 get_attr_length (insn
)
657 rtx insn ATTRIBUTE_UNUSED
;
659 #ifdef HAVE_ATTR_length
664 if (insn_lengths_max_uid
> INSN_UID (insn
))
665 return insn_lengths
[INSN_UID (insn
)];
667 switch (GET_CODE (insn
))
675 length
= insn_default_length (insn
);
679 body
= PATTERN (insn
);
680 if (GET_CODE (body
) == ADDR_VEC
|| GET_CODE (body
) == ADDR_DIFF_VEC
)
682 /* Alignment is machine-dependent and should be handled by
686 length
= insn_default_length (insn
);
690 body
= PATTERN (insn
);
691 if (GET_CODE (body
) == USE
|| GET_CODE (body
) == CLOBBER
)
694 else if (GET_CODE (body
) == ASM_INPUT
|| asm_noperands (body
) >= 0)
695 length
= asm_insn_count (body
) * insn_default_length (insn
);
696 else if (GET_CODE (body
) == SEQUENCE
)
697 for (i
= 0; i
< XVECLEN (body
, 0); i
++)
698 length
+= get_attr_length (XVECEXP (body
, 0, i
));
700 length
= insn_default_length (insn
);
707 #ifdef ADJUST_INSN_LENGTH
708 ADJUST_INSN_LENGTH (insn
, length
);
711 #else /* not HAVE_ATTR_length */
713 #endif /* not HAVE_ATTR_length */
716 /* Code to handle alignment inside shorten_branches. */
718 /* Here is an explanation how the algorithm in align_fuzz can give
721 Call a sequence of instructions beginning with alignment point X
722 and continuing until the next alignment point `block X'. When `X'
723 is used in an expression, it means the alignment value of the
726 Call the distance between the start of the first insn of block X, and
727 the end of the last insn of block X `IX', for the `inner size of X'.
728 This is clearly the sum of the instruction lengths.
730 Likewise with the next alignment-delimited block following X, which we
733 Call the distance between the start of the first insn of block X, and
734 the start of the first insn of block Y `OX', for the `outer size of X'.
736 The estimated padding is then OX - IX.
738 OX can be safely estimated as
743 OX = round_up(IX, X) + Y - X
745 Clearly est(IX) >= real(IX), because that only depends on the
746 instruction lengths, and those being overestimated is a given.
748 Clearly round_up(foo, Z) >= round_up(bar, Z) if foo >= bar, so
749 we needn't worry about that when thinking about OX.
751 When X >= Y, the alignment provided by Y adds no uncertainty factor
752 for branch ranges starting before X, so we can just round what we have.
753 But when X < Y, we don't know anything about the, so to speak,
754 `middle bits', so we have to assume the worst when aligning up from an
755 address mod X to one mod Y, which is Y - X. */
758 #define LABEL_ALIGN(LABEL) align_labels_log
761 #ifndef LABEL_ALIGN_MAX_SKIP
762 #define LABEL_ALIGN_MAX_SKIP (align_labels-1)
766 #define LOOP_ALIGN(LABEL) align_loops_log
769 #ifndef LOOP_ALIGN_MAX_SKIP
770 #define LOOP_ALIGN_MAX_SKIP (align_loops-1)
773 #ifndef LABEL_ALIGN_AFTER_BARRIER
774 #define LABEL_ALIGN_AFTER_BARRIER(LABEL) align_jumps_log
777 #ifndef LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP
778 #define LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP (align_jumps-1)
781 #ifndef ADDR_VEC_ALIGN
783 final_addr_vec_align (addr_vec
)
786 int align
= GET_MODE_SIZE (GET_MODE (PATTERN (addr_vec
)));
788 if (align
> BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
)
789 align
= BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
;
790 return exact_log2 (align
);
794 #define ADDR_VEC_ALIGN(ADDR_VEC) final_addr_vec_align (ADDR_VEC)
797 #ifndef INSN_LENGTH_ALIGNMENT
798 #define INSN_LENGTH_ALIGNMENT(INSN) length_unit_log
801 #define INSN_SHUID(INSN) (uid_shuid[INSN_UID (INSN)])
803 static int min_labelno
, max_labelno
;
805 #define LABEL_TO_ALIGNMENT(LABEL) \
806 (label_align[CODE_LABEL_NUMBER (LABEL) - min_labelno].alignment)
808 #define LABEL_TO_MAX_SKIP(LABEL) \
809 (label_align[CODE_LABEL_NUMBER (LABEL) - min_labelno].max_skip)
811 /* For the benefit of port specific code do this also as a function. */
814 label_to_alignment (label
)
817 return LABEL_TO_ALIGNMENT (label
);
820 #ifdef HAVE_ATTR_length
821 /* The differences in addresses
822 between a branch and its target might grow or shrink depending on
823 the alignment the start insn of the range (the branch for a forward
824 branch or the label for a backward branch) starts out on; if these
825 differences are used naively, they can even oscillate infinitely.
826 We therefore want to compute a 'worst case' address difference that
827 is independent of the alignment the start insn of the range end
828 up on, and that is at least as large as the actual difference.
829 The function align_fuzz calculates the amount we have to add to the
830 naively computed difference, by traversing the part of the alignment
831 chain of the start insn of the range that is in front of the end insn
832 of the range, and considering for each alignment the maximum amount
833 that it might contribute to a size increase.
835 For casesi tables, we also want to know worst case minimum amounts of
836 address difference, in case a machine description wants to introduce
837 some common offset that is added to all offsets in a table.
838 For this purpose, align_fuzz with a growth argument of 0 comuptes the
839 appropriate adjustment. */
841 /* Compute the maximum delta by which the difference of the addresses of
842 START and END might grow / shrink due to a different address for start
843 which changes the size of alignment insns between START and END.
844 KNOWN_ALIGN_LOG is the alignment known for START.
845 GROWTH should be ~0 if the objective is to compute potential code size
846 increase, and 0 if the objective is to compute potential shrink.
847 The return value is undefined for any other value of GROWTH. */
850 align_fuzz (start
, end
, known_align_log
, growth
)
855 int uid
= INSN_UID (start
);
857 int known_align
= 1 << known_align_log
;
858 int end_shuid
= INSN_SHUID (end
);
861 for (align_label
= uid_align
[uid
]; align_label
; align_label
= uid_align
[uid
])
863 int align_addr
, new_align
;
865 uid
= INSN_UID (align_label
);
866 align_addr
= INSN_ADDRESSES (uid
) - insn_lengths
[uid
];
867 if (uid_shuid
[uid
] > end_shuid
)
869 known_align_log
= LABEL_TO_ALIGNMENT (align_label
);
870 new_align
= 1 << known_align_log
;
871 if (new_align
< known_align
)
873 fuzz
+= (-align_addr
^ growth
) & (new_align
- known_align
);
874 known_align
= new_align
;
879 /* Compute a worst-case reference address of a branch so that it
880 can be safely used in the presence of aligned labels. Since the
881 size of the branch itself is unknown, the size of the branch is
882 not included in the range. I.e. for a forward branch, the reference
883 address is the end address of the branch as known from the previous
884 branch shortening pass, minus a value to account for possible size
885 increase due to alignment. For a backward branch, it is the start
886 address of the branch as known from the current pass, plus a value
887 to account for possible size increase due to alignment.
888 NB.: Therefore, the maximum offset allowed for backward branches needs
889 to exclude the branch size. */
892 insn_current_reference_address (branch
)
898 if (! INSN_ADDRESSES_SET_P ())
901 seq
= NEXT_INSN (PREV_INSN (branch
));
902 seq_uid
= INSN_UID (seq
);
903 if (GET_CODE (branch
) != JUMP_INSN
)
904 /* This can happen for example on the PA; the objective is to know the
905 offset to address something in front of the start of the function.
906 Thus, we can treat it like a backward branch.
907 We assume here that FUNCTION_BOUNDARY / BITS_PER_UNIT is larger than
908 any alignment we'd encounter, so we skip the call to align_fuzz. */
909 return insn_current_address
;
910 dest
= JUMP_LABEL (branch
);
912 /* BRANCH has no proper alignment chain set, so use SEQ.
913 BRANCH also has no INSN_SHUID. */
914 if (INSN_SHUID (seq
) < INSN_SHUID (dest
))
916 /* Forward branch. */
917 return (insn_last_address
+ insn_lengths
[seq_uid
]
918 - align_fuzz (seq
, dest
, length_unit_log
, ~0));
922 /* Backward branch. */
923 return (insn_current_address
924 + align_fuzz (dest
, seq
, length_unit_log
, ~0));
927 #endif /* HAVE_ATTR_length */
929 /* Make a pass over all insns and compute their actual lengths by shortening
930 any branches of variable length if possible. */
932 /* Give a default value for the lowest address in a function. */
934 #ifndef FIRST_INSN_ADDRESS
935 #define FIRST_INSN_ADDRESS 0
938 /* shorten_branches might be called multiple times: for example, the SH
939 port splits out-of-range conditional branches in MACHINE_DEPENDENT_REORG.
940 In order to do this, it needs proper length information, which it obtains
941 by calling shorten_branches. This cannot be collapsed with
942 shorten_branches itself into a single pass unless we also want to intergate
943 reorg.c, since the branch splitting exposes new instructions with delay
947 shorten_branches (first
)
948 rtx first ATTRIBUTE_UNUSED
;
955 #ifdef HAVE_ATTR_length
956 #define MAX_CODE_ALIGN 16
958 int something_changed
= 1;
959 char *varying_length
;
962 rtx align_tab
[MAX_CODE_ALIGN
];
966 /* We must do some computations even when not actually shortening, in
967 order to get the alignment information for the labels. */
969 init_insn_lengths ();
971 /* Compute maximum UID and allocate label_align / uid_shuid. */
972 max_uid
= get_max_uid ();
974 max_labelno
= max_label_num ();
975 min_labelno
= get_first_label_num ();
976 label_align
= (struct label_alignment
*)
977 xcalloc ((max_labelno
- min_labelno
+ 1), sizeof (struct label_alignment
));
979 uid_shuid
= (int *) xmalloc (max_uid
* sizeof *uid_shuid
);
981 /* Initialize label_align and set up uid_shuid to be strictly
982 monotonically rising with insn order. */
983 /* We use max_log here to keep track of the maximum alignment we want to
984 impose on the next CODE_LABEL (or the current one if we are processing
985 the CODE_LABEL itself). */
990 for (insn
= get_insns (), i
= 1; insn
; insn
= NEXT_INSN (insn
))
994 INSN_SHUID (insn
) = i
++;
997 /* reorg might make the first insn of a loop being run once only,
998 and delete the label in front of it. Then we want to apply
999 the loop alignment to the new label created by reorg, which
1000 is separated by the former loop start insn from the
1001 NOTE_INSN_LOOP_BEG. */
1003 else if (GET_CODE (insn
) == CODE_LABEL
)
1007 log
= LABEL_ALIGN (insn
);
1011 max_skip
= LABEL_ALIGN_MAX_SKIP
;
1013 next
= NEXT_INSN (insn
);
1014 /* ADDR_VECs only take room if read-only data goes into the text
1016 if (JUMP_TABLES_IN_TEXT_SECTION
1017 #if !defined(READONLY_DATA_SECTION)
1021 if (next
&& GET_CODE (next
) == JUMP_INSN
)
1023 rtx nextbody
= PATTERN (next
);
1024 if (GET_CODE (nextbody
) == ADDR_VEC
1025 || GET_CODE (nextbody
) == ADDR_DIFF_VEC
)
1027 log
= ADDR_VEC_ALIGN (next
);
1031 max_skip
= LABEL_ALIGN_MAX_SKIP
;
1035 LABEL_TO_ALIGNMENT (insn
) = max_log
;
1036 LABEL_TO_MAX_SKIP (insn
) = max_skip
;
1040 else if (GET_CODE (insn
) == BARRIER
)
1044 for (label
= insn
; label
&& ! INSN_P (label
);
1045 label
= NEXT_INSN (label
))
1046 if (GET_CODE (label
) == CODE_LABEL
)
1048 log
= LABEL_ALIGN_AFTER_BARRIER (insn
);
1052 max_skip
= LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP
;
1057 /* Again, we allow NOTE_INSN_LOOP_BEG - INSN - CODE_LABEL
1058 sequences in order to handle reorg output efficiently. */
1059 else if (GET_CODE (insn
) == NOTE
1060 && NOTE_LINE_NUMBER (insn
) == NOTE_INSN_LOOP_BEG
)
1065 /* Search for the label that starts the loop.
1066 Don't skip past the end of the loop, since that could
1067 lead to putting an alignment where it does not belong.
1068 However, a label after a nested (non-)loop would be OK. */
1069 for (label
= insn
; label
; label
= NEXT_INSN (label
))
1071 if (GET_CODE (label
) == NOTE
1072 && NOTE_LINE_NUMBER (label
) == NOTE_INSN_LOOP_BEG
)
1074 else if (GET_CODE (label
) == NOTE
1075 && NOTE_LINE_NUMBER (label
) == NOTE_INSN_LOOP_END
1078 else if (GET_CODE (label
) == CODE_LABEL
)
1080 log
= LOOP_ALIGN (label
);
1084 max_skip
= LOOP_ALIGN_MAX_SKIP
;
1093 #ifdef HAVE_ATTR_length
1095 /* Allocate the rest of the arrays. */
1096 insn_lengths
= (short *) xmalloc (max_uid
* sizeof (short));
1097 insn_lengths_max_uid
= max_uid
;
1098 /* Syntax errors can lead to labels being outside of the main insn stream.
1099 Initialize insn_addresses, so that we get reproducible results. */
1100 INSN_ADDRESSES_ALLOC (max_uid
);
1102 varying_length
= (char *) xcalloc (max_uid
, sizeof (char));
1104 /* Initialize uid_align. We scan instructions
1105 from end to start, and keep in align_tab[n] the last seen insn
1106 that does an alignment of at least n+1, i.e. the successor
1107 in the alignment chain for an insn that does / has a known
1109 uid_align
= (rtx
*) xcalloc (max_uid
, sizeof *uid_align
);
1111 for (i
= MAX_CODE_ALIGN
; --i
>= 0;)
1112 align_tab
[i
] = NULL_RTX
;
1113 seq
= get_last_insn ();
1114 for (; seq
; seq
= PREV_INSN (seq
))
1116 int uid
= INSN_UID (seq
);
1118 log
= (GET_CODE (seq
) == CODE_LABEL
? LABEL_TO_ALIGNMENT (seq
) : 0);
1119 uid_align
[uid
] = align_tab
[0];
1122 /* Found an alignment label. */
1123 uid_align
[uid
] = align_tab
[log
];
1124 for (i
= log
- 1; i
>= 0; i
--)
1128 #ifdef CASE_VECTOR_SHORTEN_MODE
1131 /* Look for ADDR_DIFF_VECs, and initialize their minimum and maximum
1134 int min_shuid
= INSN_SHUID (get_insns ()) - 1;
1135 int max_shuid
= INSN_SHUID (get_last_insn ()) + 1;
1138 for (insn
= first
; insn
!= 0; insn
= NEXT_INSN (insn
))
1140 rtx min_lab
= NULL_RTX
, max_lab
= NULL_RTX
, pat
;
1141 int len
, i
, min
, max
, insn_shuid
;
1143 addr_diff_vec_flags flags
;
1145 if (GET_CODE (insn
) != JUMP_INSN
1146 || GET_CODE (PATTERN (insn
)) != ADDR_DIFF_VEC
)
1148 pat
= PATTERN (insn
);
1149 len
= XVECLEN (pat
, 1);
1152 min_align
= MAX_CODE_ALIGN
;
1153 for (min
= max_shuid
, max
= min_shuid
, i
= len
- 1; i
>= 0; i
--)
1155 rtx lab
= XEXP (XVECEXP (pat
, 1, i
), 0);
1156 int shuid
= INSN_SHUID (lab
);
1167 if (min_align
> LABEL_TO_ALIGNMENT (lab
))
1168 min_align
= LABEL_TO_ALIGNMENT (lab
);
1170 XEXP (pat
, 2) = gen_rtx_LABEL_REF (VOIDmode
, min_lab
);
1171 XEXP (pat
, 3) = gen_rtx_LABEL_REF (VOIDmode
, max_lab
);
1172 insn_shuid
= INSN_SHUID (insn
);
1173 rel
= INSN_SHUID (XEXP (XEXP (pat
, 0), 0));
1174 flags
.min_align
= min_align
;
1175 flags
.base_after_vec
= rel
> insn_shuid
;
1176 flags
.min_after_vec
= min
> insn_shuid
;
1177 flags
.max_after_vec
= max
> insn_shuid
;
1178 flags
.min_after_base
= min
> rel
;
1179 flags
.max_after_base
= max
> rel
;
1180 ADDR_DIFF_VEC_FLAGS (pat
) = flags
;
1183 #endif /* CASE_VECTOR_SHORTEN_MODE */
1185 /* Compute initial lengths, addresses, and varying flags for each insn. */
1186 for (insn_current_address
= FIRST_INSN_ADDRESS
, insn
= first
;
1188 insn_current_address
+= insn_lengths
[uid
], insn
= NEXT_INSN (insn
))
1190 uid
= INSN_UID (insn
);
1192 insn_lengths
[uid
] = 0;
1194 if (GET_CODE (insn
) == CODE_LABEL
)
1196 int log
= LABEL_TO_ALIGNMENT (insn
);
1199 int align
= 1 << log
;
1200 int new_address
= (insn_current_address
+ align
- 1) & -align
;
1201 insn_lengths
[uid
] = new_address
- insn_current_address
;
1205 INSN_ADDRESSES (uid
) = insn_current_address
;
1207 if (GET_CODE (insn
) == NOTE
|| GET_CODE (insn
) == BARRIER
1208 || GET_CODE (insn
) == CODE_LABEL
)
1210 if (INSN_DELETED_P (insn
))
1213 body
= PATTERN (insn
);
1214 if (GET_CODE (body
) == ADDR_VEC
|| GET_CODE (body
) == ADDR_DIFF_VEC
)
1216 /* This only takes room if read-only data goes into the text
1218 if (JUMP_TABLES_IN_TEXT_SECTION
1219 #if !defined(READONLY_DATA_SECTION)
1223 insn_lengths
[uid
] = (XVECLEN (body
,
1224 GET_CODE (body
) == ADDR_DIFF_VEC
)
1225 * GET_MODE_SIZE (GET_MODE (body
)));
1226 /* Alignment is handled by ADDR_VEC_ALIGN. */
1228 else if (GET_CODE (body
) == ASM_INPUT
|| asm_noperands (body
) >= 0)
1229 insn_lengths
[uid
] = asm_insn_count (body
) * insn_default_length (insn
);
1230 else if (GET_CODE (body
) == SEQUENCE
)
1233 int const_delay_slots
;
1235 const_delay_slots
= const_num_delay_slots (XVECEXP (body
, 0, 0));
1237 const_delay_slots
= 0;
1239 /* Inside a delay slot sequence, we do not do any branch shortening
1240 if the shortening could change the number of delay slots
1242 for (i
= 0; i
< XVECLEN (body
, 0); i
++)
1244 rtx inner_insn
= XVECEXP (body
, 0, i
);
1245 int inner_uid
= INSN_UID (inner_insn
);
1248 if (GET_CODE (body
) == ASM_INPUT
1249 || asm_noperands (PATTERN (XVECEXP (body
, 0, i
))) >= 0)
1250 inner_length
= (asm_insn_count (PATTERN (inner_insn
))
1251 * insn_default_length (inner_insn
));
1253 inner_length
= insn_default_length (inner_insn
);
1255 insn_lengths
[inner_uid
] = inner_length
;
1256 if (const_delay_slots
)
1258 if ((varying_length
[inner_uid
]
1259 = insn_variable_length_p (inner_insn
)) != 0)
1260 varying_length
[uid
] = 1;
1261 INSN_ADDRESSES (inner_uid
) = (insn_current_address
1262 + insn_lengths
[uid
]);
1265 varying_length
[inner_uid
] = 0;
1266 insn_lengths
[uid
] += inner_length
;
1269 else if (GET_CODE (body
) != USE
&& GET_CODE (body
) != CLOBBER
)
1271 insn_lengths
[uid
] = insn_default_length (insn
);
1272 varying_length
[uid
] = insn_variable_length_p (insn
);
1275 /* If needed, do any adjustment. */
1276 #ifdef ADJUST_INSN_LENGTH
1277 ADJUST_INSN_LENGTH (insn
, insn_lengths
[uid
]);
1278 if (insn_lengths
[uid
] < 0)
1279 fatal_insn ("Negative insn length", insn
);
1283 /* Now loop over all the insns finding varying length insns. For each,
1284 get the current insn length. If it has changed, reflect the change.
1285 When nothing changes for a full pass, we are done. */
1287 while (something_changed
)
1289 something_changed
= 0;
1290 insn_current_align
= MAX_CODE_ALIGN
- 1;
1291 for (insn_current_address
= FIRST_INSN_ADDRESS
, insn
= first
;
1293 insn
= NEXT_INSN (insn
))
1296 #ifdef ADJUST_INSN_LENGTH
1301 uid
= INSN_UID (insn
);
1303 if (GET_CODE (insn
) == CODE_LABEL
)
1305 int log
= LABEL_TO_ALIGNMENT (insn
);
1306 if (log
> insn_current_align
)
1308 int align
= 1 << log
;
1309 int new_address
= (insn_current_address
+ align
- 1) & -align
;
1310 insn_lengths
[uid
] = new_address
- insn_current_address
;
1311 insn_current_align
= log
;
1312 insn_current_address
= new_address
;
1315 insn_lengths
[uid
] = 0;
1316 INSN_ADDRESSES (uid
) = insn_current_address
;
1320 length_align
= INSN_LENGTH_ALIGNMENT (insn
);
1321 if (length_align
< insn_current_align
)
1322 insn_current_align
= length_align
;
1324 insn_last_address
= INSN_ADDRESSES (uid
);
1325 INSN_ADDRESSES (uid
) = insn_current_address
;
1327 #ifdef CASE_VECTOR_SHORTEN_MODE
1328 if (optimize
&& GET_CODE (insn
) == JUMP_INSN
1329 && GET_CODE (PATTERN (insn
)) == ADDR_DIFF_VEC
)
1331 rtx body
= PATTERN (insn
);
1332 int old_length
= insn_lengths
[uid
];
1333 rtx rel_lab
= XEXP (XEXP (body
, 0), 0);
1334 rtx min_lab
= XEXP (XEXP (body
, 2), 0);
1335 rtx max_lab
= XEXP (XEXP (body
, 3), 0);
1336 addr_diff_vec_flags flags
= ADDR_DIFF_VEC_FLAGS (body
);
1337 int rel_addr
= INSN_ADDRESSES (INSN_UID (rel_lab
));
1338 int min_addr
= INSN_ADDRESSES (INSN_UID (min_lab
));
1339 int max_addr
= INSN_ADDRESSES (INSN_UID (max_lab
));
1343 /* Try to find a known alignment for rel_lab. */
1344 for (prev
= rel_lab
;
1346 && ! insn_lengths
[INSN_UID (prev
)]
1347 && ! (varying_length
[INSN_UID (prev
)] & 1);
1348 prev
= PREV_INSN (prev
))
1349 if (varying_length
[INSN_UID (prev
)] & 2)
1351 rel_align
= LABEL_TO_ALIGNMENT (prev
);
1355 /* See the comment on addr_diff_vec_flags in rtl.h for the
1356 meaning of the flags values. base: REL_LAB vec: INSN */
1357 /* Anything after INSN has still addresses from the last
1358 pass; adjust these so that they reflect our current
1359 estimate for this pass. */
1360 if (flags
.base_after_vec
)
1361 rel_addr
+= insn_current_address
- insn_last_address
;
1362 if (flags
.min_after_vec
)
1363 min_addr
+= insn_current_address
- insn_last_address
;
1364 if (flags
.max_after_vec
)
1365 max_addr
+= insn_current_address
- insn_last_address
;
1366 /* We want to know the worst case, i.e. lowest possible value
1367 for the offset of MIN_LAB. If MIN_LAB is after REL_LAB,
1368 its offset is positive, and we have to be wary of code shrink;
1369 otherwise, it is negative, and we have to be vary of code
1371 if (flags
.min_after_base
)
1373 /* If INSN is between REL_LAB and MIN_LAB, the size
1374 changes we are about to make can change the alignment
1375 within the observed offset, therefore we have to break
1376 it up into two parts that are independent. */
1377 if (! flags
.base_after_vec
&& flags
.min_after_vec
)
1379 min_addr
-= align_fuzz (rel_lab
, insn
, rel_align
, 0);
1380 min_addr
-= align_fuzz (insn
, min_lab
, 0, 0);
1383 min_addr
-= align_fuzz (rel_lab
, min_lab
, rel_align
, 0);
1387 if (flags
.base_after_vec
&& ! flags
.min_after_vec
)
1389 min_addr
-= align_fuzz (min_lab
, insn
, 0, ~0);
1390 min_addr
-= align_fuzz (insn
, rel_lab
, 0, ~0);
1393 min_addr
-= align_fuzz (min_lab
, rel_lab
, 0, ~0);
1395 /* Likewise, determine the highest lowest possible value
1396 for the offset of MAX_LAB. */
1397 if (flags
.max_after_base
)
1399 if (! flags
.base_after_vec
&& flags
.max_after_vec
)
1401 max_addr
+= align_fuzz (rel_lab
, insn
, rel_align
, ~0);
1402 max_addr
+= align_fuzz (insn
, max_lab
, 0, ~0);
1405 max_addr
+= align_fuzz (rel_lab
, max_lab
, rel_align
, ~0);
1409 if (flags
.base_after_vec
&& ! flags
.max_after_vec
)
1411 max_addr
+= align_fuzz (max_lab
, insn
, 0, 0);
1412 max_addr
+= align_fuzz (insn
, rel_lab
, 0, 0);
1415 max_addr
+= align_fuzz (max_lab
, rel_lab
, 0, 0);
1417 PUT_MODE (body
, CASE_VECTOR_SHORTEN_MODE (min_addr
- rel_addr
,
1418 max_addr
- rel_addr
,
1420 if (JUMP_TABLES_IN_TEXT_SECTION
1421 #if !defined(READONLY_DATA_SECTION)
1427 = (XVECLEN (body
, 1) * GET_MODE_SIZE (GET_MODE (body
)));
1428 insn_current_address
+= insn_lengths
[uid
];
1429 if (insn_lengths
[uid
] != old_length
)
1430 something_changed
= 1;
1435 #endif /* CASE_VECTOR_SHORTEN_MODE */
1437 if (! (varying_length
[uid
]))
1439 insn_current_address
+= insn_lengths
[uid
];
1442 if (GET_CODE (insn
) == INSN
&& GET_CODE (PATTERN (insn
)) == SEQUENCE
)
1446 body
= PATTERN (insn
);
1448 for (i
= 0; i
< XVECLEN (body
, 0); i
++)
1450 rtx inner_insn
= XVECEXP (body
, 0, i
);
1451 int inner_uid
= INSN_UID (inner_insn
);
1454 INSN_ADDRESSES (inner_uid
) = insn_current_address
;
1456 /* insn_current_length returns 0 for insns with a
1457 non-varying length. */
1458 if (! varying_length
[inner_uid
])
1459 inner_length
= insn_lengths
[inner_uid
];
1461 inner_length
= insn_current_length (inner_insn
);
1463 if (inner_length
!= insn_lengths
[inner_uid
])
1465 insn_lengths
[inner_uid
] = inner_length
;
1466 something_changed
= 1;
1468 insn_current_address
+= insn_lengths
[inner_uid
];
1469 new_length
+= inner_length
;
1474 new_length
= insn_current_length (insn
);
1475 insn_current_address
+= new_length
;
1478 #ifdef ADJUST_INSN_LENGTH
1479 /* If needed, do any adjustment. */
1480 tmp_length
= new_length
;
1481 ADJUST_INSN_LENGTH (insn
, new_length
);
1482 insn_current_address
+= (new_length
- tmp_length
);
1485 if (new_length
!= insn_lengths
[uid
])
1487 insn_lengths
[uid
] = new_length
;
1488 something_changed
= 1;
1491 /* For a non-optimizing compile, do only a single pass. */
1496 free (varying_length
);
1498 #endif /* HAVE_ATTR_length */
1501 #ifdef HAVE_ATTR_length
1502 /* Given the body of an INSN known to be generated by an ASM statement, return
1503 the number of machine instructions likely to be generated for this insn.
1504 This is used to compute its length. */
1507 asm_insn_count (body
)
1510 const char *template;
1513 if (GET_CODE (body
) == ASM_INPUT
)
1514 template = XSTR (body
, 0);
1516 template = decode_asm_operands (body
, NULL
, NULL
, NULL
, NULL
);
1518 for (; *template; template++)
1519 if (IS_ASM_LOGICAL_LINE_SEPARATOR (*template) || *template == '\n')
1526 /* Output assembler code for the start of a function,
1527 and initialize some of the variables in this file
1528 for the new function. The label for the function and associated
1529 assembler pseudo-ops have already been output in `assemble_start_function'.
1531 FIRST is the first insn of the rtl for the function being compiled.
1532 FILE is the file to write assembler code to.
1533 OPTIMIZE is nonzero if we should eliminate redundant
1534 test and compare insns. */
1537 final_start_function (first
, file
, optimize
)
1540 int optimize ATTRIBUTE_UNUSED
;
1544 this_is_asm_operands
= 0;
1546 #ifdef NON_SAVING_SETJMP
1547 /* A function that calls setjmp should save and restore all the
1548 call-saved registers on a system where longjmp clobbers them. */
1549 if (NON_SAVING_SETJMP
&& current_function_calls_setjmp
)
1553 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
1554 if (!call_used_regs
[i
])
1555 regs_ever_live
[i
] = 1;
1559 /* Initial line number is supposed to be output
1560 before the function's prologue and label
1561 so that the function's address will not appear to be
1562 in the last statement of the preceding function. */
1563 if (NOTE_LINE_NUMBER (first
) != NOTE_INSN_DELETED
)
1564 last_linenum
= high_block_linenum
= high_function_linenum
1565 = NOTE_LINE_NUMBER (first
);
1567 #if defined (DWARF2_UNWIND_INFO) || defined (IA64_UNWIND_INFO) \
1568 || defined (DWARF2_DEBUGGING_INFO)
1569 dwarf2out_begin_prologue ();
1572 /* For SDB and XCOFF, the function beginning must be marked between
1573 the function label and the prologue. We always need this, even when
1574 -g1 was used. Defer on MIPS systems so that parameter descriptions
1575 follow function entry. */
1576 #if defined(SDB_DEBUGGING_INFO) && !defined(MIPS_DEBUGGING_INFO)
1577 if (write_symbols
== SDB_DEBUG
)
1578 sdbout_begin_function (last_linenum
);
1581 #ifdef XCOFF_DEBUGGING_INFO
1582 if (write_symbols
== XCOFF_DEBUG
)
1583 xcoffout_begin_function (file
, last_linenum
);
1586 /* But only output line number for other debug info types if -g2
1588 if (NOTE_LINE_NUMBER (first
) != NOTE_INSN_DELETED
)
1589 output_source_line (file
, first
);
1591 #ifdef LEAF_REG_REMAP
1592 if (current_function_uses_only_leaf_regs
)
1593 leaf_renumber_regs (first
);
1596 /* The Sun386i and perhaps other machines don't work right
1597 if the profiling code comes after the prologue. */
1598 #ifdef PROFILE_BEFORE_PROLOGUE
1600 profile_function (file
);
1601 #endif /* PROFILE_BEFORE_PROLOGUE */
1603 #if defined (DWARF2_UNWIND_INFO) && defined (HAVE_prologue)
1604 if (dwarf2out_do_frame ())
1605 dwarf2out_frame_debug (NULL_RTX
);
1608 /* If debugging, assign block numbers to all of the blocks in this
1612 number_blocks (current_function_decl
);
1613 remove_unnecessary_notes ();
1614 /* We never actually put out begin/end notes for the top-level
1615 block in the function. But, conceptually, that block is
1617 TREE_ASM_WRITTEN (DECL_INITIAL (current_function_decl
)) = 1;
1620 #ifdef FUNCTION_PROLOGUE
1621 /* First output the function prologue: code to set up the stack frame. */
1622 FUNCTION_PROLOGUE (file
, get_frame_size ());
1625 /* If the machine represents the prologue as RTL, the profiling code must
1626 be emitted when NOTE_INSN_PROLOGUE_END is scanned. */
1627 #ifdef HAVE_prologue
1628 if (! HAVE_prologue
)
1630 profile_after_prologue (file
);
1634 /* If we are doing basic block profiling, remember a printable version
1635 of the function name. */
1636 if (profile_block_flag
)
1639 add_bb_string ((*decl_printable_name
) (current_function_decl
, 2),
1645 profile_after_prologue (file
)
1646 FILE *file ATTRIBUTE_UNUSED
;
1648 #ifdef FUNCTION_BLOCK_PROFILER
1649 if (profile_block_flag
)
1651 FUNCTION_BLOCK_PROFILER (file
, count_basic_blocks
);
1653 #endif /* FUNCTION_BLOCK_PROFILER */
1655 #ifndef PROFILE_BEFORE_PROLOGUE
1657 profile_function (file
);
1658 #endif /* not PROFILE_BEFORE_PROLOGUE */
1662 profile_function (file
)
1665 #ifndef NO_PROFILE_COUNTERS
1666 int align
= MIN (BIGGEST_ALIGNMENT
, LONG_TYPE_SIZE
);
1668 #if defined(ASM_OUTPUT_REG_PUSH)
1669 #if defined(STRUCT_VALUE_INCOMING_REGNUM) || defined(STRUCT_VALUE_REGNUM)
1670 int sval
= current_function_returns_struct
;
1672 #if defined(STATIC_CHAIN_INCOMING_REGNUM) || defined(STATIC_CHAIN_REGNUM)
1673 int cxt
= current_function_needs_context
;
1675 #endif /* ASM_OUTPUT_REG_PUSH */
1677 #ifndef NO_PROFILE_COUNTERS
1679 ASM_OUTPUT_ALIGN (file
, floor_log2 (align
/ BITS_PER_UNIT
));
1680 ASM_OUTPUT_INTERNAL_LABEL (file
, "LP", profile_label_no
);
1681 assemble_integer (const0_rtx
, LONG_TYPE_SIZE
/ BITS_PER_UNIT
, 1);
1684 function_section (current_function_decl
);
1686 #if defined(STRUCT_VALUE_INCOMING_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
1688 ASM_OUTPUT_REG_PUSH (file
, STRUCT_VALUE_INCOMING_REGNUM
);
1690 #if defined(STRUCT_VALUE_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
1693 ASM_OUTPUT_REG_PUSH (file
, STRUCT_VALUE_REGNUM
);
1698 #if defined(STATIC_CHAIN_INCOMING_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
1700 ASM_OUTPUT_REG_PUSH (file
, STATIC_CHAIN_INCOMING_REGNUM
);
1702 #if defined(STATIC_CHAIN_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
1705 ASM_OUTPUT_REG_PUSH (file
, STATIC_CHAIN_REGNUM
);
1710 FUNCTION_PROFILER (file
, profile_label_no
);
1712 #if defined(STATIC_CHAIN_INCOMING_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
1714 ASM_OUTPUT_REG_POP (file
, STATIC_CHAIN_INCOMING_REGNUM
);
1716 #if defined(STATIC_CHAIN_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
1719 ASM_OUTPUT_REG_POP (file
, STATIC_CHAIN_REGNUM
);
1724 #if defined(STRUCT_VALUE_INCOMING_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
1726 ASM_OUTPUT_REG_POP (file
, STRUCT_VALUE_INCOMING_REGNUM
);
1728 #if defined(STRUCT_VALUE_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
1731 ASM_OUTPUT_REG_POP (file
, STRUCT_VALUE_REGNUM
);
1737 /* Output assembler code for the end of a function.
1738 For clarity, args are same as those of `final_start_function'
1739 even though not all of them are needed. */
1742 final_end_function (first
, file
, optimize
)
1743 rtx first ATTRIBUTE_UNUSED
;
1744 FILE *file ATTRIBUTE_UNUSED
;
1745 int optimize ATTRIBUTE_UNUSED
;
1749 #ifdef SDB_DEBUGGING_INFO
1750 if (write_symbols
== SDB_DEBUG
)
1751 sdbout_end_function (high_function_linenum
);
1754 #ifdef DWARF_DEBUGGING_INFO
1755 if (write_symbols
== DWARF_DEBUG
)
1756 dwarfout_end_function ();
1759 #ifdef XCOFF_DEBUGGING_INFO
1760 if (write_symbols
== XCOFF_DEBUG
)
1761 xcoffout_end_function (file
, high_function_linenum
);
1764 #ifdef FUNCTION_EPILOGUE
1765 /* Finally, output the function epilogue:
1766 code to restore the stack frame and return to the caller. */
1767 FUNCTION_EPILOGUE (file
, get_frame_size ());
1770 #ifdef SDB_DEBUGGING_INFO
1771 if (write_symbols
== SDB_DEBUG
)
1772 sdbout_end_epilogue ();
1775 #ifdef DWARF_DEBUGGING_INFO
1776 if (write_symbols
== DWARF_DEBUG
)
1777 dwarfout_end_epilogue ();
1780 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
1781 if (dwarf2out_do_frame ())
1782 dwarf2out_end_epilogue ();
1785 #ifdef XCOFF_DEBUGGING_INFO
1786 if (write_symbols
== XCOFF_DEBUG
)
1787 xcoffout_end_epilogue (file
);
1790 bb_func_label_num
= -1; /* not in function, nuke label # */
1792 /* If FUNCTION_EPILOGUE is not defined, then the function body
1793 itself contains return instructions wherever needed. */
1796 /* Add a block to the linked list that remembers the current line/file/function
1797 for basic block profiling. Emit the label in front of the basic block and
1798 the instructions that increment the count field. */
1804 struct bb_list
*ptr
=
1805 (struct bb_list
*) permalloc (sizeof (struct bb_list
));
1807 /* Add basic block to linked list. */
1809 ptr
->line_num
= last_linenum
;
1810 ptr
->file_label_num
= bb_file_label_num
;
1811 ptr
->func_label_num
= bb_func_label_num
;
1813 bb_tail
= &ptr
->next
;
1815 /* Enable the table of basic-block use counts
1816 to point at the code it applies to. */
1817 ASM_OUTPUT_INTERNAL_LABEL (file
, "LPB", count_basic_blocks
);
1819 /* Before first insn of this basic block, increment the
1820 count of times it was entered. */
1821 #ifdef BLOCK_PROFILER
1822 BLOCK_PROFILER (file
, count_basic_blocks
);
1829 count_basic_blocks
++;
1832 /* Add a string to be used for basic block profiling. */
1835 add_bb_string (string
, perm_p
)
1840 struct bb_str
*ptr
= 0;
1844 string
= "<unknown>";
1848 /* Allocate a new string if the current string isn't permanent. If
1849 the string is permanent search for the same string in other
1852 len
= strlen (string
) + 1;
1855 char *p
= (char *) permalloc (len
);
1856 memcpy (p
, string
, len
);
1860 for (ptr
= sbb_head
; ptr
!= (struct bb_str
*) 0; ptr
= ptr
->next
)
1861 if (ptr
->string
== string
)
1864 /* Allocate a new string block if we need to. */
1867 ptr
= (struct bb_str
*) permalloc (sizeof (*ptr
));
1870 ptr
->label_num
= sbb_label_num
++;
1871 ptr
->string
= string
;
1873 sbb_tail
= &ptr
->next
;
1876 return ptr
->label_num
;
1879 /* Output assembler code for some insns: all or part of a function.
1880 For description of args, see `final_start_function', above.
1882 PRESCAN is 1 if we are not really outputting,
1883 just scanning as if we were outputting.
1884 Prescanning deletes and rearranges insns just like ordinary output.
1885 PRESCAN is -2 if we are outputting after having prescanned.
1886 In this case, don't try to delete or rearrange insns
1887 because that has already been done.
1888 Prescanning is done only on certain machines. */
1891 final (first
, file
, optimize
, prescan
)
1901 last_ignored_compare
= 0;
1904 /* Make a map indicating which line numbers appear in this function.
1905 When producing SDB debugging info, delete troublesome line number
1906 notes from inlined functions in other files as well as duplicate
1907 line number notes. */
1908 #ifdef SDB_DEBUGGING_INFO
1909 if (write_symbols
== SDB_DEBUG
)
1912 for (insn
= first
; insn
; insn
= NEXT_INSN (insn
))
1913 if (GET_CODE (insn
) == NOTE
&& NOTE_LINE_NUMBER (insn
) > 0)
1915 if ((RTX_INTEGRATED_P (insn
)
1916 && strcmp (NOTE_SOURCE_FILE (insn
), main_input_filename
) != 0)
1918 && NOTE_LINE_NUMBER (insn
) == NOTE_LINE_NUMBER (last
)
1919 && NOTE_SOURCE_FILE (insn
) == NOTE_SOURCE_FILE (last
)))
1921 NOTE_LINE_NUMBER (insn
) = NOTE_INSN_DELETED
;
1922 NOTE_SOURCE_FILE (insn
) = 0;
1926 if (NOTE_LINE_NUMBER (insn
) > max_line
)
1927 max_line
= NOTE_LINE_NUMBER (insn
);
1933 for (insn
= first
; insn
; insn
= NEXT_INSN (insn
))
1934 if (GET_CODE (insn
) == NOTE
&& NOTE_LINE_NUMBER (insn
) > max_line
)
1935 max_line
= NOTE_LINE_NUMBER (insn
);
1938 line_note_exists
= (char *) xcalloc (max_line
+ 1, sizeof (char));
1940 for (insn
= first
; insn
; insn
= NEXT_INSN (insn
))
1942 if (INSN_UID (insn
) > max_uid
) /* find largest UID */
1943 max_uid
= INSN_UID (insn
);
1944 if (GET_CODE (insn
) == NOTE
&& NOTE_LINE_NUMBER (insn
) > 0)
1945 line_note_exists
[NOTE_LINE_NUMBER (insn
)] = 1;
1947 /* If CC tracking across branches is enabled, record the insn which
1948 jumps to each branch only reached from one place. */
1949 if (optimize
&& GET_CODE (insn
) == JUMP_INSN
)
1951 rtx lab
= JUMP_LABEL (insn
);
1952 if (lab
&& LABEL_NUSES (lab
) == 1)
1954 LABEL_REFS (lab
) = insn
;
1964 /* Output the insns. */
1965 for (insn
= NEXT_INSN (first
); insn
;)
1967 #ifdef HAVE_ATTR_length
1968 if (INSN_UID (insn
) >= INSN_ADDRESSES_SIZE ())
1971 /* Irritatingly, the reg-stack pass is creating new instructions
1972 and because of REG_DEAD note abuse it has to run after
1973 shorten_branches. Fake address of -1 then. */
1974 insn_current_address
= -1;
1976 /* This can be triggered by bugs elsewhere in the compiler if
1977 new insns are created after init_insn_lengths is called. */
1982 insn_current_address
= INSN_ADDRESSES (INSN_UID (insn
));
1983 #endif /* HAVE_ATTR_length */
1985 insn
= final_scan_insn (insn
, file
, optimize
, prescan
, 0);
1988 /* Do basic-block profiling here
1989 if the last insn was a conditional branch. */
1990 if (profile_block_flag
&& new_block
)
1993 free (line_note_exists
);
1994 line_note_exists
= NULL
;
1998 get_insn_template (code
, insn
)
2002 const void *output
= insn_data
[code
].output
;
2003 switch (insn_data
[code
].output_format
)
2005 case INSN_OUTPUT_FORMAT_SINGLE
:
2006 return (const char *) output
;
2007 case INSN_OUTPUT_FORMAT_MULTI
:
2008 return ((const char *const *) output
)[which_alternative
];
2009 case INSN_OUTPUT_FORMAT_FUNCTION
:
2012 return (*(insn_output_fn
) output
) (recog_data
.operand
, insn
);
2019 /* The final scan for one insn, INSN.
2020 Args are same as in `final', except that INSN
2021 is the insn being scanned.
2022 Value returned is the next insn to be scanned.
2024 NOPEEPHOLES is the flag to disallow peephole processing (currently
2025 used for within delayed branch sequence output). */
2028 final_scan_insn (insn
, file
, optimize
, prescan
, nopeepholes
)
2031 int optimize ATTRIBUTE_UNUSED
;
2033 int nopeepholes ATTRIBUTE_UNUSED
;
2041 /* Ignore deleted insns. These can occur when we split insns (due to a
2042 template of "#") while not optimizing. */
2043 if (INSN_DELETED_P (insn
))
2044 return NEXT_INSN (insn
);
2046 switch (GET_CODE (insn
))
2052 switch (NOTE_LINE_NUMBER (insn
))
2054 case NOTE_INSN_DELETED
:
2055 case NOTE_INSN_LOOP_BEG
:
2056 case NOTE_INSN_LOOP_END
:
2057 case NOTE_INSN_LOOP_CONT
:
2058 case NOTE_INSN_LOOP_VTOP
:
2059 case NOTE_INSN_FUNCTION_END
:
2060 case NOTE_INSN_SETJMP
:
2061 case NOTE_INSN_REPEATED_LINE_NUMBER
:
2062 case NOTE_INSN_RANGE_BEG
:
2063 case NOTE_INSN_RANGE_END
:
2064 case NOTE_INSN_LIVE
:
2065 case NOTE_INSN_EXPECTED_VALUE
:
2068 case NOTE_INSN_BASIC_BLOCK
:
2069 #ifdef IA64_UNWIND_INFO
2070 IA64_UNWIND_EMIT (asm_out_file
, insn
);
2073 fprintf (asm_out_file
, "\t%s basic block %d\n",
2074 ASM_COMMENT_START
, NOTE_BASIC_BLOCK (insn
)->index
);
2077 case NOTE_INSN_EH_REGION_BEG
:
2078 ASM_OUTPUT_DEBUG_LABEL (asm_out_file
, "LEHB",
2079 NOTE_EH_HANDLER (insn
));
2082 case NOTE_INSN_EH_REGION_END
:
2083 ASM_OUTPUT_DEBUG_LABEL (asm_out_file
, "LEHE",
2084 NOTE_EH_HANDLER (insn
));
2087 case NOTE_INSN_PROLOGUE_END
:
2088 #ifdef FUNCTION_END_PROLOGUE
2089 FUNCTION_END_PROLOGUE (file
);
2091 profile_after_prologue (file
);
2094 case NOTE_INSN_EPILOGUE_BEG
:
2095 #ifdef FUNCTION_BEGIN_EPILOGUE
2096 FUNCTION_BEGIN_EPILOGUE (file
);
2100 case NOTE_INSN_FUNCTION_BEG
:
2101 #if defined(SDB_DEBUGGING_INFO) && defined(MIPS_DEBUGGING_INFO)
2102 /* MIPS stabs require the parameter descriptions to be after the
2103 function entry point rather than before. */
2104 if (write_symbols
== SDB_DEBUG
)
2107 sdbout_begin_function (last_linenum
);
2110 #ifdef DWARF_DEBUGGING_INFO
2111 /* This outputs a marker where the function body starts, so it
2112 must be after the prologue. */
2113 if (write_symbols
== DWARF_DEBUG
)
2116 dwarfout_begin_function ();
2121 case NOTE_INSN_BLOCK_BEG
:
2122 if (debug_info_level
== DINFO_LEVEL_NORMAL
2123 || debug_info_level
== DINFO_LEVEL_VERBOSE
2124 || write_symbols
== DWARF_DEBUG
2125 || write_symbols
== DWARF2_DEBUG
)
2127 int n
= BLOCK_NUMBER (NOTE_BLOCK (insn
));
2131 high_block_linenum
= last_linenum
;
2133 /* Output debugging info about the symbol-block beginning. */
2134 #ifdef SDB_DEBUGGING_INFO
2135 if (write_symbols
== SDB_DEBUG
)
2136 sdbout_begin_block (file
, last_linenum
, n
);
2138 #ifdef XCOFF_DEBUGGING_INFO
2139 if (write_symbols
== XCOFF_DEBUG
)
2140 xcoffout_begin_block (file
, last_linenum
, n
);
2142 #ifdef DBX_DEBUGGING_INFO
2143 if (write_symbols
== DBX_DEBUG
)
2144 ASM_OUTPUT_INTERNAL_LABEL (file
, "LBB", n
);
2146 #ifdef DWARF_DEBUGGING_INFO
2147 if (write_symbols
== DWARF_DEBUG
)
2148 dwarfout_begin_block (n
);
2150 #ifdef DWARF2_DEBUGGING_INFO
2151 if (write_symbols
== DWARF2_DEBUG
)
2152 dwarf2out_begin_block (n
);
2155 /* Mark this block as output. */
2156 TREE_ASM_WRITTEN (NOTE_BLOCK (insn
)) = 1;
2160 case NOTE_INSN_BLOCK_END
:
2161 if (debug_info_level
== DINFO_LEVEL_NORMAL
2162 || debug_info_level
== DINFO_LEVEL_VERBOSE
2163 || write_symbols
== DWARF_DEBUG
2164 || write_symbols
== DWARF2_DEBUG
)
2166 int n
= BLOCK_NUMBER (NOTE_BLOCK (insn
));
2170 /* End of a symbol-block. */
2172 if (block_depth
< 0)
2175 #ifdef XCOFF_DEBUGGING_INFO
2176 if (write_symbols
== XCOFF_DEBUG
)
2177 xcoffout_end_block (file
, high_block_linenum
, n
);
2179 #ifdef DBX_DEBUGGING_INFO
2180 if (write_symbols
== DBX_DEBUG
)
2181 ASM_OUTPUT_INTERNAL_LABEL (file
, "LBE", n
);
2183 #ifdef SDB_DEBUGGING_INFO
2184 if (write_symbols
== SDB_DEBUG
)
2185 sdbout_end_block (file
, high_block_linenum
, n
);
2187 #ifdef DWARF_DEBUGGING_INFO
2188 if (write_symbols
== DWARF_DEBUG
)
2189 dwarfout_end_block (n
);
2191 #ifdef DWARF2_DEBUGGING_INFO
2192 if (write_symbols
== DWARF2_DEBUG
)
2193 dwarf2out_end_block (n
);
2198 case NOTE_INSN_DELETED_LABEL
:
2199 /* Emit the label. We may have deleted the CODE_LABEL because
2200 the label could be proved to be unreachable, though still
2201 referenced (in the form of having its address taken. */
2202 ASM_OUTPUT_DEBUG_LABEL (file
, "L", CODE_LABEL_NUMBER (insn
));
2209 if (NOTE_LINE_NUMBER (insn
) <= 0)
2212 /* This note is a line-number. */
2217 /* If there is anything real after this note, output it.
2218 If another line note follows, omit this one. */
2219 for (note
= NEXT_INSN (insn
); note
; note
= NEXT_INSN (note
))
2221 if (GET_CODE (note
) != NOTE
&& GET_CODE (note
) != CODE_LABEL
)
2224 /* These types of notes can be significant
2225 so make sure the preceding line number stays. */
2226 else if (GET_CODE (note
) == NOTE
2227 && (NOTE_LINE_NUMBER (note
) == NOTE_INSN_BLOCK_BEG
2228 || NOTE_LINE_NUMBER (note
) == NOTE_INSN_BLOCK_END
2229 || NOTE_LINE_NUMBER (note
) == NOTE_INSN_FUNCTION_BEG
))
2231 else if (GET_CODE (note
) == NOTE
&& NOTE_LINE_NUMBER (note
) > 0)
2233 /* Another line note follows; we can delete this note
2234 if no intervening line numbers have notes elsewhere. */
2236 for (num
= NOTE_LINE_NUMBER (insn
) + 1;
2237 num
< NOTE_LINE_NUMBER (note
);
2239 if (line_note_exists
[num
])
2242 if (num
>= NOTE_LINE_NUMBER (note
))
2248 /* Output this line note if it is the first or the last line
2251 output_source_line (file
, insn
);
2258 #if defined (DWARF2_UNWIND_INFO)
2259 if (dwarf2out_do_frame ())
2260 dwarf2out_frame_debug (insn
);
2265 /* The target port might emit labels in the output function for
2266 some insn, e.g. sh.c output_branchy_insn. */
2267 if (CODE_LABEL_NUMBER (insn
) <= max_labelno
)
2269 int align
= LABEL_TO_ALIGNMENT (insn
);
2270 #ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
2271 int max_skip
= LABEL_TO_MAX_SKIP (insn
);
2274 if (align
&& NEXT_INSN (insn
))
2275 #ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
2276 ASM_OUTPUT_MAX_SKIP_ALIGN (file
, align
, max_skip
);
2278 ASM_OUTPUT_ALIGN (file
, align
);
2283 /* If this label is reached from only one place, set the condition
2284 codes from the instruction just before the branch. */
2286 /* Disabled because some insns set cc_status in the C output code
2287 and NOTICE_UPDATE_CC alone can set incorrect status. */
2288 if (0 /* optimize && LABEL_NUSES (insn) == 1*/)
2290 rtx jump
= LABEL_REFS (insn
);
2291 rtx barrier
= prev_nonnote_insn (insn
);
2293 /* If the LABEL_REFS field of this label has been set to point
2294 at a branch, the predecessor of the branch is a regular
2295 insn, and that branch is the only way to reach this label,
2296 set the condition codes based on the branch and its
2298 if (barrier
&& GET_CODE (barrier
) == BARRIER
2299 && jump
&& GET_CODE (jump
) == JUMP_INSN
2300 && (prev
= prev_nonnote_insn (jump
))
2301 && GET_CODE (prev
) == INSN
)
2303 NOTICE_UPDATE_CC (PATTERN (prev
), prev
);
2304 NOTICE_UPDATE_CC (PATTERN (jump
), jump
);
2312 #ifdef FINAL_PRESCAN_LABEL
2313 FINAL_PRESCAN_INSN (insn
, NULL
, 0);
2316 #ifdef SDB_DEBUGGING_INFO
2317 if (write_symbols
== SDB_DEBUG
&& LABEL_NAME (insn
))
2318 sdbout_label (insn
);
2322 fputs (ASM_APP_OFF
, file
);
2325 if (NEXT_INSN (insn
) != 0
2326 && GET_CODE (NEXT_INSN (insn
)) == JUMP_INSN
)
2328 rtx nextbody
= PATTERN (NEXT_INSN (insn
));
2330 /* If this label is followed by a jump-table,
2331 make sure we put the label in the read-only section. Also
2332 possibly write the label and jump table together. */
2334 if (GET_CODE (nextbody
) == ADDR_VEC
2335 || GET_CODE (nextbody
) == ADDR_DIFF_VEC
)
2337 #if defined(ASM_OUTPUT_ADDR_VEC) || defined(ASM_OUTPUT_ADDR_DIFF_VEC)
2338 /* In this case, the case vector is being moved by the
2339 target, so don't output the label at all. Leave that
2340 to the back end macros. */
2342 if (! JUMP_TABLES_IN_TEXT_SECTION
)
2344 readonly_data_section ();
2345 #ifdef READONLY_DATA_SECTION
2346 ASM_OUTPUT_ALIGN (file
,
2347 exact_log2 (BIGGEST_ALIGNMENT
2349 #endif /* READONLY_DATA_SECTION */
2352 function_section (current_function_decl
);
2354 #ifdef ASM_OUTPUT_CASE_LABEL
2355 ASM_OUTPUT_CASE_LABEL (file
, "L", CODE_LABEL_NUMBER (insn
),
2358 if (LABEL_ALTERNATE_NAME (insn
))
2359 ASM_OUTPUT_ALTERNATE_LABEL_NAME (file
, insn
);
2361 ASM_OUTPUT_INTERNAL_LABEL (file
, "L", CODE_LABEL_NUMBER (insn
));
2367 if (LABEL_ALTERNATE_NAME (insn
))
2368 ASM_OUTPUT_ALTERNATE_LABEL_NAME (file
, insn
);
2370 ASM_OUTPUT_INTERNAL_LABEL (file
, "L", CODE_LABEL_NUMBER (insn
));
2375 register rtx body
= PATTERN (insn
);
2376 int insn_code_number
;
2377 const char *template;
2382 /* An INSN, JUMP_INSN or CALL_INSN.
2383 First check for special kinds that recog doesn't recognize. */
2385 if (GET_CODE (body
) == USE
/* These are just declarations */
2386 || GET_CODE (body
) == CLOBBER
)
2390 /* If there is a REG_CC_SETTER note on this insn, it means that
2391 the setting of the condition code was done in the delay slot
2392 of the insn that branched here. So recover the cc status
2393 from the insn that set it. */
2395 note
= find_reg_note (insn
, REG_CC_SETTER
, NULL_RTX
);
2398 NOTICE_UPDATE_CC (PATTERN (XEXP (note
, 0)), XEXP (note
, 0));
2399 cc_prev_status
= cc_status
;
2403 /* Detect insns that are really jump-tables
2404 and output them as such. */
2406 if (GET_CODE (body
) == ADDR_VEC
|| GET_CODE (body
) == ADDR_DIFF_VEC
)
2408 #if !(defined(ASM_OUTPUT_ADDR_VEC) || defined(ASM_OUTPUT_ADDR_DIFF_VEC))
2409 register int vlen
, idx
;
2417 fputs (ASM_APP_OFF
, file
);
2421 #if defined(ASM_OUTPUT_ADDR_VEC) || defined(ASM_OUTPUT_ADDR_DIFF_VEC)
2422 if (GET_CODE (body
) == ADDR_VEC
)
2424 #ifdef ASM_OUTPUT_ADDR_VEC
2425 ASM_OUTPUT_ADDR_VEC (PREV_INSN (insn
), body
);
2432 #ifdef ASM_OUTPUT_ADDR_DIFF_VEC
2433 ASM_OUTPUT_ADDR_DIFF_VEC (PREV_INSN (insn
), body
);
2439 vlen
= XVECLEN (body
, GET_CODE (body
) == ADDR_DIFF_VEC
);
2440 for (idx
= 0; idx
< vlen
; idx
++)
2442 if (GET_CODE (body
) == ADDR_VEC
)
2444 #ifdef ASM_OUTPUT_ADDR_VEC_ELT
2445 ASM_OUTPUT_ADDR_VEC_ELT
2446 (file
, CODE_LABEL_NUMBER (XEXP (XVECEXP (body
, 0, idx
), 0)));
2453 #ifdef ASM_OUTPUT_ADDR_DIFF_ELT
2454 ASM_OUTPUT_ADDR_DIFF_ELT
2457 CODE_LABEL_NUMBER (XEXP (XVECEXP (body
, 1, idx
), 0)),
2458 CODE_LABEL_NUMBER (XEXP (XEXP (body
, 0), 0)));
2464 #ifdef ASM_OUTPUT_CASE_END
2465 ASM_OUTPUT_CASE_END (file
,
2466 CODE_LABEL_NUMBER (PREV_INSN (insn
)),
2471 function_section (current_function_decl
);
2476 /* Do basic-block profiling when we reach a new block.
2477 Done here to avoid jump tables. */
2478 if (profile_block_flag
&& new_block
)
2481 if (GET_CODE (body
) == ASM_INPUT
)
2483 /* There's no telling what that did to the condition codes. */
2489 fputs (ASM_APP_ON
, file
);
2492 fprintf (asm_out_file
, "\t%s\n", XSTR (body
, 0));
2496 /* Detect `asm' construct with operands. */
2497 if (asm_noperands (body
) >= 0)
2499 unsigned int noperands
= asm_noperands (body
);
2500 rtx
*ops
= (rtx
*) alloca (noperands
* sizeof (rtx
));
2503 /* There's no telling what that did to the condition codes. */
2510 fputs (ASM_APP_ON
, file
);
2514 /* Get out the operand values. */
2515 string
= decode_asm_operands (body
, ops
, NULL
, NULL
, NULL
);
2516 /* Inhibit aborts on what would otherwise be compiler bugs. */
2517 insn_noperands
= noperands
;
2518 this_is_asm_operands
= insn
;
2520 /* Output the insn using them. */
2521 output_asm_insn (string
, ops
);
2522 this_is_asm_operands
= 0;
2526 if (prescan
<= 0 && app_on
)
2528 fputs (ASM_APP_OFF
, file
);
2532 if (GET_CODE (body
) == SEQUENCE
)
2534 /* A delayed-branch sequence */
2540 final_sequence
= body
;
2542 /* The first insn in this SEQUENCE might be a JUMP_INSN that will
2543 force the restoration of a comparison that was previously
2544 thought unnecessary. If that happens, cancel this sequence
2545 and cause that insn to be restored. */
2547 next
= final_scan_insn (XVECEXP (body
, 0, 0), file
, 0, prescan
, 1);
2548 if (next
!= XVECEXP (body
, 0, 1))
2554 for (i
= 1; i
< XVECLEN (body
, 0); i
++)
2556 rtx insn
= XVECEXP (body
, 0, i
);
2557 rtx next
= NEXT_INSN (insn
);
2558 /* We loop in case any instruction in a delay slot gets
2561 insn
= final_scan_insn (insn
, file
, 0, prescan
, 1);
2562 while (insn
!= next
);
2564 #ifdef DBR_OUTPUT_SEQEND
2565 DBR_OUTPUT_SEQEND (file
);
2569 /* If the insn requiring the delay slot was a CALL_INSN, the
2570 insns in the delay slot are actually executed before the
2571 called function. Hence we don't preserve any CC-setting
2572 actions in these insns and the CC must be marked as being
2573 clobbered by the function. */
2574 if (GET_CODE (XVECEXP (body
, 0, 0)) == CALL_INSN
)
2579 /* Following a conditional branch sequence, we have a new basic
2581 if (profile_block_flag
)
2583 rtx insn
= XVECEXP (body
, 0, 0);
2584 rtx body
= PATTERN (insn
);
2586 if ((GET_CODE (insn
) == JUMP_INSN
&& GET_CODE (body
) == SET
2587 && GET_CODE (SET_SRC (body
)) != LABEL_REF
)
2588 || (GET_CODE (insn
) == JUMP_INSN
2589 && GET_CODE (body
) == PARALLEL
2590 && GET_CODE (XVECEXP (body
, 0, 0)) == SET
2591 && GET_CODE (SET_SRC (XVECEXP (body
, 0, 0))) != LABEL_REF
))
2597 /* We have a real machine instruction as rtl. */
2599 body
= PATTERN (insn
);
2602 set
= single_set (insn
);
2604 /* Check for redundant test and compare instructions
2605 (when the condition codes are already set up as desired).
2606 This is done only when optimizing; if not optimizing,
2607 it should be possible for the user to alter a variable
2608 with the debugger in between statements
2609 and the next statement should reexamine the variable
2610 to compute the condition codes. */
2615 rtx set
= single_set (insn
);
2619 && GET_CODE (SET_DEST (set
)) == CC0
2620 && insn
!= last_ignored_compare
)
2622 if (GET_CODE (SET_SRC (set
)) == SUBREG
)
2623 SET_SRC (set
) = alter_subreg (SET_SRC (set
));
2624 else if (GET_CODE (SET_SRC (set
)) == COMPARE
)
2626 if (GET_CODE (XEXP (SET_SRC (set
), 0)) == SUBREG
)
2627 XEXP (SET_SRC (set
), 0)
2628 = alter_subreg (XEXP (SET_SRC (set
), 0));
2629 if (GET_CODE (XEXP (SET_SRC (set
), 1)) == SUBREG
)
2630 XEXP (SET_SRC (set
), 1)
2631 = alter_subreg (XEXP (SET_SRC (set
), 1));
2633 if ((cc_status
.value1
!= 0
2634 && rtx_equal_p (SET_SRC (set
), cc_status
.value1
))
2635 || (cc_status
.value2
!= 0
2636 && rtx_equal_p (SET_SRC (set
), cc_status
.value2
)))
2638 /* Don't delete insn if it has an addressing side-effect. */
2639 if (! FIND_REG_INC_NOTE (insn
, 0)
2640 /* or if anything in it is volatile. */
2641 && ! volatile_refs_p (PATTERN (insn
)))
2643 /* We don't really delete the insn; just ignore it. */
2644 last_ignored_compare
= insn
;
2652 /* Following a conditional branch, we have a new basic block.
2653 But if we are inside a sequence, the new block starts after the
2654 last insn of the sequence. */
2655 if (profile_block_flag
&& final_sequence
== 0
2656 && ((GET_CODE (insn
) == JUMP_INSN
&& GET_CODE (body
) == SET
2657 && GET_CODE (SET_SRC (body
)) != LABEL_REF
)
2658 || (GET_CODE (insn
) == JUMP_INSN
&& GET_CODE (body
) == PARALLEL
2659 && GET_CODE (XVECEXP (body
, 0, 0)) == SET
2660 && GET_CODE (SET_SRC (XVECEXP (body
, 0, 0))) != LABEL_REF
)))
2664 /* Don't bother outputting obvious no-ops, even without -O.
2665 This optimization is fast and doesn't interfere with debugging.
2666 Don't do this if the insn is in a delay slot, since this
2667 will cause an improper number of delay insns to be written. */
2668 if (final_sequence
== 0
2670 && GET_CODE (insn
) == INSN
&& GET_CODE (body
) == SET
2671 && GET_CODE (SET_SRC (body
)) == REG
2672 && GET_CODE (SET_DEST (body
)) == REG
2673 && REGNO (SET_SRC (body
)) == REGNO (SET_DEST (body
)))
2678 /* If this is a conditional branch, maybe modify it
2679 if the cc's are in a nonstandard state
2680 so that it accomplishes the same thing that it would
2681 do straightforwardly if the cc's were set up normally. */
2683 if (cc_status
.flags
!= 0
2684 && GET_CODE (insn
) == JUMP_INSN
2685 && GET_CODE (body
) == SET
2686 && SET_DEST (body
) == pc_rtx
2687 && GET_CODE (SET_SRC (body
)) == IF_THEN_ELSE
2688 && GET_RTX_CLASS (GET_CODE (XEXP (SET_SRC (body
), 0))) == '<'
2689 && XEXP (XEXP (SET_SRC (body
), 0), 0) == cc0_rtx
2690 /* This is done during prescan; it is not done again
2691 in final scan when prescan has been done. */
2694 /* This function may alter the contents of its argument
2695 and clear some of the cc_status.flags bits.
2696 It may also return 1 meaning condition now always true
2697 or -1 meaning condition now always false
2698 or 2 meaning condition nontrivial but altered. */
2699 register int result
= alter_cond (XEXP (SET_SRC (body
), 0));
2700 /* If condition now has fixed value, replace the IF_THEN_ELSE
2701 with its then-operand or its else-operand. */
2703 SET_SRC (body
) = XEXP (SET_SRC (body
), 1);
2705 SET_SRC (body
) = XEXP (SET_SRC (body
), 2);
2707 /* The jump is now either unconditional or a no-op.
2708 If it has become a no-op, don't try to output it.
2709 (It would not be recognized.) */
2710 if (SET_SRC (body
) == pc_rtx
)
2712 PUT_CODE (insn
, NOTE
);
2713 NOTE_LINE_NUMBER (insn
) = NOTE_INSN_DELETED
;
2714 NOTE_SOURCE_FILE (insn
) = 0;
2717 else if (GET_CODE (SET_SRC (body
)) == RETURN
)
2718 /* Replace (set (pc) (return)) with (return). */
2719 PATTERN (insn
) = body
= SET_SRC (body
);
2721 /* Rerecognize the instruction if it has changed. */
2723 INSN_CODE (insn
) = -1;
2726 /* Make same adjustments to instructions that examine the
2727 condition codes without jumping and instructions that
2728 handle conditional moves (if this machine has either one). */
2730 if (cc_status
.flags
!= 0
2733 rtx cond_rtx
, then_rtx
, else_rtx
;
2735 if (GET_CODE (insn
) != JUMP_INSN
2736 && GET_CODE (SET_SRC (set
)) == IF_THEN_ELSE
)
2738 cond_rtx
= XEXP (SET_SRC (set
), 0);
2739 then_rtx
= XEXP (SET_SRC (set
), 1);
2740 else_rtx
= XEXP (SET_SRC (set
), 2);
2744 cond_rtx
= SET_SRC (set
);
2745 then_rtx
= const_true_rtx
;
2746 else_rtx
= const0_rtx
;
2749 switch (GET_CODE (cond_rtx
))
2762 register int result
;
2763 if (XEXP (cond_rtx
, 0) != cc0_rtx
)
2765 result
= alter_cond (cond_rtx
);
2767 validate_change (insn
, &SET_SRC (set
), then_rtx
, 0);
2768 else if (result
== -1)
2769 validate_change (insn
, &SET_SRC (set
), else_rtx
, 0);
2770 else if (result
== 2)
2771 INSN_CODE (insn
) = -1;
2772 if (SET_DEST (set
) == SET_SRC (set
))
2774 PUT_CODE (insn
, NOTE
);
2775 NOTE_LINE_NUMBER (insn
) = NOTE_INSN_DELETED
;
2776 NOTE_SOURCE_FILE (insn
) = 0;
2788 #ifdef HAVE_peephole
2789 /* Do machine-specific peephole optimizations if desired. */
2791 if (optimize
&& !flag_no_peephole
&& !nopeepholes
)
2793 rtx next
= peephole (insn
);
2794 /* When peepholing, if there were notes within the peephole,
2795 emit them before the peephole. */
2796 if (next
!= 0 && next
!= NEXT_INSN (insn
))
2798 rtx prev
= PREV_INSN (insn
);
2801 for (note
= NEXT_INSN (insn
); note
!= next
;
2802 note
= NEXT_INSN (note
))
2803 final_scan_insn (note
, file
, optimize
, prescan
, nopeepholes
);
2805 /* In case this is prescan, put the notes
2806 in proper position for later rescan. */
2807 note
= NEXT_INSN (insn
);
2808 PREV_INSN (note
) = prev
;
2809 NEXT_INSN (prev
) = note
;
2810 NEXT_INSN (PREV_INSN (next
)) = insn
;
2811 PREV_INSN (insn
) = PREV_INSN (next
);
2812 NEXT_INSN (insn
) = next
;
2813 PREV_INSN (next
) = insn
;
2816 /* PEEPHOLE might have changed this. */
2817 body
= PATTERN (insn
);
2821 /* Try to recognize the instruction.
2822 If successful, verify that the operands satisfy the
2823 constraints for the instruction. Crash if they don't,
2824 since `reload' should have changed them so that they do. */
2826 insn_code_number
= recog_memoized (insn
);
2827 cleanup_subreg_operands (insn
);
2829 /* Dump the insn in the assembly for debugging. */
2830 if (flag_dump_rtl_in_asm
)
2832 print_rtx_head
= ASM_COMMENT_START
;
2833 print_rtl_single (asm_out_file
, insn
);
2834 print_rtx_head
= "";
2837 if (! constrain_operands_cached (1))
2838 fatal_insn_not_found (insn
);
2840 /* Some target machines need to prescan each insn before
2843 #ifdef FINAL_PRESCAN_INSN
2844 FINAL_PRESCAN_INSN (insn
, recog_data
.operand
, recog_data
.n_operands
);
2847 #ifdef HAVE_conditional_execution
2848 if (GET_CODE (PATTERN (insn
)) == COND_EXEC
)
2849 current_insn_predicate
= COND_EXEC_TEST (PATTERN (insn
));
2851 current_insn_predicate
= NULL_RTX
;
2855 cc_prev_status
= cc_status
;
2857 /* Update `cc_status' for this instruction.
2858 The instruction's output routine may change it further.
2859 If the output routine for a jump insn needs to depend
2860 on the cc status, it should look at cc_prev_status. */
2862 NOTICE_UPDATE_CC (body
, insn
);
2865 current_output_insn
= debug_insn
= insn
;
2867 #if defined (DWARF2_UNWIND_INFO)
2868 if (GET_CODE (insn
) == CALL_INSN
&& dwarf2out_do_frame ())
2869 dwarf2out_frame_debug (insn
);
2872 /* Find the proper template for this insn. */
2873 template = get_insn_template (insn_code_number
, insn
);
2875 /* If the C code returns 0, it means that it is a jump insn
2876 which follows a deleted test insn, and that test insn
2877 needs to be reinserted. */
2882 if (prev_nonnote_insn (insn
) != last_ignored_compare
)
2886 /* We have already processed the notes between the setter and
2887 the user. Make sure we don't process them again, this is
2888 particularly important if one of the notes is a block
2889 scope note or an EH note. */
2891 prev
!= last_ignored_compare
;
2892 prev
= PREV_INSN (prev
))
2894 if (GET_CODE (prev
) == NOTE
)
2896 NOTE_LINE_NUMBER (prev
) = NOTE_INSN_DELETED
;
2897 NOTE_SOURCE_FILE (prev
) = 0;
2904 /* If the template is the string "#", it means that this insn must
2906 if (template[0] == '#' && template[1] == '\0')
2908 rtx
new = try_split (body
, insn
, 0);
2910 /* If we didn't split the insn, go away. */
2911 if (new == insn
&& PATTERN (new) == body
)
2912 fatal_insn ("Could not split insn", insn
);
2914 #ifdef HAVE_ATTR_length
2915 /* This instruction should have been split in shorten_branches,
2916 to ensure that we would have valid length info for the
2928 #ifdef IA64_UNWIND_INFO
2929 IA64_UNWIND_EMIT (asm_out_file
, insn
);
2931 /* Output assembler code from the template. */
2933 output_asm_insn (template, recog_data
.operand
);
2935 #if defined (DWARF2_UNWIND_INFO)
2936 #if defined (HAVE_prologue)
2937 if (GET_CODE (insn
) == INSN
&& dwarf2out_do_frame ())
2938 dwarf2out_frame_debug (insn
);
2940 if (!ACCUMULATE_OUTGOING_ARGS
2941 && GET_CODE (insn
) == INSN
2942 && dwarf2out_do_frame ())
2943 dwarf2out_frame_debug (insn
);
2948 /* It's not at all clear why we did this and doing so interferes
2949 with tests we'd like to do to use REG_WAS_0 notes, so let's try
2952 /* Mark this insn as having been output. */
2953 INSN_DELETED_P (insn
) = 1;
2956 current_output_insn
= debug_insn
= 0;
2959 return NEXT_INSN (insn
);
2962 /* Output debugging info to the assembler file FILE
2963 based on the NOTE-insn INSN, assumed to be a line number. */
2966 output_source_line (file
, insn
)
2967 FILE *file ATTRIBUTE_UNUSED
;
2970 register const char *filename
= NOTE_SOURCE_FILE (insn
);
2972 /* Remember filename for basic block profiling.
2973 Filenames are allocated on the permanent obstack
2974 or are passed in ARGV, so we don't have to save
2977 if (profile_block_flag
&& last_filename
!= filename
)
2978 bb_file_label_num
= add_bb_string (filename
, TRUE
);
2980 last_filename
= filename
;
2981 last_linenum
= NOTE_LINE_NUMBER (insn
);
2982 high_block_linenum
= MAX (last_linenum
, high_block_linenum
);
2983 high_function_linenum
= MAX (last_linenum
, high_function_linenum
);
2985 if (write_symbols
!= NO_DEBUG
)
2987 #ifdef SDB_DEBUGGING_INFO
2988 if (write_symbols
== SDB_DEBUG
2989 #if 0 /* People like having line numbers even in wrong file! */
2990 /* COFF can't handle multiple source files--lose, lose. */
2991 && !strcmp (filename
, main_input_filename
)
2993 /* COFF relative line numbers must be positive. */
2994 && last_linenum
> sdb_begin_function_line
)
2996 #ifdef ASM_OUTPUT_SOURCE_LINE
2997 ASM_OUTPUT_SOURCE_LINE (file
, last_linenum
);
2999 fprintf (file
, "\t.ln\t%d\n",
3000 ((sdb_begin_function_line
> -1)
3001 ? last_linenum
- sdb_begin_function_line
: 1));
3006 #if defined (DBX_DEBUGGING_INFO)
3007 if (write_symbols
== DBX_DEBUG
)
3008 dbxout_source_line (file
, filename
, NOTE_LINE_NUMBER (insn
));
3011 #if defined (XCOFF_DEBUGGING_INFO)
3012 if (write_symbols
== XCOFF_DEBUG
)
3013 xcoffout_source_line (file
, filename
, insn
);
3016 #ifdef DWARF_DEBUGGING_INFO
3017 if (write_symbols
== DWARF_DEBUG
)
3018 dwarfout_line (filename
, NOTE_LINE_NUMBER (insn
));
3021 #ifdef DWARF2_DEBUGGING_INFO
3022 if (write_symbols
== DWARF2_DEBUG
)
3023 dwarf2out_line (filename
, NOTE_LINE_NUMBER (insn
));
3028 /* For each operand in INSN, simplify (subreg (reg)) so that it refers
3029 directly to the desired hard register. */
3032 cleanup_subreg_operands (insn
)
3036 extract_insn_cached (insn
);
3037 for (i
= 0; i
< recog_data
.n_operands
; i
++)
3039 if (GET_CODE (recog_data
.operand
[i
]) == SUBREG
)
3040 recog_data
.operand
[i
] = alter_subreg (recog_data
.operand
[i
]);
3041 else if (GET_CODE (recog_data
.operand
[i
]) == PLUS
3042 || GET_CODE (recog_data
.operand
[i
]) == MULT
3043 || GET_CODE (recog_data
.operand
[i
]) == MEM
)
3044 recog_data
.operand
[i
] = walk_alter_subreg (recog_data
.operand
[i
]);
3047 for (i
= 0; i
< recog_data
.n_dups
; i
++)
3049 if (GET_CODE (*recog_data
.dup_loc
[i
]) == SUBREG
)
3050 *recog_data
.dup_loc
[i
] = alter_subreg (*recog_data
.dup_loc
[i
]);
3051 else if (GET_CODE (*recog_data
.dup_loc
[i
]) == PLUS
3052 || GET_CODE (*recog_data
.dup_loc
[i
]) == MULT
3053 || GET_CODE (*recog_data
.dup_loc
[i
]) == MEM
)
3054 *recog_data
.dup_loc
[i
] = walk_alter_subreg (*recog_data
.dup_loc
[i
]);
3058 /* If X is a SUBREG, replace it with a REG or a MEM,
3059 based on the thing it is a subreg of. */
3065 register rtx y
= SUBREG_REG (x
);
3067 if (GET_CODE (y
) == SUBREG
)
3068 y
= alter_subreg (y
);
3070 /* If reload is operating, we may be replacing inside this SUBREG.
3071 Check for that and make a new one if so. */
3072 if (reload_in_progress
&& find_replacement (&SUBREG_REG (x
)) != 0)
3075 if (GET_CODE (y
) == REG
)
3077 int regno
= subreg_hard_regno (x
, 1);
3081 ORIGINAL_REGNO (x
) = ORIGINAL_REGNO (y
);
3082 /* This field has a different meaning for REGs and SUBREGs. Make sure
3086 else if (GET_CODE (y
) == MEM
)
3088 register int offset
= SUBREG_BYTE (x
);
3090 /* Catch these instead of generating incorrect code. */
3091 if ((offset
% GET_MODE_SIZE (GET_MODE (x
))) != 0)
3095 MEM_COPY_ATTRIBUTES (x
, y
);
3096 XEXP (x
, 0) = plus_constant (XEXP (y
, 0), offset
);
3102 /* Do alter_subreg on all the SUBREGs contained in X. */
3105 walk_alter_subreg (x
)
3108 switch (GET_CODE (x
))
3112 XEXP (x
, 0) = walk_alter_subreg (XEXP (x
, 0));
3113 XEXP (x
, 1) = walk_alter_subreg (XEXP (x
, 1));
3117 XEXP (x
, 0) = walk_alter_subreg (XEXP (x
, 0));
3121 return alter_subreg (x
);
3132 /* Given BODY, the body of a jump instruction, alter the jump condition
3133 as required by the bits that are set in cc_status.flags.
3134 Not all of the bits there can be handled at this level in all cases.
3136 The value is normally 0.
3137 1 means that the condition has become always true.
3138 -1 means that the condition has become always false.
3139 2 means that COND has been altered. */
3147 if (cc_status
.flags
& CC_REVERSED
)
3150 PUT_CODE (cond
, swap_condition (GET_CODE (cond
)));
3153 if (cc_status
.flags
& CC_INVERTED
)
3156 PUT_CODE (cond
, reverse_condition (GET_CODE (cond
)));
3159 if (cc_status
.flags
& CC_NOT_POSITIVE
)
3160 switch (GET_CODE (cond
))
3165 /* Jump becomes unconditional. */
3171 /* Jump becomes no-op. */
3175 PUT_CODE (cond
, EQ
);
3180 PUT_CODE (cond
, NE
);
3188 if (cc_status
.flags
& CC_NOT_NEGATIVE
)
3189 switch (GET_CODE (cond
))
3193 /* Jump becomes unconditional. */
3198 /* Jump becomes no-op. */
3203 PUT_CODE (cond
, EQ
);
3209 PUT_CODE (cond
, NE
);
3217 if (cc_status
.flags
& CC_NO_OVERFLOW
)
3218 switch (GET_CODE (cond
))
3221 /* Jump becomes unconditional. */
3225 PUT_CODE (cond
, EQ
);
3230 PUT_CODE (cond
, NE
);
3235 /* Jump becomes no-op. */
3242 if (cc_status
.flags
& (CC_Z_IN_NOT_N
| CC_Z_IN_N
))
3243 switch (GET_CODE (cond
))
3249 PUT_CODE (cond
, cc_status
.flags
& CC_Z_IN_N
? GE
: LT
);
3254 PUT_CODE (cond
, cc_status
.flags
& CC_Z_IN_N
? LT
: GE
);
3259 if (cc_status
.flags
& CC_NOT_SIGNED
)
3260 /* The flags are valid if signed condition operators are converted
3262 switch (GET_CODE (cond
))
3265 PUT_CODE (cond
, LEU
);
3270 PUT_CODE (cond
, LTU
);
3275 PUT_CODE (cond
, GTU
);
3280 PUT_CODE (cond
, GEU
);
3292 /* Report inconsistency between the assembler template and the operands.
3293 In an `asm', it's the user's fault; otherwise, the compiler's fault. */
3296 output_operand_lossage (msgid
)
3299 if (this_is_asm_operands
)
3300 error_for_asm (this_is_asm_operands
, "invalid `asm': %s", _(msgid
));
3302 internal_error ("output_operand: %s", _(msgid
));
3305 /* Output of assembler code from a template, and its subroutines. */
3307 /* Output text from TEMPLATE to the assembler output file,
3308 obeying %-directions to substitute operands taken from
3309 the vector OPERANDS.
3311 %N (for N a digit) means print operand N in usual manner.
3312 %lN means require operand N to be a CODE_LABEL or LABEL_REF
3313 and print the label name with no punctuation.
3314 %cN means require operand N to be a constant
3315 and print the constant expression with no punctuation.
3316 %aN means expect operand N to be a memory address
3317 (not a memory reference!) and print a reference
3319 %nN means expect operand N to be a constant
3320 and print a constant expression for minus the value
3321 of the operand, with no other punctuation. */
3326 if (flag_print_asm_name
)
3328 /* Annotate the assembly with a comment describing the pattern and
3329 alternative used. */
3332 register int num
= INSN_CODE (debug_insn
);
3333 fprintf (asm_out_file
, "\t%s %d\t%s",
3334 ASM_COMMENT_START
, INSN_UID (debug_insn
),
3335 insn_data
[num
].name
);
3336 if (insn_data
[num
].n_alternatives
> 1)
3337 fprintf (asm_out_file
, "/%d", which_alternative
+ 1);
3338 #ifdef HAVE_ATTR_length
3339 fprintf (asm_out_file
, "\t[length = %d]",
3340 get_attr_length (debug_insn
));
3342 /* Clear this so only the first assembler insn
3343 of any rtl insn will get the special comment for -dp. */
3350 output_asm_insn (template, operands
)
3351 const char *template;
3354 register const char *p
;
3357 /* An insn may return a null string template
3358 in a case where no assembler code is needed. */
3363 putc ('\t', asm_out_file
);
3365 #ifdef ASM_OUTPUT_OPCODE
3366 ASM_OUTPUT_OPCODE (asm_out_file
, p
);
3374 putc (c
, asm_out_file
);
3375 #ifdef ASM_OUTPUT_OPCODE
3376 while ((c
= *p
) == '\t')
3378 putc (c
, asm_out_file
);
3381 ASM_OUTPUT_OPCODE (asm_out_file
, p
);
3385 #ifdef ASSEMBLER_DIALECT
3390 /* If we want the first dialect, do nothing. Otherwise, skip
3391 DIALECT_NUMBER of strings ending with '|'. */
3392 for (i
= 0; i
< dialect_number
; i
++)
3394 while (*p
&& *p
!= '}' && *p
++ != '|')
3405 /* Skip to close brace. */
3406 while (*p
&& *p
++ != '}')
3415 /* %% outputs a single %. */
3419 putc (c
, asm_out_file
);
3421 /* %= outputs a number which is unique to each insn in the entire
3422 compilation. This is useful for making local labels that are
3423 referred to more than once in a given insn. */
3427 fprintf (asm_out_file
, "%d", insn_counter
);
3429 /* % followed by a letter and some digits
3430 outputs an operand in a special way depending on the letter.
3431 Letters `acln' are implemented directly.
3432 Other letters are passed to `output_operand' so that
3433 the PRINT_OPERAND macro can define them. */
3434 else if (ISLOWER (*p
) || ISUPPER (*p
))
3439 if (! (*p
>= '0' && *p
<= '9'))
3440 output_operand_lossage ("operand number missing after %-letter");
3441 else if (this_is_asm_operands
&& (c
< 0 || (unsigned int) c
>= insn_noperands
))
3442 output_operand_lossage ("operand number out of range");
3443 else if (letter
== 'l')
3444 output_asm_label (operands
[c
]);
3445 else if (letter
== 'a')
3446 output_address (operands
[c
]);
3447 else if (letter
== 'c')
3449 if (CONSTANT_ADDRESS_P (operands
[c
]))
3450 output_addr_const (asm_out_file
, operands
[c
]);
3452 output_operand (operands
[c
], 'c');
3454 else if (letter
== 'n')
3456 if (GET_CODE (operands
[c
]) == CONST_INT
)
3457 fprintf (asm_out_file
, HOST_WIDE_INT_PRINT_DEC
,
3458 - INTVAL (operands
[c
]));
3461 putc ('-', asm_out_file
);
3462 output_addr_const (asm_out_file
, operands
[c
]);
3466 output_operand (operands
[c
], letter
);
3468 while ((c
= *p
) >= '0' && c
<= '9')
3471 /* % followed by a digit outputs an operand the default way. */
3472 else if (*p
>= '0' && *p
<= '9')
3475 if (this_is_asm_operands
3476 && (c
< 0 || (unsigned int) c
>= insn_noperands
))
3477 output_operand_lossage ("operand number out of range");
3479 output_operand (operands
[c
], 0);
3480 while ((c
= *p
) >= '0' && c
<= '9')
3483 /* % followed by punctuation: output something for that
3484 punctuation character alone, with no operand.
3485 The PRINT_OPERAND macro decides what is actually done. */
3486 #ifdef PRINT_OPERAND_PUNCT_VALID_P
3487 else if (PRINT_OPERAND_PUNCT_VALID_P ((unsigned char) *p
))
3488 output_operand (NULL_RTX
, *p
++);
3491 output_operand_lossage ("invalid %%-code");
3495 putc (c
, asm_out_file
);
3500 putc ('\n', asm_out_file
);
3503 /* Output a LABEL_REF, or a bare CODE_LABEL, as an assembler symbol. */
3506 output_asm_label (x
)
3511 if (GET_CODE (x
) == LABEL_REF
)
3513 if (GET_CODE (x
) == CODE_LABEL
3514 || (GET_CODE (x
) == NOTE
3515 && NOTE_LINE_NUMBER (x
) == NOTE_INSN_DELETED_LABEL
))
3516 ASM_GENERATE_INTERNAL_LABEL (buf
, "L", CODE_LABEL_NUMBER (x
));
3518 output_operand_lossage ("`%l' operand isn't a label");
3520 assemble_name (asm_out_file
, buf
);
3523 /* Print operand X using machine-dependent assembler syntax.
3524 The macro PRINT_OPERAND is defined just to control this function.
3525 CODE is a non-digit that preceded the operand-number in the % spec,
3526 such as 'z' if the spec was `%z3'. CODE is 0 if there was no char
3527 between the % and the digits.
3528 When CODE is a non-letter, X is 0.
3530 The meanings of the letters are machine-dependent and controlled
3531 by PRINT_OPERAND. */
3534 output_operand (x
, code
)
3536 int code ATTRIBUTE_UNUSED
;
3538 if (x
&& GET_CODE (x
) == SUBREG
)
3539 x
= alter_subreg (x
);
3541 /* If X is a pseudo-register, abort now rather than writing trash to the
3544 if (x
&& GET_CODE (x
) == REG
&& REGNO (x
) >= FIRST_PSEUDO_REGISTER
)
3547 PRINT_OPERAND (asm_out_file
, x
, code
);
3550 /* Print a memory reference operand for address X
3551 using machine-dependent assembler syntax.
3552 The macro PRINT_OPERAND_ADDRESS exists just to control this function. */
3558 walk_alter_subreg (x
);
3559 PRINT_OPERAND_ADDRESS (asm_out_file
, x
);
3562 /* Print an integer constant expression in assembler syntax.
3563 Addition and subtraction are the only arithmetic
3564 that may appear in these expressions. */
3567 output_addr_const (file
, x
)
3574 switch (GET_CODE (x
))
3584 #ifdef ASM_OUTPUT_SYMBOL_REF
3585 ASM_OUTPUT_SYMBOL_REF (file
, x
);
3587 assemble_name (file
, XSTR (x
, 0));
3595 ASM_GENERATE_INTERNAL_LABEL (buf
, "L", CODE_LABEL_NUMBER (x
));
3596 assemble_name (file
, buf
);
3600 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, INTVAL (x
));
3604 /* This used to output parentheses around the expression,
3605 but that does not work on the 386 (either ATT or BSD assembler). */
3606 output_addr_const (file
, XEXP (x
, 0));
3610 if (GET_MODE (x
) == VOIDmode
)
3612 /* We can use %d if the number is one word and positive. */
3613 if (CONST_DOUBLE_HIGH (x
))
3614 fprintf (file
, HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
3615 CONST_DOUBLE_HIGH (x
), CONST_DOUBLE_LOW (x
));
3616 else if (CONST_DOUBLE_LOW (x
) < 0)
3617 fprintf (file
, HOST_WIDE_INT_PRINT_HEX
, CONST_DOUBLE_LOW (x
));
3619 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, CONST_DOUBLE_LOW (x
));
3622 /* We can't handle floating point constants;
3623 PRINT_OPERAND must handle them. */
3624 output_operand_lossage ("floating constant misused");
3628 /* Some assemblers need integer constants to appear last (eg masm). */
3629 if (GET_CODE (XEXP (x
, 0)) == CONST_INT
)
3631 output_addr_const (file
, XEXP (x
, 1));
3632 if (INTVAL (XEXP (x
, 0)) >= 0)
3633 fprintf (file
, "+");
3634 output_addr_const (file
, XEXP (x
, 0));
3638 output_addr_const (file
, XEXP (x
, 0));
3639 if (GET_CODE (XEXP (x
, 1)) != CONST_INT
3640 || INTVAL (XEXP (x
, 1)) >= 0)
3641 fprintf (file
, "+");
3642 output_addr_const (file
, XEXP (x
, 1));
3647 /* Avoid outputting things like x-x or x+5-x,
3648 since some assemblers can't handle that. */
3649 x
= simplify_subtraction (x
);
3650 if (GET_CODE (x
) != MINUS
)
3653 output_addr_const (file
, XEXP (x
, 0));
3654 fprintf (file
, "-");
3655 if ((GET_CODE (XEXP (x
, 1)) == CONST_INT
3656 && INTVAL (XEXP (x
, 1)) < 0)
3657 || GET_CODE (XEXP (x
, 1)) != CONST_INT
)
3659 fprintf (file
, "%s", ASM_OPEN_PAREN
);
3660 output_addr_const (file
, XEXP (x
, 1));
3661 fprintf (file
, "%s", ASM_CLOSE_PAREN
);
3664 output_addr_const (file
, XEXP (x
, 1));
3669 output_addr_const (file
, XEXP (x
, 0));
3673 #ifdef OUTPUT_ADDR_CONST_EXTRA
3674 OUTPUT_ADDR_CONST_EXTRA (file
, x
, fail
);
3679 output_operand_lossage ("invalid expression as operand");
3683 /* A poor man's fprintf, with the added features of %I, %R, %L, and %U.
3684 %R prints the value of REGISTER_PREFIX.
3685 %L prints the value of LOCAL_LABEL_PREFIX.
3686 %U prints the value of USER_LABEL_PREFIX.
3687 %I prints the value of IMMEDIATE_PREFIX.
3688 %O runs ASM_OUTPUT_OPCODE to transform what follows in the string.
3689 Also supported are %d, %x, %s, %e, %f, %g and %%.
3691 We handle alternate assembler dialects here, just like output_asm_insn. */
3694 asm_fprintf
VPARAMS ((FILE *file
, const char *p
, ...))
3696 #ifndef ANSI_PROTOTYPES
3704 VA_START (argptr
, p
);
3706 #ifndef ANSI_PROTOTYPES
3707 file
= va_arg (argptr
, FILE *);
3708 p
= va_arg (argptr
, const char *);
3716 #ifdef ASSEMBLER_DIALECT
3721 /* If we want the first dialect, do nothing. Otherwise, skip
3722 DIALECT_NUMBER of strings ending with '|'. */
3723 for (i
= 0; i
< dialect_number
; i
++)
3725 while (*p
&& *p
++ != '|')
3735 /* Skip to close brace. */
3736 while (*p
&& *p
++ != '}')
3747 while ((c
>= '0' && c
<= '9') || c
== '.')
3755 fprintf (file
, "%%");
3758 case 'd': case 'i': case 'u':
3759 case 'x': case 'p': case 'X':
3763 fprintf (file
, buf
, va_arg (argptr
, int));
3767 /* This is a prefix to the 'd', 'i', 'u', 'x', 'p', and 'X' cases,
3768 but we do not check for those cases. It means that the value
3769 is a HOST_WIDE_INT, which may be either `int' or `long'. */
3771 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
3773 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
3783 fprintf (file
, buf
, va_arg (argptr
, HOST_WIDE_INT
));
3790 fprintf (file
, buf
, va_arg (argptr
, long));
3798 fprintf (file
, buf
, va_arg (argptr
, double));
3804 fprintf (file
, buf
, va_arg (argptr
, char *));
3808 #ifdef ASM_OUTPUT_OPCODE
3809 ASM_OUTPUT_OPCODE (asm_out_file
, p
);
3814 #ifdef REGISTER_PREFIX
3815 fprintf (file
, "%s", REGISTER_PREFIX
);
3820 #ifdef IMMEDIATE_PREFIX
3821 fprintf (file
, "%s", IMMEDIATE_PREFIX
);
3826 #ifdef LOCAL_LABEL_PREFIX
3827 fprintf (file
, "%s", LOCAL_LABEL_PREFIX
);
3832 fputs (user_label_prefix
, file
);
3835 #ifdef ASM_FPRINTF_EXTENSIONS
3836 /* Upper case letters are reserved for general use by asm_fprintf
3837 and so are not available to target specific code. In order to
3838 prevent the ASM_FPRINTF_EXTENSIONS macro from using them then,
3839 they are defined here. As they get turned into real extensions
3840 to asm_fprintf they should be removed from this list. */
3841 case 'A': case 'B': case 'C': case 'D': case 'E':
3842 case 'F': case 'G': case 'H': case 'J': case 'K':
3843 case 'M': case 'N': case 'P': case 'Q': case 'S':
3844 case 'T': case 'V': case 'W': case 'Y': case 'Z':
3847 ASM_FPRINTF_EXTENSIONS (file
, argptr
, p
)
3860 /* Split up a CONST_DOUBLE or integer constant rtx
3861 into two rtx's for single words,
3862 storing in *FIRST the word that comes first in memory in the target
3863 and in *SECOND the other. */
3866 split_double (value
, first
, second
)
3868 rtx
*first
, *second
;
3870 if (GET_CODE (value
) == CONST_INT
)
3872 if (HOST_BITS_PER_WIDE_INT
>= (2 * BITS_PER_WORD
))
3874 /* In this case the CONST_INT holds both target words.
3875 Extract the bits from it into two word-sized pieces.
3876 Sign extend each half to HOST_WIDE_INT. */
3877 unsigned HOST_WIDE_INT low
, high
;
3878 unsigned HOST_WIDE_INT mask
, sign_bit
, sign_extend
;
3880 /* Set sign_bit to the most significant bit of a word. */
3882 sign_bit
<<= BITS_PER_WORD
- 1;
3884 /* Set mask so that all bits of the word are set. We could
3885 have used 1 << BITS_PER_WORD instead of basing the
3886 calculation on sign_bit. However, on machines where
3887 HOST_BITS_PER_WIDE_INT == BITS_PER_WORD, it could cause a
3888 compiler warning, even though the code would never be
3890 mask
= sign_bit
<< 1;
3893 /* Set sign_extend as any remaining bits. */
3894 sign_extend
= ~mask
;
3896 /* Pick the lower word and sign-extend it. */
3897 low
= INTVAL (value
);
3902 /* Pick the higher word, shifted to the least significant
3903 bits, and sign-extend it. */
3904 high
= INTVAL (value
);
3905 high
>>= BITS_PER_WORD
- 1;
3908 if (high
& sign_bit
)
3909 high
|= sign_extend
;
3911 /* Store the words in the target machine order. */
3912 if (WORDS_BIG_ENDIAN
)
3914 *first
= GEN_INT (high
);
3915 *second
= GEN_INT (low
);
3919 *first
= GEN_INT (low
);
3920 *second
= GEN_INT (high
);
3925 /* The rule for using CONST_INT for a wider mode
3926 is that we regard the value as signed.
3927 So sign-extend it. */
3928 rtx high
= (INTVAL (value
) < 0 ? constm1_rtx
: const0_rtx
);
3929 if (WORDS_BIG_ENDIAN
)
3941 else if (GET_CODE (value
) != CONST_DOUBLE
)
3943 if (WORDS_BIG_ENDIAN
)
3945 *first
= const0_rtx
;
3951 *second
= const0_rtx
;
3954 else if (GET_MODE (value
) == VOIDmode
3955 /* This is the old way we did CONST_DOUBLE integers. */
3956 || GET_MODE_CLASS (GET_MODE (value
)) == MODE_INT
)
3958 /* In an integer, the words are defined as most and least significant.
3959 So order them by the target's convention. */
3960 if (WORDS_BIG_ENDIAN
)
3962 *first
= GEN_INT (CONST_DOUBLE_HIGH (value
));
3963 *second
= GEN_INT (CONST_DOUBLE_LOW (value
));
3967 *first
= GEN_INT (CONST_DOUBLE_LOW (value
));
3968 *second
= GEN_INT (CONST_DOUBLE_HIGH (value
));
3973 #ifdef REAL_ARITHMETIC
3976 REAL_VALUE_FROM_CONST_DOUBLE (r
, value
);
3978 /* Note, this converts the REAL_VALUE_TYPE to the target's
3979 format, splits up the floating point double and outputs
3980 exactly 32 bits of it into each of l[0] and l[1] --
3981 not necessarily BITS_PER_WORD bits. */
3982 REAL_VALUE_TO_TARGET_DOUBLE (r
, l
);
3984 /* If 32 bits is an entire word for the target, but not for the host,
3985 then sign-extend on the host so that the number will look the same
3986 way on the host that it would on the target. See for instance
3987 simplify_unary_operation. The #if is needed to avoid compiler
3990 #if HOST_BITS_PER_LONG > 32
3991 if (BITS_PER_WORD
< HOST_BITS_PER_LONG
&& BITS_PER_WORD
== 32)
3993 if (l
[0] & ((long) 1 << 31))
3994 l
[0] |= ((long) (-1) << 32);
3995 if (l
[1] & ((long) 1 << 31))
3996 l
[1] |= ((long) (-1) << 32);
4000 *first
= GEN_INT ((HOST_WIDE_INT
) l
[0]);
4001 *second
= GEN_INT ((HOST_WIDE_INT
) l
[1]);
4003 if ((HOST_FLOAT_FORMAT
!= TARGET_FLOAT_FORMAT
4004 || HOST_BITS_PER_WIDE_INT
!= BITS_PER_WORD
)
4005 && ! flag_pretend_float
)
4009 #ifdef HOST_WORDS_BIG_ENDIAN
4016 /* Host and target agree => no need to swap. */
4017 *first
= GEN_INT (CONST_DOUBLE_LOW (value
));
4018 *second
= GEN_INT (CONST_DOUBLE_HIGH (value
));
4022 *second
= GEN_INT (CONST_DOUBLE_LOW (value
));
4023 *first
= GEN_INT (CONST_DOUBLE_HIGH (value
));
4025 #endif /* no REAL_ARITHMETIC */
4029 /* Return nonzero if this function has no function calls. */
4037 if (profile_flag
|| profile_block_flag
|| profile_arc_flag
)
4040 for (insn
= get_insns (); insn
; insn
= NEXT_INSN (insn
))
4042 if (GET_CODE (insn
) == CALL_INSN
4043 && ! SIBLING_CALL_P (insn
))
4045 if (GET_CODE (insn
) == INSN
4046 && GET_CODE (PATTERN (insn
)) == SEQUENCE
4047 && GET_CODE (XVECEXP (PATTERN (insn
), 0, 0)) == CALL_INSN
4048 && ! SIBLING_CALL_P (XVECEXP (PATTERN (insn
), 0, 0)))
4051 for (link
= current_function_epilogue_delay_list
;
4053 link
= XEXP (link
, 1))
4055 insn
= XEXP (link
, 0);
4057 if (GET_CODE (insn
) == CALL_INSN
4058 && ! SIBLING_CALL_P (insn
))
4060 if (GET_CODE (insn
) == INSN
4061 && GET_CODE (PATTERN (insn
)) == SEQUENCE
4062 && GET_CODE (XVECEXP (PATTERN (insn
), 0, 0)) == CALL_INSN
4063 && ! SIBLING_CALL_P (XVECEXP (PATTERN (insn
), 0, 0)))
4070 /* Return 1 if branch is an forward branch.
4071 Uses insn_shuid array, so it works only in the final pass. May be used by
4072 output templates to customary add branch prediction hints.
4075 final_forward_branch_p (insn
)
4078 int insn_id
, label_id
;
4081 insn_id
= INSN_SHUID (insn
);
4082 label_id
= INSN_SHUID (JUMP_LABEL (insn
));
4083 /* We've hit some insns that does not have id information available. */
4084 if (!insn_id
|| !label_id
)
4086 return insn_id
< label_id
;
4089 /* On some machines, a function with no call insns
4090 can run faster if it doesn't create its own register window.
4091 When output, the leaf function should use only the "output"
4092 registers. Ordinarily, the function would be compiled to use
4093 the "input" registers to find its arguments; it is a candidate
4094 for leaf treatment if it uses only the "input" registers.
4095 Leaf function treatment means renumbering so the function
4096 uses the "output" registers instead. */
4098 #ifdef LEAF_REGISTERS
4100 /* Return 1 if this function uses only the registers that can be
4101 safely renumbered. */
4104 only_leaf_regs_used ()
4107 char *permitted_reg_in_leaf_functions
= LEAF_REGISTERS
;
4109 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
4110 if ((regs_ever_live
[i
] || global_regs
[i
])
4111 && ! permitted_reg_in_leaf_functions
[i
])
4114 if (current_function_uses_pic_offset_table
4115 && pic_offset_table_rtx
!= 0
4116 && GET_CODE (pic_offset_table_rtx
) == REG
4117 && ! permitted_reg_in_leaf_functions
[REGNO (pic_offset_table_rtx
)])
4123 /* Scan all instructions and renumber all registers into those
4124 available in leaf functions. */
4127 leaf_renumber_regs (first
)
4132 /* Renumber only the actual patterns.
4133 The reg-notes can contain frame pointer refs,
4134 and renumbering them could crash, and should not be needed. */
4135 for (insn
= first
; insn
; insn
= NEXT_INSN (insn
))
4137 leaf_renumber_regs_insn (PATTERN (insn
));
4138 for (insn
= current_function_epilogue_delay_list
;
4140 insn
= XEXP (insn
, 1))
4141 if (INSN_P (XEXP (insn
, 0)))
4142 leaf_renumber_regs_insn (PATTERN (XEXP (insn
, 0)));
4145 /* Scan IN_RTX and its subexpressions, and renumber all regs into those
4146 available in leaf functions. */
4149 leaf_renumber_regs_insn (in_rtx
)
4150 register rtx in_rtx
;
4153 register const char *format_ptr
;
4158 /* Renumber all input-registers into output-registers.
4159 renumbered_regs would be 1 for an output-register;
4162 if (GET_CODE (in_rtx
) == REG
)
4166 /* Don't renumber the same reg twice. */
4170 newreg
= REGNO (in_rtx
);
4171 /* Don't try to renumber pseudo regs. It is possible for a pseudo reg
4172 to reach here as part of a REG_NOTE. */
4173 if (newreg
>= FIRST_PSEUDO_REGISTER
)
4178 newreg
= LEAF_REG_REMAP (newreg
);
4181 regs_ever_live
[REGNO (in_rtx
)] = 0;
4182 regs_ever_live
[newreg
] = 1;
4183 REGNO (in_rtx
) = newreg
;
4187 if (INSN_P (in_rtx
))
4189 /* Inside a SEQUENCE, we find insns.
4190 Renumber just the patterns of these insns,
4191 just as we do for the top-level insns. */
4192 leaf_renumber_regs_insn (PATTERN (in_rtx
));
4196 format_ptr
= GET_RTX_FORMAT (GET_CODE (in_rtx
));
4198 for (i
= 0; i
< GET_RTX_LENGTH (GET_CODE (in_rtx
)); i
++)
4199 switch (*format_ptr
++)
4202 leaf_renumber_regs_insn (XEXP (in_rtx
, i
));
4206 if (NULL
!= XVEC (in_rtx
, i
))
4208 for (j
= 0; j
< XVECLEN (in_rtx
, i
); j
++)
4209 leaf_renumber_regs_insn (XVECEXP (in_rtx
, i
, j
));