GCC Middle and Back End API Reference
reginfo.c File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "hard-reg-set.h"
#include "tree.h"
#include "rtl.h"
#include "expr.h"
#include "tm_p.h"
#include "flags.h"
#include "basic-block.h"
#include "regs.h"
#include "addresses.h"
#include "function.h"
#include "insn-config.h"
#include "recog.h"
#include "reload.h"
#include "diagnostic-core.h"
#include "output.h"
#include "hashtab.h"
#include "target.h"
#include "tree-pass.h"
#include "df.h"
#include "ira.h"
Include dependency graph for reginfo.c:

Data Structures

struct  reg_pref

Macros

#define CALL_REALLY_USED_REGNO_P(X)   call_used_regs[X]
#define N_REG_INTS   ((FIRST_PSEUDO_REGISTER + (32 - 1)) / 32)

Functions

void reg_set_to_hard_reg_set ()
void init_reg_sets ()
void save_register_info ()
static void restore_register_info ()
static void init_reg_sets_1 ()
void init_reg_modes_target ()
void init_regs ()
void reinit_regs ()
void init_fake_stack_mems ()
int register_move_cost ()
int memory_move_cost ()
int memory_move_secondary_cost (enum machine_mode mode, reg_class_t rclass, bool in)
enum machine_mode choose_hard_reg_mode (unsigned int regno, unsigned int nregs, bool call_saved)
void fix_register ()
void globalize_reg ()
enum reg_class reg_preferred_class ()
enum reg_class reg_alternate_class ()
enum reg_class reg_allocno_class ()
static void allocate_reg_info ()
bool resize_reg_info ()
void free_reg_info ()
static unsigned int reginfo_init ()
rtl_opt_passmake_pass_reginfo_init ()
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)
void reg_scan ()
static void reg_scan_mark_refs ()
int reg_class_subset_p ()
int reg_classes_intersect_p ()
void init_subregs_of_mode ()
void finish_subregs_of_mode ()

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]
static tree global_regs_decl [FIRST_PSEUDO_REGISTER]
regset regs_invalidated_by_call_regset
regset fixed_reg_set_regset
static bitmap_obstack persistent_obstack
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_prefreg_pref
static int reg_info_size
static int max_regno_since_last_resize

Macro Definition Documentation

#define CALL_REALLY_USED_REGNO_P (   X)    call_used_regs[X]
#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.


Function Documentation

static void allocate_reg_info ( )
static

Allocate space for reg info and initilize it.

enum machine_mode choose_hard_reg_mode ( unsigned int  regno,
unsigned int  nregs,
bool  call_saved 
)

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 CALL_SAVED is true, only consider modes that are call saved.

 We first look for the largest integer mode that can be validly
 held in REGNO.  If none, we look for the largest floating-point mode.
 If we still didn't find a valid mode, try CCmode.   
 Iterate over all of the CCmodes.   
 We can't find a mode valid for this register.   

Referenced by expand_builtin_dwarf_sp_column().

void finish_subregs_of_mode ( void  )
void fix_register ( )

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.

Decode the name and update the primary form of the register info.

void free_reg_info ( void  )

Free up the space allocated by allocate_reg_info.

void globalize_reg ( )

Mark register number I as global.

If we're globalizing the frame pointer, we need to set the appropriate regs_invalidated_by_call bit, even if it's already set in fixed_regs.

 If already fixed, nothing else to do.   
void init_fake_stack_mems ( void  )

Initialize some fake stack-frame MEM references for use in memory_move_secondary_cost.

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.

If we couldn't find a valid mode, just use the previous mode if it is suitable, otherwise fall back on word_mode.

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.

 First copy the register information from the initial int form into
 the regsets.   
     Note that we hard-code 32 here, not HOST_BITS_PER_INT.   
 Sanity check: make sure the target macros FIXED_REGISTERS and
 CALL_USED_REGISTERS had the right number of initializers.   
static void init_reg_sets_1 ( )
static

