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

Data Structures

struct  regno_assign_info
 

Functions

static void process_copy_to_form_thread (int regno1, int regno2, int copy_freq)
 
static void init_regno_assign_info (void)
 
static void finish_regno_assign_info (void)
 
static int reload_pseudo_compare_func (const void *v1p, const void *v2p)
 
static int pseudo_compare_func (const void *v1p, const void *v2p)
 
static void create_live_range_start_chains (void)
 
static void insert_in_live_range_start_chain (int regno)
 
static void finish_live_range_start_chains (void)
 
static void init_lives (void)
 
static void finish_lives (void)
 
static void update_lives (int regno, bool free_p)
 
static void init_live_reload_and_inheritance_pseudos (void)
 
static void finish_live_reload_and_inheritance_pseudos (void)
 
static void adjust_hard_regno_cost (int hard_regno, int incr)
 
static int find_hard_regno_for_1 (int regno, int *cost, int try_only_hard_regno, bool first_p, HARD_REG_SET regno_set)
 
static int find_hard_regno_for (int regno, int *cost, int try_only_hard_regno, bool first_p)
 
static void update_hard_regno_preference (int regno, int hard_regno, int div)
 
static const char * pseudo_prefix_title (int regno)
 
void lra_setup_reg_renumber (int regno, int hard_regno, bool print_p)
 
static void setup_try_hard_regno_pseudos (int p, enum reg_class rclass)
 
static void assign_temporarily (int regno, int hard_regno)
 
static bool must_not_spill_p (unsigned spill_regno)
 
static int spill_for (int regno, bitmap spilled_pseudo_bitmap, bool first_p)
 
static void assign_hard_regno (int hard_regno, int regno)
 
static void setup_live_pseudos_and_spill_after_risky_transforms (bitmap spilled_pseudo_bitmap)
 
static void improve_inheritance (bitmap changed_pseudos)
 
static void find_all_spills_for (int regno)
 
static bool assign_by_spills (void)
 
bool lra_assign (bool &fails_p)
 
static bool find_reload_regno_insns (int regno, rtx_insn *&start, rtx_insn *&finish)
 
bool lra_split_hard_reg_for (void)
 

Variables

int lra_assignment_iter
 
int lra_assignment_iter_after_spill
 
static bool former_reload_pseudo_spill_p
 
static enum reg_class * regno_allocno_class_array
 
static int * regno_live_length
 
static struct regno_assign_info * regno_assign_info
 
static bitmap_head non_reload_pseudos
 
static lra_live_range_tstart_point_ranges
 
static struct lra_live_range not_in_chain_mark
 
static bitmap_headlive_hard_reg_pseudos
 
static bitmap_obstack live_hard_reg_pseudos_bitmap_obstack
 
static int * live_pseudos_reg_renumber
 
static sparseset live_range_hard_reg_pseudos
 
static sparseset live_range_reload_inheritance_pseudos
 
static sparseset conflict_reload_and_inheritance_pseudos
 
static bitmap_headlive_reload_and_inheritance_pseudos
 
static bitmap_obstack live_reload_and_inheritance_pseudos_bitmap_obstack
 
static int curr_hard_regno_costs_check = 0
 
static int hard_regno_costs_check [FIRST_PSEUDO_REGISTER]
 
static int hard_regno_costs [FIRST_PSEUDO_REGISTER]
 
static int curr_update_hard_regno_preference_check
 
static int * update_hard_regno_preference_check
 
static bitmap_head insn_conflict_pseudos
 
static bitmap_head spill_pseudos_bitmap
 
static bitmap_head best_spill_pseudos_bitmap
 
static int curr_pseudo_check
 
static int try_hard_reg_pseudos_check [FIRST_PSEUDO_REGISTER]
 
static bitmap_head try_hard_reg_pseudos [FIRST_PSEUDO_REGISTER]
 
static int * sorted_reload_pseudos
 
static int * sorted_pseudos
 
static bitmap_head all_spilled_pseudos
 
static bitmap_head changed_pseudo_bitmap
 

Function Documentation

◆ adjust_hard_regno_cost()

