GCC Middle and Back End API Reference
sel-sched.c File Reference

Data Structures

struct  rtx_search_arg
struct  hard_regs_data
struct  reg_rename
struct  cmpd_local_params
struct  moveop_static_params
struct  fur_static_params
struct  code_motion_path_driver_info_def

Typedefs

typedef struct rtx_search_argrtx_search_arg_p
typedef struct fur_static_paramsfur_static_params_p
typedef struct cmpd_local_paramscmpd_local_params_p
typedef struct
moveop_static_params
moveop_static_params_p
typedef vec< vinsn_tvinsn_vec_t

Enumerations

enum  MOVEUP_EXPR_CODE { MOVEUP_EXPR_SAME, MOVEUP_EXPR_AS_RHS, MOVEUP_EXPR_NULL, MOVEUP_EXPR_CHANGED }

Functions

static bool rtx_ok_for_substitution_p (rtx, rtx)
static int sel_rank_for_schedule (const void *, const void *)
static av_set_t find_sequential_best_exprs (bnd_t, expr_t, bool)
static basic_block find_block_for_bookkeeping (edge e1, edge e2, bool lax)
static rtx get_dest_from_orig_ops (av_set_t)
static basic_block generate_bookkeeping_insn (expr_t, edge, edge)
static bool find_used_regs (insn_t, av_set_t, regset, struct reg_rename *, def_list_t *)
static bool move_op (insn_t, av_set_t, expr_t, rtx, expr_t, bool *)
static int code_motion_path_driver (insn_t, av_set_t, ilist_t, cmpd_local_params_p, void *)
static void sel_sched_region_1 (void)
static void sel_sched_region_2 (int)
static av_set_t compute_av_set_inside_bb (insn_t, ilist_t, int, bool)
static void debug_state (state_t)
static void advance_one_cycle ()
static bool in_fallthru_bb_p ()
static void extract_new_fences_from (flist_t old_fences, flist_tail_t new_fences, int orig_max_seqno)
static bool can_substitute_through_p ()
static bool substitute_reg_in_expr ()
static int count_occurrences_1 ()
static int count_occurrences_equiv ()
static bool rtx_ok_for_substitution_p ()
static rtx create_insn_rtx_with_rhs ()
static bool replace_src_with_reg_ok_p ()
static bool replace_dest_with_reg_ok_p ()
static rtx create_insn_rtx_with_lhs ()
static void replace_dest_with_reg_in_expr ()
static bool vinsn_writes_one_of_regs_p (vinsn_t vi, regset used_regs, HARD_REG_SET unavailable_hard_regs)
static enum reg_class get_reg_class ()
static void init_hard_regno_rename ()
static bool sel_hard_regno_rename_ok ()
static void init_regs_for_mode ()
static void init_hard_regs_data ()
static void mark_unavailable_hard_regs (def_t def, struct reg_rename *reg_rename_p, regset used_regs)
static rtx choose_best_reg_1 (HARD_REG_SET hard_regs_used, struct reg_rename *reg_rename_p, def_list_t original_insns, bool *is_orig_reg_p_ptr)
static rtx choose_best_reg (HARD_REG_SET hard_regs_used, struct reg_rename *reg_rename_p, def_list_t original_insns, bool *is_orig_reg_p_ptr)
static rtx choose_best_pseudo_reg (regset used_regs, struct reg_rename *reg_rename_p, def_list_t original_insns, bool *is_orig_reg_p_ptr)
static void verify_target_availability (expr_t expr, regset used_regs, struct reg_rename *reg_rename_p)
static void collect_unavailable_regs_from_bnds (expr_t expr, blist_t bnds, regset used_regs, struct reg_rename *reg_rename_p, def_list_t *original_insns)
static bool try_replace_dest_reg ()
static bool find_best_reg_for_expr ()
static bool can_speculate_dep_p ()
static insn_t create_speculation_check ()
static bool identical_copy_p ()
static void undo_transformations ()
static enum MOVEUP_EXPR_CODE moveup_expr_inside_insn_group ()
static bool moving_insn_creates_bookkeeping_block_p (insn_t insn, insn_t through_insn)
static bool implicit_clobber_conflict_p ()
static enum MOVEUP_EXPR_CODE moveup_expr (expr_t expr, insn_t through_insn, bool inside_insn_group, enum local_trans_type *ptrans_type)
static bool try_bitmap_cache (expr_t expr, insn_t insn, bool inside_insn_group, enum MOVEUP_EXPR_CODE *res)
static bool try_transformation_cache (expr_t expr, insn_t insn, enum MOVEUP_EXPR_CODE *res)
static void update_bitmap_cache (expr_t expr, insn_t insn, bool inside_insn_group, enum MOVEUP_EXPR_CODE res)
static void update_transformation_cache (expr_t expr, insn_t insn, bool inside_insn_group, enum local_trans_type trans_type, vinsn_t expr_old_vinsn)
static enum MOVEUP_EXPR_CODE moveup_expr_cached ()
static void moveup_set_expr ()
static void moveup_set_inside_insn_group ()
static bool equal_after_moveup_path_p ()
static bool is_ineligible_successor ()
static av_set_t compute_av_set_at_bb_end ()
static av_set_t compute_av_set ()
static void propagate_lv_set ()
static regset compute_live_after_bb ()
regset compute_live ()
static void update_liveness_on_insn ()
static void compute_live_below_insn ()
static void update_data_sets ()
static ds_t get_spec_check_type_for_insn ()
static int sel_target_adjust_priority ()
static int sel_rank_for_schedule ()
static void process_pipelined_exprs ()
static void process_spec_exprs ()
static expr_t process_use_exprs ()
static bool vinsn_vec_has_expr_p ()
static bool av_set_could_be_blocked_by_bookkeeping_p ()
static void vinsn_vec_clear ()
static void vinsn_vec_add ()
static void vinsn_vec_free ()
void sel_add_to_insn_priority (rtx insn, int amount)
static bool fill_vec_av_set (av_set_t av, blist_t bnds, fence_t fence, int *pneed_stall)
static void convert_vec_av_set_to_ready ()
static expr_t fill_ready_list (av_set_t *av_ptr, blist_t bnds, fence_t fence, int *pneed_stall)
static bool sel_dfa_new_cycle ()
static int invoke_reorder_hooks ()
static expr_t find_expr_for_ready ()
static int invoke_dfa_lookahead_guard ()
static int calculate_privileged_insns ()
static int invoke_aftermath_hooks ()
static int estimate_insn_cost ()
static int get_expr_cost ()
static int choose_best_insn ()
static expr_t find_best_expr (av_set_t *av_vliw_ptr, blist_t bnds, fence_t fence, int *pneed_stall)
static insn_t emit_insn_from_expr_after (expr_t expr, vinsn_t vinsn, int seqno, insn_t place_to_insert)
static bool block_valid_for_bookkeeping_p ()
static basic_block find_block_for_bookkeeping ()
static basic_block create_block_for_bookkeeping ()
static insn_t find_place_for_bookkeeping ()
static int find_seqno_for_bookkeeping ()
static insn_t emit_bookkeeping_insn ()
static basic_block generate_bookkeeping_insn ()
static void remove_insns_that_need_bookkeeping ()
static void move_cond_jump ()
static void remove_temp_moveop_nops ()
static void remove_insns_for_debug ()
static void compute_av_set_on_boundaries ()
static av_set_t find_sequential_best_exprs ()
static void move_nop_to_previous_block ()
static insn_t prepare_place_to_insert ()
static bool move_exprs_to_boundary (bnd_t bnd, expr_t expr_vliw, av_set_t expr_seq, expr_t c_expr)
static void debug_state ()
static bool advance_state_on_fence ()
static void update_fence_and_insn ()
static blist_tupdate_boundaries (fence_t fence, bnd_t bnd, insn_t insn, blist_t *bndsp, blist_t *bnds_tailp)
static insn_t schedule_expr_on_boundary ()
static void stall_for_cycles ()
static void fill_insns ()
static rtx get_dest_from_orig_ops ()
static void update_and_record_unavailable_insns ()
static void move_op_merge_succs (insn_t insn, insn_t succ, int moveop_drv_call_res, cmpd_local_params_p lparams, void *static_params)
static void fur_merge_succs (insn_t insn, insn_t succ, int moveop_drv_call_res, cmpd_local_params_p lparams, void *static_params)
static void move_op_after_merge_succs ()
static void track_scheduled_insns_and_blocks ()
static bool maybe_emit_renaming_copy (rtx insn, moveop_static_params_p params)
static bool maybe_emit_speculative_check (rtx insn, expr_t expr, moveop_static_params_p params)
static bool handle_emitting_transformations (rtx insn, expr_t expr, moveop_static_params_p params)
static bool need_nop_to_preserve_insn_bb ()
static void remove_insn_from_stream ()
static void move_op_orig_expr_found (insn_t insn, expr_t expr, cmpd_local_params_p lparams, void *static_params)
static void fur_orig_expr_found (insn_t insn, expr_t expr, cmpd_local_params_p lparams, void *static_params)
static void move_op_at_first_insn (insn_t insn, cmpd_local_params_p lparams, void *static_params)
static void fur_at_first_insn (insn_t insn, cmpd_local_params_p lparams, void *static_params)
static void move_op_ascend ()
static int fur_on_enter (insn_t insn, cmpd_local_params_p local_params, void *static_params, bool visited_p)
static int move_op_on_enter (insn_t insn, cmpd_local_params_p local_params, void *static_params, bool visited_p)
static bool move_op_orig_expr_not_found (insn_t insn, av_set_t orig_ops, void *static_params)
static bool fur_orig_expr_not_found ()
static int code_motion_process_successors (insn_t insn, av_set_t orig_ops, ilist_t path, void *static_params)
static void code_motion_path_driver_cleanup ()
static void init_seqno_1 ()
static int init_seqno ()
static void sel_setup_region_sched_flags ()
static bool current_region_empty_p ()
static void setup_current_loop_nest ()
static void sel_compute_priorities ()
static bool sel_region_init ()
static void simplify_changed_insns ()
static void find_ebb_boundaries ()
static void reset_sched_cycles_in_current_ebb ()
static void put_TImodes ()
static void sel_region_target_finish ()
static void sel_region_finish ()
static void schedule_on_fences (flist_t fences, int max_seqno, ilist_t **scheduled_insns_tailpp)
static void find_min_max_seqno ()
static flist_t calculate_new_fences ()
static int update_seqnos_and_stage (int min_seqno, int max_seqno, int highest_seqno_in_use, ilist_t *pscheduled_insns)
static void sel_sched_region_2 ()
void sel_sched_region ()
static void sel_global_init ()
static void sel_global_finish ()
bool maybe_skip_selective_scheduling ()
void run_selective_scheduling ()

Variables

