GCC Middle and Back End API Reference
lra-spills.c File Reference

Data Structures

struct  pseudo_slot
struct  slot

Functions

static void assign_mem_slot ()
static int regno_freq_compare ()
static int pseudo_reg_slot_compare ()
static int assign_spill_hard_regs ()
static void add_pseudo_to_slot ()
static void assign_stack_slot_num_and_sort_pseudos ()
static void remove_pseudos ()
static void spill_pseudos ()
bool lra_need_for_spills_p ()
void lra_spill ()
static bool alter_subregs ()
void lra_final_code_change ()

Variables

static int regs_num
static rtxspill_hard_reg
static struct pseudo_slotpseudo_slots
static struct slotslots
static int slots_num

Function Documentation

static bool alter_subregs ( )
static
Apply alter_subreg for subregs of regs in *LOC.  Use FINAL_P for
   alter_subreg calls. Return true if any subreg of reg is
   processed.   

References alter_subreg().

Referenced by lra_final_code_change().

static void assign_mem_slot ( )
static
Set up memory of the spilled pseudo I.  The function can allocate
   the corresponding stack slot if it is not done yet.   

References assign_stack_local(), lra_eliminate_regs_1(), lra_reg_info, pseudo_slot::mem, slot::mem, min_align(), mode_for_size(), reg_renumber, regno_reg_rtx, set_mem_attrs_for_spill(), and pseudo_slot::slot_num.

Referenced by lra_spill().

static int assign_spill_hard_regs ( )
static
Assign spill hard registers to N pseudos in PSEUDO_REGNOS which is
   sorted in order of highest frequency first.  Put the pseudos which
   did not get a spill hard register at the beginning of array
   PSEUDO_REGNOS.  Return the number of such pseudos.   

References add_to_hard_reg_set(), lra_reg::biggest_mode, bitmap_bit_p(), bitmap_clear(), bitmap_intersect_compl_p(), bitmap_set_bit(), df_set_regs_ever_live(), free(), gen_raw_REG(), slot::hard_regno, slot::live_ranges, lra_dump_file, lra_get_allocno_class(), lra_get_regno_hard_regno(), lra_live_max_point, lra_no_alloc_regs, lra_reg_info, lra_reg_spill_p, lra_live_range::next, nr, overlaps_hard_reg_set_p(), reg_obstack, slot::regno, regs_num, regstat_get_setjmp_crosses(), spill_hard_reg, lra_live_range::start, and targetm.

Referenced by lra_spill().

static void assign_stack_slot_num_and_sort_pseudos ( )
static
Assign stack slot numbers to pseudos in array PSEUDO_REGNOS of
   length N.  Sort pseudos in PSEUDO_REGNOS for subsequent assigning
   memory stack slots.   

References add_pseudo_to_slot(), slot::hard_regno, slot::live_ranges, lra_intersected_live_ranges_p(), lra_reg_info, slot::mem, pseudo_reg_slot_compare(), slot::regno, and slots_num.

Referenced by lra_spill().

bool lra_need_for_spills_p ( void  )
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().

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

static int pseudo_reg_slot_compare ( )
static
Sort pseudos according to their slots, putting the slots in the order
   that they should be allocated.  Slots with lower numbers have the highest
   priority and should get the smallest displacement from the stack or
   frame pointer (whichever is being used).

   The first allocated slot is always closest to the frame pointer,
   so prefer lower slot numbers when frame_pointer_needed.  If the stack
   and frame grow in the same direction, then the first allocated slot is
   always closest to the initial stack pointer and furthest away from the
   final stack pointer, so allocate higher numbers first when using the
   stack pointer in that case.  The reverse is true if the stack and
   frame grow in opposite directions.   

References lra_reg_info, and pseudo_slot::slot_num.

Referenced by assign_stack_slot_num_and_sort_pseudos().

static int regno_freq_compare ( )
static
Sort pseudos according their usage frequencies.   

References lra_reg_info.

Referenced by lra_spill().

static void remove_pseudos ( )
static
Recursively process LOC in INSN and change spilled pseudos to the
   corresponding memory or spilled hard reg.  Ignore spilled pseudos
   created from the scratches.   

References copy_rtx(), lra_former_scratch_p(), lra_get_regno_hard_regno(), pseudo_slot::mem, and spill_hard_reg.

Referenced by lra_undo_inheritance(), and spill_pseudos().

static void spill_pseudos ( )
static
Convert spilled pseudos into their stack slots or spill hard regs,
   put insns to process on the constraint stack (that is all insns in
   which pseudos were changed to memory or spill hard regs).    

References bitmap_and_compl_into(), bitmap_bit_p(), bitmap_clear(), bitmap_ior_into(), bitmap_set_bit(), df_get_live_in(), df_get_live_out(), lra_dump_file, lra_former_scratch_p(), lra_get_regno_hard_regno(), lra_push_insn(), lra_reg_info, lra_reg_spill_p, lra_set_used_insn_alternative(), reg_obstack, regs_num, remove_pseudos(), spilled_pseudos, and targetm.

Referenced by lra_spill().


Variable Documentation

struct pseudo_slot* pseudo_slots
static
The stack slots for each spilled pseudo.  Indexed by regnos.        

Referenced by lra_spill().

int regs_num
static
@verbatim Change pseudos by memory.

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 for a pass to change spilled pseudos into
   memory.

   The pass creates necessary stack slots and assigns spilled pseudos
   to the stack slots in following way:

   for all spilled pseudos P most frequently used first do
     for all stack slots S do
       if P doesn't conflict with pseudos assigned to S then
         assign S to P and goto to the next pseudo process
       end
     end
     create new stack slot S and assign P to S
   end

   The actual algorithm is bit more complicated because of different
   pseudo sizes.

   After that the code changes spilled pseudos (except ones created
   from scratches) by corresponding stack slot memory in RTL.

   If at least one stack slot was created, we need to run more passes
   because we have new addresses which should be checked and because
   the old address displacements might change and address constraints
   (or insn memory constraints) might not be satisfied any more.

   For some targets, the pass can spill some pseudos into hard
   registers of different class (usually into vector registers)
   instead of spilling them into memory if it is possible and
   profitable.  Spilling GENERAL_REGS pseudo into SSE registers for
   Intel Corei7 is an example of such optimization.  And this is
   actually recommended by Intel optimization guide.

   The file also contains code for final change of pseudos on hard
   regs correspondingly assigned to them.   
Max regno at the start of the pass.      

Referenced by assign_spill_hard_regs(), lra_eliminate(), lra_spill(), and spill_pseudos().

struct slot* slots
static
Array containing info about the stack slots.       The array element is
   indexed by the stack slot number in the range [0..slots_num).   

Referenced by change_stack(), pointer_map< T >::insert(), make_return_insns(), pointer_map< T >::pointer_map(), pointer_map< T >::traverse(), and pointer_map< T >::~pointer_map().

int slots_num
static
The number of the stack slots currently existing.   

Referenced by assign_stack_slot_num_and_sort_pseudos(), and lra_spill().

rtx* spill_hard_reg
static
Map spilled regno -> hard regno used instead of memory for
   spilling.   

Referenced by assign_spill_hard_regs(), lra_spill(), reload(), and remove_pseudos().