GCC Middle and Back End API Reference
reginfo.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 "df.h"
#include "memmodel.h"
#include "tm_p.h"
#include "insn-config.h"
#include "regs.h"
#include "ira.h"
#include "recog.h"
#include "diagnostic-core.h"
#include "reload.h"
#include "output.h"
#include "tree-pass.h"
#include "function-abi.h"
Include dependency graph for reginfo.cc:

Data Structures

class  simplifiable_subreg
 
struct  reg_pref
 

Macros

#define call_used_regs    (this_target_hard_regs->x_call_used_regs)
 
#define regs_invalidated_by_call    (this_target_hard_regs->x_regs_invalidated_by_call)
 
#define N_REG_INTS    ((FIRST_PSEUDO_REGISTER + (32 - 1)) / 32)
 

Functions

static void clear_global_regs_cache (void)
 
void reginfo_cc_finalize (void)
 
void init_reg_class_start_regs ()
 
void reg_set_to_hard_reg_set (HARD_REG_SET *to, const_bitmap from)
 
void init_reg_sets (void)
 
void save_register_info (void)
 
static void restore_register_info (void)
 
static void init_reg_sets_1 (void)
 
void init_reg_modes_target (void)
 
void init_regs (void)
 
void reinit_regs (void)
 
void init_fake_stack_mems (void)
 
int register_move_cost (machine_mode mode, reg_class_t from, reg_class_t to)
 
int memory_move_cost (machine_mode mode, reg_class_t rclass, bool in)
 
int memory_move_secondary_cost (machine_mode mode, reg_class_t rclass, bool in)
 
machine_mode choose_hard_reg_mode (unsigned int regno, unsigned int nregs, const predefined_function_abi *abi)
 
void fix_register (const char *name, int fixed, int call_used)
 
void globalize_reg (tree decl, int i)
 
enum reg_class reg_preferred_class (int regno)
 
enum reg_class reg_alternate_class (int regno)
 
enum reg_class reg_allocno_class (int regno)
 
static void allocate_reg_info (void)
 
bool resize_reg_info (void)
 
void free_reg_info (void)
 
static unsigned int reginfo_init (void)
 
rtl_opt_passmake_pass_reginfo_init (gcc::context *ctxt)
 
void setup_reg_classes (int regno, enum reg_class prefclass, enum reg_class altclass, enum reg_class allocnoclass)
 
static void reg_scan_mark_refs (rtx, rtx_insn *)
 
void reg_scan (rtx_insn *f, unsigned int nregs)
 
bool reg_class_subset_p (reg_class_t c1, reg_class_t c2)
 
bool reg_classes_intersect_p (reg_class_t c1, reg_class_t c2)
 
const HARD_REG_SETsimplifiable_subregs (const subreg_shape &shape)
 
static void record_subregs_of_mode (rtx subreg, bool partial_def)
 
static void find_subregs_of_mode (rtx x)
 
void init_subregs_of_mode (void)
 
const HARD_REG_SETvalid_mode_changes_for_regno (unsigned int regno)
 
void finish_subregs_of_mode (void)
 

Variables

int max_regno
 
struct target_hard_regs default_target_hard_regs
 
struct target_regs default_target_regs
 
static const char initial_fixed_regs [] = FIXED_REGISTERS
 
static const char initial_call_used_regs [] = CALL_USED_REGISTERS
 
char global_regs [FIRST_PSEUDO_REGISTER]
 
HARD_REG_SET global_reg_set
 
tree global_regs_decl [FIRST_PSEUDO_REGISTER]
 
static const unsigned int_reg_class_contents [N_REG_CLASSES][N_REG_INTS] = REG_CLASS_CONTENTS
 
static const char *const initial_reg_names [] = REGISTER_NAMES
 
const char * reg_class_names [] = REG_CLASS_NAMES
 
static int no_global_reg_vars = 0
 
static char saved_fixed_regs [FIRST_PSEUDO_REGISTER]
 