bool pipelining_p
bool bookkeeping_p
int max_insns_to_rename
static struct hard_regs_data sel_hrd
struct
code_motion_path_driver_info_def
code_motion_path_driver_info
struct
code_motion_path_driver_info_def
move_op_hooks 
fur_hooks
int sched_emulate_haifa_p
int global_level
flist_t fences
static bool enable_schedule_as_rhs_p
static bool scheduled_something_on_previous_fence
static int first_emitted_uid
static bitmap_head _forced_ebb_heads
bitmap_headforced_ebb_heads = &_forced_ebb_heads
bitmap blocks_to_reschedule = NULL
static bool ignore_first = false
static int max_issue_size = 0
static int can_issue_more
static int max_ws
static int num_insns_scheduled
static vec< expr_tvec_av_set = vNULL
static vinsn_vec_t vec_bookkeeping_blocked_vinsns = vinsn_vec_t()
static vinsn_vec_t vec_target_unavailable_vinsns = vinsn_vec_t()
static vec< insn_tvec_temp_moveop_nops = vNULL
static bitmap current_originators = NULL
static bitmap current_copies = NULL
static bitmap code_motion_visited_blocks = NULL
static int stat_bookkeeping_copies
static int stat_insns_needed_bookkeeping
static int stat_renamed_scheduled
static int stat_substitutions_total
static int reg_rename_tick [FIRST_PSEUDO_REGISTER]
static int reg_rename_this_tick
static bool was_target_conflict = false
static int max_uid_before_move_op = 0
struct
code_motion_path_driver_info_def 
move_op_hooks
static int cur_seqno

Typedef Documentation

A vector of vinsns is used to hold temporary lists of vinsns.   

Enumeration Type Documentation

Definitions of local types and macros.   
Represents possible outcomes of moving an expression through an insn.   
Enumerator:
MOVEUP_EXPR_SAME 
MOVEUP_EXPR_AS_RHS 
MOVEUP_EXPR_NULL 
MOVEUP_EXPR_CHANGED 

Function Documentation

static void advance_one_cycle ( )
static
static bool advance_state_on_fence ( )
static
Advance state on FENCE with INSN.  Return true if INSN is
   an ASM, and we should advance state once more.   

References advance_one_cycle(), can_issue_more, debug_state(), dfa_state_size, issue_rate, memcpy(), recog_memoized(), and sched_verbose.

Referenced by update_fence_and_insn().

static bool av_set_could_be_blocked_by_bookkeeping_p ( )
static
Return true if either of expressions from ORIG_OPS can be blocked
   by previously created bookkeeping code.  STATIC_PARAMS points to static
   parameters of move_op.   

References bitmap_bit_p(), moveop_static_params::dest, moveop_static_params::failed_insn, move_op_hooks, moveup_expr_cached(), MOVEUP_EXPR_NULL, register_unavailable_p(), and vinsn_vec_has_expr_p().

Referenced by code_motion_process_successors().

static bool block_valid_for_bookkeeping_p ( )
static
Return TRUE if BB can hold bookkeeping code.   

References in_current_region_p(), and basic_block_def::succs.

Referenced by find_block_for_bookkeeping().

static flist_t calculate_new_fences ( )
static
static int calculate_privileged_insns ( )
static
Calculate the number of privileged insns and return it.   

References find_expr_for_ready(), ready_list::n_ready, ready, ready_try, sched_verbose, and sel_print().

Referenced by find_best_expr().

static bool can_speculate_dep_p ( )
static
Return true if dependence described by DS can be overcomed.   

References spec_info_def::data_weakness_cutoff, ds_weak(), spec_info_def::mask, and spec_info.

Referenced by moveup_expr().

static bool can_substitute_through_p ( )
static
Functions to support substitution.   
Returns whether INSN with dependence status DS is eligible for
   substitution, i.e. it's a copy operation x := y, and RHS that is
   moved up through this insn should be substituted.   

Referenced by moveup_expr(), and moveup_expr_inside_insn_group().

static int choose_best_insn ( )
static
Find the best insn for scheduling, either via max_issue or just take
   the most prioritized available.   

References can_issue_more, cycle_issued_insns, dfa_lookahead, find_expr_for_ready(), get_expr_cost(), max_issue(), ready_list::n_ready, ready, sched_verbose, and sel_print().

Referenced by find_best_expr().

static rtx choose_best_pseudo_reg ( regset  used_regs,
struct reg_rename reg_rename_p,
def_list_t  original_insns,
bool *  is_orig_reg_p_ptr 
)
static
Choose the pseudo register for storing rhs value.  As this is supposed
   to work before reload, we return either the original register or make
   the new one.  The parameters are the same that in choose_nest_reg_1
   functions, except that USED_REGS may contain pseudos.
   If we work with hard regs, check also REG_RENAME_P->UNAVAILABLE_HARD_REGS.

   TODO: take into account register pressure while doing this.  Up to this
   moment, this function would never return NULL for pseudos, but we should
   not rely on this.   

References reg_rename::crosses_call, df_regs_ever_live_p(), gen_reg_rtx(), gen_rtx_REG(), max_reg_num(), max_regno, maybe_extend_reg_info_p(), _def::orig_insn, reload_completed, and reg_rename::unavailable_hard_regs.

Referenced by find_best_reg_for_expr().

static rtx choose_best_reg ( HARD_REG_SET  hard_regs_used,
struct reg_rename reg_rename_p,
def_list_t  original_insns,
bool *  is_orig_reg_p_ptr 
)
static
A wrapper around choose_best_reg_1 () to verify that we make correct
   assumptions about available registers in the function.   

References choose_best_reg_1(), hard_regs_data::regs_ever_used, and sel_hrd.

Referenced by find_best_reg_for_expr().

static rtx choose_best_reg_1 ( HARD_REG_SET  hard_regs_used,
struct reg_rename reg_rename_p,
def_list_t  original_insns,
bool *  is_orig_reg_p_ptr 
)
static
Choose the register among free, that is suitable for storing
   the rhs value.

   ORIGINAL_INSNS is the list of insns where the operation (rhs)
   originally appears.  There could be multiple original operations
   for single rhs since we moving it up and merging along different
   paths.

   Some code is adapted from regrename.c (regrename_optimize).
   If original register is available, function returns it.
   Otherwise it performs the checks, so the new register should
   comply with the following:
    - it should not violate any live ranges (such registers are in
      REG_RENAME_P->available_for_renaming set);
    - it should not be in the HARD_REGS_USED regset;
    - it should be in the class compatible with original uses;
    - it should not be clobbered through reference with different mode;
    - if we're in the leaf function, then the new register should
      not be in the LEAF_REGISTERS;
    - etc.

   If several registers meet the conditions, the register with smallest
   tick is returned to achieve more even register allocation.

   If original register seems to be ok, we set *IS_ORIG_REG_P_PTR to true.

   If no register satisfies the above conditions, NULL_RTX is returned.   

References reg_rename::available_for_renaming, gen_rtx_REG(), rtx_search_arg::n, _def::orig_insn, and reg_rename_tick.

Referenced by choose_best_reg().

static int code_motion_path_driver ( insn_t  insn,
av_set_t  orig_ops,
ilist_t  path,
cmpd_local_params_p  local_params_in,
void *  static_params 
)
static
The driver function that implements move_op or find_used_regs
   functionality dependent whether code_motion_path_driver_INFO is set to
   &MOVE_OP_HOOKS or &FUR_HOOKS.  This function implements the common parts
   of code (CFG traversal etc) that are shared among both functions.  INSN
   is the insn we're starting the search from, ORIG_OPS are the expressions
   we're searching for, PATH is traversed path, LOCAL_PARAMS_IN are local
   parameters of the driver, and STATIC_PARAMS are static parameters of
   the caller.

   Returns whether original instructions were found.  Note that top-level
   code_motion_path_driver always returns true.   

References code_motion_path_driver_info_def::ascend, code_motion_path_driver_info_def::at_first_insn, av_set_clear(), av_set_code_motion_filter(), av_set_copy(), av_set_leave_one_nonspec(), av_set_lookup(), bitmap_bit_p(), bitmap_set_bit(), code_motion_path_driver_cleanup(), code_motion_process_successors(), dump_av_set(), dump_insn(), basic_block_def::index, is_ineligible_successor(), code_motion_path_driver_info_def::on_enter, code_motion_path_driver_info_def::orig_expr_found, code_motion_path_driver_info_def::orig_expr_not_found, cmpd_local_params::removed_last_insn, code_motion_path_driver_info_def::routine_name, sched_verbose, sel_bb_end(), sel_bb_end_p(), sel_bb_head(), sel_bb_head_p(), sel_print(), and undo_transformations().

Referenced by code_motion_process_successors(), find_used_regs(), and move_op().

static void code_motion_path_driver_cleanup ( )
inlinestatic
Perform a cleanup when the driver is about to terminate.  ORIG_OPS_P
   is the pointer to the av set with expressions we were looking for,
   PATH_P is the pointer to the traversed path.   

References av_set_clear().

Referenced by code_motion_path_driver().

static int code_motion_process_successors ( insn_t  insn,
av_set_t  orig_ops,
ilist_t  path,
void *  static_params 
)
static
Traverse all successors of INSN.  For each successor that is SUCCS_NORMAL
   code_motion_path_driver is called recursively.  Original operation
   was found at least on one path that is starting with one of INSN's
   successors (this fact is asserted).  ORIG_OPS is expressions we're looking
   for, PATH is the path we've traversed, STATIC_PARAMS is the parameters
   of either move_op or find_used_regs depending on the caller.

   Return 0 if we haven't found expression, 1 if we found it, -1 if we don't
   know for sure at this point.   

References code_motion_path_driver_info_def::after_merge_succs, av_set_could_be_blocked_by_bookkeeping_p(), cmpd_local_params::c_expr_local, cmpd_local_params::c_expr_merged, code_motion_path_driver(), succ_iterator::current_flags, cmpd_local_params::e1, succ_iterator::e1, cmpd_local_params::e2, succ_iterator::e2, basic_block_def::index, code_motion_path_driver_info_def::merge_succs, sched_verbose, sel_bb_end(), sel_print(), code_motion_path_driver_info_def::succ_flags, and basic_block_def::succs.

Referenced by code_motion_path_driver().

static void collect_unavailable_regs_from_bnds ( expr_t  expr,
blist_t  bnds,
regset  used_regs,
struct reg_rename reg_rename_p,
def_list_t original_insns 
)
static
Collect unavailable registers due to liveness for EXPR from BNDS
   into USED_REGS.  Save additional information about available
   registers and unavailable due to hardware restriction registers
   into REG_RENAME_P structure.  Save original insns into ORIGINAL_INSNS
   list.   

References av_set_clear(), av_set_is_in_p(), find_sequential_best_exprs(), and find_used_regs().

Referenced by find_best_reg_for_expr().

static av_set_t compute_av_set ( )
static
Compute av set before INSN.
   INSN - the current operation (actual rtx INSN)
   P - the current path, which is list of insns visited so far
   WS - software lookahead window size.
   UNIQUE_P - TRUE, if returned av_set will be changed, hence
   if we want to save computed av_set in s_i_d, we should make a copy of it.

   In the resulting set we will have only expressions that don't have delay
   stalls and nonsubstitutable dependences.   

References compute_av_set_inside_bb().

Referenced by compute_av_set_on_boundaries(), and update_data_sets().

static av_set_t compute_av_set_at_bb_end ( )
static
static av_set_t compute_av_set_inside_bb ( insn_t  first_insn,
ilist_t  p,
int  ws,
bool  need_copy_p 
)
static
This function computes av_set for the FIRST_INSN by dragging valid
   av_set through all basic block insns either from the end of basic block
   (computed using compute_av_set_at_bb_end) or from the insn on which
   MAX_WS was exceeded.  It uses compute_av_set_at_bb_end to compute av_set
   below the basic block and handling conditional branches.
   FIRST_INSN - the basic block head, P - path consisting of the insns
   traversed on the way to the FIRST_INSN (the path is sparse, only bb heads
   and bb ends are added to the path), WS - current window size,
   NEED_COPY_P - true if we'll make a copy of av_set before returning it.   

