GCC Middle and Back End API Reference
regs.h File Reference
#include "machmode.h"
#include "hard-reg-set.h"
#include "rtl.h"
Include dependency graph for regs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  regstat_n_sets_and_refs_t
struct  reg_info_t
struct  target_regs

Macros

#define REG_BYTES(R)   mode_size[(int) GET_MODE (R)]
#define REGMODE_NATURAL_SIZE(MODE)   UNITS_PER_WORD
#define SET_REG_N_REFS(N, V)   (regstat_n_sets_and_refs[N].refs = V)
#define INC_REG_N_REFS(N, V)   (regstat_n_sets_and_refs[N].refs += V)
#define SET_REG_N_SETS(N, V)   (regstat_n_sets_and_refs[N].sets = V)
#define INC_REG_N_SETS(N, V)   (regstat_n_sets_and_refs[N].sets += V)
#define REG_FREQ(N)   (reg_info_p[N].freq)
#define REG_FREQ_MAX   1000
#define REG_FREQ_FROM_BB(bb)
#define REG_N_DEATHS(N)   (reg_info_p[N].deaths)
#define PSEUDO_REGNO_SIZE(N)
#define PSEUDO_REGNO_BYTES(N)   GET_MODE_SIZE (PSEUDO_REGNO_MODE (N))
#define PSEUDO_REGNO_MODE(N)   GET_MODE (regno_reg_rtx[N])
#define REG_N_CALLS_CROSSED(N)   (reg_info_p[N].calls_crossed)
#define REG_FREQ_CALLS_CROSSED(N)   (reg_info_p[N].freq_calls_crossed)
#define REG_N_THROWING_CALLS_CROSSED(N)   (reg_info_p[N].throw_calls_crossed)
#define REG_LIVE_LENGTH(N)   (reg_info_p[N].live_length)
#define REG_BLOCK_UNKNOWN   0
#define REG_BLOCK_GLOBAL   -1
#define REG_BASIC_BLOCK(N)   (reg_info_p[N].basic_block)
#define CALLER_SAVE_PROFITABLE(REFS, CALLS)   (4 * (CALLS) < (REFS))
#define HARD_REGNO_CALLER_SAVE_MODE(REGNO, NREGS, MODE)   choose_hard_reg_mode (REGNO, NREGS, false)
#define HARD_REGNO_CALL_PART_CLOBBERED(REGNO, MODE)   0
#define this_target_regs   (&default_target_regs)
#define hard_regno_nregs   (this_target_regs->x_hard_regno_nregs)
#define reg_raw_mode   (this_target_regs->x_reg_raw_mode)
#define have_regs_of_mode   (this_target_regs->x_have_regs_of_mode)
#define contains_reg_of_mode   (this_target_regs->x_contains_reg_of_mode)
#define direct_load   (this_target_regs->x_direct_load)
#define direct_store   (this_target_regs->x_direct_store)
#define float_extend_from_mem   (this_target_regs->x_float_extend_from_mem)
#define END_HARD_REGNO(X)   end_hard_regno (GET_MODE (X), REGNO (X))
#define END_REGNO(X)   (HARD_REGISTER_P (X) ? END_HARD_REGNO (X) : REGNO (X) + 1)

Functions

static int REG_N_REFS ()
static int REG_N_SETS ()
bool reg_is_parm_p (rtx)
void regstat_init_n_sets_and_refs (void)
void regstat_free_n_sets_and_refs (void)
void regstat_compute_ri (void)
void regstat_free_ri (void)
bitmap regstat_get_setjmp_crosses (void)
void regstat_compute_calls_crossed (void)
void regstat_free_calls_crossed (void)
void dump_reg_info (FILE *)
static unsigned int end_hard_regno ()
static void add_to_hard_reg_set (HARD_REG_SET *regs, enum machine_mode mode, unsigned int regno)
static void remove_from_hard_reg_set (HARD_REG_SET *regs, enum machine_mode mode, unsigned int regno)
static bool in_hard_reg_set_p (const HARD_REG_SET regs, enum machine_mode mode, unsigned int regno)
static bool overlaps_hard_reg_set_p (const HARD_REG_SET regs, enum machine_mode mode, unsigned int regno)
static void add_range_to_hard_reg_set (HARD_REG_SET *regs, unsigned int regno, int nregs)
static void remove_range_from_hard_reg_set (HARD_REG_SET *regs, unsigned int regno, int nregs)
static bool range_overlaps_hard_reg_set_p (const HARD_REG_SET set, unsigned regno, int nregs)
static bool range_in_hard_reg_set_p ()

