GCC Middle and Back End API Reference
ira-emit.c File Reference

Data Structures

struct  move

Typedefs

typedef void * void_p
typedef struct movemove_t

Functions

void ira_initiate_emit_data ()
void ira_finish_emit_data ()
static ira_allocno_t create_new_allocno ()
static move_t create_move ()
static void free_move ()
static void free_move_list ()
static bool eq_move_lists_p ()
static void print_move_list ()
void ira_debug_move_list (move_t list)
void ira_debug_move_list ()
static bool change_regs ()
static void add_to_edge_list ()
rtx ira_create_new_reg ()
static bool subloop_tree_node_p ()
static void set_allocno_reg ()
static bool entered_from_non_parent_p ()
static void setup_entered_from_non_parent_p ()
static bool store_can_be_removed_p ()
static void generate_edge_moves ()
static void change_loop ()
static void set_allocno_somewhere_renamed_p ()
static bool eq_edge_move_lists_p ()
static void unify_moves ()
static void traverse_moves ()
static move_t modify_move_list ()
static rtx emit_move_list ()
static void emit_moves ()
static void update_costs ()
static void add_range_and_copies_from_move_list (move_t list, ira_loop_tree_node_t node, bitmap live_through, int freq)
static void add_ranges_and_copies ()
void ira_emit ()

Variables

ira_emit_data_t ira_allocno_emit_data
static vec< void_pnew_allocno_emit_data_vec
static move_tat_bb_start
static move_tat_bb_end
static int max_regno_before_changing
static bitmap local_allocno_bitmap
static bitmap used_regno_bitmap
static bitmap renamed_regno_bitmap
static move_t hard_regno_last_set [FIRST_PSEUDO_REGISTER]
static int hard_regno_last_set_check [FIRST_PSEUDO_REGISTER]
static move_tallocno_last_set
static int * allocno_last_set_check
static vec< move_tmove_vec
static int curr_tick

Typedef Documentation

typedef struct move* move_t
See comments below.   
typedef void* void_p
Definitions for vectors of pointers.   

Function Documentation

static void add_range_and_copies_from_move_list ( move_t  list,
ira_loop_tree_node_t  node,
bitmap  live_through,
int  freq 
)
static
Process moves from LIST with execution FREQ to add ranges, copies,
   and modify costs for allocnos involved in the moves.  All regnos
   living through the list is in LIVE_THROUGH, and the loop tree node
   used to find corresponding allocnos is NODE.   

References allocno_emit_reg(), bitmap_clear_bit(), live_range::finish, ira_allocno_copy::first, move::from, hard_regs_live, move::insn, internal_flag_ira_verbose, ior_hard_reg_conflicts(), ira_add_allocno_copy(), ira_add_live_range_to_object(), ira_allocate_object_conflicts(), ira_dump_file, ira_max_point, move::next, nr, ira_allocno_copy::num, ira_loop_tree_node::regno_allocno_map, ira_allocno_copy::second, live_range::start, move::to, and update_costs().

Referenced by add_ranges_and_copies().

static void add_ranges_and_copies ( )
static
Process all move list to add ranges, conflicts, copies, and modify
   costs for allocnos involved in the moves.   

References add_range_and_copies_from_move_list(), edge_def::aux, bitmap_and(), bitmap_copy(), edge_def::dest, df_get_live_in(), df_get_live_out(), basic_block_def::index, ira_allocate_bitmap(), ira_free_bitmap(), ira_loop_tree_node::parent, and basic_block_def::succs.

Referenced by ira_emit().

static void add_to_edge_list ( )
static
Attach MOVE to the edge E.  The move is attached to the head of the
   list if HEAD_P is TRUE.   

References edge_def::aux, last, and move::next.

Referenced by generate_edge_moves().

static bool change_regs ( )
static
This recursive function changes pseudo-registers in *LOC if it is
   necessary.  The function returns TRUE if a change was done.   

References allocno_emit_reg(), ira_curr_regno_allocno_map, and max_regno_before_changing.

Referenced by change_loop().

static move_t create_move ( )
static
Return new move of allocnos TO and FROM.   

References move::deps, move::deps_num, move::from, move::insn, ira_allocate(), move::next, move::to, and move::visited_p.

Referenced by generate_edge_moves(), and modify_move_list().

static ira_allocno_t create_new_allocno ( )
static
Create and return a new allocno with given REGNO and
   LOOP_TREE_NODE.  Allocate emit data for it.   

References ira_allocate(), ira_create_allocno(), and memset().

Referenced by modify_move_list().

static bool entered_from_non_parent_p ( )
static
Return true if there is an entry to given loop not from its parent
   (or grandparent) block.  For example, it is possible for two
   adjacent loops inside another loop.   

References ira_loop_tree_node::bb, ira_loop_tree_node::children, ira_loop_tree_node::next, ira_loop_tree_node::parent, basic_block_def::preds, and edge_def::src.

