GCC Middle and Back End API Reference
lra.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "target.h"
#include "rtl.h"
#include "rtl-error.h"
#include "tree.h"
#include "predict.h"
#include "df.h"
#include "memmodel.h"
#include "tm_p.h"
#include "optabs.h"
#include "regs.h"
#include "ira.h"
#include "recog.h"
#include "expr.h"
#include "cfgrtl.h"
#include "cfgbuild.h"
#include "lra.h"
#include "lra-int.h"
#include "print-rtl.h"
#include "function-abi.h"
Include dependency graph for lra.cc:

Functions

void lra_dump_bitmap_with_title (const char *title, bitmap set, int index)
 
static int get_new_reg_value (void)
 
static void expand_reg_info (void)
 
static void invalidate_insn_recog_data (int)
 
static int get_insn_freq (rtx_insn *)
 
static void invalidate_insn_data_regno_info (lra_insn_recog_data_t, rtx_insn *, int)
 
static void expand_reg_data (int old)
 
rtx lra_create_new_reg_with_unique_value (machine_mode md_mode, rtx original, enum reg_class rclass, HARD_REG_SET *exclude_start_hard_regs, const char *title)
 
rtx lra_create_new_reg (machine_mode md_mode, rtx original, enum reg_class rclass, HARD_REG_SET *exclude_start_hard_regs, const char *title)
 
void lra_set_regno_unique_value (int regno)
 
void lra_invalidate_insn_data (rtx_insn *insn)
 
void lra_set_insn_deleted (rtx_insn *insn)
 
void lra_delete_dead_insn (rtx_insn *insn)
 
static rtx_insnemit_add3_insn (rtx x, rtx y, rtx z)
 
static rtx_insnemit_add2_insn (rtx x, rtx y)
 
void lra_emit_add (rtx x, rtx y, rtx z)
 
static void remove_insn_scratches (rtx_insn *insn)
 
void lra_emit_move (rtx x, rtx y)
 
void lra_update_dups (lra_insn_recog_data_t id, signed char *nops)
 
void lra_asm_insn_error (rtx_insn *insn)
 
static struct lra_insn_regnew_insn_reg (rtx_insn *insn, int regno, enum op_type type, machine_mode mode, bool subreg_p, alternative_mask early_clobber_alts, struct lra_insn_reg *next)
 
static void free_insn_regs (struct lra_insn_reg *ir)
 
static void finish_insn_regs (void)
 
static void init_insn_code_data_once (void)
 
static void finish_insn_code_data_once (void)
 
static struct lra_static_insn_dataget_static_insn_data (int icode, int nop, int ndup, int nalt)
 
static void init_insn_recog_data (void)
 
static void check_and_expand_insn_recog_data (int index)
 
static void free_insn_recog_data (lra_insn_recog_data_t data)
 
static void finish_insn_recog_data (void)
 
static void setup_operand_alternative (lra_insn_recog_data_t data, const operand_alternative *op_alt)
 
static struct lra_insn_regcollect_non_operand_hard_regs (rtx_insn *insn, rtx *x, lra_insn_recog_data_t data, struct lra_insn_reg *list, enum op_type type, bool early_clobber)
 
lra_insn_recog_data_t lra_set_insn_recog_data (rtx_insn *insn)
 
static lra_insn_recog_data_t get_insn_recog_data_by_uid (int uid)
 
lra_insn_recog_data_t lra_update_insn_recog_data (rtx_insn *insn)
 
void lra_set_used_insn_alternative (rtx_insn *insn, int alt)
 
void lra_set_used_insn_alternative_by_uid (int uid, int alt)
 
static void initialize_lra_reg_info_element (int i)
 
static void init_reg_info (void)
 
static void finish_reg_info (void)
 
void lra_free_copies (void)
 
void lra_create_copy (int regno1, int regno2, int freq)
 
lra_copy_t lra_get_copy (int n)
 
static void add_regs_to_insn_regno_info (lra_insn_recog_data_t data, rtx x, rtx_insn *insn, enum op_type type, alternative_mask early_clobber_alts)
 
void lra_invalidate_insn_regno_info (rtx_insn *insn)
 
static void setup_insn_reg_info (lra_insn_recog_data_t data, int freq)
 
void lra_update_insn_regno_info (rtx_insn *insn)
 
struct lra_insn_reglra_get_insn_regs (int uid)
 
hashval_t lra_rtx_hash (rtx x)
 
static void lra_push_insn_1 (rtx_insn *insn, bool always_update)
 
void lra_push_insn (rtx_insn *insn)
 
void lra_push_insn_and_update_insn_regno_info (rtx_insn *insn)
 
void lra_push_insn_by_uid (unsigned int uid)
 
rtx_insnlra_pop_insn (void)
 
unsigned int lra_insn_stack_length (void)
 
static void push_insns (rtx_insn *from, rtx_insn *to)
 
static poly_int64 setup_sp_offset (rtx_insn *from, rtx_insn *last)
 
void lra_dump_insns (FILE *f)
 
void lra_dump_insns_if_possible (const char *title)
 
void lra_process_new_insns (rtx_insn *insn, rtx_insn *before, rtx_insn *after, const char *title)
 
bool lra_substitute_pseudo (rtx *loc, int old_regno, rtx new_reg, bool subreg_p, bool debug_p)
 
bool lra_substitute_pseudo_within_insn (rtx_insn *insn, int old_regno, rtx new_reg, bool subreg_p)
 
static rtx get_scratch_reg (rtx original)
 
static void remove_scratches (void)
 
static void check_rtl (bool final_p)
 
static bool has_nonexceptional_receiver (void)
 
static void update_inc_notes (void)
 
static void setup_reg_spill_flag (void)
 
void lra (FILE *f, int verbose)
 
void lra_init_once (void)
 
void lra_finish_once (void)
 

Variables

HARD_REG_SET lra_no_alloc_regs
 
int lra_curr_reload_num
 
object_allocator< lra_insn_reglra_insn_reg_pool ("insn regs")
 
struct lra_static_insn_datainsn_code_data [NUM_INSN_CODES]
 