References av_set_add(), av_set_clear(), av_set_copy(), av_set_lookup(), clear_expr(), compute_av_set_at_bb_end(), copy_expr(), cur_insn, dump_av_set(), global_level, is_ineligible_successor(), max_ws, moveup_set_expr(), sched_verbose, sel_bb_end(), sel_bb_head_p(), and sel_print().

Referenced by compute_av_set(), and compute_av_set_at_bb_end().

static void compute_av_set_on_boundaries ( )
static
Compute available instructions on BNDS.  FENCE is the current fence.  Write
   the computed set to *AV_VLIW_P.   

References av_set_clear(), av_set_copy(), av_set_union_and_clear(), compute_av_set(), dump_av_set(), dump_blist(), moveup_set_inside_insn_group(), sched_verbose, sel_bb_head_p(), and sel_print().

Referenced by fill_insns().

regset compute_live ( )
Compute the set of all live registers at the point before INSN and save
   it at INSN if INSN is bb header.   

References compute_live_after_bb(), get_regset_from_pool(), ignore_first, in_current_region_p(), propagate_lv_set(), return_regset_to_pool(), and sel_bb_head_p().

static regset compute_live_after_bb ( )
static
static void compute_live_below_insn ( )
inlinestatic
Compute liveness below INSN and write it into REGS.   

References compute_live(), and si.

Referenced by fur_orig_expr_found().

static void convert_vec_av_set_to_ready ( )
static
Convert a vectored and sorted av set to the ready list that
   the rest of the backend wants to see.   

References ready_list::first, max_issue_size, ready_list::n_ready, ready, ready_try, sched_extend_ready_list(), and ready_list::vec.

Referenced by fill_ready_list().

static int count_occurrences_1 ( )
static
Helper function for count_occurences_equiv.   

References rtx_search_arg::n, and rtx_search_arg::x.

Referenced by count_occurrences_equiv().

static int count_occurrences_equiv ( )
static
Return the number of places WHAT appears within WHERE.
   Bail out when we found a reference occupying several hard registers.   

References count_occurrences_1(), for_each_rtx(), rtx_search_arg::n, and rtx_search_arg::x.

Referenced by rtx_ok_for_substitution_p().

static rtx create_insn_rtx_with_lhs ( )
static
Create a pattern with rhs of VI and lhs of LHS_RTX.   

References copy_rtx(), and create_insn_rtx_from_pattern().

Referenced by replace_dest_with_reg_in_expr().

static rtx create_insn_rtx_with_rhs ( )
static
Functions to support register renaming.   
Substitute VI's set source with REGNO.  Returns newly created pattern
   that has REGNO as its source.   

References copy_rtx(), and create_insn_rtx_from_pattern().

Referenced by maybe_emit_renaming_copy().

static insn_t create_speculation_check ( )
static
Get a speculation check instruction.
   C_EXPR is a speculative expression,
   CHECK_DS describes speculations that should be checked,
   ORIG_INSN is the original non-speculative insn in the stream.   

References bb_note(), copy_rtx(), create_insn_rtx_from_pattern(), ds_get_max_dep_weak(), sel_create_recovery_block(), sel_gen_insn_from_rtx_after(), sel_gen_recovery_insn_from_rtx_after(), sel_vinsn_cost(), speculate_expr(), and targetm.

Referenced by maybe_emit_speculative_check().

static bool current_region_empty_p ( )
static
Return true if all basic blocks of current region are empty.   

References current_nr_blocks, and sel_bb_empty_p().

Referenced by sel_region_init().

static void debug_state ( )
static
Debug a DFA state as an array of bytes.   

References dfa_state_size, and sel_print().

static insn_t emit_bookkeeping_insn ( )
static
Insert bookkeeping copy of C_EXPS's insn after PLACE_TO_INSERT, assigning
   NEW_SEQNO to it.  Return created insn.   

References bitmap_set_bit(), create_copy_of_insn_rtx(), create_vinsn_from_insn_rtx(), and emit_insn_from_expr_after().

Referenced by generate_bookkeeping_insn().

static insn_t emit_insn_from_expr_after ( expr_t  expr,
vinsn_t  vinsn,
int  seqno,
insn_t  place_to_insert 
)
static
Functions that implement the core of the scheduler.   
Emit an instruction from EXPR with SEQNO and VINSN after
   PLACE_TO_INSERT.   

References df_set_regs_ever_live(), expr_dest_regno(), reg_rename_this_tick, reg_rename_tick, and sel_gen_insn_from_expr_after().

Referenced by emit_bookkeeping_insn(), and schedule_expr_on_boundary().

static bool equal_after_moveup_path_p ( )
static
Returns true if after moving EXPR along PATH it equals to EXPR_VLIW.   

References clear_expr(), copy_expr_onside(), moveup_expr_cached(), MOVEUP_EXPR_NULL, and vinsn_equal_p().

Referenced by find_sequential_best_exprs().

static int estimate_insn_cost ( )
static
Estimate the cost of issuing INSN on DFA state STATE.   

References dfa_state_size, and memcpy().

Referenced by get_expr_cost(), and reset_sched_cycles_in_current_ebb().

static void extract_new_fences_from ( flist_t  old_fences,
flist_tail_t  new_fences,
int  orig_max_seqno 
)
static
Construct successor fences from OLD_FENCEs and put them in NEW_FENCES.
   When a successor will continue a ebb, transfer all parameters of a fence
   to the new fence.  ORIG_MAX_SEQNO is the maximal seqno before this round
   of scheduling helping to distinguish between the old and the new code.   

References add_clean_fence_to_fences(), add_dirty_fence_to_fences(), bitmap_set_bit(), in_fallthru_bb_p(), in_same_ebb_p(), move_fence_to_fences(), pipelining_p, sched_verbose, sel_bb_end_p(), sel_bb_head(), sel_print(), si, single_pred_p(), single_succ(), and single_succ_p().

Referenced by calculate_new_fences().

static void fill_insns ( )
static
static expr_t fill_ready_list ( av_set_t av_ptr,
blist_t  bnds,
fence_t  fence,
int *  pneed_stall 
)
static
Initialize ready list from *AV_PTR for the max_issue () call.
   If any unrecognizable insn found in *AV_PTR, return it (and skip
   max_issue).  BND and FENCE are current boundary and fence,
   respectively.  If we need to stall for some cycles before an expr
   from *AV_PTR would become available, write this number to *PNEED_STALL.   

References convert_vec_av_set_to_ready(), fill_vec_av_set(), ready_list::n_ready, process_pipelined_exprs(), process_spec_exprs(), process_use_exprs(), and ready.

Referenced by find_best_expr().

static bool fill_vec_av_set ( av_set_t  av,
blist_t  bnds,
fence_t  fence,
int *  pneed_stall 
)
static
Turn AV into a vector, filter inappropriate insns and sort it.  Return
   true if there is something to schedule.  BNDS and FENCE are current
   boundaries and fence, respectively.  If we need to stall for some cycles
   before an expr from AV would become available, write this number to
   *PNEED_STALL.   

References current_loop_nest, dump_expr(), find_best_reg_for_expr(), issue_rate, max_insns_to_rename, loop::ninsns, num_insns_scheduled, pipelining_p, sched_verbose, sel_insn_is_speculation_check(), sel_print(), sel_rank_for_schedule(), sel_target_adjust_priority(), sel_vinsn_cost(), si, tick_check_p(), vinsn_vec_has_expr_p(), and xrecalloc().

Referenced by fill_ready_list().

static expr_t find_best_expr ( av_set_t av_vliw_ptr,
blist_t  bnds,
fence_t  fence,
int *  pneed_stall 
)
static
Choose the best expr from *AV_VLIW_PTR and a suitable register for it.
   BNDS and FENCE are current boundaries and scheduling fence respectively.
   Return the expr found and NULL if nothing can be issued atm.
   Write to PNEED_STALL the number of cycles to stall if no expr was found.   

References calculate_privileged_insns(), can_issue_more, choose_best_insn(), dump_expr(), fill_ready_list(), find_expr_for_ready(), invoke_aftermath_hooks(), invoke_dfa_lookahead_guard(), invoke_reorder_hooks(), ready_list::n_ready, ready, sched_verbose, sel_print(), and targetm.

Referenced by fill_insns().

static bool find_best_reg_for_expr ( )
static
Select and assign best register to EXPR searching from BNDS.
   Set *IS_ORIG_REG_P to TRUE if original register was selected.
   Return FALSE if no register can be chosen, which could happen when:
   * EXPR_SEPARABLE_P is true but we were unable to find suitable register;
   * EXPR_SEPARABLE_P is false but the insn sets/clobbers one of the registers
     that are used on the moving path.   

References bitmap_empty_p(), choose_best_pseudo_reg(), choose_best_reg(), collect_unavailable_regs_from_bnds(), get_clear_regset_from_pool(), reload_completed, return_regset_to_pool(), sel_vinsn_cost(), try_replace_dest_reg(), reg_rename::unavailable_hard_regs, used_regs, verify_target_availability(), and vinsn_writes_one_of_regs_p().

Referenced by fill_vec_av_set().

static basic_block find_block_for_bookkeeping ( edge  e1,
edge  e2,
bool  lax 
)
static
static basic_block find_block_for_bookkeeping ( )
static
Attempt to find a block that can hold bookkeeping code for path(s) incoming
   into E2->dest, except from E1->src (there may be a sequence of empty basic
   blocks between E1->src and E2->dest).  Return found block, or NULL if new
   one must be created.  If LAX holds, don't assume there is a simple path
   from E1->src to E2->dest.   

References block_valid_for_bookkeeping_p(), edge_def::dest, basic_block_def::preds, edge_def::src, and basic_block_def::succs.

static void find_ebb_boundaries ( )
static
Find boundaries of the EBB starting from basic block BB, marking blocks of
   this EBB in SCHEDULED_BLOCKS and appropriately filling in HEAD, TAIL,
   PREV_HEAD, and NEXT_TAIL fields of CURRENT_SCHED_INFO structure.   

References bb_ends_ebb_p(), bb_next_bb(), bitmap_set_bit(), current_sched_info, get_ebb_head_tail(), haifa_sched_info::head, basic_block_def::index, haifa_sched_info::next_tail, haifa_sched_info::prev_head, sched_verbose, sel_print(), and haifa_sched_info::tail.

Referenced by sel_region_target_finish().

static expr_t find_expr_for_ready ( )
inlinestatic
Return an EXPR corresponding to INDEX element of ready list, if
   FOLLOW_READY_ELEMENT is true (i.e., an expr of
   ready_element (&ready, INDEX) will be returned), and to INDEX element of
   ready.vec otherwise.   

References ready_list::first, ready, and ready_list::vec.

Referenced by calculate_privileged_insns(), choose_best_insn(), find_best_expr(), and invoke_dfa_lookahead_guard().

static void find_min_max_seqno ( )
static
Calculate MIN_SEQNO and MAX_SEQNO.   

Referenced by sel_sched_region_2().

static insn_t find_place_for_bookkeeping ( )
static
Return insn after which we must insert bookkeeping code for path(s) incoming
   into E2->dest, except from E1->src.  If the returned insn immediately
   precedes a fence, assign that fence to *FENCE_TO_REWIND.   