Referenced by setup_entered_from_non_parent_p().

static bool eq_edge_move_lists_p ( )
static
Return TRUE if move lists on all edges given in vector VEC are
   equal.   

References eq_move_lists_p().

Referenced by unify_moves().

static bool eq_move_lists_p ( )
static
Return TRUE if the move list LIST1 and LIST2 are equal (two
   moves are equal if they involve the same allocnos).   

References move::from, move::next, and move::to.

Referenced by eq_edge_move_lists_p().

static void free_move ( )
static
Free memory for MOVE and its dependencies.   

References move::deps, and ira_free().

Referenced by free_move_list().

static void free_move_list ( )
static
Free memory for list of the moves given by its HEAD.   

References free_move(), and move::next.

Referenced by ira_emit(), and unify_moves().

static void generate_edge_moves ( )
static
Generate and attach moves to the edge E.  This looks at the final
   regnos of allocnos living on the edge with the same original regno
   to figure out when moves should be generated.   

References add_to_edge_list(), allocno_emit_reg(), edge_def::aux, bitmap_bit_p(), create_move(), edge_def::dest, df_get_live_in(), df_get_live_out(), internal_flag_ira_verbose, ira_dump_file, ira_loop_tree_node::parent, ira_loop_tree_node::regno_allocno_map, edge_def::src, and store_can_be_removed_p().

Referenced by ira_emit().

rtx ira_create_new_reg ( )
Create and return new pseudo-register with the same attributes as
   ORIGINAL_REG.   

References gen_reg_rtx(), internal_flag_ira_verbose, ira_dump_file, and ira_expand_reg_equiv().

Referenced by change_loop(), find_moveable_pseudos(), and modify_move_list().

void ira_debug_move_list ( move_t  list)
void ira_debug_move_list ( )
Print move list LIST into stderr.   

References print_move_list().

void ira_finish_emit_data ( void  )
Free the emit data.   

References ira_free().

Referenced by ira().

void ira_initiate_emit_data ( void  )
Allocate and initiate the emit data.   

References ira_allocate(), ira_allocnos_num, and memset().

Referenced by ira().

static move_t modify_move_list ( )
static
Remove unnecessary moves in the LIST, makes topological sorting,
   and removes cycles on hard reg dependencies by introducing new
   allocnos assigned to memory and additional moves.  It returns the
   result move list.   

References allocno_emit_reg(), create_move(), create_new_allocno(), curr_tick, move::deps, move::deps_num, first, move::from, hard_regno_last_set_check, internal_flag_ira_verbose, ira_allocate(), ira_create_allocno_objects(), ira_create_new_reg(), ira_dump_file, ira_move_loops_num, ira_objects_num, ira_set_allocno_class(), last, move::next, move::to, and traverse_moves().

Referenced by emit_moves().

static void print_move_list ( )
static
Print move list LIST into file F.   

References move::from, move::next, and move::to.

Referenced by ira_debug_move_list().

static void set_allocno_reg ( )
static
Set up member `reg' to REG for allocnos which has the same regno as
   ALLOCNO and which are inside the loop corresponding to ALLOCNO.  

References ira_regno_allocno_map, ira_loop_tree_node::parent, ira_loop_tree_node::regno_allocno_map, and subloop_tree_node_p().

Referenced by change_loop().

static void set_allocno_somewhere_renamed_p ( )
static
Process to set up flag somewhere_renamed_p.   

References allocno_emit_reg(), and bitmap_bit_p().

Referenced by ira_emit().

static void setup_entered_from_non_parent_p ( )
static
Set up ENTERED_FROM_NON_PARENT_P for each loop region.   

References cfun, ira_loop_tree_node::entered_from_non_parent_p, entered_from_non_parent_p(), get_loops(), and ira_loop_nodes.

Referenced by ira_emit().

static bool store_can_be_removed_p ( )
static
Return TRUE if move of SRC_ALLOCNO (assigned to hard register) to
   DEST_ALLOCNO (assigned to memory) can be removed because it does
   not change value of the destination.  One possible reason for this
   is the situation when SRC_ALLOCNO is not modified in the
   corresponding loop.   

References allocno_emit_reg(), bitmap_bit_p(), ira_loop_tree_node::entered_from_non_parent_p, ira_loop_tree_node::modified_regnos, ira_loop_tree_node::parent, and ira_loop_tree_node::regno_allocno_map.

Referenced by generate_edge_moves().

static bool subloop_tree_node_p ( )
static
Return TRUE if loop given by SUBNODE inside the loop given by
   NODE.   

References ira_loop_tree_node::parent.

Referenced by set_allocno_reg().

static void traverse_moves ( )
static
This recursive function traverses dependencies of MOVE and produces
   topological sorting (in depth-first order).   

References move::deps, move::deps_num, and move::visited_p.

Referenced by modify_move_list().

static void unify_moves ( )
static
Look at all entry edges (if START_P) or exit edges of basic block
   BB and put move lists at the BB start or end if it is possible.  In
   other words, this decreases code duplication of allocno moves.   

References edge_def::aux, control_flow_insn_p(), eq_edge_move_lists_p(), free_move_list(), basic_block_def::index, basic_block_def::preds, and basic_block_def::succs.

Referenced by ira_emit().

static void update_costs ( )
static
Update costs of A and corresponding allocnos on upper levels on the
   loop tree from reading (if READ_P) or writing A on an execution
   path with FREQ.   

References ira_loop_tree_node::regno_allocno_map.

Referenced by add_range_and_copies_from_move_list().


Variable Documentation

move_t* allocno_last_set
static
Last move (in move sequence being processed) setting up the
   corresponding allocno.   
int* allocno_last_set_check
static
If the element value is equal to CURR_TICK then the corresponding
   element in . `allocno_last_set' is defined and correct.   