static struct lra_operand_data debug_operand_data
 
static struct lra_static_insn_data debug_bind_static_data
 
static struct lra_static_insn_data debug_marker_static_data
 
int lra_insn_recog_data_len
 
lra_insn_recog_data_tlra_insn_recog_data
 
static object_allocator< class lra_insn_recog_datalra_insn_recog_data_pool ("insn recog data pool")
 
static object_allocator< lra_copylra_copy_pool ("lra copies")
 
static int reg_info_size
 
class lra_reglra_reg_info
 
HARD_REG_SET hard_regs_spilled_into
 
static int last_reg_value
 
static vec< lra_copy_tcopy_vec
 
static sbitmap lra_constraint_insn_stack_bitmap
 
vec< rtx_insn * > lra_constraint_insn_stack
 
bool lra_in_progress = false
 
int lra_new_regno_start
 
int lra_constraint_new_regno_start
 
int lra_bad_spill_regno_start
 
rtx lra_pmode_pseudo
 
bitmap_head lra_inheritance_pseudos
 
bitmap_head lra_split_regs
 
bitmap_head lra_optional_reload_pseudos
 
bitmap_head lra_subreg_reload_pseudos
 
FILElra_dump_file
 
int lra_verbose
 
bool lra_hard_reg_split_p
 
bool lra_asm_error_p
 
bool lra_reg_spill_p
 
bool lra_simple_p
 

Function Documentation

◆ add_regs_to_insn_regno_info()

static void add_regs_to_insn_regno_info ( lra_insn_recog_data_t data,
rtx x,
rtx_insn * insn,
enum op_type type,
alternative_mask early_clobber_alts )
static
This page contains code dealing with info about registers in
insns.   
Process X of INSN recursively and add info (operand type is given
by TYPE) about registers in X to the insn DATA.  If X can be early
clobbered, alternatives in which it can be early clobbered are given
by EARLY_CLOBBER_ALTS.   

References add_regs_to_insn_regno_info(), ALL_ALTERNATIVES, bitmap_set_bit, lra_insn_reg::early_clobber_alts, expand_reg_info(), gcc_unreachable, GET_CODE, GET_MODE, GET_RTX_FORMAT, GET_RTX_LENGTH, ggc_alloc(), i, INSN_UID(), lra_reg_info, new_insn_reg(), NULL, OP_IN, OP_INOUT, OP_OUT, read_modify_subreg_p(), REG_P, lra_insn_reg::regno, REGNO, SET, SET_DEST, SET_SRC, lra_insn_reg::subreg_p, SUBREG_REG, wider_subreg_mode(), XEXP, XVECEXP, and XVECLEN.

Referenced by add_regs_to_insn_regno_info(), and lra_update_insn_regno_info().

◆ check_and_expand_insn_recog_data()

static void check_and_expand_insn_recog_data ( int index)
static
Expand, if necessary, LRA data about insns.    

References ggc_alloc(), i, lra_insn_recog_data_len, and NULL.

Referenced by lra_set_insn_recog_data(), lra_set_used_insn_alternative_by_uid(), and lra_update_insn_recog_data().

◆ check_rtl()

static void check_rtl ( bool final_p)
static
Function checks RTL for correctness.  If FINAL_P is true, it is
done at the end of LRA and the check is more rigorous.   

References asm_noperands(), cfun, extract_constrain_insn(), fatal_insn_not_found, FOR_BB_INSNS, FOR_EACH_BB_FN, GET_CODE, ggc_alloc(), lra_assert, NONDEBUG_INSN_P, PATTERN(), recog_memoized(), and reload_completed.

Referenced by lra().

◆ collect_non_operand_hard_regs()

static struct lra_insn_reg * collect_non_operand_hard_regs ( rtx_insn * insn,
rtx * x,
lra_insn_recog_data_t data,
struct lra_insn_reg * list,
enum op_type type,
bool early_clobber )
static
Recursively process X and collect info about registers, which are
not the insn operands, in X with TYPE (in/out/inout) and flag that
it is early clobbered in the insn (EARLY_CLOBBER) and add the info
to LIST.  X is a part of insn given by DATA.     Return the result
list.   

References ALL_ALTERNATIVES, collect_non_operand_hard_regs(), end_hard_regno(), GET_CODE, GET_MODE, GET_RTX_FORMAT, GET_RTX_LENGTH, ggc_alloc(), i, last, data::n_dups, data::n_operands, new_insn_reg(), NULL, OP_IN, OP_INOUT, OP_OUT, data::operand, read_modify_subreg_p(), REG_P, lra_insn_reg::regno, REGNO, SET, SET_DEST, SET_SRC, lra_insn_reg::subreg_p, SUBREG_REG, wider_subreg_mode(), XEXP, XVECEXP, and XVECLEN.

Referenced by collect_non_operand_hard_regs(), and lra_set_insn_recog_data().

◆ emit_add2_insn()

static rtx_insn * emit_add2_insn ( rtx x,
rtx y )
static
Emit insn x = x + y.  Return the insn.  We use gen_add2_insn as the
last resort.   

References emit_add3_insn(), emit_insn(), gen_add2_insn(), NULL_RTX, and y.

Referenced by lra_emit_add().

◆ emit_add3_insn()

static rtx_insn * emit_add3_insn ( rtx x,
rtx y,
rtx z )
static
Emit insn x = y + z.  Return NULL if we failed to do it.
Otherwise, return the insn.  We don't use gen_add3_insn as it might
clobber CC.   

References delete_insns_since(), emit_insn(), gen_addptr3_insn(), get_last_insn(), GET_MODE, ggc_alloc(), have_addptr3_insn(), last, lra_assert, NULL, NULL_RTX, recog_memoized(), and y.

Referenced by emit_add2_insn(), and lra_emit_add().

◆ expand_reg_data()

static void expand_reg_data ( int old)
static

◆ expand_reg_info()

static void expand_reg_info ( void )
static
Expand common reg info if it is necessary.   

References ggc_alloc(), i, initialize_lra_reg_info_element(), lra_reg_info, max_reg_num(), and reg_info_size.