static void adjust_hard_regno_cost ( int hard_regno,
int incr )
inlinestatic
Adjust cost of HARD_REGNO by INCR.  Reset the cost first if it is
not defined yet.   

References curr_hard_regno_costs_check, hard_regno_costs, and hard_regno_costs_check.

Referenced by find_hard_regno_for_1().

◆ assign_by_spills()

◆ assign_hard_regno()

static void assign_hard_regno ( int hard_regno,
int regno )
static

◆ assign_temporarily()

static void assign_temporarily ( int regno,
int hard_regno )
static
Assign temporarily HARD_REGNO to pseudo REGNO.  Temporary
assignment means that we might undo the data change.      

References bitmap_clear_bit(), bitmap_set_bit, lra_live_range::finish, insert_in_live_range_start_chain(), live_hard_reg_pseudos, live_pseudos_reg_renumber, lra_reg_info, NULL, r, and lra_live_range::regno.

Referenced by spill_for().

◆ create_live_range_start_chains()

static void create_live_range_start_chains ( void )
static

◆ find_all_spills_for()

static void find_all_spills_for ( int regno)
static

◆ find_hard_regno_for()

static int find_hard_regno_for ( int regno,
int * cost,
int try_only_hard_regno,
bool first_p )
static
A wrapper for find_hard_regno_for_1 (see comments for that function
description).  This function tries to find a hard register for
preferred class first if it is worth.   

References CLEAR_HARD_REG_SET, find_hard_regno_for_1(), lra_new_regno_start, reg_class_contents, reg_preferred_class(), lra_live_range::regno, and regno_allocno_class_array.

Referenced by assign_by_spills(), improve_inheritance(), and spill_for().

◆ find_hard_regno_for_1()

static int find_hard_regno_for_1 ( int regno,
int * cost,
int try_only_hard_regno,
bool first_p,
HARD_REG_SET regno_set )
static
Try to find a free hard register for pseudo REGNO.  Return the
hard register on success and set *COST to the cost of using
that register.  (If several registers have equal cost, the one with
the highest priority wins.)  Return -1 on failure.

If FIRST_P, return the first available hard reg ignoring other
criteria, e.g. allocation cost.  This approach results in less hard
reg pool fragmentation and permit to allocate hard regs to reload
pseudos in complicated situations where pseudo sizes are different.

If TRY_ONLY_HARD_REGNO >= 0, consider only that hard register,
otherwise consider all hard registers in REGNO's class.

If REGNO_SET is not empty, only hard registers from the set are
considered.   

References add_to_hard_reg_set(), adjust_hard_regno_cost(), lra_reg::biggest_mode, cfun, lra_reg::conflict_hard_regs, conflict_reload_and_inheritance_pseudos, crtl, curr_hard_regno_costs_check, df_regs_ever_live_p(), end_hard_regno(), ENTRY_BLOCK_PTR_FOR_FN, lra_reg::exclude_start_hard_regs, EXECUTE_IF_SET_IN_BITMAP, EXECUTE_IF_SET_IN_SPARSESET, lra_live_range::finish, lra_reg::freq, hard_reg_set_empty_p(), hard_reg_set_subset_p(), hard_regno_costs, hard_regno_costs_check, hard_regno_nregs(), i, INT_MAX, INT_MIN, ira_allocno_class_translate, ira_class_hard_regs, ira_class_hard_regs_num, ira_prohibited_class_mode_regs, ira_reg_classes_intersect_p, live_hard_reg_pseudos, live_pseudos_reg_renumber, live_range_hard_reg_pseudos, live_reload_and_inheritance_pseudos, lra_assert, lra_constraint_new_regno_start, lra_hard_reg_usage, lra_no_alloc_regs, lra_reg_info, lra_reg_val_equal_p(), NULL, lra_reg::offset, offset, overlaps_hard_reg_set_p(), lra_reg::preferred_hard_regno1, PSEUDO_REGNO_MODE, r, reg_class_contents, REG_FREQ_FROM_BB, lra_live_range::regno, regno_allocno_class_array, SET_HARD_REG_BIT, sparseset_clear(), sparseset_clear_bit(), sparseset_set_bit(), lra_live_range::start_next, start_point_ranges, targetm, TEST_HARD_REG_BIT, and lra_reg::val.

