GCC Middle and Back End API Reference
lra-int.h File Reference

Go to the source code of this file.

Data Structures

struct  lra_live_range
struct  lra_copy
struct  lra_reg
struct  lra_operand_data
struct  lra_insn_reg
struct  lra_static_insn_data
struct  lra_insn_recog_data
struct  target_lra_int

Typedefs

typedef struct lra_live_rangelra_live_range_t
typedef struct lra_copylra_copy_t
typedef struct
lra_insn_recog_data
lra_insn_recog_data_t

Functions

static int lra_get_regno_hard_regno ()
void lra_push_insn (rtx)
void lra_push_insn_by_uid (unsigned int)
void lra_push_insn_and_update_insn_regno_info (rtx)
rtx lra_pop_insn (void)
unsigned int lra_insn_stack_length (void)
rtx lra_create_new_reg_with_unique_value (enum machine_mode, rtx, enum reg_class, const char *)
void lra_set_regno_unique_value (int)
void lra_invalidate_insn_data (rtx)
void lra_set_insn_deleted (rtx)
void lra_delete_dead_insn (rtx)
void lra_emit_add (rtx, rtx, rtx)
void lra_emit_move (rtx, rtx)
void lra_update_dups (lra_insn_recog_data_t, signed char *)
void lra_process_new_insns (rtx, rtx, rtx, const char *)
lra_insn_recog_data_t lra_set_insn_recog_data (rtx)
lra_insn_recog_data_t lra_update_insn_recog_data (rtx)
void lra_set_used_insn_alternative (rtx, int)
void lra_set_used_insn_alternative_by_uid (int, int)
void lra_invalidate_insn_regno_info (rtx)
void lra_update_insn_regno_info (rtx)
struct lra_insn_reglra_get_insn_regs (int)
void lra_free_copies (void)
void lra_create_copy (int, int, int)
lra_copy_t lra_get_copy (int)
bool lra_former_scratch_p (int)
bool lra_former_scratch_operand_p (rtx, int)
int lra_constraint_offset (int, enum machine_mode)
bool lra_constraints (bool)
void lra_constraints_init (void)
void lra_constraints_finish (void)
void lra_inheritance (void)
bool lra_undo_inheritance (void)
void lra_create_live_ranges (bool)
lra_live_range_t lra_copy_live_range_list (lra_live_range_t)
lra_live_range_t lra_merge_live_ranges (lra_live_range_t, lra_live_range_t)
bool lra_intersected_live_ranges_p (lra_live_range_t, lra_live_range_t)
void lra_print_live_range_list (FILE *, lra_live_range_t)
void debug (lra_live_range &ref)
void debug (lra_live_range *ptr)
void lra_debug_live_range_list (lra_live_range_t)
void lra_debug_pseudo_live_ranges (int)
void lra_debug_live_ranges (void)
void lra_clear_live_ranges (void)
void lra_live_ranges_init (void)
void lra_live_ranges_finish (void)
void lra_setup_reload_pseudo_preferenced_hard_reg (int, int, int)
void lra_setup_reg_renumber (int, int, bool)
bool lra_assign (void)
bool lra_coalesce (void)
bool lra_need_for_spills_p (void)
void lra_spill (void)
void lra_final_code_change (void)
void lra_debug_elim_table (void)
int lra_get_elimination_hard_regno (int)
rtx lra_eliminate_regs_1 (rtx, enum machine_mode, bool, bool, bool)
void lra_eliminate (bool)
void lra_eliminate_reg_if_possible (rtx *)
static void lra_update_dup ()
static void lra_update_operator_dups ()
static lra_insn_recog_data_t lra_get_insn_recog_data ()
static void lra_update_reg_val_offset ()
static bool lra_reg_val_equal_p ()
static void lra_assign_reg_val ()

Variables