After switches have been processed, which perhaps alter `fixed_regs' and `call_used_regs', convert them to HARD_REG_SETs.

 Let the target tweak things if necessary.   
 Compute number of hard regs in each class.   
 Initialize the table of subunions.
 reg_class_subunion[I][J] gets the largest-numbered reg-class
 that is contained in the union of classes I and J.   
 Initialize the table of superunions.
 reg_class_superunion[I][J] gets the smallest-numbered reg-class
 containing the union of classes I and J.   
 Initialize the tables of subclasses and superclasses of each reg class.
 First clear the whole table, then add the elements as they are found.   
           Reg class I is a subclass of J.
           Add J to the table of superclasses of I.   
           Add I to the table of superclasses of J.   
 Initialize "constant" tables.   
     As a special exception, registers whose class is NO_REGS are
     not accepted by `register_operand'.  The reason for this change
     is to allow the representation of special architecture artifacts
     (such as a condition code register) without extending the rtl
     definitions.  Since registers of class NO_REGS cannot be used
     as registers in any case where register classes are examined,
     it is better to apply this exception in a target-independent way.   
     If a register is too limited to be treated as a register operand,
     then it should never be allocated to a pseudo.   
     call_used_regs must include fixed_regs.   
     There are a couple of fixed registers that we know are safe to
     exclude from being clobbered by calls:

     The frame pointer is always preserved across calls.  The arg
     pointer is if it is fixed.  The stack pointer usually is,
     unless TARGET_RETURN_POPS_ARGS, in which case an explicit
     CLOBBER will be present.  If we are generating PIC code, the
     PIC offset table register is preserved across calls, though the
     target can override that.   
 Preserve global registers if called more than once.   
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.

This finishes what was started by init_reg_sets, but couldn't be done until after register usage was specified.

void init_subregs_of_mode ( void  )

Passes for keeping and updating info about modes of registers inside subregisters.

Referenced by setup_allocno_class_and_costs().

rtl_opt_pass* make_pass_reginfo_init ( )
int memory_move_cost ( )

Compute cost of moving registers to/from memory.

int memory_move_secondary_cost ( enum 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.

 We need a memory reference to feed to SECONDARY... macros.   
 mem may be unused even if the SECONDARY_ macros are defined.   
   This isn't simply a copy-to-temporary situation.  Can't guess
   what it is, so TARGET_MEMORY_MOVE_COST really ought not to be
   calling here in that case.

   I'm tempted to put in an assert here, but returning this will
   probably only give poor estimates, which is what we would've
   had before this code anyways.   
 Check if the secondary reload register will also need a
 secondary reload.   

References HARD_REGNO_CALL_PART_CLOBBERED, and hard_regno_nregs.

Referenced by default_target_option_pragma_parse().

enum reg_class reg_allocno_class ( )

Return the reg_class which is used by IRA for its allocation.

Referenced by move_invariants().

enum reg_class reg_alternate_class ( )
int reg_class_subset_p ( )

Return nonzero if C1 is a subset of C2, i.e., if every register in C1 is also in C2.

Referenced by find_valid_class_1(), and remove_address_replacements().

int reg_classes_intersect_p ( )

Return nonzero if there is a register that is in both C1 and C2.

References bitmap_bit_p.

enum reg_class reg_preferred_class ( )

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.

void reg_scan ( )
static void reg_scan_mark_refs ( rtx  ,
rtx   
)
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.

static void reg_scan_mark_refs ( )
static

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.

     Count a set of the destination if it is a register.   
     If this is setting a pseudo from another pseudo or the sum of a
     pseudo and a constant integer and the other pseudo is known to be
     a pointer, set the destination to be a pointer as well.

     Likewise if it is setting the destination from an address or from a
     value equivalent to an address or to the sum of an address and
     something else.

     But don't do any of this if the pseudo corresponds to a user
     variable since it should have already been set as a pointer based
     on the type.   
         If the destination pseudo is set more than once, then other
         sets might not be to a pointer value (consider access to a
         union in two threads of control in the presence of global
         optimizations).  So only set REG_POINTER on the destination
         pseudo if this is the only set of that pseudo.   
     If this is setting a register from a register or from a simple
     conversion of a register, propagate REG_EXPR.   
     ... fall through ...   
void reg_set_to_hard_reg_set ( )

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 CLEAR_HARD_REG_SET, reg_class_contents, and SET_HARD_REG_BIT.

static unsigned int reginfo_init ( )
static

Initialize some global data for this pass.

This prevents dump_reg_info from losing if called before reginfo is run.

 No more global register variables may be declared.   
int register_move_cost ( )

Compute cost of moving data from a register of class FROM to one of TO, using MODE.

Referenced by find_valid_class().

void reinit_regs ( void  )

The same as previous function plus initializing IRA.

caller_save needs to be re-initialized.

bool resize_reg_info ( void  )

Resize reg info. The new elements will be initialized. Return TRUE if new pseudos were added since the last call.

Referenced by split_live_ranges_for_shrink_wrap().

static void restore_register_info ( )
static

Restore the register information.

References targetm.

void save_register_info ( void  )

Save the register information.

 Sanity check:  make sure the target macros FIXED_REGISTERS and
 CALL_USED_REGISTERS had the right number of initializers.   
 Likewise for call_really_used_regs.   
 And similarly for reg_names.   

References accessible_reg_set, call_really_used_regs, call_used_regs, COPY_HARD_REG_SET, fixed_regs, operand_reg_set, and reg_names.

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

Set up preferred, alternate, and allocno classes for REGNO as PREFCLASS, ALTCLASS, and ALLOCNOCLASS.


Variable Documentation

struct target_hard_regs default_target_hard_regs
struct target_regs default_target_regs
regset fixed_reg_set_regset

Same information as FIXED_REG_SET but in regset form.

char global_regs[FIRST_PSEUDO_REGISTER]

Indexed by hard register number, contains 1 for registers that are being used for global register decls. These must be exempt from ordinary flow analysis and are also considered fixed.

Referenced by fprint_ul(), merge_overlapping_regs(), and split_all_insns().

tree global_regs_decl[FIRST_PSEUDO_REGISTER]
static

Declaration for the global register.

const char initial_call_used_regs[] = CALL_USED_REGISTERS
static

Data for initializing call_used_regs.

const char initial_fixed_regs[] = FIXED_REGISTERS
static

Data for initializing fixed_regs.

const char* const initial_reg_names[] = REGISTER_NAMES
static

Array containing all of the register names.

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

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().

int max_regno_since_last_resize
static

Max_reg_num still last resize_reg_info call.

int no_global_reg_vars = 0
static

No more global register variables may be declared; true once reginfo has been initialized.

bitmap_obstack persistent_obstack
static

The bitmap_obstack is used to hold some static variables that should not be reset after each function is compiled.

const char* reg_class_names[] = REG_CLASS_NAMES

Array containing all of the register class names.

Referenced by regrename_chain_from_id(), and scan_one_insn().

int reg_info_size
static

Current size of reg_info.

struct reg_pref* reg_pref
static

Record preferences of each pseudo. This is available after RA is run.

regset regs_invalidated_by_call_regset

Same information as REGS_INVALIDATED_BY_CALL but in regset form to be used in dataflow more conveniently.

Referenced by df_scan_free().

HARD_REG_SET saved_accessible_reg_set
static
char saved_call_used_regs[FIRST_PSEUDO_REGISTER]
static
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.

HARD_REG_SET saved_operand_reg_set
static
const char* saved_reg_names[FIRST_PSEUDO_REGISTER]
static