Referenced by add_regs_to_insn_regno_info(), expand_reg_data(), and lra().

◆ finish_insn_code_data_once()

static void finish_insn_code_data_once ( void )
static
Called once per compiler work to finalize some LRA data related to
insns.   

References free(), ggc_alloc(), i, insn_code_data, and NULL.

Referenced by lra_finish_once().

◆ finish_insn_recog_data()

static void finish_insn_recog_data ( void )
static

◆ finish_insn_regs()

static void finish_insn_regs ( void )
static
Finish pool for insn reg info.   

References lra_insn_reg_pool.

Referenced by finish_insn_recog_data().

◆ finish_reg_info()

static void finish_reg_info ( void )
static
Finish common reg info and copies.   

References bitmap_clear(), free(), i, lra_reg::insn_bitmap, lra_reg_info, and reg_info_size.

Referenced by lra().

◆ free_insn_recog_data()

static void free_insn_recog_data ( lra_insn_recog_data_t data)
static

◆ free_insn_regs()

static void free_insn_regs ( struct lra_insn_reg * ir)
static
Free insn reg info list IR.    

References ggc_alloc(), lra_insn_reg_pool, and NULL.

Referenced by free_insn_recog_data().

◆ get_insn_freq()

static int get_insn_freq ( rtx_insn * insn)
static

◆ get_insn_recog_data_by_uid()

static lra_insn_recog_data_t get_insn_recog_data_by_uid ( int uid)
static
Return info about insn give by UID.  The info should be already set
up.      

References lra_assert, and NULL.

Referenced by lra_get_insn_regs().

◆ get_new_reg_value()

static int get_new_reg_value ( void )
static
Return new register value.   

References last_reg_value.

Referenced by initialize_lra_reg_info_element(), and lra_set_regno_unique_value().

◆ get_scratch_reg()

static rtx get_scratch_reg ( rtx original)
static
Return new register of the same mode as ORIGINAL of class ALL_REGS.
Used in ira_remove_scratches.   

References GET_MODE, ggc_alloc(), lra_create_new_reg(), and NULL.

Referenced by remove_insn_scratches().

◆ get_static_insn_data()

static struct lra_static_insn_data * get_static_insn_data ( int icode,
int nop,
int ndup,
int nalt )
static
Return static insn data, allocate and setup if necessary.  Although
dup_num is static data (it depends only on icode), to set it up we
need to extract insn first.     So recog_data should be valid for
normal insn (ICODE >= 0) before the call.   

References operand_data::constraint, insn_operand_data::constraint, recog_data_d::dup_num, ggc_alloc(), i, insn_code_data, insn_data, insn_operand_data::is_operator, lra_assert, operand_data::mode, insn_operand_data::mode, data::n_alternatives, data::n_dups, data::n_operands, NULL, OP_IN, OP_INOUT, OP_OUT, data::operand, insn_data_d::operand, recog_data, operand_data::strict_low, and insn_operand_data::strict_low.

Referenced by lra_set_insn_recog_data().

◆ has_nonexceptional_receiver()

static bool has_nonexceptional_receiver ( void )
static
Determine if the current function has an exception receiver block
that reaches the exit block via non-exceptional edges   

References cfun, EXIT_BLOCK_PTR_FOR_FN, basic_block_def::flags, FOR_EACH_BB_FN, FOR_EACH_EDGE, free(), ggc_alloc(), n_basic_blocks_for_fn, basic_block_def::preds, and worklist.

Referenced by lra().

◆ init_insn_code_data_once()

static void init_insn_code_data_once ( void )
static
Called once per compiler work to initialize some LRA data related
to insns.   

References ggc_alloc(), and insn_code_data.

Referenced by lra_init_once().

◆ init_insn_recog_data()

static void init_insn_recog_data ( void )
static
Initialize LRA data about insns.   

References lra_insn_recog_data_len, and NULL.

Referenced by lra().

◆ init_reg_info()

static void init_reg_info ( void )
static

◆ initialize_lra_reg_info_element()

◆ invalidate_insn_data_regno_info()

static void invalidate_insn_data_regno_info ( lra_insn_recog_data_t data,
rtx_insn * insn,
int freq )
static
Invalidate all reg info of INSN with DATA and execution frequency
FREQ.  Update common info about the invalidated registers.   

References bitmap_clear_bit(), DEBUG_INSN_P, lra_reg::freq, ggc_alloc(), i, INSN_UID(), lra_assert, lra_insn_reg_pool, lra_reg_info, lra_reg::nrefs, and NULL.

Referenced by lra_invalidate_insn_regno_info(), lra_update_insn_recog_data(), and lra_update_insn_regno_info().

◆ invalidate_insn_recog_data()

static void invalidate_insn_recog_data ( int uid)
static
Invalidate all info about insn given by its UID.   

References free_insn_recog_data(), lra_assert, and NULL.

Referenced by lra_invalidate_insn_data(), and lra_update_insn_recog_data().

◆ lra()

void lra ( FILE * f,
int verbose )
Major LRA entry function.  F is a file should be used to dump LRA
debug info with given verbosity.   