Variables

int max_regno
struct regstat_n_sets_and_refs_tregstat_n_sets_and_refs
struct reg_info_treg_info_p
size_t reg_info_p_size
short * reg_renumber
int caller_save_needed
struct target_regs default_target_regs

Macro Definition Documentation

#define CALLER_SAVE_PROFITABLE (   REFS,
  CALLS 
)    (4 * (CALLS) < (REFS))

Predicate to decide whether to give a hard reg to a pseudo which is referenced REFS times and would need to be saved and restored around a call CALLS times.

#define contains_reg_of_mode   (this_target_regs->x_contains_reg_of_mode)

Referenced by scan_one_insn().

#define direct_load   (this_target_regs->x_direct_load)
#define direct_store   (this_target_regs->x_direct_store)
#define END_HARD_REGNO (   X)    end_hard_regno (GET_MODE (X), REGNO (X))

Likewise for hard register X.

Referenced by find_reg_equal_equiv_note(), find_regno_note(), record_value_for_reg(), and use_crosses_set_p().

#define END_REGNO (   X)    (HARD_REGISTER_P (X) ? END_HARD_REGNO (X) : REGNO (X) + 1)

Likewise for hard or pseudo register X.

Referenced by covers_regno_p(), and note_uses().

#define float_extend_from_mem   (this_target_regs->x_float_extend_from_mem)
#define HARD_REGNO_CALL_PART_CLOBBERED (   REGNO,
  MODE 
)    0

Registers that get partially clobbered by a call in a given mode. These must not be call used registers.

Referenced by expand_builtin_dwarf_sp_column(), and memory_move_secondary_cost().

#define HARD_REGNO_CALLER_SAVE_MODE (   REGNO,
  NREGS,
  MODE 
)    choose_hard_reg_mode (REGNO, NREGS, false)

Select a register mode required for caller save of hard regno REGNO.

Referenced by init_caller_save(), and save_call_clobbered_regs().

#define have_regs_of_mode   (this_target_regs->x_have_regs_of_mode)

Referenced by int_mode_for_mode().

#define INC_REG_N_REFS (   N,
 
)    (regstat_n_sets_and_refs[N].refs += V)
#define INC_REG_N_SETS (   N,
 
)    (regstat_n_sets_and_refs[N].sets += V)
#define PSEUDO_REGNO_BYTES (   N)    GET_MODE_SIZE (PSEUDO_REGNO_MODE (N))

Get the number of bytes required to hold pseudo-reg N.

Referenced by collect_spilled_coalesced_allocnos().

#define PSEUDO_REGNO_SIZE (   N)
Value:
((GET_MODE_SIZE (PSEUDO_REGNO_MODE (N)) + UNITS_PER_WORD - 1) \
/ UNITS_PER_WORD)

Get the number of consecutive words required to hold pseudo-reg N.

#define REG_BASIC_BLOCK (   N)    (reg_info_p[N].basic_block)
#define REG_BLOCK_GLOBAL   -1
#define REG_BLOCK_UNKNOWN   0

Indexed by n, gives number of basic block that (REG n) is used in. If the value is REG_BLOCK_GLOBAL (-1), it means (REG n) is used in more than one basic block. REG_BLOCK_UNKNOWN (0) means it hasn't been seen yet so we don't know. This information remains valid for the rest of the compilation of the current function; it is used to control register allocation.

#define REG_BYTES (   R)    mode_size[(int) GET_MODE (R)]

Define per-register tables for data flow info and register allocation. Copyright (C) 1987-2013 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/.

#define REG_FREQ (   N)    (reg_info_p[N].freq)

Estimate frequency of references to register N.

#define REG_FREQ_CALLS_CROSSED (   N)    (reg_info_p[N].freq_calls_crossed)
#define REG_FREQ_FROM_BB (   bb)
Value:
(optimize_size \
|| (flag_branch_probabilities \
&& !ENTRY_BLOCK_PTR->count) \
: ((bb)->frequency * REG_FREQ_MAX / BB_FREQ_MAX)\
? ((bb)->frequency * REG_FREQ_MAX / BB_FREQ_MAX)\
: 1)