Referenced by ira_emit().

move_t * at_bb_end
static
move_t* at_bb_start
static
Array of moves (indexed by BB index) which should be put at the
   start/end of the corresponding basic blocks.   
int curr_tick
static
The variable value is used to check correctness of values of
   elements of arrays `hard_regno_last_set' and
   `allocno_last_set_check'.   

Referenced by ira_emit(), and modify_move_list().

move_t hard_regno_last_set[FIRST_PSEUDO_REGISTER]
static
Last move (in move sequence being processed) setting up the
   corresponding hard register.   
int hard_regno_last_set_check[FIRST_PSEUDO_REGISTER]
static
If the element value is equal to CURR_TICK then the corresponding
   element in `hard_regno_last_set' is defined and correct.   

Referenced by ira_emit(), and modify_move_list().

ira_emit_data_t ira_allocno_emit_data
@verbatim Integrated Register Allocator.  Changing code and generating moves.

Copyright (C) 2006-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/.

When we have more one region, we need to change the original RTL
   code after coloring.  Let us consider two allocnos representing the
   same pseudo-register outside and inside a region respectively.
   They can get different hard-registers.  The reload pass works on
   pseudo registers basis and there is no way to say the reload that
   pseudo could be in different registers and it is even more
   difficult to say in what places of the code the pseudo should have
   particular hard-registers.  So in this case IRA has to create and
   use a new pseudo-register inside the region and adds code to move
   allocno values on the region's borders.  This is done by the code
   in this file.

   The code makes top-down traversal of the regions and generate new
   pseudos and the move code on the region borders.  In some
   complicated cases IRA can create a new pseudo used temporarily to
   move allocno values when a swap of values stored in two
   hard-registers is needed (e.g. two allocnos representing different
   pseudos outside region got respectively hard registers 1 and 2 and
   the corresponding allocnos inside the region got respectively hard
   registers 2 and 1).  At this stage, the new pseudo is marked as
   spilled.

   IRA still creates the pseudo-register and the moves on the region
   borders even when the both corresponding allocnos were assigned to
   the same hard-register.  It is done because, if the reload pass for
   some reason spills a pseudo-register representing the original
   pseudo outside or inside the region, the effect will be smaller
   because another pseudo will still be in the hard-register.  In most
   cases, this is better then spilling the original pseudo in its
   whole live-range.  If reload does not change the allocation for the
   two pseudo-registers, the trivial move will be removed by
   post-reload optimizations.

   IRA does not generate a new pseudo and moves for the allocno values
   if the both allocnos representing an original pseudo inside and
   outside region assigned to the same hard register when the register
   pressure in the region for the corresponding pressure class is less
   than number of available hard registers for given pressure class.

   IRA also does some optimizations to remove redundant moves which is
   transformed into stores by the reload pass on CFG edges
   representing exits from the region.

   IRA tries to reduce duplication of code generated on CFG edges
   which are enters and exits to/from regions by moving some code to
   the edge sources or destinations when it is possible.   
Data used to emit live range split insns and to flattening IR.   
bitmap local_allocno_bitmap
static
Bitmap of allocnos local for the current loop.   
int max_regno_before_changing
static
Max regno before renaming some pseudo-registers.  For example, the
   same pseudo-register can be renamed in a loop if its allocation is
   different outside the loop.   

Referenced by change_regs(), and ira_emit().

vec<move_t> move_vec
static
Definition of vector of moves.   
This vec contains moves sorted topologically (depth-first) on their
   dependency graph.   
vec<void_p> new_allocno_emit_data_vec
static
Pointers to data allocated for allocnos being created during
   emitting.  Usually there are quite few such allocnos because they
   are created only for resolving loop in register shuffling.   
bitmap renamed_regno_bitmap
static
This bitmap contains regnos of allocnos which were renamed locally
   because the allocnos correspond to disjoint live ranges in loops
   with a common parent.   
bitmap used_regno_bitmap
static
This bitmap is used to find that we need to generate and to use a
   new pseudo-register when processing allocnos with the same original
   regno.