References assign_stack_local(), bitmap_clear(), bitmap_empty_p(), bitmap_initialize(), bitmap_ones(), cfun, check_rtl(), commit_edge_insertions(), crtl, DF_NO_INSN_RESCAN, df_set_flags(), df_set_regs_ever_live(), emit_note(), expand_reg_info(), find_many_sub_basic_blocks(), finish_insn_recog_data(), finish_reg_info(), fixed_regs, fixup_abnormal_edges(), gen_reg_rtx(), get_frame_size(), get_insns(), get_last_insn(), get_max_uid(), ggc_alloc(), has_nonexceptional_receiver(), i, init_insn_recog_data(), init_reg_info(), INT_MAX, ira_no_alloc_regs, ira_restore_scratches(), last_basic_block_for_fn, LOCAL_REGNO, lra_asm_error_p, lra_assign(), lra_assignment_iter, lra_assignment_iter_after_spill, lra_bad_spill_regno_start, lra_clear_live_ranges(), lra_coalesce(), lra_coalesce_iter, lra_constraint_insn_stack, lra_constraint_insn_stack_bitmap, lra_constraint_iter, lra_constraint_new_regno_start, lra_constraints(), lra_constraints_finish(), lra_constraints_init(), lra_create_live_ranges(), lra_curr_reload_num, lra_dump_file, lra_eliminate(), lra_final_code_change(), lra_hard_reg_split_p, lra_in_progress, lra_inheritance(), lra_inheritance_iter, lra_inheritance_pseudos, lra_init_equiv(), lra_live_range_iter, lra_live_ranges_finish(), lra_live_ranges_init(), LRA_MAX_INHERITANCE_PASSES, LRA_MAX_REMATERIALIZATION_PASSES, lra_need_for_scratch_reg_p(), lra_need_for_spills_p(), lra_new_regno_start, lra_no_alloc_regs, lra_optional_reload_pseudos, lra_pmode_pseudo, lra_reg_spill_p, lra_remat(), lra_rematerialization_iter, lra_simple_p, lra_spill(), lra_split_hard_reg_for(), lra_split_regs, lra_subreg_reload_pseudos, lra_undo_inheritance(), lra_undo_inheritance_iter, lra_verbose, max_reg_num(), NULL, push_insns(), reg_obstack, regstat_free_n_sets_and_refs(), regstat_free_ri(), reload_completed, remove_scratches(), sbitmap_alloc(), sbitmap_free(), setup_reg_spill_flag(), timevar_pop(), timevar_push(), unshare_all_rtl_again(), update_inc_notes(), and verbose.

Referenced by do_reload().

◆ lra_asm_insn_error()

void lra_asm_insn_error ( rtx_insn * insn)

◆ lra_create_copy()

void lra_create_copy ( int regno1,
int regno2,
int freq )
Create copy of two pseudos REGNO1 and REGNO2.  The copy execution
frequency is FREQ.   

References lra_reg::copies, copy_vec, lra_reg::freq, ggc_alloc(), lra_assert, lra_copy_pool, lra_dump_file, lra_reg_info, and NULL.

Referenced by process_bb_lives().

◆ lra_create_new_reg()

◆ lra_create_new_reg_with_unique_value()

rtx lra_create_new_reg_with_unique_value ( machine_mode md_mode,
rtx original,
enum reg_class rclass,
HARD_REG_SET * exclude_start_hard_regs,
const char * title )
Create and return a new reg of ORIGINAL mode.  If ORIGINAL is NULL
or of VOIDmode, use MD_MODE for the new reg.  Initialize its
register class to RCLASS.  Print message about assigning class
RCLASS containing new register name TITLE unless it is NULL.  Use
attributes of ORIGINAL if it is a register.  The created register
will have unique held value.   

References lra_reg::exclude_start_hard_regs, expand_reg_data(), gen_reg_rtx(), GET_MODE, ggc_alloc(), lra_assert, lra_dump_file, lra_reg_info, max_reg_num(), NULL, NULL_RTX, ORIGINAL_REGNO, REG_ATTRS, reg_class_names, REG_P, REG_POINTER, REG_USERVAR_P, REGNO, and setup_reg_classes().

Referenced by check_and_process_move(), get_reload_reg(), lra_create_new_reg(), match_reload(), and process_addr_reg().

◆ lra_delete_dead_insn()

void lra_delete_dead_insn ( rtx_insn * insn)
Delete an unneeded INSN and any previous insns who sole purpose is
loading data that is dead in INSN.   

References find_regno_note(), GET_CODE, ggc_alloc(), lra_delete_dead_insn(), lra_set_insn_deleted(), PATTERN(), prev_real_insn(), reg_mentioned_p(), REG_P, REGNO, SET, SET_DEST, SET_SRC, and side_effects_p().

Referenced by lra_delete_dead_insn().

◆ lra_dump_bitmap_with_title()

void lra_dump_bitmap_with_title ( const char * title,
bitmap set,
int index )
LRA (local register allocator) driver and LRA utilities.
   Copyright (C) 2010-2024 Free Software Foundation, Inc.
   Contributed by Vladimir Makarov <vmakarov@redhat.com>.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
The Local Register Allocator (LRA) is a replacement of former
   reload pass.  It is focused to simplify code solving the reload
   pass tasks, to make the code maintenance easier, and to implement new
   perspective optimizations.

   The major LRA design solutions are:
     o division small manageable, separated sub-tasks
     o reflection of all transformations and decisions in RTL as more
       as possible
     o insn constraints as a primary source of the info (minimizing
       number of target-depended macros/hooks)

   In brief LRA works by iterative insn process with the final goal is
   to satisfy all insn and address constraints:
     o New reload insns (in brief reloads) and reload pseudos might be
       generated;
     o Some pseudos might be spilled to assign hard registers to
       new reload pseudos;
     o Recalculating spilled pseudo values (rematerialization);
     o Changing spilled pseudos to stack memory or their equivalences;
     o Allocation stack memory changes the address displacement and
       new iteration is needed.

   Here is block diagram of LRA passes:

                                ------------------------
           ---------------     | Undo inheritance for   |     ---------------
          | Memory-memory |    | spilled pseudos,       |    | New (and old) |
          | move coalesce |<---| splits for pseudos got |<-- |   pseudos     |
           ---------------     | the same hard regs,    |    |  assignment   |
  Start           |            | and optional reloads   |     ---------------
    |             |             ------------------------            ^
    V             |              ----------------                   |
 -----------      V             | Update virtual |                  |