References control_flow_insn_p(), create_block_for_bookkeeping(), find_block_for_bookkeeping(), flist_lookup(), basic_block_def::index, sched_verbose, sel_bb_head(), and sel_print().

Referenced by generate_bookkeeping_insn().

static int find_seqno_for_bookkeeping ( )
static
Find a proper seqno for bookkeeing insn inserted at PLACE_TO_INSERT
   for JOIN_POINT.    

References get_seqno_by_preds(), and pipelining_p.

Referenced by generate_bookkeeping_insn().

static av_set_t find_sequential_best_exprs ( bnd_t  ,
expr_t  ,
bool   
)
static
static av_set_t find_sequential_best_exprs ( )
static
Calculate the sequential av set on BND corresponding to the EXPR_VLIW
   expression.  When FOR_MOVEOP is true, also replace the register of
   expressions found with the register from EXPR_VLIW.   

References av_set_add(), dump_av_set(), equal_after_moveup_path_p(), expr_dest_regno(), replace_dest_with_reg_in_expr(), sched_verbose, sel_print(), stat_renamed_scheduled, and stat_substitutions_total.

static bool find_used_regs ( insn_t  insn,
av_set_t  orig_ops,
regset  used_regs,
struct reg_rename reg_rename_p,
def_list_t original_insns 
)
static
Find the set of registers that are unavailable for storing expres
   while moving ORIG_OPS up on the path starting from INSN due to
   liveness (USED_REGS) or hardware restrictions (REG_RENAME_P).

   All the original operations found during the traversal are saved in the
   ORIGINAL_INSNS list.

   REG_RENAME_P denotes the set of hardware registers that
   can not be used with renaming due to the register class restrictions,
   mode restrictions and other (the register we'll choose should be
   compatible class with the original uses, shouldn't be in call_used_regs,
   should be HARD_REGNO_RENAME_OK etc).

   Returns TRUE if we've found all original insns, FALSE otherwise.

   This function utilizes code_motion_path_driver (formerly find_used_regs_1)
   to traverse the code motion paths.  This helper function finds registers
   that are not available for storing expres while moving ORIG_OPS up on the
   path starting from INSN.  A register considered as used on the moving path,
   if one of the following conditions is not satisfied:

      (1) a register not set or read on any path from xi to an instance of
          the original operation,
      (2) not among the live registers of the point immediately following the
          first original operation on a given downward path, except for the
          original target register of the operation,
      (3) not live on the other path of any conditional branch that is passed
          by the operation, in case original operations are not present on
          both paths of the conditional branch.

   All the original operations found during the traversal are saved in the
   ORIGINAL_INSNS list.

   REG_RENAME_P->CROSSES_CALL is true, if there is a call insn on the path
   from INSN to original insn. In this case CALL_USED_REG_SET will be added
   to unavailable hard regs at the point original operation is found.   

References bitmap_clear(), code_motion_path_driver(), reg_rename::crosses_call, fur_static_params::crosses_call, fur_hooks, mark_unavailable_hard_regs(), _def::orig_insn, fur_static_params::original_insns, used_regs, and fur_static_params::used_regs.

Referenced by collect_unavailable_regs_from_bnds().

static void fur_at_first_insn ( insn_t  insn,
cmpd_local_params_p  lparams,
void *  static_params 
)
static
This function is called on the ascending pass, before returning from the
   current basic block.   

References sel_bb_head_p().

static void fur_merge_succs ( insn_t  insn,
insn_t  succ,
int  moveop_drv_call_res,
cmpd_local_params_p  lparams,
void *  static_params 
)
static
Add used regs for the successor SUCC into SPARAMS->USED_REGS.

   SUCC is one of the SUCCS_NORMAL successors of INSN,
   MOVEOP_DRV_CALL_RES is the result of call code_motion_path_driver on succ or 0,
     if SUCC is one of SUCCS_BACK or SUCCS_OUT.
   STATIC_PARAMS contain USED_REGS set.   

References compute_live(), and fur_static_params::used_regs.

static int fur_on_enter ( insn_t  insn,
cmpd_local_params_p  local_params,
void *  static_params,
bool  visited_p 
)
static
This function is called on enter to the basic block.
   Returns TRUE if this block already have been visited and
   code_motion_path_driver should return 1, FALSE otherwise.   

References fur_static_params::crosses_call, cmpd_local_params::old_original_insns, and fur_static_params::original_insns.

static void fur_orig_expr_found ( insn_t  insn,
expr_t  expr,
cmpd_local_params_p  lparams,
void *  static_params 
)
static
The function is called when original expr is found.
   INSN - current insn traversed, EXPR - the corresponding expr found,
   crosses_call and original_insns in STATIC_PARAMS are updated.   

References compute_live_below_insn(), fur_static_params::crosses_call, def_list_add(), get_clear_regset_from_pool(), fur_static_params::original_insns, return_regset_to_pool(), and fur_static_params::used_regs.

static bool fur_orig_expr_not_found ( )
static
This function is called while descending current basic block if current
   insn is not the original EXPR we're searching for.

   Return value: TRUE (code_motion_path_driver should continue).   

References fur_static_params::crosses_call, sched_insns_conditions_mutex_p(), and fur_static_params::used_regs.

static basic_block generate_bookkeeping_insn ( expr_t  ,
edge  ,
edge   
)
static

Referenced by move_op_at_first_insn().

static basic_block generate_bookkeeping_insn ( )
static
Generate a bookkeeping copy of C_EXPR's insn for path(s) incoming into to
   E2->dest, except from E1->src (there may be a sequence of empty blocks
   between E1->src and E2->dest).  Return block containing the copy.
   All scheduler data is initialized for the newly created insn.   

References edge_def::dest, emit_bookkeeping_insn(), exchange_data_sets(), find_place_for_bookkeeping(), find_seqno_for_bookkeeping(), basic_block_def::index, sched_verbose, sel_bb_empty_p(), sel_bb_head(), sel_print(), edge_def::src, and stat_bookkeeping_copies.

static rtx get_dest_from_orig_ops ( av_set_t  )
static

Referenced by move_exprs_to_boundary().

static rtx get_dest_from_orig_ops ( )
static
All exprs in ORIG_OPS must have the same destination register or memory.
   Return that destination.   

References rtx_equal_p().

static int get_expr_cost ( )
static
Return the cost of issuing EXPR on the FENCE as estimated by DFA.
   This function properly handles ASMs, USEs etc.   

References estimate_insn_cost(), and recog_memoized().

Referenced by choose_best_insn().

static enum reg_class get_reg_class ( )
static
Returns register class of the output register in INSN.
   Returns NO_REGS for call insns because some targets have constraints on
   destination register of a call insn.

   Code adopted from regrename.c::build_def_use.   
Insns like
    (insn (set (reg:CCZ 17 flags) (compare:CCZ ...)))
    may result in returning NO_REGS, cause flags is written implicitly through
    CMP insn, which has no OP_OUT | OP_INOUT operands.   

References asm_noperands(), operand_alternative::cl, constrain_operands(), recog_data_d::dup_num, extract_insn(), operand_alternative::matches, recog_data_d::n_dups, recog_data_d::n_operands, OP_INOUT, OP_OUT, recog_data_d::operand_loc, recog_data_d::operand_type, preprocess_constraints(), recog_data, recog_op_alt, and which_alternative.

Referenced by mark_unavailable_hard_regs().

static ds_t get_spec_check_type_for_insn ( )
static
Helper for move_op () and find_used_regs ().
   Return speculation type for which a check should be created on the place
   of INSN.  EXPR is one of the original ops we are searching for.   

References ds_get_speculation_types(), spec_info_def::flags, SEL_SCHED_SPEC_DONT_CHECK_CONTROL, spec_info, and targetm.

Referenced by maybe_emit_speculative_check().

static bool handle_emitting_transformations ( rtx  insn,
expr_t  expr,
moveop_static_params_p  params 
)
static
Handle transformations that leave an insn in place of original
   insn such as renaming/speculation.  Return true if one of such
   transformations actually happened, and we have emitted this insn.   

References maybe_emit_renaming_copy(), and maybe_emit_speculative_check().

Referenced by move_op_orig_expr_found().

static bool identical_copy_p ( )
static
True when INSN is a "regN = regN" copy.   

References SET.

Referenced by undo_transformations().

static bool implicit_clobber_conflict_p ( )
static
Return true when the conflict with newly created implicit clobbers
   between EXPR and THROUGH_INSN is found because of renaming.   

References bitmap_bit_p(), cancel_changes(), copy_rtx(), emit_insn(), end_sequence(), extract_insn(), gen_reg_rtx(), ira_implicitly_set_insn_hard_regs(), max_reg_num(), max_regno, maybe_extend_reg_info_p(), preprocess_constraints(), sched_verbose, sel_print(), start_sequence(), validate_change(), and verify_changes().

Referenced by moveup_expr().

static bool in_fallthru_bb_p ( )
static
Returns true when SUCC in a fallthru bb of INSN, possibly
   skipping empty basic blocks.   

References edge_def::dest, find_fallthru_edge_from(), basic_block_def::next_bb, and sel_bb_empty_p().

Referenced by extract_new_fences_from().

static void init_hard_regno_rename ( )
static
Calculate HARD_REGNO_RENAME_OK data for REGNO.   

References hard_regs_data::regs_ever_used, hard_regs_data::regs_for_rename, and sel_hrd.

Referenced by sel_hard_regno_rename_ok().

static void init_hard_regs_data ( )
static
static void init_regs_for_mode ( )
static
static int init_seqno ( )
static
Initialize seqnos for the current region.  BLOCKS_TO_RESCHEDULE contains
   blocks on which we're rescheduling when pipelining, FROM is the block where
   traversing region begins (it may not be the head of the region when
   pipelining, but the head of the loop instead).

   Returns the maximal seqno found.   

References bitmap_clear(), bitmap_clear_bit(), bitmap_ones(), cur_seqno, current_nr_blocks, init_seqno_1(), sbitmap_alloc(), sbitmap_free(), and sched_max_luid.

Referenced by sel_sched_region_1().

static void init_seqno_1 ( )
static
A helper for init_seqno.  Traverse the region starting from BB and
   compute seqnos for visited insns, marking visited bbs in VISITED_BBS.
   Clear visited blocks from BLOCKS_TO_RESCHEDULE.   

References bb_note(), bitmap_bit_p(), bitmap_clear_bit(), bitmap_set_bit(), cur_seqno, in_current_region_p(), basic_block_def::index, and si.

Referenced by init_seqno().

static int invoke_aftermath_hooks ( )
static
Call the rest of the hooks after the choice was made.  Return
   the number of insns that still can be issued given that the current
   number is ISSUE_MORE.  FENCE and BEST_INSN are the current fence
   and the insn chosen for scheduling, respectively.   

References curr_state, dfa_state_size, memcpy(), sched_dump, sched_verbose, sel_dfa_new_cycle(), and targetm.

Referenced by find_best_expr().

static int invoke_dfa_lookahead_guard ( )
static
Calculate insns worth trying via lookahead_guard hook.  Return a number
   of such insns found.   

References dump_vinsn(), find_expr_for_ready(), ready_list::n_ready, ready, ready_element(), ready_try, sched_verbose, sel_print(), and targetm.

Referenced by find_best_expr().