Referenced by find_hard_regno_for().

◆ find_reload_regno_insns()

static bool find_reload_regno_insns ( int regno,
rtx_insn *& start,
rtx_insn *& finish )
static
Find start and finish insns for reload pseudo REGNO.  Return true
if we managed to find the expected insns.  Return false,
otherwise.   

References bitmap_bit_p, EXECUTE_IF_SET_IN_BITMAP, GET_CODE, lra_insn_recog_data::insn, INSN_UID(), lra_reg_info, NEXT_INSN(), next_insn(), NULL, PATTERN(), PREV_INSN(), and lra_insn_reg::regno.

Referenced by lra_split_hard_reg_for().

◆ finish_live_range_start_chains()

static void finish_live_range_start_chains ( void )
static
Free START_POINT_RANGES.   

References free(), gcc_assert, NULL, and start_point_ranges.

Referenced by lra_assign().

◆ finish_live_reload_and_inheritance_pseudos()

static void finish_live_reload_and_inheritance_pseudos ( void )
static

◆ finish_lives()

static void finish_lives ( void )
static

◆ finish_regno_assign_info()

static void finish_regno_assign_info ( void )
static
Free REGNO_ASSIGN_INFO.   

References free().

Referenced by lra_assign().

◆ improve_inheritance()

static void improve_inheritance ( bitmap changed_pseudos)
static
Improve allocation by assigning the same hard regno of inheritance
pseudos to the connected pseudos.  We need this because inheritance
pseudos are allocated after reload pseudos in the thread and when
we assign a hard register to a reload pseudo we don't know yet that
the connected inheritance pseudos can get the same hard register.
Add pseudos with changed allocation to bitmap CHANGED_PSEUDOS.   

References assign_hard_regno(), bitmap_bit_p, bitmap_set_bit, changed_pseudos, EXECUTE_IF_SET_IN_BITMAP, find_hard_regno_for(), gcc_unreachable, i, lra_assert, lra_constraint_new_regno_start, lra_dump_file, lra_inheritance_iter, lra_inheritance_pseudos, LRA_MAX_INHERITANCE_PASSES, lra_reg_info, lra_setup_reg_renumber(), NULL, pseudo_compare_func(), qsort, reg_renumber, lra_insn_reg::regno, lra_copy::regno1, lra_copy::regno1_next, lra_copy::regno2, lra_copy::regno2_next, sorted_pseudos, and update_lives().

Referenced by assign_by_spills().

◆ init_live_reload_and_inheritance_pseudos()

static void init_live_reload_and_inheritance_pseudos ( void )
static

◆ init_lives()

◆ init_regno_assign_info()

◆ insert_in_live_range_start_chain()

static void insert_in_live_range_start_chain ( int regno)
static
Insert live ranges of pseudo REGNO into start chains if they are
not there yet.   

References lra_reg::live_ranges, lra_reg_info, not_in_chain_mark, NULL, r, lra_live_range::regno, and start_point_ranges.

Referenced by assign_temporarily(), and update_lives().

◆ lra_assign()

bool lra_assign ( bool & fails_p)
Entry function to assign hard registers to new reload pseudos
starting with LRA_CONSTRAINT_NEW_REGNO_START (by possible spilling
of old pseudos) and possibly to the old pseudos.  The function adds
what insns to process for the next constraint pass.     Those are all
insns who contains non-reload and non-inheritance pseudos with
changed allocation.

Return true if we did not spill any non-reload and non-inheritance
pseudos.  Set up FAILS_P if we failed to assign hard registers to
all reload pseudos.   