|  Remove   |----> ------------>|    register    |                  |
| scratches |     ^             |  displacements |                  |
 -----------      |              ----------------                   |
                  |                      |                          |
                  |                      V         New              |
                  |                 ------------  pseudos   -------------------
                  |                |Constraints:| or insns | Inheritance/split |
                  |                |    RTL     |--------->|  transformations  |
                  |                | transfor-  |          |    in EBB scope   |
                  | substi-        |  mations   |           -------------------
                  | tutions         ------------
                  |                     | No change
          ----------------              V
         | Spilled pseudo |      -------------------
         |    to memory   |<----| Rematerialization |
         |  substitution  |      -------------------
          ----------------        
                  | No susbtitions
                  V                
      -------------------------
     | Hard regs substitution, |
     |  devirtalization, and   |------> Finish
     | restoring scratches got |
     |         memory          |
      -------------------------

   To speed up the process:
     o We process only insns affected by changes on previous
       iterations;
     o We don't use DFA-infrastructure because it results in much slower
       compiler speed than a special IR described below does;
     o We use a special insn representation for quick access to insn
       info which is always *synchronized* with the current RTL;
       o Insn IR is minimized by memory.  It is divided on three parts:
         o one specific for each insn in RTL (only operand locations);
         o one common for all insns in RTL with the same insn code
           (different operand attributes from machine descriptions);
         o one oriented for maintenance of live info (list of pseudos).
       o Pseudo data:
         o all insns where the pseudo is referenced;
         o live info (conflicting hard regs, live ranges, # of
           references etc);
         o data used for assigning (preferred hard regs, costs etc).

   This file contains LRA driver, LRA utility functions and data, and
   code for dealing with scratches.   
Dump bitmap SET with TITLE and BB INDEX.   

References bitmap_empty_p(), count, EXECUTE_IF_SET_IN_BITMAP, ggc_alloc(), i, and lra_dump_file.

Referenced by dump_candidates_and_remat_bb_data(), and lra_create_live_ranges_1().

◆ lra_dump_insns()

void lra_dump_insns ( FILE * f)
Dump all func insns in a slim form.   

References dump_rtl_slim(), get_insns(), and NULL.

Referenced by lra_dump_insns_if_possible().

◆ lra_dump_insns_if_possible()

void lra_dump_insns_if_possible ( const char * title)
Dump all func insns in a slim form with TITLE when the dump file is open and
lra_verbose >=7.   

References ggc_alloc(), lra_dump_file, lra_dump_insns(), lra_verbose, and NULL.

Referenced by lra_constraints(), lra_inheritance(), lra_remat(), lra_split_hard_reg_for(), and lra_undo_inheritance().

◆ lra_emit_add()

void lra_emit_add ( rtx x,
rtx y,
rtx z )
Target checks operands through operand predicates to recognize an
insn.  We should have a special precaution to generate add insns
which are frequent results of elimination.

Emit insns for x = y + z.  X can be used to store intermediate
values and should be not in Y and Z when we use X to store an
intermediate value.  Y + Z should form [base] [+ index[ * scale]] [
+ disp] where base and index are registers, disp and scale are
constants.  Y should contain base if it is present, Z should
contain disp if any.  index[*scale] can be part of Y or Z.   

References CONSTANT_P, delete_insns_since(), emit_add2_insn(), emit_add3_insn(), emit_move_insn(), expand_reg_data(), GET_CODE, get_last_insn(), GET_MODE, ggc_alloc(), last, lra_assert, max_reg_num(), NULL, NULL_RTX, recog_memoized(), REG_P, XEXP, and y.

Referenced by base_plus_disp_to_reg(), and lra_emit_move().

◆ lra_emit_move()

void lra_emit_move ( rtx x,
rtx y )
Emit x := y, processing special case when y = u + v or y = u + v *
scale + w through emit_add (Y can be an address which is base +
index reg * scale + displacement in general case).  X may be used
as intermediate result therefore it should be not in Y.   

References emit_insn(), emit_move_insn(), expand_reg_data(), GET_CODE, ggc_alloc(), lra_reg::last_reload, lra_curr_reload_num, lra_emit_add(), lra_reg_info, max_reg_num(), NULL_RTX, ORIGINAL_REGNO, REG_P, remove_insn_scratches(), rtx_equal_p(), XEXP, and y.

Referenced by check_and_process_move(), curr_insn_transform(), inherit_reload_reg(), insert_move_for_subreg(), match_reload(), process_addr_reg(), process_address_1(), and process_invariant_for_inheritance().

◆ lra_finish_once()

void lra_finish_once ( void )
Called once per compiler to finish LRA data which are initialize
once.   

References finish_insn_code_data_once().

Referenced by finalize().

◆ lra_free_copies()

void lra_free_copies ( void )
Free all copies.   

References lra_reg::copies, copy_vec, ggc_alloc(), lra_copy_pool, lra_reg_info, and NULL.

Referenced by lra_create_live_ranges_1().

◆ lra_get_copy()

lra_copy_t lra_get_copy ( int n)
Return N-th (0, 1, ...) copy.  If there is no copy, return
NULL.   

References copy_vec, and NULL.

Referenced by init_regno_assign_info().

◆ lra_get_insn_regs()

struct lra_insn_reg * lra_get_insn_regs ( int uid)
Return reg info of insn given by it UID.   

References get_insn_recog_data_by_uid().

Referenced by spill_for().

◆ lra_init_once()

void lra_init_once ( void )
Called once per compiler to initialize LRA data once.   

References init_insn_code_data_once().

Referenced by ira_init_once().

◆ lra_insn_stack_length()

unsigned int lra_insn_stack_length ( void )
Return the current size of the insn stack.   

References lra_constraint_insn_stack.

Referenced by lra_constraints().

◆ lra_invalidate_insn_data()

void lra_invalidate_insn_data ( rtx_insn * insn)
Invalidate INSN related info used by LRA.  The info should never be
used after that.   

References INSN_UID(), invalidate_insn_recog_data(), and lra_invalidate_insn_regno_info().

Referenced by curr_insn_transform(), lra_final_code_change(), lra_set_insn_deleted(), and spill_pseudos().

◆ lra_invalidate_insn_regno_info()

void lra_invalidate_insn_regno_info ( rtx_insn * insn)
Invalidate all reg info of INSN.  Update common info about the
invalidated registers.   

References get_insn_freq(), invalidate_insn_data_regno_info(), and lra_get_insn_recog_data().

Referenced by lra_invalidate_insn_data().

◆ lra_pop_insn()

rtx_insn * lra_pop_insn ( void )
Take the last-inserted insns off the stack and return it.   

References bitmap_clear_bit(), INSN_UID(), lra_constraint_insn_stack, and lra_constraint_insn_stack_bitmap.