static int invoke_reorder_hooks ( )
static
Invoke reorder* target hooks on the ready list.  Return the number of insns
   we can issue.  FENCE is the current fence.   

References issue_rate, ready_list::n_ready, pipelining_p, ready, ready_element(), ready_lastpos(), sched_dump, sched_verbose, targetm, and ready_list::vec.

Referenced by find_best_expr().

static bool is_ineligible_successor ( )
static
Functions that compute av and lv sets.   
Returns true if INSN is not a downward continuation of the given path P in
   the current stage.   

References pipelining_p.

Referenced by code_motion_path_driver(), compute_av_set_inside_bb(), and update_boundaries().

static void mark_unavailable_hard_regs ( def_t  def,
struct reg_rename reg_rename_p,
regset  used_regs 
)
static
Mark hardware regs in REG_RENAME_P that are not suitable
   for renaming rhs in INSN due to hardware restrictions (register class,
   modes compatibility etc).  This doesn't affect original insn's dest reg,
   if it isn't in USED_REGS.  DEF is a definition insn of rhs for which the
   destination register is sought.  LHS (DEF->ORIG_INSN) may be REG or MEM.
   Registers that are in used_regs are always marked in
   unavailable_hard_regs as well.   

References add_to_hard_reg_set(), reg_rename::available_for_renaming, _def::crosses_call, get_reg_class(), global_regs, init_regs_for_mode(), _def::orig_insn, hard_regs_data::regs_for_call_clobbered, hard_regs_data::regs_for_mode, hard_regs_data::regs_for_mode_ok, reload_completed, sel_hard_regno_rename_ok(), sel_hrd, SET, hard_regs_data::stack_regs, reg_rename::unavailable_hard_regs, and used_regs.

Referenced by find_used_regs().

static bool maybe_emit_renaming_copy ( rtx  insn,
moveop_static_params_p  params 
)
static
Emit a register-register copy for INSN if needed.  Return true if
   emitted one.  PARAMS is the move_op static parameters.   

References moveop_static_params::c_expr, create_insn_rtx_with_rhs(), moveop_static_params::dest, expr_dest_reg(), replace_dest_with_reg_in_expr(), sel_gen_insn_from_rtx_after(), and moveop_static_params::was_renamed.

Referenced by handle_emitting_transformations().

static bool maybe_emit_speculative_check ( rtx  insn,
expr_t  expr,
moveop_static_params_p  params 
)
static
Emit a speculative check for INSN speculated as EXPR if needed.
   Return true if we've  emitted one.  PARAMS is the move_op static
   parameters.   

References moveop_static_params::c_expr, create_speculation_check(), and get_spec_check_type_for_insn().

Referenced by handle_emitting_transformations().

bool maybe_skip_selective_scheduling ( void  )
Return true when we need to skip selective scheduling.  Used for debugging.   

References dbg_cnt().

Referenced by rest_of_handle_sched(), and rest_of_handle_sched2().

static void move_cond_jump ( )
static
Moving conditional jump through some instructions.

   Consider example:

       ...                     <- current scheduling point
       NOTE BASIC BLOCK:       <- bb header
       (p8)  add r14=r14+0x9;;
       (p8)  mov [r14]=r23
       (!p8) jump L1;;
       NOTE BASIC BLOCK:
       ...

   We can schedule jump one cycle earlier, than mov, because they cannot be
   executed together as their predicates are mutually exclusive.

   This is done in this way: first, new fallthrough basic block is created
   after jump (it is always can be done, because there already should be a
   fallthrough block, where control flow goes in case of predicate being true -
   in our example; otherwise there should be a dependence between those
   instructions and jump and we cannot schedule jump right now);
   next, all instructions between jump and current scheduling point are moved
   to this new block.  And the result is this:

      NOTE BASIC BLOCK:
      (!p8) jump L1           <- current scheduling point
      NOTE BASIC BLOCK:       <- bb header
      (p8)  add r14=r14+0x9;;
      (p8)  mov [r14]=r23
      NOTE BASIC BLOCK:
      ...

References edge_def::dest, find_fallthru_edge_from(), get_clear_regset_from_pool(), global_level, basic_block_def::index, basic_block_def::next_bb, reorder_insns(), sched_insns_conditions_mutex_p(), sched_verbose, sel_bb_empty_p(), sel_bb_end(), sel_bb_head(), sel_print(), sel_split_edge(), single_pred(), tidy_control_flow(), and update_data_sets().

Referenced by schedule_expr_on_boundary().

static bool move_exprs_to_boundary ( bnd_t  bnd,
expr_t  expr_vliw,
av_set_t  expr_seq,
expr_t  c_expr 
)
static
Find original instructions for EXPR_SEQ and move it to BND boundary.
   Return the expression to emit in C_EXPR.   

References bitmap_clear(), bitmap_copy(), bitmap_ior_into(), get_dest_from_orig_ops(), get_max_uid(), max_uid_before_move_op, move_op(), stat_bookkeeping_copies, and stat_insns_needed_bookkeeping.

Referenced by schedule_expr_on_boundary().

static void move_nop_to_previous_block ( )
static
Move nop to previous block.   

References bb_note(), next_insn(), sel_bb_end(), and sel_bb_head_p().

static bool move_op ( insn_t  insn,
av_set_t  orig_ops,
expr_t  expr_vliw,
rtx  dest,
expr_t  c_expr,
bool *  should_move 
)
static
Move up the operations from ORIG_OPS set traversing the dag starting
   from INSN.  PATH represents the edges traversed so far.
   DEST is the register chosen for scheduling the current expr.  Insert
   bookkeeping code in the join points.  EXPR_VLIW is the chosen expression,
   C_EXPR is how it looks like at the given cfg point.
   Set *SHOULD_MOVE to indicate whether we have only disconnected
   one of the insns found.

   Returns whether original instructions were found, which is asserted
   to be true in the caller.   

References bitmap_clear(), moveop_static_params::c_expr, code_motion_path_driver(), moveop_static_params::dest, cmpd_local_params::e1, moveop_static_params::failed_insn, move_op_hooks, moveop_static_params::uid, and moveop_static_params::was_renamed.

Referenced by move_exprs_to_boundary().

static void move_op_after_merge_succs ( )
static
This function is called after the last successor.  Copies LP->C_EXPR_MERGED
   into SP->CEXPR.   

References moveop_static_params::c_expr, and cmpd_local_params::c_expr_merged.

static void move_op_ascend ( )
static
Called on the backward stage of recursion to call moveup_expr for insn
   and sparams->c_expr.   

References moveop_static_params::c_expr, moveup_expr_cached(), MOVEUP_EXPR_NULL, and update_liveness_on_insn().

static void move_op_at_first_insn ( insn_t  insn,
cmpd_local_params_p  lparams,
void *  static_params 
)
static
static void move_op_merge_succs ( insn_t  insn,
insn_t  succ,
int  moveop_drv_call_res,
cmpd_local_params_p  lparams,
void *  static_params 
)
static
The main effect of this function is that sparams->c_expr is merged
   with (or copied to) lparams->c_expr_merged.  If there's only one successor,
   we avoid merging anything by copying sparams->c_expr to lparams->c_expr_merged.
   lparams->c_expr_merged is copied back to sparams->c_expr after all
   successors has been traversed.  lparams->c_expr_local is an expr allocated
   on stack in the caller function, and is used if there is more than one
   successor.

   SUCC is one of the SUCCS_NORMAL successors of INSN,
   MOVEOP_DRV_CALL_RES is the result of call code_motion_path_driver on succ,
   LPARAMS and STATIC_PARAMS contain the parameters described above.   

References moveop_static_params::c_expr, cmpd_local_params::c_expr_local, cmpd_local_params::c_expr_merged, clear_expr(), and merge_expr_data().

static int move_op_on_enter ( insn_t  insn,
cmpd_local_params_p  local_params,
void *  static_params,
bool  visited_p 
)
static
Same as above but for move_op.    
static void move_op_orig_expr_found ( insn_t  insn,
expr_t  expr,
cmpd_local_params_p  lparams,
void *  static_params 
)
static
This function is called when original expr is found.
   INSN - current insn traversed, EXPR - the corresponding expr found.
   LPARAMS is the local parameters of code modion driver, STATIC_PARAMS
   is static parameters of move_op.   

References moveop_static_params::c_expr, copy_expr_onside(), handle_emitting_transformations(), remove_insn_from_stream(), track_scheduled_insns_and_blocks(), and moveop_static_params::uid.

static bool move_op_orig_expr_not_found ( insn_t  insn,
av_set_t  orig_ops,
void *  static_params 
)
static
This function is called while descending current basic block if current
   insn is not the original EXPR we're searching for.

   Return value: FALSE, if code_motion_path_driver should perform a local
                        cleanup and return 0 itself;
                 TRUE, if code_motion_path_driver should continue.   

References moveop_static_params::dest, moveop_static_params::failed_insn, and lhs_of_insn_equals_to_dest_p().

static enum MOVEUP_EXPR_CODE moveup_expr ( expr_t  expr,
insn_t  through_insn,
bool  inside_insn_group,
enum local_trans_type ptrans_type 
)
static
Modifies EXPR so it can be moved through the THROUGH_INSN,
   performing necessary transformations.  Record the type of transformation
   made in PTRANS_TYPE, when it is not NULL.  When INSIDE_INSN_GROUP,
   permit all dependencies except true ones, and try to remove those
   too via forward substitution.  All cases when a non-eliminable
   non-zero cost dependency exists inside an insn group will be fixed
   in tick_check_p instead.   

References bookkeeping_can_be_created_if_moved_through_p(), can_speculate_dep_p(), can_substitute_through_p(), control_flow_insn_p(), DEPS_IN_INSN, DEPS_IN_LHS, DEPS_IN_RHS, enable_schedule_as_rhs_p, fallthru_bb_of_jump(), has_dependence_p(), implicit_clobber_conflict_p(), in_current_region_p(), MOVEUP_EXPR_AS_RHS, MOVEUP_EXPR_CHANGED, moveup_expr_inside_insn_group(), MOVEUP_EXPR_NULL, MOVEUP_EXPR_SAME, moving_insn_creates_bookkeeping_block_p(), reload_completed, sched_insns_conditions_mutex_p(), sched_verbose, sel_clear_has_dependence(), sel_insn_is_speculation_check(), sel_print(), speculate_expr(), substitute_reg_in_expr(), TRANS_SPECULATION, TRANS_SUBSTITUTION, and was_target_conflict.

Referenced by moveup_expr_cached().

static enum MOVEUP_EXPR_CODE moveup_expr_inside_insn_group ( )
static
Moveup_* helpers for code motion and computing av sets.   
Propagates EXPR inside an insn group through THROUGH_INSN.
   The difference from the below function is that only substitution is
   performed.   

References can_substitute_through_p(), DEPS_IN_INSN, DEPS_IN_LHS, DEPS_IN_RHS, has_dependence_p(), MOVEUP_EXPR_AS_RHS, MOVEUP_EXPR_CHANGED, MOVEUP_EXPR_NULL, MOVEUP_EXPR_SAME, and substitute_reg_in_expr().

Referenced by moveup_expr().

static void moveup_set_expr ( )
static
Moves an av set AVP up through INSN, performing necessary
   transformations.   