struct lra_reglra_reg_info
FILE * lra_dump_file
bool lra_reg_spill_p
HARD_REG_SET lra_no_alloc_regs
int lra_insn_recog_data_len
lra_insn_recog_data_tlra_insn_recog_data
int lra_curr_reload_num
int lra_new_regno_start
int lra_constraint_new_regno_start
bitmap_head lra_inheritance_pseudos
bitmap_head lra_split_regs
bitmap_head lra_subreg_reload_pseudos
bitmap_head lra_optional_reload_pseudos
int lra_constraint_new_insn_uid_start
int lra_constraint_iter
int lra_constraint_iter_after_spill
bool lra_risky_transformations_p
int lra_inheritance_iter
int lra_undo_inheritance_iter
int lra_live_max_point
int * lra_point_freq
int lra_hard_reg_usage [FIRST_PSEUDO_REGISTER]
int lra_live_range_iter
int lra_coalesce_iter
struct target_lra_int default_target_lra_int
struct target_lra_intthis_target_lra_int

Typedef Documentation

typedef struct lra_copy* lra_copy_t

Function Documentation

void debug ( lra_live_range ref)
void debug ( lra_live_range ptr)
bool lra_assign ( void  )
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.   

References assign_by_spills(), bitmap_clear(), bitmap_ior_into(), create_live_range_start_chains(), finish_live_range_start_chains(), finish_live_reload_and_inheritance_pseudos(), finish_lives(), finish_regno_assign_info(), free(), init_live_reload_and_inheritance_pseudos(), init_lives(), init_regno_assign_info(), lra_get_allocno_class(), lra_push_insn_by_uid(), lra_reg_info, lra_set_used_insn_alternative_by_uid(), max_reg_num(), max_regno, overlaps_hard_reg_set_p(), reg_obstack, reg_renumber, regno_allocno_class_array, setup_live_pseudos_and_spill_after_risky_transforms(), sorted_pseudos, sorted_reload_pseudos, timevar_pop(), and timevar_push().

Referenced by lra().

static void lra_assign_reg_val ( )
inlinestatic
Assign value of register FROM to TO.   

References lra_reg::offset, and lra_reg::val.

Referenced by lra_create_new_reg(), and match_reload().

void lra_clear_live_ranges ( void  )
Finish all live ranges.   

References free_live_range_list(), lra_reg_info, and max_reg_num().

Referenced by lra().

int lra_constraint_offset ( int  ,
enum  machine_mode 
)
lra-constraints.c:  
bool lra_constraints ( bool  )
void lra_constraints_finish ( void  )
Finalize the LRA constraint pass.  It is done once per
   function.   

Referenced by lra().

void lra_constraints_init ( void  )
Initiate the LRA constraint pass.  It is done once per
   function.   

Referenced by lra().

lra_live_range_t lra_copy_live_range_list ( lra_live_range_t  )
void lra_create_copy ( int  ,
int  ,
int   
)

Referenced by process_bb_lives().

void lra_create_live_ranges ( bool  )

Referenced by lra().