Compute register frequency from the BB frequency. When optimizing for size, or profile driven feedback is available and the function is never executed, frequency is always equivalent. Otherwise rescale the basic block frequency.

Referenced by find_call_crossed_cheap_reg(), ira_reassign_pseudos(), process_reg_shuffles(), and saved_hard_reg_compare_func().

#define REG_FREQ_MAX   1000

The weights for each insn varies from 0 to REG_FREQ_BASE. This constant does not need to be high, as in infrequently executed regions we want to count instructions equivalently to optimize for size instead of speed.

#define REG_LIVE_LENGTH (   N)    (reg_info_p[N].live_length)

Total number of instructions at which (REG n) is live.

This is set in regstat.c whenever register info is requested and remains valid for the rest of the compilation of the function; it is used to control register allocation. The larger this is, the less priority (REG n) gets for allocation in a hard register (in IRA in priority-coloring mode).

Negative values are special: -1 is used to mark a pseudo reg that should not be allocated to a hard register, because it crosses a setjmp call.

#define REG_N_CALLS_CROSSED (   N)    (reg_info_p[N].calls_crossed)

Indexed by N, gives number of CALL_INSNS across which (REG n) is live.

#define REG_N_DEATHS (   N)    (reg_info_p[N].deaths)

Indexed by N, gives number of insns in which register N dies. Note that if register N is live around loops, it can die in transitions between basic blocks, and that is not counted here. So this is only a reliable indicator of how many regions of life there are for registers that are contained in one basic block.

#define REG_N_THROWING_CALLS_CROSSED (   N)    (reg_info_p[N].throw_calls_crossed)

Indexed by N, gives number of CALL_INSNS that may throw, across which (REG n) is live.

#define reg_raw_mode   (this_target_regs->x_reg_raw_mode)
#define REGMODE_NATURAL_SIZE (   MODE)    UNITS_PER_WORD

When you only have the mode of a pseudo register before it has a hard register chosen for it, this reports the size of each hard register a pseudo in such a mode would get allocated to. A target may override this.

#define SET_REG_N_REFS (   N,
 
)    (regstat_n_sets_and_refs[N].refs = V)

Indexed by n, gives number of times (REG n) is used or set.

#define SET_REG_N_SETS (   N,
 
)    (regstat_n_sets_and_refs[N].sets = V)

Indexed by n, gives number of times (REG n) is set.

#define this_target_regs   (&default_target_regs)

Function Documentation

static void add_range_to_hard_reg_set ( HARD_REG_SET regs,
unsigned int  regno,
int  nregs 
)
inlinestatic

Like add_to_hard_reg_set, but use a REGNO/NREGS range instead of REGNO and MODE.

static void add_to_hard_reg_set ( HARD_REG_SET regs,
enum machine_mode  mode,
unsigned int  regno 
)
inlinestatic

Add to REGS all the registers required to store a value of mode MODE in register REGNO.

Referenced by mark_referenced_regs().

void dump_reg_info ( FILE *  )
static unsigned int end_hard_regno ( )
inlinestatic

Return an exclusive upper bound on the registers occupied by hard register (reg:MODE REGNO).

Referenced by operands_match_p(), and remove_from_hard_reg_set().

static bool in_hard_reg_set_p ( const HARD_REG_SET  regs,
enum machine_mode  mode,
unsigned int  regno 
)
inlinestatic

Return true if REGS contains the whole of (reg:MODE REGNO).

References SET_HARD_REG_BIT.

Referenced by find_replacement(), find_valid_class(), process_alt_operands(), and setup_hard_regno_aclass().

static bool overlaps_hard_reg_set_p ( const HARD_REG_SET  regs,
enum machine_mode  mode,
unsigned int  regno 
)
inlinestatic

Return true if (reg:MODE REGNO) includes an element of REGS.

Referenced by lra_setup_reg_renumber().

static bool range_in_hard_reg_set_p ( )
inlinestatic

Like in_hard_reg_set_p, but use a REGNO/NREGS range instead of REGNO and MODE.

static bool range_overlaps_hard_reg_set_p ( const HARD_REG_SET  set,
unsigned  regno,
int  nregs 
)
inlinestatic