References av_set_iter_remove(), merge_with_other_exprs(), MOVEUP_EXPR_AS_RHS, moveup_expr_cached(), MOVEUP_EXPR_CHANGED, MOVEUP_EXPR_NULL, and MOVEUP_EXPR_SAME.

Referenced by compute_av_set_inside_bb(), and moveup_set_inside_insn_group().

static void moveup_set_inside_insn_group ( )
static
Moves AVP set along PATH.   

References moveup_set_expr(), sched_verbose, and sel_print().

Referenced by compute_av_set_on_boundaries().

static bool moving_insn_creates_bookkeeping_block_p ( insn_t  insn,
insn_t  through_insn 
)
static
Return true when moving a debug INSN across THROUGH_INSN will
   create a bookkeeping block.  We don't want to create such blocks,
   for they would cause codegen differences between compilations with
   and without debug info.   

References bookkeeping_can_be_created_if_moved_through_p(), find_block_for_bookkeeping(), basic_block_def::preds, sched_verbose, sel_print(), and basic_block_def::succs.

Referenced by moveup_expr().

static bool need_nop_to_preserve_insn_bb ( )
static
If INSN is the only insn in the basic block (not counting JUMP,
   which may be a jump to next insn, and DEBUG_INSNs), we want to
   leave a NOP there till the return to fill_insns.   

References sel_bb_end(), and sel_bb_head().

Referenced by remove_insn_from_stream().

static insn_t prepare_place_to_insert ( )
static
Prepare a place to insert the chosen expression on BND.   

References get_nop_from_pool().

Referenced by schedule_expr_on_boundary().

static void process_pipelined_exprs ( )
static
Filter out expressions from av set pointed to by AV_PTR
   that are pipelined too many times.   

References av_set_iter_remove(), and si.

Referenced by fill_ready_list().

static void process_spec_exprs ( )
static
static expr_t process_use_exprs ( )
static
Search for any use-like insns in AV_PTR and decide on scheduling
   them.  Return one when found, and NULL otherwise.
   Note that we check here whether a USE could be scheduled to avoid
   an infinite loop later.   

References av_set_iter_remove(), pipelining_p, recog_memoized(), and si.

Referenced by fill_ready_list().

static void propagate_lv_set ( )
static
Propagate a liveness set LV through INSN.   

References df_simulate_one_insn_backwards().

Referenced by compute_live().

static void put_TImodes ( )
static
Put TImode markers on insns starting a new issue group.   

References clock(), current_sched_info, haifa_sched_info::head, issue_rate, haifa_sched_info::next_tail, reload_completed, sched_verbose, and sel_print().

Referenced by sel_region_target_finish().

static void remove_insn_from_stream ( )
static
Remove INSN from stream.  When ONLY_DISCONNECT is true, its data
   is not removed but reused when INSN is re-emitted.   

References get_nop_from_pool(), need_nop_to_preserve_insn_bb(), and sel_remove_insn().

Referenced by move_op_orig_expr_found().

static void remove_insns_for_debug ( )
static
Remove from AV_VLIW_P all instructions but next when debug counter
   tells us so.  Next instruction is fetched from BNDS.   

References av_set_iter_remove(), and dbg_cnt().

Referenced by fill_insns().

static void remove_insns_that_need_bookkeeping ( )
static
Remove from AV_PTR all insns that may need bookkeeping when scheduling
   on FENCE, but we are unable to copy them.   

References av_set_iter_remove(), bookkeeping_p, CDI_DOMINATORS, control_flow_insn_p(), dominated_by_p(), sched_verbose, and sel_print().

Referenced by fill_insns().

static void remove_temp_moveop_nops ( )
static
Remove nops generated during move_op for preventing removal of empty
   basic blocks.   

References return_nop_to_pool().

Referenced by schedule_expr_on_boundary().

static void replace_dest_with_reg_in_expr ( )
static
Substitute lhs in the given expression EXPR for the register with number
   NEW_REGNO.  SET_DEST may be arbitrary rtx, not only register.   

References change_vinsn_in_expr(), create_insn_rtx_with_lhs(), and create_vinsn_from_insn_rtx().

Referenced by find_sequential_best_exprs(), maybe_emit_renaming_copy(), and try_replace_dest_reg().

static bool replace_dest_with_reg_ok_p ( )
static
Returns whether INSN still be valid after replacing it's DEST with
   register NEW_REG.   

References cancel_changes(), validate_change(), and verify_changes().

Referenced by try_replace_dest_reg().

static bool replace_src_with_reg_ok_p ( )
static
Returns whether INSN's src can be replaced with register number
   NEW_SRC_REG. E.g. the following insn is valid for i386:

    (insn:HI 2205 6585 2207 727 ../../gcc/libiberty/regex.c:3337
      (set (mem/s:QI (plus:SI (plus:SI (reg/f:SI 7 sp)
                        (reg:SI 0 ax [orig:770 c1 ] [770]))
                    (const_int 288 [0x120])) [0 str S1 A8])
            (const_int 0 [0x0])) 43 {*movqi_1} (nil)
        (nil))

  But if we change (const_int 0 [0x0]) to (reg:QI 4 si), it will be invalid
  because of operand constraints:

    (define_insn "*movqi_1"
      [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
            (match_operand:QI 1 "general_operand"      " q,qn,qm,q,rn,qm,qn")
            )]

  So do constrain_operands here, before choosing NEW_SRC_REG as best
  reg for rhs.   

References cancel_changes(), get_dest_and_mode(), validate_change(), and verify_changes().

Referenced by try_replace_dest_reg().

static void reset_sched_cycles_in_current_ebb ( )
static
static bool rtx_ok_for_substitution_p ( rtx  ,
rtx   
)
static
Forward declarations of static functions.   

Referenced by substitute_reg_in_expr().

static bool rtx_ok_for_substitution_p ( )
static
Returns TRUE if WHAT is found in WHERE rtx tree.   

References count_occurrences_equiv().

void run_selective_scheduling ( void  )
static void schedule_on_fences ( flist_t  fences,
int  max_seqno,
ilist_t **  scheduled_insns_tailpp 
)
static
Functions that implement the scheduler driver.   
Schedule a parallel instruction group on each of FENCES.  MAX_SEQNO
   is the current maximum seqno.  SCHEDULED_INSNS_TAILPP is the list
   of insns scheduled -- these would be postprocessed later.   

References dump_flist(), fences, fill_insns(), sched_verbose, scheduled_something_on_previous_fence, sel_print(), and vinsn_vec_clear().

Referenced by sel_sched_region_2().

void sel_add_to_insn_priority ( rtx  insn,
int  amount 
)
Increase EXPR_PRIORITY_ADJ for INSN by AMOUNT.   

References sched_verbose, and sel_print().

Referenced by increase_insn_priority().

static void sel_compute_priorities ( )
static
Compute instruction priorities for current region.   

References compute_priorities(), debug_rgn_dependencies(), free_rgn_deps(), sched_rgn_compute_dependencies(), and sched_verbose.

Referenced by sel_region_init().

static bool sel_dfa_new_cycle ( )
static
Wrapper for dfa_new_cycle ().  Returns TRUE if cycle was advanced.   

References advance_one_cycle(), curr_state, dfa_state_size, memcpy(), sched_dump, sched_verbose, and targetm.

Referenced by invoke_aftermath_hooks().

static bool sel_hard_regno_rename_ok ( )
inlinestatic
A wrapper around HARD_REGNO_RENAME_OK that will look into the hard regs
   data first.   

References init_hard_regno_rename(), hard_regs_data::regs_for_rename, and sel_hrd.

Referenced by mark_unavailable_hard_regs().

static int sel_rank_for_schedule ( const void *  ,
const void *   
)
static

Referenced by fill_vec_av_set().

static int sel_rank_for_schedule ( )
static
Rank two available exprs for schedule.  Never return 0 here.   

References control_flow_insn_p(), ds_weak(), first_emitted_uid, spec_info_def::mask, sel_insn_is_speculation_check(), and spec_info.

static void sel_region_finish ( )
static
Free the scheduling data for the current region.  When RESET_SCHED_CYCLES_P
   is true, make an additional pass emulating scheduler to get correct insn
   cycles for md_finish calls.   

References bb_note(), bitmap_clear(), compute_live(), finish_deps_global(), free_nop_pool(), free_nop_vinsn(), h_d_i_d, max_issue_size, reload_completed, sched_finish_luids(), sched_finish_ready_list(), sel_finish_bbs(), sel_finish_global_and_expr(), sel_region_target_finish(), sel_unregister_cfg_hooks(), si, simplify_changed_insns(), and vinsn_vec_free().

Referenced by sel_sched_region().

static void sel_region_target_finish ( )
static
Perform MD_FINISH on EBBs comprising current region.  When
   RESET_SCHED_CYCLES_P is true, run a pass emulating the scheduler
   to produce correct sched cycles on insns.   

References bitmap_bit_p(), current_nr_blocks, current_sched_info, find_ebb_boundaries(), haifa_sched_info::head, no_real_insns_p(), put_TImodes(), reset_sched_cycles_in_current_ebb(), sched_dump, sched_extend_luids(), sched_verbose, sel_is_loop_preheader_p(), haifa_sched_info::tail, and targetm.

Referenced by sel_region_finish().

static void sel_sched_region_2 ( int  )
static

Referenced by sel_sched_region_1().

static void sel_sched_region_2 ( )
static
The main driver for scheduling a region.  This function is responsible
   for correct propagation of fences (i.e. scheduling points) and creating
   a group of parallel insns at each of them.  It also supports
   pipelining.  ORIG_MAX_SEQNO is the maximal seqno before this pass
   of scheduling.   

References calculate_new_fences(), find_min_max_seqno(), num_insns_scheduled, sched_verbose, schedule_on_fences(), scheduled_insns, sel_print(), stat_bookkeeping_copies, stat_insns_needed_bookkeeping, stat_renamed_scheduled, stat_substitutions_total, and update_seqnos_and_stage().

static void sel_setup_region_sched_flags ( )
static
Initialize scheduling parameters for current region.   

References bookkeeping_p, current_loop_nest, enable_schedule_as_rhs_p, loop_has_exit_edges(), max_insns_to_rename, max_ws, and pipelining_p.

Referenced by sel_region_init().

static int sel_target_adjust_priority ( )
static
Functions to choose the best insn from available ones.   
Adjusts the priority for EXPR using the backend *_adjust_priority hook.   

References priority(), sched_verbose, sel_print(), and targetm.

Referenced by fill_vec_av_set().

static void setup_current_loop_nest ( )
static
Prepare and verify loop nest for pipelining.   

References current_loop_nest, get_loop_nest_for_rgn(), loop_latch_edge(), and sel_add_loop_preheaders().

Referenced by sel_region_init().

static void simplify_changed_insns ( )
static
Simplify insns after the scheduling.   

References current_nr_blocks, and validate_simplify_insn().

Referenced by sel_region_finish().

static void stall_for_cycles ( )
static
Stall for N cycles on FENCE.   

References advance_one_cycle(), and issue_rate.

Referenced by fill_insns().

static bool substitute_reg_in_expr ( )
static
Substitute all occurrences of INSN's destination in EXPR' vinsn with INSN's
   source (if INSN is eligible for substitution).  Returns TRUE if
   substitution was actually performed, FALSE otherwise.  Substitution might
   be not performed because it's either EXPR' vinsn doesn't contain INSN's
   destination or the resulting insn is invalid for the target machine.
   When UNDO is true, perform unsubstitution instead (the difference is in
   the part of rtx on which validate_replace_rtx is called).   