Referenced by lra_constraints().

◆ lra_process_new_insns()

◆ lra_push_insn()

◆ lra_push_insn_1()

static void lra_push_insn_1 ( rtx_insn * insn,
bool always_update )
inlinestatic
Put INSN on the stack.  If ALWAYS_UPDATE is true, always update the reg
info for INSN, otherwise only update it if INSN is not already on the
stack.   

References bitmap_bit_p, bitmap_set_bit, ggc_alloc(), INSN_UID(), lra_constraint_insn_stack, lra_constraint_insn_stack_bitmap, lra_update_insn_regno_info(), sbitmap_resize(), and SBITMAP_SIZE.

Referenced by lra_push_insn(), and lra_push_insn_and_update_insn_regno_info().

◆ lra_push_insn_and_update_insn_regno_info()

void lra_push_insn_and_update_insn_regno_info ( rtx_insn * insn)
Put INSN on the stack and update its reg info.   

References lra_push_insn_1().

Referenced by combine_reload_insn(), and remove_inheritance_pseudos().

◆ lra_push_insn_by_uid()

void lra_push_insn_by_uid ( unsigned int uid)
Put insn with UID on the stack.   

References lra_push_insn().

Referenced by lra_assign(), and lra_constraints().

◆ lra_rtx_hash()

hashval_t lra_rtx_hash ( rtx x)
Recursive hash function for RTL X.   

References abort, GET_CODE, GET_RTX_FORMAT, GET_RTX_LENGTH, ggc_alloc(), i, lra_rtx_hash(), REGNO, UINTVAL, XEXP, XINT, XSTR, XVECEXP, XVECLEN, and XWINT.

Referenced by invariant_hash(), and lra_rtx_hash().

◆ lra_set_insn_deleted()

◆ lra_set_insn_recog_data()

◆ lra_set_regno_unique_value()

void lra_set_regno_unique_value ( int regno)
Set up for REGNO unique hold value.    

References get_new_reg_value(), lra_reg_info, and lra_reg::val.

Referenced by curr_insn_transform(), and lra_coalesce().

◆ lra_set_used_insn_alternative()

void lra_set_used_insn_alternative ( rtx_insn * insn,
int alt )
Set up that INSN is using alternative ALT now.   

References ggc_alloc(), and lra_get_insn_recog_data().

Referenced by curr_insn_transform(), process_insn_for_elimination(), spill_pseudos(), and spill_pseudos().

◆ lra_set_used_insn_alternative_by_uid()

void lra_set_used_insn_alternative_by_uid ( int uid,
int alt )
Set up that insn with UID is using alternative ALT now.  The insn
info should be already set up.   

References check_and_expand_insn_recog_data(), ggc_alloc(), lra_assert, and NULL.

Referenced by lra_assign(), and remove_inheritance_pseudos().

◆ lra_substitute_pseudo()

bool lra_substitute_pseudo ( rtx * loc,
int old_regno,
rtx new_reg,
bool subreg_p,
bool debug_p )
Replace all references to register OLD_REGNO in *LOC with pseudo
register NEW_REG.  Try to simplify subreg of constant if SUBREG_P.
DEBUG_P is if LOC is within a DEBUG_INSN.  Return true if any
change was made.   

References const0_rtx, CONST_SCALAR_INT_P, CONSTANT_P, gen_rtx_SUBREG(), GET_CODE, GET_MODE, GET_RTX_FORMAT, GET_RTX_LENGTH, ggc_alloc(), i, lra_substitute_pseudo(), NULL_RTX, offset, partial_subreg_p(), REG_P, REGNO, SCALAR_INT_MODE_P, simplify_subreg(), simplify_unary_operation(), SUBREG_BYTE, subreg_lowpart_offset(), lra_insn_reg::subreg_p, SUBREG_REG, subst(), XEXP, XVECEXP, XVECLEN, and y.

Referenced by inherit_reload_reg(), lra_substitute_pseudo(), lra_substitute_pseudo_within_insn(), and split_reg().

◆ lra_substitute_pseudo_within_insn()

bool lra_substitute_pseudo_within_insn ( rtx_insn * insn,
int old_regno,
rtx new_reg,
bool subreg_p )
Call lra_substitute_pseudo within an insn.  Try to simplify subreg
of constant if SUBREG_P.  This won't update the insn ptr, just the
contents of the insn.   

References DEBUG_INSN_P, ggc_alloc(), lra_substitute_pseudo(), and lra_insn_reg::subreg_p.

Referenced by inherit_reload_reg(), process_bb_lives(), remove_inheritance_pseudos(), and undo_optional_reloads().

◆ lra_update_dups()

void lra_update_dups ( lra_insn_recog_data_t id,
signed char * nops )
Update insn operands which are duplication of operands whose
numbers are in array of NOPS (with end marker -1).  The insn is
represented by its LRA internal representation ID.   

References ggc_alloc(), and i.

Referenced by combine_reload_insn(), and match_reload().

◆ lra_update_insn_recog_data()

◆ lra_update_insn_regno_info()

◆ new_insn_reg()

static struct lra_insn_reg * new_insn_reg ( rtx_insn * insn,
int regno,
enum op_type type,
machine_mode mode,
bool subreg_p,
alternative_mask early_clobber_alts,
struct lra_insn_reg * next )
static
Create LRA insn related info about a reference to REGNO in INSN
with TYPE (in/out/inout), biggest reference mode MODE, flag that it
is reference through subreg (SUBREG_P), and reference to the next
insn reg info (NEXT).  If REGNO can be early clobbered,
alternatives in which it can be early clobbered are given by
EARLY_CLOBBER_ALTS.   

References lra_insn_reg::early_clobber_alts, ggc_alloc(), lra_insn_reg_pool, lra_update_biggest_mode(), lra_insn_reg::next, NONDEBUG_INSN_P, lra_insn_reg::regno, lra_insn_reg::subreg_p, and type().

Referenced by add_regs_to_insn_regno_info(), and collect_non_operand_hard_regs().

◆ push_insns()