References all_spilled_pseudos, assign_by_spills(), bitmap_clear(), bitmap_initialize(), bitmap_ior_into(), changed_pseudo_bitmap, check_and_force_assignment_correctness_p, create_live_range_start_chains(), EXECUTE_IF_SET_IN_BITMAP, finish_live_range_start_chains(), finish_live_reload_and_inheritance_pseudos(), finish_lives(), finish_regno_assign_info(), former_reload_pseudo_spill_p, free(), gcc_unreachable, i, init_live_reload_and_inheritance_pseudos(), init_lives(), init_regno_assign_info(), internal_error(), lra_asm_error_p, lra_assignment_iter, lra_assignment_iter_after_spill, lra_dump_file, lra_get_allocno_class(), lra_hard_reg_split_p, LRA_MAX_ASSIGNMENT_ITERATION_NUMBER, lra_push_insn_by_uid(), lra_reg_info, lra_set_used_insn_alternative_by_uid(), max_reg_num(), max_regno, NULL, NULL_RTX, overlaps_hard_reg_set_p(), PSEUDO_REGNO_MODE, r, reg_obstack, reg_renumber, regno_allocno_class_array, regno_live_length, setup_live_pseudos_and_spill_after_risky_transforms(), sorted_pseudos, sorted_reload_pseudos, timevar_pop(), and timevar_push().

Referenced by lra().

◆ lra_setup_reg_renumber()

void lra_setup_reg_renumber ( int regno,
int hard_regno,
bool print_p )

◆ lra_split_hard_reg_for()

◆ must_not_spill_p()

static bool must_not_spill_p ( unsigned spill_regno)
static

◆ process_copy_to_form_thread()

static void process_copy_to_form_thread ( int regno1,
int regno2,
int copy_freq )
static
Process a pseudo copy with execution frequency COPY_FREQ connecting
REGNO1 and REGNO2 to form threads.   

References regno_assign_info::first, regno_assign_info::freq, last, lra_assert, lra_constraint_new_regno_start, and regno_assign_info::next.

Referenced by init_regno_assign_info().

◆ pseudo_compare_func()

static int pseudo_compare_func ( const void * v1p,
const void * v2p )
static
The function is used to sort *non-reload* pseudos to try to assign
them hard registers.     The order calculation is simpler than in the
previous function and based on the pseudo frequency usage.   

References regno_assign_info::freq, lra_reg_info, and non_spilled_static_chain_regno_p().

Referenced by assign_by_spills(), improve_inheritance(), and setup_live_pseudos_and_spill_after_risky_transforms().

◆ pseudo_prefix_title()

static const char * pseudo_prefix_title ( int regno)
static

◆ reload_pseudo_compare_func()

static int reload_pseudo_compare_func ( const void * v1p,
const void * v2p )
static
The function is used to sort *reload* and *inheritance* pseudos to
try to assign them hard registers.  We put pseudos from the same
thread always nearby.   

References regno_assign_info::first, regno_assign_info::freq, ira_class_hard_regs_num, ira_reg_class_max_nregs, lra_assert, lra_constraint_new_regno_start, lra_reg_info, regno_allocno_class_array, and regno_live_length.

Referenced by assign_by_spills(), and spill_for().

◆ setup_live_pseudos_and_spill_after_risky_transforms()

static void setup_live_pseudos_and_spill_after_risky_transforms ( bitmap spilled_pseudo_bitmap)
static
The constraints pass is allowed to create equivalences between
pseudos that make the current allocation "incorrect" (in the sense
that pseudos are assigned to hard registers from their own conflict
sets).  The global variable check_and_force_assignment_correctness_p says
whether this might have happened.

Process pseudos assigned to hard registers (less frequently used
first), spill if a conflict is found, and mark the spilled pseudos
in SPILLED_PSEUDO_BITMAP.  Set up LIVE_HARD_REG_PSEUDOS from
pseudos, assigned to hard registers.      

References add_to_hard_reg_set(), lra_insn_reg::biggest_mode, lra_reg::biggest_mode, bitmap_set_bit, check_and_force_assignment_correctness_p, lra_reg::conflict_hard_regs, EXECUTE_IF_SET_IN_BITMAP, EXECUTE_IF_SET_IN_SPARSESET, former_reload_pseudo_spill_p, hard_regno_nregs(), i, live_hard_reg_pseudos, live_pseudos_reg_renumber, live_range_hard_reg_pseudos, lra_assert, lra_constraint_new_regno_start, lra_dump_file, lra_get_allocno_class(), lra_hard_reg_usage, lra_no_alloc_regs, lra_reg_info, lra_reg_val_equal_p(), max_reg_num(), max_regno, NULL, NULL_RTX, lra_reg::offset, offset, overlaps_hard_reg_set_p(), pic_offset_table_rtx, pseudo_compare_func(), PSEUDO_REGNO_MODE, qsort, r, reg_class_contents, reg_renumber, REGNO, lra_insn_reg::regno, lra_live_range::regno, sorted_pseudos, sparseset_clear(), sparseset_set_bit(), lra_live_range::start_next, start_point_ranges, TEST_HARD_REG_BIT, update_lives(), and lra_reg::val.