rtx lra_create_new_reg_with_unique_value ( enum machine_mode  md_mode,
rtx  original,
enum reg_class  rclass,
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 expand_reg_data(), gen_reg_rtx(), lra_dump_file, reg_class_names, and setup_reg_classes().

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

void lra_debug_elim_table ( void  )
lra-elimination.c:  
Print info about elimination table to stderr.   

References print_elim_table().

void lra_debug_live_range_list ( lra_live_range_t  )
void lra_debug_live_ranges ( void  )
Print live ranges of all pseudos to stderr.        

References print_live_ranges().

void lra_debug_pseudo_live_ranges ( int  )
void lra_delete_dead_insn ( rtx  )
void lra_eliminate ( bool  )
void lra_eliminate_reg_if_possible ( rtx )
rtx lra_eliminate_regs_1 ( rtx  x,
enum machine_mode  mem_mode,
bool  subst_p,
bool  update_p,
bool  full_p 
)
Scan X and replace any eliminable registers (such as fp) with a
   replacement (such as sp) if SUBST_P, plus an offset.  The offset is
   a change in the offset between the eliminable register and its
   substitution if UPDATE_P, or the full offset if FULL_P, or
   otherwise zero.

   MEM_MODE is the mode of an enclosing MEM.  We need this to know how
   much to adjust a register for, e.g., PRE_DEC.  Also, if we are
   inside a MEM, we are allowed to replace a sum of a hard register
   and the constant zero with the hard register, which we cannot do
   outside a MEM.  In addition, we need to record the fact that a
   hard register is referenced outside a MEM.

   Alternatively, INSN may be a note (an EXPR_LIST or INSN_LIST).
   That's used when we eliminate in expressions stored in notes.   

References alloc_reg_note(), alter_subreg(), current_function_decl, form_sum(), elim_table::from_rtx, gen_rtvec_v(), get_elimination(), HOST_WIDE_INT, lra_eliminate_regs_1(), elim_table::offset, offset, plus_constant(), elim_table::previous_offset, replace_equiv_address_nv(), SET, simplify_gen_subreg(), elim_table::to, and elim_table::to_rtx.

Referenced by assign_mem_slot(), eliminate_regs_in_insn(), lra_eliminate(), lra_eliminate_regs(), and lra_eliminate_regs_1().

void lra_emit_add ( rtx  ,
rtx  ,
rtx   
)
bool lra_former_scratch_operand_p ( rtx  ,
int   
)

Referenced by curr_insn_transform().

void lra_free_copies ( void  )
Free all copies.   

References lra_reg::copies, pool_free(), lra_copy::regno1, and lra_copy::regno2.

Referenced by lra_create_live_ranges().

lra_copy_t lra_get_copy ( int  )

Referenced by init_regno_assign_info().

int lra_get_elimination_hard_regno ( int  )
struct lra_insn_reg* lra_get_insn_regs ( int  )
read

Referenced by spill_for().

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

Referenced by lra_constraints().

bool lra_intersected_live_ranges_p ( lra_live_range_t  ,
lra_live_range_t   
)
void lra_invalidate_insn_data ( rtx  )
void lra_invalidate_insn_regno_info ( rtx  )
void lra_live_ranges_finish ( void  )
Finish live ranges data once per function.   

References free_alloc_pool().

Referenced by lra().

void lra_live_ranges_init ( void  )
Initialize live ranges data once per function.   

References create_alloc_pool().

Referenced by lra().

lra_live_range_t lra_merge_live_ranges ( lra_live_range_t  ,
lra_live_range_t   
)
bool lra_need_for_spills_p ( void  )
lra-spills.c:   
Return true if we need to change some pseudos into memory.   

References lra_former_scratch_p(), lra_get_regno_hard_regno(), lra_reg_info, max_reg_num(), and max_regno.

Referenced by lra().

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

References bitmap_clear_bit().

Referenced by lra_constraints().

void lra_print_live_range_list ( FILE *  ,
lra_live_range_t   
)
void lra_process_new_insns ( rtx  ,
rtx  ,
rtx  ,
const char *   
)
void lra_push_insn_and_update_insn_regno_info ( rtx  )
void lra_push_insn_by_uid ( unsigned  int)

Referenced by lra_assign(), and lra_constraints().

static bool lra_reg_val_equal_p ( )
inlinestatic
Return true if register content is equal to VAL with OFFSET.   

Referenced by find_hard_regno_for(), and setup_live_pseudos_and_spill_after_risky_transforms().

lra_insn_recog_data_t lra_set_insn_recog_data ( rtx  )

Referenced by lra_get_insn_recog_data().

void lra_set_regno_unique_value ( int  )

Referenced by curr_insn_transform().

void lra_set_used_insn_alternative ( rtx  ,
int   
)
void lra_set_used_insn_alternative_by_uid ( int  ,
int   
)
void lra_setup_reg_renumber ( int  ,
int  ,
bool   
)
lra-assigns.c:  
void lra_setup_reload_pseudo_preferenced_hard_reg ( int  regno,
int  hard_regno,
int  profit 
)
void lra_spill ( void  )
Change spilled pseudos into memory or spill hard regs.  Put changed
   insns on the constraint stack (these insns will be considered on
   the next constraint pass).  The changed insns are all insns in
   which pseudos were changed.   

References assign_mem_slot(), assign_spill_hard_regs(), assign_stack_local(), assign_stack_slot_num_and_sort_pseudos(), free(), lra_dump_file, lra_former_scratch_p(), lra_get_regno_hard_regno(), lra_reg_info, max_reg_num(), pseudo_slot::mem, pseudo_slot::next, pseudo_slots, regno_freq_compare(), regs_num, slots_num, spill_hard_reg, and spill_pseudos().

Referenced by lra().

bool lra_undo_inheritance ( void  )
Entry function for undoing inheritance/split transformation.       Return true
   if we did any RTL change in this pass.   

References bitmap_clear(), bitmap_set_bit(), lra_dump_file, lra_inheritance_pseudos, lra_reg_info, lra_split_regs, lra_undo_inheritance_iter, reg_obstack, reg_renumber, lra_insn_reg::regno, remove_inheritance_pseudos(), remove_pseudos(), lra_reg::restore_regno, and undo_optional_reloads().

Referenced by lra().

static void lra_update_dup ( )
inlinestatic
Update insn operands which are duplication of NOP operand.  The
   insn is represented by its LRA internal representation ID.   

References lra_static_insn_data::dup_num, and lra_static_insn_data::n_dups.

Referenced by curr_insn_transform(), lra_final_code_change(), match_reload(), remove_scratches(), restore_scratches(), and swap_operands().

void lra_update_dups ( lra_insn_recog_data_t  ,
signed char *   
)

Referenced by match_reload().

lra_insn_recog_data_t lra_update_insn_recog_data ( rtx  )
static void lra_update_operator_dups ( )
inlinestatic
Process operator duplications in insn with ID.  We do it after the
   operands processing.  Generally speaking, we could do this probably
   simultaneously with operands processing because a common practice
   is to enumerate the operators after their operands.   

References lra_static_insn_data::dup_num, lra_operand_data::is_operator, lra_static_insn_data::n_dups, and lra_static_insn_data::operand.

Referenced by curr_insn_transform(), and lra_final_code_change().

static void lra_update_reg_val_offset ( )
inlinestatic
Update offset from pseudos with VAL by INCR.   

References max_reg_num(), and lra_reg::offset.

Referenced by update_reg_eliminate().


Variable Documentation

struct target_lra_int default_target_lra_int
This page contains code dealing LRA insn info (or in other words
   LRA internal insn representation).   
int lra_coalesce_iter
lra-coalesce.c:  
The current iteration (1, 2, ...) of the coalescing pass.   

Referenced by lra(), and lra_coalesce().

int lra_constraint_iter
The current iteration number of this LRA pass.   

Referenced by lra(), and lra_constraints().

int lra_constraint_iter_after_spill
The current iteration number of this LRA pass after the last spill
   pass.   

Referenced by lra(), and lra_constraints().

int lra_constraint_new_insn_uid_start
First UID of insns generated before a new spill pass.   

Referenced by lra().

int lra_curr_reload_num
The number of emitted reload insns so far.   

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

int lra_hard_reg_usage[FIRST_PSEUDO_REGISTER]
Accumulated execution frequency of all references for each hard
   register.   

Referenced by find_hard_regno_for(), lra_create_live_ranges(), lra_setup_reg_renumber(), process_bb_lives(), and setup_live_pseudos_and_spill_after_risky_transforms().

int lra_inheritance_iter
Current number of inheritance/split iteration.   

Referenced by improve_inheritance(), lra(), and lra_inheritance().

bitmap_head lra_inheritance_pseudos
Map INSN_UID -> the insn recog data (NULL if unknown).   
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(), and init_insn_recog_data().

int lra_live_max_point
lra-lives.c:  
@verbatim Build live ranges for pseudos.

Copyright (C) 2010-2013 Free Software Foundation, Inc. Contributed by Vladimir Makarov vmaka.nosp@m.rov@.nosp@m.redha.nosp@m.t.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/.

This file contains code to build pseudo live-ranges (analogous
   structures used in IRA, so read comments about the live-ranges
   there) and other info necessary for other passes to assign
   hard-registers to pseudos, coalesce the spilled pseudos, and assign
   stack memory slots to spilled pseudos.   
Program points are enumerated by numbers from range
   0..LRA_LIVE_MAX_POINT-1.  There are approximately two times more
   program points than insns.  Program points are places in the
   program where liveness info can be changed.  In most general case
   (there are more complicated cases too) some program points
   correspond to places where input operand dies and other ones
   correspond to places where output operands are born.   

Referenced by assign_spill_hard_regs(), create_live_range_start_chains(), init_live_reload_and_inheritance_pseudos(), init_lives(), lra_create_live_ranges(), and remove_some_program_points_and_update_live_ranges().

int lra_live_range_iter
The number of the current live range pass.   

Referenced by lra().

int lra_new_regno_start
Start of pseudo regnos before the LRA.   

Referenced by lra(), and match_reload().

HARD_REG_SET lra_no_alloc_regs
@verbatim LRA (local register allocator) driver and LRA utilities.

Copyright (C) 2010-2013 Free Software Foundation, Inc. Contributed by Vladimir Makarov vmaka.nosp@m.rov@.nosp@m.redha.nosp@m.t.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/.

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 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              |
         ----------------    No    ------------  pseudos   -------------------
        | Spilled pseudo | change |Constraints:| or insns | Inheritance/split |
        |    to memory   |<-------|    RTL     |--------->|  transformations  |
        |  substitution  |        | transfor-  |          |    in EBB scope   |
         ----------------         |  mations   |           -------------------
                |                   ------------
                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.   
Hard registers currently not available for allocation.  It can
   changed after some hard  registers become not eliminable.   

Referenced by add_regs_to_insn_regno_info(), assign_spill_hard_regs(), collect_non_operand_hard_regs(), contains_reg_p(), find_hard_regno_for(), in_class_p(), inherit_in_ebb(), lra(), lra_eliminate_reg_if_possible(), make_hard_regno_born(), make_hard_regno_dead(), need_for_split_p(), process_alt_operands(), process_bb_lives(), setup_live_pseudos_and_spill_after_risky_transforms(), spill_pseudos(), and update_reg_eliminate().

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

Referenced by assign_by_spills(), curr_insn_transform(), pseudo_prefix_title(), spill_for(), and undo_optional_reloads().

int* lra_point_freq
The start of the above vector elements.   

Referenced by lra_create_live_ranges(), next_program_point(), and remove_some_program_points_and_update_live_ranges().

struct lra_reg* lra_reg_info
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().

bool lra_risky_transformations_p
True if we substituted equiv which needs checking register
   allocation correctness because the equivalent value contains
   allocatable hard registers or when we restore multi-register
   pseudo.   

Referenced by inherit_in_ebb(), lra_constraints(), setup_live_pseudos_and_spill_after_risky_transforms(), and split_reg().

bitmap_head lra_split_regs
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 assinment
   pass.   

Referenced by assign_by_spills(), pseudo_prefix_title(), simplify_operand_subreg(), and spill_for().

int lra_undo_inheritance_iter
This page contains code to undo failed inheritance/split
   transformations.   
Current number of iteration undoing inheritance/split.   

Referenced by curr_insn_transform(), lra(), and lra_undo_inheritance().

struct target_lra_int* this_target_lra_int