static void push_insns ( rtx_insn * from,
rtx_insn * to )
static
Push insns FROM to TO (excluding it) going in reverse order.    

References INSN_P, lra_push_insn(), NULL_RTX, and PREV_INSN().

Referenced by lra(), and lra_process_new_insns().

◆ remove_insn_scratches()

static void remove_insn_scratches ( rtx_insn * insn)
static
Remove all insn scratches in INSN.   

References df_insn_rescan(), get_scratch_reg(), ira_remove_insn_scratches(), and lra_dump_file.

Referenced by lra_emit_move(), and remove_scratches().

◆ remove_scratches()

static void remove_scratches ( void )
static
Remove all insn scratches in the current function.   

References cfun, FOR_BB_INSNS, FOR_EACH_BB_FN, INSN_P, and remove_insn_scratches().

Referenced by lra().

◆ setup_insn_reg_info()

static void setup_insn_reg_info ( lra_insn_recog_data_t data,
int freq )
static
Update common reg info from reg info of insn given by its DATA and
execution frequency FREQ.   

References lra_reg::freq, ggc_alloc(), i, lra_reg_info, lra_reg::nrefs, and NULL.

Referenced by lra_update_insn_regno_info().

◆ setup_operand_alternative()

static void setup_operand_alternative ( lra_insn_recog_data_t data,
const operand_alternative * op_alt )
static
Setup info about operands in alternatives of LRA DATA of insn.   

References ggc_alloc(), i, and lra_assert.

Referenced by lra_set_insn_recog_data().

◆ setup_reg_spill_flag()

static void setup_reg_spill_flag ( void )
static
Set up value LRA_REG_SPILL_P.   

References ggc_alloc(), lra_reg_spill_p, NULL, and targetm.

Referenced by lra().

◆ setup_sp_offset()

static poly_int64 setup_sp_offset ( rtx_insn * from,
rtx_insn * last )
static
Set up and return sp offset for insns in range [FROM, LAST].  The offset is
taken from the next BB insn after LAST or zero if there in such
insn.   

References ggc_alloc(), INSN_P, last, lra_get_insn_recog_data(), lra_update_sp_offset(), NEXT_INSN(), next_nonnote_nondebug_insn_bb(), NULL_RTX, offset, and PATTERN().

Referenced by lra_process_new_insns().

◆ update_inc_notes()

static void update_inc_notes ( void )
static
Remove all REG_DEAD and REG_UNUSED notes and regenerate REG_INC.
We change pseudos by hard registers without notification of DF and
that can make the notes obsolete.  DF-infrastructure does not deal
with REG_INC notes -- so we should regenerate them here.   

References add_auto_inc_notes(), AUTO_INC_DEC, cfun, FOR_BB_INSNS, FOR_EACH_BB_FN, ggc_alloc(), NONDEBUG_INSN_P, PATTERN(), REG_NOTE_KIND, REG_NOTES, and XEXP.

Referenced by lra().

Variable Documentation

◆ copy_vec

vec<lra_copy_t> copy_vec
static
Vec referring to pseudo copies.   

Referenced by init_reg_info(), lra_create_copy(), lra_free_copies(), and lra_get_copy().

◆ debug_bind_static_data

struct lra_static_insn_data debug_bind_static_data
static
Initial value:
=
{
0,
-1,
1,
0,
0,
NULL,
}
static struct lra_operand_data debug_operand_data
Definition lra.cc:628
#define NULL
Definition system.h:50
The following data are used as static insn data for all debug
bind insns.  If structure lra_static_insn_data is changed, the
initializer should be changed too.   

Referenced by lra_set_insn_recog_data().

◆ debug_marker_static_data

struct lra_static_insn_data debug_marker_static_data
static
Initial value:
=
{
0,
-1,
0,
0,
0,
NULL,
}
The following data are used as static insn data for all debug
marker insns.  If structure lra_static_insn_data is changed, the
initializer should be changed too.   

Referenced by lra_set_insn_recog_data().

◆ debug_operand_data

struct lra_operand_data debug_operand_data
static
Initial value:
=
{
NULL,
0,
0, 0, 0
}
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
@ OP_IN
Definition recog.h:40
Debug insns are represented as a special insn with one input
operand which is RTL expression in var_location.   
The following data are used as static insn operand data for all
debug insns.     If structure lra_operand_data is changed, the
initializer should be changed too.   

◆ hard_regs_spilled_into

◆ insn_code_data

This page contains code dealing LRA insn info (or in other words
LRA internal insn representation).   
Map INSN_CODE -> the static insn data.  This info is valid during
all translation unit.   

Referenced by finish_insn_code_data_once(), get_static_insn_data(), and init_insn_code_data_once().

◆ last_reg_value

int last_reg_value
static
Last register value.    

Referenced by get_new_reg_value(), and init_reg_info().

◆ lra_asm_error_p

bool lra_asm_error_p
True if we found an asm error.   

Referenced by curr_insn_transform(), lra(), lra_asm_insn_error(), and lra_assign().

◆ lra_bad_spill_regno_start

int lra_bad_spill_regno_start
Avoid spilling pseudos with regno more than the following value if
it is possible.   

Referenced by lra(), and spill_for().

◆ lra_constraint_insn_stack

vec<rtx_insn *> lra_constraint_insn_stack
The stack itself.   

Referenced by lra(), lra_insn_stack_length(), lra_pop_insn(), and lra_push_insn_1().

◆ lra_constraint_insn_stack_bitmap

sbitmap lra_constraint_insn_stack_bitmap
static
This page contains code dealing with stack of the insns which
should be processed by the next constraint pass.   
Bitmap used to put an insn on the stack only in one exemplar.   

Referenced by lra(), lra_pop_insn(), and lra_push_insn_1().

◆ lra_constraint_new_regno_start

◆ lra_copy_pool

object_allocator< lra_copy > lra_copy_pool("lra copies") ( "lra copies" )
static
Pools for copies.   

Referenced by finish_insn_recog_data(), lra_create_copy(), and lra_free_copies().

◆ lra_curr_reload_num

int lra_curr_reload_num
The number of emitted reload insns so far.   