static char saved_call_used_regs [FIRST_PSEUDO_REGISTER]
 
static const char * saved_reg_names [FIRST_PSEUDO_REGISTER]
 
static HARD_REG_SET saved_accessible_reg_set
 
static HARD_REG_SET saved_operand_reg_set
 
static struct reg_pref * reg_pref
 
static int reg_info_size
 
static int max_regno_since_last_resize
 
static HARD_REG_SET ** valid_mode_changes
 
static obstack valid_mode_changes_obstack
 

Macro Definition Documentation

◆ call_used_regs

◆ N_REG_INTS

#define N_REG_INTS    ((FIRST_PSEUDO_REGISTER + (32 - 1)) / 32)
Used to initialize reg_alloc_order.   
The same information, but as an array of unsigned ints.  We copy from
these unsigned ints to the table above.  We do this so the tm.h files
do not have to be aware of the wordsize for machines with <= 64 regs.
Note that we hard-code 32 here, not HOST_BITS_PER_INT.   

◆ regs_invalidated_by_call

#define regs_invalidated_by_call    (this_target_hard_regs->x_regs_invalidated_by_call)

Referenced by globalize_reg(), and init_reg_sets_1().

Function Documentation

◆ allocate_reg_info()

static void allocate_reg_info ( void )
static

◆ choose_hard_reg_mode()

machine_mode choose_hard_reg_mode ( unsigned int regno,
unsigned int nregs,
const predefined_function_abi * abi )
Return a machine mode that is legitimate for hard reg REGNO and large
enough to save nregs.  If we can't find one, return VOIDmode.
If ABI is nonnull, only consider modes that are preserved across
calls that use ABI.   

References predefined_function_abi::clobbers_reg_p(), FOR_EACH_MODE_IN_CLASS, GET_MODE_SIZE(), hard_regno_nregs(), maybe_gt, and targetm.

Referenced by default_dwarf_frame_reg_mode(), init_reg_modes_target(), and zcur_select_mode_rtx().

◆ clear_global_regs_cache()

static void clear_global_regs_cache ( void )
static

References global_regs, global_regs_decl, i, and NULL.

Referenced by reginfo_cc_finalize().

◆ find_subregs_of_mode()

static void find_subregs_of_mode ( rtx x)
static
Call record_subregs_of_mode for all the subregs in X.   

References find_subregs_of_mode(), GET_CODE, GET_RTX_FORMAT, GET_RTX_LENGTH, i, record_subregs_of_mode(), XEXP, XVECEXP, and XVECLEN.

Referenced by find_subregs_of_mode(), and init_subregs_of_mode().

◆ finish_subregs_of_mode()

void finish_subregs_of_mode ( void )

◆ fix_register()

void fix_register ( const char * name,
int fixed,
int call_used )
Specify the usage characteristics of the register named NAME.
It should be a fixed register if FIXED and a
call-used register if CALL_USED.   

References call_used_regs, decode_reg_name_and_count(), error(), fixed_regs, gcc_assert, gcc_unreachable, HARD_FRAME_POINTER_REGNUM, i, and warning().

Referenced by handle_common_deferred_options().

◆ free_reg_info()

void free_reg_info ( void )
Free up the space allocated by allocate_reg_info.   

References free(), NULL, and reg_renumber.

Referenced by move_loop_invariants(), one_code_hoisting_pass(), and rest_of_handle_final().

◆ globalize_reg()

◆ init_fake_stack_mems()

void init_fake_stack_mems ( void )
Initialize some fake stack-frame MEM references for use in
memory_move_secondary_cost.   

References gen_rtx_MEM(), i, stack_pointer_rtx, and top_of_stack.

Referenced by backend_init_target().

◆ init_reg_class_start_regs()

void init_reg_class_start_regs ( )
extern
In insn-preds.cc.   

Referenced by init_reg_sets().

◆ init_reg_modes_target()

void init_reg_modes_target ( void )
Compute the table of register modes.
  These values are used to record death information for individual registers
  (as opposed to a multi-register mode).
  This function might be invoked more than once, if the target has support
  for changing register usage conventions on a per-function basis.