References change_vinsn_in_expr(), copy_rtx(), create_copy_of_insn_rtx(), create_vinsn_from_insn_rtx(), expr_dest_reg(), register_unavailable_p(), rtx_ok_for_substitution_p(), and validate_replace_rtx_part_nosimplify().

Referenced by moveup_expr(), moveup_expr_inside_insn_group(), and undo_transformations().

static void track_scheduled_insns_and_blocks ( )
static
Track bookkeeping copies created, insns scheduled, and blocks for
   rescheduling when INSN is found by move_op.   

References bitmap_clear_bit(), bitmap_set_bit(), first_emitted_uid, max_uid_before_move_op, num_insns_scheduled, and stat_bookkeeping_copies.

Referenced by move_op_orig_expr_found().

static bool try_bitmap_cache ( expr_t  expr,
insn_t  insn,
bool  inside_insn_group,
enum MOVEUP_EXPR_CODE res 
)
static
Try to look at bitmap caches for EXPR and INSN pair, return true
   if successful.  When INSIDE_INSN_GROUP, also try ignore dependencies
   that can exist within a parallel group.  Write to RES the resulting
   code for moveup_expr.   

References bitmap_bit_p(), enable_schedule_as_rhs_p, MOVEUP_EXPR_AS_RHS, MOVEUP_EXPR_NULL, MOVEUP_EXPR_SAME, sched_verbose, and sel_print().

Referenced by moveup_expr_cached().

static bool try_replace_dest_reg ( )
static
Return TRUE if it is possible to replace LHSes of ORIG_INSNS with BEST_REG.
   If BEST_REG is valid, replace LHS of EXPR with it.   

References expr_dest_regno(), replace_dest_with_reg_in_expr(), replace_dest_with_reg_ok_p(), and replace_src_with_reg_ok_p().

Referenced by find_best_reg_for_expr().

static bool try_transformation_cache ( expr_t  expr,
insn_t  insn,
enum MOVEUP_EXPR_CODE res 
)
static
static void update_and_record_unavailable_insns ( )
static
Update data sets for the bookkeeping block and record those expressions
   which become no longer available after inserting this bookkeeping.   

References av_set_clear(), av_set_copy(), av_set_lookup(), control_flow_insn_p(), sel_bb_end(), sel_bb_head(), update_data_sets(), update_liveness_on_insn(), and vinsn_vec_add().

Referenced by move_op_at_first_insn().

static void update_bitmap_cache ( expr_t  expr,
insn_t  insn,
bool  inside_insn_group,
enum MOVEUP_EXPR_CODE  res 
)
static
Update bitmap caches on INSN with result RES of propagating EXPR.   

References bitmap_clear_bit(), bitmap_set_bit(), MOVEUP_EXPR_AS_RHS, MOVEUP_EXPR_NULL, and MOVEUP_EXPR_SAME.

Referenced by moveup_expr_cached().

static blist_t* update_boundaries ( fence_t  fence,
bnd_t  bnd,
insn_t  insn,
blist_t bndsp,
blist_t bnds_tailp 
)
static
Update boundary BND (and, if needed, FENCE) with INSN, remove the
   old boundary from BNDSP, add new boundaries to BNDS_TAIL_P and
   return it.   

References advance_deps_context(), blist_add(), blist_remove(), ilist_copy(), is_ineligible_successor(), sched_verbose, sel_bb_end_p(), sel_print(), and si.

Referenced by fill_insns().

static void update_data_sets ( )
static
Update the data gathered in av and lv sets starting from INSN.   

References compute_av_set(), sel_bb_head_p(), and update_liveness_on_insn().

Referenced by move_cond_jump(), move_op_at_first_insn(), and update_and_record_unavailable_insns().

static void update_fence_and_insn ( )
static
Update FENCE on which INSN was scheduled and this INSN, too.  NEED_STALL
   is nonzero if we need to stall after issuing INSN.   

References advance_one_cycle(), advance_state_on_fence(), dump_insn_1(), sched_verbose, scheduled_something_on_previous_fence, sel_print(), and vec_safe_push().

Referenced by fill_insns().

static void update_liveness_on_insn ( )
inlinestatic
Update liveness sets for INSN.   

References compute_live(), and ignore_first.

Referenced by move_op_ascend(), sel_region_init(), update_and_record_unavailable_insns(), and update_data_sets().

static int update_seqnos_and_stage ( int  min_seqno,
int  max_seqno,
int  highest_seqno_in_use,
ilist_t pscheduled_insns 
)
static
Update seqnos of insns given by PSCHEDULED_INSNS.  MIN_SEQNO and MAX_SEQNO
   are the miminum and maximum seqnos of the group, HIGHEST_SEQNO_IN_USE is
   the highest seqno used in a region.  Return the updated highest seqno.   

References free_data_for_scheduled_insn(), global_level, and pipelining_p.

Referenced by sel_sched_region_2().

static void update_transformation_cache ( expr_t  expr,
insn_t  insn,
bool  inside_insn_group,
enum local_trans_type  trans_type,
vinsn_t  expr_old_vinsn 
)
static
static void verify_target_availability ( expr_t  expr,
regset  used_regs,
struct reg_rename reg_rename_p 
)
static
True when target of EXPR is available due to EXPR_TARGET_AVAILABLE,
   USED_REGS and REG_RENAME_P->UNAVAILABLE_HARD_REGS.   

References bitmap_bit_p(), reg_rename::crosses_call, expr_dest_regno(), rtx_search_arg::n, reload_completed, scheduled_something_on_previous_fence, and reg_rename::unavailable_hard_regs.

Referenced by find_best_reg_for_expr().

static void vinsn_vec_add ( )
static
Add the vinsn of EXPR to the VINSN_VEC.   

References vinsn_attach().

Referenced by schedule_expr_on_boundary(), and update_and_record_unavailable_insns().

static void vinsn_vec_clear ( )
static
Clear VINSN_VEC and detach vinsns.   

References len, and vinsn_detach().

Referenced by schedule_on_fences().

static void vinsn_vec_free ( )
static
Free the vector representing blocked expressions.   

Referenced by sel_region_finish().

static bool vinsn_vec_has_expr_p ( )
static
Lookup EXPR in VINSN_VEC and return TRUE if found.  Also check patterns from
   EXPR's history of changes.   

References bitmap_intersect_p(), and vinsn_equal_p().

Referenced by av_set_could_be_blocked_by_bookkeeping_p(), and fill_vec_av_set().

static bool vinsn_writes_one_of_regs_p ( vinsn_t  vi,
regset  used_regs,
HARD_REG_SET  unavailable_hard_regs 
)
static
Returns whether VI writes either one of the USED_REGS registers or,
   if a register is a hard one, one of the UNAVAILABLE_HARD_REGS registers.   

Referenced by find_best_reg_for_expr().


Variable Documentation

bitmap_head _forced_ebb_heads
static
Set of basic blocks that are forced to start new ebbs.  This is a subset
   of all the ebb heads.   
bitmap blocks_to_reschedule = NULL
Blocks that need to be rescheduled after pipelining.   
bool bookkeeping_p
int can_issue_more
static
struct code_motion_path_driver_info_def* code_motion_path_driver_info
Global pointer to current hooks, either points to MOVE_OP_HOOKS or
   FUR_HOOKS.   
bitmap code_motion_visited_blocks = NULL
static
This bitmap marks the blocks visited by code_motion_path_driver so we don't
   visit them afterwards.   
int cur_seqno
static
Functions that work with regions.   
Current number of seqno used in init_seqno and init_seqno_1.   

Referenced by init_seqno(), and init_seqno_1().

bitmap current_copies = NULL
static
bitmap current_originators = NULL
static
These bitmaps record original instructions scheduled on the current
   iteration and bookkeeping copies created by them.   
bool enable_schedule_as_rhs_p
static
True when separable insns should be scheduled as RHSes.   

Referenced by moveup_expr(), sel_sched_region_1(), sel_setup_region_sched_flags(), and try_bitmap_cache().

flist_t fences
Current fences.   

Referenced by calculate_new_fences(), schedule_on_fences(), and sel_dump_cfg_2().

int first_emitted_uid
static
All newly emitted insns will have their uids greater than this value.   

Referenced by sel_rank_for_schedule(), sel_region_init(), and track_scheduled_insns_and_blocks().

bitmap_head* forced_ebb_heads = &_forced_ebb_heads
Used in bb_in_ebb_p.   
Initial value:
Set of hooks for performing move_op and find_used_regs routines with
   code_motion_path_driver.   
Hooks and data to perform find_used_regs operations
   with code_motion_path_driver.   

Referenced by find_used_regs().