Referenced by lra_assign().

◆ setup_try_hard_regno_pseudos()

static void setup_try_hard_regno_pseudos ( int p,
enum reg_class rclass )
static
Set up try_hard_reg_pseudos for given program point P and class
RCLASS.  Those are pseudos living at P and assigned to a hard
register of RCLASS.     In other words, those are pseudos which can be
spilled to assign a hard register of RCLASS to a pseudo living at
P.   

References bitmap_clear(), bitmap_set_bit, curr_pseudo_check, EXECUTE_IF_SET_IN_BITMAP, hard_regno_nregs(), i, live_hard_reg_pseudos, live_pseudos_reg_renumber, overlaps_hard_reg_set_p(), PSEUDO_REGNO_MODE, reg_class_contents, try_hard_reg_pseudos, and try_hard_reg_pseudos_check.

Referenced by spill_for().

◆ spill_for()

static int spill_for ( int regno,
bitmap spilled_pseudo_bitmap,
bool first_p )
static
Spill some pseudos for a reload pseudo REGNO and return hard
register which should be used for pseudo after spilling.  The
function adds spilled pseudos to SPILLED_PSEUDO_BITMAP.  When we
choose hard register (and pseudos occupying the hard registers and
to be spilled), we take into account not only how REGNO will
benefit from the spills but also how other reload pseudos not yet
assigned to hard registers benefit from the spills too.  In very
rare cases, the function can fail and return -1.

If FIRST_P, return the first available hard reg ignoring other
criteria, e.g. allocation cost and cost of spilling non-reload
pseudos.  This approach results in less hard reg pool fragmentation
and permit to allocate hard regs to reload pseudos in complicated
situations where pseudo sizes are different.   

References assign_temporarily(), best_spill_pseudos_bitmap, bitmap_bit_p, bitmap_clear(), bitmap_copy(), bitmap_empty_p(), bitmap_ior_into(), bitmap_set_bit, BLOCK_FOR_INSN(), curr_pseudo_check, EXECUTE_IF_SET_IN_BITMAP, EXECUTE_IF_SET_IN_SPARSESET, find_hard_regno_for(), former_reload_pseudo_spill_p, lra_reg::freq, hard_regno_nregs(), i, rtx_insn_list::insn(), insn_conflict_pseudos, INT_MAX, ira_class_hard_regs, ira_class_hard_regs_num, ira_reg_classes_intersect_p, ira_reg_equiv, live_pseudos_reg_renumber, live_range_reload_inheritance_pseudos, lra_assert, lra_bad_spill_regno_start, lra_constraint_new_regno_start, lra_dump_file, lra_get_insn_regs(), lra_reg_info, lra_setup_reg_renumber(), must_not_spill_p(), lra_insn_reg::next, rtx_insn_list::next(), non_spilled_static_chain_regno_p(), NULL, pseudo_prefix_title(), PSEUDO_REGNO_MODE, qsort, r, REG_FREQ_FROM_BB, reg_renumber, lra_insn_reg::regno, lra_live_range::regno, regno_allocno_class_array, reload_pseudo_compare_func(), setup_try_hard_regno_pseudos(), sorted_reload_pseudos, sparseset_cardinality(), sparseset_clear(), sparseset_set_bit(), spill_pseudos_bitmap, lra_live_range::start_next, start_point_ranges, static_p, try_hard_reg_pseudos, try_hard_reg_pseudos_check, and update_lives().

Referenced by assign_by_spills().

◆ update_hard_regno_preference()

static void update_hard_regno_preference ( int regno,
int hard_regno,
int div )
static
Update the preference for using HARD_REGNO for pseudos that are
connected directly or indirectly with REGNO.  Apply divisor DIV
to any preference adjustments.

