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"
116 #include "basic-block.h"
118 #include "tree-pass.h"
125 /* Hard registers currently not available for allocation. It can
126 changed after some hard registers become not eliminable. */
127 HARD_REG_SET lra_no_alloc_regs
;
129 static int get_new_reg_value (void);
130 static void expand_reg_info (void);
131 static void invalidate_insn_recog_data (int);
132 static int get_insn_freq (rtx_insn
*);
133 static void invalidate_insn_data_regno_info (lra_insn_recog_data_t
,
136 /* Expand all regno related info needed for LRA. */
138 expand_reg_data (int old
)
142 ira_expand_reg_equiv ();
143 for (int i
= (int) max_reg_num () - 1; i
>= old
; i
--)
144 lra_change_class (i
, ALL_REGS
, " Set", true);
147 /* Create and return a new reg of ORIGINAL mode. If ORIGINAL is NULL
148 or of VOIDmode, use MD_MODE for the new reg. Initialize its
149 register class to RCLASS. Print message about assigning class
150 RCLASS containing new register name TITLE unless it is NULL. Use
151 attributes of ORIGINAL if it is a register. The created register
152 will have unique held value. */
154 lra_create_new_reg_with_unique_value (enum machine_mode md_mode
, rtx original
,
155 enum reg_class rclass
, const char *title
)
157 enum machine_mode mode
;
160 if (original
== NULL_RTX
|| (mode
= GET_MODE (original
)) == VOIDmode
)
162 lra_assert (mode
!= VOIDmode
);
163 new_reg
= gen_reg_rtx (mode
);
164 if (original
== NULL_RTX
|| ! REG_P (original
))
166 if (lra_dump_file
!= NULL
)
167 fprintf (lra_dump_file
, " Creating newreg=%i", REGNO (new_reg
));
171 if (ORIGINAL_REGNO (original
) >= FIRST_PSEUDO_REGISTER
)
172 ORIGINAL_REGNO (new_reg
) = ORIGINAL_REGNO (original
);
173 REG_USERVAR_P (new_reg
) = REG_USERVAR_P (original
);
174 REG_POINTER (new_reg
) = REG_POINTER (original
);
175 REG_ATTRS (new_reg
) = REG_ATTRS (original
);
176 if (lra_dump_file
!= NULL
)
177 fprintf (lra_dump_file
, " Creating newreg=%i from oldreg=%i",
178 REGNO (new_reg
), REGNO (original
));
180 if (lra_dump_file
!= NULL
)
183 fprintf (lra_dump_file
, ", assigning class %s to%s%s r%d",
184 reg_class_names
[rclass
], *title
== '\0' ? "" : " ",
185 title
, REGNO (new_reg
));
186 fprintf (lra_dump_file
, "\n");
188 expand_reg_data (max_reg_num ());
189 setup_reg_classes (REGNO (new_reg
), rclass
, NO_REGS
, rclass
);
193 /* Analogous to the previous function but also inherits value of
196 lra_create_new_reg (enum machine_mode md_mode
, rtx original
,
197 enum reg_class rclass
, const char *title
)
202 = lra_create_new_reg_with_unique_value (md_mode
, original
, rclass
, title
);
203 if (original
!= NULL_RTX
&& REG_P (original
))
204 lra_assign_reg_val (REGNO (original
), REGNO (new_reg
));
208 /* Set up for REGNO unique hold value. */
210 lra_set_regno_unique_value (int regno
)
212 lra_reg_info
[regno
].val
= get_new_reg_value ();
215 /* Invalidate INSN related info used by LRA. The info should never be
218 lra_invalidate_insn_data (rtx_insn
*insn
)
220 lra_invalidate_insn_regno_info (insn
);
221 invalidate_insn_recog_data (INSN_UID (insn
));
224 /* Mark INSN deleted and invalidate the insn related info used by
227 lra_set_insn_deleted (rtx_insn
*insn
)
229 lra_invalidate_insn_data (insn
);
230 SET_INSN_DELETED (insn
);
233 /* Delete an unneeded INSN and any previous insns who sole purpose is
234 loading data that is dead in INSN. */
236 lra_delete_dead_insn (rtx_insn
*insn
)
238 rtx_insn
*prev
= prev_real_insn (insn
);
241 /* If the previous insn sets a register that dies in our insn,
243 if (prev
&& GET_CODE (PATTERN (prev
)) == SET
244 && (prev_dest
= SET_DEST (PATTERN (prev
)), REG_P (prev_dest
))
245 && reg_mentioned_p (prev_dest
, PATTERN (insn
))
246 && find_regno_note (insn
, REG_DEAD
, REGNO (prev_dest
))
247 && ! side_effects_p (SET_SRC (PATTERN (prev
))))
248 lra_delete_dead_insn (prev
);
250 lra_set_insn_deleted (insn
);
253 /* Emit insn x = y + z. Return NULL if we failed to do it.
254 Otherwise, return the insn. We don't use gen_add3_insn as it might
257 emit_add3_insn (rtx x
, rtx y
, rtx z
)
261 last
= get_last_insn ();
263 if (have_addptr3_insn (x
, y
, z
))
265 rtx insn
= gen_addptr3_insn (x
, y
, z
);
267 /* If the target provides an "addptr" pattern it hopefully does
268 for a reason. So falling back to the normal add would be
270 lra_assert (insn
!= NULL_RTX
);
275 rtx_insn
*insn
= emit_insn (gen_rtx_SET (VOIDmode
, x
,
276 gen_rtx_PLUS (GET_MODE (y
), y
, z
)));
277 if (recog_memoized (insn
) < 0)
279 delete_insns_since (last
);
285 /* Emit insn x = x + y. Return the insn. We use gen_add2_insn as the
288 emit_add2_insn (rtx x
, rtx y
)
292 insn
= emit_add3_insn (x
, x
, y
);
293 if (insn
== NULL_RTX
)
295 insn
= gen_add2_insn (x
, y
);
296 if (insn
!= NULL_RTX
)
302 /* Target checks operands through operand predicates to recognize an
303 insn. We should have a special precaution to generate add insns
304 which are frequent results of elimination.
306 Emit insns for x = y + z. X can be used to store intermediate
307 values and should be not in Y and Z when we use X to store an
308 intermediate value. Y + Z should form [base] [+ index[ * scale]] [
309 + disp] where base and index are registers, disp and scale are
310 constants. Y should contain base if it is present, Z should
311 contain disp if any. index[*scale] can be part of Y or Z. */
313 lra_emit_add (rtx x
, rtx y
, rtx z
)
317 rtx a1
, a2
, base
, index
, disp
, scale
, index_scale
;
320 rtx add3_insn
= emit_add3_insn (x
, y
, z
);
321 old
= max_reg_num ();
322 if (add3_insn
!= NULL
)
326 disp
= a2
= NULL_RTX
;
327 if (GET_CODE (y
) == PLUS
)
341 index_scale
= scale
= NULL_RTX
;
342 if (GET_CODE (a1
) == MULT
)
345 index
= XEXP (a1
, 0);
346 scale
= XEXP (a1
, 1);
349 else if (a2
!= NULL_RTX
&& GET_CODE (a2
) == MULT
)
352 index
= XEXP (a2
, 0);
353 scale
= XEXP (a2
, 1);
361 if (! (REG_P (base
) || GET_CODE (base
) == SUBREG
)
362 || (index
!= NULL_RTX
363 && ! (REG_P (index
) || GET_CODE (index
) == SUBREG
))
364 || (disp
!= NULL_RTX
&& ! CONSTANT_P (disp
))
365 || (scale
!= NULL_RTX
&& ! CONSTANT_P (scale
)))
367 /* Probably we have no 3 op add. Last chance is to use 2-op
368 add insn. To succeed, don't move Z to X as an address
369 segment always comes in Y. Otherwise, we might fail when
370 adding the address segment to register. */
371 lra_assert (x
!= y
&& x
!= z
);
372 emit_move_insn (x
, y
);
373 rtx insn
= emit_add2_insn (x
, z
);
374 lra_assert (insn
!= NULL_RTX
);
378 if (index_scale
== NULL_RTX
)
380 if (disp
== NULL_RTX
)
382 /* Generate x = index_scale; x = x + base. */
383 lra_assert (index_scale
!= NULL_RTX
&& base
!= NULL_RTX
);
384 emit_move_insn (x
, index_scale
);
385 rtx insn
= emit_add2_insn (x
, base
);
386 lra_assert (insn
!= NULL_RTX
);
388 else if (scale
== NULL_RTX
)
390 /* Try x = base + disp. */
391 lra_assert (base
!= NULL_RTX
);
392 last
= get_last_insn ();
393 rtx_insn
*move_insn
=
394 emit_move_insn (x
, gen_rtx_PLUS (GET_MODE (base
), base
, disp
));
395 if (recog_memoized (move_insn
) < 0)
397 delete_insns_since (last
);
398 /* Generate x = disp; x = x + base. */
399 emit_move_insn (x
, disp
);
400 rtx add2_insn
= emit_add2_insn (x
, base
);
401 lra_assert (add2_insn
!= NULL_RTX
);
403 /* Generate x = x + index. */
404 if (index
!= NULL_RTX
)
406 rtx insn
= emit_add2_insn (x
, index
);
407 lra_assert (insn
!= NULL_RTX
);
412 /* Try x = index_scale; x = x + disp; x = x + base. */
413 last
= get_last_insn ();
414 rtx_insn
*move_insn
= emit_move_insn (x
, index_scale
);
416 if (recog_memoized (move_insn
) >= 0)
418 rtx insn
= emit_add2_insn (x
, disp
);
419 if (insn
!= NULL_RTX
)
421 insn
= emit_add2_insn (x
, disp
);
422 if (insn
!= NULL_RTX
)
428 delete_insns_since (last
);
429 /* Generate x = disp; x = x + base; x = x + index_scale. */
430 emit_move_insn (x
, disp
);
431 rtx insn
= emit_add2_insn (x
, base
);
432 lra_assert (insn
!= NULL_RTX
);
433 insn
= emit_add2_insn (x
, index_scale
);
434 lra_assert (insn
!= NULL_RTX
);
439 /* Functions emit_... can create pseudos -- so expand the pseudo
441 if (old
!= max_reg_num ())
442 expand_reg_data (old
);
445 /* The number of emitted reload insns so far. */
446 int lra_curr_reload_num
;
448 /* Emit x := y, processing special case when y = u + v or y = u + v *
449 scale + w through emit_add (Y can be an address which is base +
450 index reg * scale + displacement in general case). X may be used
451 as intermediate result therefore it should be not in Y. */
453 lra_emit_move (rtx x
, rtx y
)
457 if (GET_CODE (y
) != PLUS
)
459 if (rtx_equal_p (x
, y
))
461 old
= max_reg_num ();
462 emit_move_insn (x
, y
);
464 lra_reg_info
[ORIGINAL_REGNO (x
)].last_reload
= ++lra_curr_reload_num
;
465 /* Function emit_move can create pseudos -- so expand the pseudo
467 if (old
!= max_reg_num ())
468 expand_reg_data (old
);
471 lra_emit_add (x
, XEXP (y
, 0), XEXP (y
, 1));
474 /* Update insn operands which are duplication of operands whose
475 numbers are in array of NOPS (with end marker -1). The insn is
476 represented by its LRA internal representation ID. */
478 lra_update_dups (lra_insn_recog_data_t id
, signed char *nops
)
481 struct lra_static_insn_data
*static_id
= id
->insn_static_data
;
483 for (i
= 0; i
< static_id
->n_dups
; i
++)
484 for (j
= 0; (nop
= nops
[j
]) >= 0; j
++)
485 if (static_id
->dup_num
[i
] == nop
)
486 *id
->dup_loc
[i
] = *id
->operand_loc
[nop
];
491 /* This page contains code dealing with info about registers in the
494 /* Pools for insn reg info. */
495 static alloc_pool insn_reg_pool
;
497 /* Initiate pool for insn reg info. */
499 init_insn_regs (void)
502 = create_alloc_pool ("insn regs", sizeof (struct lra_insn_reg
), 100);
505 /* Create LRA insn related info about a reference to REGNO in INSN with
506 TYPE (in/out/inout), biggest reference mode MODE, flag that it is
507 reference through subreg (SUBREG_P), flag that is early clobbered
508 in the insn (EARLY_CLOBBER), and reference to the next insn reg
510 static struct lra_insn_reg
*
511 new_insn_reg (rtx_insn
*insn
, int regno
, enum op_type type
,
512 enum machine_mode mode
,
513 bool subreg_p
, bool early_clobber
, struct lra_insn_reg
*next
)
515 struct lra_insn_reg
*ir
;
517 ir
= (struct lra_insn_reg
*) pool_alloc (insn_reg_pool
);
519 ir
->biggest_mode
= mode
;
520 if (GET_MODE_SIZE (mode
) > GET_MODE_SIZE (lra_reg_info
[regno
].biggest_mode
)
521 && NONDEBUG_INSN_P (insn
))
522 lra_reg_info
[regno
].biggest_mode
= mode
;
523 ir
->subreg_p
= subreg_p
;
524 ir
->early_clobber
= early_clobber
;
530 /* Free insn reg info IR. */
532 free_insn_reg (struct lra_insn_reg
*ir
)
534 pool_free (insn_reg_pool
, ir
);
537 /* Free insn reg info list IR. */
539 free_insn_regs (struct lra_insn_reg
*ir
)
541 struct lra_insn_reg
*next_ir
;
543 for (; ir
!= NULL
; ir
= next_ir
)
550 /* Finish pool for insn reg info. */
552 finish_insn_regs (void)
554 free_alloc_pool (insn_reg_pool
);
559 /* This page contains code dealing LRA insn info (or in other words
560 LRA internal insn representation). */
562 /* Map INSN_CODE -> the static insn data. This info is valid during
563 all translation unit. */
564 struct lra_static_insn_data
*insn_code_data
[LAST_INSN_CODE
];
566 /* Debug insns are represented as a special insn with one input
567 operand which is RTL expression in var_location. */
569 /* The following data are used as static insn operand data for all
570 debug insns. If structure lra_operand_data is changed, the
571 initializer should be changed too. */
572 static struct lra_operand_data debug_operand_data
=
574 NULL
, /* alternative */
575 VOIDmode
, /* We are not interesting in the operand mode. */
580 /* The following data are used as static insn data for all debug
581 insns. If structure lra_static_insn_data is changed, the
582 initializer should be changed too. */
583 static struct lra_static_insn_data debug_insn_static_data
=
586 0, /* Duplication operands #. */
587 -1, /* Commutative operand #. */
588 1, /* Operands #. There is only one operand which is debug RTL
590 0, /* Duplications #. */
591 0, /* Alternatives #. We are not interesting in alternatives
592 because we does not proceed debug_insns for reloads. */
593 NULL
, /* Hard registers referenced in machine description. */
594 NULL
/* Descriptions of operands in alternatives. */
597 /* Called once per compiler work to initialize some LRA data related
600 init_insn_code_data_once (void)
602 memset (insn_code_data
, 0, sizeof (insn_code_data
));
605 /* Called once per compiler work to finalize some LRA data related to
608 finish_insn_code_data_once (void)
612 for (i
= 0; i
< LAST_INSN_CODE
; i
++)
614 if (insn_code_data
[i
] != NULL
)
615 free (insn_code_data
[i
]);
619 /* Return static insn data, allocate and setup if necessary. Although
620 dup_num is static data (it depends only on icode), to set it up we
621 need to extract insn first. So recog_data should be valid for
622 normal insn (ICODE >= 0) before the call. */
623 static struct lra_static_insn_data
*
624 get_static_insn_data (int icode
, int nop
, int ndup
, int nalt
)
626 struct lra_static_insn_data
*data
;
629 lra_assert (icode
< LAST_INSN_CODE
);
630 if (icode
>= 0 && (data
= insn_code_data
[icode
]) != NULL
)
632 lra_assert (nop
>= 0 && ndup
>= 0 && nalt
>= 0);
633 n_bytes
= sizeof (struct lra_static_insn_data
)
634 + sizeof (struct lra_operand_data
) * nop
635 + sizeof (int) * ndup
;
636 data
= XNEWVAR (struct lra_static_insn_data
, n_bytes
);
637 data
->operand_alternative
= NULL
;
638 data
->n_operands
= nop
;
640 data
->n_alternatives
= nalt
;
641 data
->operand
= ((struct lra_operand_data
*)
642 ((char *) data
+ sizeof (struct lra_static_insn_data
)));
643 data
->dup_num
= ((int *) ((char *) data
->operand
644 + sizeof (struct lra_operand_data
) * nop
));
649 insn_code_data
[icode
] = data
;
650 for (i
= 0; i
< nop
; i
++)
652 data
->operand
[i
].constraint
653 = insn_data
[icode
].operand
[i
].constraint
;
654 data
->operand
[i
].mode
= insn_data
[icode
].operand
[i
].mode
;
655 data
->operand
[i
].strict_low
= insn_data
[icode
].operand
[i
].strict_low
;
656 data
->operand
[i
].is_operator
657 = insn_data
[icode
].operand
[i
].is_operator
;
658 data
->operand
[i
].type
659 = (data
->operand
[i
].constraint
[0] == '=' ? OP_OUT
660 : data
->operand
[i
].constraint
[0] == '+' ? OP_INOUT
662 data
->operand
[i
].is_address
= false;
664 for (i
= 0; i
< ndup
; i
++)
665 data
->dup_num
[i
] = recog_data
.dup_num
[i
];
670 /* The current length of the following array. */
671 int lra_insn_recog_data_len
;
673 /* Map INSN_UID -> the insn recog data (NULL if unknown). */
674 lra_insn_recog_data_t
*lra_insn_recog_data
;
676 /* Initialize LRA data about insns. */
678 init_insn_recog_data (void)
680 lra_insn_recog_data_len
= 0;
681 lra_insn_recog_data
= NULL
;
685 /* Expand, if necessary, LRA data about insns. */
687 check_and_expand_insn_recog_data (int index
)
691 if (lra_insn_recog_data_len
> index
)
693 old
= lra_insn_recog_data_len
;
694 lra_insn_recog_data_len
= index
* 3 / 2 + 1;
695 lra_insn_recog_data
= XRESIZEVEC (lra_insn_recog_data_t
,
697 lra_insn_recog_data_len
);
698 for (i
= old
; i
< lra_insn_recog_data_len
; i
++)
699 lra_insn_recog_data
[i
] = NULL
;
702 /* Finish LRA DATA about insn. */
704 free_insn_recog_data (lra_insn_recog_data_t data
)
706 if (data
->operand_loc
!= NULL
)
707 free (data
->operand_loc
);
708 if (data
->dup_loc
!= NULL
)
709 free (data
->dup_loc
);
710 if (data
->arg_hard_regs
!= NULL
)
711 free (data
->arg_hard_regs
);
712 if (data
->icode
< 0 && NONDEBUG_INSN_P (data
->insn
))
714 if (data
->insn_static_data
->operand_alternative
!= NULL
)
715 free (const_cast <operand_alternative
*>
716 (data
->insn_static_data
->operand_alternative
));
717 free_insn_regs (data
->insn_static_data
->hard_regs
);
718 free (data
->insn_static_data
);
720 free_insn_regs (data
->regs
);
725 /* Finish LRA data about all insns. */
727 finish_insn_recog_data (void)
730 lra_insn_recog_data_t data
;
732 for (i
= 0; i
< lra_insn_recog_data_len
; i
++)
733 if ((data
= lra_insn_recog_data
[i
]) != NULL
)
734 free_insn_recog_data (data
);
736 free (lra_insn_recog_data
);
739 /* Setup info about operands in alternatives of LRA DATA of insn. */
741 setup_operand_alternative (lra_insn_recog_data_t data
,
742 const operand_alternative
*op_alt
)
745 int icode
= data
->icode
;
746 struct lra_static_insn_data
*static_data
= data
->insn_static_data
;
748 static_data
->commutative
= -1;
749 nop
= static_data
->n_operands
;
750 nalt
= static_data
->n_alternatives
;
751 static_data
->operand_alternative
= op_alt
;
752 for (i
= 0; i
< nop
; i
++)
754 static_data
->operand
[i
].early_clobber
= false;
755 static_data
->operand
[i
].is_address
= false;
756 if (static_data
->operand
[i
].constraint
[0] == '%')
758 /* We currently only support one commutative pair of operands. */
759 if (static_data
->commutative
< 0)
760 static_data
->commutative
= i
;
762 lra_assert (icode
< 0); /* Asm */
763 /* The last operand should not be marked commutative. */
764 lra_assert (i
!= nop
- 1);
767 for (j
= 0; j
< nalt
; j
++)
768 for (i
= 0; i
< nop
; i
++, op_alt
++)
770 static_data
->operand
[i
].early_clobber
|= op_alt
->earlyclobber
;
771 static_data
->operand
[i
].is_address
|= op_alt
->is_address
;
775 /* Recursively process X and collect info about registers, which are
776 not the insn operands, in X with TYPE (in/out/inout) and flag that
777 it is early clobbered in the insn (EARLY_CLOBBER) and add the info
778 to LIST. X is a part of insn given by DATA. Return the result
780 static struct lra_insn_reg
*
781 collect_non_operand_hard_regs (rtx
*x
, lra_insn_recog_data_t data
,
782 struct lra_insn_reg
*list
,
783 enum op_type type
, bool early_clobber
)
785 int i
, j
, regno
, last
;
787 enum machine_mode mode
;
788 struct lra_insn_reg
*curr
;
790 enum rtx_code code
= GET_CODE (op
);
791 const char *fmt
= GET_RTX_FORMAT (code
);
793 for (i
= 0; i
< data
->insn_static_data
->n_operands
; i
++)
794 if (x
== data
->operand_loc
[i
])
795 /* It is an operand loc. Stop here. */
797 for (i
= 0; i
< data
->insn_static_data
->n_dups
; i
++)
798 if (x
== data
->dup_loc
[i
])
799 /* It is a dup loc. Stop here. */
801 mode
= GET_MODE (op
);
805 op
= SUBREG_REG (op
);
806 code
= GET_CODE (op
);
807 if (GET_MODE_SIZE (mode
) < GET_MODE_SIZE (GET_MODE (op
)))
809 mode
= GET_MODE (op
);
810 if (GET_MODE_SIZE (mode
) > REGMODE_NATURAL_SIZE (mode
))
816 if ((regno
= REGNO (op
)) >= FIRST_PSEUDO_REGISTER
)
818 for (last
= regno
+ hard_regno_nregs
[regno
][mode
];
821 if (! TEST_HARD_REG_BIT (lra_no_alloc_regs
, regno
)
822 || TEST_HARD_REG_BIT (eliminable_regset
, regno
))
824 for (curr
= list
; curr
!= NULL
; curr
= curr
->next
)
825 if (curr
->regno
== regno
&& curr
->subreg_p
== subreg_p
826 && curr
->biggest_mode
== mode
)
828 if (curr
->type
!= type
)
829 curr
->type
= OP_INOUT
;
830 if (curr
->early_clobber
!= early_clobber
)
831 curr
->early_clobber
= true;
836 /* This is a new hard regno or the info can not be
837 integrated into the found structure. */
841 /* This clobber is to inform popping floating
843 && ! (FIRST_STACK_REG
<= regno
844 && regno
<= LAST_STACK_REG
));
846 list
= new_insn_reg (data
->insn
, regno
, type
, mode
, subreg_p
,
847 early_clobber
, list
);
855 list
= collect_non_operand_hard_regs (&SET_DEST (op
), data
,
856 list
, OP_OUT
, false);
857 list
= collect_non_operand_hard_regs (&SET_SRC (op
), data
,
861 /* We treat clobber of non-operand hard registers as early
862 clobber (the behavior is expected from asm). */
863 list
= collect_non_operand_hard_regs (&XEXP (op
, 0), data
,
866 case PRE_INC
: case PRE_DEC
: case POST_INC
: case POST_DEC
:
867 list
= collect_non_operand_hard_regs (&XEXP (op
, 0), data
,
868 list
, OP_INOUT
, false);
870 case PRE_MODIFY
: case POST_MODIFY
:
871 list
= collect_non_operand_hard_regs (&XEXP (op
, 0), data
,
872 list
, OP_INOUT
, false);
873 list
= collect_non_operand_hard_regs (&XEXP (op
, 1), data
,
877 fmt
= GET_RTX_FORMAT (code
);
878 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
881 list
= collect_non_operand_hard_regs (&XEXP (op
, i
), data
,
883 else if (fmt
[i
] == 'E')
884 for (j
= XVECLEN (op
, i
) - 1; j
>= 0; j
--)
885 list
= collect_non_operand_hard_regs (&XVECEXP (op
, i
, j
), data
,
892 /* Set up and return info about INSN. Set up the info if it is not set up
894 lra_insn_recog_data_t
895 lra_set_insn_recog_data (rtx_insn
*insn
)
897 lra_insn_recog_data_t data
;
900 unsigned int uid
= INSN_UID (insn
);
901 struct lra_static_insn_data
*insn_static_data
;
903 check_and_expand_insn_recog_data (uid
);
904 if (DEBUG_INSN_P (insn
))
908 icode
= INSN_CODE (insn
);
910 /* It might be a new simple insn which is not recognized yet. */
911 INSN_CODE (insn
) = icode
= recog_memoized (insn
);
913 data
= XNEW (struct lra_insn_recog_data
);
914 lra_insn_recog_data
[uid
] = data
;
916 data
->used_insn_alternative
= -1;
919 if (DEBUG_INSN_P (insn
))
921 data
->insn_static_data
= &debug_insn_static_data
;
922 data
->dup_loc
= NULL
;
923 data
->arg_hard_regs
= NULL
;
924 data
->preferred_alternatives
= ALL_ALTERNATIVES
;
925 data
->operand_loc
= XNEWVEC (rtx
*, 1);
926 data
->operand_loc
[0] = &INSN_VAR_LOCATION_LOC (insn
);
932 enum machine_mode operand_mode
[MAX_RECOG_OPERANDS
];
933 const char *constraints
[MAX_RECOG_OPERANDS
];
935 nop
= asm_noperands (PATTERN (insn
));
936 data
->operand_loc
= data
->dup_loc
= NULL
;
940 /* It is a special insn like USE or CLOBBER. We should
941 recognize any regular insn otherwise LRA can do nothing
943 gcc_assert (GET_CODE (PATTERN (insn
)) == USE
944 || GET_CODE (PATTERN (insn
)) == CLOBBER
945 || GET_CODE (PATTERN (insn
)) == ASM_INPUT
);
946 data
->insn_static_data
= insn_static_data
947 = get_static_insn_data (-1, 0, 0, nalt
);
951 /* expand_asm_operands makes sure there aren't too many
953 lra_assert (nop
<= MAX_RECOG_OPERANDS
);
955 data
->operand_loc
= XNEWVEC (rtx
*, nop
);
956 /* Now get the operand values and constraints out of the
958 decode_asm_operands (PATTERN (insn
), NULL
,
960 constraints
, operand_mode
, NULL
);
963 const char *p
= recog_data
.constraints
[0];
965 for (p
= constraints
[0]; *p
; p
++)
968 data
->insn_static_data
= insn_static_data
969 = get_static_insn_data (-1, nop
, 0, nalt
);
970 for (i
= 0; i
< nop
; i
++)
972 insn_static_data
->operand
[i
].mode
= operand_mode
[i
];
973 insn_static_data
->operand
[i
].constraint
= constraints
[i
];
974 insn_static_data
->operand
[i
].strict_low
= false;
975 insn_static_data
->operand
[i
].is_operator
= false;
976 insn_static_data
->operand
[i
].is_address
= false;
979 for (i
= 0; i
< insn_static_data
->n_operands
; i
++)
980 insn_static_data
->operand
[i
].type
981 = (insn_static_data
->operand
[i
].constraint
[0] == '=' ? OP_OUT
982 : insn_static_data
->operand
[i
].constraint
[0] == '+' ? OP_INOUT
984 data
->preferred_alternatives
= ALL_ALTERNATIVES
;
987 operand_alternative
*op_alt
= XCNEWVEC (operand_alternative
,
989 preprocess_constraints (nop
, nalt
, constraints
, op_alt
);
990 setup_operand_alternative (data
, op_alt
);
996 data
->insn_static_data
= insn_static_data
997 = get_static_insn_data (icode
, insn_data
[icode
].n_operands
,
998 insn_data
[icode
].n_dups
,
999 insn_data
[icode
].n_alternatives
);
1000 n
= insn_static_data
->n_operands
;
1005 locs
= XNEWVEC (rtx
*, n
);
1006 memcpy (locs
, recog_data
.operand_loc
, n
* sizeof (rtx
*));
1008 data
->operand_loc
= locs
;
1009 n
= insn_static_data
->n_dups
;
1014 locs
= XNEWVEC (rtx
*, n
);
1015 memcpy (locs
, recog_data
.dup_loc
, n
* sizeof (rtx
*));
1017 data
->dup_loc
= locs
;
1018 data
->preferred_alternatives
= get_preferred_alternatives (insn
);
1019 const operand_alternative
*op_alt
= preprocess_insn_constraints (icode
);
1020 if (!insn_static_data
->operand_alternative
)
1021 setup_operand_alternative (data
, op_alt
);
1022 else if (op_alt
!= insn_static_data
->operand_alternative
)
1023 insn_static_data
->operand_alternative
= op_alt
;
1025 if (GET_CODE (PATTERN (insn
)) == CLOBBER
|| GET_CODE (PATTERN (insn
)) == USE
)
1026 insn_static_data
->hard_regs
= NULL
;
1028 insn_static_data
->hard_regs
1029 = collect_non_operand_hard_regs (&PATTERN (insn
), data
,
1030 NULL
, OP_IN
, false);
1031 data
->arg_hard_regs
= NULL
;
1035 int n_hard_regs
, regno
, arg_hard_regs
[FIRST_PSEUDO_REGISTER
];
1038 /* Finding implicit hard register usage. We believe it will be
1039 not changed whatever transformations are used. Call insns
1040 are such example. */
1041 for (link
= CALL_INSN_FUNCTION_USAGE (insn
);
1043 link
= XEXP (link
, 1))
1044 if (GET_CODE (XEXP (link
, 0)) == USE
1045 && REG_P (XEXP (XEXP (link
, 0), 0)))
1047 regno
= REGNO (XEXP (XEXP (link
, 0), 0));
1048 lra_assert (regno
< FIRST_PSEUDO_REGISTER
);
1049 /* It is an argument register. */
1050 for (i
= (hard_regno_nregs
1051 [regno
][GET_MODE (XEXP (XEXP (link
, 0), 0))]) - 1;
1054 arg_hard_regs
[n_hard_regs
++] = regno
+ i
;
1056 if (n_hard_regs
!= 0)
1058 arg_hard_regs
[n_hard_regs
++] = -1;
1059 data
->arg_hard_regs
= XNEWVEC (int, n_hard_regs
);
1060 memcpy (data
->arg_hard_regs
, arg_hard_regs
,
1061 sizeof (int) * n_hard_regs
);
1064 /* Some output operand can be recognized only from the context not
1065 from the constraints which are empty in this case. Call insn may
1066 contain a hard register in set destination with empty constraint
1067 and extract_insn treats them as an input. */
1068 for (i
= 0; i
< insn_static_data
->n_operands
; i
++)
1072 struct lra_operand_data
*operand
= &insn_static_data
->operand
[i
];
1074 /* ??? Should we treat 'X' the same way. It looks to me that
1075 'X' means anything and empty constraint means we do not
1077 if (operand
->type
!= OP_IN
|| *operand
->constraint
!= '\0'
1078 || operand
->is_operator
)
1080 pat
= PATTERN (insn
);
1081 if (GET_CODE (pat
) == SET
)
1083 if (data
->operand_loc
[i
] != &SET_DEST (pat
))
1086 else if (GET_CODE (pat
) == PARALLEL
)
1088 for (j
= XVECLEN (pat
, 0) - 1; j
>= 0; j
--)
1090 set
= XVECEXP (PATTERN (insn
), 0, j
);
1091 if (GET_CODE (set
) == SET
1092 && &SET_DEST (set
) == data
->operand_loc
[i
])
1100 operand
->type
= OP_OUT
;
1105 /* Return info about insn give by UID. The info should be already set
1107 static lra_insn_recog_data_t
1108 get_insn_recog_data_by_uid (int uid
)
1110 lra_insn_recog_data_t data
;
1112 data
= lra_insn_recog_data
[uid
];
1113 lra_assert (data
!= NULL
);
1117 /* Invalidate all info about insn given by its UID. */
1119 invalidate_insn_recog_data (int uid
)
1121 lra_insn_recog_data_t data
;
1123 data
= lra_insn_recog_data
[uid
];
1124 lra_assert (data
!= NULL
);
1125 free_insn_recog_data (data
);
1126 lra_insn_recog_data
[uid
] = NULL
;
1129 /* Update all the insn info about INSN. It is usually called when
1130 something in the insn was changed. Return the updated info. */
1131 lra_insn_recog_data_t
1132 lra_update_insn_recog_data (rtx_insn
*insn
)
1134 lra_insn_recog_data_t data
;
1136 unsigned int uid
= INSN_UID (insn
);
1137 struct lra_static_insn_data
*insn_static_data
;
1138 HOST_WIDE_INT sp_offset
= 0;
1140 check_and_expand_insn_recog_data (uid
);
1141 if ((data
= lra_insn_recog_data
[uid
]) != NULL
1142 && data
->icode
!= INSN_CODE (insn
))
1144 sp_offset
= data
->sp_offset
;
1145 invalidate_insn_data_regno_info (data
, insn
, get_insn_freq (insn
));
1146 invalidate_insn_recog_data (uid
);
1151 data
= lra_get_insn_recog_data (insn
);
1152 /* Initiate or restore SP offset. */
1153 data
->sp_offset
= sp_offset
;
1156 insn_static_data
= data
->insn_static_data
;
1157 data
->used_insn_alternative
= -1;
1158 if (DEBUG_INSN_P (insn
))
1160 if (data
->icode
< 0)
1163 enum machine_mode operand_mode
[MAX_RECOG_OPERANDS
];
1164 const char *constraints
[MAX_RECOG_OPERANDS
];
1166 nop
= asm_noperands (PATTERN (insn
));
1169 lra_assert (nop
== data
->insn_static_data
->n_operands
);
1170 /* Now get the operand values and constraints out of the
1172 decode_asm_operands (PATTERN (insn
), NULL
,
1174 constraints
, operand_mode
, NULL
);
1175 #ifdef ENABLE_CHECKING
1179 for (i
= 0; i
< nop
; i
++)
1181 (insn_static_data
->operand
[i
].mode
== operand_mode
[i
]
1182 && insn_static_data
->operand
[i
].constraint
== constraints
[i
]
1183 && ! insn_static_data
->operand
[i
].is_operator
);
1187 #ifdef ENABLE_CHECKING
1191 for (i
= 0; i
< insn_static_data
->n_operands
; i
++)
1193 (insn_static_data
->operand
[i
].type
1194 == (insn_static_data
->operand
[i
].constraint
[0] == '=' ? OP_OUT
1195 : insn_static_data
->operand
[i
].constraint
[0] == '+' ? OP_INOUT
1202 insn_extract (insn
);
1203 n
= insn_static_data
->n_operands
;
1205 memcpy (data
->operand_loc
, recog_data
.operand_loc
, n
* sizeof (rtx
*));
1206 n
= insn_static_data
->n_dups
;
1208 memcpy (data
->dup_loc
, recog_data
.dup_loc
, n
* sizeof (rtx
*));
1209 lra_assert (check_bool_attrs (insn
));
1214 /* Set up that INSN is using alternative ALT now. */
1216 lra_set_used_insn_alternative (rtx_insn
*insn
, int alt
)
1218 lra_insn_recog_data_t data
;
1220 data
= lra_get_insn_recog_data (insn
);
1221 data
->used_insn_alternative
= alt
;
1224 /* Set up that insn with UID is using alternative ALT now. The insn
1225 info should be already set up. */
1227 lra_set_used_insn_alternative_by_uid (int uid
, int alt
)
1229 lra_insn_recog_data_t data
;
1231 check_and_expand_insn_recog_data (uid
);
1232 data
= lra_insn_recog_data
[uid
];
1233 lra_assert (data
!= NULL
);
1234 data
->used_insn_alternative
= alt
;
1239 /* This page contains code dealing with common register info and
1242 /* The size of the following array. */
1243 static int reg_info_size
;
1244 /* Common info about each register. */
1245 struct lra_reg
*lra_reg_info
;
1247 /* Last register value. */
1248 static int last_reg_value
;
1250 /* Return new register value. */
1252 get_new_reg_value (void)
1254 return ++last_reg_value
;
1257 /* Pools for copies. */
1258 static alloc_pool copy_pool
;
1260 /* Vec referring to pseudo copies. */
1261 static vec
<lra_copy_t
> copy_vec
;
1263 /* Initialize I-th element of lra_reg_info. */
1265 initialize_lra_reg_info_element (int i
)
1267 bitmap_initialize (&lra_reg_info
[i
].insn_bitmap
, ®_obstack
);
1269 lra_reg_info
[i
].no_stack_p
= false;
1271 CLEAR_HARD_REG_SET (lra_reg_info
[i
].conflict_hard_regs
);
1272 CLEAR_HARD_REG_SET (lra_reg_info
[i
].actual_call_used_reg_set
);
1273 lra_reg_info
[i
].preferred_hard_regno1
= -1;
1274 lra_reg_info
[i
].preferred_hard_regno2
= -1;
1275 lra_reg_info
[i
].preferred_hard_regno_profit1
= 0;
1276 lra_reg_info
[i
].preferred_hard_regno_profit2
= 0;
1277 lra_reg_info
[i
].biggest_mode
= VOIDmode
;
1278 lra_reg_info
[i
].live_ranges
= NULL
;
1279 lra_reg_info
[i
].nrefs
= lra_reg_info
[i
].freq
= 0;
1280 lra_reg_info
[i
].last_reload
= 0;
1281 lra_reg_info
[i
].restore_regno
= -1;
1282 lra_reg_info
[i
].val
= get_new_reg_value ();
1283 lra_reg_info
[i
].offset
= 0;
1284 lra_reg_info
[i
].copies
= NULL
;
1287 /* Initialize common reg info and copies. */
1289 init_reg_info (void)
1294 reg_info_size
= max_reg_num () * 3 / 2 + 1;
1295 lra_reg_info
= XNEWVEC (struct lra_reg
, reg_info_size
);
1296 for (i
= 0; i
< reg_info_size
; i
++)
1297 initialize_lra_reg_info_element (i
);
1299 = create_alloc_pool ("lra copies", sizeof (struct lra_copy
), 100);
1300 copy_vec
.create (100);
1304 /* Finish common reg info and copies. */
1306 finish_reg_info (void)
1310 for (i
= 0; i
< reg_info_size
; i
++)
1311 bitmap_clear (&lra_reg_info
[i
].insn_bitmap
);
1312 free (lra_reg_info
);
1314 free_alloc_pool (copy_pool
);
1315 copy_vec
.release ();
1318 /* Expand common reg info if it is necessary. */
1320 expand_reg_info (void)
1322 int i
, old
= reg_info_size
;
1324 if (reg_info_size
> max_reg_num ())
1326 reg_info_size
= max_reg_num () * 3 / 2 + 1;
1327 lra_reg_info
= XRESIZEVEC (struct lra_reg
, lra_reg_info
, reg_info_size
);
1328 for (i
= old
; i
< reg_info_size
; i
++)
1329 initialize_lra_reg_info_element (i
);
1332 /* Free all copies. */
1334 lra_free_copies (void)
1338 while (copy_vec
.length () != 0)
1340 cp
= copy_vec
.pop ();
1341 lra_reg_info
[cp
->regno1
].copies
= lra_reg_info
[cp
->regno2
].copies
= NULL
;
1342 pool_free (copy_pool
, cp
);
1346 /* Create copy of two pseudos REGNO1 and REGNO2. The copy execution
1347 frequency is FREQ. */
1349 lra_create_copy (int regno1
, int regno2
, int freq
)
1354 lra_assert (regno1
!= regno2
);
1355 regno1_dest_p
= true;
1356 if (regno1
> regno2
)
1360 regno1_dest_p
= false;
1364 cp
= (lra_copy_t
) pool_alloc (copy_pool
);
1365 copy_vec
.safe_push (cp
);
1366 cp
->regno1_dest_p
= regno1_dest_p
;
1368 cp
->regno1
= regno1
;
1369 cp
->regno2
= regno2
;
1370 cp
->regno1_next
= lra_reg_info
[regno1
].copies
;
1371 lra_reg_info
[regno1
].copies
= cp
;
1372 cp
->regno2_next
= lra_reg_info
[regno2
].copies
;
1373 lra_reg_info
[regno2
].copies
= cp
;
1374 if (lra_dump_file
!= NULL
)
1375 fprintf (lra_dump_file
, " Creating copy r%d%sr%d@%d\n",
1376 regno1
, regno1_dest_p
? "<-" : "->", regno2
, freq
);
1379 /* Return N-th (0, 1, ...) copy. If there is no copy, return
1382 lra_get_copy (int n
)
1384 if (n
>= (int) copy_vec
.length ())
1391 /* This page contains code dealing with info about registers in
1394 /* Process X of insn UID recursively and add info (operand type is
1395 given by TYPE, flag of that it is early clobber is EARLY_CLOBBER)
1396 about registers in X to the insn DATA. */
1398 add_regs_to_insn_regno_info (lra_insn_recog_data_t data
, rtx x
, int uid
,
1399 enum op_type type
, bool early_clobber
)
1403 enum machine_mode mode
;
1406 struct lra_insn_reg
*curr
;
1408 code
= GET_CODE (x
);
1409 mode
= GET_MODE (x
);
1411 if (GET_CODE (x
) == SUBREG
)
1414 code
= GET_CODE (x
);
1415 if (GET_MODE_SIZE (mode
) < GET_MODE_SIZE (GET_MODE (x
)))
1417 mode
= GET_MODE (x
);
1418 if (GET_MODE_SIZE (mode
) > REGMODE_NATURAL_SIZE (mode
))
1425 if (regno
< FIRST_PSEUDO_REGISTER
1426 && TEST_HARD_REG_BIT (lra_no_alloc_regs
, regno
)
1427 && ! TEST_HARD_REG_BIT (eliminable_regset
, regno
))
1430 if (bitmap_set_bit (&lra_reg_info
[regno
].insn_bitmap
, uid
))
1432 data
->regs
= new_insn_reg (data
->insn
, regno
, type
, mode
, subreg_p
,
1433 early_clobber
, data
->regs
);
1438 for (curr
= data
->regs
; curr
!= NULL
; curr
= curr
->next
)
1439 if (curr
->regno
== regno
)
1441 if (curr
->subreg_p
!= subreg_p
|| curr
->biggest_mode
!= mode
)
1442 /* The info can not be integrated into the found
1444 data
->regs
= new_insn_reg (data
->insn
, regno
, type
, mode
,
1445 subreg_p
, early_clobber
,
1449 if (curr
->type
!= type
)
1450 curr
->type
= OP_INOUT
;
1451 if (curr
->early_clobber
!= early_clobber
)
1452 curr
->early_clobber
= true;
1463 add_regs_to_insn_regno_info (data
, SET_DEST (x
), uid
, OP_OUT
, false);
1464 add_regs_to_insn_regno_info (data
, SET_SRC (x
), uid
, OP_IN
, false);
1467 /* We treat clobber of non-operand hard registers as early
1468 clobber (the behavior is expected from asm). */
1469 add_regs_to_insn_regno_info (data
, XEXP (x
, 0), uid
, OP_OUT
, true);
1471 case PRE_INC
: case PRE_DEC
: case POST_INC
: case POST_DEC
:
1472 add_regs_to_insn_regno_info (data
, XEXP (x
, 0), uid
, OP_INOUT
, false);
1474 case PRE_MODIFY
: case POST_MODIFY
:
1475 add_regs_to_insn_regno_info (data
, XEXP (x
, 0), uid
, OP_INOUT
, false);
1476 add_regs_to_insn_regno_info (data
, XEXP (x
, 1), uid
, OP_IN
, false);
1479 if ((code
!= PARALLEL
&& code
!= EXPR_LIST
) || type
!= OP_OUT
)
1480 /* Some targets place small structures in registers for return
1481 values of functions, and those registers are wrapped in
1482 PARALLEL that we may see as the destination of a SET. Here
1485 (call_insn 13 12 14 2 (set (parallel:BLK [
1486 (expr_list:REG_DEP_TRUE (reg:DI 0 ax)
1488 (expr_list:REG_DEP_TRUE (reg:DI 1 dx)
1489 (const_int 8 [0x8]))
1491 (call (mem:QI (symbol_ref:DI (... */
1493 fmt
= GET_RTX_FORMAT (code
);
1494 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
1497 add_regs_to_insn_regno_info (data
, XEXP (x
, i
), uid
, type
, false);
1498 else if (fmt
[i
] == 'E')
1500 for (j
= XVECLEN (x
, i
) - 1; j
>= 0; j
--)
1501 add_regs_to_insn_regno_info (data
, XVECEXP (x
, i
, j
), uid
,
1508 /* Return execution frequency of INSN. */
1510 get_insn_freq (rtx_insn
*insn
)
1512 basic_block bb
= BLOCK_FOR_INSN (insn
);
1514 gcc_checking_assert (bb
!= NULL
);
1515 return REG_FREQ_FROM_BB (bb
);
1518 /* Invalidate all reg info of INSN with DATA and execution frequency
1519 FREQ. Update common info about the invalidated registers. */
1521 invalidate_insn_data_regno_info (lra_insn_recog_data_t data
, rtx_insn
*insn
,
1527 struct lra_insn_reg
*ir
, *next_ir
;
1529 uid
= INSN_UID (insn
);
1530 debug_p
= DEBUG_INSN_P (insn
);
1531 for (ir
= data
->regs
; ir
!= NULL
; ir
= next_ir
)
1536 bitmap_clear_bit (&lra_reg_info
[i
].insn_bitmap
, uid
);
1537 if (i
>= FIRST_PSEUDO_REGISTER
&& ! debug_p
)
1539 lra_reg_info
[i
].nrefs
--;
1540 lra_reg_info
[i
].freq
-= freq
;
1541 lra_assert (lra_reg_info
[i
].nrefs
>= 0 && lra_reg_info
[i
].freq
>= 0);
1547 /* Invalidate all reg info of INSN. Update common info about the
1548 invalidated registers. */
1550 lra_invalidate_insn_regno_info (rtx_insn
*insn
)
1552 invalidate_insn_data_regno_info (lra_get_insn_recog_data (insn
), insn
,
1553 get_insn_freq (insn
));
1556 /* Update common reg info from reg info of insn given by its DATA and
1557 execution frequency FREQ. */
1559 setup_insn_reg_info (lra_insn_recog_data_t data
, int freq
)
1562 struct lra_insn_reg
*ir
;
1564 for (ir
= data
->regs
; ir
!= NULL
; ir
= ir
->next
)
1565 if ((i
= ir
->regno
) >= FIRST_PSEUDO_REGISTER
)
1567 lra_reg_info
[i
].nrefs
++;
1568 lra_reg_info
[i
].freq
+= freq
;
1572 /* Set up insn reg info of INSN. Update common reg info from reg info
1575 lra_update_insn_regno_info (rtx_insn
*insn
)
1578 lra_insn_recog_data_t data
;
1579 struct lra_static_insn_data
*static_data
;
1582 if (! INSN_P (insn
))
1584 data
= lra_get_insn_recog_data (insn
);
1585 static_data
= data
->insn_static_data
;
1586 freq
= get_insn_freq (insn
);
1587 invalidate_insn_data_regno_info (data
, insn
, freq
);
1588 uid
= INSN_UID (insn
);
1589 for (i
= static_data
->n_operands
- 1; i
>= 0; i
--)
1590 add_regs_to_insn_regno_info (data
, *data
->operand_loc
[i
], uid
,
1591 static_data
->operand
[i
].type
,
1592 static_data
->operand
[i
].early_clobber
);
1593 if ((code
= GET_CODE (PATTERN (insn
))) == CLOBBER
|| code
== USE
)
1594 add_regs_to_insn_regno_info (data
, XEXP (PATTERN (insn
), 0), uid
,
1595 code
== USE
? OP_IN
: OP_OUT
, false);
1596 if (NONDEBUG_INSN_P (insn
))
1597 setup_insn_reg_info (data
, freq
);
1600 /* Return reg info of insn given by it UID. */
1601 struct lra_insn_reg
*
1602 lra_get_insn_regs (int uid
)
1604 lra_insn_recog_data_t data
;
1606 data
= get_insn_recog_data_by_uid (uid
);
1612 /* This page contains code dealing with stack of the insns which
1613 should be processed by the next constraint pass. */
1615 /* Bitmap used to put an insn on the stack only in one exemplar. */
1616 static sbitmap lra_constraint_insn_stack_bitmap
;
1618 /* The stack itself. */
1619 vec
<rtx_insn
*> lra_constraint_insn_stack
;
1621 /* Put INSN on the stack. If ALWAYS_UPDATE is true, always update the reg
1622 info for INSN, otherwise only update it if INSN is not already on the
1625 lra_push_insn_1 (rtx_insn
*insn
, bool always_update
)
1627 unsigned int uid
= INSN_UID (insn
);
1629 lra_update_insn_regno_info (insn
);
1630 if (uid
>= SBITMAP_SIZE (lra_constraint_insn_stack_bitmap
))
1631 lra_constraint_insn_stack_bitmap
=
1632 sbitmap_resize (lra_constraint_insn_stack_bitmap
, 3 * uid
/ 2, 0);
1633 if (bitmap_bit_p (lra_constraint_insn_stack_bitmap
, uid
))
1635 bitmap_set_bit (lra_constraint_insn_stack_bitmap
, uid
);
1636 if (! always_update
)
1637 lra_update_insn_regno_info (insn
);
1638 lra_constraint_insn_stack
.safe_push (insn
);
1641 /* Put INSN on the stack. */
1643 lra_push_insn (rtx_insn
*insn
)
1645 lra_push_insn_1 (insn
, false);
1648 /* Put INSN on the stack and update its reg info. */
1650 lra_push_insn_and_update_insn_regno_info (rtx_insn
*insn
)
1652 lra_push_insn_1 (insn
, true);
1655 /* Put insn with UID on the stack. */
1657 lra_push_insn_by_uid (unsigned int uid
)
1659 lra_push_insn (lra_insn_recog_data
[uid
]->insn
);
1662 /* Take the last-inserted insns off the stack and return it. */
1666 rtx_insn
*insn
= lra_constraint_insn_stack
.pop ();
1667 bitmap_clear_bit (lra_constraint_insn_stack_bitmap
, INSN_UID (insn
));
1671 /* Return the current size of the insn stack. */
1673 lra_insn_stack_length (void)
1675 return lra_constraint_insn_stack
.length ();
1678 /* Push insns FROM to TO (excluding it) going in reverse order. */
1680 push_insns (rtx_insn
*from
, rtx_insn
*to
)
1684 if (from
== NULL_RTX
)
1686 for (insn
= from
; insn
!= to
; insn
= PREV_INSN (insn
))
1688 lra_push_insn (insn
);
1691 /* Set up sp offset for insn in range [FROM, LAST]. The offset is
1692 taken from the next BB insn after LAST or zero if there in such
1695 setup_sp_offset (rtx_insn
*from
, rtx_insn
*last
)
1697 rtx_insn
*before
= next_nonnote_insn_bb (last
);
1698 HOST_WIDE_INT offset
= (before
== NULL_RTX
|| ! INSN_P (before
)
1699 ? 0 : lra_get_insn_recog_data (before
)->sp_offset
);
1701 for (rtx_insn
*insn
= from
; insn
!= NEXT_INSN (last
); insn
= NEXT_INSN (insn
))
1702 lra_get_insn_recog_data (insn
)->sp_offset
= offset
;
1705 /* Emit insns BEFORE before INSN and insns AFTER after INSN. Put the
1706 insns onto the stack. Print about emitting the insns with
1709 lra_process_new_insns (rtx_insn
*insn
, rtx_insn
*before
, rtx_insn
*after
,
1714 if (before
== NULL_RTX
&& after
== NULL_RTX
)
1716 if (lra_dump_file
!= NULL
)
1718 dump_insn_slim (lra_dump_file
, insn
);
1719 if (before
!= NULL_RTX
)
1721 fprintf (lra_dump_file
," %s before:\n", title
);
1722 dump_rtl_slim (lra_dump_file
, before
, NULL
, -1, 0);
1724 if (after
!= NULL_RTX
)
1726 fprintf (lra_dump_file
, " %s after:\n", title
);
1727 dump_rtl_slim (lra_dump_file
, after
, NULL
, -1, 0);
1729 fprintf (lra_dump_file
, "\n");
1731 if (before
!= NULL_RTX
)
1733 emit_insn_before (before
, insn
);
1734 push_insns (PREV_INSN (insn
), PREV_INSN (before
));
1735 setup_sp_offset (before
, PREV_INSN (insn
));
1737 if (after
!= NULL_RTX
)
1739 for (last
= after
; NEXT_INSN (last
) != NULL_RTX
; last
= NEXT_INSN (last
))
1741 emit_insn_after (after
, insn
);
1742 push_insns (last
, insn
);
1743 setup_sp_offset (after
, last
);
1749 /* This page contains code dealing with scratches (changing them onto
1750 pseudos and restoring them from the pseudos).
1752 We change scratches into pseudos at the beginning of LRA to
1753 simplify dealing with them (conflicts, hard register assignments).
1755 If the pseudo denoting scratch was spilled it means that we do need
1756 a hard register for it. Such pseudos are transformed back to
1757 scratches at the end of LRA. */
1759 /* Description of location of a former scratch operand. */
1762 rtx_insn
*insn
; /* Insn where the scratch was. */
1763 int nop
; /* Number of the operand which was a scratch. */
1766 typedef struct sloc
*sloc_t
;
1768 /* Locations of the former scratches. */
1769 static vec
<sloc_t
> scratches
;
1771 /* Bitmap of scratch regnos. */
1772 static bitmap_head scratch_bitmap
;
1774 /* Bitmap of scratch operands. */
1775 static bitmap_head scratch_operand_bitmap
;
1777 /* Return true if pseudo REGNO is made of SCRATCH. */
1779 lra_former_scratch_p (int regno
)
1781 return bitmap_bit_p (&scratch_bitmap
, regno
);
1784 /* Return true if the operand NOP of INSN is a former scratch. */
1786 lra_former_scratch_operand_p (rtx_insn
*insn
, int nop
)
1788 return bitmap_bit_p (&scratch_operand_bitmap
,
1789 INSN_UID (insn
) * MAX_RECOG_OPERANDS
+ nop
) != 0;
1792 /* Change scratches onto pseudos and save their location. */
1794 remove_scratches (void)
1797 bool insn_changed_p
;
1802 lra_insn_recog_data_t id
;
1803 struct lra_static_insn_data
*static_id
;
1805 scratches
.create (get_max_uid ());
1806 bitmap_initialize (&scratch_bitmap
, ®_obstack
);
1807 bitmap_initialize (&scratch_operand_bitmap
, ®_obstack
);
1808 FOR_EACH_BB_FN (bb
, cfun
)
1809 FOR_BB_INSNS (bb
, insn
)
1812 id
= lra_get_insn_recog_data (insn
);
1813 static_id
= id
->insn_static_data
;
1814 insn_changed_p
= false;
1815 for (i
= 0; i
< static_id
->n_operands
; i
++)
1816 if (GET_CODE (*id
->operand_loc
[i
]) == SCRATCH
1817 && GET_MODE (*id
->operand_loc
[i
]) != VOIDmode
)
1819 insn_changed_p
= true;
1820 *id
->operand_loc
[i
] = reg
1821 = lra_create_new_reg (static_id
->operand
[i
].mode
,
1822 *id
->operand_loc
[i
], ALL_REGS
, NULL
);
1823 add_reg_note (insn
, REG_UNUSED
, reg
);
1824 lra_update_dup (id
, i
);
1825 loc
= XNEW (struct sloc
);
1828 scratches
.safe_push (loc
);
1829 bitmap_set_bit (&scratch_bitmap
, REGNO (*id
->operand_loc
[i
]));
1830 bitmap_set_bit (&scratch_operand_bitmap
,
1831 INSN_UID (insn
) * MAX_RECOG_OPERANDS
+ i
);
1832 if (lra_dump_file
!= NULL
)
1833 fprintf (lra_dump_file
,
1834 "Removing SCRATCH in insn #%u (nop %d)\n",
1835 INSN_UID (insn
), i
);
1838 /* Because we might use DF right after caller-saves sub-pass
1839 we need to keep DF info up to date. */
1840 df_insn_rescan (insn
);
1844 /* Changes pseudos created by function remove_scratches onto scratches. */
1846 restore_scratches (void)
1851 rtx_insn
*last
= NULL
;
1852 lra_insn_recog_data_t id
= NULL
;
1854 for (i
= 0; scratches
.iterate (i
, &loc
); i
++)
1856 if (last
!= loc
->insn
)
1859 id
= lra_get_insn_recog_data (last
);
1861 if (REG_P (*id
->operand_loc
[loc
->nop
])
1862 && ((regno
= REGNO (*id
->operand_loc
[loc
->nop
]))
1863 >= FIRST_PSEUDO_REGISTER
)
1864 && lra_get_regno_hard_regno (regno
) < 0)
1866 /* It should be only case when scratch register with chosen
1867 constraint 'X' did not get memory or hard register. */
1868 lra_assert (lra_former_scratch_p (regno
));
1869 *id
->operand_loc
[loc
->nop
]
1870 = gen_rtx_SCRATCH (GET_MODE (*id
->operand_loc
[loc
->nop
]));
1871 lra_update_dup (id
, loc
->nop
);
1872 if (lra_dump_file
!= NULL
)
1873 fprintf (lra_dump_file
, "Restoring SCRATCH in insn #%u(nop %d)\n",
1874 INSN_UID (loc
->insn
), loc
->nop
);
1877 for (i
= 0; scratches
.iterate (i
, &loc
); i
++)
1879 scratches
.release ();
1880 bitmap_clear (&scratch_bitmap
);
1881 bitmap_clear (&scratch_operand_bitmap
);
1886 #ifdef ENABLE_CHECKING
1888 /* Function checks RTL for correctness. If FINAL_P is true, it is
1889 done at the end of LRA and the check is more rigorous. */
1891 check_rtl (bool final_p
)
1896 lra_assert (! final_p
|| reload_completed
);
1897 FOR_EACH_BB_FN (bb
, cfun
)
1898 FOR_BB_INSNS (bb
, insn
)
1899 if (NONDEBUG_INSN_P (insn
)
1900 && GET_CODE (PATTERN (insn
)) != USE
1901 && GET_CODE (PATTERN (insn
)) != CLOBBER
1902 && GET_CODE (PATTERN (insn
)) != ASM_INPUT
)
1906 #ifdef ENABLED_CHECKING
1907 extract_constrain_insn (insn
);
1911 /* LRA code is based on assumption that all addresses can be
1912 correctly decomposed. LRA can generate reloads for
1913 decomposable addresses. The decomposition code checks the
1914 correctness of the addresses. So we don't need to check
1915 the addresses here. Don't call insn_invalid_p here, it can
1916 change the code at this stage. */
1917 if (recog_memoized (insn
) < 0 && asm_noperands (PATTERN (insn
)) < 0)
1918 fatal_insn_not_found (insn
);
1921 #endif /* #ifdef ENABLE_CHECKING */
1923 /* Determine if the current function has an exception receiver block
1924 that reaches the exit block via non-exceptional edges */
1926 has_nonexceptional_receiver (void)
1930 basic_block
*tos
, *worklist
, bb
;
1932 /* If we're not optimizing, then just err on the safe side. */
1936 /* First determine which blocks can reach exit via normal paths. */
1937 tos
= worklist
= XNEWVEC (basic_block
, n_basic_blocks_for_fn (cfun
) + 1);
1939 FOR_EACH_BB_FN (bb
, cfun
)
1940 bb
->flags
&= ~BB_REACHABLE
;
1942 /* Place the exit block on our worklist. */
1943 EXIT_BLOCK_PTR_FOR_FN (cfun
)->flags
|= BB_REACHABLE
;
1944 *tos
++ = EXIT_BLOCK_PTR_FOR_FN (cfun
);
1946 /* Iterate: find everything reachable from what we've already seen. */
1947 while (tos
!= worklist
)
1951 FOR_EACH_EDGE (e
, ei
, bb
->preds
)
1952 if (e
->flags
& EDGE_ABNORMAL
)
1959 basic_block src
= e
->src
;
1961 if (!(src
->flags
& BB_REACHABLE
))
1963 src
->flags
|= BB_REACHABLE
;
1969 /* No exceptional block reached exit unexceptionally. */
1975 /* Process recursively X of INSN and add REG_INC notes if necessary. */
1977 add_auto_inc_notes (rtx_insn
*insn
, rtx x
)
1979 enum rtx_code code
= GET_CODE (x
);
1983 if (code
== MEM
&& auto_inc_p (XEXP (x
, 0)))
1985 add_reg_note (insn
, REG_INC
, XEXP (XEXP (x
, 0), 0));
1989 /* Scan all X sub-expressions. */
1990 fmt
= GET_RTX_FORMAT (code
);
1991 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
1994 add_auto_inc_notes (insn
, XEXP (x
, i
));
1995 else if (fmt
[i
] == 'E')
1996 for (j
= XVECLEN (x
, i
) - 1; j
>= 0; j
--)
1997 add_auto_inc_notes (insn
, XVECEXP (x
, i
, j
));
2003 /* Remove all REG_DEAD and REG_UNUSED notes and regenerate REG_INC.
2004 We change pseudos by hard registers without notification of DF and
2005 that can make the notes obsolete. DF-infrastructure does not deal
2006 with REG_INC notes -- so we should regenerate them here. */
2008 update_inc_notes (void)
2014 FOR_EACH_BB_FN (bb
, cfun
)
2015 FOR_BB_INSNS (bb
, insn
)
2016 if (NONDEBUG_INSN_P (insn
))
2018 pnote
= ®_NOTES (insn
);
2021 if (REG_NOTE_KIND (*pnote
) == REG_DEAD
2022 || REG_NOTE_KIND (*pnote
) == REG_UNUSED
2023 || REG_NOTE_KIND (*pnote
) == REG_INC
)
2024 *pnote
= XEXP (*pnote
, 1);
2026 pnote
= &XEXP (*pnote
, 1);
2029 add_auto_inc_notes (insn
, PATTERN (insn
));
2034 /* Set to 1 while in lra. */
2035 int lra_in_progress
;
2037 /* Start of pseudo regnos before the LRA. */
2038 int lra_new_regno_start
;
2040 /* Start of reload pseudo regnos before the new spill pass. */
2041 int lra_constraint_new_regno_start
;
2043 /* Inheritance pseudo regnos before the new spill pass. */
2044 bitmap_head lra_inheritance_pseudos
;
2046 /* Split regnos before the new spill pass. */
2047 bitmap_head lra_split_regs
;
2049 /* Reload pseudo regnos before the new assignmnet pass which still can
2050 be spilled after the assinment pass as memory is also accepted in
2051 insns for the reload pseudos. */
2052 bitmap_head lra_optional_reload_pseudos
;
2054 /* Pseudo regnos used for subreg reloads before the new assignment
2055 pass. Such pseudos still can be spilled after the assinment
2057 bitmap_head lra_subreg_reload_pseudos
;
2059 /* First UID of insns generated before a new spill pass. */
2060 int lra_constraint_new_insn_uid_start
;
2062 /* File used for output of LRA debug information. */
2063 FILE *lra_dump_file
;
2065 /* True if we should try spill into registers of different classes
2066 instead of memory. */
2067 bool lra_reg_spill_p
;
2069 /* Set up value LRA_REG_SPILL_P. */
2071 setup_reg_spill_flag (void)
2075 if (targetm
.spill_class
!= NULL
)
2076 for (cl
= 0; cl
< (int) LIM_REG_CLASSES
; cl
++)
2077 for (mode
= 0; mode
< MAX_MACHINE_MODE
; mode
++)
2078 if (targetm
.spill_class ((enum reg_class
) cl
,
2079 (enum machine_mode
) mode
) != NO_REGS
)
2081 lra_reg_spill_p
= true;
2084 lra_reg_spill_p
= false;
2087 /* True if the current function is too big to use regular algorithms
2088 in LRA. In other words, we should use simpler and faster algorithms
2089 in LRA. It also means we should not worry about generation code
2090 for caller saves. The value is set up in IRA. */
2093 /* Major LRA entry function. F is a file should be used to dump LRA
2099 bool live_p
, scratch_p
, inserted_p
;
2103 timevar_push (TV_LRA
);
2105 /* Make sure that the last insn is a note. Some subsequent passes
2107 emit_note (NOTE_INSN_DELETED
);
2109 COPY_HARD_REG_SET (lra_no_alloc_regs
, ira_no_alloc_regs
);
2114 init_insn_recog_data ();
2116 #ifdef ENABLE_CHECKING
2117 /* Some quick check on RTL generated by previous passes. */
2121 lra_in_progress
= 1;
2123 lra_live_range_iter
= lra_coalesce_iter
= lra_constraint_iter
= 0;
2124 lra_assignment_iter
= lra_assignment_iter_after_spill
= 0;
2125 lra_inheritance_iter
= lra_undo_inheritance_iter
= 0;
2127 setup_reg_spill_flag ();
2129 /* Function remove_scratches can creates new pseudos for clobbers --
2130 so set up lra_constraint_new_regno_start before its call to
2131 permit changing reg classes for pseudos created by this
2133 lra_constraint_new_regno_start
= lra_new_regno_start
= max_reg_num ();
2134 remove_scratches ();
2135 scratch_p
= lra_constraint_new_regno_start
!= max_reg_num ();
2137 /* A function that has a non-local label that can reach the exit
2138 block via non-exceptional paths must save all call-saved
2140 if (cfun
->has_nonlocal_label
&& has_nonexceptional_receiver ())
2141 crtl
->saves_all_registers
= 1;
2143 if (crtl
->saves_all_registers
)
2144 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
2145 if (! call_used_regs
[i
] && ! fixed_regs
[i
] && ! LOCAL_REGNO (i
))
2146 df_set_regs_ever_live (i
, true);
2148 /* We don't DF from now and avoid its using because it is to
2149 expensive when a lot of RTL changes are made. */
2150 df_set_flags (DF_NO_INSN_RESCAN
);
2151 lra_constraint_insn_stack
.create (get_max_uid ());
2152 lra_constraint_insn_stack_bitmap
= sbitmap_alloc (get_max_uid ());
2153 bitmap_clear (lra_constraint_insn_stack_bitmap
);
2154 lra_live_ranges_init ();
2155 lra_constraints_init ();
2156 lra_curr_reload_num
= 0;
2157 push_insns (get_last_insn (), NULL
);
2158 /* It is needed for the 1st coalescing. */
2159 lra_constraint_new_insn_uid_start
= get_max_uid ();
2160 bitmap_initialize (&lra_inheritance_pseudos
, ®_obstack
);
2161 bitmap_initialize (&lra_split_regs
, ®_obstack
);
2162 bitmap_initialize (&lra_optional_reload_pseudos
, ®_obstack
);
2163 bitmap_initialize (&lra_subreg_reload_pseudos
, ®_obstack
);
2165 if (get_frame_size () != 0 && crtl
->stack_alignment_needed
)
2166 /* If we have a stack frame, we must align it now. The stack size
2167 may be a part of the offset computation for register
2169 assign_stack_local (BLKmode
, 0, crtl
->stack_alignment_needed
);
2175 /* We should try to assign hard registers to scratches even
2176 if there were no RTL transformations in
2178 if (! lra_constraints (lra_constraint_iter
== 0)
2179 && (lra_constraint_iter
> 1
2180 || (! scratch_p
&& ! caller_save_needed
)))
2182 /* Constraint transformations may result in that eliminable
2183 hard regs become uneliminable and pseudos which use them
2184 should be spilled. It is better to do it before pseudo
2187 For example, rs6000 can make
2188 RS6000_PIC_OFFSET_TABLE_REGNUM uneliminable if we started
2189 to use a constant pool. */
2190 lra_eliminate (false, false);
2191 /* Do inheritance only for regular algorithms. */
2194 if (flag_use_caller_save
)
2197 lra_clear_live_ranges ();
2198 /* As a side-effect of lra_create_live_ranges, we calculate
2199 actual_call_used_reg_set, which is needed during
2201 lra_create_live_ranges (true);
2206 lra_clear_live_ranges ();
2207 /* We need live ranges for lra_assign -- so build them. */
2208 lra_create_live_ranges (true);
2210 /* If we don't spill non-reload and non-inheritance pseudos,
2211 there is no sense to run memory-memory move coalescing.
2212 If inheritance pseudos were spilled, the memory-memory
2213 moves involving them will be removed by pass undoing
2219 bool spill_p
= !lra_assign ();
2221 if (lra_undo_inheritance ())
2227 lra_create_live_ranges (true);
2230 if (lra_coalesce ())
2234 lra_clear_live_ranges ();
2237 /* Don't clear optional reloads bitmap until all constraints are
2238 satisfied as we need to differ them from regular reloads. */
2239 bitmap_clear (&lra_optional_reload_pseudos
);
2240 bitmap_clear (&lra_subreg_reload_pseudos
);
2241 bitmap_clear (&lra_inheritance_pseudos
);
2242 bitmap_clear (&lra_split_regs
);
2243 if (! lra_need_for_spills_p ())
2247 /* We need full live info for spilling pseudos into
2248 registers instead of memory. */
2249 lra_create_live_ranges (lra_reg_spill_p
);
2253 /* Assignment of stack slots changes elimination offsets for
2254 some eliminations. So update the offsets here. */
2255 lra_eliminate (false, false);
2256 lra_constraint_new_regno_start
= max_reg_num ();
2257 lra_constraint_new_insn_uid_start
= get_max_uid ();
2258 lra_assignment_iter_after_spill
= 0;
2260 restore_scratches ();
2261 lra_eliminate (true, false);
2262 lra_final_code_change ();
2263 lra_in_progress
= 0;
2265 lra_clear_live_ranges ();
2266 lra_live_ranges_finish ();
2267 lra_constraints_finish ();
2269 sbitmap_free (lra_constraint_insn_stack_bitmap
);
2270 lra_constraint_insn_stack
.release ();
2271 finish_insn_recog_data ();
2272 regstat_free_n_sets_and_refs ();
2274 reload_completed
= 1;
2275 update_inc_notes ();
2277 inserted_p
= fixup_abnormal_edges ();
2279 /* We've possibly turned single trapping insn into multiple ones. */
2280 if (cfun
->can_throw_non_call_exceptions
)
2283 blocks
= sbitmap_alloc (last_basic_block_for_fn (cfun
));
2284 bitmap_ones (blocks
);
2285 find_many_sub_basic_blocks (blocks
);
2286 sbitmap_free (blocks
);
2290 commit_edge_insertions ();
2292 /* Replacing pseudos with their memory equivalents might have
2293 created shared rtx. Subsequent passes would get confused
2294 by this, so unshare everything here. */
2295 unshare_all_rtl_again (get_insns ());
2297 #ifdef ENABLE_CHECKING
2301 timevar_pop (TV_LRA
);
2304 /* Called once per compiler to initialize LRA data once. */
2306 lra_init_once (void)
2308 init_insn_code_data_once ();
2311 /* Called once per compiler to finish LRA data which are initialize
2314 lra_finish_once (void)
2316 finish_insn_code_data_once ();