int global_level
GLOBAL_LEVEL is used to discard information stored in basic block headers
   av_sets.  Av_set of bb header is valid if its (bb header's) level is equal
   to GLOBAL_LEVEL.  And invalid if lesser.  This is primarily used to advance
   scheduling window.   

Referenced by compute_av_set_inside_bb(), move_cond_jump(), sel_sched_region_1(), and update_seqnos_and_stage().

bool ignore_first = false
static
True when the first lv set should be ignored when updating liveness.   

Referenced by compute_live(), compute_live_after_bb(), and update_liveness_on_insn().

int max_insns_to_rename
Maximum number of insns that are eligible for renaming.   

Referenced by fill_vec_av_set(), and sel_setup_region_sched_flags().

int max_issue_size = 0
static
Number of insns max_issue has initialized data structures for.   

Referenced by convert_vec_av_set_to_ready(), and sel_region_finish().

int max_uid_before_move_op = 0
static
Records the maximal UID before moving up an instruction.  Used for
   distinguishing between bookkeeping copies and original insns.   

Referenced by move_exprs_to_boundary(), and track_scheduled_insns_and_blocks().

int max_ws
static
Maximum software lookahead window size, reduced when rescheduling after
   pipelining.   

Referenced by compute_av_set_inside_bb(), sel_sched_region_1(), and sel_setup_region_sched_flags().

struct code_motion_path_driver_info_def move_op_hooks
Initial value:
Hooks and data to perform move_op operations with code_motion_path_driver.   

Referenced by av_set_could_be_blocked_by_bookkeeping_p(), and move_op().

int num_insns_scheduled
static
Number of insns scheduled in current region.   

Referenced by fill_vec_av_set(), sel_sched_region_2(), and track_scheduled_insns_and_blocks().

bool pipelining_p
@verbatim Instruction scheduling pass.  Selective scheduler and pipeliner.

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

Implementation of selective scheduling approach.
   The below implementation follows the original approach with the following
   changes:

   o the scheduler works after register allocation (but can be also tuned
   to work before RA);
   o some instructions are not copied or register renamed;
   o conditional jumps are not moved with code duplication;
   o several jumps in one parallel group are not supported;
   o when pipelining outer loops, code motion through inner loops
   is not supported;
   o control and data speculation are supported;
   o some improvements for better compile time/performance were made.

   Terminology
   ===========

   A vinsn, or virtual insn, is an insn with additional data characterizing
   insn pattern, such as LHS, RHS, register sets used/set/clobbered, etc.
   Vinsns also act as smart pointers to save memory by reusing them in
   different expressions.  A vinsn is described by vinsn_t type.

   An expression is a vinsn with additional data characterizing its properties
   at some point in the control flow graph.  The data may be its usefulness,
   priority, speculative status, whether it was renamed/subsituted, etc.
   An expression is described by expr_t type.

   Availability set (av_set) is a set of expressions at a given control flow
   point. It is represented as av_set_t.  The expressions in av sets are kept
   sorted in the terms of expr_greater_p function.  It allows to truncate
   the set while leaving the best expressions.

   A fence is a point through which code motion is prohibited.  On each step,
   we gather a parallel group of insns at a fence.  It is possible to have
   multiple fences. A fence is represented via fence_t.

   A boundary is the border between the fence group and the rest of the code.
   Currently, we never have more than one boundary per fence, as we finalize
   the fence group when a jump is scheduled. A boundary is represented
   via bnd_t.

   High-level overview
   ===================

   The scheduler finds regions to schedule, schedules each one, and finalizes.
   The regions are formed starting from innermost loops, so that when the inner
   loop is pipelined, its prologue can be scheduled together with yet unprocessed
   outer loop. The rest of acyclic regions are found using extend_rgns:
   the blocks that are not yet allocated to any regions are traversed in top-down
   order, and a block is added to a region to which all its predecessors belong;
   otherwise, the block starts its own region.

   The main scheduling loop (sel_sched_region_2) consists of just
   scheduling on each fence and updating fences.  For each fence,
   we fill a parallel group of insns (fill_insns) until some insns can be added.
   First, we compute available exprs (av-set) at the boundary of the current
   group.  Second, we choose the best expression from it.  If the stall is
   required to schedule any of the expressions, we advance the current cycle
   appropriately.  So, the final group does not exactly correspond to a VLIW
   word.  Third, we move the chosen expression to the boundary (move_op)
   and update the intermediate av sets and liveness sets.  We quit fill_insns
   when either no insns left for scheduling or we have scheduled enough insns
   so we feel like advancing a scheduling point.

   Computing available expressions
   ===============================

   The computation (compute_av_set) is a bottom-up traversal.  At each insn,
   we're moving the union of its successors' sets through it via
   moveup_expr_set.  The dependent expressions are removed.  Local
   transformations (substitution, speculation) are applied to move more
   exprs.  Then the expr corresponding to the current insn is added.
   The result is saved on each basic block header.

   When traversing the CFG, we're moving down for no more than max_ws insns.
   Also, we do not move down to ineligible successors (is_ineligible_successor),
   which include moving along a back-edge, moving to already scheduled code,
   and moving to another fence.  The first two restrictions are lifted during
   pipelining, which allows us to move insns along a back-edge.  We always have
   an acyclic region for scheduling because we forbid motion through fences.

   Choosing the best expression
   ============================

   We sort the final availability set via sel_rank_for_schedule, then we remove
   expressions which are not yet ready (tick_check_p) or which dest registers
   cannot be used.  For some of them, we choose another register via
   find_best_reg.  To do this, we run find_used_regs to calculate the set of
   registers which cannot be used.  The find_used_regs function performs
   a traversal of code motion paths for an expr.  We consider for renaming
   only registers which are from the same regclass as the original one and
   using which does not interfere with any live ranges.  Finally, we convert
   the resulting set to the ready list format and use max_issue and reorder*
   hooks similarly to the Haifa scheduler.

   Scheduling the best expression
   ==============================

   We run the move_op routine to perform the same type of code motion paths
   traversal as in find_used_regs.  (These are working via the same driver,
   code_motion_path_driver.)  When moving down the CFG, we look for original
   instruction that gave birth to a chosen expression.  We undo
   the transformations performed on an expression via the history saved in it.
   When found, we remove the instruction or leave a reg-reg copy/speculation
   check if needed.  On a way up, we insert bookkeeping copies at each join
   point.  If a copy is not needed, it will be removed later during this
   traversal.  We update the saved av sets and liveness sets on the way up, too.

   Finalizing the schedule
   =======================

   When pipelining, we reschedule the blocks from which insns were pipelined
   to get a tighter schedule.  On Itanium, we also perform bundling via
   the same routine from ia64.c.

   Dependence analysis changes
   ===========================

   We augmented the sched-deps.c with hooks that get called when a particular
   dependence is found in a particular part of an insn.  Using these hooks, we
   can do several actions such as: determine whether an insn can be moved through
   another (has_dependence_p, moveup_expr); find out whether an insn can be
   scheduled on the current cycle (tick_check_p); find out registers that
   are set/used/clobbered by an insn and find out all the strange stuff that
   restrict its movement, like SCHED_GROUP_P or CANT_MOVE (done in
   init_global_and_expr_for_insn).

   Initialization changes
   ======================

   There are parts of haifa-sched.c, sched-deps.c, and sched-rgn.c that are
   reused in all of the schedulers.  We have split up the initialization of data
   of such parts into different functions prefixed with scheduler type and
   postfixed with the type of data initialized: {,sel_,haifa_}sched_{init,finish},
   sched_rgn_init/finish, sched_deps_init/finish, sched_init_{luids/bbs}, etc.
   The same splitting is done with current_sched_info structure:
   dependence-related parts are in sched_deps_info, common part is in
   common_sched_info, and haifa/sel/etc part is in current_sched_info.

   Target contexts
   ===============

   As we now have multiple-point scheduling, this would not work with backends
   which save some of the scheduler state to use it in the target hooks.
   For this purpose, we introduce a concept of target contexts, which
   encapsulate such information.  The backend should implement simple routines
   of allocating/freeing/setting such a context.  The scheduler calls these
   as target hooks and handles the target context as an opaque pointer (similar
   to the DFA state type, state_t).

   Various speedups
   ================

   As the correct data dependence graph is not supported during scheduling (which
   is to be changed in mid-term), we cache as much of the dependence analysis
   results as possible to avoid reanalyzing.  This includes: bitmap caches on
   each insn in stream of the region saying yes/no for a query with a pair of
   UIDs; hashtables with the previously done transformations on each insn in
   stream; a vector keeping a history of transformations on each expr.

   Also, we try to minimize the dependence context used on each fence to check
   whether the given expression is ready for scheduling by removing from it
   insns that are definitely completed the execution.  The results of
   tick_check_p checks are also cached in a vector on each fence.

   We keep a valid liveness set on each insn in a region to avoid the high
   cost of recomputation on large basic blocks.

   Finally, we try to minimize the number of needed updates to the availability
   sets.  The updates happen in two cases: when fill_insns terminates,
   we advance all fences and increase the stage number to show that the region
   has changed and the sets are to be recomputed; and when the next iteration
   of a loop in fill_insns happens (but this one reuses the saved av sets
   on bb headers.)  Thus, we try to break the fill_insns loop only when
   "significant" number of insns from the current scheduling window was
   scheduled.  This should be made a target param.


   TODO: correctly support the data dependence graph at all stages and get rid
   of all caches.  This should speed up the scheduler.
   TODO: implement moving cond jumps with bookkeeping copies on both targets.
   TODO: tune the scheduler before RA so it does not create too much pseudos.


   References:
   S.-M. Moon and K. Ebcioglu. Parallelizing nonnumerical code with
   selective scheduling and software pipelining.
   ACM TOPLAS, Vol 19, No. 6, pages 853--898, Nov. 1997.

   Andrey Belevantsev, Maxim Kuvyrkov, Vladimir Makarov, Dmitry Melnik,
   and Dmitry Zhurikhin.  An interblock VLIW-targeted instruction scheduler
   for GCC. In Proceedings of GCC Developers' Summit 2006.

   Arutyun Avetisyan, Andrey Belevantsev, and Dmitry Melnik.  GCC Instruction
   Scheduler and Software Pipeliner on the Itanium Platform.   EPIC-7 Workshop.
   http://rogue.colorado.edu/EPIC7/.
True when pipelining is enabled.   

Referenced by _eligible_successor_edge_p(), extract_new_fences_from(), fill_insns(), fill_vec_av_set(), find_seqno_for_bookkeeping(), invoke_reorder_hooks(), is_ineligible_successor(), process_spec_exprs(), process_use_exprs(), schedule_expr_on_boundary(), sel_sched_region(), sel_sched_region_1(), sel_setup_region_sched_flags(), and update_seqnos_and_stage().

int reg_rename_this_tick
static
Indicates the number of times renaming happened before the current one.   

Referenced by emit_insn_from_expr_after(), and sel_region_init().

int reg_rename_tick[FIRST_PSEUDO_REGISTER]
static
reg_rename_tick[REG1] > reg_rename_tick[REG2] if REG1 was chosen as the
   best register more recently than REG2.   

Referenced by choose_best_reg_1(), emit_insn_from_expr_after(), and sel_region_init().

int sched_emulate_haifa_p
True if/when we want to emulate Haifa scheduler in the common code.
   This is used in sched_rgn_local_init and in various places in
   sched-deps.c.   

Referenced by debug_dependencies(), init_deps_global(), sched_analyze_insn(), and sched_rgn_compute_dependencies().

bool scheduled_something_on_previous_fence
static
Used in verify_target_availability to assert that target reg is reported
   unavailabile by both TARGET_UNAVAILABLE and find_used_regs only if
   we haven't scheduled anything on the previous fence.
   if scheduled_something_on_previous_fence is true, TARGET_UNAVAILABLE can
   have more conservative value than the one returned by the
   find_used_regs, thus we shouldn't assert that these values are equal.   

Referenced by schedule_on_fences(), update_fence_and_insn(), and verify_target_availability().

struct hard_regs_data sel_hrd
static
A global structure that contains the needed information about harg
   regs.   

Referenced by choose_best_reg(), init_hard_regno_rename(), init_hard_regs_data(), init_regs_for_mode(), mark_unavailable_hard_regs(), and sel_hard_regno_rename_ok().

int stat_bookkeeping_copies
static
Variables to accumulate different statistics.   
The number of bookkeeping copies created.   

Referenced by generate_bookkeeping_insn(), move_exprs_to_boundary(), sel_sched_region_2(), and track_scheduled_insns_and_blocks().

int stat_insns_needed_bookkeeping
static
The number of insns that required bookkeeiping for their scheduling.   

Referenced by move_exprs_to_boundary(), and sel_sched_region_2().

int stat_renamed_scheduled
static
The number of insns that got renamed.   

Referenced by find_sequential_best_exprs(), and sel_sched_region_2().

int stat_substitutions_total
static
The number of substitutions made during scheduling.   

Referenced by find_sequential_best_exprs(), and sel_sched_region_2().

vec<expr_t> vec_av_set = vNULL
static
A vector of expressions is used to be able to sort them.   
vinsn_vec_t vec_bookkeeping_blocked_vinsns = vinsn_vec_t()
static
This vector has the exprs which may still present in av_sets, but actually
   can't be moved up due to bookkeeping created during code motion to another
   fence.  See comment near the call to update_and_record_unavailable_insns
   for the detailed explanations.   
vinsn_vec_t vec_target_unavailable_vinsns = vinsn_vec_t()
static
This vector has vinsns which are scheduled with renaming on the first fence
   and then seen on the second.  For expressions with such vinsns, target
   availability information may be wrong.   
vec<insn_t> vec_temp_moveop_nops = vNULL
static
Vector to store temporary nops inserted in move_op to prevent removal
   of empty bbs.   
bool was_target_conflict = false
static
True when a conflict on a target register was found during moveup_expr.   

Referenced by moveup_expr(), and update_transformation_cache().