The more indirectly a pseudo is connected, the smaller its effect
should be.  We therefore increase DIV on each "hop".   

References curr_update_hard_regno_preference_check, lra_copy::freq, gcc_unreachable, lra_reg_info, lra_setup_reload_pseudo_preferenced_hard_reg(), NULL, reg_renumber, lra_live_range::regno, lra_copy::regno1, lra_copy::regno1_next, lra_copy::regno2, lra_copy::regno2_next, update_hard_regno_preference(), and update_hard_regno_preference_check.

Referenced by lra_setup_reg_renumber(), and update_hard_regno_preference().

◆ update_lives()

static void update_lives ( int regno,
bool free_p )
static
Update the LIVE_HARD_REG_PSEUDOS and LIVE_PSEUDOS_REG_RENUMBER
entries for pseudo REGNO.  Assume that the register has been
spilled if FREE_P, otherwise assume that it has been assigned
reg_renumber[REGNO] (if >= 0).  We also insert the pseudo live
ranges in the start chains when it is assumed to be assigned to a
hard register because we use the chains of pseudos assigned to hard
registers during allocation.   

References bitmap_clear_bit(), bitmap_set_bit, lra_live_range::finish, insert_in_live_range_start_chain(), live_hard_reg_pseudos, live_pseudos_reg_renumber, lra_reg_info, NULL, r, reg_renumber, and lra_live_range::regno.

Referenced by assign_by_spills(), assign_hard_regno(), improve_inheritance(), setup_live_pseudos_and_spill_after_risky_transforms(), and spill_for().

Variable Documentation

◆ all_spilled_pseudos

bitmap_head all_spilled_pseudos
static
Bitmap finally containing all pseudos spilled on this assignment
pass.   

Referenced by assign_by_spills(), and lra_assign().

◆ best_spill_pseudos_bitmap

bitmap_head best_spill_pseudos_bitmap
static

Referenced by assign_by_spills(), and spill_for().

◆ changed_pseudo_bitmap

bitmap_head changed_pseudo_bitmap
static
All pseudos whose allocation was changed.   

Referenced by assign_by_spills(), and lra_assign().

◆ conflict_reload_and_inheritance_pseudos

sparseset conflict_reload_and_inheritance_pseudos
static
Sparseset used to calculate reload pseudos conflicting with a given
pseudo when we are trying to find a hard register for the given
pseudo.   

Referenced by find_hard_regno_for_1(), finish_live_reload_and_inheritance_pseudos(), and init_live_reload_and_inheritance_pseudos().

◆ curr_hard_regno_costs_check

int curr_hard_regno_costs_check = 0
static
The value used to check that cost of given hard reg is really
defined currently.   

Referenced by adjust_hard_regno_cost(), and find_hard_regno_for_1().

◆ curr_pseudo_check

int curr_pseudo_check
static
Current pseudo check for validity of elements in
TRY_HARD_REG_PSEUDOS.   

Referenced by assign_by_spills(), setup_try_hard_regno_pseudos(), and spill_for().

◆ curr_update_hard_regno_preference_check

int curr_update_hard_regno_preference_check
static
Current value used for checking elements in
update_hard_regno_preference_check.      

Referenced by assign_by_spills(), lra_setup_reg_renumber(), and update_hard_regno_preference().

◆ former_reload_pseudo_spill_p

bool former_reload_pseudo_spill_p
static
Flag of spilling former reload pseudos on this pass.   

Referenced by assign_by_spills(), lra_assign(), setup_live_pseudos_and_spill_after_risky_transforms(), and spill_for().

◆ hard_regno_costs

int hard_regno_costs[FIRST_PSEUDO_REGISTER]
static
The current costs of allocation of hard regs.  Defined only if the
value of the corresponding element of the previous array is equal to
CURR_HARD_REGNO_COSTS_CHECK.      

Referenced by adjust_hard_regno_cost(), and find_hard_regno_for_1().

◆ hard_regno_costs_check

int hard_regno_costs_check[FIRST_PSEUDO_REGISTER]
static
Array used to check that cost of the corresponding hard reg (the
array element index) is really defined currently.   

