Line data Source code
1 : /* Convert RTL to assembler code and output it, for GNU compiler.
2 : Copyright (C) 1987-2026 Free Software Foundation, Inc.
3 :
4 : This file is part of GCC.
5 :
6 : GCC is free software; you can redistribute it and/or modify it under
7 : the terms of the GNU General Public License as published by the Free
8 : Software Foundation; either version 3, or (at your option) any later
9 : version.
10 :
11 : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 : WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 : for more details.
15 :
16 : You should have received a copy of the GNU General Public License
17 : along with GCC; see the file COPYING3. If not see
18 : <http://www.gnu.org/licenses/>. */
19 :
20 : /* This is the final pass of the compiler.
21 : It looks at the rtl code for a function and outputs assembler code.
22 :
23 : Call `final_start_function' to output the assembler code for function entry,
24 : `final' to output assembler code for some RTL code,
25 : `final_end_function' to output assembler code for function exit.
26 : If a function is compiled in several pieces, each piece is
27 : output separately with `final'.
28 :
29 : Some optimizations are also done at this level.
30 : Move instructions that were made unnecessary by good register allocation
31 : are detected and omitted from the output. (Though most of these
32 : are removed by the last jump pass.)
33 :
34 : Instructions to set the condition codes are omitted when it can be
35 : seen that the condition codes already had the desired values.
36 :
37 : In some cases it is sufficient if the inherited condition codes
38 : have related values, but this may require the following insn
39 : (the one that tests the condition codes) to be modified.
40 :
41 : The code for the function prologue and epilogue are generated
42 : directly in assembler by the target functions function_prologue and
43 : function_epilogue. Those instructions never exist as rtl. */
44 :
45 : #include "config.h"
46 : #define INCLUDE_ALGORITHM /* reverse */
47 : #include "system.h"
48 : #include "coretypes.h"
49 : #include "backend.h"
50 : #include "target.h"
51 : #include "rtl.h"
52 : #include "tree.h"
53 : #include "cfghooks.h"
54 : #include "df.h"
55 : #include "memmodel.h"
56 : #include "tm_p.h"
57 : #include "insn-config.h"
58 : #include "regs.h"
59 : #include "emit-rtl.h"
60 : #include "recog.h"
61 : #include "cgraph.h"
62 : #include "tree-pretty-print.h" /* for dump_function_header */
63 : #include "varasm.h"
64 : #include "insn-attr.h"
65 : #include "conditions.h"
66 : #include "flags.h"
67 : #include "output.h"
68 : #include "except.h"
69 : #include "rtl-error.h"
70 : #include "toplev.h" /* exact_log2, floor_log2 */
71 : #include "reload.h"
72 : #include "intl.h"
73 : #include "cfgrtl.h"
74 : #include "debug.h"
75 : #include "tree-pass.h"
76 : #include "tree-ssa.h"
77 : #include "cfgloop.h"
78 : #include "stringpool.h"
79 : #include "attribs.h"
80 : #include "asan.h"
81 : #include "rtl-iter.h"
82 : #include "print-rtl.h"
83 : #include "function-abi.h"
84 : #include "common/common-target.h"
85 : #include "diagnostic.h"
86 : #include "diagnostics/file-cache.h"
87 : #include "selftest.h"
88 :
89 : #include "dwarf2out.h"
90 :
91 : /* Most ports don't need to define CC_STATUS_INIT.
92 : So define a null default for it to save conditionalization later. */
93 : #ifndef CC_STATUS_INIT
94 : #define CC_STATUS_INIT
95 : #endif
96 :
97 : /* Is the given character a logical line separator for the assembler? */
98 : #ifndef IS_ASM_LOGICAL_LINE_SEPARATOR
99 : #define IS_ASM_LOGICAL_LINE_SEPARATOR(C, STR) ((C) == ';')
100 : #endif
101 :
102 : #ifndef JUMP_TABLES_IN_TEXT_SECTION
103 : #define JUMP_TABLES_IN_TEXT_SECTION 0
104 : #endif
105 :
106 : /* Bitflags used by final_scan_insn. */
107 : #define SEEN_NOTE 1
108 : #define SEEN_EMITTED 2
109 : #define SEEN_NEXT_VIEW 4
110 :
111 : /* Last insn processed by final_scan_insn. */
112 : static rtx_insn *debug_insn;
113 : rtx_insn *current_output_insn;
114 :
115 : /* Line number of last NOTE. */
116 : static int last_linenum;
117 :
118 : /* Column number of last NOTE. */
119 : static int last_columnnum;
120 :
121 : /* Discriminator written to assembly. */
122 : static int last_discriminator;
123 :
124 : /* Compute discriminator to be written to assembly for current instruction.
125 : Note: actual usage depends on loc_discriminator_kind setting. */
126 : static inline int compute_discriminator (location_t loc);
127 :
128 : /* Highest line number in current block. */
129 : static int high_block_linenum;
130 :
131 : /* Likewise for function. */
132 : static int high_function_linenum;
133 :
134 : /* Filename of last NOTE. */
135 : static const char *last_filename;
136 :
137 : /* Whether to force emission of a line note before the next insn. */
138 : static bool force_source_line = false;
139 :
140 : extern const int length_unit_log; /* Defined in generated attribute code. */
141 :
142 : /* Nonzero while outputting an `asm' with operands.
143 : This means that inconsistencies are the user's fault, so don't die.
144 : The precise value is the insn being output, to pass to error_for_asm. */
145 : const rtx_insn *this_is_asm_operands;
146 :
147 : /* Number of operands of this insn, for an `asm' with operands. */
148 : unsigned int insn_noperands;
149 :
150 : /* Compare optimization flag. */
151 :
152 : static rtx last_ignored_compare = 0;
153 :
154 : /* Assign a unique number to each insn that is output.
155 : This can be used to generate unique local labels. */
156 :
157 : static int insn_counter = 0;
158 :
159 : /* Number of unmatched NOTE_INSN_BLOCK_BEG notes we have seen. */
160 :
161 : static int block_depth;
162 :
163 : /* True if have enabled APP processing of our assembler output. */
164 :
165 : static bool app_on;
166 :
167 : /* If we are outputting an insn sequence, this contains the sequence rtx.
168 : Zero otherwise. */
169 :
170 : rtx_sequence *final_sequence;
171 :
172 : #ifdef ASSEMBLER_DIALECT
173 :
174 : /* Number of the assembler dialect to use, starting at 0. */
175 : static int dialect_number;
176 : #endif
177 :
178 : /* Nonnull if the insn currently being emitted was a COND_EXEC pattern. */
179 : rtx current_insn_predicate;
180 :
181 : /* True if printing into -fdump-final-insns= dump. */
182 : bool final_insns_dump_p;
183 :
184 : /* True if profile_function should be called, but hasn't been called yet. */
185 : static bool need_profile_function;
186 :
187 : static int asm_insn_count (rtx);
188 : static void profile_function (FILE *);
189 : static void profile_after_prologue (FILE *);
190 : static bool notice_source_line (rtx_insn *, bool *);
191 : static rtx walk_alter_subreg (rtx *, bool *);
192 : static void output_asm_name (void);
193 : static void output_alternate_entry_point (FILE *, rtx_insn *);
194 : static tree get_mem_expr_from_op (rtx, int *);
195 : static void output_asm_operand_names (rtx *, int *, int);
196 : #ifdef LEAF_REGISTERS
197 : static void leaf_renumber_regs (rtx_insn *);
198 : #endif
199 : static int align_fuzz (rtx_insn *, rtx_insn *, int, unsigned);
200 : static void collect_fn_hard_reg_usage (void);
201 :
202 : /* Initialize data in final at the beginning of a compilation. */
203 :
204 : void
205 295422 : init_final (const char *filename ATTRIBUTE_UNUSED)
206 : {
207 295422 : app_on = 0;
208 295422 : final_sequence = 0;
209 :
210 : #ifdef ASSEMBLER_DIALECT
211 295422 : dialect_number = ASSEMBLER_DIALECT;
212 : #endif
213 295422 : }
214 :
215 : /* Default target function prologue and epilogue assembler output.
216 :
217 : If not overridden for epilogue code, then the function body itself
218 : contains return instructions wherever needed. */
219 : void
220 1536723 : default_function_pro_epilogue (FILE *)
221 : {
222 1536723 : }
223 :
224 : void
225 65691 : default_function_switched_text_sections (FILE *file ATTRIBUTE_UNUSED,
226 : tree decl ATTRIBUTE_UNUSED,
227 : bool new_is_cold ATTRIBUTE_UNUSED)
228 : {
229 65691 : }
230 :
231 : /* Default target hook that outputs nothing to a stream. */
232 : void
233 3166417 : no_asm_to_stream (FILE *file ATTRIBUTE_UNUSED)
234 : {
235 3166417 : }
236 :
237 : /* Enable APP processing of subsequent output.
238 : Used before the output from an `asm' statement. */
239 :
240 : void
241 34115 : app_enable (void)
242 : {
243 34115 : if (! app_on)
244 : {
245 30822 : fputs (ASM_APP_ON, asm_out_file);
246 30822 : app_on = 1;
247 : }
248 34115 : }
249 :
250 : /* Disable APP processing of subsequent output.
251 : Called from varasm.cc before most kinds of output. */
252 :
253 : void
254 158731506 : app_disable (void)
255 : {
256 158731506 : if (app_on)
257 : {
258 29720 : fputs (ASM_APP_OFF, asm_out_file);
259 29720 : app_on = 0;
260 : }
261 158731506 : }
262 :
263 : /* Return the number of slots filled in the current
264 : delayed branch sequence (we don't count the insn needing the
265 : delay slot). Zero if not in a delayed branch sequence. */
266 :
267 : int
268 0 : dbr_sequence_length (void)
269 : {
270 0 : if (final_sequence != 0)
271 0 : return final_sequence->len () - 1;
272 : else
273 : return 0;
274 : }
275 :
276 : /* The next two pages contain routines used to compute the length of an insn
277 : and to shorten branches. */
278 :
279 : /* Arrays for insn lengths, and addresses. The latter is referenced by
280 : `insn_current_length'. */
281 :
282 : static int *insn_lengths;
283 :
284 : vec<int> insn_addresses_;
285 :
286 : /* Max uid for which the above arrays are valid. */
287 : static int insn_lengths_max_uid;
288 :
289 : /* Address of insn being processed. Used by `insn_current_length'. */
290 : int insn_current_address;
291 :
292 : /* Address of insn being processed in previous iteration. */
293 : int insn_last_address;
294 :
295 : /* known invariant alignment of insn being processed. */
296 : int insn_current_align;
297 :
298 : /* After shorten_branches, for any insn, uid_align[INSN_UID (insn)]
299 : gives the next following alignment insn that increases the known
300 : alignment, or NULL_RTX if there is no such insn.
301 : For any alignment obtained this way, we can again index uid_align with
302 : its uid to obtain the next following align that in turn increases the
303 : alignment, till we reach NULL_RTX; the sequence obtained this way
304 : for each insn we'll call the alignment chain of this insn in the following
305 : comments. */
306 :
307 : static rtx_insn **uid_align;
308 : static int *uid_shuid;
309 : static vec<align_flags> label_align;
310 :
311 : /* Indicate that branch shortening hasn't yet been done. */
312 :
313 : void
314 1537552 : init_insn_lengths (void)
315 : {
316 1537552 : if (uid_shuid)
317 : {
318 1533028 : free (uid_shuid);
319 1533028 : uid_shuid = 0;
320 : }
321 1537552 : if (insn_lengths)
322 : {
323 1533028 : free (insn_lengths);
324 1533028 : insn_lengths = 0;
325 1533028 : insn_lengths_max_uid = 0;
326 : }
327 1537552 : if (HAVE_ATTR_length)
328 1537552 : INSN_ADDRESSES_FREE ();
329 1537552 : if (uid_align)
330 : {
331 1533028 : free (uid_align);
332 1533028 : uid_align = 0;
333 : }
334 1537552 : }
335 :
336 : /* Obtain the current length of an insn. If branch shortening has been done,
337 : get its actual length. Otherwise, use FALLBACK_FN to calculate the
338 : length. */
339 : static int
340 413947701 : get_attr_length_1 (rtx_insn *insn, int (*fallback_fn) (rtx_insn *))
341 : {
342 413947701 : rtx body;
343 413947701 : int i;
344 413947701 : int length = 0;
345 :
346 413947701 : if (!HAVE_ATTR_length)
347 : return 0;
348 :
349 413947701 : if (insn_lengths_max_uid > INSN_UID (insn))
350 3382 : return insn_lengths[INSN_UID (insn)];
351 : else
352 413944319 : switch (GET_CODE (insn))
353 : {
354 : case NOTE:
355 : case BARRIER:
356 : case CODE_LABEL:
357 : case DEBUG_INSN:
358 : return 0;
359 :
360 9853899 : case CALL_INSN:
361 9853899 : case JUMP_INSN:
362 9853899 : body = PATTERN (insn);
363 9853899 : if (GET_CODE (body) == ASM_INPUT || asm_noperands (body) >= 0)
364 173 : length = asm_insn_count (body) * fallback_fn (insn);
365 : else
366 9853726 : length = fallback_fn (insn);
367 : break;
368 :
369 392653276 : case INSN:
370 392653276 : body = PATTERN (insn);
371 392653276 : if (GET_CODE (body) == USE || GET_CODE (body) == CLOBBER)
372 : return 0;
373 :
374 392309597 : else if (GET_CODE (body) == ASM_INPUT || asm_noperands (body) >= 0)
375 7914 : length = asm_insn_count (body) * fallback_fn (insn);
376 392301683 : else if (rtx_sequence *seq = dyn_cast <rtx_sequence *> (body))
377 0 : for (i = 0; i < seq->len (); i++)
378 0 : length += get_attr_length_1 (seq->insn (i), fallback_fn);
379 : else
380 392301683 : length = fallback_fn (insn);
381 : break;
382 :
383 : default:
384 : break;
385 : }
386 :
387 : #ifdef ADJUST_INSN_LENGTH
388 : ADJUST_INSN_LENGTH (insn, length);
389 : #endif
390 : return length;
391 : }
392 :
393 : /* Obtain the current length of an insn. If branch shortening has been done,
394 : get its actual length. Otherwise, get its maximum length. */
395 : int
396 394814263 : get_attr_length (rtx_insn *insn)
397 : {
398 394814263 : return get_attr_length_1 (insn, insn_default_length);
399 : }
400 :
401 : /* Obtain the current length of an insn. If branch shortening has been done,
402 : get its actual length. Otherwise, get its minimum length. */
403 : int
404 19133438 : get_attr_min_length (rtx_insn *insn)
405 : {
406 19133438 : return get_attr_length_1 (insn, insn_min_length);
407 : }
408 :
409 : /* Code to handle alignment inside shorten_branches. */
410 :
411 : /* Here is an explanation how the algorithm in align_fuzz can give
412 : proper results:
413 :
414 : Call a sequence of instructions beginning with alignment point X
415 : and continuing until the next alignment point `block X'. When `X'
416 : is used in an expression, it means the alignment value of the
417 : alignment point.
418 :
419 : Call the distance between the start of the first insn of block X, and
420 : the end of the last insn of block X `IX', for the `inner size of X'.
421 : This is clearly the sum of the instruction lengths.
422 :
423 : Likewise with the next alignment-delimited block following X, which we
424 : shall call block Y.
425 :
426 : Call the distance between the start of the first insn of block X, and
427 : the start of the first insn of block Y `OX', for the `outer size of X'.
428 :
429 : The estimated padding is then OX - IX.
430 :
431 : OX can be safely estimated as
432 :
433 : if (X >= Y)
434 : OX = round_up(IX, Y)
435 : else
436 : OX = round_up(IX, X) + Y - X
437 :
438 : Clearly est(IX) >= real(IX), because that only depends on the
439 : instruction lengths, and those being overestimated is a given.
440 :
441 : Clearly round_up(foo, Z) >= round_up(bar, Z) if foo >= bar, so
442 : we needn't worry about that when thinking about OX.
443 :
444 : When X >= Y, the alignment provided by Y adds no uncertainty factor
445 : for branch ranges starting before X, so we can just round what we have.
446 : But when X < Y, we don't know anything about the, so to speak,
447 : `middle bits', so we have to assume the worst when aligning up from an
448 : address mod X to one mod Y, which is Y - X. */
449 :
450 : #ifndef LABEL_ALIGN
451 : #define LABEL_ALIGN(LABEL) align_labels
452 : #endif
453 :
454 : #ifndef LOOP_ALIGN
455 : #define LOOP_ALIGN(LABEL) align_loops
456 : #endif
457 :
458 : #ifndef LABEL_ALIGN_AFTER_BARRIER
459 : #define LABEL_ALIGN_AFTER_BARRIER(LABEL) 0
460 : #endif
461 :
462 : #ifndef JUMP_ALIGN
463 : #define JUMP_ALIGN(LABEL) align_jumps
464 : #endif
465 :
466 : #ifndef ADDR_VEC_ALIGN
467 : static int
468 7457 : final_addr_vec_align (rtx_jump_table_data *addr_vec)
469 : {
470 7457 : int align = GET_MODE_SIZE (addr_vec->get_data_mode ());
471 :
472 14819 : if (align > BIGGEST_ALIGNMENT / BITS_PER_UNIT)
473 0 : align = BIGGEST_ALIGNMENT / BITS_PER_UNIT;
474 7457 : return exact_log2 (align);
475 :
476 : }
477 :
478 : #define ADDR_VEC_ALIGN(ADDR_VEC) final_addr_vec_align (ADDR_VEC)
479 : #endif
480 :
481 : #ifndef INSN_LENGTH_ALIGNMENT
482 : #define INSN_LENGTH_ALIGNMENT(INSN) length_unit_log
483 : #endif
484 :
485 : #define INSN_SHUID(INSN) (uid_shuid[INSN_UID (INSN)])
486 :
487 : static int min_labelno, max_labelno;
488 :
489 : #define LABEL_TO_ALIGNMENT(LABEL) \
490 : (label_align[CODE_LABEL_NUMBER (LABEL) - min_labelno])
491 :
492 : /* For the benefit of port specific code do this also as a function. */
493 :
494 : align_flags
495 1074 : label_to_alignment (rtx_insn *label)
496 : {
497 1074 : if (CODE_LABEL_NUMBER (label) <= max_labelno)
498 1074 : return LABEL_TO_ALIGNMENT (label);
499 0 : return align_flags ();
500 : }
501 :
502 : /* The differences in addresses
503 : between a branch and its target might grow or shrink depending on
504 : the alignment the start insn of the range (the branch for a forward
505 : branch or the label for a backward branch) starts out on; if these
506 : differences are used naively, they can even oscillate infinitely.
507 : We therefore want to compute a 'worst case' address difference that
508 : is independent of the alignment the start insn of the range end
509 : up on, and that is at least as large as the actual difference.
510 : The function align_fuzz calculates the amount we have to add to the
511 : naively computed difference, by traversing the part of the alignment
512 : chain of the start insn of the range that is in front of the end insn
513 : of the range, and considering for each alignment the maximum amount
514 : that it might contribute to a size increase.
515 :
516 : For casesi tables, we also want to know worst case minimum amounts of
517 : address difference, in case a machine description wants to introduce
518 : some common offset that is added to all offsets in a table.
519 : For this purpose, align_fuzz with a growth argument of 0 computes the
520 : appropriate adjustment. */
521 :
522 : /* Compute the maximum delta by which the difference of the addresses of
523 : START and END might grow / shrink due to a different address for start
524 : which changes the size of alignment insns between START and END.
525 : KNOWN_ALIGN_LOG is the alignment known for START.
526 : GROWTH should be ~0 if the objective is to compute potential code size
527 : increase, and 0 if the objective is to compute potential shrink.
528 : The return value is undefined for any other value of GROWTH. */
529 :
530 : static int
531 28841334 : align_fuzz (rtx_insn *start, rtx_insn *end, int known_align_log,
532 : unsigned int growth)
533 : {
534 28841334 : int uid = INSN_UID (start);
535 28841334 : rtx_insn *align_label;
536 28841334 : int known_align = 1 << known_align_log;
537 28841334 : int end_shuid = INSN_SHUID (end);
538 28841334 : int fuzz = 0;
539 :
540 42299145 : for (align_label = uid_align[uid]; align_label; align_label = uid_align[uid])
541 : {
542 16321284 : int align_addr, new_align;
543 :
544 16321284 : uid = INSN_UID (align_label);
545 16321284 : align_addr = INSN_ADDRESSES (uid) - insn_lengths[uid];
546 16321284 : if (uid_shuid[uid] > end_shuid)
547 : break;
548 13457811 : align_flags alignment = LABEL_TO_ALIGNMENT (align_label);
549 13457811 : new_align = 1 << alignment.levels[0].log;
550 13457811 : if (new_align < known_align)
551 0 : continue;
552 13457811 : fuzz += (-align_addr ^ growth) & (new_align - known_align);
553 13457811 : known_align = new_align;
554 : }
555 28841334 : return fuzz;
556 : }
557 :
558 : /* Compute a worst-case reference address of a branch so that it
559 : can be safely used in the presence of aligned labels. Since the
560 : size of the branch itself is unknown, the size of the branch is
561 : not included in the range. I.e. for a forward branch, the reference
562 : address is the end address of the branch as known from the previous
563 : branch shortening pass, minus a value to account for possible size
564 : increase due to alignment. For a backward branch, it is the start
565 : address of the branch as known from the current pass, plus a value
566 : to account for possible size increase due to alignment.
567 : NB.: Therefore, the maximum offset allowed for backward branches needs
568 : to exclude the branch size. */
569 :
570 : int
571 28841334 : insn_current_reference_address (rtx_insn *branch)
572 : {
573 28841334 : int seq_uid;
574 :
575 28841334 : if (! INSN_ADDRESSES_SET_P ())
576 : return 0;
577 :
578 28841334 : rtx_insn *seq = NEXT_INSN (PREV_INSN (branch));
579 28841334 : seq_uid = INSN_UID (seq);
580 28841334 : if (!jump_to_label_p (branch))
581 : /* This can happen for example on the PA; the objective is to know the
582 : offset to address something in front of the start of the function.
583 : Thus, we can treat it like a backward branch.
584 : We assume here that FUNCTION_BOUNDARY / BITS_PER_UNIT is larger than
585 : any alignment we'd encounter, so we skip the call to align_fuzz. */
586 0 : return insn_current_address;
587 28841334 : rtx_insn *dest = as_a<rtx_insn *> (JUMP_LABEL (branch));
588 :
589 : /* BRANCH has no proper alignment chain set, so use SEQ.
590 : BRANCH also has no INSN_SHUID. */
591 28841334 : if (INSN_SHUID (seq) < INSN_SHUID (dest))
592 : {
593 : /* Forward branch. */
594 20821116 : return (insn_last_address + insn_lengths[seq_uid]
595 20821116 : - align_fuzz (seq, dest, length_unit_log, ~0));
596 : }
597 : else
598 : {
599 : /* Backward branch. */
600 8020218 : return (insn_current_address
601 8020218 : + align_fuzz (dest, seq, length_unit_log, ~0));
602 : }
603 : }
604 :
605 : /* Compute branch alignments based on CFG profile. */
606 :
607 : void
608 1531124 : compute_alignments (void)
609 : {
610 1531124 : basic_block bb;
611 1531124 : align_flags max_alignment;
612 :
613 1531124 : label_align.truncate (0);
614 :
615 1531124 : max_labelno = max_label_num ();
616 1531124 : min_labelno = get_first_label_num ();
617 1531124 : label_align.safe_grow_cleared (max_labelno - min_labelno + 1, true);
618 :
619 : /* If not optimizing or optimizing for size, don't assign any alignments. */
620 1531124 : if (! optimize || optimize_function_for_size_p (cfun))
621 528078 : return;
622 :
623 1003046 : if (dump_file)
624 : {
625 33 : dump_reg_info (dump_file);
626 33 : dump_flow_info (dump_file, TDF_DETAILS);
627 33 : flow_loops_dump (dump_file, NULL, 1);
628 : }
629 1003046 : loop_optimizer_init (AVOID_CFG_MODIFICATIONS);
630 1003046 : profile_count count_threshold = cfun->cfg->count_max / param_align_threshold;
631 :
632 1003046 : if (dump_file)
633 : {
634 33 : fprintf (dump_file, "count_max: ");
635 33 : cfun->cfg->count_max.dump (dump_file);
636 33 : fprintf (dump_file, "\n");
637 : }
638 11820734 : FOR_EACH_BB_FN (bb, cfun)
639 : {
640 10817688 : rtx_insn *label = BB_HEAD (bb);
641 10817688 : bool has_fallthru = 0;
642 10817688 : edge e;
643 10817688 : edge_iterator ei;
644 :
645 17784190 : if (!LABEL_P (label)
646 10817688 : || optimize_bb_for_size_p (bb))
647 : {
648 6966502 : if (dump_file)
649 130 : fprintf (dump_file,
650 : "BB %4i loop %2i loop_depth %2i skipped.\n",
651 : bb->index,
652 130 : bb->loop_father->num,
653 : bb_loop_depth (bb));
654 6968084 : continue;
655 : }
656 3851186 : max_alignment = LABEL_ALIGN (label);
657 3851186 : profile_count fallthru_count = profile_count::zero ();
658 3851186 : profile_count branch_count = profile_count::zero ();
659 :
660 11248207 : FOR_EACH_EDGE (e, ei, bb->preds)
661 : {
662 7397021 : if (e->flags & EDGE_FALLTHRU)
663 2350757 : has_fallthru = 1, fallthru_count += e->count ();
664 : else
665 5046264 : branch_count += e->count ();
666 : }
667 3851186 : if (dump_file)
668 : {
669 119 : fprintf (dump_file, "BB %4i loop %2i loop_depth"
670 : " %2i fall ",
671 119 : bb->index, bb->loop_father->num,
672 : bb_loop_depth (bb));
673 119 : fallthru_count.dump (dump_file);
674 119 : fprintf (dump_file, " branch ");
675 119 : branch_count.dump (dump_file);
676 119 : if (!bb->loop_father->inner && bb->loop_father->num)
677 20 : fprintf (dump_file, " inner_loop");
678 119 : if (bb->loop_father->header == bb)
679 18 : fprintf (dump_file, " loop_header");
680 119 : fprintf (dump_file, "\n");
681 : }
682 3851186 : if (!fallthru_count.initialized_p () || !branch_count.initialized_p ())
683 1582 : continue;
684 :
685 : /* There are two purposes to align block with no fallthru incoming edge:
686 : 1) to avoid fetch stalls when branch destination is near cache boundary
687 : 2) to improve cache efficiency in case the previous block is not executed
688 : (so it does not need to be in the cache).
689 :
690 : We to catch first case, we align frequently executed blocks.
691 : To catch the second, we align blocks that are executed more frequently
692 : than the predecessor and the predecessor is likely to not be executed
693 : when function is called. */
694 :
695 3849604 : if (!has_fallthru
696 3849604 : && (branch_count > count_threshold
697 430872 : || (bb->count > bb->prev_bb->count * 10
698 27204 : && (bb->prev_bb->count
699 3876808 : <= ENTRY_BLOCK_PTR_FOR_FN (cfun)->count / 2))))
700 : {
701 1095845 : align_flags alignment = JUMP_ALIGN (label);
702 1095845 : if (dump_file)
703 38 : fprintf (dump_file, " jump alignment added.\n");
704 1095845 : max_alignment = align_flags::max (max_alignment, alignment);
705 : }
706 : /* In case block is frequent and reached mostly by non-fallthru edge,
707 : align it. It is most likely a first block of loop. */
708 3849604 : if (has_fallthru
709 2349608 : && !(single_succ_p (bb)
710 809082 : && single_succ (bb) == EXIT_BLOCK_PTR_FOR_FN (cfun))
711 2000486 : && optimize_bb_for_speed_p (bb)
712 2000486 : && branch_count + fallthru_count > count_threshold
713 6199214 : && (branch_count > fallthru_count * param_align_loop_iterations))
714 : {
715 307434 : align_flags alignment = LOOP_ALIGN (label);
716 307434 : if (dump_file)
717 11 : fprintf (dump_file, " internal loop alignment added.\n");
718 307434 : max_alignment = align_flags::max (max_alignment, alignment);
719 : }
720 3849604 : LABEL_TO_ALIGNMENT (label) = max_alignment;
721 : }
722 :
723 1003046 : loop_optimizer_finalize ();
724 1003046 : free_dominance_info (CDI_DOMINATORS);
725 : }
726 :
727 : /* Grow the LABEL_ALIGN array after new labels are created. */
728 :
729 : static void
730 3 : grow_label_align (void)
731 : {
732 3 : int old = max_labelno;
733 3 : int n_labels;
734 3 : int n_old_labels;
735 :
736 3 : max_labelno = max_label_num ();
737 :
738 3 : n_labels = max_labelno - min_labelno + 1;
739 3 : n_old_labels = old - min_labelno + 1;
740 :
741 3 : label_align.safe_grow_cleared (n_labels, true);
742 :
743 : /* Range of labels grows monotonically in the function. Failing here
744 : means that the initialization of array got lost. */
745 3 : gcc_assert (n_old_labels <= n_labels);
746 3 : }
747 :
748 : /* Update the already computed alignment information. LABEL_PAIRS is a vector
749 : made up of pairs of labels for which the alignment information of the first
750 : element will be copied from that of the second element. */
751 :
752 : void
753 0 : update_alignments (vec<rtx> &label_pairs)
754 : {
755 0 : unsigned int i = 0;
756 0 : rtx iter, label = NULL_RTX;
757 :
758 0 : if (max_labelno != max_label_num ())
759 0 : grow_label_align ();
760 :
761 0 : FOR_EACH_VEC_ELT (label_pairs, i, iter)
762 0 : if (i & 1)
763 0 : LABEL_TO_ALIGNMENT (label) = LABEL_TO_ALIGNMENT (iter);
764 : else
765 : label = iter;
766 0 : }
767 :
768 : namespace {
769 :
770 : const pass_data pass_data_compute_alignments =
771 : {
772 : RTL_PASS, /* type */
773 : "alignments", /* name */
774 : OPTGROUP_NONE, /* optinfo_flags */
775 : TV_NONE, /* tv_id */
776 : 0, /* properties_required */
777 : 0, /* properties_provided */
778 : 0, /* properties_destroyed */
779 : 0, /* todo_flags_start */
780 : 0, /* todo_flags_finish */
781 : };
782 :
783 : class pass_compute_alignments : public rtl_opt_pass
784 : {
785 : public:
786 302985 : pass_compute_alignments (gcc::context *ctxt)
787 605970 : : rtl_opt_pass (pass_data_compute_alignments, ctxt)
788 : {}
789 :
790 : /* opt_pass methods: */
791 1531124 : unsigned int execute (function *) final override
792 : {
793 1531124 : compute_alignments ();
794 1531124 : return 0;
795 : }
796 :
797 : }; // class pass_compute_alignments
798 :
799 : } // anon namespace
800 :
801 : rtl_opt_pass *
802 302985 : make_pass_compute_alignments (gcc::context *ctxt)
803 : {
804 302985 : return new pass_compute_alignments (ctxt);
805 : }
806 :
807 :
808 : /* Make a pass over all insns and compute their actual lengths by shortening
809 : any branches of variable length if possible. */
810 :
811 : /* shorten_branches might be called multiple times: for example, the SH
812 : port splits out-of-range conditional branches in MACHINE_DEPENDENT_REORG.
813 : In order to do this, it needs proper length information, which it obtains
814 : by calling shorten_branches. This cannot be collapsed with
815 : shorten_branches itself into a single pass unless we also want to integrate
816 : reorg.cc, since the branch splitting exposes new instructions with delay
817 : slots. */
818 :
819 : void
820 1533028 : shorten_branches (rtx_insn *first)
821 : {
822 1533028 : rtx_insn *insn;
823 1533028 : int max_uid;
824 1533028 : int i;
825 1533028 : rtx_insn *seq;
826 1533028 : bool something_changed = true;
827 1533028 : char *varying_length;
828 1533028 : rtx body;
829 1533028 : int uid;
830 1533028 : rtx_insn *align_tab[MAX_CODE_ALIGN + 1];
831 :
832 : /* Compute maximum UID and allocate label_align / uid_shuid. */
833 1533028 : max_uid = get_max_uid ();
834 :
835 : /* Free uid_shuid before reallocating it. */
836 1533028 : free (uid_shuid);
837 :
838 1533028 : uid_shuid = XNEWVEC (int, max_uid);
839 :
840 1533028 : if (max_labelno != max_label_num ())
841 3 : grow_label_align ();
842 :
843 : /* Initialize label_align and set up uid_shuid to be strictly
844 : monotonically rising with insn order. */
845 : /* We use alignment here to keep track of the maximum alignment we want to
846 : impose on the next CODE_LABEL (or the current one if we are processing
847 : the CODE_LABEL itself). */
848 :
849 1533028 : align_flags max_alignment;
850 :
851 216822267 : for (insn = get_insns (), i = 1; insn; insn = NEXT_INSN (insn))
852 : {
853 215289239 : INSN_SHUID (insn) = i++;
854 215289239 : if (INSN_P (insn))
855 96767181 : continue;
856 :
857 118522058 : if (rtx_code_label *label = dyn_cast <rtx_code_label *> (insn))
858 : {
859 : /* Merge in alignments computed by compute_alignments. */
860 7055289 : align_flags alignment = LABEL_TO_ALIGNMENT (label);
861 7055289 : max_alignment = align_flags::max (max_alignment, alignment);
862 :
863 7055289 : rtx_jump_table_data *table = jump_table_for_label (label);
864 7055289 : if (!table)
865 : {
866 7047832 : align_flags alignment = LABEL_ALIGN (label);
867 7047832 : max_alignment = align_flags::max (max_alignment, alignment);
868 : }
869 : /* ADDR_VECs only take room if read-only data goes into the text
870 : section. */
871 7055289 : if ((JUMP_TABLES_IN_TEXT_SECTION
872 7055289 : || readonly_data_section == text_section)
873 0 : && table)
874 : {
875 0 : align_flags alignment = align_flags (ADDR_VEC_ALIGN (table));
876 0 : max_alignment = align_flags::max (max_alignment, alignment);
877 : }
878 7055289 : LABEL_TO_ALIGNMENT (label) = max_alignment;
879 7055289 : max_alignment = align_flags ();
880 : }
881 111466769 : else if (BARRIER_P (insn))
882 : {
883 : rtx_insn *label;
884 :
885 28701138 : for (label = insn; label && ! INSN_P (label);
886 23795359 : label = NEXT_INSN (label))
887 27113931 : if (LABEL_P (label))
888 : {
889 3318572 : align_flags alignment
890 3318572 : = align_flags (LABEL_ALIGN_AFTER_BARRIER (insn));
891 3318572 : max_alignment = align_flags::max (max_alignment, alignment);
892 3318572 : break;
893 : }
894 : }
895 : }
896 1533028 : if (!HAVE_ATTR_length)
897 : return;
898 :
899 : /* Allocate the rest of the arrays. */
900 1533028 : insn_lengths = XNEWVEC (int, max_uid);
901 1533028 : insn_lengths_max_uid = max_uid;
902 : /* Syntax errors can lead to labels being outside of the main insn stream.
903 : Initialize insn_addresses, so that we get reproducible results. */
904 1533028 : INSN_ADDRESSES_ALLOC (max_uid);
905 :
906 1533028 : varying_length = XCNEWVEC (char, max_uid);
907 :
908 : /* Initialize uid_align. We scan instructions
909 : from end to start, and keep in align_tab[n] the last seen insn
910 : that does an alignment of at least n+1, i.e. the successor
911 : in the alignment chain for an insn that does / has a known
912 : alignment of n. */
913 1533028 : uid_align = XCNEWVEC (rtx_insn *, max_uid);
914 :
915 27594504 : for (i = MAX_CODE_ALIGN + 1; --i >= 0;)
916 26061476 : align_tab[i] = nullptr;
917 1533028 : seq = get_last_insn ();
918 216822267 : for (; seq; seq = PREV_INSN (seq))
919 : {
920 215289239 : int uid = INSN_UID (seq);
921 215289239 : int log;
922 215289239 : log = (LABEL_P (seq) ? LABEL_TO_ALIGNMENT (seq).levels[0].log : 0);
923 215289239 : uid_align[uid] = align_tab[0];
924 215289239 : if (log)
925 : {
926 : /* Found an alignment label. */
927 1341010 : gcc_checking_assert (log < MAX_CODE_ALIGN + 1);
928 1341010 : uid_align[uid] = align_tab[log];
929 6705140 : for (i = log - 1; i >= 0; i--)
930 5364130 : align_tab[i] = seq;
931 : }
932 : }
933 :
934 : /* When optimizing, we start assuming minimum length, and keep increasing
935 : lengths as we find the need for this, till nothing changes.
936 : When not optimizing, we start assuming maximum lengths, and
937 : do a single pass to update the lengths. */
938 1533028 : bool increasing = optimize != 0;
939 :
940 : #ifdef CASE_VECTOR_SHORTEN_MODE
941 : if (optimize)
942 : {
943 : /* Look for ADDR_DIFF_VECs, and initialize their minimum and maximum
944 : label fields. */
945 :
946 : int min_shuid = INSN_SHUID (get_insns ()) - 1;
947 : int max_shuid = INSN_SHUID (get_last_insn ()) + 1;
948 : int rel;
949 :
950 : for (insn = first; insn != 0; insn = NEXT_INSN (insn))
951 : {
952 : rtx_insn *min_lab = nullptr, *max_lab = nullptr;
953 : rtx pat;
954 : int len, i, min, max, insn_shuid;
955 : int min_align;
956 : addr_diff_vec_flags flags;
957 :
958 : if (! JUMP_TABLE_DATA_P (insn)
959 : || GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC)
960 : continue;
961 : pat = PATTERN (insn);
962 : len = XVECLEN (pat, 1);
963 : gcc_assert (len > 0);
964 : min_align = MAX_CODE_ALIGN;
965 : for (min = max_shuid, max = min_shuid, i = len - 1; i >= 0; i--)
966 : {
967 : rtx_insn *lab = label_ref_label (XVECEXP (pat, 1, i));
968 : int shuid = INSN_SHUID (lab);
969 : if (shuid < min)
970 : {
971 : min = shuid;
972 : min_lab = lab;
973 : }
974 : if (shuid > max)
975 : {
976 : max = shuid;
977 : max_lab = lab;
978 : }
979 :
980 : int label_alignment = LABEL_TO_ALIGNMENT (lab).levels[0].log;
981 : if (min_align > label_alignment)
982 : min_align = label_alignment;
983 : }
984 : XEXP (pat, 2) = gen_rtx_LABEL_REF (Pmode, min_lab);
985 : XEXP (pat, 3) = gen_rtx_LABEL_REF (Pmode, max_lab);
986 : insn_shuid = INSN_SHUID (insn);
987 : rel = INSN_SHUID (label_ref_label (XEXP (pat, 0)));
988 : memset (&flags, 0, sizeof (flags));
989 : flags.min_align = min_align;
990 : flags.base_after_vec = rel > insn_shuid;
991 : flags.min_after_vec = min > insn_shuid;
992 : flags.max_after_vec = max > insn_shuid;
993 : flags.min_after_base = min > rel;
994 : flags.max_after_base = max > rel;
995 : ADDR_DIFF_VEC_FLAGS (pat) = flags;
996 :
997 : if (increasing)
998 : PUT_MODE (pat, CASE_VECTOR_SHORTEN_MODE (0, 0, pat));
999 : }
1000 : }
1001 : #endif /* CASE_VECTOR_SHORTEN_MODE */
1002 :
1003 : /* Compute initial lengths, addresses, and varying flags for each insn. */
1004 1533028 : int (*length_fun) (rtx_insn *) = increasing ? insn_min_length : insn_default_length;
1005 :
1006 1533028 : for (insn_current_address = 0, insn = first;
1007 216822267 : insn != 0;
1008 215289239 : insn_current_address += insn_lengths[uid], insn = NEXT_INSN (insn))
1009 : {
1010 215289239 : uid = INSN_UID (insn);
1011 :
1012 215289239 : insn_lengths[uid] = 0;
1013 :
1014 215289239 : if (LABEL_P (insn))
1015 : {
1016 7055289 : int log = LABEL_TO_ALIGNMENT (insn).levels[0].log;
1017 7055289 : if (log)
1018 : {
1019 1341010 : int align = 1 << log;
1020 1341010 : int new_address = (insn_current_address + align - 1) & -align;
1021 1341010 : insn_lengths[uid] = new_address - insn_current_address;
1022 : }
1023 : }
1024 :
1025 215289239 : INSN_ADDRESSES (uid) = insn_current_address + insn_lengths[uid];
1026 :
1027 215289239 : if (NOTE_P (insn) || BARRIER_P (insn)
1028 103829927 : || LABEL_P (insn) || DEBUG_INSN_P (insn))
1029 118514605 : continue;
1030 96774634 : if (insn->deleted ())
1031 0 : continue;
1032 :
1033 96774634 : body = PATTERN (insn);
1034 96774634 : if (rtx_jump_table_data *table = dyn_cast <rtx_jump_table_data *> (insn))
1035 : {
1036 : /* This only takes room if read-only data goes into the text
1037 : section. */
1038 7457 : if (JUMP_TABLES_IN_TEXT_SECTION
1039 7457 : || readonly_data_section == text_section)
1040 0 : insn_lengths[uid] = (XVECLEN (body,
1041 : GET_CODE (body) == ADDR_DIFF_VEC)
1042 0 : * GET_MODE_SIZE (table->get_data_mode ()));
1043 : /* Alignment is handled by ADDR_VEC_ALIGN. */
1044 : }
1045 96767177 : else if (GET_CODE (body) == ASM_INPUT || asm_noperands (body) >= 0)
1046 96681 : insn_lengths[uid] = asm_insn_count (body) * insn_default_length (insn);
1047 96670496 : else if (rtx_sequence *body_seq = dyn_cast <rtx_sequence *> (body))
1048 : {
1049 : int i;
1050 : int const_delay_slots;
1051 : if (DELAY_SLOTS)
1052 : const_delay_slots = const_num_delay_slots (body_seq->insn (0));
1053 : else
1054 : const_delay_slots = 0;
1055 :
1056 : int (*inner_length_fun) (rtx_insn *)
1057 : = const_delay_slots ? length_fun : insn_default_length;
1058 : /* Inside a delay slot sequence, we do not do any branch shortening
1059 : if the shortening could change the number of delay slots
1060 : of the branch. */
1061 0 : for (i = 0; i < body_seq->len (); i++)
1062 : {
1063 0 : rtx_insn *inner_insn = body_seq->insn (i);
1064 0 : int inner_uid = INSN_UID (inner_insn);
1065 0 : int inner_length;
1066 :
1067 0 : if (GET_CODE (PATTERN (inner_insn)) == ASM_INPUT
1068 0 : || asm_noperands (PATTERN (inner_insn)) >= 0)
1069 0 : inner_length = (asm_insn_count (PATTERN (inner_insn))
1070 0 : * insn_default_length (inner_insn));
1071 : else
1072 0 : inner_length = inner_length_fun (inner_insn);
1073 :
1074 0 : insn_lengths[inner_uid] = inner_length;
1075 0 : if (const_delay_slots)
1076 : {
1077 : if ((varying_length[inner_uid]
1078 : = insn_variable_length_p (inner_insn)) != 0)
1079 : varying_length[uid] = 1;
1080 : INSN_ADDRESSES (inner_uid) = (insn_current_address
1081 : + insn_lengths[uid]);
1082 : }
1083 : else
1084 0 : varying_length[inner_uid] = 0;
1085 0 : insn_lengths[uid] += inner_length;
1086 : }
1087 : }
1088 96670496 : else if (GET_CODE (body) != USE && GET_CODE (body) != CLOBBER)
1089 : {
1090 95595738 : insn_lengths[uid] = length_fun (insn);
1091 95595738 : varying_length[uid] = insn_variable_length_p (insn);
1092 : }
1093 :
1094 : /* If needed, do any adjustment. */
1095 : #ifdef ADJUST_INSN_LENGTH
1096 : ADJUST_INSN_LENGTH (insn, insn_lengths[uid]);
1097 : if (insn_lengths[uid] < 0)
1098 : fatal_insn ("negative insn length", insn);
1099 : #endif
1100 : }
1101 :
1102 : /* Now loop over all the insns finding varying length insns. For each,
1103 : get the current insn length. If it has changed, reflect the change.
1104 : When nothing changes for a full pass, we are done. */
1105 :
1106 2868726 : while (something_changed)
1107 : {
1108 1798375 : something_changed = false;
1109 1798375 : insn_current_align = MAX_CODE_ALIGN - 1;
1110 393728580 : for (insn_current_address = 0, insn = first;
1111 393728580 : insn != 0;
1112 391930205 : insn = NEXT_INSN (insn))
1113 : {
1114 391930205 : int new_length;
1115 : #ifdef ADJUST_INSN_LENGTH
1116 : int tmp_length;
1117 : #endif
1118 391930205 : int length_align;
1119 :
1120 391930205 : uid = INSN_UID (insn);
1121 :
1122 391930205 : if (rtx_code_label *label = dyn_cast <rtx_code_label *> (insn))
1123 : {
1124 12564619 : int log = LABEL_TO_ALIGNMENT (label).levels[0].log;
1125 :
1126 : #ifdef CASE_VECTOR_SHORTEN_MODE
1127 : /* If the mode of a following jump table was changed, we
1128 : may need to update the alignment of this label. */
1129 :
1130 : if (JUMP_TABLES_IN_TEXT_SECTION
1131 : || readonly_data_section == text_section)
1132 : {
1133 : rtx_jump_table_data *table = jump_table_for_label (label);
1134 : if (table)
1135 : {
1136 : int newlog = ADDR_VEC_ALIGN (table);
1137 : if (newlog != log)
1138 : {
1139 : log = newlog;
1140 : LABEL_TO_ALIGNMENT (insn) = log;
1141 : something_changed = true;
1142 : }
1143 : }
1144 : }
1145 : #endif
1146 :
1147 12564619 : if (log > insn_current_align)
1148 : {
1149 2701542 : int align = 1 << log;
1150 2701542 : int new_address= (insn_current_address + align - 1) & -align;
1151 2701542 : insn_lengths[uid] = new_address - insn_current_address;
1152 2701542 : insn_current_align = log;
1153 2701542 : insn_current_address = new_address;
1154 : }
1155 : else
1156 9863077 : insn_lengths[uid] = 0;
1157 12564619 : INSN_ADDRESSES (uid) = insn_current_address;
1158 12564619 : continue;
1159 12564619 : }
1160 :
1161 379365586 : length_align = INSN_LENGTH_ALIGNMENT (insn);
1162 379365586 : if (length_align < insn_current_align)
1163 4499917 : insn_current_align = length_align;
1164 :
1165 379365586 : insn_last_address = INSN_ADDRESSES (uid);
1166 379365586 : INSN_ADDRESSES (uid) = insn_current_address;
1167 :
1168 : #ifdef CASE_VECTOR_SHORTEN_MODE
1169 : if (optimize
1170 : && JUMP_TABLE_DATA_P (insn)
1171 : && GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC)
1172 : {
1173 : rtx_jump_table_data *table = as_a <rtx_jump_table_data *> (insn);
1174 : rtx body = PATTERN (insn);
1175 : int old_length = insn_lengths[uid];
1176 : rtx_insn *rel_lab =
1177 : safe_as_a <rtx_insn *> (XEXP (XEXP (body, 0), 0));
1178 : rtx_insn *min_lab = label_ref_label (XEXP (body, 2));
1179 : rtx_insn *max_lab = label_ref_label (XEXP (body, 3));
1180 : int rel_addr = INSN_ADDRESSES (INSN_UID (rel_lab));
1181 : int min_addr = INSN_ADDRESSES (INSN_UID (min_lab));
1182 : int max_addr = INSN_ADDRESSES (INSN_UID (max_lab));
1183 : rtx_insn *prev;
1184 : int rel_align = 0;
1185 : addr_diff_vec_flags flags;
1186 : scalar_int_mode vec_mode;
1187 :
1188 : /* Avoid automatic aggregate initialization. */
1189 : flags = ADDR_DIFF_VEC_FLAGS (body);
1190 :
1191 : /* Try to find a known alignment for rel_lab. */
1192 : for (prev = rel_lab;
1193 : prev
1194 : && ! insn_lengths[INSN_UID (prev)]
1195 : && ! (varying_length[INSN_UID (prev)] & 1);
1196 : prev = PREV_INSN (prev))
1197 : if (varying_length[INSN_UID (prev)] & 2)
1198 : {
1199 : rel_align = LABEL_TO_ALIGNMENT (prev).levels[0].log;
1200 : break;
1201 : }
1202 :
1203 : /* See the comment on addr_diff_vec_flags in rtl.h for the
1204 : meaning of the flags values. base: REL_LAB vec: INSN */
1205 : /* Anything after INSN has still addresses from the last
1206 : pass; adjust these so that they reflect our current
1207 : estimate for this pass. */
1208 : if (flags.base_after_vec)
1209 : rel_addr += insn_current_address - insn_last_address;
1210 : if (flags.min_after_vec)
1211 : min_addr += insn_current_address - insn_last_address;
1212 : if (flags.max_after_vec)
1213 : max_addr += insn_current_address - insn_last_address;
1214 : /* We want to know the worst case, i.e. lowest possible value
1215 : for the offset of MIN_LAB. If MIN_LAB is after REL_LAB,
1216 : its offset is positive, and we have to be wary of code shrink;
1217 : otherwise, it is negative, and we have to be vary of code
1218 : size increase. */
1219 : if (flags.min_after_base)
1220 : {
1221 : /* If INSN is between REL_LAB and MIN_LAB, the size
1222 : changes we are about to make can change the alignment
1223 : within the observed offset, therefore we have to break
1224 : it up into two parts that are independent. */
1225 : if (! flags.base_after_vec && flags.min_after_vec)
1226 : {
1227 : min_addr -= align_fuzz (rel_lab, insn, rel_align, 0);
1228 : min_addr -= align_fuzz (insn, min_lab, 0, 0);
1229 : }
1230 : else
1231 : min_addr -= align_fuzz (rel_lab, min_lab, rel_align, 0);
1232 : }
1233 : else
1234 : {
1235 : if (flags.base_after_vec && ! flags.min_after_vec)
1236 : {
1237 : min_addr -= align_fuzz (min_lab, insn, 0, ~0);
1238 : min_addr -= align_fuzz (insn, rel_lab, 0, ~0);
1239 : }
1240 : else
1241 : min_addr -= align_fuzz (min_lab, rel_lab, 0, ~0);
1242 : }
1243 : /* Likewise, determine the highest lowest possible value
1244 : for the offset of MAX_LAB. */
1245 : if (flags.max_after_base)
1246 : {
1247 : if (! flags.base_after_vec && flags.max_after_vec)
1248 : {
1249 : max_addr += align_fuzz (rel_lab, insn, rel_align, ~0);
1250 : max_addr += align_fuzz (insn, max_lab, 0, ~0);
1251 : }
1252 : else
1253 : max_addr += align_fuzz (rel_lab, max_lab, rel_align, ~0);
1254 : }
1255 : else
1256 : {
1257 : if (flags.base_after_vec && ! flags.max_after_vec)
1258 : {
1259 : max_addr += align_fuzz (max_lab, insn, 0, 0);
1260 : max_addr += align_fuzz (insn, rel_lab, 0, 0);
1261 : }
1262 : else
1263 : max_addr += align_fuzz (max_lab, rel_lab, 0, 0);
1264 : }
1265 : vec_mode = CASE_VECTOR_SHORTEN_MODE (min_addr - rel_addr,
1266 : max_addr - rel_addr, body);
1267 : if (!increasing
1268 : || (GET_MODE_SIZE (vec_mode)
1269 : >= GET_MODE_SIZE (table->get_data_mode ())))
1270 : PUT_MODE (body, vec_mode);
1271 : if (JUMP_TABLES_IN_TEXT_SECTION
1272 : || readonly_data_section == text_section)
1273 : {
1274 : insn_lengths[uid]
1275 : = (XVECLEN (body, 1)
1276 : * GET_MODE_SIZE (table->get_data_mode ()));
1277 : insn_current_address += insn_lengths[uid];
1278 : if (insn_lengths[uid] != old_length)
1279 : something_changed = true;
1280 : }
1281 :
1282 : continue;
1283 : }
1284 : #endif /* CASE_VECTOR_SHORTEN_MODE */
1285 :
1286 379365586 : if (! (varying_length[uid]))
1287 : {
1288 363030547 : rtx_sequence *seq;
1289 363030547 : if (NONJUMP_INSN_P (insn)
1290 363030547 : && (seq = dyn_cast<rtx_sequence *> (PATTERN (insn))))
1291 : {
1292 0 : for (int i = 0; i < seq->len (); i++)
1293 : {
1294 0 : rtx_insn *inner_insn = seq->insn (i);
1295 0 : int inner_uid = INSN_UID (inner_insn);
1296 :
1297 0 : INSN_ADDRESSES (inner_uid) = insn_current_address;
1298 :
1299 0 : insn_current_address += insn_lengths[inner_uid];
1300 : }
1301 : }
1302 : else
1303 363030547 : insn_current_address += insn_lengths[uid];
1304 :
1305 363030547 : continue;
1306 363030547 : }
1307 :
1308 16335039 : rtx_sequence *seqn;
1309 16335039 : if (NONJUMP_INSN_P (insn)
1310 16335039 : && (seqn = dyn_cast <rtx_sequence *> (PATTERN (insn))))
1311 : {
1312 : int i;
1313 :
1314 0 : body = PATTERN (insn);
1315 0 : new_length = 0;
1316 0 : for (i = 0; i < seqn->len (); i++)
1317 : {
1318 0 : rtx_insn *inner_insn = seqn->insn (i);
1319 0 : int inner_uid = INSN_UID (inner_insn);
1320 0 : int inner_length;
1321 :
1322 0 : INSN_ADDRESSES (inner_uid) = insn_current_address;
1323 :
1324 : /* insn_current_length returns 0 for insns with a
1325 : non-varying length. */
1326 0 : if (! varying_length[inner_uid])
1327 0 : inner_length = insn_lengths[inner_uid];
1328 : else
1329 0 : inner_length = insn_current_length (inner_insn);
1330 :
1331 0 : if (inner_length != insn_lengths[inner_uid])
1332 : {
1333 0 : if (!increasing || inner_length > insn_lengths[inner_uid])
1334 : {
1335 0 : insn_lengths[inner_uid] = inner_length;
1336 0 : something_changed = true;
1337 : }
1338 : else
1339 : inner_length = insn_lengths[inner_uid];
1340 : }
1341 0 : insn_current_address += inner_length;
1342 0 : new_length += inner_length;
1343 : }
1344 : }
1345 : else
1346 : {
1347 16335039 : new_length = insn_current_length (insn);
1348 16335039 : insn_current_address += new_length;
1349 : }
1350 :
1351 : #ifdef ADJUST_INSN_LENGTH
1352 : /* If needed, do any adjustment. */
1353 : tmp_length = new_length;
1354 : ADJUST_INSN_LENGTH (insn, new_length);
1355 : insn_current_address += (new_length - tmp_length);
1356 : #endif
1357 :
1358 16335039 : if (new_length != insn_lengths[uid]
1359 5474026 : && (!increasing || new_length > insn_lengths[uid]))
1360 : {
1361 5474026 : insn_lengths[uid] = new_length;
1362 5474026 : something_changed = true;
1363 : }
1364 : else
1365 10861013 : insn_current_address += insn_lengths[uid] - new_length;
1366 : }
1367 : /* For a non-optimizing compile, do only a single pass. */
1368 1798375 : if (!increasing)
1369 : break;
1370 : }
1371 1533028 : crtl->max_insn_address = insn_current_address;
1372 1533028 : free (varying_length);
1373 : }
1374 :
1375 : /* Given the body of an INSN known to be generated by an ASM statement, return
1376 : the number of machine instructions likely to be generated for this insn.
1377 : This is used to compute its length. */
1378 :
1379 : static int
1380 104768 : asm_insn_count (rtx body)
1381 : {
1382 104768 : const char *templ;
1383 :
1384 104768 : if (GET_CODE (body) == ASM_INPUT)
1385 3585 : templ = XSTR (body, 0);
1386 : else
1387 101183 : templ = decode_asm_operands (body, NULL, NULL, NULL, NULL, NULL);
1388 :
1389 104768 : return asm_str_count (templ);
1390 : }
1391 :
1392 : /* Return the number of machine instructions likely to be generated for the
1393 : inline-asm template. */
1394 : int
1395 771091 : asm_str_count (const char *templ)
1396 : {
1397 771091 : int count = 1;
1398 :
1399 771091 : if (!*templ)
1400 : return 0;
1401 :
1402 3879287 : for (; *templ; templ++)
1403 3674120 : if (IS_ASM_LOGICAL_LINE_SEPARATOR (*templ, templ)
1404 3666666 : || *templ == '\n')
1405 223286 : count++;
1406 :
1407 : return count;
1408 : }
1409 :
1410 : /* Return true if DWARF2 debug info can be emitted for DECL. */
1411 :
1412 : static bool
1413 3139135 : dwarf2_debug_info_emitted_p (tree decl)
1414 : {
1415 : /* When DWARF2 debug info is not generated internally. */
1416 3139135 : if (!dwarf_debuginfo_p () && !dwarf_based_debuginfo_p ())
1417 : return false;
1418 :
1419 1182443 : if (DECL_IGNORED_P (decl))
1420 16958 : return false;
1421 :
1422 : return true;
1423 : }
1424 :
1425 : /* Return scope resulting from combination of S1 and S2. */
1426 : static tree
1427 0 : choose_inner_scope (tree s1, tree s2)
1428 : {
1429 0 : if (!s1)
1430 : return s2;
1431 0 : if (!s2)
1432 : return s1;
1433 0 : if (BLOCK_NUMBER (s1) > BLOCK_NUMBER (s2))
1434 0 : return s1;
1435 : return s2;
1436 : }
1437 :
1438 : /* Emit lexical block notes needed to change scope from S1 to S2. */
1439 :
1440 : static void
1441 17843337 : change_scope (rtx_insn *orig_insn, tree s1, tree s2)
1442 : {
1443 17843337 : rtx_insn *insn = orig_insn;
1444 17843337 : tree com = NULL_TREE;
1445 17843337 : tree ts1 = s1, ts2 = s2;
1446 17843337 : tree s;
1447 :
1448 58496900 : while (ts1 != ts2)
1449 : {
1450 40653563 : gcc_assert (ts1 && ts2);
1451 40653563 : if (BLOCK_NUMBER (ts1) > BLOCK_NUMBER (ts2))
1452 16409008 : ts1 = BLOCK_SUPERCONTEXT (ts1);
1453 24244555 : else if (BLOCK_NUMBER (ts1) < BLOCK_NUMBER (ts2))
1454 16409008 : ts2 = BLOCK_SUPERCONTEXT (ts2);
1455 : else
1456 : {
1457 7835547 : ts1 = BLOCK_SUPERCONTEXT (ts1);
1458 7835547 : ts2 = BLOCK_SUPERCONTEXT (ts2);
1459 : }
1460 : }
1461 42087892 : com = ts1;
1462 :
1463 : /* Close scopes. */
1464 : s = s1;
1465 42087892 : while (s != com)
1466 : {
1467 24244555 : rtx_note *note = emit_note_before (NOTE_INSN_BLOCK_END, insn);
1468 24244555 : NOTE_BLOCK (note) = s;
1469 24244555 : s = BLOCK_SUPERCONTEXT (s);
1470 : }
1471 :
1472 : /* Open scopes. */
1473 : s = s2;
1474 42087892 : while (s != com)
1475 : {
1476 24244555 : insn = emit_note_before (NOTE_INSN_BLOCK_BEG, insn);
1477 24244555 : NOTE_BLOCK (insn) = s;
1478 24244555 : s = BLOCK_SUPERCONTEXT (s);
1479 : }
1480 17843337 : }
1481 :
1482 : /* Rebuild all the NOTE_INSN_BLOCK_BEG and NOTE_INSN_BLOCK_END notes based
1483 : on the scope tree and the newly reordered instructions. */
1484 :
1485 : static void
1486 580508 : reemit_insn_block_notes (void)
1487 : {
1488 580508 : tree cur_block = DECL_INITIAL (cfun->decl);
1489 580508 : rtx_insn *insn;
1490 :
1491 580508 : insn = get_insns ();
1492 154759723 : for (; insn; insn = NEXT_INSN (insn))
1493 : {
1494 154179215 : tree this_block;
1495 :
1496 : /* Prevent lexical blocks from straddling section boundaries. */
1497 154179215 : if (NOTE_P (insn))
1498 99891219 : switch (NOTE_KIND (insn))
1499 : {
1500 : case NOTE_INSN_SWITCH_TEXT_SECTIONS:
1501 : {
1502 80848 : for (tree s = cur_block; s != DECL_INITIAL (cfun->decl);
1503 59421 : s = BLOCK_SUPERCONTEXT (s))
1504 : {
1505 59421 : rtx_note *note = emit_note_before (NOTE_INSN_BLOCK_END, insn);
1506 59421 : NOTE_BLOCK (note) = s;
1507 59421 : note = emit_note_after (NOTE_INSN_BLOCK_BEG, insn);
1508 59421 : NOTE_BLOCK (note) = s;
1509 : }
1510 : }
1511 : break;
1512 :
1513 11484283 : case NOTE_INSN_BEGIN_STMT:
1514 11484283 : case NOTE_INSN_INLINE_ENTRY:
1515 11484283 : this_block = LOCATION_BLOCK (NOTE_MARKER_LOCATION (insn));
1516 11475431 : if (!this_block)
1517 14321 : continue;
1518 11469962 : goto set_cur_block_to_this_block;
1519 :
1520 88385509 : default:
1521 88385509 : continue;
1522 88385509 : }
1523 :
1524 54309423 : if (!active_insn_p (insn))
1525 7376962 : continue;
1526 :
1527 : /* Avoid putting scope notes between jump table and its label. */
1528 46932461 : if (JUMP_TABLE_DATA_P (insn))
1529 6289 : continue;
1530 :
1531 46926172 : this_block = insn_scope (insn);
1532 : /* For sequences compute scope resulting from merging all scopes
1533 : of instructions nested inside. */
1534 46926172 : if (rtx_sequence *body = dyn_cast <rtx_sequence *> (PATTERN (insn)))
1535 : {
1536 : int i;
1537 :
1538 : this_block = NULL;
1539 0 : for (i = 0; i < body->len (); i++)
1540 0 : this_block = choose_inner_scope (this_block,
1541 0 : insn_scope (body->insn (i)));
1542 : }
1543 46926172 : if (! this_block)
1544 : {
1545 10499179 : if (insn->location () == UNKNOWN_LOCATION)
1546 5115261 : continue;
1547 : else
1548 5383918 : this_block = DECL_INITIAL (cfun->decl);
1549 : }
1550 :
1551 36426993 : set_cur_block_to_this_block:
1552 53280873 : if (this_block != cur_block)
1553 : {
1554 17262829 : change_scope (insn, cur_block, this_block);
1555 17262829 : cur_block = this_block;
1556 : }
1557 : }
1558 :
1559 : /* change_scope emits before the insn, not after. */
1560 580508 : rtx_note *note = emit_note (NOTE_INSN_DELETED);
1561 580508 : change_scope (note, cur_block, DECL_INITIAL (cfun->decl));
1562 580508 : delete_insn (note);
1563 :
1564 580508 : reorder_blocks ();
1565 580508 : }
1566 :
1567 : static const char *some_local_dynamic_name;
1568 :
1569 : /* Locate some local-dynamic symbol still in use by this function
1570 : so that we can print its name in local-dynamic base patterns.
1571 : Return null if there are no local-dynamic references. */
1572 :
1573 : const char *
1574 423 : get_some_local_dynamic_name ()
1575 : {
1576 423 : subrtx_iterator::array_type array;
1577 423 : rtx_insn *insn;
1578 :
1579 423 : if (some_local_dynamic_name)
1580 : return some_local_dynamic_name;
1581 :
1582 8864 : for (insn = get_insns (); insn ; insn = NEXT_INSN (insn))
1583 8857 : if (NONDEBUG_INSN_P (insn))
1584 18127 : FOR_EACH_SUBRTX (iter, array, PATTERN (insn), ALL)
1585 : {
1586 15729 : const_rtx x = *iter;
1587 15729 : if (GET_CODE (x) == SYMBOL_REF)
1588 : {
1589 569 : if (SYMBOL_REF_TLS_MODEL (x) == TLS_MODEL_LOCAL_DYNAMIC)
1590 187 : return some_local_dynamic_name = XSTR (x, 0);
1591 382 : if (CONSTANT_POOL_ADDRESS_P (x))
1592 0 : iter.substitute (get_pool_constant (x));
1593 : }
1594 : }
1595 :
1596 : return 0;
1597 423 : }
1598 :
1599 : /* Arrange for us to emit a source location note before any further
1600 : real insns or section changes, by setting the SEEN_NEXT_VIEW bit in
1601 : *SEEN, as long as we are keeping track of location views. The bit
1602 : indicates we have referenced the next view at the current PC, so we
1603 : have to emit it. This should be called next to the var_location
1604 : debug hook. */
1605 :
1606 : static inline void
1607 65685461 : set_next_view_needed (int *seen)
1608 : {
1609 65685461 : if (debug_variable_location_views)
1610 65685447 : *seen |= SEEN_NEXT_VIEW;
1611 : }
1612 :
1613 : /* Clear the flag in *SEEN indicating we need to emit the next view.
1614 : This should be called next to the source_line debug hook. */
1615 :
1616 : static inline void
1617 48727120 : clear_next_view_needed (int *seen)
1618 : {
1619 48727120 : *seen &= ~SEEN_NEXT_VIEW;
1620 : }
1621 :
1622 : /* Test whether we have a pending request to emit the next view in
1623 : *SEEN, and emit it if needed, clearing the request bit. */
1624 :
1625 : static inline void
1626 93273078 : maybe_output_next_view (int *seen)
1627 : {
1628 93273078 : if ((*seen & SEEN_NEXT_VIEW) != 0)
1629 : {
1630 8920800 : clear_next_view_needed (seen);
1631 8920800 : (*debug_hooks->source_line) (last_linenum, last_columnnum,
1632 : last_filename, last_discriminator,
1633 : false);
1634 : }
1635 93273078 : }
1636 :
1637 : /* We want to emit param bindings (before the first begin_stmt) in the
1638 : initial view, if we are emitting views. To that end, we may
1639 : consume initial notes in the function, processing them in
1640 : final_start_function, before signaling the beginning of the
1641 : prologue, rather than in final.
1642 :
1643 : We don't test whether the DECLs are PARM_DECLs: the assumption is
1644 : that there will be a NOTE_INSN_BEGIN_STMT marker before any
1645 : non-parameter NOTE_INSN_VAR_LOCATION. It's ok if the marker is not
1646 : there, we'll just have more variable locations bound in the initial
1647 : view, which is consistent with their being bound without any code
1648 : that would give them a value. */
1649 :
1650 : static inline bool
1651 2991914 : in_initial_view_p (rtx_insn *insn)
1652 : {
1653 2991914 : return (!DECL_IGNORED_P (current_function_decl)
1654 2981150 : && debug_variable_location_views
1655 1953083 : && insn && GET_CODE (insn) == NOTE
1656 4783085 : && (NOTE_KIND (insn) == NOTE_INSN_VAR_LOCATION
1657 837656 : || NOTE_KIND (insn) == NOTE_INSN_DELETED));
1658 : }
1659 :
1660 : /* Output assembler code for the start of a function,
1661 : and initialize some of the variables in this file
1662 : for the new function. The label for the function and associated
1663 : assembler pseudo-ops have already been output in `assemble_start_function'.
1664 :
1665 : FIRST is the first insn of the rtl for the function being compiled.
1666 : FILE is the file to write assembler code to.
1667 : SEEN should be initially set to zero, and it may be updated to
1668 : indicate we have references to the next location view, that would
1669 : require us to emit it at the current PC.
1670 : OPTIMIZE_P is nonzero if we should eliminate redundant
1671 : test and compare insns. */
1672 :
1673 : static void
1674 1536723 : final_start_function_1 (rtx_insn **firstp, FILE *file, int *seen,
1675 : int optimize_p ATTRIBUTE_UNUSED)
1676 : {
1677 1536723 : block_depth = 0;
1678 :
1679 1536723 : this_is_asm_operands = 0;
1680 :
1681 1536723 : need_profile_function = false;
1682 :
1683 1536723 : last_filename = LOCATION_FILE (prologue_location);
1684 1536723 : last_linenum = LOCATION_LINE (prologue_location);
1685 1536723 : last_columnnum = LOCATION_COLUMN (prologue_location);
1686 1536723 : last_discriminator = 0;
1687 1536723 : force_source_line = false;
1688 :
1689 1536723 : high_block_linenum = high_function_linenum = last_linenum;
1690 :
1691 1536723 : rtx_insn *first = *firstp;
1692 1536723 : if (in_initial_view_p (first))
1693 : {
1694 1453287 : do
1695 : {
1696 1453287 : final_scan_insn (first, file, 0, 0, seen);
1697 1453287 : first = NEXT_INSN (first);
1698 : }
1699 1453287 : while (in_initial_view_p (first));
1700 499772 : *firstp = first;
1701 : }
1702 :
1703 1536723 : if (!DECL_IGNORED_P (current_function_decl))
1704 1525959 : debug_hooks->begin_prologue (last_linenum, last_columnnum,
1705 : last_filename);
1706 :
1707 1536723 : if (!dwarf2_debug_info_emitted_p (current_function_decl))
1708 964687 : dwarf2out_begin_prologue (0, 0, NULL);
1709 :
1710 1536723 : if (DECL_IGNORED_P (current_function_decl) && last_linenum && last_filename)
1711 6391 : debug_hooks->set_ignored_loc (last_linenum, last_columnnum, last_filename);
1712 :
1713 : #ifdef LEAF_REG_REMAP
1714 : if (crtl->uses_only_leaf_regs)
1715 : leaf_renumber_regs (first);
1716 : #endif
1717 :
1718 : /* The Sun386i and perhaps other machines don't work right
1719 : if the profiling code comes after the prologue. */
1720 1536723 : if (targetm.profile_before_prologue () && crtl->profile)
1721 : {
1722 383 : if (targetm.asm_out.function_prologue == default_function_pro_epilogue
1723 383 : && targetm.have_prologue ())
1724 : {
1725 : rtx_insn *insn;
1726 766 : for (insn = first; insn; insn = NEXT_INSN (insn))
1727 766 : if (!NOTE_P (insn))
1728 : {
1729 : insn = NULL;
1730 : break;
1731 : }
1732 766 : else if (NOTE_KIND (insn) == NOTE_INSN_BASIC_BLOCK
1733 383 : || NOTE_KIND (insn) == NOTE_INSN_FUNCTION_BEG)
1734 : break;
1735 383 : else if (NOTE_KIND (insn) == NOTE_INSN_DELETED
1736 0 : || NOTE_KIND (insn) == NOTE_INSN_VAR_LOCATION)
1737 383 : continue;
1738 : else
1739 : {
1740 : insn = NULL;
1741 : break;
1742 : }
1743 :
1744 383 : if (insn)
1745 383 : need_profile_function = true;
1746 : else
1747 0 : profile_function (file);
1748 : }
1749 : else
1750 0 : profile_function (file);
1751 : }
1752 :
1753 : /* If debugging, assign block numbers to all of the blocks in this
1754 : function. */
1755 1536723 : if (write_symbols)
1756 : {
1757 580508 : reemit_insn_block_notes ();
1758 580508 : number_blocks (current_function_decl);
1759 : /* We never actually put out begin/end notes for the top-level
1760 : block in the function. But, conceptually, that block is
1761 : always needed. */
1762 580508 : TREE_ASM_WRITTEN (DECL_INITIAL (current_function_decl)) = 1;
1763 : }
1764 :
1765 1536723 : unsigned HOST_WIDE_INT min_frame_size
1766 1536723 : = constant_lower_bound (get_frame_size ());
1767 1536723 : if (min_frame_size > (unsigned HOST_WIDE_INT) warn_frame_larger_than_size)
1768 : {
1769 : /* Issue a warning */
1770 6 : warning (OPT_Wframe_larger_than_,
1771 : "the frame size of %wu bytes is larger than %wu bytes",
1772 : min_frame_size, warn_frame_larger_than_size);
1773 : }
1774 :
1775 : /* First output the function prologue: code to set up the stack frame. */
1776 1536723 : targetm.asm_out.function_prologue (file);
1777 :
1778 : /* If the machine represents the prologue as RTL, the profiling code must
1779 : be emitted when NOTE_INSN_PROLOGUE_END is scanned. */
1780 1536723 : if (! targetm.have_prologue ())
1781 0 : profile_after_prologue (file);
1782 1536723 : }
1783 :
1784 : /* This is an exported final_start_function_1, callable without SEEN. */
1785 :
1786 : void
1787 5598 : final_start_function (rtx_insn *first, FILE *file,
1788 : int optimize_p ATTRIBUTE_UNUSED)
1789 : {
1790 5598 : int seen = 0;
1791 5598 : final_start_function_1 (&first, file, &seen, optimize_p);
1792 5598 : gcc_assert (seen == 0);
1793 5598 : }
1794 :
1795 : static void
1796 1533029 : profile_after_prologue (FILE *file ATTRIBUTE_UNUSED)
1797 : {
1798 1533029 : if (!targetm.profile_before_prologue () && crtl->profile)
1799 12 : profile_function (file);
1800 1533029 : }
1801 :
1802 : static void
1803 395 : profile_function (FILE *file ATTRIBUTE_UNUSED)
1804 : {
1805 : #ifndef NO_PROFILE_COUNTERS
1806 : # define NO_PROFILE_COUNTERS 0
1807 : #endif
1808 : #ifdef ASM_OUTPUT_REG_PUSH
1809 395 : rtx sval = NULL, chain = NULL;
1810 :
1811 395 : if (cfun->returns_struct)
1812 0 : sval = targetm.calls.struct_value_rtx (TREE_TYPE (current_function_decl),
1813 : true);
1814 395 : if (cfun->static_chain_decl)
1815 1 : chain = targetm.calls.static_chain (current_function_decl, true);
1816 : #endif /* ASM_OUTPUT_REG_PUSH */
1817 :
1818 395 : if (! NO_PROFILE_COUNTERS)
1819 : {
1820 : int align = MIN (BIGGEST_ALIGNMENT, LONG_TYPE_SIZE);
1821 : switch_to_section (data_section);
1822 : ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT));
1823 : targetm.asm_out.internal_label (file, "LP", current_function_funcdef_no);
1824 : assemble_integer (const0_rtx, LONG_TYPE_SIZE / BITS_PER_UNIT, align, 1);
1825 : }
1826 :
1827 395 : switch_to_section (current_function_section ());
1828 :
1829 : #ifdef ASM_OUTPUT_REG_PUSH
1830 395 : if (sval && REG_P (sval))
1831 0 : ASM_OUTPUT_REG_PUSH (file, REGNO (sval));
1832 395 : if (chain && REG_P (chain))
1833 1 : ASM_OUTPUT_REG_PUSH (file, REGNO (chain));
1834 : #endif
1835 :
1836 395 : FUNCTION_PROFILER (file, current_function_funcdef_no);
1837 :
1838 : #ifdef ASM_OUTPUT_REG_PUSH
1839 395 : if (chain && REG_P (chain))
1840 1 : ASM_OUTPUT_REG_POP (file, REGNO (chain));
1841 395 : if (sval && REG_P (sval))
1842 0 : ASM_OUTPUT_REG_POP (file, REGNO (sval));
1843 : #endif
1844 395 : }
1845 :
1846 : /* Output assembler code for the end of a function.
1847 : For clarity, args are same as those of `final_start_function'
1848 : even though not all of them are needed. */
1849 :
1850 : void
1851 1536723 : final_end_function (void)
1852 : {
1853 1536723 : app_disable ();
1854 :
1855 1536723 : if (!DECL_IGNORED_P (current_function_decl))
1856 1525959 : debug_hooks->end_function (high_function_linenum);
1857 :
1858 : /* Finally, output the function epilogue:
1859 : code to restore the stack frame and return to the caller. */
1860 1536723 : targetm.asm_out.function_epilogue (asm_out_file);
1861 :
1862 : /* And debug output. */
1863 1536723 : if (!DECL_IGNORED_P (current_function_decl))
1864 1525959 : debug_hooks->end_epilogue (last_linenum, last_filename);
1865 :
1866 1536723 : if (!dwarf2_debug_info_emitted_p (current_function_decl)
1867 1536723 : && dwarf2out_do_frame ())
1868 964629 : dwarf2out_end_epilogue (last_linenum, last_filename);
1869 :
1870 1536723 : some_local_dynamic_name = 0;
1871 1536723 : }
1872 :
1873 :
1874 : /* Dumper helper for basic block information. FILE is the assembly
1875 : output file, and INSN is the instruction being emitted. */
1876 :
1877 : static void
1878 274628437 : dump_basic_block_info (FILE *file, rtx_insn *insn, basic_block *start_to_bb,
1879 : basic_block *end_to_bb, int bb_map_size, int *bb_seqn)
1880 : {
1881 274628437 : basic_block bb;
1882 :
1883 274628437 : if (!flag_debug_asm)
1884 : return;
1885 :
1886 35141 : if (INSN_UID (insn) < bb_map_size
1887 35141 : && (bb = start_to_bb[INSN_UID (insn)]) != NULL)
1888 : {
1889 2148 : edge e;
1890 2148 : edge_iterator ei;
1891 :
1892 2148 : fprintf (file, "%s BLOCK %d", ASM_COMMENT_START, bb->index);
1893 2148 : if (bb->count.initialized_p ())
1894 : {
1895 212 : fprintf (file, ", count:");
1896 212 : bb->count.dump (file);
1897 : }
1898 2148 : fprintf (file, " seq:%d", (*bb_seqn)++);
1899 2148 : fprintf (file, "\n%s PRED:", ASM_COMMENT_START);
1900 4586 : FOR_EACH_EDGE (e, ei, bb->preds)
1901 : {
1902 2438 : dump_edge_info (file, e, TDF_DETAILS, 0);
1903 : }
1904 2148 : fprintf (file, "\n");
1905 : }
1906 35141 : if (INSN_UID (insn) < bb_map_size
1907 35141 : && (bb = end_to_bb[INSN_UID (insn)]) != NULL)
1908 : {
1909 2148 : edge e;
1910 2148 : edge_iterator ei;
1911 :
1912 2148 : fprintf (asm_out_file, "%s SUCC:", ASM_COMMENT_START);
1913 4577 : FOR_EACH_EDGE (e, ei, bb->succs)
1914 : {
1915 2429 : dump_edge_info (asm_out_file, e, TDF_DETAILS, 1);
1916 : }
1917 2148 : fprintf (file, "\n");
1918 : }
1919 : }
1920 :
1921 : /* Output assembler code for some insns: all or part of a function.
1922 : For description of args, see `final_start_function', above. */
1923 :
1924 : static void
1925 1533029 : final_1 (rtx_insn *first, FILE *file, int seen, int optimize_p)
1926 : {
1927 1533029 : rtx_insn *insn, *next;
1928 :
1929 : /* Used for -dA dump. */
1930 1533029 : basic_block *start_to_bb = NULL;
1931 1533029 : basic_block *end_to_bb = NULL;
1932 1533029 : int bb_map_size = 0;
1933 1533029 : int bb_seqn = 0;
1934 :
1935 1533029 : last_ignored_compare = 0;
1936 :
1937 1533029 : init_recog ();
1938 :
1939 1533029 : CC_STATUS_INIT;
1940 :
1941 1533029 : if (flag_debug_asm)
1942 : {
1943 1236 : basic_block bb;
1944 :
1945 1236 : bb_map_size = get_max_uid () + 1;
1946 1236 : start_to_bb = XCNEWVEC (basic_block, bb_map_size);
1947 1236 : end_to_bb = XCNEWVEC (basic_block, bb_map_size);
1948 :
1949 : /* There is no cfg for a thunk. */
1950 1236 : if (!cfun->is_thunk)
1951 3378 : FOR_EACH_BB_REVERSE_FN (bb, cfun)
1952 : {
1953 2148 : start_to_bb[INSN_UID (BB_HEAD (bb))] = bb;
1954 2148 : end_to_bb[INSN_UID (BB_END (bb))] = bb;
1955 : }
1956 : }
1957 :
1958 : /* Output the insns. */
1959 276161466 : for (insn = first; insn;)
1960 : {
1961 274628437 : if (HAVE_ATTR_length)
1962 : {
1963 274628437 : if ((unsigned) INSN_UID (insn) >= INSN_ADDRESSES_SIZE ())
1964 : {
1965 : /* This can be triggered by bugs elsewhere in the compiler if
1966 : new insns are created after init_insn_lengths is called. */
1967 60792458 : gcc_assert (NOTE_P (insn));
1968 60792458 : insn_current_address = -1;
1969 : }
1970 : else
1971 213835979 : insn_current_address = INSN_ADDRESSES (INSN_UID (insn));
1972 : /* final can be seen as an iteration of shorten_branches that
1973 : does nothing (since a fixed point has already been reached). */
1974 274628437 : insn_last_address = insn_current_address;
1975 : }
1976 :
1977 274628437 : dump_basic_block_info (file, insn, start_to_bb, end_to_bb,
1978 : bb_map_size, &bb_seqn);
1979 274628437 : insn = final_scan_insn (insn, file, optimize_p, 0, &seen);
1980 : }
1981 :
1982 1533029 : maybe_output_next_view (&seen);
1983 :
1984 1533029 : if (flag_debug_asm)
1985 : {
1986 1236 : free (start_to_bb);
1987 1236 : free (end_to_bb);
1988 : }
1989 :
1990 : /* Remove CFI notes, to avoid compare-debug failures. */
1991 276161466 : for (insn = first; insn; insn = next)
1992 : {
1993 274628437 : next = NEXT_INSN (insn);
1994 274628437 : if (NOTE_P (insn)
1995 165892713 : && (NOTE_KIND (insn) == NOTE_INSN_CFI
1996 165892713 : || NOTE_KIND (insn) == NOTE_INSN_CFI_LABEL))
1997 12184502 : delete_insn (insn);
1998 : }
1999 1533029 : }
2000 :
2001 : /* This is an exported final_1, callable without SEEN. */
2002 :
2003 : void
2004 1904 : final (rtx_insn *first, FILE *file, int optimize_p)
2005 : {
2006 : /* Those that use the internal final_start_function_1/final_1 API
2007 : skip initial debug bind notes in final_start_function_1, and pass
2008 : the modified FIRST to final_1. But those that use the public
2009 : final_start_function/final APIs, final_start_function can't move
2010 : FIRST because it's not passed by reference, so if they were
2011 : skipped there, skip them again here. */
2012 1904 : while (in_initial_view_p (first))
2013 0 : first = NEXT_INSN (first);
2014 :
2015 1904 : final_1 (first, file, 0, optimize_p);
2016 1904 : }
2017 :
2018 : const char *
2019 95595818 : get_insn_template (int code, rtx_insn *insn)
2020 : {
2021 95595818 : switch (insn_data[code].output_format)
2022 : {
2023 18100225 : case INSN_OUTPUT_FORMAT_SINGLE:
2024 18100225 : return insn_data[code].output.single;
2025 10333763 : case INSN_OUTPUT_FORMAT_MULTI:
2026 10333763 : return insn_data[code].output.multi[which_alternative];
2027 67161830 : case INSN_OUTPUT_FORMAT_FUNCTION:
2028 67161830 : gcc_assert (insn);
2029 67161830 : return (*insn_data[code].output.function) (recog_data.operand, insn);
2030 :
2031 0 : default:
2032 0 : gcc_unreachable ();
2033 : }
2034 : }
2035 :
2036 : /* Emit the appropriate declaration for an alternate-entry-point
2037 : symbol represented by INSN, to FILE. INSN is a CODE_LABEL with
2038 : LABEL_KIND != LABEL_NORMAL.
2039 :
2040 : The case fall-through in this function is intentional. */
2041 : static void
2042 0 : output_alternate_entry_point (FILE *file, rtx_insn *insn)
2043 : {
2044 0 : const char *name = LABEL_NAME (insn);
2045 :
2046 0 : switch (LABEL_KIND (insn))
2047 : {
2048 0 : case LABEL_WEAK_ENTRY:
2049 : #ifdef ASM_WEAKEN_LABEL
2050 0 : ASM_WEAKEN_LABEL (file, name);
2051 0 : gcc_fallthrough ();
2052 : #endif
2053 0 : case LABEL_GLOBAL_ENTRY:
2054 0 : targetm.asm_out.globalize_label (file, name);
2055 0 : gcc_fallthrough ();
2056 0 : case LABEL_STATIC_ENTRY:
2057 : #ifdef ASM_OUTPUT_TYPE_DIRECTIVE
2058 0 : ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "function");
2059 : #endif
2060 0 : ASM_OUTPUT_LABEL (file, name);
2061 0 : break;
2062 :
2063 0 : case LABEL_NORMAL:
2064 0 : default:
2065 0 : gcc_unreachable ();
2066 : }
2067 0 : }
2068 :
2069 : /* Given a CALL_INSN, find and return the nested CALL. */
2070 : static rtx
2071 39564639 : call_from_call_insn (const rtx_call_insn *insn)
2072 : {
2073 39564639 : rtx x;
2074 39564639 : gcc_assert (CALL_P (insn));
2075 39564639 : x = PATTERN (insn);
2076 :
2077 56598254 : while (GET_CODE (x) != CALL)
2078 : {
2079 17033615 : switch (GET_CODE (x))
2080 : {
2081 0 : default:
2082 0 : gcc_unreachable ();
2083 0 : case COND_EXEC:
2084 0 : x = COND_EXEC_CODE (x);
2085 0 : break;
2086 1697407 : case PARALLEL:
2087 1697407 : x = XVECEXP (x, 0, 0);
2088 1697407 : break;
2089 15336208 : case SET:
2090 15336208 : x = XEXP (x, 1);
2091 15336208 : break;
2092 : }
2093 : }
2094 39564639 : return x;
2095 : }
2096 :
2097 : /* Return the CALL in X if there is one. */
2098 :
2099 : rtx
2100 33233242 : get_call_rtx_from (const rtx_insn *insn)
2101 : {
2102 33233242 : const rtx_call_insn *call_insn = as_a<const rtx_call_insn *> (insn);
2103 33233242 : return call_from_call_insn (call_insn);
2104 : }
2105 :
2106 : /* Print a comment into the asm showing FILENAME, LINENUM, and the
2107 : corresponding source line, if available. */
2108 :
2109 : static void
2110 32 : asm_show_source (const char *filename, int linenum)
2111 : {
2112 32 : if (!filename)
2113 0 : return;
2114 :
2115 32 : diagnostics::char_span line
2116 32 : = global_dc->get_file_cache ().get_source_line (filename, linenum);
2117 32 : if (!line)
2118 : return;
2119 :
2120 32 : fprintf (asm_out_file, "%s %s:%i: ", ASM_COMMENT_START, filename, linenum);
2121 : /* "line" is not 0-terminated, so we must use its length. */
2122 32 : fwrite (line.get_buffer (), 1, line.length (), asm_out_file);
2123 32 : fputc ('\n', asm_out_file);
2124 : }
2125 :
2126 : /* Judge if an absolute jump table is relocatable. */
2127 :
2128 : bool
2129 14914 : jumptable_relocatable (void)
2130 : {
2131 14914 : bool relocatable = false;
2132 :
2133 14914 : if (!CASE_VECTOR_PC_RELATIVE
2134 14914 : && !targetm.asm_out.generate_pic_addr_diff_vec ()
2135 14914 : && targetm_common.have_named_sections)
2136 12488 : relocatable = targetm.asm_out.reloc_rw_mask ();
2137 :
2138 14914 : return relocatable;
2139 : }
2140 :
2141 : /* The final scan for one insn, INSN.
2142 : Args are same as in `final', except that INSN
2143 : is the insn being scanned.
2144 : Value returned is the next insn to be scanned.
2145 :
2146 : NOPEEPHOLES is the flag to disallow peephole processing (currently
2147 : used for within delayed branch sequence output).
2148 :
2149 : SEEN is used to track the end of the prologue, for emitting
2150 : debug information. We force the emission of a line note after
2151 : both NOTE_INSN_PROLOGUE_END and NOTE_INSN_FUNCTION_BEG. */
2152 :
2153 : static rtx_insn *
2154 276081724 : final_scan_insn_1 (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED,
2155 : int nopeepholes ATTRIBUTE_UNUSED, int *seen)
2156 : {
2157 276081724 : rtx_insn *next;
2158 276081724 : rtx_jump_table_data *table;
2159 :
2160 276081724 : insn_counter++;
2161 :
2162 : /* Ignore deleted insns. These can occur when we split insns (due to a
2163 : template of "#") while not optimizing. */
2164 276081724 : if (insn->deleted ())
2165 0 : return NEXT_INSN (insn);
2166 :
2167 276081724 : switch (GET_CODE (insn))
2168 : {
2169 167346000 : case NOTE:
2170 167346000 : switch (NOTE_KIND (insn))
2171 : {
2172 : case NOTE_INSN_DELETED:
2173 : case NOTE_INSN_UPDATE_SJLJ_CONTEXT:
2174 : break;
2175 :
2176 65691 : case NOTE_INSN_SWITCH_TEXT_SECTIONS:
2177 65691 : maybe_output_next_view (seen);
2178 :
2179 65691 : output_function_exception_table (0);
2180 :
2181 65691 : if (targetm.asm_out.unwind_emit)
2182 0 : targetm.asm_out.unwind_emit (asm_out_file, insn);
2183 :
2184 65691 : in_cold_section_p = !in_cold_section_p;
2185 :
2186 65691 : gcc_checking_assert (in_cold_section_p);
2187 65691 : if (in_cold_section_p)
2188 65691 : cold_function_name
2189 65691 : = clone_function_name (current_function_decl, "cold");
2190 :
2191 65691 : if (dwarf2out_do_frame ())
2192 : {
2193 65689 : dwarf2out_switch_text_section ();
2194 65689 : if (!dwarf2_debug_info_emitted_p (current_function_decl)
2195 65689 : && !DECL_IGNORED_P (current_function_decl))
2196 44245 : debug_hooks->switch_text_section ();
2197 : }
2198 2 : else if (!DECL_IGNORED_P (current_function_decl))
2199 1 : debug_hooks->switch_text_section ();
2200 65723 : if (DECL_IGNORED_P (current_function_decl) && last_linenum
2201 65723 : && last_filename)
2202 32 : debug_hooks->set_ignored_loc (last_linenum, last_columnnum,
2203 : last_filename);
2204 :
2205 65691 : switch_to_section (current_function_section ());
2206 65691 : targetm.asm_out.function_switched_text_sections (asm_out_file,
2207 : current_function_decl,
2208 : in_cold_section_p);
2209 : /* Emit a label for the split cold section. Form label name by
2210 : suffixing "cold" to the original function's name. */
2211 65691 : if (in_cold_section_p)
2212 : {
2213 : #ifdef ASM_DECLARE_COLD_FUNCTION_NAME
2214 65691 : ASM_DECLARE_COLD_FUNCTION_NAME (asm_out_file,
2215 : IDENTIFIER_POINTER
2216 : (cold_function_name),
2217 : current_function_decl);
2218 : #else
2219 : ASM_OUTPUT_LABEL (asm_out_file,
2220 : IDENTIFIER_POINTER (cold_function_name));
2221 : #endif
2222 65691 : if (dwarf2out_do_frame ()
2223 65691 : && cfun->fde->dw_fde_second_begin != NULL)
2224 65689 : ASM_OUTPUT_LABEL (asm_out_file, cfun->fde->dw_fde_second_begin);
2225 : }
2226 : break;
2227 :
2228 14646420 : case NOTE_INSN_BASIC_BLOCK:
2229 14646420 : if (need_profile_function)
2230 : {
2231 383 : profile_function (asm_out_file);
2232 383 : need_profile_function = false;
2233 : }
2234 :
2235 14646420 : if (targetm.asm_out.unwind_emit)
2236 0 : targetm.asm_out.unwind_emit (asm_out_file, insn);
2237 :
2238 : break;
2239 :
2240 428427 : case NOTE_INSN_EH_REGION_BEG:
2241 428427 : ASM_OUTPUT_DEBUG_LABEL (asm_out_file, "LEHB",
2242 : NOTE_EH_HANDLER (insn));
2243 428427 : break;
2244 :
2245 428427 : case NOTE_INSN_EH_REGION_END:
2246 428427 : ASM_OUTPUT_DEBUG_LABEL (asm_out_file, "LEHE",
2247 : NOTE_EH_HANDLER (insn));
2248 428427 : break;
2249 :
2250 1533029 : case NOTE_INSN_PROLOGUE_END:
2251 1533029 : targetm.asm_out.function_end_prologue (file);
2252 1533029 : profile_after_prologue (file);
2253 :
2254 1533029 : if ((*seen & (SEEN_EMITTED | SEEN_NOTE)) == SEEN_NOTE)
2255 : {
2256 640738 : *seen |= SEEN_EMITTED;
2257 640738 : force_source_line = true;
2258 : }
2259 : else
2260 892291 : *seen |= SEEN_NOTE;
2261 :
2262 : break;
2263 :
2264 1633388 : case NOTE_INSN_EPILOGUE_BEG:
2265 1633388 : if (!DECL_IGNORED_P (current_function_decl))
2266 1627959 : (*debug_hooks->begin_epilogue) (last_linenum, last_filename);
2267 1633388 : targetm.asm_out.function_begin_epilogue (file);
2268 1633388 : break;
2269 :
2270 12178572 : case NOTE_INSN_CFI:
2271 12178572 : dwarf2out_emit_cfi (NOTE_CFI (insn));
2272 12178572 : break;
2273 :
2274 5930 : case NOTE_INSN_CFI_LABEL:
2275 5930 : ASM_OUTPUT_DEBUG_LABEL (asm_out_file, "LCFI",
2276 : NOTE_LABEL_NUMBER (insn));
2277 5930 : break;
2278 :
2279 1531125 : case NOTE_INSN_FUNCTION_BEG:
2280 1531125 : if (need_profile_function)
2281 : {
2282 0 : profile_function (asm_out_file);
2283 0 : need_profile_function = false;
2284 : }
2285 :
2286 1531125 : app_disable ();
2287 1531125 : if (!DECL_IGNORED_P (current_function_decl))
2288 1524055 : debug_hooks->end_prologue (last_linenum, last_filename);
2289 :
2290 1531125 : if ((*seen & (SEEN_EMITTED | SEEN_NOTE)) == SEEN_NOTE)
2291 : {
2292 890387 : *seen |= SEEN_EMITTED;
2293 890387 : force_source_line = true;
2294 : }
2295 : else
2296 640738 : *seen |= SEEN_NOTE;
2297 :
2298 : break;
2299 :
2300 24303976 : case NOTE_INSN_BLOCK_BEG:
2301 24303976 : if (debug_info_level >= DINFO_LEVEL_NORMAL
2302 31251 : || dwarf_debuginfo_p ()
2303 24303976 : || write_symbols == VMS_DEBUG)
2304 : {
2305 24303976 : int n = BLOCK_NUMBER (NOTE_BLOCK (insn));
2306 :
2307 24303976 : app_disable ();
2308 24303976 : ++block_depth;
2309 24303976 : high_block_linenum = last_linenum;
2310 :
2311 : /* Output debugging info about the symbol-block beginning. */
2312 24303976 : if (!DECL_IGNORED_P (current_function_decl))
2313 24303976 : debug_hooks->begin_block (last_linenum, n, NOTE_BLOCK (insn));
2314 :
2315 : /* Mark this block as output. */
2316 24303976 : TREE_ASM_WRITTEN (NOTE_BLOCK (insn)) = 1;
2317 24303976 : BLOCK_IN_COLD_SECTION_P (NOTE_BLOCK (insn)) = in_cold_section_p;
2318 : }
2319 : break;
2320 :
2321 24303976 : case NOTE_INSN_BLOCK_END:
2322 24303976 : maybe_output_next_view (seen);
2323 :
2324 24303976 : if (debug_info_level >= DINFO_LEVEL_NORMAL
2325 31251 : || dwarf_debuginfo_p ()
2326 24303976 : || write_symbols == VMS_DEBUG)
2327 : {
2328 24303976 : int n = BLOCK_NUMBER (NOTE_BLOCK (insn));
2329 :
2330 24303976 : app_disable ();
2331 :
2332 : /* End of a symbol-block. */
2333 24303976 : --block_depth;
2334 24303976 : gcc_assert (block_depth >= 0);
2335 :
2336 24303976 : if (!DECL_IGNORED_P (current_function_decl))
2337 24303976 : debug_hooks->end_block (high_block_linenum, n);
2338 24303976 : gcc_assert (BLOCK_IN_COLD_SECTION_P (NOTE_BLOCK (insn))
2339 : == in_cold_section_p);
2340 : }
2341 : break;
2342 :
2343 59737 : case NOTE_INSN_DELETED_LABEL:
2344 : /* Emit the label. We may have deleted the CODE_LABEL because
2345 : the label could be proved to be unreachable, though still
2346 : referenced (in the form of having its address taken. */
2347 59737 : ASM_OUTPUT_DEBUG_LABEL (file, "L", CODE_LABEL_NUMBER (insn));
2348 59737 : break;
2349 :
2350 8814 : case NOTE_INSN_DELETED_DEBUG_LABEL:
2351 : /* Similarly, but need to use different namespace for it. */
2352 8814 : if (CODE_LABEL_NUMBER (insn) != -1)
2353 8814 : ASM_OUTPUT_DEBUG_LABEL (file, "LDL", CODE_LABEL_NUMBER (insn));
2354 : break;
2355 :
2356 65701807 : case NOTE_INSN_VAR_LOCATION:
2357 65701807 : if (!DECL_IGNORED_P (current_function_decl))
2358 : {
2359 65685461 : debug_hooks->var_location (insn);
2360 65685461 : set_next_view_needed (seen);
2361 : }
2362 : break;
2363 :
2364 4132581 : case NOTE_INSN_BEGIN_STMT:
2365 4132581 : gcc_checking_assert (cfun->debug_nonbind_markers);
2366 4132581 : if (!DECL_IGNORED_P (current_function_decl)
2367 4132581 : && notice_source_line (insn, NULL))
2368 : {
2369 11484266 : output_source_line:
2370 11484266 : (*debug_hooks->source_line) (last_linenum, last_columnnum,
2371 : last_filename, last_discriminator,
2372 : true);
2373 11484266 : clear_next_view_needed (seen);
2374 : }
2375 : break;
2376 :
2377 7351702 : case NOTE_INSN_INLINE_ENTRY:
2378 7351702 : gcc_checking_assert (cfun->debug_nonbind_markers);
2379 7351702 : if (!DECL_IGNORED_P (current_function_decl)
2380 7351702 : && notice_source_line (insn, NULL))
2381 : {
2382 7351685 : (*debug_hooks->inline_entry) (LOCATION_BLOCK
2383 : (NOTE_MARKER_LOCATION (insn)));
2384 7351685 : goto output_source_line;
2385 : }
2386 : break;
2387 :
2388 0 : default:
2389 0 : gcc_unreachable ();
2390 : break;
2391 : }
2392 : break;
2393 :
2394 : case BARRIER:
2395 : break;
2396 :
2397 7055291 : case CODE_LABEL:
2398 : /* The target port might emit labels in the output function for
2399 : some insn, e.g. sh.cc output_branchy_insn. */
2400 7055291 : if (CODE_LABEL_NUMBER (insn) <= max_labelno)
2401 : {
2402 7055289 : align_flags alignment = LABEL_TO_ALIGNMENT (insn);
2403 8396299 : if (alignment.levels[0].log && NEXT_INSN (insn))
2404 : {
2405 : #ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
2406 : /* Output both primary and secondary alignment. */
2407 1341010 : ASM_OUTPUT_MAX_SKIP_ALIGN (file, alignment.levels[0].log,
2408 : alignment.levels[0].maxskip);
2409 1341010 : ASM_OUTPUT_MAX_SKIP_ALIGN (file, alignment.levels[1].log,
2410 : alignment.levels[1].maxskip);
2411 : #else
2412 : #ifdef ASM_OUTPUT_ALIGN_WITH_NOP
2413 : ASM_OUTPUT_ALIGN_WITH_NOP (file, alignment.levels[0].log);
2414 : #else
2415 : ASM_OUTPUT_ALIGN (file, alignment.levels[0].log);
2416 : #endif
2417 : #endif
2418 : }
2419 : }
2420 7055291 : CC_STATUS_INIT;
2421 :
2422 7055291 : if (!DECL_IGNORED_P (current_function_decl) && LABEL_NAME (insn))
2423 69403 : debug_hooks->label (as_a <rtx_code_label *> (insn));
2424 :
2425 7055291 : app_disable ();
2426 :
2427 : /* If this label is followed by a jump-table, make sure we put
2428 : the label in the read-only section. Also possibly write the
2429 : label and jump table together. */
2430 7055291 : table = jump_table_for_label (as_a <rtx_code_label *> (insn));
2431 :
2432 : /* Still in the function's own section here, which is where the base
2433 : label of a PC-relative table has to go. */
2434 7055291 : if (table
2435 7457 : && JUMP_TABLE_SHARED_P (PATTERN (table))
2436 7056218 : && targetm.asm_out.jump_table_base)
2437 0 : targetm.asm_out.jump_table_base (file, table,
2438 0 : CODE_LABEL_NUMBER (insn));
2439 :
2440 7055291 : if (table)
2441 : {
2442 : #if defined(ASM_OUTPUT_ADDR_VEC) || defined(ASM_OUTPUT_ADDR_DIFF_VEC)
2443 : /* In this case, the case vector is being moved by the
2444 : target, so don't output the label at all. Leave that
2445 : to the back end macros. */
2446 : #else
2447 7457 : if (! JUMP_TABLES_IN_TEXT_SECTION)
2448 : {
2449 7457 : int log_align;
2450 :
2451 7457 : switch_to_section (targetm.asm_out.function_rodata_section
2452 : (current_function_decl,
2453 : jumptable_relocatable ()));
2454 :
2455 : #ifdef ADDR_VEC_ALIGN
2456 7457 : log_align = ADDR_VEC_ALIGN (table);
2457 : #else
2458 : log_align = exact_log2 (BIGGEST_ALIGNMENT / BITS_PER_UNIT);
2459 : #endif
2460 7457 : ASM_OUTPUT_ALIGN (file, log_align);
2461 : }
2462 : else
2463 : switch_to_section (current_function_section ());
2464 :
2465 : #ifdef ASM_OUTPUT_CASE_LABEL
2466 7457 : ASM_OUTPUT_CASE_LABEL (file, "L", CODE_LABEL_NUMBER (insn), table);
2467 : #else
2468 : targetm.asm_out.internal_label (file, "L", CODE_LABEL_NUMBER (insn));
2469 : #endif
2470 : #endif
2471 7457 : break;
2472 : }
2473 7047834 : if (LABEL_ALT_ENTRY_P (insn))
2474 0 : output_alternate_entry_point (file, insn);
2475 : else
2476 7047834 : targetm.asm_out.internal_label (file, "L", CODE_LABEL_NUMBER (insn));
2477 : break;
2478 :
2479 96774652 : default:
2480 96774652 : {
2481 96774652 : rtx body = PATTERN (insn);
2482 96774652 : int insn_code_number;
2483 96774652 : const char *templ;
2484 96774652 : bool is_stmt, *is_stmt_p;
2485 :
2486 96774652 : if (MAY_HAVE_DEBUG_MARKER_INSNS && cfun->debug_nonbind_markers)
2487 : {
2488 21931160 : is_stmt = false;
2489 21931160 : is_stmt_p = NULL;
2490 : }
2491 : else
2492 : is_stmt_p = &is_stmt;
2493 :
2494 : /* Reset this early so it is correct for ASM statements. */
2495 96774652 : current_insn_predicate = NULL_RTX;
2496 :
2497 : /* An INSN, JUMP_INSN or CALL_INSN.
2498 : First check for special kinds that recog doesn't recognize. */
2499 :
2500 96774652 : if (GET_CODE (body) == USE /* These are just declarations. */
2501 96774652 : || GET_CODE (body) == CLOBBER)
2502 : break;
2503 :
2504 : /* Detect insns that are really jump-tables
2505 : and output them as such. */
2506 :
2507 95699893 : if (JUMP_TABLE_DATA_P (insn))
2508 : {
2509 : #if !(defined(ASM_OUTPUT_ADDR_VEC) || defined(ASM_OUTPUT_ADDR_DIFF_VEC))
2510 7457 : int vlen, idx;
2511 : #endif
2512 :
2513 7457 : if (! JUMP_TABLES_IN_TEXT_SECTION)
2514 7457 : switch_to_section (targetm.asm_out.function_rodata_section
2515 : (current_function_decl,
2516 : jumptable_relocatable ()));
2517 : else
2518 : switch_to_section (current_function_section ());
2519 :
2520 7457 : app_disable ();
2521 :
2522 : #if defined(ASM_OUTPUT_ADDR_VEC) || defined(ASM_OUTPUT_ADDR_DIFF_VEC)
2523 : if (GET_CODE (body) == ADDR_VEC)
2524 : {
2525 : #ifdef ASM_OUTPUT_ADDR_VEC
2526 : ASM_OUTPUT_ADDR_VEC (PREV_INSN (insn), body);
2527 : #else
2528 : gcc_unreachable ();
2529 : #endif
2530 : }
2531 : else
2532 : {
2533 : #ifdef ASM_OUTPUT_ADDR_DIFF_VEC
2534 : ASM_OUTPUT_ADDR_DIFF_VEC (PREV_INSN (insn), body);
2535 : #else
2536 : gcc_unreachable ();
2537 : #endif
2538 : }
2539 : #else
2540 7457 : vlen = XVECLEN (body, GET_CODE (body) == ADDR_DIFF_VEC);
2541 176396 : for (idx = 0; idx < vlen; idx++)
2542 : {
2543 168939 : if (GET_CODE (body) == ADDR_VEC)
2544 : {
2545 : #ifdef ASM_OUTPUT_ADDR_VEC_ELT
2546 140907 : ASM_OUTPUT_ADDR_VEC_ELT
2547 : (file, CODE_LABEL_NUMBER
2548 : (label_ref_label (XVECEXP (body, 0, idx))));
2549 : #else
2550 : gcc_unreachable ();
2551 : #endif
2552 : }
2553 : else
2554 : {
2555 : #ifdef ASM_OUTPUT_ADDR_DIFF_ELT
2556 28032 : ASM_OUTPUT_ADDR_DIFF_ELT
2557 : (file,
2558 : body,
2559 : CODE_LABEL_NUMBER
2560 : (label_ref_label (XVECEXP (body, 1, idx))),
2561 : CODE_LABEL_NUMBER (label_ref_label (XEXP (body, 0))));
2562 : #else
2563 : gcc_unreachable ();
2564 : #endif
2565 : }
2566 : }
2567 : #ifdef ASM_OUTPUT_CASE_END
2568 : ASM_OUTPUT_CASE_END (file,
2569 : CODE_LABEL_NUMBER (PREV_INSN (insn)),
2570 : insn);
2571 : #endif
2572 : #endif
2573 :
2574 7457 : switch_to_section (current_function_section ());
2575 :
2576 7457 : if (debug_variable_location_views
2577 7457 : && !DECL_IGNORED_P (current_function_decl))
2578 6285 : debug_hooks->var_location (insn);
2579 :
2580 : break;
2581 : }
2582 : /* Output this line note if it is the first or the last line
2583 : note in a row. */
2584 95692436 : if (!DECL_IGNORED_P (current_function_decl)
2585 95692436 : && notice_source_line (insn, is_stmt_p))
2586 : {
2587 28322054 : if (flag_verbose_asm)
2588 32 : asm_show_source (last_filename, last_linenum);
2589 28322054 : (*debug_hooks->source_line) (last_linenum, last_columnnum,
2590 : last_filename, last_discriminator,
2591 : is_stmt);
2592 28322054 : clear_next_view_needed (seen);
2593 : }
2594 : else
2595 67370382 : maybe_output_next_view (seen);
2596 :
2597 95692436 : gcc_checking_assert (!DEBUG_INSN_P (insn));
2598 :
2599 95692436 : if (GET_CODE (body) == PARALLEL
2600 12011181 : && GET_CODE (XVECEXP (body, 0, 0)) == ASM_INPUT)
2601 95692436 : body = XVECEXP (body, 0, 0);
2602 :
2603 95692436 : if (GET_CODE (body) == ASM_INPUT)
2604 : {
2605 3172 : const char *string = XSTR (body, 0);
2606 :
2607 : /* There's no telling what that did to the condition codes. */
2608 3172 : CC_STATUS_INIT;
2609 :
2610 3172 : if (string[0])
2611 : {
2612 895 : expanded_location loc;
2613 :
2614 895 : app_enable ();
2615 895 : loc = expand_location (ASM_INPUT_SOURCE_LOCATION (body));
2616 895 : if (*loc.file && loc.line)
2617 895 : fprintf (asm_out_file, "%s %i \"%s\" 1\n",
2618 : ASM_COMMENT_START, loc.line, loc.file);
2619 895 : fprintf (asm_out_file, "\t%s\n", string);
2620 : #if HAVE_AS_LINE_ZERO
2621 895 : if (*loc.file && loc.line)
2622 895 : fprintf (asm_out_file, "%s 0 \"\" 2\n", ASM_COMMENT_START);
2623 : #endif
2624 : }
2625 : break;
2626 : }
2627 :
2628 : /* Detect `asm' construct with operands. */
2629 95689264 : if (asm_noperands (body) >= 0)
2630 : {
2631 93509 : unsigned int noperands = asm_noperands (body);
2632 93509 : rtx *ops = XALLOCAVEC (rtx, noperands);
2633 93509 : const char *string;
2634 93509 : location_t loc;
2635 93509 : expanded_location expanded;
2636 :
2637 : /* There's no telling what that did to the condition codes. */
2638 93509 : CC_STATUS_INIT;
2639 :
2640 : /* Get out the operand values. */
2641 93509 : string = decode_asm_operands (body, ops, NULL, NULL, NULL, &loc);
2642 : /* Inhibit dying on what would otherwise be compiler bugs. */
2643 93509 : insn_noperands = noperands;
2644 93509 : this_is_asm_operands = insn;
2645 93509 : expanded = expand_location (loc);
2646 :
2647 : #ifdef FINAL_PRESCAN_INSN
2648 : FINAL_PRESCAN_INSN (insn, ops, insn_noperands);
2649 : #endif
2650 :
2651 : /* Output the insn using them. */
2652 93509 : if (string[0])
2653 : {
2654 20783 : app_enable ();
2655 20783 : if (expanded.file && expanded.line)
2656 20723 : fprintf (asm_out_file, "%s %i \"%s\" 1\n",
2657 : ASM_COMMENT_START, expanded.line, expanded.file);
2658 20783 : output_asm_insn (string, ops);
2659 : #if HAVE_AS_LINE_ZERO
2660 20783 : if (expanded.file && expanded.line)
2661 20723 : fprintf (asm_out_file, "%s 0 \"\" 2\n", ASM_COMMENT_START);
2662 : #endif
2663 : }
2664 :
2665 93509 : if (targetm.asm_out.final_postscan_insn)
2666 0 : targetm.asm_out.final_postscan_insn (file, insn, ops,
2667 : insn_noperands);
2668 :
2669 93509 : this_is_asm_operands = 0;
2670 93509 : break;
2671 : }
2672 :
2673 95595755 : app_disable ();
2674 :
2675 95595755 : if (rtx_sequence *seq = dyn_cast <rtx_sequence *> (body))
2676 : {
2677 : /* A delayed-branch sequence */
2678 0 : int i;
2679 :
2680 0 : final_sequence = seq;
2681 :
2682 : /* The first insn in this SEQUENCE might be a JUMP_INSN that will
2683 : force the restoration of a comparison that was previously
2684 : thought unnecessary. If that happens, cancel this sequence
2685 : and cause that insn to be restored. */
2686 :
2687 0 : next = final_scan_insn (seq->insn (0), file, 0, 1, seen);
2688 0 : if (next != seq->insn (1))
2689 : {
2690 0 : final_sequence = 0;
2691 0 : return next;
2692 : }
2693 :
2694 0 : for (i = 1; i < seq->len (); i++)
2695 : {
2696 0 : rtx_insn *insn = seq->insn (i);
2697 0 : rtx_insn *next = NEXT_INSN (insn);
2698 : /* We loop in case any instruction in a delay slot gets
2699 : split. */
2700 0 : do
2701 0 : insn = final_scan_insn (insn, file, 0, 1, seen);
2702 0 : while (insn != next);
2703 : }
2704 : #ifdef DBR_OUTPUT_SEQEND
2705 : DBR_OUTPUT_SEQEND (file);
2706 : #endif
2707 0 : final_sequence = 0;
2708 :
2709 : /* If the insn requiring the delay slot was a CALL_INSN, the
2710 : insns in the delay slot are actually executed before the
2711 : called function. Hence we don't preserve any CC-setting
2712 : actions in these insns and the CC must be marked as being
2713 : clobbered by the function. */
2714 0 : if (CALL_P (seq->insn (0)))
2715 : {
2716 0 : CC_STATUS_INIT;
2717 : }
2718 0 : break;
2719 : }
2720 :
2721 : /* We have a real machine instruction as rtl. */
2722 :
2723 95595755 : body = PATTERN (insn);
2724 :
2725 : /* Do machine-specific peephole optimizations if desired. */
2726 :
2727 95595755 : if (HAVE_peephole && optimize_p && !flag_no_peephole && !nopeepholes)
2728 : {
2729 : rtx_insn *next = peephole (insn);
2730 : /* When peepholing, if there were notes within the peephole,
2731 : emit them before the peephole. */
2732 : if (next != 0 && next != NEXT_INSN (insn))
2733 : {
2734 : rtx_insn *note, *prev = PREV_INSN (insn);
2735 :
2736 : for (note = NEXT_INSN (insn); note != next;
2737 : note = NEXT_INSN (note))
2738 : final_scan_insn (note, file, optimize_p, nopeepholes, seen);
2739 :
2740 : /* Put the notes in the proper position for a later
2741 : rescan. For example, the SH target can do this
2742 : when generating a far jump in a delayed branch
2743 : sequence. */
2744 : note = NEXT_INSN (insn);
2745 : SET_PREV_INSN (note) = prev;
2746 : SET_NEXT_INSN (prev) = note;
2747 : SET_NEXT_INSN (PREV_INSN (next)) = insn;
2748 : SET_PREV_INSN (insn) = PREV_INSN (next);
2749 : SET_NEXT_INSN (insn) = next;
2750 : SET_PREV_INSN (next) = insn;
2751 : }
2752 :
2753 : /* PEEPHOLE might have changed this. */
2754 : body = PATTERN (insn);
2755 : }
2756 :
2757 : /* Try to recognize the instruction.
2758 : If successful, verify that the operands satisfy the
2759 : constraints for the instruction. Crash if they don't,
2760 : since `reload' should have changed them so that they do. */
2761 :
2762 95595755 : insn_code_number = recog_memoized (insn);
2763 95595755 : cleanup_subreg_operands (insn);
2764 :
2765 : /* Dump the insn in the assembly for debugging (-dAP).
2766 : If the final dump is requested as slim RTL, dump slim
2767 : RTL to the assembly file also. */
2768 95595755 : if (flag_dump_rtl_in_asm)
2769 : {
2770 29 : print_rtx_head = ASM_COMMENT_START;
2771 29 : if (! (dump_flags & TDF_SLIM))
2772 29 : print_rtl_single (asm_out_file, insn);
2773 : else
2774 0 : dump_insn_slim (asm_out_file, insn);
2775 29 : print_rtx_head = "";
2776 : }
2777 :
2778 95595755 : if (! constrain_operands_cached (insn, 1))
2779 0 : fatal_insn_not_found (insn);
2780 :
2781 : /* Some target machines need to prescan each insn before
2782 : it is output. */
2783 :
2784 : #ifdef FINAL_PRESCAN_INSN
2785 : FINAL_PRESCAN_INSN (insn, recog_data.operand, recog_data.n_operands);
2786 : #endif
2787 :
2788 95595755 : if (targetm.have_conditional_execution ()
2789 95595755 : && GET_CODE (PATTERN (insn)) == COND_EXEC)
2790 0 : current_insn_predicate = COND_EXEC_TEST (PATTERN (insn));
2791 :
2792 95595755 : current_output_insn = debug_insn = insn;
2793 :
2794 : /* Find the proper template for this insn. */
2795 95595755 : templ = get_insn_template (insn_code_number, insn);
2796 :
2797 : /* If the C code returns 0, it means that it is a jump insn
2798 : which follows a deleted test insn, and that test insn
2799 : needs to be reinserted. */
2800 95595755 : if (templ == 0)
2801 : {
2802 0 : rtx_insn *prev;
2803 :
2804 0 : gcc_assert (prev_nonnote_insn (insn) == last_ignored_compare);
2805 :
2806 : /* We have already processed the notes between the setter and
2807 : the user. Make sure we don't process them again, this is
2808 : particularly important if one of the notes is a block
2809 : scope note or an EH note. */
2810 0 : for (prev = insn;
2811 0 : prev != last_ignored_compare;
2812 0 : prev = PREV_INSN (prev))
2813 : {
2814 0 : if (NOTE_P (prev))
2815 0 : delete_insn (prev); /* Use delete_note. */
2816 : }
2817 :
2818 : return prev;
2819 : }
2820 :
2821 : /* If the template is the string "#", it means that this insn must
2822 : be split. */
2823 95595755 : if (templ[0] == '#' && templ[1] == '\0')
2824 : {
2825 0 : rtx_insn *new_rtx = try_split (body, insn, 0);
2826 :
2827 : /* If we didn't split the insn, go away. */
2828 0 : if (new_rtx == insn && PATTERN (new_rtx) == body)
2829 0 : fatal_insn ("could not split insn", insn);
2830 :
2831 : /* If we have a length attribute, this instruction should have
2832 : been split in shorten_branches, to ensure that we would have
2833 : valid length info for the splitees. */
2834 0 : gcc_assert (!HAVE_ATTR_length);
2835 :
2836 : return new_rtx;
2837 : }
2838 :
2839 : /* ??? This will put the directives in the wrong place if
2840 : get_insn_template outputs assembly directly. However calling it
2841 : before get_insn_template breaks if the insns is split. */
2842 95595755 : if (targetm.asm_out.unwind_emit_before_insn
2843 95595755 : && targetm.asm_out.unwind_emit)
2844 0 : targetm.asm_out.unwind_emit (asm_out_file, insn);
2845 :
2846 95595755 : rtx_call_insn *call_insn = dyn_cast <rtx_call_insn *> (insn);
2847 6331397 : if (call_insn != NULL)
2848 : {
2849 6331397 : rtx x = call_from_call_insn (call_insn);
2850 6331397 : x = XEXP (x, 0);
2851 6331397 : if (x && MEM_P (x) && GET_CODE (XEXP (x, 0)) == SYMBOL_REF)
2852 : {
2853 6124444 : tree t;
2854 6124444 : x = XEXP (x, 0);
2855 6124444 : t = SYMBOL_REF_DECL (x);
2856 6124444 : if (t)
2857 5862730 : assemble_external (t);
2858 : }
2859 : }
2860 :
2861 : /* Output assembler code from the template. */
2862 95595755 : output_asm_insn (templ, recog_data.operand);
2863 :
2864 : /* Some target machines need to postscan each insn after
2865 : it is output. */
2866 95595755 : if (targetm.asm_out.final_postscan_insn)
2867 0 : targetm.asm_out.final_postscan_insn (file, insn, recog_data.operand,
2868 0 : recog_data.n_operands);
2869 :
2870 95595755 : if (!targetm.asm_out.unwind_emit_before_insn
2871 0 : && targetm.asm_out.unwind_emit)
2872 0 : targetm.asm_out.unwind_emit (asm_out_file, insn);
2873 :
2874 : /* Let the debug info back-end know about this call. We do this only
2875 : after the instruction has been emitted because labels that may be
2876 : created to reference the call instruction must appear after it. */
2877 52825795 : if ((debug_variable_location_views || call_insn != NULL)
2878 98639055 : && !DECL_IGNORED_P (current_function_decl))
2879 45781422 : debug_hooks->var_location (insn);
2880 :
2881 95595755 : current_output_insn = debug_insn = 0;
2882 : }
2883 : }
2884 276081724 : return NEXT_INSN (insn);
2885 : }
2886 :
2887 : /* This is a wrapper around final_scan_insn_1 that allows ports to
2888 : call it recursively without a known value for SEEN. The value is
2889 : saved at the outermost call, and recovered for recursive calls.
2890 : Recursive calls MUST pass NULL, or the same pointer if they can
2891 : otherwise get to it. */
2892 :
2893 : rtx_insn *
2894 276081724 : final_scan_insn (rtx_insn *insn, FILE *file, int optimize_p,
2895 : int nopeepholes, int *seen)
2896 : {
2897 276081724 : static int *enclosing_seen;
2898 276081724 : static int recursion_counter;
2899 :
2900 276081724 : gcc_assert (seen || recursion_counter);
2901 276081724 : gcc_assert (!recursion_counter || !seen || seen == enclosing_seen);
2902 :
2903 276081724 : if (!recursion_counter++)
2904 276081724 : enclosing_seen = seen;
2905 0 : else if (!seen)
2906 0 : seen = enclosing_seen;
2907 :
2908 276081724 : rtx_insn *ret = final_scan_insn_1 (insn, file, optimize_p, nopeepholes, seen);
2909 :
2910 276081724 : if (!--recursion_counter)
2911 276081724 : enclosing_seen = NULL;
2912 :
2913 276081724 : return ret;
2914 : }
2915 :
2916 :
2917 :
2918 : /* Map DECLs to instance discriminators. This is allocated and
2919 : defined in ada/gcc-interfaces/trans.cc, when compiling with -gnateS.
2920 : Mappings from this table are saved and restored for LTO, so
2921 : link-time compilation will have this map set, at least in
2922 : partitions containing at least one DECL with an associated instance
2923 : discriminator. */
2924 :
2925 : decl_to_instance_map_t *decl_to_instance_map;
2926 :
2927 : /* Return the instance number assigned to DECL. */
2928 :
2929 : static inline int
2930 0 : map_decl_to_instance (const_tree decl)
2931 : {
2932 0 : int *inst;
2933 :
2934 0 : if (!decl_to_instance_map || !decl || !DECL_P (decl))
2935 : return 0;
2936 :
2937 0 : inst = decl_to_instance_map->get (decl);
2938 :
2939 0 : if (!inst)
2940 : return 0;
2941 :
2942 0 : return *inst;
2943 : }
2944 :
2945 : /* Set DISCRIMINATOR to the appropriate value, possibly derived from LOC. */
2946 :
2947 : static inline int
2948 98058612 : compute_discriminator (location_t loc)
2949 : {
2950 98058612 : int discriminator;
2951 :
2952 98058612 : if (!decl_to_instance_map)
2953 98058612 : discriminator = get_discriminator_from_loc (loc);
2954 : else
2955 : {
2956 0 : tree block = LOCATION_BLOCK (loc);
2957 :
2958 0 : while (block && TREE_CODE (block) == BLOCK
2959 0 : && !inlined_function_outer_scope_p (block))
2960 0 : block = BLOCK_SUPERCONTEXT (block);
2961 :
2962 0 : tree decl;
2963 :
2964 0 : if (!block)
2965 0 : decl = current_function_decl;
2966 0 : else if (DECL_P (block))
2967 : decl = block;
2968 : else
2969 0 : decl = block_ultimate_origin (block);
2970 :
2971 0 : discriminator = map_decl_to_instance (decl);
2972 : }
2973 :
2974 98058612 : return discriminator;
2975 : }
2976 :
2977 : /* Return discriminator of the statement that produced this insn. */
2978 : int
2979 86574346 : insn_discriminator (const rtx_insn *insn)
2980 : {
2981 86574346 : return compute_discriminator (insn->location ());
2982 : }
2983 :
2984 : /* Return whether a source line note needs to be emitted before INSN.
2985 : Sets IS_STMT to TRUE if the line should be marked as a possible
2986 : breakpoint location. */
2987 :
2988 : static bool
2989 107124992 : notice_source_line (rtx_insn *insn, bool *is_stmt)
2990 : {
2991 107124992 : const char *filename;
2992 107124992 : int linenum, columnnum;
2993 107124992 : int discriminator;
2994 :
2995 107124992 : if (NOTE_MARKER_P (insn))
2996 : {
2997 11484283 : location_t loc = NOTE_MARKER_LOCATION (insn);
2998 11484283 : expanded_location xloc = expand_location (loc);
2999 11484283 : if (xloc.line == 0
3000 11484283 : && (LOCATION_LOCUS (loc) == UNKNOWN_LOCATION
3001 27 : || LOCATION_LOCUS (loc) == BUILTINS_LOCATION))
3002 17 : return false;
3003 :
3004 11484266 : filename = xloc.file;
3005 11484266 : linenum = xloc.line;
3006 11484266 : columnnum = xloc.column;
3007 11484266 : discriminator = compute_discriminator (loc);
3008 11484266 : force_source_line = true;
3009 11484266 : }
3010 95640709 : else if (insn->has_location ())
3011 : {
3012 86482871 : expanded_location xloc = insn_location (insn);
3013 86482871 : filename = xloc.file;
3014 86482871 : linenum = xloc.line;
3015 86482871 : columnnum = xloc.column;
3016 86482871 : discriminator = insn_discriminator (insn);
3017 : }
3018 : else
3019 : {
3020 : filename = NULL;
3021 : linenum = 0;
3022 : columnnum = 0;
3023 : discriminator = 0;
3024 : }
3025 :
3026 97967137 : if (filename == NULL)
3027 : return false;
3028 :
3029 97967137 : if (force_source_line
3030 85215195 : || filename != last_filename
3031 82145624 : || last_linenum != linenum
3032 69882954 : || (debug_column_info && last_columnnum != columnnum))
3033 : {
3034 32698683 : force_source_line = false;
3035 32698683 : last_filename = filename;
3036 32698683 : last_linenum = linenum;
3037 32698683 : last_columnnum = columnnum;
3038 32698683 : last_discriminator = discriminator;
3039 32698683 : if (is_stmt)
3040 12541474 : *is_stmt = true;
3041 32698683 : high_block_linenum = MAX (last_linenum, high_block_linenum);
3042 32698683 : high_function_linenum = MAX (last_linenum, high_function_linenum);
3043 32698683 : return true;
3044 : }
3045 :
3046 65268454 : if (SUPPORTS_DISCRIMINATOR && last_discriminator != discriminator)
3047 : {
3048 : /* If the discriminator changed, but the line number did not,
3049 : output the line table entry with is_stmt false so the
3050 : debugger does not treat this as a breakpoint location. */
3051 7107637 : last_discriminator = discriminator;
3052 7107637 : if (is_stmt)
3053 6539944 : *is_stmt = false;
3054 : return true;
3055 : }
3056 :
3057 : return false;
3058 : }
3059 :
3060 : /* For each operand in INSN, simplify (subreg (reg)) so that it refers
3061 : directly to the desired hard register. */
3062 :
3063 : void
3064 104273277 : cleanup_subreg_operands (rtx_insn *insn)
3065 : {
3066 104273277 : int i;
3067 104273277 : bool changed = false;
3068 104273277 : extract_insn_cached (insn);
3069 426706744 : for (i = 0; i < recog_data.n_operands; i++)
3070 : {
3071 : /* The following test cannot use recog_data.operand when testing
3072 : for a SUBREG: the underlying object might have been changed
3073 : already if we are inside a match_operator expression that
3074 : matches the else clause. Instead we test the underlying
3075 : expression directly. */
3076 218160190 : if (GET_CODE (*recog_data.operand_loc[i]) == SUBREG)
3077 : {
3078 235 : recog_data.operand[i] = alter_subreg (recog_data.operand_loc[i], true);
3079 235 : changed = true;
3080 : }
3081 218159955 : else if (GET_CODE (recog_data.operand[i]) == PLUS
3082 : || GET_CODE (recog_data.operand[i]) == MULT
3083 : || MEM_P (recog_data.operand[i]))
3084 50937338 : recog_data.operand[i] = walk_alter_subreg (recog_data.operand_loc[i], &changed);
3085 : }
3086 :
3087 106465037 : for (i = 0; i < recog_data.n_dups; i++)
3088 : {
3089 2191760 : if (GET_CODE (*recog_data.dup_loc[i]) == SUBREG)
3090 : {
3091 0 : *recog_data.dup_loc[i] = alter_subreg (recog_data.dup_loc[i], true);
3092 0 : changed = true;
3093 : }
3094 : else if (GET_CODE (*recog_data.dup_loc[i]) == PLUS
3095 : || GET_CODE (*recog_data.dup_loc[i]) == MULT
3096 : || MEM_P (*recog_data.dup_loc[i]))
3097 587565 : *recog_data.dup_loc[i] = walk_alter_subreg (recog_data.dup_loc[i], &changed);
3098 : }
3099 104273277 : if (changed)
3100 235 : df_insn_rescan (insn);
3101 104273277 : }
3102 :
3103 : /* If X is a SUBREG, try to replace it with a REG or a MEM, based on
3104 : the thing it is a subreg of. Do it anyway if FINAL_P. */
3105 :
3106 : rtx
3107 3368751 : alter_subreg (rtx *xp, bool final_p)
3108 : {
3109 3368751 : rtx x = *xp;
3110 3368751 : rtx y = SUBREG_REG (x);
3111 :
3112 : /* simplify_subreg does not remove subreg from volatile references.
3113 : We are required to. */
3114 3368751 : if (MEM_P (y))
3115 : {
3116 235392 : poly_int64 offset = SUBREG_BYTE (x);
3117 :
3118 : /* For paradoxical subregs on big-endian machines, SUBREG_BYTE
3119 : contains 0 instead of the proper offset. See simplify_subreg. */
3120 235392 : if (paradoxical_subreg_p (x))
3121 33612 : offset = byte_lowpart_offset (GET_MODE (x), GET_MODE (y));
3122 :
3123 235392 : if (final_p)
3124 110 : *xp = adjust_address (y, GET_MODE (x), offset);
3125 : else
3126 235282 : *xp = adjust_address_nv (y, GET_MODE (x), offset);
3127 : }
3128 3133359 : else if (REG_P (y) && HARD_REGISTER_P (y))
3129 : {
3130 6266718 : rtx new_rtx = simplify_subreg (GET_MODE (x), y, GET_MODE (y),
3131 3133359 : SUBREG_BYTE (x));
3132 :
3133 3133359 : if (new_rtx != 0)
3134 3127708 : *xp = new_rtx;
3135 5651 : else if (final_p && REG_P (y))
3136 : {
3137 : /* Simplify_subreg can't handle some REG cases, but we have to. */
3138 2173 : unsigned int regno;
3139 2173 : poly_int64 offset;
3140 :
3141 2173 : regno = subreg_regno (x);
3142 2173 : if (subreg_lowpart_p (x))
3143 2173 : offset = byte_lowpart_offset (GET_MODE (x), GET_MODE (y));
3144 : else
3145 0 : offset = SUBREG_BYTE (x);
3146 2173 : *xp = gen_rtx_REG_offset (y, GET_MODE (x), regno, offset);
3147 : }
3148 : }
3149 :
3150 3368751 : return *xp;
3151 : }
3152 :
3153 : /* Do alter_subreg on all the SUBREGs contained in X. */
3154 :
3155 : static rtx
3156 173055835 : walk_alter_subreg (rtx *xp, bool *changed)
3157 : {
3158 173055835 : rtx x = *xp;
3159 173055835 : switch (GET_CODE (x))
3160 : {
3161 36097514 : case PLUS:
3162 36097514 : case MULT:
3163 36097514 : case AND:
3164 36097514 : case ASHIFT:
3165 36097514 : XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0), changed);
3166 36097514 : XEXP (x, 1) = walk_alter_subreg (&XEXP (x, 1), changed);
3167 36097514 : break;
3168 :
3169 45318250 : case MEM:
3170 45318250 : case ZERO_EXTEND:
3171 45318250 : XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0), changed);
3172 45318250 : break;
3173 :
3174 0 : case SUBREG:
3175 0 : *changed = true;
3176 0 : return alter_subreg (xp, true);
3177 :
3178 : default:
3179 : break;
3180 : }
3181 :
3182 173055835 : return *xp;
3183 : }
3184 :
3185 : /* Report inconsistency between the assembler template and the operands.
3186 : In an `asm', it's the user's fault; otherwise, the compiler's fault. */
3187 :
3188 : void
3189 23 : output_operand_lossage (const char *cmsgid, ...)
3190 : {
3191 23 : char *fmt_string;
3192 23 : char *new_message;
3193 23 : const char *pfx_str;
3194 23 : va_list ap;
3195 :
3196 23 : va_start (ap, cmsgid);
3197 :
3198 23 : pfx_str = this_is_asm_operands ? _("invalid 'asm': ") : "output_operand: ";
3199 23 : fmt_string = xasprintf ("%s%s", pfx_str, _(cmsgid));
3200 23 : new_message = xvasprintf (fmt_string, ap);
3201 :
3202 23 : if (this_is_asm_operands)
3203 23 : error_for_asm (this_is_asm_operands, "%s", new_message);
3204 : else
3205 0 : internal_error ("%s", new_message);
3206 :
3207 23 : free (fmt_string);
3208 23 : free (new_message);
3209 23 : va_end (ap);
3210 23 : }
3211 :
3212 : /* Output of assembler code from a template, and its subroutines. */
3213 :
3214 : /* Annotate the assembly with a comment describing the pattern and
3215 : alternative used. */
3216 :
3217 : static void
3218 3536 : output_asm_name (void)
3219 : {
3220 3536 : if (debug_insn)
3221 : {
3222 3382 : fprintf (asm_out_file, "\t%s %d\t",
3223 3382 : ASM_COMMENT_START, INSN_UID (debug_insn));
3224 :
3225 3382 : fprintf (asm_out_file, "[c=%d",
3226 : insn_cost (debug_insn, optimize_insn_for_speed_p ()));
3227 3382 : if (HAVE_ATTR_length)
3228 3382 : fprintf (asm_out_file, " l=%d",
3229 : get_attr_length (debug_insn));
3230 3382 : fprintf (asm_out_file, "] ");
3231 :
3232 3382 : int num = INSN_CODE (debug_insn);
3233 3382 : fprintf (asm_out_file, "%s", insn_data[num].name);
3234 3382 : if (insn_data[num].n_alternatives > 1)
3235 1967 : fprintf (asm_out_file, "/%d", which_alternative);
3236 :
3237 : /* Clear this so only the first assembler insn
3238 : of any rtl insn will get the special comment for -dp. */
3239 3382 : debug_insn = 0;
3240 : }
3241 3536 : }
3242 :
3243 : /* If OP is a REG or MEM and we can find a MEM_EXPR corresponding to it
3244 : or its address, return that expr . Set *PADDRESSP to 1 if the expr
3245 : corresponds to the address of the object and 0 if to the object. */
3246 :
3247 : static tree
3248 406 : get_mem_expr_from_op (rtx op, int *paddressp)
3249 : {
3250 406 : tree expr;
3251 406 : int inner_addressp;
3252 :
3253 406 : *paddressp = 0;
3254 :
3255 406 : if (REG_P (op))
3256 259 : return REG_EXPR (op);
3257 147 : else if (!MEM_P (op))
3258 : return 0;
3259 :
3260 51 : if (MEM_EXPR (op) != 0)
3261 : return MEM_EXPR (op);
3262 :
3263 : /* Otherwise we have an address, so indicate it and look at the address. */
3264 0 : *paddressp = 1;
3265 0 : op = XEXP (op, 0);
3266 :
3267 : /* First check if we have a decl for the address, then look at the right side
3268 : if it is a PLUS. Otherwise, strip off arithmetic and keep looking.
3269 : But don't allow the address to itself be indirect. */
3270 0 : if ((expr = get_mem_expr_from_op (op, &inner_addressp)) && ! inner_addressp)
3271 : return expr;
3272 0 : else if (GET_CODE (op) == PLUS
3273 0 : && (expr = get_mem_expr_from_op (XEXP (op, 1), &inner_addressp)))
3274 : return expr;
3275 :
3276 0 : while (UNARY_P (op)
3277 0 : || GET_RTX_CLASS (GET_CODE (op)) == RTX_BIN_ARITH)
3278 0 : op = XEXP (op, 0);
3279 :
3280 0 : expr = get_mem_expr_from_op (op, &inner_addressp);
3281 0 : return inner_addressp ? 0 : expr;
3282 : }
3283 :
3284 : /* Output operand names for assembler instructions. OPERANDS is the
3285 : operand vector, OPORDER is the order to write the operands, and NOPS
3286 : is the number of operands to write. */
3287 :
3288 : static void
3289 248 : output_asm_operand_names (rtx *operands, int *oporder, int nops)
3290 : {
3291 248 : int wrote = 0;
3292 248 : int i;
3293 :
3294 654 : for (i = 0; i < nops; i++)
3295 : {
3296 406 : int addressp;
3297 406 : int opnum = oporder[i];
3298 : /* Skip invalid ops. */
3299 406 : if (opnum == MAX_RECOG_OPERANDS)
3300 0 : continue;
3301 406 : rtx op = operands[opnum];
3302 406 : tree expr = get_mem_expr_from_op (op, &addressp);
3303 :
3304 634 : fprintf (asm_out_file, "%c%s",
3305 : wrote ? ',' : '\t', wrote ? "" : ASM_COMMENT_START);
3306 406 : wrote = 1;
3307 406 : if (expr)
3308 : {
3309 231 : fprintf (asm_out_file, "%s",
3310 231 : addressp ? "*" : "");
3311 231 : print_mem_expr (asm_out_file, expr);
3312 231 : wrote = 1;
3313 : }
3314 79 : else if (REG_P (op) && ORIGINAL_REGNO (op)
3315 243 : && ORIGINAL_REGNO (op) != REGNO (op))
3316 41 : fprintf (asm_out_file, " tmp%i", ORIGINAL_REGNO (op));
3317 : }
3318 248 : }
3319 :
3320 : #ifdef ASSEMBLER_DIALECT
3321 : /* Helper function to parse assembler dialects in the asm string.
3322 : This is called from output_asm_insn and asm_fprintf. */
3323 : static const char *
3324 261098738 : do_assembler_dialects (const char *p, int *dialect)
3325 : {
3326 261098738 : char c = *(p - 1);
3327 :
3328 261098738 : switch (c)
3329 : {
3330 130549368 : case '{':
3331 130549368 : {
3332 130549368 : int i;
3333 :
3334 130549368 : if (*dialect)
3335 0 : output_operand_lossage ("nested assembly dialect alternatives");
3336 : else
3337 130549368 : *dialect = 1;
3338 :
3339 : /* If we want the first dialect, do nothing. Otherwise, skip
3340 : DIALECT_NUMBER of strings ending with '|'. */
3341 130550469 : for (i = 0; i < dialect_number; i++)
3342 : {
3343 9311 : while (*p && *p != '}')
3344 : {
3345 8733 : if (*p == '|')
3346 : {
3347 1102 : p++;
3348 1102 : break;
3349 : }
3350 :
3351 : /* Skip over any character after a percent sign. */
3352 7631 : if (*p == '%')
3353 2722 : p++;
3354 7631 : if (*p)
3355 7631 : p++;
3356 : }
3357 :
3358 1680 : if (*p == '}')
3359 : break;
3360 : }
3361 :
3362 130549368 : if (*p == '\0')
3363 0 : output_operand_lossage ("unterminated assembly dialect alternative");
3364 : }
3365 : break;
3366 :
3367 66980511 : case '|':
3368 66980511 : if (*dialect)
3369 : {
3370 : /* Skip to close brace. */
3371 355877122 : do
3372 : {
3373 355877122 : if (*p == '\0')
3374 : {
3375 0 : output_operand_lossage ("unterminated assembly dialect alternative");
3376 0 : break;
3377 : }
3378 :
3379 : /* Skip over any character after a percent sign. */
3380 355877122 : if (*p == '%' && p[1])
3381 : {
3382 131269453 : p += 2;
3383 131269453 : continue;
3384 : }
3385 :
3386 224607669 : if (*p++ == '}')
3387 : break;
3388 : }
3389 : while (1);
3390 :
3391 66980510 : *dialect = 0;
3392 : }
3393 : else
3394 1 : putc (c, asm_out_file);
3395 : break;
3396 :
3397 63568859 : case '}':
3398 63568859 : if (! *dialect)
3399 1 : putc (c, asm_out_file);
3400 63568859 : *dialect = 0;
3401 63568859 : break;
3402 0 : default:
3403 0 : gcc_unreachable ();
3404 : }
3405 :
3406 261098738 : return p;
3407 : }
3408 : #endif
3409 :
3410 : static rtx *current_modifier_operands;
3411 : static const vec<unsigned long> *current_modifier_opnums;
3412 :
3413 : /* Return the Nth operand of the current multi-operand modifier. */
3414 :
3415 : rtx
3416 12 : output_operand_modifier_operand (int code, unsigned int n)
3417 : {
3418 12 : if (code < PRINT_OPERAND_MODIFIER_BASE
3419 12 : || !current_modifier_opnums
3420 24 : || n >= current_modifier_opnums->length ())
3421 : return nullptr;
3422 8 : rtx x = current_modifier_operands[(*current_modifier_opnums)[n]];
3423 8 : if (x && GET_CODE (x) == SUBREG)
3424 0 : x = alter_subreg (&x, true);
3425 8 : if (x)
3426 8 : mark_symbol_refs_as_used (x);
3427 8 : return x;
3428 : }
3429 :
3430 : /* Output OPERAND, which was parsed from a %[...] reference. */
3431 :
3432 : static void
3433 156 : output_bracketed_operand (bracketed_operand &operand, rtx *operands,
3434 : int *oporder, char *opoutput, int &ops)
3435 : {
3436 156 : if (this_is_asm_operands)
3437 624 : for (unsigned long opnum : operand.opnums)
3438 156 : if (opnum >= insn_noperands)
3439 : {
3440 0 : output_operand_lossage ("operand number out of range");
3441 0 : return;
3442 : }
3443 156 : unsigned long opnum = operand.opnums[0];
3444 156 : if (!operand.modifier.empty ())
3445 : {
3446 0 : int code = targetm.asm_out.print_operand_modifier
3447 0 : (operand.modifier, this_is_asm_operands != NULL);
3448 0 : if (code < PRINT_OPERAND_MODIFIER_BASE)
3449 : {
3450 0 : output_operand_lossage ("invalid operand modifier '%.*s'",
3451 0 : (int) operand.modifier.size (),
3452 : operand.modifier.begin ());
3453 0 : return;
3454 : }
3455 0 : rtx *saved_operands = current_modifier_operands;
3456 0 : const vec<unsigned long> *saved_opnums = current_modifier_opnums;
3457 0 : current_modifier_operands = operands;
3458 0 : current_modifier_opnums = &operand.opnums;
3459 0 : output_operand (operands[opnum], code);
3460 0 : current_modifier_operands = saved_operands;
3461 0 : current_modifier_opnums = saved_opnums;
3462 : }
3463 : else
3464 156 : output_operand (operands[opnum], 0);
3465 :
3466 624 : for (unsigned long number : operand.opnums)
3467 : {
3468 156 : if (!opoutput[number])
3469 154 : oporder[ops++] = number;
3470 156 : opoutput[number] = 1;
3471 : }
3472 : }
3473 :
3474 : /* Output text from TEMPLATE to the assembler output file,
3475 : obeying %-directions to substitute operands taken from
3476 : the vector OPERANDS.
3477 :
3478 : %N (for N a digit) means print operand N in usual manner.
3479 : %lN means require operand N to be a CODE_LABEL or LABEL_REF
3480 : and print the label name with no punctuation.
3481 : %cN means require operand N to be a constant
3482 : and print the constant expression with no punctuation.
3483 : %aN means expect operand N to be a memory address
3484 : (not a memory reference!) and print a reference
3485 : to that address.
3486 : %nN means expect operand N to be a constant
3487 : and print a constant expression for minus the value
3488 : of the operand, with no other punctuation. */
3489 :
3490 : void
3491 108020242 : output_asm_insn (const char *templ, rtx *operands)
3492 : {
3493 108020242 : const char *p;
3494 108020242 : int c;
3495 : #ifdef ASSEMBLER_DIALECT
3496 108020242 : int dialect = 0;
3497 : #endif
3498 108020242 : int oporder[MAX_RECOG_OPERANDS+1];
3499 108020242 : char opoutput[MAX_RECOG_OPERANDS+1];
3500 108020242 : int ops = 0;
3501 :
3502 : /* An insn may return a null string template
3503 : in a case where no assembler code is needed. */
3504 108020242 : if (*templ == 0)
3505 13257075 : return;
3506 :
3507 94763167 : memset (opoutput, 0, sizeof opoutput);
3508 94763167 : p = templ;
3509 94763167 : putc ('\t', asm_out_file);
3510 :
3511 : #ifdef ASM_OUTPUT_OPCODE
3512 102492478 : ASM_OUTPUT_OPCODE (asm_out_file, p);
3513 : #endif
3514 :
3515 1163246356 : while ((c = *p++))
3516 1068483189 : switch (c)
3517 : {
3518 39367 : case '\n':
3519 39367 : if (flag_verbose_asm)
3520 0 : output_asm_operand_names (operands, oporder, ops);
3521 39367 : if (flag_print_asm_name)
3522 74 : output_asm_name ();
3523 :
3524 39367 : ops = 0;
3525 39367 : memset (opoutput, 0, sizeof opoutput);
3526 :
3527 39367 : putc (c, asm_out_file);
3528 : #ifdef ASM_OUTPUT_OPCODE
3529 114587 : while ((c = *p) == '\t')
3530 : {
3531 35853 : putc (c, asm_out_file);
3532 35853 : p++;
3533 : }
3534 39367 : ASM_OUTPUT_OPCODE (asm_out_file, p);
3535 : #endif
3536 : break;
3537 :
3538 : #ifdef ASSEMBLER_DIALECT
3539 261098738 : case '{':
3540 261098738 : case '}':
3541 261098738 : case '|':
3542 261098738 : p = do_assembler_dialects (p, &dialect);
3543 261098738 : break;
3544 : #endif
3545 :
3546 192156940 : case '%':
3547 : /* %% outputs a single %. %{, %} and %| print {, } and | respectively
3548 : if ASSEMBLER_DIALECT defined and these characters have a special
3549 : meaning as dialect delimiters.*/
3550 192156940 : if (*p == '%'
3551 : #ifdef ASSEMBLER_DIALECT
3552 192141683 : || *p == '{' || *p == '}' || *p == '|'
3553 : #endif
3554 : )
3555 : {
3556 135575 : putc (*p, asm_out_file);
3557 135575 : p++;
3558 : }
3559 : /* %= outputs a number which is unique to each insn in the entire
3560 : compilation. This is useful for making local labels that are
3561 : referred to more than once in a given insn. */
3562 192021365 : else if (*p == '=')
3563 : {
3564 19 : p++;
3565 19 : fprintf (asm_out_file, "%d", insn_counter);
3566 : }
3567 192021346 : else if (*p == '[')
3568 : {
3569 156 : bracketed_operand operand;
3570 156 : if (!parse_bracketed_operand (&p, operand))
3571 : {
3572 0 : output_operand_lossage ("invalid %%[...] operand modifier");
3573 0 : break;
3574 : }
3575 156 : output_bracketed_operand (operand, operands, oporder, opoutput,
3576 : ops);
3577 156 : c = *p;
3578 156 : }
3579 : /* % followed by a letter and some digits
3580 : outputs an operand in a special way depending on the letter.
3581 : Letters `acln' are implemented directly.
3582 : Other letters are passed to `output_operand' so that
3583 : the TARGET_PRINT_OPERAND hook can define them. */
3584 192021190 : else if (ISALPHA (*p))
3585 : {
3586 50610920 : int letter = *p++;
3587 50610920 : unsigned long opnum;
3588 50610920 : char *endptr;
3589 50610920 : int letter2 = 0;
3590 :
3591 50610920 : if (letter == 'c' && *p == 'c')
3592 98 : letter2 = *p++;
3593 50610920 : opnum = strtoul (p, &endptr, 10);
3594 :
3595 50610920 : if (endptr == p)
3596 0 : output_operand_lossage ("operand number missing "
3597 : "after %%-letter");
3598 50610920 : else if (this_is_asm_operands && opnum >= insn_noperands)
3599 : {
3600 : /* Force the opnum in bounds to a bogus location. */
3601 4 : opnum = MAX_RECOG_OPERANDS;
3602 4 : output_operand_lossage ("operand number out of range");
3603 : }
3604 50610916 : else if (letter == 'l')
3605 8958028 : output_asm_label (operands[opnum]);
3606 41652888 : else if (letter == 'a')
3607 2283 : output_address (VOIDmode, operands[opnum]);
3608 41650605 : else if (letter == 'c')
3609 : {
3610 247418 : if (letter2 == 'c' || CONSTANT_ADDRESS_P (operands[opnum]))
3611 1559 : output_addr_const (asm_out_file, operands[opnum]);
3612 : else
3613 245859 : output_operand (operands[opnum], 'c');
3614 : }
3615 41403187 : else if (letter == 'n')
3616 : {
3617 0 : if (CONST_INT_P (operands[opnum]))
3618 0 : fprintf (asm_out_file, HOST_WIDE_INT_PRINT_DEC,
3619 0 : - INTVAL (operands[opnum]));
3620 : else
3621 : {
3622 0 : putc ('-', asm_out_file);
3623 0 : output_addr_const (asm_out_file, operands[opnum]);
3624 : }
3625 : }
3626 : else
3627 41403187 : output_operand (operands[opnum], letter);
3628 :
3629 50610920 : if (!opoutput[opnum])
3630 48237286 : oporder[ops++] = opnum;
3631 50610920 : opoutput[opnum] = 1;
3632 :
3633 50610920 : p = endptr;
3634 50610920 : c = *p;
3635 : }
3636 : /* % followed by a digit outputs an operand the default way. */
3637 141410270 : else if (ISDIGIT (*p))
3638 : {
3639 119324907 : unsigned long opnum;
3640 119324907 : char *endptr;
3641 :
3642 119324907 : opnum = strtoul (p, &endptr, 10);
3643 119324907 : if (this_is_asm_operands && opnum >= insn_noperands)
3644 : {
3645 : /* Force the opnum in bounds to a bogus location. */
3646 3 : opnum = MAX_RECOG_OPERANDS;
3647 3 : output_operand_lossage ("operand number out of range");
3648 : }
3649 : else
3650 119324904 : output_operand (operands[opnum], 0);
3651 :
3652 119324907 : if (!opoutput[opnum])
3653 116952944 : oporder[ops++] = opnum;
3654 119324907 : opoutput[opnum] = 1;
3655 :
3656 119324907 : p = endptr;
3657 119324907 : c = *p;
3658 : }
3659 : /* % followed by punctuation: output something for that
3660 : punctuation character alone, with no operand. The
3661 : TARGET_PRINT_OPERAND hook decides what is actually done. */
3662 22085363 : else if (targetm.asm_out.print_operand_punct_valid_p ((unsigned char) *p))
3663 22085363 : output_operand (NULL_RTX, *p++);
3664 : else
3665 0 : output_operand_lossage ("invalid %%-code");
3666 : break;
3667 :
3668 615188144 : default:
3669 615188144 : putc (c, asm_out_file);
3670 : }
3671 :
3672 : /* Try to keep the asm a bit more readable. */
3673 94763167 : if ((flag_verbose_asm || flag_print_asm_name) && strlen (templ) < 9)
3674 415 : putc ('\t', asm_out_file);
3675 :
3676 : /* Write out the variable names for operands, if we know them. */
3677 94763167 : if (flag_verbose_asm)
3678 248 : output_asm_operand_names (operands, oporder, ops);
3679 94763167 : if (flag_print_asm_name)
3680 3462 : output_asm_name ();
3681 :
3682 94763167 : putc ('\n', asm_out_file);
3683 : }
3684 :
3685 : /* Output a LABEL_REF, or a bare CODE_LABEL, as an assembler symbol. */
3686 :
3687 : void
3688 8965739 : output_asm_label (rtx x)
3689 : {
3690 8965739 : char buf[256];
3691 :
3692 8965739 : if (GET_CODE (x) == LABEL_REF)
3693 7871 : x = label_ref_label (x);
3694 8965739 : rtx_note *note = dyn_cast<rtx_note *> (x);
3695 8965739 : if (LABEL_P (x)
3696 105 : || (note
3697 105 : && NOTE_KIND (note) == NOTE_INSN_DELETED_LABEL))
3698 8965739 : ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (x));
3699 : else
3700 0 : output_operand_lossage ("'%%l' operand isn't a label");
3701 :
3702 8965739 : assemble_name (asm_out_file, buf);
3703 8965739 : }
3704 :
3705 : /* Marks SYMBOL_REFs in x as referenced through use of assemble_external. */
3706 :
3707 : void
3708 160974114 : mark_symbol_refs_as_used (rtx x)
3709 : {
3710 160974114 : subrtx_iterator::array_type array;
3711 439390549 : FOR_EACH_SUBRTX (iter, array, x, ALL)
3712 : {
3713 278416435 : const_rtx x = *iter;
3714 278416435 : if (GET_CODE (x) == SYMBOL_REF)
3715 16424376 : if (tree t = SYMBOL_REF_DECL (x))
3716 15220321 : assemble_external (t);
3717 : }
3718 160974114 : }
3719 :
3720 : /* Print operand X using machine-dependent assembler syntax.
3721 : CODE is a non-digit that preceded the operand-number in the % spec,
3722 : such as 'z' if the spec was `%z3'. CODE is 0 if there was no char
3723 : between the % and the digits.
3724 : When CODE is a non-letter, X is 0.
3725 :
3726 : The meanings of the letters are machine-dependent and controlled
3727 : by TARGET_PRINT_OPERAND. */
3728 :
3729 : void
3730 183059469 : output_operand (rtx x, int code ATTRIBUTE_UNUSED)
3731 : {
3732 183059469 : if (x && GET_CODE (x) == SUBREG)
3733 0 : x = alter_subreg (&x, true);
3734 :
3735 : /* X must not be a pseudo reg. */
3736 183059469 : if (!targetm.no_register_allocation)
3737 183059469 : gcc_assert (!x || !REG_P (x) || REGNO (x) < FIRST_PSEUDO_REGISTER);
3738 :
3739 183059469 : targetm.asm_out.print_operand (asm_out_file, x, code);
3740 :
3741 183059469 : if (x == NULL_RTX)
3742 : return;
3743 :
3744 160974106 : mark_symbol_refs_as_used (x);
3745 : }
3746 :
3747 : /* Print a memory reference operand for address X using
3748 : machine-dependent assembler syntax. */
3749 :
3750 : void
3751 4017654 : output_address (machine_mode mode, rtx x)
3752 : {
3753 4017654 : bool changed = false;
3754 4017654 : walk_alter_subreg (&x, &changed);
3755 4017654 : targetm.asm_out.print_operand_address (asm_out_file, mode, x);
3756 4017654 : }
3757 :
3758 : /* Print an integer constant expression in assembler syntax.
3759 : Addition and subtraction are the only arithmetic
3760 : that may appear in these expressions. */
3761 :
3762 : void
3763 168211709 : output_addr_const (FILE *file, rtx x)
3764 : {
3765 178899760 : char buf[256];
3766 :
3767 178899760 : restart:
3768 178899760 : switch (GET_CODE (x))
3769 : {
3770 541 : case PC:
3771 541 : putc ('.', file);
3772 541 : break;
3773 :
3774 128803456 : case SYMBOL_REF:
3775 128803456 : if (SYMBOL_REF_DECL (x))
3776 21086657 : assemble_external (SYMBOL_REF_DECL (x));
3777 : #ifdef ASM_OUTPUT_SYMBOL_REF
3778 128803456 : ASM_OUTPUT_SYMBOL_REF (file, x);
3779 : #else
3780 : assemble_name (file, XSTR (x, 0));
3781 : #endif
3782 : break;
3783 :
3784 15120 : case LABEL_REF:
3785 15120 : x = label_ref_label (x);
3786 : /* Fall through. */
3787 15120 : case CODE_LABEL:
3788 15120 : ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (x));
3789 : #ifdef ASM_OUTPUT_LABEL_REF
3790 : ASM_OUTPUT_LABEL_REF (file, buf);
3791 : #else
3792 15120 : assemble_name (file, buf);
3793 : #endif
3794 15120 : break;
3795 :
3796 39377679 : case CONST_INT:
3797 39377679 : fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (x));
3798 39377679 : break;
3799 :
3800 2753382 : case CONST:
3801 : /* This used to output parentheses around the expression,
3802 : but that does not work on the 386 (either ATT or BSD assembler). */
3803 2753382 : output_addr_const (file, XEXP (x, 0));
3804 2753382 : break;
3805 :
3806 2 : case CONST_WIDE_INT:
3807 : /* We do not know the mode here so we have to use a round about
3808 : way to build a wide-int to get it printed properly. */
3809 2 : {
3810 2 : wide_int w = wide_int::from_array (&CONST_WIDE_INT_ELT (x, 0),
3811 2 : CONST_WIDE_INT_NUNITS (x),
3812 2 : CONST_WIDE_INT_NUNITS (x)
3813 2 : * HOST_BITS_PER_WIDE_INT,
3814 2 : false);
3815 2 : print_decs (w, file);
3816 2 : }
3817 2 : break;
3818 :
3819 0 : case CONST_DOUBLE:
3820 0 : if (CONST_DOUBLE_AS_INT_P (x))
3821 : {
3822 : /* We can use %d if the number is one word and positive. */
3823 0 : if (CONST_DOUBLE_HIGH (x))
3824 0 : fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3825 : (unsigned HOST_WIDE_INT) CONST_DOUBLE_HIGH (x),
3826 0 : (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (x));
3827 0 : else if (CONST_DOUBLE_LOW (x) < 0)
3828 0 : fprintf (file, HOST_WIDE_INT_PRINT_HEX,
3829 : (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (x));
3830 : else
3831 0 : fprintf (file, HOST_WIDE_INT_PRINT_DEC, CONST_DOUBLE_LOW (x));
3832 : }
3833 : else
3834 : /* We can't handle floating point constants;
3835 : PRINT_OPERAND must handle them. */
3836 0 : output_operand_lossage ("floating constant misused");
3837 : break;
3838 :
3839 0 : case CONST_FIXED:
3840 0 : fprintf (file, HOST_WIDE_INT_PRINT_DEC, CONST_FIXED_VALUE_LOW (x));
3841 0 : break;
3842 :
3843 2773606 : case PLUS:
3844 : /* Some assemblers need integer constants to appear last (eg masm). */
3845 2773606 : if (CONST_INT_P (XEXP (x, 0)))
3846 : {
3847 0 : output_addr_const (file, XEXP (x, 1));
3848 0 : if (INTVAL (XEXP (x, 0)) >= 0)
3849 0 : fprintf (file, "+");
3850 0 : output_addr_const (file, XEXP (x, 0));
3851 : }
3852 : else
3853 : {
3854 2773606 : output_addr_const (file, XEXP (x, 0));
3855 2773606 : if (!CONST_INT_P (XEXP (x, 1))
3856 2773606 : || INTVAL (XEXP (x, 1)) >= 0)
3857 2746894 : fprintf (file, "+");
3858 2773606 : output_addr_const (file, XEXP (x, 1));
3859 : }
3860 : break;
3861 :
3862 5161069 : case MINUS:
3863 : /* Avoid outputting things like x-x or x+5-x,
3864 : since some assemblers can't handle that. */
3865 5161069 : x = simplify_subtraction (x);
3866 5161069 : if (GET_CODE (x) != MINUS)
3867 0 : goto restart;
3868 :
3869 5161069 : output_addr_const (file, XEXP (x, 0));
3870 5161069 : fprintf (file, "-");
3871 5161069 : if ((CONST_INT_P (XEXP (x, 1)) && INTVAL (XEXP (x, 1)) >= 0)
3872 : || GET_CODE (XEXP (x, 1)) == PC
3873 : || GET_CODE (XEXP (x, 1)) == SYMBOL_REF
3874 : || GET_CODE (XEXP (x, 1)) == LABEL_REF
3875 : || GET_CODE (XEXP (x, 1)) == CODE_LABEL)
3876 : output_addr_const (file, XEXP (x, 1));
3877 : else
3878 : {
3879 6 : fputs (targetm.asm_out.open_paren, file);
3880 6 : output_addr_const (file, XEXP (x, 1));
3881 6 : fputs (targetm.asm_out.close_paren, file);
3882 : }
3883 : break;
3884 :
3885 0 : case ZERO_EXTEND:
3886 0 : case SIGN_EXTEND:
3887 0 : case SUBREG:
3888 0 : case TRUNCATE:
3889 0 : output_addr_const (file, XEXP (x, 0));
3890 0 : break;
3891 :
3892 14905 : default:
3893 14905 : if (targetm.asm_out.output_addr_const_extra (file, x))
3894 : break;
3895 :
3896 0 : output_operand_lossage ("invalid expression as operand");
3897 : }
3898 168211709 : }
3899 :
3900 : /* Output a quoted string. */
3901 :
3902 : void
3903 1609782 : output_quoted_string (FILE *asm_file, const char *string)
3904 : {
3905 : #ifdef OUTPUT_QUOTED_STRING
3906 : OUTPUT_QUOTED_STRING (asm_file, string);
3907 : #else
3908 1609782 : char c;
3909 :
3910 1609782 : putc ('\"', asm_file);
3911 95833712 : while ((c = *string++) != 0)
3912 : {
3913 92614148 : if (ISPRINT (c))
3914 : {
3915 92614136 : if (c == '\"' || c == '\\')
3916 15 : putc ('\\', asm_file);
3917 92614136 : putc (c, asm_file);
3918 : }
3919 : else
3920 12 : fprintf (asm_file, "\\%03o", (unsigned char) c);
3921 : }
3922 1609782 : putc ('\"', asm_file);
3923 : #endif
3924 1609782 : }
3925 :
3926 : /* Write a HOST_WIDE_INT number in hex form 0x1234, fast. */
3927 :
3928 : void
3929 517882590 : fprint_whex (FILE *f, unsigned HOST_WIDE_INT value)
3930 : {
3931 517882590 : char buf[2 + CHAR_BIT * sizeof (value) / 4];
3932 517882590 : if (value == 0)
3933 49523410 : putc ('0', f);
3934 : else
3935 : {
3936 : char *p = buf + sizeof (buf);
3937 978197225 : do
3938 978197225 : *--p = "0123456789abcdef"[value % 16];
3939 978197225 : while ((value /= 16) != 0);
3940 468359180 : *--p = 'x';
3941 468359180 : *--p = '0';
3942 468359180 : fwrite (p, 1, buf + sizeof (buf) - p, f);
3943 : }
3944 517882590 : }
3945 :
3946 : /* Internal function that prints an unsigned long in decimal in reverse.
3947 : The output string IS NOT null-terminated. */
3948 :
3949 : static int
3950 448932671 : sprint_ul_rev (char *s, unsigned long value)
3951 : {
3952 0 : int i = 0;
3953 1395870961 : do
3954 : {
3955 1395870961 : s[i] = "0123456789"[value % 10];
3956 1395870961 : value /= 10;
3957 1395870961 : i++;
3958 : /* alternate version, without modulo */
3959 : /* oldval = value; */
3960 : /* value /= 10; */
3961 : /* s[i] = "0123456789" [oldval - 10*value]; */
3962 : /* i++ */
3963 : }
3964 1395870961 : while (value != 0);
3965 328277485 : return i;
3966 : }
3967 :
3968 : /* Write an unsigned long as decimal to a file, fast. */
3969 :
3970 : void
3971 120655186 : fprint_ul (FILE *f, unsigned long value)
3972 : {
3973 : /* python says: len(str(2**64)) == 20 */
3974 120655186 : char s[20];
3975 120655186 : int i;
3976 :
3977 120655186 : i = sprint_ul_rev (s, value);
3978 :
3979 : /* It's probably too small to bother with string reversal and fputs. */
3980 234131975 : do
3981 : {
3982 234131975 : i--;
3983 234131975 : putc (s[i], f);
3984 : }
3985 234131975 : while (i != 0);
3986 120655186 : }
3987 :
3988 : /* Write an unsigned long as decimal to a string, fast.
3989 : s must be wide enough to not overflow, at least 21 chars.
3990 : Returns the length of the string (without terminating '\0'). */
3991 :
3992 : int
3993 328277485 : sprint_ul (char *s, unsigned long value)
3994 : {
3995 328277485 : int len = sprint_ul_rev (s, value);
3996 328277485 : s[len] = '\0';
3997 :
3998 328277485 : std::reverse (s, s + len);
3999 328277485 : return len;
4000 : }
4001 :
4002 : /* A poor man's fprintf, with the added features of %I, %R, %L, and %U.
4003 : %R prints the value of REGISTER_PREFIX.
4004 : %L prints the value of LOCAL_LABEL_PREFIX.
4005 : %U prints the value of USER_LABEL_PREFIX.
4006 : %I prints the value of IMMEDIATE_PREFIX.
4007 : %O runs ASM_OUTPUT_OPCODE to transform what follows in the string.
4008 : Also supported are %d, %i, %u, %x, %X, %o, %c, %s and %%.
4009 :
4010 : We handle alternate assembler dialects here, just like output_asm_insn. */
4011 :
4012 : void
4013 2 : asm_fprintf (FILE *file, const char *p, ...)
4014 : {
4015 2 : char buf[10];
4016 2 : char *q, c;
4017 : #ifdef ASSEMBLER_DIALECT
4018 2 : int dialect = 0;
4019 : #endif
4020 2 : va_list argptr;
4021 :
4022 2 : va_start (argptr, p);
4023 :
4024 2 : buf[0] = '%';
4025 :
4026 21 : while ((c = *p++))
4027 19 : switch (c)
4028 : {
4029 : #ifdef ASSEMBLER_DIALECT
4030 0 : case '{':
4031 0 : case '}':
4032 0 : case '|':
4033 0 : p = do_assembler_dialects (p, &dialect);
4034 0 : break;
4035 : #endif
4036 :
4037 6 : case '%':
4038 6 : c = *p++;
4039 6 : q = &buf[1];
4040 6 : while (strchr ("-+ #0", c))
4041 : {
4042 0 : *q++ = c;
4043 0 : c = *p++;
4044 : }
4045 6 : while (ISDIGIT (c) || c == '.')
4046 : {
4047 0 : *q++ = c;
4048 0 : c = *p++;
4049 : }
4050 6 : switch (c)
4051 : {
4052 2 : case '%':
4053 2 : putc ('%', file);
4054 2 : break;
4055 :
4056 0 : case 'd': case 'i': case 'u':
4057 0 : case 'x': case 'X': case 'o':
4058 0 : case 'c':
4059 0 : *q++ = c;
4060 0 : *q = 0;
4061 0 : fprintf (file, buf, va_arg (argptr, int));
4062 0 : break;
4063 :
4064 0 : case 'w':
4065 : /* This is a prefix to the 'd', 'i', 'u', 'x', 'X', and
4066 : 'o' cases, but we do not check for those cases. It
4067 : means that the value is a HOST_WIDE_INT, which may be
4068 : either `long' or `long long'. */
4069 0 : memcpy (q, HOST_WIDE_INT_PRINT, strlen (HOST_WIDE_INT_PRINT));
4070 0 : q += strlen (HOST_WIDE_INT_PRINT);
4071 0 : *q++ = *p++;
4072 0 : *q = 0;
4073 0 : fprintf (file, buf, va_arg (argptr, HOST_WIDE_INT));
4074 0 : break;
4075 :
4076 0 : case 'l':
4077 0 : *q++ = c;
4078 0 : if (*p == 'l')
4079 : {
4080 0 : *q++ = *p++;
4081 0 : *q++ = *p++;
4082 0 : *q = 0;
4083 0 : fprintf (file, buf, va_arg (argptr, long long));
4084 : }
4085 : else
4086 : {
4087 0 : *q++ = *p++;
4088 0 : *q = 0;
4089 0 : fprintf (file, buf, va_arg (argptr, long));
4090 : }
4091 :
4092 : break;
4093 :
4094 0 : case 's':
4095 0 : *q++ = c;
4096 0 : *q = 0;
4097 0 : fprintf (file, buf, va_arg (argptr, char *));
4098 0 : break;
4099 :
4100 0 : case 'O':
4101 : #ifdef ASM_OUTPUT_OPCODE
4102 0 : ASM_OUTPUT_OPCODE (asm_out_file, p);
4103 : #endif
4104 : break;
4105 :
4106 : case 'R':
4107 : #ifdef REGISTER_PREFIX
4108 : fprintf (file, "%s", REGISTER_PREFIX);
4109 : #endif
4110 : break;
4111 :
4112 : case 'I':
4113 : #ifdef IMMEDIATE_PREFIX
4114 : fprintf (file, "%s", IMMEDIATE_PREFIX);
4115 : #endif
4116 : break;
4117 :
4118 0 : case 'L':
4119 : #ifdef LOCAL_LABEL_PREFIX
4120 0 : fprintf (file, "%s", LOCAL_LABEL_PREFIX);
4121 : #endif
4122 0 : break;
4123 :
4124 0 : case 'U':
4125 0 : fputs (user_label_prefix, file);
4126 0 : break;
4127 :
4128 : #ifdef ASM_FPRINTF_EXTENSIONS
4129 : /* Uppercase letters are reserved for general use by asm_fprintf
4130 : and so are not available to target specific code. In order to
4131 : prevent the ASM_FPRINTF_EXTENSIONS macro from using them then,
4132 : they are defined here. As they get turned into real extensions
4133 : to asm_fprintf they should be removed from this list. */
4134 : case 'A': case 'B': case 'C': case 'D': case 'E':
4135 : case 'F': case 'G': case 'H': case 'J': case 'K':
4136 : case 'M': case 'N': case 'P': case 'Q': case 'S':
4137 : case 'T': case 'V': case 'W': case 'Y': case 'Z':
4138 : break;
4139 :
4140 4 : ASM_FPRINTF_EXTENSIONS (file, argptr, p)
4141 : #endif
4142 0 : default:
4143 0 : gcc_unreachable ();
4144 : }
4145 : break;
4146 :
4147 13 : default:
4148 13 : putc (c, file);
4149 : }
4150 2 : va_end (argptr);
4151 2 : }
4152 :
4153 : /* Return true if this function has no function calls. */
4154 :
4155 : bool
4156 3093290 : leaf_function_p (void)
4157 : {
4158 3093290 : rtx_insn *insn;
4159 :
4160 : /* Ensure we walk the entire function body. */
4161 3093290 : gcc_assert (!in_sequence_p ());
4162 :
4163 : /* Some back-ends (e.g. s390) want leaf functions to stay leaf
4164 : functions even if they call mcount. */
4165 3093290 : if (crtl->profile && !targetm.keep_leaf_when_profiled ())
4166 : return false;
4167 :
4168 82350610 : for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
4169 : {
4170 81219390 : rtx_call_insn *call = dyn_cast<rtx_call_insn *> (insn);
4171 2102274 : if (call && ! SIBLING_CALL_P (call) && ! FAKE_CALL_P (call))
4172 : return false;
4173 79258110 : rtx_sequence *seq;
4174 79258110 : if (NONJUMP_INSN_P (insn)
4175 38435694 : && (seq = dyn_cast <rtx_sequence *> (PATTERN (insn)))
4176 79258110 : && (call = dyn_cast<rtx_call_insn *> (seq->insn (0)))
4177 79258110 : && ! SIBLING_CALL_P (call))
4178 : return false;
4179 : }
4180 :
4181 : return true;
4182 : }
4183 :
4184 : /* Return true if branch is a forward branch.
4185 : Uses insn_shuid array, so it works only in the final pass. May be used by
4186 : output templates to customary add branch prediction hints.
4187 : */
4188 : bool
4189 0 : final_forward_branch_p (rtx_insn *insn)
4190 : {
4191 0 : int insn_id, label_id;
4192 :
4193 0 : gcc_assert (uid_shuid);
4194 0 : insn_id = INSN_SHUID (insn);
4195 0 : label_id = INSN_SHUID (JUMP_LABEL (insn));
4196 : /* We've hit some insns that does not have id information available. */
4197 0 : gcc_assert (insn_id && label_id);
4198 0 : return insn_id < label_id;
4199 : }
4200 :
4201 : /* On some machines, a function with no call insns
4202 : can run faster if it doesn't create its own register window.
4203 : When output, the leaf function should use only the "output"
4204 : registers. Ordinarily, the function would be compiled to use
4205 : the "input" registers to find its arguments; it is a candidate
4206 : for leaf treatment if it uses only the "input" registers.
4207 : Leaf function treatment means renumbering so the function
4208 : uses the "output" registers instead. */
4209 :
4210 : #ifdef LEAF_REGISTERS
4211 :
4212 : /* Return bool if this function uses only the registers that can be
4213 : safely renumbered. */
4214 :
4215 : bool
4216 : only_leaf_regs_used (void)
4217 : {
4218 : int i;
4219 : const char *const permitted_reg_in_leaf_functions = LEAF_REGISTERS;
4220 :
4221 : for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
4222 : if ((df_regs_ever_live_p (i) || global_regs[i])
4223 : && ! permitted_reg_in_leaf_functions[i])
4224 : return false;
4225 :
4226 : if (crtl->uses_pic_offset_table
4227 : && pic_offset_table_rtx != 0
4228 : && REG_P (pic_offset_table_rtx)
4229 : && ! permitted_reg_in_leaf_functions[REGNO (pic_offset_table_rtx)])
4230 : return false;
4231 :
4232 : return true;
4233 : }
4234 :
4235 : /* Scan all instructions and renumber all registers into those
4236 : available in leaf functions. */
4237 :
4238 : static void
4239 : leaf_renumber_regs (rtx_insn *first)
4240 : {
4241 : rtx_insn *insn;
4242 :
4243 : /* Renumber only the actual patterns.
4244 : The reg-notes can contain frame pointer refs,
4245 : and renumbering them could crash, and should not be needed. */
4246 : for (insn = first; insn; insn = NEXT_INSN (insn))
4247 : if (INSN_P (insn))
4248 : leaf_renumber_regs_insn (PATTERN (insn));
4249 : }
4250 :
4251 : /* Scan IN_RTX and its subexpressions, and renumber all regs into those
4252 : available in leaf functions. */
4253 :
4254 : void
4255 : leaf_renumber_regs_insn (rtx in_rtx)
4256 : {
4257 : int i, j;
4258 : const char *format_ptr;
4259 :
4260 : if (in_rtx == 0)
4261 : return;
4262 :
4263 : /* Renumber all input-registers into output-registers.
4264 : renumbered_regs would be 1 for an output-register;
4265 : they */
4266 :
4267 : if (REG_P (in_rtx))
4268 : {
4269 : int newreg;
4270 :
4271 : /* Don't renumber the same reg twice. */
4272 : if (in_rtx->used)
4273 : return;
4274 :
4275 : newreg = REGNO (in_rtx);
4276 : /* Don't try to renumber pseudo regs. It is possible for a pseudo reg
4277 : to reach here as part of a REG_NOTE. */
4278 : if (newreg >= FIRST_PSEUDO_REGISTER)
4279 : {
4280 : in_rtx->used = 1;
4281 : return;
4282 : }
4283 : newreg = LEAF_REG_REMAP (newreg);
4284 : gcc_assert (newreg >= 0);
4285 : df_set_regs_ever_live (REGNO (in_rtx), false);
4286 : df_set_regs_ever_live (newreg, true);
4287 : SET_REGNO (in_rtx, newreg);
4288 : in_rtx->used = 1;
4289 : return;
4290 : }
4291 :
4292 : if (INSN_P (in_rtx))
4293 : {
4294 : /* Inside a SEQUENCE, we find insns.
4295 : Renumber just the patterns of these insns,
4296 : just as we do for the top-level insns. */
4297 : leaf_renumber_regs_insn (PATTERN (in_rtx));
4298 : return;
4299 : }
4300 :
4301 : format_ptr = GET_RTX_FORMAT (GET_CODE (in_rtx));
4302 :
4303 : for (i = 0; i < GET_RTX_LENGTH (GET_CODE (in_rtx)); i++)
4304 : switch (*format_ptr++)
4305 : {
4306 : case 'e':
4307 : leaf_renumber_regs_insn (XEXP (in_rtx, i));
4308 : break;
4309 :
4310 : case 'E':
4311 : if (XVEC (in_rtx, i) != NULL)
4312 : for (j = 0; j < XVECLEN (in_rtx, i); j++)
4313 : leaf_renumber_regs_insn (XVECEXP (in_rtx, i, j));
4314 : break;
4315 :
4316 : case 'S':
4317 : case 's':
4318 : case '0':
4319 : case 'i':
4320 : case 'L':
4321 : case 'w':
4322 : case 'p':
4323 : case 'n':
4324 : case 'u':
4325 : break;
4326 :
4327 : default:
4328 : gcc_unreachable ();
4329 : }
4330 : }
4331 : #endif
4332 :
4333 : /* Turn the RTL into assembly. */
4334 : static unsigned int
4335 1531125 : rest_of_handle_final (void)
4336 : {
4337 1531125 : const char *fnname = get_fnname_from_decl (current_function_decl);
4338 :
4339 : /* Turn debug markers into notes if the var-tracking pass has not
4340 : been invoked. */
4341 1531125 : if (!flag_var_tracking && MAY_HAVE_DEBUG_MARKER_INSNS)
4342 1 : delete_vta_debug_insns (false);
4343 :
4344 1531125 : assemble_start_function (current_function_decl, fnname);
4345 1531125 : rtx_insn *first = get_insns ();
4346 1531125 : int seen = 0;
4347 1531125 : final_start_function_1 (&first, asm_out_file, &seen, optimize);
4348 1531125 : final_1 (first, asm_out_file, seen, optimize);
4349 1531125 : if (flag_ipa_ra
4350 982766 : && !lookup_attribute ("noipa", DECL_ATTRIBUTES (current_function_decl))
4351 : /* Functions with naked attributes are supported only with basic asm
4352 : statements in the body, thus for supported use cases the information
4353 : on clobbered registers is not available. */
4354 2490761 : && !lookup_attribute ("naked", DECL_ATTRIBUTES (current_function_decl)))
4355 959636 : collect_fn_hard_reg_usage ();
4356 1531125 : final_end_function ();
4357 :
4358 : /* The IA-64 ".handlerdata" directive must be issued before the ".endp"
4359 : directive that closes the procedure descriptor. Similarly, for x64 SEH.
4360 : Otherwise it's not strictly necessary, but it doesn't hurt either. */
4361 2996559 : output_function_exception_table (crtl->has_bb_partition ? 1 : 0);
4362 :
4363 1531125 : assemble_end_function (current_function_decl, fnname);
4364 :
4365 : /* Free up reg info memory. */
4366 1531125 : free_reg_info ();
4367 :
4368 1531125 : if (! quiet_flag)
4369 0 : fflush (asm_out_file);
4370 :
4371 : /* Note that for those inline functions where we don't initially
4372 : know for certain that we will be generating an out-of-line copy,
4373 : the first invocation of this routine (rest_of_compilation) will
4374 : skip over this code by doing a `goto exit_rest_of_compilation;'.
4375 : Later on, wrapup_global_declarations will (indirectly) call
4376 : rest_of_compilation again for those inline functions that need
4377 : to have out-of-line copies generated. During that call, we
4378 : *will* be routed past here. */
4379 :
4380 1531125 : timevar_push (TV_SYMOUT);
4381 1531125 : if (!DECL_IGNORED_P (current_function_decl))
4382 1524055 : debug_hooks->function_decl (current_function_decl);
4383 1531125 : timevar_pop (TV_SYMOUT);
4384 :
4385 : /* Release the blocks that are linked to DECL_INITIAL() to free the memory. */
4386 1531125 : DECL_INITIAL (current_function_decl) = error_mark_node;
4387 :
4388 1531125 : if (DECL_STATIC_CONSTRUCTOR (current_function_decl)
4389 1531125 : && targetm.have_ctors_dtors)
4390 24549 : targetm.asm_out.constructor (XEXP (DECL_RTL (current_function_decl), 0),
4391 : decl_init_priority_lookup
4392 24549 : (current_function_decl));
4393 1531125 : if (DECL_STATIC_DESTRUCTOR (current_function_decl)
4394 1531125 : && targetm.have_ctors_dtors)
4395 1681 : targetm.asm_out.destructor (XEXP (DECL_RTL (current_function_decl), 0),
4396 : decl_fini_priority_lookup
4397 1681 : (current_function_decl));
4398 1531125 : return 0;
4399 : }
4400 :
4401 : namespace {
4402 :
4403 : const pass_data pass_data_final =
4404 : {
4405 : RTL_PASS, /* type */
4406 : "final", /* name */
4407 : OPTGROUP_NONE, /* optinfo_flags */
4408 : TV_FINAL, /* tv_id */
4409 : 0, /* properties_required */
4410 : 0, /* properties_provided */
4411 : 0, /* properties_destroyed */
4412 : 0, /* todo_flags_start */
4413 : 0, /* todo_flags_finish */
4414 : };
4415 :
4416 : class pass_final : public rtl_opt_pass
4417 : {
4418 : public:
4419 302985 : pass_final (gcc::context *ctxt)
4420 605970 : : rtl_opt_pass (pass_data_final, ctxt)
4421 : {}
4422 :
4423 : /* opt_pass methods: */
4424 1531125 : unsigned int execute (function *) final override
4425 : {
4426 1531125 : return rest_of_handle_final ();
4427 : }
4428 :
4429 : }; // class pass_final
4430 :
4431 : } // anon namespace
4432 :
4433 : rtl_opt_pass *
4434 302985 : make_pass_final (gcc::context *ctxt)
4435 : {
4436 302985 : return new pass_final (ctxt);
4437 : }
4438 :
4439 :
4440 : static unsigned int
4441 1531124 : rest_of_handle_shorten_branches (void)
4442 : {
4443 : /* Shorten branches. */
4444 0 : shorten_branches (get_insns ());
4445 1531124 : return 0;
4446 : }
4447 :
4448 : namespace {
4449 :
4450 : const pass_data pass_data_shorten_branches =
4451 : {
4452 : RTL_PASS, /* type */
4453 : "shorten", /* name */
4454 : OPTGROUP_NONE, /* optinfo_flags */
4455 : TV_SHORTEN_BRANCH, /* tv_id */
4456 : 0, /* properties_required */
4457 : 0, /* properties_provided */
4458 : 0, /* properties_destroyed */
4459 : 0, /* todo_flags_start */
4460 : 0, /* todo_flags_finish */
4461 : };
4462 :
4463 : class pass_shorten_branches : public rtl_opt_pass
4464 : {
4465 : public:
4466 302985 : pass_shorten_branches (gcc::context *ctxt)
4467 605970 : : rtl_opt_pass (pass_data_shorten_branches, ctxt)
4468 : {}
4469 :
4470 : /* opt_pass methods: */
4471 1531124 : unsigned int execute (function *) final override
4472 : {
4473 1531124 : return rest_of_handle_shorten_branches ();
4474 : }
4475 :
4476 : }; // class pass_shorten_branches
4477 :
4478 : } // anon namespace
4479 :
4480 : rtl_opt_pass *
4481 302985 : make_pass_shorten_branches (gcc::context *ctxt)
4482 : {
4483 302985 : return new pass_shorten_branches (ctxt);
4484 : }
4485 :
4486 :
4487 : static unsigned int
4488 1531954 : rest_of_clean_state (void)
4489 : {
4490 1531954 : rtx_insn *insn, *next;
4491 1531954 : FILE *final_output = NULL;
4492 1531954 : int save_unnumbered = flag_dump_unnumbered;
4493 1531954 : int save_noaddr = flag_dump_noaddr;
4494 :
4495 1531954 : if (flag_dump_final_insns)
4496 : {
4497 4004 : final_output = fopen (flag_dump_final_insns, "a");
4498 4004 : if (!final_output)
4499 : {
4500 0 : error ("could not open final insn dump file %qs: %m",
4501 : flag_dump_final_insns);
4502 0 : flag_dump_final_insns = NULL;
4503 : }
4504 : else
4505 : {
4506 4004 : flag_dump_noaddr = flag_dump_unnumbered = 1;
4507 4004 : if (flag_compare_debug_opt || flag_compare_debug)
4508 3932 : dump_flags |= TDF_NOUID | TDF_COMPARE_DEBUG;
4509 4004 : dump_function_header (final_output, current_function_decl,
4510 : dump_flags);
4511 4004 : final_insns_dump_p = true;
4512 :
4513 158372 : for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
4514 154368 : if (LABEL_P (insn))
4515 5031 : INSN_UID (insn) = CODE_LABEL_NUMBER (insn);
4516 : else
4517 : {
4518 149337 : if (NOTE_P (insn))
4519 74223 : set_block_for_insn (insn, NULL);
4520 149337 : INSN_UID (insn) = 0;
4521 : }
4522 : }
4523 : }
4524 :
4525 : /* It is very important to decompose the RTL instruction chain here:
4526 : debug information keeps pointing into CODE_LABEL insns inside the function
4527 : body. If these remain pointing to the other insns, we end up preserving
4528 : whole RTL chain and attached detailed debug info in memory. */
4529 265466625 : for (insn = get_insns (); insn; insn = next)
4530 : {
4531 263934671 : next = NEXT_INSN (insn);
4532 263934671 : SET_NEXT_INSN (insn) = NULL;
4533 263934671 : SET_PREV_INSN (insn) = NULL;
4534 :
4535 263934671 : rtx_insn *call_insn = insn;
4536 263934671 : rtx_sequence *seq;
4537 263934671 : if (NONJUMP_INSN_P (call_insn)
4538 263934671 : && (seq = dyn_cast <rtx_sequence *> (PATTERN (call_insn))))
4539 0 : call_insn = seq->insn (0);
4540 263934671 : if (CALL_P (call_insn))
4541 : {
4542 6330508 : rtx note
4543 6330508 : = find_reg_note (call_insn, REG_CALL_ARG_LOCATION, NULL_RTX);
4544 6330508 : if (note)
4545 3286892 : remove_note (call_insn, note);
4546 : }
4547 :
4548 263934671 : if (final_output
4549 154368 : && (!NOTE_P (insn)
4550 74223 : || (NOTE_KIND (insn) != NOTE_INSN_VAR_LOCATION
4551 : && NOTE_KIND (insn) != NOTE_INSN_BEGIN_STMT
4552 74223 : && NOTE_KIND (insn) != NOTE_INSN_INLINE_ENTRY
4553 : && NOTE_KIND (insn) != NOTE_INSN_BLOCK_BEG
4554 : && NOTE_KIND (insn) != NOTE_INSN_BLOCK_END
4555 : && NOTE_KIND (insn) != NOTE_INSN_DELETED_DEBUG_LABEL)))
4556 119615 : print_rtl_single (final_output, insn);
4557 : }
4558 :
4559 1531954 : if (final_output)
4560 : {
4561 4004 : flag_dump_noaddr = save_noaddr;
4562 4004 : flag_dump_unnumbered = save_unnumbered;
4563 4004 : final_insns_dump_p = false;
4564 :
4565 4004 : if (fclose (final_output))
4566 : {
4567 0 : error ("could not close final insn dump file %qs: %m",
4568 : flag_dump_final_insns);
4569 0 : flag_dump_final_insns = NULL;
4570 : }
4571 : }
4572 :
4573 1531954 : flag_rerun_cse_after_global_opts = 0;
4574 1531954 : reload_completed = 0;
4575 1531954 : post_ra_split_completed = false;
4576 1531954 : epilogue_completed = 0;
4577 : #ifdef STACK_REGS
4578 1531954 : regstack_completed = false;
4579 : #endif
4580 :
4581 : /* Clear out the insn_length contents now that they are no
4582 : longer valid. */
4583 1531954 : init_insn_lengths ();
4584 :
4585 : /* Show no temporary slots allocated. */
4586 1531954 : init_temp_slots ();
4587 :
4588 1531954 : free_bb_for_insn ();
4589 :
4590 1531954 : if (cfun->gimple_df)
4591 1531884 : delete_tree_ssa (cfun);
4592 :
4593 : /* We can reduce stack alignment on call site only when we are sure that
4594 : the function body just produced will be actually used in the final
4595 : executable. */
4596 1531954 : if (flag_ipa_stack_alignment
4597 1531954 : && decl_binds_to_current_def_p (current_function_decl))
4598 : {
4599 1277389 : unsigned int pref = crtl->preferred_stack_boundary;
4600 1277389 : if (crtl->stack_alignment_needed > crtl->preferred_stack_boundary)
4601 : pref = crtl->stack_alignment_needed;
4602 1277389 : cgraph_node::rtl_info (current_function_decl)
4603 1277389 : ->preferred_incoming_stack_boundary = pref;
4604 : }
4605 :
4606 : /* Make sure volatile mem refs aren't considered valid operands for
4607 : arithmetic insns. We must call this here if this is a nested inline
4608 : function, since the above code leaves us in the init_recog state,
4609 : and the function context push/pop code does not save/restore volatile_ok.
4610 :
4611 : ??? Maybe it isn't necessary for expand_start_function to call this
4612 : anymore if we do it here? */
4613 :
4614 1531954 : init_recog_no_volatile ();
4615 :
4616 : /* We're done with this function. Free up memory if we can. */
4617 1531954 : free_after_parsing (cfun);
4618 1531954 : free_after_compilation (cfun);
4619 1531954 : return 0;
4620 : }
4621 :
4622 : namespace {
4623 :
4624 : const pass_data pass_data_clean_state =
4625 : {
4626 : RTL_PASS, /* type */
4627 : "*clean_state", /* name */
4628 : OPTGROUP_NONE, /* optinfo_flags */
4629 : TV_FINAL, /* tv_id */
4630 : 0, /* properties_required */
4631 : 0, /* properties_provided */
4632 : PROP_rtl, /* properties_destroyed */
4633 : 0, /* todo_flags_start */
4634 : 0, /* todo_flags_finish */
4635 : };
4636 :
4637 : class pass_clean_state : public rtl_opt_pass
4638 : {
4639 : public:
4640 302985 : pass_clean_state (gcc::context *ctxt)
4641 605970 : : rtl_opt_pass (pass_data_clean_state, ctxt)
4642 : {}
4643 :
4644 : /* opt_pass methods: */
4645 1531954 : unsigned int execute (function *) final override
4646 : {
4647 1531954 : return rest_of_clean_state ();
4648 : }
4649 :
4650 : }; // class pass_clean_state
4651 :
4652 : } // anon namespace
4653 :
4654 : rtl_opt_pass *
4655 302985 : make_pass_clean_state (gcc::context *ctxt)
4656 : {
4657 302985 : return new pass_clean_state (ctxt);
4658 : }
4659 :
4660 : /* Return true if INSN is a call to the current function. */
4661 :
4662 : static bool
4663 826013 : self_recursive_call_p (rtx_insn *insn)
4664 : {
4665 826013 : tree fndecl = get_call_fndecl (insn);
4666 826013 : return (fndecl == current_function_decl
4667 826013 : && decl_binds_to_current_def_p (fndecl));
4668 : }
4669 :
4670 : /* Collect hard register usage for the current function. */
4671 :
4672 : static void
4673 959636 : collect_fn_hard_reg_usage (void)
4674 : {
4675 959636 : rtx_insn *insn;
4676 : #ifdef STACK_REGS
4677 959636 : int i;
4678 : #endif
4679 959636 : struct cgraph_rtl_info *node;
4680 959636 : HARD_REG_SET function_used_regs;
4681 :
4682 : /* ??? To be removed when all the ports have been fixed. */
4683 959636 : if (!targetm.call_fusage_contains_non_callee_clobbers)
4684 649457 : return;
4685 :
4686 : /* Be conservative - mark fixed and global registers as used. */
4687 959636 : function_used_regs = fixed_reg_set;
4688 :
4689 : #ifdef STACK_REGS
4690 : /* Handle STACK_REGS conservatively, since the df-framework does not
4691 : provide accurate information for them. */
4692 :
4693 8636724 : for (i = FIRST_STACK_REG; i <= LAST_STACK_REG; i++)
4694 7677088 : SET_HARD_REG_BIT (function_used_regs, i);
4695 : #endif
4696 :
4697 52758616 : for (insn = get_insns (); insn != NULL_RTX; insn = next_insn (insn))
4698 : {
4699 52448437 : HARD_REG_SET insn_used_regs;
4700 :
4701 52448437 : if (!NONDEBUG_INSN_P (insn))
4702 34930518 : continue;
4703 :
4704 17517919 : auto call = dyn_cast<rtx_call_insn *> (insn);
4705 826013 : if (call && !self_recursive_call_p (call))
4706 822774 : function_used_regs
4707 1645548 : |= insn_callee_abi (call).full_and_partial_reg_clobbers ();
4708 :
4709 17517919 : find_all_hard_reg_sets (insn, &insn_used_regs, false);
4710 17517919 : function_used_regs |= insn_used_regs;
4711 :
4712 35035838 : if (hard_reg_set_subset_p (crtl->abi->full_and_partial_reg_clobbers (),
4713 : function_used_regs))
4714 649457 : return;
4715 : }
4716 :
4717 : /* Mask out fully-saved registers, so that they don't affect equality
4718 : comparisons between function_abis. */
4719 310179 : function_used_regs &= crtl->abi->full_and_partial_reg_clobbers ();
4720 :
4721 310179 : node = cgraph_node::rtl_info (current_function_decl);
4722 310179 : gcc_assert (node != NULL);
4723 :
4724 310179 : node->function_used_regs = function_used_regs;
4725 : }
4726 :
4727 : #if CHECKING_P
4728 :
4729 : namespace selftest {
4730 :
4731 : static void
4732 4 : test_parse_bracketed_operand ()
4733 : {
4734 4 : const struct
4735 : {
4736 : const char *text;
4737 : const char *modifier;
4738 : unsigned long opnums[2];
4739 : unsigned int count;
4740 4 : } valid[] = {
4741 : { "[10]", "", { 10 }, 1 },
4742 : { "[fmt:11]", "fmt", { 11 }, 1 },
4743 : { "[gpr,zero:13]", "gpr,zero", { 13 }, 1 },
4744 : { "[fmt:13,14]", "fmt", { 13, 14 }, 2 },
4745 : { "[999999999999999999999999999999999999]", "", { ULONG_MAX }, 1 }
4746 : };
4747 4 : bracketed_operand operand;
4748 24 : for (const auto &test : valid)
4749 : {
4750 20 : const char *p = test.text;
4751 20 : ASSERT_TRUE (parse_bracketed_operand (&p, operand));
4752 20 : ASSERT_TRUE (operand.modifier == test.modifier);
4753 40 : ASSERT_EQ (test.count, operand.opnums.length ());
4754 44 : for (unsigned int i = 0; i < test.count; ++i)
4755 24 : ASSERT_EQ (test.opnums[i], operand.opnums[i]);
4756 20 : ASSERT_EQ ('\0', *p);
4757 : }
4758 4 : const char *invalid[] = {
4759 : "[fmt]12", "[fmt:1,]", "[fmt]", "[fmt:]", "[]0", "[0,1]",
4760 : "[fmt:12x]", "[fmt:1", "[:1]", "[,fmt:1]", "[fmt,:1]", "[fmt,,part:1]"
4761 : };
4762 52 : for (const char *text : invalid)
4763 : {
4764 48 : const char *p = text;
4765 48 : ASSERT_FALSE (parse_bracketed_operand (&p, operand));
4766 : }
4767 4 : }
4768 :
4769 : /* The same syntax must be understood by the operand reference scanner. */
4770 :
4771 : static void
4772 4 : test_referenced_operands ()
4773 : {
4774 4 : const struct
4775 : {
4776 : const char *text;
4777 : unsigned int mask;
4778 4 : } tests[] = {
4779 : { "%[0] %[fmt:1,2]", 7 },
4780 : { "%%[0] %%[fmt:1,2]", 0 },
4781 : { "%[1]0 %2", 6 },
4782 : { "%0 %a1 %cc2", 7 },
4783 : { "%[fmt:2,2] %[99]", 4 },
4784 : { "%[fmt:1,]", 0 },
4785 : { "%", 0 }
4786 : };
4787 32 : for (const auto &test : tests)
4788 : {
4789 28 : bool used[3];
4790 28 : get_referenced_operands (test.text, used, 3);
4791 140 : for (unsigned int i = 0; i < 3; ++i)
4792 84 : ASSERT_EQ ((test.mask & (1U << i)) != 0, used[i]);
4793 : }
4794 4 : }
4795 :
4796 : static void
4797 4 : test_output_operand_modifier_operand ()
4798 : {
4799 4 : rtx operands[] = { GEN_INT (10), gen_rtx_REG (QImode, 0) };
4800 4 : auto_vec<unsigned long, 2> opnums;
4801 4 : opnums.safe_push (1);
4802 4 : opnums.safe_push (0);
4803 4 : current_modifier_operands = operands;
4804 4 : current_modifier_opnums = &opnums;
4805 4 : rtx x = output_operand_modifier_operand (PRINT_OPERAND_MODIFIER_BASE, 0);
4806 4 : ASSERT_TRUE (REG_P (x));
4807 4 : ASSERT_EQ (QImode, GET_MODE (x));
4808 4 : ASSERT_EQ (operands[0], output_operand_modifier_operand
4809 : (PRINT_OPERAND_MODIFIER_BASE, 1));
4810 4 : ASSERT_EQ (nullptr, output_operand_modifier_operand
4811 : (PRINT_OPERAND_MODIFIER_BASE, 2));
4812 4 : current_modifier_operands = nullptr;
4813 4 : current_modifier_opnums = nullptr;
4814 4 : }
4815 :
4816 : void
4817 4 : final_cc_tests ()
4818 : {
4819 4 : test_parse_bracketed_operand ();
4820 4 : test_referenced_operands ();
4821 4 : test_output_operand_modifier_operand ();
4822 4 : }
4823 :
4824 : } // namespace selftest
4825 :
4826 : #endif /* CHECKING_P */
|