Like overlaps_hard_reg_set_p, but use a REGNO/NREGS range instead of REGNO and MODE.

bool reg_is_parm_p ( rtx  )

Given a REG, return TRUE if the reg is a PARM_DECL, FALSE otherwise.

static int REG_N_REFS ( )
inlinestatic

Indexed by n, gives number of times (REG n) is used or set.

Referenced by ira_reassign_pseudos().

static int REG_N_SETS ( )
inlinestatic

Indexed by n, gives number of times (REG n) is set.

void regstat_compute_calls_crossed ( void  )

Compute register info: lifetime, bb, and number of defs and uses.

Initialize everything.

void regstat_compute_ri ( void  )

Compute register info: lifetime, bb, and number of defs and uses.

Initialize everything.

 See the setjmp comment in regstat_bb_compute_ri.   

Referenced by split_live_ranges_for_shrink_wrap().

void regstat_free_calls_crossed ( void  )

Free all storage associated with the problem.

void regstat_free_n_sets_and_refs ( void  )

Free the array that holds the REG_N_SETS and REG_N_REFS.

void regstat_free_ri ( void  )

Free all storage associated with the problem.

bitmap regstat_get_setjmp_crosses ( void  )

Return a bitmap containing the set of registers that cross a setjmp. The client should not change or delete this bitmap.

References BASIC_BLOCK, bitmap_clear_bit(), bitmap_copy(), bitmap_set_bit, df_get_artificial_defs(), df_get_artificial_uses(), df_get_live_out(), DF_REF_FLAGS, and DF_REF_REGNO.

void regstat_init_n_sets_and_refs ( void  )

Functions defined in regstat.c.

If a pass need to change these values in some magical way or the pass needs to have accurate values for these and is not using incremental df scanning, then it should use REG_N_SETS and REG_N_USES. If the pass is doing incremental scanning then it should be getting the info from DF_REG_DEF_COUNT and DF_REG_USE_COUNT.

Referenced by split_live_ranges_for_shrink_wrap().

static void remove_from_hard_reg_set ( HARD_REG_SET regs,
enum machine_mode  mode,
unsigned int  regno 
)
inlinestatic

Likewise, but remove the registers.

References end_hard_regno(), and TEST_HARD_REG_BIT.

static void remove_range_from_hard_reg_set ( HARD_REG_SET regs,
unsigned int  regno,
int  nregs 
)
inlinestatic

Likewise, but remove the registers.


Variable Documentation

int caller_save_needed

Flag set by local-alloc or global-alloc if they decide to allocate something in a call-clobbered register.

Flag set by local-alloc or global-alloc if anything is live in a call-clobbered reg across calls.

struct target_regs default_target_regs
int max_regno

Maximum register number used in this function, plus one.

Compute different info about registers. Copyright (C) 1987-2013 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 calculate_allocation_cost(), coalescable_pseudo_p(), coalesced_pseudo_reg_slot_compare(), and update_lives().

struct reg_info_t* reg_info_p
size_t reg_info_p_size

The number allocated elements of reg_info_p.

short* reg_renumber

Vector of substitutions of register numbers, used to map pseudo regs into hardware regs.

This can't be folded into reg_n_info without changing all of the machine dependent directories, since the reload functions in the machine dependent files access it.

Vector of substitutions of register numbers, used to map pseudo regs into hardware regs. This is set up as a result of register allocation. Element N is the hard reg assigned to pseudo reg N, or is -1 if no hard reg was assigned. If N is a hard reg number, element N is N.

Referenced by add_to_inherit(), can_reload_into(), check_and_process_move(), init_lives(), insert_save(), invert_exp_1(), invert_jump_1(), ira_reassign_pseudos(), lra_debug_live_ranges(), maybe_fix_stack_asms(), save_call_clobbered_regs(), set_label_offsets(), setup_try_hard_regno_pseudos(), slot_coalesced_allocno_live_ranges_intersect_p(), substitute_pseudo(), and update_hard_regno_preference().

struct regstat_n_sets_and_refs_t* regstat_n_sets_and_refs

Scanning of rtl for dataflow analysis. Copyright (C) 2007-2013 Free Software Foundation, Inc. Contributed by Kenneth Zadeck (zadec.nosp@m.k@na.nosp@m.tural.nosp@m.brid.nosp@m.ge.co.nosp@m.m).

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/.