Referenced by adjust_hard_regno_cost(), and find_hard_regno_for_1().

◆ insn_conflict_pseudos

bitmap_head insn_conflict_pseudos
static
Pseudos which occur in insns containing a particular pseudo.   

Referenced by assign_by_spills(), and spill_for().

◆ live_hard_reg_pseudos

bitmap_head* live_hard_reg_pseudos
static
Map: program point -> bitmap of all pseudos living at the point and
assigned to hard registers.      

Referenced by assign_temporarily(), find_all_spills_for(), find_hard_regno_for_1(), finish_lives(), init_lives(), setup_live_pseudos_and_spill_after_risky_transforms(), setup_try_hard_regno_pseudos(), and update_lives().

◆ live_hard_reg_pseudos_bitmap_obstack

bitmap_obstack live_hard_reg_pseudos_bitmap_obstack
static

Referenced by finish_lives(), and init_lives().

◆ live_pseudos_reg_renumber

int* live_pseudos_reg_renumber
static
reg_renumber corresponding to pseudos marked in
live_hard_reg_pseudos.  reg_renumber might be not matched to
live_hard_reg_pseudos but live_pseudos_reg_renumber always reflects
live_hard_reg_pseudos.   

Referenced by assign_temporarily(), find_all_spills_for(), find_hard_regno_for_1(), finish_lives(), init_lives(), setup_live_pseudos_and_spill_after_risky_transforms(), setup_try_hard_regno_pseudos(), spill_for(), and update_lives().

◆ live_range_hard_reg_pseudos

sparseset live_range_hard_reg_pseudos
static
Sparseset used to calculate living hard reg pseudos for some program
point range.      

Referenced by assign_by_spills(), find_all_spills_for(), find_hard_regno_for_1(), finish_lives(), init_lives(), and setup_live_pseudos_and_spill_after_risky_transforms().

◆ live_range_reload_inheritance_pseudos

sparseset live_range_reload_inheritance_pseudos
static
Sparseset used to calculate living reload/inheritance pseudos for
some program point range.   

Referenced by finish_lives(), init_lives(), and spill_for().

◆ live_reload_and_inheritance_pseudos

bitmap_head* live_reload_and_inheritance_pseudos
static
Map: program point -> bitmap of all reload and inheritance pseudos
living at the point.      

Referenced by find_hard_regno_for_1(), finish_live_reload_and_inheritance_pseudos(), and init_live_reload_and_inheritance_pseudos().

◆ live_reload_and_inheritance_pseudos_bitmap_obstack

bitmap_obstack live_reload_and_inheritance_pseudos_bitmap_obstack
static

◆ lra_assignment_iter

int lra_assignment_iter
Assign reload pseudos.
   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/>.   
This file's main objective is to assign hard registers to reload
pseudos.  It also tries to allocate hard registers to other
pseudos, but at a lower priority than the reload pseudos.  The pass
does not transform the RTL.

We must allocate a hard register to every reload pseudo.  We try to
increase the chances of finding a viable allocation by assigning
the pseudos in order of fewest available hard registers first.  If
we still fail to find a hard register, we spill other (non-reload)
pseudos in order to make room.

find_hard_regno_for finds hard registers for allocation without
spilling.  spill_for does the same with spilling.  Both functions
use a cost model to determine the most profitable choice of hard
and spill registers.

Once we have finished allocating reload pseudos, we also try to
assign registers to other (non-reload) pseudos.  This is useful if
hard registers were freed up by the spilling just described.

We try to assign hard registers by collecting pseudos into threads.
These threads contain reload and inheritance pseudos that are
connected by copies (move insns).  Doing this improves the chances
of pseudos in the thread getting the same hard register and, as a
result, of allowing some move insns to be deleted.

When we assign a hard register to a pseudo, we decrease the cost of
using the same hard register for pseudos that are connected by
copies.

If two hard registers have the same frequency-derived cost, we
prefer hard registers with higher priorities.  The mapping of
registers to priorities is controlled by the register_priority
target hook.  For example, x86-64 has a few register priorities:
hard registers with and without REX prefixes have different
priorities.  This permits us to generate smaller code as insns
without REX prefixes are shorter.

