1 /* LRA (local register allocator) driver and LRA utilities.
2 Copyright (C) 2010-2014 Free Software Foundation, Inc.
3 Contributed by Vladimir Makarov <vmakarov@redhat.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
22 /* The Local Register Allocator (LRA) is a replacement of former
23 reload pass. It is focused to simplify code solving the reload
24 pass tasks, to make the code maintenance easier, and to implement new
25 perspective optimizations.
27 The major LRA design solutions are:
28 o division small manageable, separated sub-tasks
29 o reflection of all transformations and decisions in RTL as more
31 o insn constraints as a primary source of the info (minimizing
32 number of target-depended macros/hooks)
34 In brief LRA works by iterative insn process with the final goal is
35 to satisfy all insn and address constraints:
36 o New reload insns (in brief reloads) and reload pseudos might be
38 o Some pseudos might be spilled to assign hard registers to
40 o Changing spilled pseudos to stack memory or their equivalences;
41 o Allocation stack memory changes the address displacement and
42 new iteration is needed.
44 Here is block diagram of LRA passes:
46 ------------------------
47 --------------- | Undo inheritance for | ---------------
48 | Memory-memory | | spilled pseudos, | | New (and old) |
49 | move coalesce |<---| splits for pseudos got |<-- | pseudos |
50 --------------- | the same hard regs, | | assignment |
51 Start | | and optional reloads | ---------------
52 | | ------------------------ ^
53 V | ---------------- |
54 ----------- V | Update virtual | |
55 | Remove |----> ------------>| register | |
56 | scratches | ^ | displacements | |
57 ----------- | ---------------- |
60 ---------------- No ------------ pseudos -------------------
61 | Spilled pseudo | change |Constraints:| or insns | Inheritance/split |
62 | to memory |<-------| RTL |--------->| transformations |
63 | substitution | | transfor- | | in EBB scope |
64 ---------------- | mations | -------------------
67 -------------------------
68 | Hard regs substitution, |
69 | devirtalization, and |------> Finish
70 | restoring scratches got |
72 -------------------------
74 To speed up the process:
75 o We process only insns affected by changes on previous
77 o We don't use DFA-infrastructure because it results in much slower
78 compiler speed than a special IR described below does;
79 o We use a special insn representation for quick access to insn
80 info which is always *synchronized* with the current RTL;
81 o Insn IR is minimized by memory. It is divided on three parts:
82 o one specific for each insn in RTL (only operand locations);
83 o one common for all insns in RTL with the same insn code
84 (different operand attributes from machine descriptions);
85 o one oriented for maintenance of live info (list of pseudos).
87 o all insns where the pseudo is referenced;
88 o live info (conflicting hard regs, live ranges, # of
90 o data used for assigning (preferred hard regs, costs etc).
92 This file contains LRA driver, LRA utility functions and data, and
93 code for dealing with scratches. */
97 #include "coretypes.h"
99 #include "hard-reg-set.h"
103 #include "insn-config.h"
104 #include "insn-codes.h"
107 #include "addresses.h"
110 #include "hash-set.h"
112 #include "machmode.h"
114 #include "function.h"
115 #include "tree-core.h"
119 #include "dominance.h"
122 #include "cfgbuild.h"
123 #include "basic-block.h"
125 #include "tree-pass.h"
132 /* Hard registers currently not available for allocation. It can
133 changed after some hard registers become not eliminable. */
134 HARD_REG_SET lra_no_alloc_regs
;
136 static int get_new_reg_value (void);
137 static void expand_reg_info (void);
138 static void invalidate_insn_recog_data (int);
139 static int get_insn_freq (rtx_insn
*);
140 static void invalidate_insn_data_regno_info (lra_insn_recog_data_t
,
143 /* Expand all regno related info needed for LRA. */
145 expand_reg_data (int old
)
149 ira_expand_reg_equiv ();
150 for (int i
= (int) max_reg_num () - 1; i
>= old
; i
--)
151 lra_change_class (i
, ALL_REGS
, " Set", true);
154 /* Create and return a new reg of ORIGINAL mode. If ORIGINAL is NULL
155 or of VOIDmode, use MD_MODE for the new reg. Initialize its
156 register class to RCLASS. Print message about assigning class
157 RCLASS containing new register name TITLE unless it is NULL. Use
158 attributes of ORIGINAL if it is a register. The created register
159 will have unique held value. */
161 lra_create_new_reg_with_unique_value (machine_mode md_mode
, rtx original
,
162 enum reg_class rclass
, const char *title
)
167 if (original
== NULL_RTX
|| (mode
= GET_MODE (original
)) == VOIDmode
)
169 lra_assert (mode
!= VOIDmode
);
170 new_reg
= gen_reg_rtx (mode
);
171 if (original
== NULL_RTX
|| ! REG_P (original
))
173 if (lra_dump_file
!= NULL
)
174 fprintf (lra_dump_file
, " Creating newreg=%i", REGNO (new_reg
));
178 if (ORIGINAL_REGNO (original
) >= FIRST_PSEUDO_REGISTER
)
179 ORIGINAL_REGNO (new_reg
) = ORIGINAL_REGNO (original
);
180 REG_USERVAR_P (new_reg
) = REG_USERVAR_P (original
);
181 REG_POINTER (new_reg
) = REG_POINTER (original
);
182 REG_ATTRS (new_reg
) = REG_ATTRS (original
);
183 if (lra_dump_file
!= NULL
)
184 fprintf (lra_dump_file
, " Creating newreg=%i from oldreg=%i",
185 REGNO (new_reg
), REGNO (original
));
187 if (lra_dump_file
!= NULL
)
190 fprintf (lra_dump_file
, ", assigning class %s to%s%s r%d",
191 reg_class_names
[rclass
], *title
== '\0' ? "" : " ",
192 title
, REGNO (new_reg
));
193 fprintf (lra_dump_file
, "\n");
195 expand_reg_data (max_reg_num ());
196 setup_reg_classes (REGNO (new_reg
), rclass
, NO_REGS
, rclass
);
200 /* Analogous to the previous function but also inherits value of
203 lra_create_new_reg (machine_mode md_mode
, rtx original
,
204 enum reg_class rclass
, const char *title
)
209 = lra_create_new_reg_with_unique_value (md_mode
, original
, rclass
, title
);
210 if (original
!= NULL_RTX
&& REG_P (original
))
211 lra_assign_reg_val (REGNO (original
), REGNO (new_reg
));
215 /* Set up for REGNO unique hold value. */
217 lra_set_regno_unique_value (int regno
)
219 lra_reg_info
[regno
].val
= get_new_reg_value ();
222 /* Invalidate INSN related info used by LRA. The info should never be
225 lra_invalidate_insn_data (rtx_insn
*insn
)
227 lra_invalidate_insn_regno_info (insn
);
228 invalidate_insn_recog_data (INSN_UID (insn
));
231 /* Mark INSN deleted and invalidate the insn related info used by
234 lra_set_insn_deleted (rtx_insn
*insn
)
236 lra_invalidate_insn_data (insn
);
237 SET_INSN_DELETED (insn
);
240 /* Delete an unneeded INSN and any previous insns who sole purpose is
241 loading data that is dead in INSN. */
243 lra_delete_dead_insn (rtx_insn
*insn
)
245 rtx_insn
*prev
= prev_real_insn (insn
);
248 /* If the previous insn sets a register that dies in our insn,
250 if (prev
&& GET_CODE (PATTERN (prev
)) == SET
251 && (prev_dest
= SET_DEST (PATTERN (prev
)), REG_P (prev_dest
))
252 && reg_mentioned_p (prev_dest
, PATTERN (insn
))
253 && find_regno_note (insn
, REG_DEAD
, REGNO (prev_dest
))
254 && ! side_effects_p (SET_SRC (PATTERN (prev
))))
255 lra_delete_dead_insn (prev
);
257 lra_set_insn_deleted (insn
);
260 /* Emit insn x = y + z. Return NULL if we failed to do it.
261 Otherwise, return the insn. We don't use gen_add3_insn as it might
264 emit_add3_insn (rtx x
, rtx y
, rtx z
)
268 last
= get_last_insn ();
270 if (have_addptr3_insn (x
, y
, z
))
272 rtx insn
= gen_addptr3_insn (x
, y
, z
);
274 /* If the target provides an "addptr" pattern it hopefully does
275 for a reason. So falling back to the normal add would be
277 lra_assert (insn
!= NULL_RTX
);
282 rtx_insn
*insn
= emit_insn (gen_rtx_SET (VOIDmode
, x
,
283 gen_rtx_PLUS (GET_MODE (y
), y
, z
)));
284 if (recog_memoized (insn
) < 0)
286 delete_insns_since (last
);
292 /* Emit insn x = x + y. Return the insn. We use gen_add2_insn as the
295 emit_add2_insn (rtx x
, rtx y
)
299 insn
= emit_add3_insn (x
, x
, y
);
300 if (insn
== NULL_RTX
)
302 insn
= gen_add2_insn (x
, y
);
303 if (insn
!= NULL_RTX
)
309 /* Target checks operands through operand predicates to recognize an
310 insn. We should have a special precaution to generate add insns
311 which are frequent results of elimination.
313 Emit insns for x = y + z. X can be used to store intermediate
314 values and should be not in Y and Z when we use X to store an
315 intermediate value. Y + Z should form [base] [+ index[ * scale]] [
316 + disp] where base and index are registers, disp and scale are
317 constants. Y should contain base if it is present, Z should
318 contain disp if any. index[*scale] can be part of Y or Z. */
320 lra_emit_add (rtx x
, rtx y
, rtx z
)
324 rtx a1
, a2
, base
, index
, disp
, scale
, index_scale
;
327 rtx add3_insn
= emit_add3_insn (x
, y
, z
);
328 old
= max_reg_num ();
329 if (add3_insn
!= NULL
)
333 disp
= a2
= NULL_RTX
;
334 if (GET_CODE (y
) == PLUS
)
348 index_scale
= scale
= NULL_RTX
;
349 if (GET_CODE (a1
) == MULT
)
352 index
= XEXP (a1
, 0);
353 scale
= XEXP (a1
, 1);
356 else if (a2
!= NULL_RTX
&& GET_CODE (a2
) == MULT
)
359 index
= XEXP (a2
, 0);
360 scale
= XEXP (a2
, 1);
368 if (! (REG_P (base
) || GET_CODE (base
) == SUBREG
)
369 || (index
!= NULL_RTX
370 && ! (REG_P (index
) || GET_CODE (index
) == SUBREG
))
371 || (disp
!= NULL_RTX
&& ! CONSTANT_P (disp
))
372 || (scale
!= NULL_RTX
&& ! CONSTANT_P (scale
)))
374 /* Probably we have no 3 op add. Last chance is to use 2-op
375 add insn. To succeed, don't move Z to X as an address
376 segment always comes in Y. Otherwise, we might fail when
377 adding the address segment to register. */
378 lra_assert (x
!= y
&& x
!= z
);
379 emit_move_insn (x
, y
);
380 rtx insn
= emit_add2_insn (x
, z
);
381 lra_assert (insn
!= NULL_RTX
);
385 if (index_scale
== NULL_RTX
)
387 if (disp
== NULL_RTX
)
389 /* Generate x = index_scale; x = x + base. */
390 lra_assert (index_scale
!= NULL_RTX
&& base
!= NULL_RTX
);
391 emit_move_insn (x
, index_scale
);
392 rtx insn
= emit_add2_insn (x
, base
);
393 lra_assert (insn
!= NULL_RTX
);
395 else if (scale
== NULL_RTX
)
397 /* Try x = base + disp. */
398 lra_assert (base
!= NULL_RTX
);
399 last
= get_last_insn ();
400 rtx_insn
*move_insn
=
401 emit_move_insn (x
, gen_rtx_PLUS (GET_MODE (base
), base
, disp
));
402 if (recog_memoized (move_insn
) < 0)
404 delete_insns_since (last
);
405 /* Generate x = disp; x = x + base. */
406 emit_move_insn (x
, disp
);
407 rtx add2_insn
= emit_add2_insn (x
, base
);
408 lra_assert (add2_insn
!= NULL_RTX
);
410 /* Generate x = x + index. */
411 if (index
!= NULL_RTX
)
413 rtx insn
= emit_add2_insn (x
, index
);
414 lra_assert (insn
!= NULL_RTX
);
419 /* Try x = index_scale; x = x + disp; x = x + base. */
420 last
= get_last_insn ();
421 rtx_insn
*move_insn
= emit_move_insn (x
, index_scale
);
423 if (recog_memoized (move_insn
) >= 0)
425 rtx insn
= emit_add2_insn (x
, disp
);
426 if (insn
!= NULL_RTX
)
428 insn
= emit_add2_insn (x
, disp
);
429 if (insn
!= NULL_RTX
)
435 delete_insns_since (last
);
436 /* Generate x = disp; x = x + base; x = x + index_scale. */
437 emit_move_insn (x
, disp
);
438 rtx insn
= emit_add2_insn (x
, base
);
439 lra_assert (insn
!= NULL_RTX
);
440 insn
= emit_add2_insn (x
, index_scale
);
441 lra_assert (insn
!= NULL_RTX
);
446 /* Functions emit_... can create pseudos -- so expand the pseudo
448 if (old
!= max_reg_num ())
449 expand_reg_data (old
);
452 /* The number of emitted reload insns so far. */
453 int lra_curr_reload_num
;
455 /* Emit x := y, processing special case when y = u + v or y = u + v *
456 scale + w through emit_add (Y can be an address which is base +
457 index reg * scale + displacement in general case). X may be used
458 as intermediate result therefore it should be not in Y. */
460 lra_emit_move (rtx x
, rtx y
)
464 if (GET_CODE (y
) != PLUS
)
466 if (rtx_equal_p (x
, y
))
468 old
= max_reg_num ();
469 emit_move_insn (x
, y
);
471 lra_reg_info
[ORIGINAL_REGNO (x
)].last_reload
= ++lra_curr_reload_num
;
472 /* Function emit_move can create pseudos -- so expand the pseudo
474 if (old
!= max_reg_num ())
475 expand_reg_data (old
);
478 lra_emit_add (x
, XEXP (y
, 0), XEXP (y
, 1));
481 /* Update insn operands which are duplication of operands whose
482 numbers are in array of NOPS (with end marker -1). The insn is
483 represented by its LRA internal representation ID. */
485 lra_update_dups (lra_insn_recog_data_t id
, signed char *nops
)
488 struct lra_static_insn_data
*static_id
= id
->insn_static_data
;
490 for (i
= 0; i
< static_id
->n_dups
; i
++)
491 for (j
= 0; (nop
= nops
[j
]) >= 0; j
++)
492 if (static_id
->dup_num
[i
] == nop
)
493 *id
->dup_loc
[i
] = *id
->operand_loc
[nop
];
498 /* This page contains code dealing with info about registers in the
501 /* Pools for insn reg info. */
502 static alloc_pool insn_reg_pool
;
504 /* Initiate pool for insn reg info. */
506 init_insn_regs (void)
509 = create_alloc_pool ("insn regs", sizeof (struct lra_insn_reg
), 100);
512 /* Create LRA insn related info about a reference to REGNO in INSN with
513 TYPE (in/out/inout), biggest reference mode MODE, flag that it is
514 reference through subreg (SUBREG_P), flag that is early clobbered
515 in the insn (EARLY_CLOBBER), and reference to the next insn reg
517 static struct lra_insn_reg
*
518 new_insn_reg (rtx_insn
*insn
, int regno
, enum op_type type
,
520 bool subreg_p
, bool early_clobber
, struct lra_insn_reg
*next
)
522 struct lra_insn_reg
*ir
;
524 ir
= (struct lra_insn_reg
*) pool_alloc (insn_reg_pool
);
526 ir
->biggest_mode
= mode
;
527 if (GET_MODE_SIZE (mode
) > GET_MODE_SIZE (lra_reg_info
[regno
].biggest_mode
)
528 && NONDEBUG_INSN_P (insn
))
529 lra_reg_info
[regno
].biggest_mode
= mode
;
530 ir
->subreg_p
= subreg_p
;
531 ir
->early_clobber
= early_clobber
;
537 /* Free insn reg info IR. */
539 free_insn_reg (struct lra_insn_reg
*ir
)
541 pool_free (insn_reg_pool
, ir
);
544 /* Free insn reg info list IR. */
546 free_insn_regs (struct lra_insn_reg
*ir
)
548 struct lra_insn_reg
*next_ir
;
550 for (; ir
!= NULL
; ir
= next_ir
)
557 /* Finish pool for insn reg info. */
559 finish_insn_regs (void)
561 free_alloc_pool (insn_reg_pool
);
566 /* This page contains code dealing LRA insn info (or in other words
567 LRA internal insn representation). */
569 /* Map INSN_CODE -> the static insn data. This info is valid during
570 all translation unit. */
571 struct lra_static_insn_data
*insn_code_data
[LAST_INSN_CODE
];
573 /* Debug insns are represented as a special insn with one input
574 operand which is RTL expression in var_location. */
576 /* The following data are used as static insn operand data for all
577 debug insns. If structure lra_operand_data is changed, the
578 initializer should be changed too. */
579 static struct lra_operand_data debug_operand_data
=
581 NULL
, /* alternative */
582 VOIDmode
, /* We are not interesting in the operand mode. */
587 /* The following data are used as static insn data for all debug
588 insns. If structure lra_static_insn_data is changed, the
589 initializer should be changed too. */
590 static struct lra_static_insn_data debug_insn_static_data
=
593 0, /* Duplication operands #. */
594 -1, /* Commutative operand #. */
595 1, /* Operands #. There is only one operand which is debug RTL
597 0, /* Duplications #. */
598 0, /* Alternatives #. We are not interesting in alternatives
599 because we does not proceed debug_insns for reloads. */
600 NULL
, /* Hard registers referenced in machine description. */
601 NULL
/* Descriptions of operands in alternatives. */
604 /* Called once per compiler work to initialize some LRA data related
607 init_insn_code_data_once (void)
609 memset (insn_code_data
, 0, sizeof (insn_code_data
));
612 /* Called once per compiler work to finalize some LRA data related to
615 finish_insn_code_data_once (void)
619 for (i
= 0; i
< LAST_INSN_CODE
; i
++)
621 if (insn_code_data
[i
] != NULL
)
622 free (insn_code_data
[i
]);
626 /* Return static insn data, allocate and setup if necessary. Although
627 dup_num is static data (it depends only on icode), to set it up we
628 need to extract insn first. So recog_data should be valid for
629 normal insn (ICODE >= 0) before the call. */
630 static struct lra_static_insn_data
*
631 get_static_insn_data (int icode
, int nop
, int ndup
, int nalt
)
633 struct lra_static_insn_data
*data
;
636 lra_assert (icode
< LAST_INSN_CODE
);
637 if (icode
>= 0 && (data
= insn_code_data
[icode
]) != NULL
)
639 lra_assert (nop
>= 0 && ndup
>= 0 && nalt
>= 0);
640 n_bytes
= sizeof (struct lra_static_insn_data
)
641 + sizeof (struct lra_operand_data
) * nop
642 + sizeof (int) * ndup
;
643 data
= XNEWVAR (struct lra_static_insn_data
, n_bytes
);
644 data
->operand_alternative
= NULL
;
645 data
->n_operands
= nop
;
647 data
->n_alternatives
= nalt
;
648 data
->operand
= ((struct lra_operand_data
*)
649 ((char *) data
+ sizeof (struct lra_static_insn_data
)));
650 data
->dup_num
= ((int *) ((char *) data
->operand
651 + sizeof (struct lra_operand_data
) * nop
));
656 insn_code_data
[icode
] = data
;
657 for (i
= 0; i
< nop
; i
++)
659 data
->operand
[i
].constraint
660 = insn_data
[icode
].operand
[i
].constraint
;
661 data
->operand
[i
].mode
= insn_data
[icode
].operand
[i
].mode
;
662 data
->operand
[i
].strict_low
= insn_data
[icode
].operand
[i
].strict_low
;
663 data
->operand
[i
].is_operator
664 = insn_data
[icode
].operand
[i
].is_operator
;
665 data
->operand
[i
].type
666 = (data
->operand
[i
].constraint
[0] == '=' ? OP_OUT
667 : data
->operand
[i
].constraint
[0] == '+' ? OP_INOUT
669 data
->operand
[i
].is_address
= false;
671 for (i
= 0; i
< ndup
; i
++)
672 data
->dup_num
[i
] = recog_data
.dup_num
[i
];
677 /* The current length of the following array. */
678 int lra_insn_recog_data_len
;
680 /* Map INSN_UID -> the insn recog data (NULL if unknown). */
681 lra_insn_recog_data_t
*lra_insn_recog_data
;
683 /* Initialize LRA data about insns. */
685 init_insn_recog_data (void)
687 lra_insn_recog_data_len
= 0;
688 lra_insn_recog_data
= NULL
;
692 /* Expand, if necessary, LRA data about insns. */
694 check_and_expand_insn_recog_data (int index
)
698 if (lra_insn_recog_data_len
> index
)
700 old
= lra_insn_recog_data_len
;
701 lra_insn_recog_data_len
= index
* 3 / 2 + 1;
702 lra_insn_recog_data
= XRESIZEVEC (lra_insn_recog_data_t
,
704 lra_insn_recog_data_len
);
705 for (i
= old
; i
< lra_insn_recog_data_len
; i
++)
706 lra_insn_recog_data
[i
] = NULL
;
709 /* Finish LRA DATA about insn. */
711 free_insn_recog_data (lra_insn_recog_data_t data
)
713 if (data
->operand_loc
!= NULL
)
714 free (data
->operand_loc
);
715 if (data
->dup_loc
!= NULL
)
716 free (data
->dup_loc
);
717 if (data
->arg_hard_regs
!= NULL
)
718 free (data
->arg_hard_regs
);
719 if (data
->icode
< 0 && NONDEBUG_INSN_P (data
->insn
))
721 if (data
->insn_static_data
->operand_alternative
!= NULL
)
722 free (const_cast <operand_alternative
*>
723 (data
->insn_static_data
->operand_alternative
));
724 free_insn_regs (data
->insn_static_data
->hard_regs
);
725 free (data
->insn_static_data
);
727 free_insn_regs (data
->regs
);
732 /* Finish LRA data about all insns. */
734 finish_insn_recog_data (void)
737 lra_insn_recog_data_t data
;
739 for (i
= 0; i
< lra_insn_recog_data_len
; i
++)
740 if ((data
= lra_insn_recog_data
[i
]) != NULL
)
741 free_insn_recog_data (data
);
743 free (lra_insn_recog_data
);
746 /* Setup info about operands in alternatives of LRA DATA of insn. */
748 setup_operand_alternative (lra_insn_recog_data_t data
,
749 const operand_alternative
*op_alt
)
752 int icode
= data
->icode
;
753 struct lra_static_insn_data
*static_data
= data
->insn_static_data
;
755 static_data
->commutative
= -1;
756 nop
= static_data
->n_operands
;
757 nalt
= static_data
->n_alternatives
;
758 static_data
->operand_alternative
= op_alt
;
759 for (i
= 0; i
< nop
; i
++)
761 static_data
->operand
[i
].early_clobber
= false;
762 static_data
->operand
[i
].is_address
= false;
763 if (static_data
->operand
[i
].constraint
[0] == '%')
765 /* We currently only support one commutative pair of operands. */
766 if (static_data
->commutative
< 0)
767 static_data
->commutative
= i
;
769 lra_assert (icode
< 0); /* Asm */
770 /* The last operand should not be marked commutative. */
771 lra_assert (i
!= nop
- 1);
774 for (j
= 0; j
< nalt
; j
++)
775 for (i
= 0; i
< nop
; i
++, op_alt
++)
777 static_data
->operand
[i
].early_clobber
|= op_alt
->earlyclobber
;
778 static_data
->operand
[i
].is_address
|= op_alt
->is_address
;
782 /* Recursively process X and collect info about registers, which are
783 not the insn operands, in X with TYPE (in/out/inout) and flag that
784 it is early clobbered in the insn (EARLY_CLOBBER) and add the info
785 to LIST. X is a part of insn given by DATA. Return the result
787 static struct lra_insn_reg
*
788 collect_non_operand_hard_regs (rtx
*x
, lra_insn_recog_data_t data
,
789 struct lra_insn_reg
*list
,
790 enum op_type type
, bool early_clobber
)
792 int i
, j
, regno
, last
;
795 struct lra_insn_reg
*curr
;
797 enum rtx_code code
= GET_CODE (op
);
798 const char *fmt
= GET_RTX_FORMAT (code
);
800 for (i
= 0; i
< data
->insn_static_data
->n_operands
; i
++)
801 if (x
== data
->operand_loc
[i
])
802 /* It is an operand loc. Stop here. */
804 for (i
= 0; i
< data
->insn_static_data
->n_dups
; i
++)
805 if (x
== data
->dup_loc
[i
])
806 /* It is a dup loc. Stop here. */
808 mode
= GET_MODE (op
);
812 op
= SUBREG_REG (op
);
813 code
= GET_CODE (op
);
814 if (GET_MODE_SIZE (mode
) < GET_MODE_SIZE (GET_MODE (op
)))
816 mode
= GET_MODE (op
);
817 if (GET_MODE_SIZE (mode
) > REGMODE_NATURAL_SIZE (mode
))
823 if ((regno
= REGNO (op
)) >= FIRST_PSEUDO_REGISTER
)
825 for (last
= regno
+ hard_regno_nregs
[regno
][mode
];
828 if (! TEST_HARD_REG_BIT (lra_no_alloc_regs
, regno
)
829 || TEST_HARD_REG_BIT (eliminable_regset
, regno
))
831 for (curr
= list
; curr
!= NULL
; curr
= curr
->next
)
832 if (curr
->regno
== regno
&& curr
->subreg_p
== subreg_p
833 && curr
->biggest_mode
== mode
)
835 if (curr
->type
!= type
)
836 curr
->type
= OP_INOUT
;
837 if (curr
->early_clobber
!= early_clobber
)
838 curr
->early_clobber
= true;
843 /* This is a new hard regno or the info can not be
844 integrated into the found structure. */
848 /* This clobber is to inform popping floating
850 && ! (FIRST_STACK_REG
<= regno
851 && regno
<= LAST_STACK_REG
));
853 list
= new_insn_reg (data
->insn
, regno
, type
, mode
, subreg_p
,
854 early_clobber
, list
);
862 list
= collect_non_operand_hard_regs (&SET_DEST (op
), data
,
863 list
, OP_OUT
, false);
864 list
= collect_non_operand_hard_regs (&SET_SRC (op
), data
,
868 /* We treat clobber of non-operand hard registers as early
869 clobber (the behavior is expected from asm). */
870 list
= collect_non_operand_hard_regs (&XEXP (op
, 0), data
,
873 case PRE_INC
: case PRE_DEC
: case POST_INC
: case POST_DEC
:
874 list
= collect_non_operand_hard_regs (&XEXP (op
, 0), data
,
875 list
, OP_INOUT
, false);
877 case PRE_MODIFY
: case POST_MODIFY
:
878 list
= collect_non_operand_hard_regs (&XEXP (op
, 0), data
,
879 list
, OP_INOUT
, false);
880 list
= collect_non_operand_hard_regs (&XEXP (op
, 1), data
,
884 fmt
= GET_RTX_FORMAT (code
);
885 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
888 list
= collect_non_operand_hard_regs (&XEXP (op
, i
), data
,
890 else if (fmt
[i
] == 'E')
891 for (j
= XVECLEN (op
, i
) - 1; j
>= 0; j
--)
892 list
= collect_non_operand_hard_regs (&XVECEXP (op
, i
, j
), data
,
899 /* Set up and return info about INSN. Set up the info if it is not set up
901 lra_insn_recog_data_t
902 lra_set_insn_recog_data (rtx_insn
*insn
)
904 lra_insn_recog_data_t data
;
907 unsigned int uid
= INSN_UID (insn
);
908 struct lra_static_insn_data
*insn_static_data
;
910 check_and_expand_insn_recog_data (uid
);
911 if (DEBUG_INSN_P (insn
))
915 icode
= INSN_CODE (insn
);
917 /* It might be a new simple insn which is not recognized yet. */
918 INSN_CODE (insn
) = icode
= recog_memoized (insn
);
920 data
= XNEW (struct lra_insn_recog_data
);
921 lra_insn_recog_data
[uid
] = data
;
923 data
->used_insn_alternative
= -1;
926 if (DEBUG_INSN_P (insn
))
928 data
->insn_static_data
= &debug_insn_static_data
;
929 data
->dup_loc
= NULL
;
930 data
->arg_hard_regs
= NULL
;
931 data
->preferred_alternatives
= ALL_ALTERNATIVES
;
932 data
->operand_loc
= XNEWVEC (rtx
*, 1);
933 data
->operand_loc
[0] = &INSN_VAR_LOCATION_LOC (insn
);
939 machine_mode operand_mode
[MAX_RECOG_OPERANDS
];
940 const char *constraints
[MAX_RECOG_OPERANDS
];
942 nop
= asm_noperands (PATTERN (insn
));
943 data
->operand_loc
= data
->dup_loc
= NULL
;
947 /* It is a special insn like USE or CLOBBER. We should
948 recognize any regular insn otherwise LRA can do nothing
950 gcc_assert (GET_CODE (PATTERN (insn
)) == USE
951 || GET_CODE (PATTERN (insn
)) == CLOBBER
952 || GET_CODE (PATTERN (insn
)) == ASM_INPUT
);
953 data
->insn_static_data
= insn_static_data
954 = get_static_insn_data (-1, 0, 0, nalt
);
958 /* expand_asm_operands makes sure there aren't too many
960 lra_assert (nop
<= MAX_RECOG_OPERANDS
);
962 data
->operand_loc
= XNEWVEC (rtx
*, nop
);
963 /* Now get the operand values and constraints out of the
965 decode_asm_operands (PATTERN (insn
), NULL
,
967 constraints
, operand_mode
, NULL
);
970 const char *p
= recog_data
.constraints
[0];
972 for (p
= constraints
[0]; *p
; p
++)
975 data
->insn_static_data
= insn_static_data
976 = get_static_insn_data (-1, nop
, 0, nalt
);
977 for (i
= 0; i
< nop
; i
++)
979 insn_static_data
->operand
[i
].mode
= operand_mode
[i
];
980 insn_static_data
->operand
[i
].constraint
= constraints
[i
];
981 insn_static_data
->operand
[i
].strict_low
= false;
982 insn_static_data
->operand
[i
].is_operator
= false;
983 insn_static_data
->operand
[i
].is_address
= false;
986 for (i
= 0; i
< insn_static_data
->n_operands
; i
++)
987 insn_static_data
->operand
[i
].type
988 = (insn_static_data
->operand
[i
].constraint
[0] == '=' ? OP_OUT
989 : insn_static_data
->operand
[i
].constraint
[0] == '+' ? OP_INOUT
991 data
->preferred_alternatives
= ALL_ALTERNATIVES
;
994 operand_alternative
*op_alt
= XCNEWVEC (operand_alternative
,
996 preprocess_constraints (nop
, nalt
, constraints
, op_alt
);
997 setup_operand_alternative (data
, op_alt
);
1002 insn_extract (insn
);
1003 data
->insn_static_data
= insn_static_data
1004 = get_static_insn_data (icode
, insn_data
[icode
].n_operands
,
1005 insn_data
[icode
].n_dups
,
1006 insn_data
[icode
].n_alternatives
);
1007 n
= insn_static_data
->n_operands
;
1012 locs
= XNEWVEC (rtx
*, n
);
1013 memcpy (locs
, recog_data
.operand_loc
, n
* sizeof (rtx
*));
1015 data
->operand_loc
= locs
;
1016 n
= insn_static_data
->n_dups
;
1021 locs
= XNEWVEC (rtx
*, n
);
1022 memcpy (locs
, recog_data
.dup_loc
, n
* sizeof (rtx
*));
1024 data
->dup_loc
= locs
;
1025 data
->preferred_alternatives
= get_preferred_alternatives (insn
);
1026 const operand_alternative
*op_alt
= preprocess_insn_constraints (icode
);
1027 if (!insn_static_data
->operand_alternative
)
1028 setup_operand_alternative (data
, op_alt
);
1029 else if (op_alt
!= insn_static_data
->operand_alternative
)
1030 insn_static_data
->operand_alternative
= op_alt
;
1032 if (GET_CODE (PATTERN (insn
)) == CLOBBER
|| GET_CODE (PATTERN (insn
)) == USE
)
1033 insn_static_data
->hard_regs
= NULL
;
1035 insn_static_data
->hard_regs
1036 = collect_non_operand_hard_regs (&PATTERN (insn
), data
,
1037 NULL
, OP_IN
, false);
1038 data
->arg_hard_regs
= NULL
;
1042 int n_hard_regs
, regno
, arg_hard_regs
[FIRST_PSEUDO_REGISTER
];
1045 /* Finding implicit hard register usage. We believe it will be
1046 not changed whatever transformations are used. Call insns
1047 are such example. */
1048 for (link
= CALL_INSN_FUNCTION_USAGE (insn
);
1050 link
= XEXP (link
, 1))
1051 if (GET_CODE (XEXP (link
, 0)) == USE
1052 && REG_P (XEXP (XEXP (link
, 0), 0)))
1054 regno
= REGNO (XEXP (XEXP (link
, 0), 0));
1055 lra_assert (regno
< FIRST_PSEUDO_REGISTER
);
1056 /* It is an argument register. */
1057 for (i
= (hard_regno_nregs
1058 [regno
][GET_MODE (XEXP (XEXP (link
, 0), 0))]) - 1;
1061 arg_hard_regs
[n_hard_regs
++] = regno
+ i
;
1063 if (n_hard_regs
!= 0)
1065 arg_hard_regs
[n_hard_regs
++] = -1;
1066 data
->arg_hard_regs
= XNEWVEC (int, n_hard_regs
);
1067 memcpy (data
->arg_hard_regs
, arg_hard_regs
,
1068 sizeof (int) * n_hard_regs
);
1071 /* Some output operand can be recognized only from the context not
1072 from the constraints which are empty in this case. Call insn may
1073 contain a hard register in set destination with empty constraint
1074 and extract_insn treats them as an input. */
1075 for (i
= 0; i
< insn_static_data
->n_operands
; i
++)
1079 struct lra_operand_data
*operand
= &insn_static_data
->operand
[i
];
1081 /* ??? Should we treat 'X' the same way. It looks to me that
1082 'X' means anything and empty constraint means we do not
1084 if (operand
->type
!= OP_IN
|| *operand
->constraint
!= '\0'
1085 || operand
->is_operator
)
1087 pat
= PATTERN (insn
);
1088 if (GET_CODE (pat
) == SET
)
1090 if (data
->operand_loc
[i
] != &SET_DEST (pat
))
1093 else if (GET_CODE (pat
) == PARALLEL
)
1095 for (j
= XVECLEN (pat
, 0) - 1; j
>= 0; j
--)
1097 set
= XVECEXP (PATTERN (insn
), 0, j
);
1098 if (GET_CODE (set
) == SET
1099 && &SET_DEST (set
) == data
->operand_loc
[i
])
1107 operand
->type
= OP_OUT
;
1112 /* Return info about insn give by UID. The info should be already set
1114 static lra_insn_recog_data_t
1115 get_insn_recog_data_by_uid (int uid
)
1117 lra_insn_recog_data_t data
;
1119 data
= lra_insn_recog_data
[uid
];
1120 lra_assert (data
!= NULL
);
1124 /* Invalidate all info about insn given by its UID. */
1126 invalidate_insn_recog_data (int uid
)
1128 lra_insn_recog_data_t data
;
1130 data
= lra_insn_recog_data
[uid
];
1131 lra_assert (data
!= NULL
);
1132 free_insn_recog_data (data
);
1133 lra_insn_recog_data
[uid
] = NULL
;
1136 /* Update all the insn info about INSN. It is usually called when
1137 something in the insn was changed. Return the updated info. */
1138 lra_insn_recog_data_t
1139 lra_update_insn_recog_data (rtx_insn
*insn
)
1141 lra_insn_recog_data_t data
;
1143 unsigned int uid
= INSN_UID (insn
);
1144 struct lra_static_insn_data
*insn_static_data
;
1145 HOST_WIDE_INT sp_offset
= 0;
1147 check_and_expand_insn_recog_data (uid
);
1148 if ((data
= lra_insn_recog_data
[uid
]) != NULL
1149 && data
->icode
!= INSN_CODE (insn
))
1151 sp_offset
= data
->sp_offset
;
1152 invalidate_insn_data_regno_info (data
, insn
, get_insn_freq (insn
));
1153 invalidate_insn_recog_data (uid
);
1158 data
= lra_get_insn_recog_data (insn
);
1159 /* Initiate or restore SP offset. */
1160 data
->sp_offset
= sp_offset
;
1163 insn_static_data
= data
->insn_static_data
;
1164 data
->used_insn_alternative
= -1;
1165 if (DEBUG_INSN_P (insn
))
1167 if (data
->icode
< 0)
1170 machine_mode operand_mode
[MAX_RECOG_OPERANDS
];
1171 const char *constraints
[MAX_RECOG_OPERANDS
];
1173 nop
= asm_noperands (PATTERN (insn
));
1176 lra_assert (nop
== data
->insn_static_data
->n_operands
);
1177 /* Now get the operand values and constraints out of the
1179 decode_asm_operands (PATTERN (insn
), NULL
,
1181 constraints
, operand_mode
, NULL
);
1182 #ifdef ENABLE_CHECKING
1186 for (i
= 0; i
< nop
; i
++)
1188 (insn_static_data
->operand
[i
].mode
== operand_mode
[i
]
1189 && insn_static_data
->operand
[i
].constraint
== constraints
[i
]
1190 && ! insn_static_data
->operand
[i
].is_operator
);
1194 #ifdef ENABLE_CHECKING
1198 for (i
= 0; i
< insn_static_data
->n_operands
; i
++)
1200 (insn_static_data
->operand
[i
].type
1201 == (insn_static_data
->operand
[i
].constraint
[0] == '=' ? OP_OUT
1202 : insn_static_data
->operand
[i
].constraint
[0] == '+' ? OP_INOUT
1209 insn_extract (insn
);
1210 n
= insn_static_data
->n_operands
;
1212 memcpy (data
->operand_loc
, recog_data
.operand_loc
, n
* sizeof (rtx
*));
1213 n
= insn_static_data
->n_dups
;
1215 memcpy (data
->dup_loc
, recog_data
.dup_loc
, n
* sizeof (rtx
*));
1216 lra_assert (check_bool_attrs (insn
));
1221 /* Set up that INSN is using alternative ALT now. */
1223 lra_set_used_insn_alternative (rtx_insn
*insn
, int alt
)
1225 lra_insn_recog_data_t data
;
1227 data
= lra_get_insn_recog_data (insn
);
1228 data
->used_insn_alternative
= alt
;
1231 /* Set up that insn with UID is using alternative ALT now. The insn
1232 info should be already set up. */
1234 lra_set_used_insn_alternative_by_uid (int uid
, int alt
)
1236 lra_insn_recog_data_t data
;
1238 check_and_expand_insn_recog_data (uid
);
1239 data
= lra_insn_recog_data
[uid
];
1240 lra_assert (data
!= NULL
);
1241 data
->used_insn_alternative
= alt
;
1246 /* This page contains code dealing with common register info and
1249 /* The size of the following array. */
1250 static int reg_info_size
;
1251 /* Common info about each register. */
1252 struct lra_reg
*lra_reg_info
;
1254 /* Last register value. */
1255 static int last_reg_value
;
1257 /* Return new register value. */
1259 get_new_reg_value (void)
1261 return ++last_reg_value
;
1264 /* Pools for copies. */
1265 static alloc_pool copy_pool
;
1267 /* Vec referring to pseudo copies. */
1268 static vec
<lra_copy_t
> copy_vec
;
1270 /* Initialize I-th element of lra_reg_info. */
1272 initialize_lra_reg_info_element (int i
)
1274 bitmap_initialize (&lra_reg_info
[i
].insn_bitmap
, ®_obstack
);
1276 lra_reg_info
[i
].no_stack_p
= false;
1278 CLEAR_HARD_REG_SET (lra_reg_info
[i
].conflict_hard_regs
);
1279 CLEAR_HARD_REG_SET (lra_reg_info
[i
].actual_call_used_reg_set
);
1280 lra_reg_info
[i
].preferred_hard_regno1
= -1;
1281 lra_reg_info
[i
].preferred_hard_regno2
= -1;
1282 lra_reg_info
[i
].preferred_hard_regno_profit1
= 0;
1283 lra_reg_info
[i
].preferred_hard_regno_profit2
= 0;
1284 lra_reg_info
[i
].biggest_mode
= VOIDmode
;
1285 lra_reg_info
[i
].live_ranges
= NULL
;
1286 lra_reg_info
[i
].nrefs
= lra_reg_info
[i
].freq
= 0;
1287 lra_reg_info
[i
].last_reload
= 0;
1288 lra_reg_info
[i
].restore_regno
= -1;
1289 lra_reg_info
[i
].val
= get_new_reg_value ();
1290 lra_reg_info
[i
].offset
= 0;
1291 lra_reg_info
[i
].copies
= NULL
;
1294 /* Initialize common reg info and copies. */
1296 init_reg_info (void)
1301 reg_info_size
= max_reg_num () * 3 / 2 + 1;
1302 lra_reg_info
= XNEWVEC (struct lra_reg
, reg_info_size
);
1303 for (i
= 0; i
< reg_info_size
; i
++)
1304 initialize_lra_reg_info_element (i
);
1306 = create_alloc_pool ("lra copies", sizeof (struct lra_copy
), 100);
1307 copy_vec
.create (100);
1311 /* Finish common reg info and copies. */
1313 finish_reg_info (void)
1317 for (i
= 0; i
< reg_info_size
; i
++)
1318 bitmap_clear (&lra_reg_info
[i
].insn_bitmap
);
1319 free (lra_reg_info
);
1321 free_alloc_pool (copy_pool
);
1322 copy_vec
.release ();
1325 /* Expand common reg info if it is necessary. */
1327 expand_reg_info (void)
1329 int i
, old
= reg_info_size
;
1331 if (reg_info_size
> max_reg_num ())
1333 reg_info_size
= max_reg_num () * 3 / 2 + 1;
1334 lra_reg_info
= XRESIZEVEC (struct lra_reg
, lra_reg_info
, reg_info_size
);
1335 for (i
= old
; i
< reg_info_size
; i
++)
1336 initialize_lra_reg_info_element (i
);
1339 /* Free all copies. */
1341 lra_free_copies (void)
1345 while (copy_vec
.length () != 0)
1347 cp
= copy_vec
.pop ();
1348 lra_reg_info
[cp
->regno1
].copies
= lra_reg_info
[cp
->regno2
].copies
= NULL
;
1349 pool_free (copy_pool
, cp
);
1353 /* Create copy of two pseudos REGNO1 and REGNO2. The copy execution
1354 frequency is FREQ. */
1356 lra_create_copy (int regno1
, int regno2
, int freq
)
1361 lra_assert (regno1
!= regno2
);
1362 regno1_dest_p
= true;
1363 if (regno1
> regno2
)
1367 regno1_dest_p
= false;
1371 cp
= (lra_copy_t
) pool_alloc (copy_pool
);
1372 copy_vec
.safe_push (cp
);
1373 cp
->regno1_dest_p
= regno1_dest_p
;
1375 cp
->regno1
= regno1
;
1376 cp
->regno2
= regno2
;
1377 cp
->regno1_next
= lra_reg_info
[regno1
].copies
;
1378 lra_reg_info
[regno1
].copies
= cp
;
1379 cp
->regno2_next
= lra_reg_info
[regno2
].copies
;
1380 lra_reg_info
[regno2
].copies
= cp
;
1381 if (lra_dump_file
!= NULL
)
1382 fprintf (lra_dump_file
, " Creating copy r%d%sr%d@%d\n",
1383 regno1
, regno1_dest_p
? "<-" : "->", regno2
, freq
);
1386 /* Return N-th (0, 1, ...) copy. If there is no copy, return
1389 lra_get_copy (int n
)
1391 if (n
>= (int) copy_vec
.length ())
1398 /* This page contains code dealing with info about registers in
1401 /* Process X of insn UID recursively and add info (operand type is
1402 given by TYPE, flag of that it is early clobber is EARLY_CLOBBER)
1403 about registers in X to the insn DATA. */
1405 add_regs_to_insn_regno_info (lra_insn_recog_data_t data
, rtx x
, int uid
,
1406 enum op_type type
, bool early_clobber
)
1413 struct lra_insn_reg
*curr
;
1415 code
= GET_CODE (x
);
1416 mode
= GET_MODE (x
);
1418 if (GET_CODE (x
) == SUBREG
)
1421 code
= GET_CODE (x
);
1422 if (GET_MODE_SIZE (mode
) < GET_MODE_SIZE (GET_MODE (x
)))
1424 mode
= GET_MODE (x
);
1425 if (GET_MODE_SIZE (mode
) > REGMODE_NATURAL_SIZE (mode
))
1432 if (regno
< FIRST_PSEUDO_REGISTER
1433 && TEST_HARD_REG_BIT (lra_no_alloc_regs
, regno
)
1434 && ! TEST_HARD_REG_BIT (eliminable_regset
, regno
))
1437 if (bitmap_set_bit (&lra_reg_info
[regno
].insn_bitmap
, uid
))
1439 data
->regs
= new_insn_reg (data
->insn
, regno
, type
, mode
, subreg_p
,
1440 early_clobber
, data
->regs
);
1445 for (curr
= data
->regs
; curr
!= NULL
; curr
= curr
->next
)
1446 if (curr
->regno
== regno
)
1448 if (curr
->subreg_p
!= subreg_p
|| curr
->biggest_mode
!= mode
)
1449 /* The info can not be integrated into the found
1451 data
->regs
= new_insn_reg (data
->insn
, regno
, type
, mode
,
1452 subreg_p
, early_clobber
,
1456 if (curr
->type
!= type
)
1457 curr
->type
= OP_INOUT
;
1458 if (curr
->early_clobber
!= early_clobber
)
1459 curr
->early_clobber
= true;
1470 add_regs_to_insn_regno_info (data
, SET_DEST (x
), uid
, OP_OUT
, false);
1471 add_regs_to_insn_regno_info (data
, SET_SRC (x
), uid
, OP_IN
, false);
1474 /* We treat clobber of non-operand hard registers as early
1475 clobber (the behavior is expected from asm). */
1476 add_regs_to_insn_regno_info (data
, XEXP (x
, 0), uid
, OP_OUT
, true);
1478 case PRE_INC
: case PRE_DEC
: case POST_INC
: case POST_DEC
:
1479 add_regs_to_insn_regno_info (data
, XEXP (x
, 0), uid
, OP_INOUT
, false);
1481 case PRE_MODIFY
: case POST_MODIFY
:
1482 add_regs_to_insn_regno_info (data
, XEXP (x
, 0), uid
, OP_INOUT
, false);
1483 add_regs_to_insn_regno_info (data
, XEXP (x
, 1), uid
, OP_IN
, false);
1486 if ((code
!= PARALLEL
&& code
!= EXPR_LIST
) || type
!= OP_OUT
)
1487 /* Some targets place small structures in registers for return
1488 values of functions, and those registers are wrapped in
1489 PARALLEL that we may see as the destination of a SET. Here
1492 (call_insn 13 12 14 2 (set (parallel:BLK [
1493 (expr_list:REG_DEP_TRUE (reg:DI 0 ax)
1495 (expr_list:REG_DEP_TRUE (reg:DI 1 dx)
1496 (const_int 8 [0x8]))
1498 (call (mem:QI (symbol_ref:DI (... */
1500 fmt
= GET_RTX_FORMAT (code
);
1501 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
1504 add_regs_to_insn_regno_info (data
, XEXP (x
, i
), uid
, type
, false);
1505 else if (fmt
[i
] == 'E')
1507 for (j
= XVECLEN (x
, i
) - 1; j
>= 0; j
--)
1508 add_regs_to_insn_regno_info (data
, XVECEXP (x
, i
, j
), uid
,
1515 /* Return execution frequency of INSN. */
1517 get_insn_freq (rtx_insn
*insn
)
1519 basic_block bb
= BLOCK_FOR_INSN (insn
);
1521 gcc_checking_assert (bb
!= NULL
);
1522 return REG_FREQ_FROM_BB (bb
);
1525 /* Invalidate all reg info of INSN with DATA and execution frequency
1526 FREQ. Update common info about the invalidated registers. */
1528 invalidate_insn_data_regno_info (lra_insn_recog_data_t data
, rtx_insn
*insn
,
1534 struct lra_insn_reg
*ir
, *next_ir
;
1536 uid
= INSN_UID (insn
);
1537 debug_p
= DEBUG_INSN_P (insn
);
1538 for (ir
= data
->regs
; ir
!= NULL
; ir
= next_ir
)
1543 bitmap_clear_bit (&lra_reg_info
[i
].insn_bitmap
, uid
);
1544 if (i
>= FIRST_PSEUDO_REGISTER
&& ! debug_p
)
1546 lra_reg_info
[i
].nrefs
--;
1547 lra_reg_info
[i
].freq
-= freq
;
1548 lra_assert (lra_reg_info
[i
].nrefs
>= 0 && lra_reg_info
[i
].freq
>= 0);
1554 /* Invalidate all reg info of INSN. Update common info about the
1555 invalidated registers. */
1557 lra_invalidate_insn_regno_info (rtx_insn
*insn
)
1559 invalidate_insn_data_regno_info (lra_get_insn_recog_data (insn
), insn
,
1560 get_insn_freq (insn
));
1563 /* Update common reg info from reg info of insn given by its DATA and
1564 execution frequency FREQ. */
1566 setup_insn_reg_info (lra_insn_recog_data_t data
, int freq
)
1569 struct lra_insn_reg
*ir
;
1571 for (ir
= data
->regs
; ir
!= NULL
; ir
= ir
->next
)
1572 if ((i
= ir
->regno
) >= FIRST_PSEUDO_REGISTER
)
1574 lra_reg_info
[i
].nrefs
++;
1575 lra_reg_info
[i
].freq
+= freq
;
1579 /* Set up insn reg info of INSN. Update common reg info from reg info
1582 lra_update_insn_regno_info (rtx_insn
*insn
)
1585 lra_insn_recog_data_t data
;
1586 struct lra_static_insn_data
*static_data
;
1589 if (! INSN_P (insn
))
1591 data
= lra_get_insn_recog_data (insn
);
1592 static_data
= data
->insn_static_data
;
1593 freq
= get_insn_freq (insn
);
1594 invalidate_insn_data_regno_info (data
, insn
, freq
);
1595 uid
= INSN_UID (insn
);
1596 for (i
= static_data
->n_operands
- 1; i
>= 0; i
--)
1597 add_regs_to_insn_regno_info (data
, *data
->operand_loc
[i
], uid
,
1598 static_data
->operand
[i
].type
,
1599 static_data
->operand
[i
].early_clobber
);
1600 if ((code
= GET_CODE (PATTERN (insn
))) == CLOBBER
|| code
== USE
)
1601 add_regs_to_insn_regno_info (data
, XEXP (PATTERN (insn
), 0), uid
,
1602 code
== USE
? OP_IN
: OP_OUT
, false);
1603 if (NONDEBUG_INSN_P (insn
))
1604 setup_insn_reg_info (data
, freq
);
1607 /* Return reg info of insn given by it UID. */
1608 struct lra_insn_reg
*
1609 lra_get_insn_regs (int uid
)
1611 lra_insn_recog_data_t data
;
1613 data
= get_insn_recog_data_by_uid (uid
);
1619 /* This page contains code dealing with stack of the insns which
1620 should be processed by the next constraint pass. */
1622 /* Bitmap used to put an insn on the stack only in one exemplar. */
1623 static sbitmap lra_constraint_insn_stack_bitmap
;
1625 /* The stack itself. */
1626 vec
<rtx_insn
*> lra_constraint_insn_stack
;
1628 /* Put INSN on the stack. If ALWAYS_UPDATE is true, always update the reg
1629 info for INSN, otherwise only update it if INSN is not already on the
1632 lra_push_insn_1 (rtx_insn
*insn
, bool always_update
)
1634 unsigned int uid
= INSN_UID (insn
);
1636 lra_update_insn_regno_info (insn
);
1637 if (uid
>= SBITMAP_SIZE (lra_constraint_insn_stack_bitmap
))
1638 lra_constraint_insn_stack_bitmap
=
1639 sbitmap_resize (lra_constraint_insn_stack_bitmap
, 3 * uid
/ 2, 0);
1640 if (bitmap_bit_p (lra_constraint_insn_stack_bitmap
, uid
))
1642 bitmap_set_bit (lra_constraint_insn_stack_bitmap
, uid
);
1643 if (! always_update
)
1644 lra_update_insn_regno_info (insn
);
1645 lra_constraint_insn_stack
.safe_push (insn
);
1648 /* Put INSN on the stack. */
1650 lra_push_insn (rtx_insn
*insn
)
1652 lra_push_insn_1 (insn
, false);
1655 /* Put INSN on the stack and update its reg info. */
1657 lra_push_insn_and_update_insn_regno_info (rtx_insn
*insn
)
1659 lra_push_insn_1 (insn
, true);
1662 /* Put insn with UID on the stack. */
1664 lra_push_insn_by_uid (unsigned int uid
)
1666 lra_push_insn (lra_insn_recog_data
[uid
]->insn
);
1669 /* Take the last-inserted insns off the stack and return it. */
1673 rtx_insn
*insn
= lra_constraint_insn_stack
.pop ();
1674 bitmap_clear_bit (lra_constraint_insn_stack_bitmap
, INSN_UID (insn
));
1678 /* Return the current size of the insn stack. */
1680 lra_insn_stack_length (void)
1682 return lra_constraint_insn_stack
.length ();
1685 /* Push insns FROM to TO (excluding it) going in reverse order. */
1687 push_insns (rtx_insn
*from
, rtx_insn
*to
)
1691 if (from
== NULL_RTX
)
1693 for (insn
= from
; insn
!= to
; insn
= PREV_INSN (insn
))
1695 lra_push_insn (insn
);
1698 /* Set up sp offset for insn in range [FROM, LAST]. The offset is
1699 taken from the next BB insn after LAST or zero if there in such
1702 setup_sp_offset (rtx_insn
*from
, rtx_insn
*last
)
1704 rtx_insn
*before
= next_nonnote_insn_bb (last
);
1705 HOST_WIDE_INT offset
= (before
== NULL_RTX
|| ! INSN_P (before
)
1706 ? 0 : lra_get_insn_recog_data (before
)->sp_offset
);
1708 for (rtx_insn
*insn
= from
; insn
!= NEXT_INSN (last
); insn
= NEXT_INSN (insn
))
1709 lra_get_insn_recog_data (insn
)->sp_offset
= offset
;
1712 /* Emit insns BEFORE before INSN and insns AFTER after INSN. Put the
1713 insns onto the stack. Print about emitting the insns with
1716 lra_process_new_insns (rtx_insn
*insn
, rtx_insn
*before
, rtx_insn
*after
,
1721 if (before
== NULL_RTX
&& after
== NULL_RTX
)
1723 if (lra_dump_file
!= NULL
)
1725 dump_insn_slim (lra_dump_file
, insn
);
1726 if (before
!= NULL_RTX
)
1728 fprintf (lra_dump_file
," %s before:\n", title
);
1729 dump_rtl_slim (lra_dump_file
, before
, NULL
, -1, 0);
1731 if (after
!= NULL_RTX
)
1733 fprintf (lra_dump_file
, " %s after:\n", title
);
1734 dump_rtl_slim (lra_dump_file
, after
, NULL
, -1, 0);
1736 fprintf (lra_dump_file
, "\n");
1738 if (before
!= NULL_RTX
)
1740 emit_insn_before (before
, insn
);
1741 push_insns (PREV_INSN (insn
), PREV_INSN (before
));
1742 setup_sp_offset (before
, PREV_INSN (insn
));
1744 if (after
!= NULL_RTX
)
1746 for (last
= after
; NEXT_INSN (last
) != NULL_RTX
; last
= NEXT_INSN (last
))
1748 emit_insn_after (after
, insn
);
1749 push_insns (last
, insn
);
1750 setup_sp_offset (after
, last
);
1756 /* This page contains code dealing with scratches (changing them onto
1757 pseudos and restoring them from the pseudos).
1759 We change scratches into pseudos at the beginning of LRA to
1760 simplify dealing with them (conflicts, hard register assignments).
1762 If the pseudo denoting scratch was spilled it means that we do need
1763 a hard register for it. Such pseudos are transformed back to
1764 scratches at the end of LRA. */
1766 /* Description of location of a former scratch operand. */
1769 rtx_insn
*insn
; /* Insn where the scratch was. */
1770 int nop
; /* Number of the operand which was a scratch. */
1773 typedef struct sloc
*sloc_t
;
1775 /* Locations of the former scratches. */
1776 static vec
<sloc_t
> scratches
;
1778 /* Bitmap of scratch regnos. */
1779 static bitmap_head scratch_bitmap
;
1781 /* Bitmap of scratch operands. */
1782 static bitmap_head scratch_operand_bitmap
;
1784 /* Return true if pseudo REGNO is made of SCRATCH. */
1786 lra_former_scratch_p (int regno
)
1788 return bitmap_bit_p (&scratch_bitmap
, regno
);
1791 /* Return true if the operand NOP of INSN is a former scratch. */
1793 lra_former_scratch_operand_p (rtx_insn
*insn
, int nop
)
1795 return bitmap_bit_p (&scratch_operand_bitmap
,
1796 INSN_UID (insn
) * MAX_RECOG_OPERANDS
+ nop
) != 0;
1799 /* Change scratches onto pseudos and save their location. */
1801 remove_scratches (void)
1804 bool insn_changed_p
;
1809 lra_insn_recog_data_t id
;
1810 struct lra_static_insn_data
*static_id
;
1812 scratches
.create (get_max_uid ());
1813 bitmap_initialize (&scratch_bitmap
, ®_obstack
);
1814 bitmap_initialize (&scratch_operand_bitmap
, ®_obstack
);
1815 FOR_EACH_BB_FN (bb
, cfun
)
1816 FOR_BB_INSNS (bb
, insn
)
1819 id
= lra_get_insn_recog_data (insn
);
1820 static_id
= id
->insn_static_data
;
1821 insn_changed_p
= false;
1822 for (i
= 0; i
< static_id
->n_operands
; i
++)
1823 if (GET_CODE (*id
->operand_loc
[i
]) == SCRATCH
1824 && GET_MODE (*id
->operand_loc
[i
]) != VOIDmode
)
1826 insn_changed_p
= true;
1827 *id
->operand_loc
[i
] = reg
1828 = lra_create_new_reg (static_id
->operand
[i
].mode
,
1829 *id
->operand_loc
[i
], ALL_REGS
, NULL
);
1830 add_reg_note (insn
, REG_UNUSED
, reg
);
1831 lra_update_dup (id
, i
);
1832 loc
= XNEW (struct sloc
);
1835 scratches
.safe_push (loc
);
1836 bitmap_set_bit (&scratch_bitmap
, REGNO (*id
->operand_loc
[i
]));
1837 bitmap_set_bit (&scratch_operand_bitmap
,
1838 INSN_UID (insn
) * MAX_RECOG_OPERANDS
+ i
);
1839 if (lra_dump_file
!= NULL
)
1840 fprintf (lra_dump_file
,
1841 "Removing SCRATCH in insn #%u (nop %d)\n",
1842 INSN_UID (insn
), i
);
1845 /* Because we might use DF right after caller-saves sub-pass
1846 we need to keep DF info up to date. */
1847 df_insn_rescan (insn
);
1851 /* Changes pseudos created by function remove_scratches onto scratches. */
1853 restore_scratches (void)
1858 rtx_insn
*last
= NULL
;
1859 lra_insn_recog_data_t id
= NULL
;
1861 for (i
= 0; scratches
.iterate (i
, &loc
); i
++)
1863 if (last
!= loc
->insn
)
1866 id
= lra_get_insn_recog_data (last
);
1868 if (REG_P (*id
->operand_loc
[loc
->nop
])
1869 && ((regno
= REGNO (*id
->operand_loc
[loc
->nop
]))
1870 >= FIRST_PSEUDO_REGISTER
)
1871 && lra_get_regno_hard_regno (regno
) < 0)
1873 /* It should be only case when scratch register with chosen
1874 constraint 'X' did not get memory or hard register. */
1875 lra_assert (lra_former_scratch_p (regno
));
1876 *id
->operand_loc
[loc
->nop
]
1877 = gen_rtx_SCRATCH (GET_MODE (*id
->operand_loc
[loc
->nop
]));
1878 lra_update_dup (id
, loc
->nop
);
1879 if (lra_dump_file
!= NULL
)
1880 fprintf (lra_dump_file
, "Restoring SCRATCH in insn #%u(nop %d)\n",
1881 INSN_UID (loc
->insn
), loc
->nop
);
1884 for (i
= 0; scratches
.iterate (i
, &loc
); i
++)
1886 scratches
.release ();
1887 bitmap_clear (&scratch_bitmap
);
1888 bitmap_clear (&scratch_operand_bitmap
);
1893 #ifdef ENABLE_CHECKING
1895 /* Function checks RTL for correctness. If FINAL_P is true, it is
1896 done at the end of LRA and the check is more rigorous. */
1898 check_rtl (bool final_p
)
1903 lra_assert (! final_p
|| reload_completed
);
1904 FOR_EACH_BB_FN (bb
, cfun
)
1905 FOR_BB_INSNS (bb
, insn
)
1906 if (NONDEBUG_INSN_P (insn
)
1907 && GET_CODE (PATTERN (insn
)) != USE
1908 && GET_CODE (PATTERN (insn
)) != CLOBBER
1909 && GET_CODE (PATTERN (insn
)) != ASM_INPUT
)
1913 #ifdef ENABLED_CHECKING
1914 extract_constrain_insn (insn
);
1918 /* LRA code is based on assumption that all addresses can be
1919 correctly decomposed. LRA can generate reloads for
1920 decomposable addresses. The decomposition code checks the
1921 correctness of the addresses. So we don't need to check
1922 the addresses here. Don't call insn_invalid_p here, it can
1923 change the code at this stage. */
1924 if (recog_memoized (insn
) < 0 && asm_noperands (PATTERN (insn
)) < 0)
1925 fatal_insn_not_found (insn
);
1928 #endif /* #ifdef ENABLE_CHECKING */
1930 /* Determine if the current function has an exception receiver block
1931 that reaches the exit block via non-exceptional edges */
1933 has_nonexceptional_receiver (void)
1937 basic_block
*tos
, *worklist
, bb
;
1939 /* If we're not optimizing, then just err on the safe side. */
1943 /* First determine which blocks can reach exit via normal paths. */
1944 tos
= worklist
= XNEWVEC (basic_block
, n_basic_blocks_for_fn (cfun
) + 1);
1946 FOR_EACH_BB_FN (bb
, cfun
)
1947 bb
->flags
&= ~BB_REACHABLE
;
1949 /* Place the exit block on our worklist. */
1950 EXIT_BLOCK_PTR_FOR_FN (cfun
)->flags
|= BB_REACHABLE
;
1951 *tos
++ = EXIT_BLOCK_PTR_FOR_FN (cfun
);
1953 /* Iterate: find everything reachable from what we've already seen. */
1954 while (tos
!= worklist
)
1958 FOR_EACH_EDGE (e
, ei
, bb
->preds
)
1959 if (e
->flags
& EDGE_ABNORMAL
)
1966 basic_block src
= e
->src
;
1968 if (!(src
->flags
& BB_REACHABLE
))
1970 src
->flags
|= BB_REACHABLE
;
1976 /* No exceptional block reached exit unexceptionally. */
1982 /* Process recursively X of INSN and add REG_INC notes if necessary. */
1984 add_auto_inc_notes (rtx_insn
*insn
, rtx x
)
1986 enum rtx_code code
= GET_CODE (x
);
1990 if (code
== MEM
&& auto_inc_p (XEXP (x
, 0)))
1992 add_reg_note (insn
, REG_INC
, XEXP (XEXP (x
, 0), 0));
1996 /* Scan all X sub-expressions. */
1997 fmt
= GET_RTX_FORMAT (code
);
1998 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
2001 add_auto_inc_notes (insn
, XEXP (x
, i
));
2002 else if (fmt
[i
] == 'E')
2003 for (j
= XVECLEN (x
, i
) - 1; j
>= 0; j
--)
2004 add_auto_inc_notes (insn
, XVECEXP (x
, i
, j
));
2010 /* Remove all REG_DEAD and REG_UNUSED notes and regenerate REG_INC.
2011 We change pseudos by hard registers without notification of DF and
2012 that can make the notes obsolete. DF-infrastructure does not deal
2013 with REG_INC notes -- so we should regenerate them here. */
2015 update_inc_notes (void)
2021 FOR_EACH_BB_FN (bb
, cfun
)
2022 FOR_BB_INSNS (bb
, insn
)
2023 if (NONDEBUG_INSN_P (insn
))
2025 pnote
= ®_NOTES (insn
);
2028 if (REG_NOTE_KIND (*pnote
) == REG_DEAD
2029 || REG_NOTE_KIND (*pnote
) == REG_UNUSED
2030 || REG_NOTE_KIND (*pnote
) == REG_INC
)
2031 *pnote
= XEXP (*pnote
, 1);
2033 pnote
= &XEXP (*pnote
, 1);
2036 add_auto_inc_notes (insn
, PATTERN (insn
));
2041 /* Set to 1 while in lra. */
2042 int lra_in_progress
;
2044 /* Start of pseudo regnos before the LRA. */
2045 int lra_new_regno_start
;
2047 /* Start of reload pseudo regnos before the new spill pass. */
2048 int lra_constraint_new_regno_start
;
2050 /* Inheritance pseudo regnos before the new spill pass. */
2051 bitmap_head lra_inheritance_pseudos
;
2053 /* Split regnos before the new spill pass. */
2054 bitmap_head lra_split_regs
;
2056 /* Reload pseudo regnos before the new assignmnet pass which still can
2057 be spilled after the assinment pass as memory is also accepted in
2058 insns for the reload pseudos. */
2059 bitmap_head lra_optional_reload_pseudos
;
2061 /* Pseudo regnos used for subreg reloads before the new assignment
2062 pass. Such pseudos still can be spilled after the assinment
2064 bitmap_head lra_subreg_reload_pseudos
;
2066 /* First UID of insns generated before a new spill pass. */
2067 int lra_constraint_new_insn_uid_start
;
2069 /* File used for output of LRA debug information. */
2070 FILE *lra_dump_file
;
2072 /* True if we should try spill into registers of different classes
2073 instead of memory. */
2074 bool lra_reg_spill_p
;
2076 /* Set up value LRA_REG_SPILL_P. */
2078 setup_reg_spill_flag (void)
2082 if (targetm
.spill_class
!= NULL
)
2083 for (cl
= 0; cl
< (int) LIM_REG_CLASSES
; cl
++)
2084 for (mode
= 0; mode
< MAX_MACHINE_MODE
; mode
++)
2085 if (targetm
.spill_class ((enum reg_class
) cl
,
2086 (machine_mode
) mode
) != NO_REGS
)
2088 lra_reg_spill_p
= true;
2091 lra_reg_spill_p
= false;
2094 /* True if the current function is too big to use regular algorithms
2095 in LRA. In other words, we should use simpler and faster algorithms
2096 in LRA. It also means we should not worry about generation code
2097 for caller saves. The value is set up in IRA. */
2100 /* Major LRA entry function. F is a file should be used to dump LRA
2106 bool live_p
, scratch_p
, inserted_p
;
2110 timevar_push (TV_LRA
);
2112 /* Make sure that the last insn is a note. Some subsequent passes
2114 emit_note (NOTE_INSN_DELETED
);
2116 COPY_HARD_REG_SET (lra_no_alloc_regs
, ira_no_alloc_regs
);
2121 init_insn_recog_data ();
2123 #ifdef ENABLE_CHECKING
2124 /* Some quick check on RTL generated by previous passes. */
2128 lra_in_progress
= 1;
2130 lra_live_range_iter
= lra_coalesce_iter
= lra_constraint_iter
= 0;
2131 lra_assignment_iter
= lra_assignment_iter_after_spill
= 0;
2132 lra_inheritance_iter
= lra_undo_inheritance_iter
= 0;
2134 setup_reg_spill_flag ();
2136 /* Function remove_scratches can creates new pseudos for clobbers --
2137 so set up lra_constraint_new_regno_start before its call to
2138 permit changing reg classes for pseudos created by this
2140 lra_constraint_new_regno_start
= lra_new_regno_start
= max_reg_num ();
2141 remove_scratches ();
2142 scratch_p
= lra_constraint_new_regno_start
!= max_reg_num ();
2144 /* A function that has a non-local label that can reach the exit
2145 block via non-exceptional paths must save all call-saved
2147 if (cfun
->has_nonlocal_label
&& has_nonexceptional_receiver ())
2148 crtl
->saves_all_registers
= 1;
2150 if (crtl
->saves_all_registers
)
2151 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
2152 if (! call_used_regs
[i
] && ! fixed_regs
[i
] && ! LOCAL_REGNO (i
))
2153 df_set_regs_ever_live (i
, true);
2155 /* We don't DF from now and avoid its using because it is to
2156 expensive when a lot of RTL changes are made. */
2157 df_set_flags (DF_NO_INSN_RESCAN
);
2158 lra_constraint_insn_stack
.create (get_max_uid ());
2159 lra_constraint_insn_stack_bitmap
= sbitmap_alloc (get_max_uid ());
2160 bitmap_clear (lra_constraint_insn_stack_bitmap
);
2161 lra_live_ranges_init ();
2162 lra_constraints_init ();
2163 lra_curr_reload_num
= 0;
2164 push_insns (get_last_insn (), NULL
);
2165 /* It is needed for the 1st coalescing. */
2166 lra_constraint_new_insn_uid_start
= get_max_uid ();
2167 bitmap_initialize (&lra_inheritance_pseudos
, ®_obstack
);
2168 bitmap_initialize (&lra_split_regs
, ®_obstack
);
2169 bitmap_initialize (&lra_optional_reload_pseudos
, ®_obstack
);
2170 bitmap_initialize (&lra_subreg_reload_pseudos
, ®_obstack
);
2172 if (get_frame_size () != 0 && crtl
->stack_alignment_needed
)
2173 /* If we have a stack frame, we must align it now. The stack size
2174 may be a part of the offset computation for register
2176 assign_stack_local (BLKmode
, 0, crtl
->stack_alignment_needed
);
2182 /* We should try to assign hard registers to scratches even
2183 if there were no RTL transformations in
2185 if (! lra_constraints (lra_constraint_iter
== 0)
2186 && (lra_constraint_iter
> 1
2187 || (! scratch_p
&& ! caller_save_needed
)))
2189 /* Constraint transformations may result in that eliminable
2190 hard regs become uneliminable and pseudos which use them
2191 should be spilled. It is better to do it before pseudo
2194 For example, rs6000 can make
2195 RS6000_PIC_OFFSET_TABLE_REGNUM uneliminable if we started
2196 to use a constant pool. */
2197 lra_eliminate (false, false);
2198 /* Do inheritance only for regular algorithms. */
2201 if (flag_use_caller_save
)
2204 lra_clear_live_ranges ();
2205 /* As a side-effect of lra_create_live_ranges, we calculate
2206 actual_call_used_reg_set, which is needed during
2208 lra_create_live_ranges (true);
2213 lra_clear_live_ranges ();
2214 /* We need live ranges for lra_assign -- so build them. */
2215 lra_create_live_ranges (true);
2217 /* If we don't spill non-reload and non-inheritance pseudos,
2218 there is no sense to run memory-memory move coalescing.
2219 If inheritance pseudos were spilled, the memory-memory
2220 moves involving them will be removed by pass undoing
2226 bool spill_p
= !lra_assign ();
2228 if (lra_undo_inheritance ())
2234 lra_create_live_ranges (true);
2237 if (lra_coalesce ())
2241 lra_clear_live_ranges ();
2244 /* Don't clear optional reloads bitmap until all constraints are
2245 satisfied as we need to differ them from regular reloads. */
2246 bitmap_clear (&lra_optional_reload_pseudos
);
2247 bitmap_clear (&lra_subreg_reload_pseudos
);
2248 bitmap_clear (&lra_inheritance_pseudos
);
2249 bitmap_clear (&lra_split_regs
);
2250 if (! lra_need_for_spills_p ())
2254 /* We need full live info for spilling pseudos into
2255 registers instead of memory. */
2256 lra_create_live_ranges (lra_reg_spill_p
);
2260 /* Assignment of stack slots changes elimination offsets for
2261 some eliminations. So update the offsets here. */
2262 lra_eliminate (false, false);
2263 lra_constraint_new_regno_start
= max_reg_num ();
2264 lra_constraint_new_insn_uid_start
= get_max_uid ();
2265 lra_assignment_iter_after_spill
= 0;
2267 restore_scratches ();
2268 lra_eliminate (true, false);
2269 lra_final_code_change ();
2270 lra_in_progress
= 0;
2272 lra_clear_live_ranges ();
2273 lra_live_ranges_finish ();
2274 lra_constraints_finish ();
2276 sbitmap_free (lra_constraint_insn_stack_bitmap
);
2277 lra_constraint_insn_stack
.release ();
2278 finish_insn_recog_data ();
2279 regstat_free_n_sets_and_refs ();
2281 reload_completed
= 1;
2282 update_inc_notes ();
2284 inserted_p
= fixup_abnormal_edges ();
2286 /* We've possibly turned single trapping insn into multiple ones. */
2287 if (cfun
->can_throw_non_call_exceptions
)
2290 blocks
= sbitmap_alloc (last_basic_block_for_fn (cfun
));
2291 bitmap_ones (blocks
);
2292 find_many_sub_basic_blocks (blocks
);
2293 sbitmap_free (blocks
);
2297 commit_edge_insertions ();
2299 /* Replacing pseudos with their memory equivalents might have
2300 created shared rtx. Subsequent passes would get confused
2301 by this, so unshare everything here. */
2302 unshare_all_rtl_again (get_insns ());
2304 #ifdef ENABLE_CHECKING
2308 timevar_pop (TV_LRA
);
2311 /* Called once per compiler to initialize LRA data once. */
2313 lra_init_once (void)
2315 init_insn_code_data_once ();
2318 /* Called once per compiler to finish LRA data which are initialize
2321 lra_finish_once (void)
2323 finish_insn_code_data_once ();