References choose_hard_reg_mode(), hard_regno_nregs(), i, NULL, reg_raw_mode, targetm, this_target_regs, and word_mode.

Referenced by init_emit_regs().

◆ init_reg_sets()

void init_reg_sets ( void )
Function called only once per target_globals to initialize the
target_hard_regs structure.  Once this is done, various switches
may override.   

References accessible_reg_set, call_used_regs, CLEAR_HARD_REG_SET, fixed_regs, gcc_assert, i, init_reg_class_start_regs(), initial_call_used_regs, initial_fixed_regs, initial_reg_names, int_reg_class_contents, operand_reg_set, reg_alloc_order, reg_class_contents, reg_names, SET_HARD_REG_BIT, and SET_HARD_REG_SET.

Referenced by general_init().

◆ init_reg_sets_1()

◆ init_regs()

void init_regs ( void )
Finish initializing the register sets and initialize the register modes.
  This function might be invoked more than once, if the target has support
  for changing register usage conventions on a per-function basis.

References init_reg_sets_1().

Referenced by add_removable_extension(), backend_init(), reinit_regs(), and target_reinit().

◆ init_subregs_of_mode()

◆ make_pass_reginfo_init()

rtl_opt_pass * make_pass_reginfo_init ( gcc::context * ctxt)

◆ memory_move_cost()

int memory_move_cost ( machine_mode mode,
reg_class_t rclass,
bool in )
Compute cost of moving registers to/from memory.   

References targetm.

Referenced by choose_reload_regs(), reload_cse_simplify_set(), and setup_class_subset_and_memory_move_costs().

◆ memory_move_secondary_cost()

int memory_move_secondary_cost ( machine_mode mode,
reg_class_t rclass,
bool in )
Compute extra cost of moving registers to/from memory due to reloads.
Only needed if secondary reloads are required for memory moves.   

References memory_move_secondary_cost(), register_move_cost(), secondary_reload_class(), and top_of_stack.

Referenced by default_memory_move_cost(), and memory_move_secondary_cost().

◆ record_subregs_of_mode()

static void record_subregs_of_mode ( rtx subreg,
bool partial_def )
static
Restrict the choice of register for SUBREG_REG (SUBREG) based
on information about SUBREG.

If PARTIAL_DEF, SUBREG is a partial definition of a multipart inner
register and we want to ensure that the other parts of the inner
register are correctly preserved.  If !PARTIAL_DEF we need to
ensure that SUBREG itself can be formed.   

References gcc_checking_assert, GET_MODE_SIZE(), subreg_shape::inner_mode, known_ge, known_lt, subreg_shape::offset, subreg_shape::outer_mode, REG_P, REGMODE_NATURAL_SIZE, REGNO, shape_of_subreg(), simplifiable_subregs(), SUBREG_REG, valid_mode_changes, and valid_mode_changes_obstack.

Referenced by find_subregs_of_mode(), and init_subregs_of_mode().

◆ reg_allocno_class()

◆ reg_alternate_class()

◆ reg_class_subset_p()

bool reg_class_subset_p ( reg_class_t c1,
reg_class_t c2 )
Return true if C1 is a subset of C2, i.e., if every register in C1
is also in C2.   

References hard_reg_set_subset_p(), and reg_class_contents.

Referenced by combine_reloads(), default_secondary_reload(), find_reloads(), find_reusable_reload(), push_reload(), push_secondary_reload(), and setup_reg_class_relations().

◆ reg_classes_intersect_p()

bool reg_classes_intersect_p ( reg_class_t c1,
reg_class_t c2 )

◆ reg_preferred_class()

enum reg_class reg_preferred_class ( int regno)
Return the reg_class in which pseudo reg number REGNO is best allocated.
This function is sometimes called before the info has been computed.
When that happens, just return GENERAL_REGS, which is innocuous.   

References gcc_assert, reg_pref::prefclass, and reg_info_size.