If a few hard registers are still equally good for the assignment,
we choose the least used hard register.  It is called leveling and
may be profitable for some targets.

Only insns with changed allocation pseudos are processed on the
next constraint pass.

The pseudo live-ranges are used to find conflicting pseudos.

For understanding the code, it is important to keep in mind that
inheritance, split, and reload pseudos created since last
constraint pass have regno >= lra_constraint_new_regno_start.
Inheritance and split pseudos created on any pass are in the
corresponding bitmaps.  Inheritance and split pseudos since the
last constraint pass have also the corresponding non-negative
restore_regno.   
Current iteration number of the pass and current iteration number
of the pass after the latest spill pass when any former reload
pseudo was spilled.   

Referenced by lra(), lra_assign(), and lra_split_hard_reg_for().

◆ lra_assignment_iter_after_spill

int lra_assignment_iter_after_spill

Referenced by lra(), and lra_assign().

◆ non_reload_pseudos

bitmap_head non_reload_pseudos
static
All inherited, subreg or optional pseudos created before last spill
sub-pass.  Such pseudos are permitted to get memory instead of hard
regs.   

Referenced by assign_by_spills(), lra_split_hard_reg_for(), and must_not_spill_p().

◆ not_in_chain_mark

struct lra_live_range not_in_chain_mark
static
Used as a flag that a live range is not inserted in the start point
chain.   

Referenced by create_live_range_start_chains(), and insert_in_live_range_start_chain().

◆ regno_allocno_class_array

enum reg_class* regno_allocno_class_array
static
Array containing corresponding values of function
lra_get_allocno_class.  It is used to speed up the code.   

Referenced by assign_by_spills(), find_all_spills_for(), find_hard_regno_for(), find_hard_regno_for_1(), init_regno_assign_info(), lra_assign(), reload_pseudo_compare_func(), and spill_for().

◆ regno_assign_info

struct regno_assign_info* regno_assign_info
static
Map regno to the corresponding regno assignment info.   

◆ regno_live_length

int* regno_live_length
static
Array containing lengths of pseudo live ranges.  It is used to
speed up the code.   

Referenced by lra_assign(), and reload_pseudo_compare_func().

◆ sorted_pseudos

int* sorted_pseudos
static

◆ sorted_reload_pseudos

int* sorted_reload_pseudos
static
Array used for sorting reload pseudos for subsequent allocation
after spilling some pseudo.      

Referenced by lra_assign(), and spill_for().

◆ spill_pseudos_bitmap

bitmap_head spill_pseudos_bitmap
static
Bitmaps used to contain spill pseudos for given pseudo hard regno
and best spill pseudos for given pseudo (and best hard regno).   

Referenced by assign_by_spills(), and spill_for().

◆ start_point_ranges

lra_live_range_t* start_point_ranges
static
Arrays of size LRA_LIVE_MAX_POINT mapping a program point to the
pseudo live ranges with given start point.  We insert only live
ranges of pseudos interesting for assignment purposes.  They are
reload pseudos and pseudos assigned to hard registers.   

Referenced by create_live_range_start_chains(), find_all_spills_for(), find_hard_regno_for_1(), finish_live_range_start_chains(), insert_in_live_range_start_chain(), setup_live_pseudos_and_spill_after_risky_transforms(), and spill_for().

◆ try_hard_reg_pseudos

bitmap_head try_hard_reg_pseudos[FIRST_PSEUDO_REGISTER]
static
Pseudos who hold given hard register at the considered points.   

Referenced by assign_by_spills(), setup_try_hard_regno_pseudos(), and spill_for().

◆ try_hard_reg_pseudos_check

int try_hard_reg_pseudos_check[FIRST_PSEUDO_REGISTER]
static
Array used for validity of elements in TRY_HARD_REG_PSEUDOS.    

Referenced by assign_by_spills(), setup_try_hard_regno_pseudos(), and spill_for().

◆ update_hard_regno_preference_check

int* update_hard_regno_preference_check
static
If an element value is equal to the above variable value, then the
corresponding regno has been processed for preference
propagation.      

Referenced by assign_by_spills(), and update_hard_regno_preference().