Referenced by lra(), lra_constraints(), and lra_emit_move().

◆ lra_dump_file

◆ lra_hard_reg_split_p

bool lra_hard_reg_split_p
True if we split hard reg after the last constraint sub-pass.   

Referenced by lra(), and lra_assign().

◆ lra_in_progress

◆ lra_inheritance_pseudos

◆ lra_insn_recog_data

lra_insn_recog_data_t* lra_insn_recog_data
Map INSN_UID -> the insn recog data (NULL if unknown).   

◆ lra_insn_recog_data_len

int lra_insn_recog_data_len
The current length of the following array.   

Referenced by check_and_expand_insn_recog_data(), finish_insn_recog_data(), init_insn_recog_data(), and lra_get_insn_recog_data().

◆ lra_insn_recog_data_pool

object_allocator< class lra_insn_recog_data > lra_insn_recog_data_pool("insn recog data pool") ( "insn recog data pool" )
static
Alloc pool we allocate entries for lra_insn_recog_data from.   

Referenced by finish_insn_recog_data(), free_insn_recog_data(), and lra_set_insn_recog_data().

◆ lra_insn_reg_pool

object_allocator< lra_insn_reg > lra_insn_reg_pool("insn regs") ( "insn regs" )
This page contains code dealing with info about registers in the
insns.   
Pools for insn reg info.   

Referenced by finish_insn_recog_data(), finish_insn_regs(), free_insn_regs(), invalidate_insn_data_regno_info(), and new_insn_reg().

◆ lra_new_regno_start

int lra_new_regno_start
Start of pseudo regnos before the LRA.   

Referenced by find_hard_regno_for(), lra(), and match_reload().

◆ lra_no_alloc_regs

◆ lra_optional_reload_pseudos

bitmap_head lra_optional_reload_pseudos
Reload pseudo regnos before the new assignment pass which still can
be spilled after the assignment pass as memory is also accepted in
insns for the reload pseudos.   

Referenced by assign_by_spills(), combine_reload_insn(), curr_insn_transform(), find_all_spills_for(), lra(), lra_split_hard_reg_for(), must_not_spill_p(), pseudo_prefix_title(), and undo_optional_reloads().

◆ lra_pmode_pseudo

rtx lra_pmode_pseudo
A pseudo of Pmode.   

Referenced by eliminate_regs_in_insn(), and lra().

◆ lra_reg_info

class lra_reg* lra_reg_info
Common info about each register.   

Referenced by add_pseudo_to_slot(), add_regs_to_insn_regno_info(), assign_by_spills(), assign_hard_regno(), assign_mem_slot(), assign_spill_hard_regs(), assign_stack_slot_num_and_sort_pseudos(), assign_temporarily(), check_pseudos_live_through_calls(), create_live_range_start_chains(), curr_insn_transform(), expand_reg_info(), find_all_spills_for(), find_hard_regno_for_1(), find_reload_regno_insns(), finish_reg_info(), fix_bb_live_info(), improve_inheritance(), inherit_reload_reg(), init_live_reload_and_inheritance_pseudos(), init_reg_info(), init_regno_assign_info(), initialize_lra_reg_info_element(), insert_in_live_range_start_chain(), invalidate_insn_data_regno_info(), lra_assign(), lra_assign_reg_val(), lra_clear_live_ranges(), lra_coalesce(), lra_constraints(), lra_create_copy(), lra_create_live_ranges_1(), lra_create_new_reg_with_unique_value(), lra_eliminate(), lra_emit_move(), lra_final_code_change(), lra_free_copies(), lra_need_for_scratch_reg_p(), lra_need_for_spills_p(), lra_reg_val_equal_p(), lra_set_regno_unique_value(), lra_setup_reg_renumber(), lra_setup_reload_pseudo_preferenced_hard_reg(), lra_spill(), lra_split_hard_reg_for(), lra_undo_inheritance(), lra_update_biggest_mode(), lra_update_reg_val_offset(), make_hard_regno_dead(), mark_pseudo_dead(), merge_pseudos(), multi_block_pseudo_p(), need_for_split_p(), print_pseudo_live_ranges(), process_alt_operands(), process_bb_lives(), process_invariant_for_inheritance(), pseudo_compare_func(), pseudo_reg_slot_compare(), regno_freq_compare(), regno_val_use_in(), reload_pseudo_compare_func(), remove_inheritance_pseudos(), remove_pseudos(), remove_some_program_points_and_update_live_ranges(), setup_insn_reg_info(), setup_live_pseudos_and_spill_after_risky_transforms(), spill_for(), spill_hard_reg_in_range(), spill_pseudos(), spill_pseudos(), split_reg(), undo_optional_reloads(), update_hard_regno_preference(), update_lives(), update_pseudo_point(), and update_reg_eliminate().

◆ lra_reg_spill_p

bool lra_reg_spill_p
True if we should try spill into registers of different classes
instead of memory.   

Referenced by assign_spill_hard_regs(), lra(), setup_reg_spill_flag(), and spill_pseudos().

◆ lra_simple_p

bool lra_simple_p
True if the current function is too big to use regular algorithms
in LRA. In other words, we should use simpler and faster algorithms
in LRA.  It also means we should not worry about generation code
for caller saves.  The value is set up in IRA.   

Referenced by assign_by_spills(), curr_insn_transform(), ira(), and lra().

◆ lra_split_regs

◆ lra_subreg_reload_pseudos

bitmap_head lra_subreg_reload_pseudos
Pseudo regnos used for subreg reloads before the new assignment
pass.  Such pseudos still can be spilled after the assignment
pass.   

Referenced by assign_by_spills(), lra(), lra_split_hard_reg_for(), must_not_spill_p(), pseudo_prefix_title(), and simplify_operand_subreg().

◆ lra_verbose

int lra_verbose
How verbose should be the debug information.  

Referenced by lra(), and lra_dump_insns_if_possible().

◆ reg_info_size

int reg_info_size
static
This page contains code dealing with common register info and
pseudo copies.   
The size of the following array.   

Referenced by expand_reg_info(), finish_reg_info(), and init_reg_info().