Referenced by dump_reg_info(), find_costs_and_classes(), find_hard_regno_for(), find_reloads(), ira(), ira_bad_reload_regno_1(), ira_get_dup_out_num(), move_invariants(), must_not_spill_p(), setup_preferred_alternate_classes_for_new_pseudos(), update_conflict_hard_reg_costs(), and update_equiv_regs().

◆ reg_scan()

void reg_scan ( rtx_insn * f,
unsigned int nregs )

◆ reg_scan_mark_refs()

static void reg_scan_mark_refs ( rtx x,
rtx_insn * insn )
static
This is the `regscan' pass of the compiler, run just before cse and
again just before loop.  It finds the first and last use of each
pseudo-register.   
X is the expression to scan.  INSN is the insn it appears in.
NOTE_FLAG is nonzero if X is from INSN's notes rather than its body.
We should only record information for REGs with numbers
greater than or equal to MIN_REGNO.   

References CASE_CONST_ANY, CONST_INT_P, DF_REG_DEF_COUNT, find_reg_note(), GET_CODE, GET_RTX_FORMAT, GET_RTX_LENGTH, i, MEM_P, REG_ATTRS, REG_P, REG_POINTER, reg_scan_mark_refs(), REG_USERVAR_P, REGNO, SET, SET_DEST, set_reg_attrs_from_value(), SET_SRC, XEXP, XVEC, XVECEXP, and XVECLEN.

Referenced by reg_scan(), and reg_scan_mark_refs().

◆ reg_set_to_hard_reg_set()

void reg_set_to_hard_reg_set ( HARD_REG_SET * to,
const_bitmap from )
Given a register bitmap, turn on the bits in a HARD_REG_SET that
correspond to the hard registers, if any, set in that map.  This
could be done far more efficiently by having all sorts of special-cases
with moving single words, but probably isn't worth the trouble.   

References EXECUTE_IF_SET_IN_BITMAP, i, and SET_HARD_REG_BIT.

◆ reginfo_cc_finalize()

void reginfo_cc_finalize ( void )

◆ reginfo_init()

static unsigned int reginfo_init ( void )
static
Initialize some global data for this pass.   

References df, df_compute_regs_ever_live(), max_regno_since_last_resize, no_global_reg_vars, NULL, and reg_info_size.

◆ register_move_cost()

int register_move_cost ( machine_mode mode,
reg_class_t from,
reg_class_t to )
Compute cost of moving data from a register of class FROM to one of
TO, using MODE.   

References targetm.

Referenced by choose_reload_regs(), find_reloads(), find_valid_class(), find_valid_class_1(), ira_init_register_move_cost(), memory_move_secondary_cost(), and reload_cse_simplify_set().

◆ reinit_regs()

void reinit_regs ( void )
The same as previous function plus initializing IRA.   

References caller_save_initialized_p, init_regs(), ira_init(), recog_init(), and this_target_rtl.

Referenced by globalize_reg().

◆ resize_reg_info()

bool resize_reg_info ( void )

◆ restore_register_info()

static void restore_register_info ( void )
static

◆ save_register_info()

◆ setup_reg_classes()

void setup_reg_classes ( int regno,
enum reg_class prefclass,
enum reg_class altclass,
enum reg_class allocnoclass )

◆ simplifiable_subregs()

◆ valid_mode_changes_for_regno()

const HARD_REG_SET * valid_mode_changes_for_regno ( unsigned int regno)

Variable Documentation

◆ default_target_hard_regs

struct target_hard_regs default_target_hard_regs

◆ default_target_regs

struct target_regs default_target_regs

◆ global_reg_set

HARD_REG_SET global_reg_set

◆ global_regs

◆ global_regs_decl

tree global_regs_decl[FIRST_PSEUDO_REGISTER]
Declaration for the global register.  

Referenced by clear_global_regs_cache(), do_reload(), and globalize_reg().

◆ initial_call_used_regs

const char initial_call_used_regs[] = CALL_USED_REGISTERS
static
Data for initializing call_used_regs.   

Referenced by init_reg_sets().

◆ initial_fixed_regs

const char initial_fixed_regs[] = FIXED_REGISTERS
static
Data for initializing fixed_regs.   

Referenced by init_reg_sets().

◆ initial_reg_names

const char* const initial_reg_names[] = REGISTER_NAMES
static
Array containing all of the register names.   

Referenced by init_reg_sets().

◆ int_reg_class_contents

const unsigned int_reg_class_contents[N_REG_CLASSES][N_REG_INTS] = REG_CLASS_CONTENTS
static

Referenced by init_reg_sets().

◆ max_regno

int max_regno
Compute different info about registers.
   Copyright (C) 1987-2024 Free Software Foundation, Inc.

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 contains regscan pass of the compiler and passes for
dealing with info about modes of pseudo-registers inside
subregisters.  It also defines some tables of information about the
hardware registers, function init_reg_sets to initialize the
tables, and other auxiliary functions to deal with info about
registers and their classes.   
Maximum register number used in this function, plus one.   

Referenced by assign_by_spills(), build_insn_chain(), calculate_elim_costs_all_insns(), choose_reload_regs(), create_live_range_start_chains(), dead_or_predicable(), finish_spills(), fix_reg_equiv_init(), grow_reg_equivs(), if_convert(), init_eliminable_invariants(), init_live_reload_and_inheritance_pseudos(), init_lives(), init_loop_tree_node(), init_regno_assign_info(), ira(), ira_print_disposition(), ira_sort_regnos_for_alter_reg(), lra_assign(), lra_coalesce(), lra_create_live_ranges_1(), lra_final_code_change(), lra_need_for_scratch_reg_p(), lra_need_for_spills_p(), lra_remat(), lra_split_hard_reg_for(), print_live_ranges(), rebuild_regno_allocno_maps(), regstat_compute_calls_crossed(), regstat_compute_ri(), regstat_init_n_sets_and_refs(), reload(), reload_as_needed(), remove_init_insns(), remove_some_program_points_and_update_live_ranges(), run_rtl_passes(), setup_live_pseudos_and_spill_after_risky_transforms(), setup_preferred_alternate_classes_for_new_pseudos(), setup_reg_equiv_init(), spill_hard_reg(), and subst_reloads().

◆ max_regno_since_last_resize

int max_regno_since_last_resize
static
Max_reg_num still last resize_reg_info call.   

Referenced by allocate_reg_info(), reginfo_init(), and resize_reg_info().

◆ no_global_reg_vars

int no_global_reg_vars = 0
static
No more global register variables may be declared; true once
reginfo has been initialized.   

Referenced by globalize_reg(), reginfo_cc_finalize(), and reginfo_init().

◆ reg_class_names

◆ reg_info_size

◆ reg_pref

struct reg_pref* reg_pref
static
Record preferences of each pseudo.  This is available after RA is
run.   

◆ saved_accessible_reg_set

HARD_REG_SET saved_accessible_reg_set
static

◆ saved_call_used_regs

char saved_call_used_regs[FIRST_PSEUDO_REGISTER]
static

◆ saved_fixed_regs

char saved_fixed_regs[FIRST_PSEUDO_REGISTER]
static
We need to save copies of some of the register information which
can be munged by command-line switches so we can restore it during
subsequent back-end reinitialization.   

Referenced by restore_register_info(), and save_register_info().

◆ saved_operand_reg_set

HARD_REG_SET saved_operand_reg_set
static

◆ saved_reg_names

const char* saved_reg_names[FIRST_PSEUDO_REGISTER]
static

◆ valid_mode_changes

HARD_REG_SET** valid_mode_changes
static
Passes for keeping and updating info about modes of registers
inside subregisters.   

Referenced by finish_subregs_of_mode(), init_subregs_of_mode(), record_subregs_of_mode(), and valid_mode_changes_for_regno().

◆ valid_mode_changes_obstack

obstack valid_mode_changes_obstack
static