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

Data Structures

struct  delay_pair
struct  delay_i1_hasher
struct  delay_i2_hasher
struct  model_pressure_data
struct  model_insn_info
struct  model_pressure_limit
struct  model_pressure_group
struct  sched_block_state
struct  haifa_saved_data
struct  choice_entry

Typedefs

typedef
TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DATA_T 
first_cycle_multipass_data_t

Functions

static int may_trap_exp (const_rtx, int)
static int haifa_luid_for_non_insn (rtx x)
static int insn_delay ()
static int may_trap_exp ()
static int haifa_classify_rtx ()
int haifa_classify_insn ()
void set_modulo_params ()
int haifa_htab_i2_traverse ()
int haifa_htab_i1_traverse ()
void discard_delay_pairs_above ()
void record_delay_slot_pair ()
rtx real_insn_for_shadow ()
static int pair_delay ()
void add_delay_dependencies ()
static int priority (rtx)
static int rank_for_schedule (const void *, const void *)
static void swap_sort (rtx *, int)
static void queue_insn (rtx, int, const char *)
static int schedule_insn (rtx)
static void adjust_priority (rtx)
static void advance_one_cycle (void)
static void extend_h_i_d (void)
static void ready_add (struct ready_list *, rtx, bool)
static rtx ready_remove_first (struct ready_list *)
static rtx ready_remove_first_dispatch (struct ready_list *ready)
static void queue_to_ready (struct ready_list *)
static int early_queue_to_ready (state_t, struct ready_list *)
static void debug_ready_list (struct ready_list *)
static rtx ready_remove (struct ready_list *, int)
static void ready_remove_insn (rtx)
static void fix_inter_tick (rtx, rtx)
static int fix_tick_ready (rtx)
static void change_queue_index (rtx, int)
static void init_h_i_d (rtx)
static int haifa_speculate_insn (rtx, ds_t, rtx *)
static void generate_recovery_code (rtx)
static void process_insn_forw_deps_be_in_spec (rtx, rtx, ds_t)
static void begin_speculative_block (rtx)
static void add_to_speculative_block (rtx)
static void init_before_recovery (basic_block *)
static void create_check_block_twin (rtx, bool)
static void fix_recovery_deps (basic_block)
static bool haifa_change_pattern (rtx, rtx)
static void dump_new_block_header (int, basic_block, rtx, rtx)
static void restore_bb_notes (basic_block)
static void fix_jump_move (rtx)
static void move_block_after_check (rtx)
static void move_succs (vec< edge, va_gc > **, basic_block)
static void sched_remove_insn (rtx)
static void clear_priorities (rtx, rtx_vec_t *)
static void calc_priorities (rtx_vec_t)
static void add_jump_dependencies (rtx, rtx)
void schedule_insns ()
void sched_init_region_reg_pressure_info ()
static void mark_regno_birth_or_death ()
static void initiate_reg_pressure_info ()
static void setup_ref_regs ()
static void initiate_bb_reg_pressure_info ()
static void save_reg_pressure ()
static void restore_reg_pressure ()
static bool dying_use_p ()
static void print_curr_reg_pressure ()
static bool cond_clobbered_p ()
static void update_insn_after_change ()
static void apply_replacement (dep_t, bool)
static void restore_pattern (dep_t, bool)
static ds_t recompute_todo_spec ()
int insn_cost ()
int dep_cost_1 ()
int dep_cost ()
void increase_insn_priority ()
static bool contributes_to_priority_p ()
static int dep_list_size ()
static int priority ()
static void calculate_reg_deaths (rtx insn, int *death))
static void setup_insn_reg_pressure_info ()
static int model_index ()
static void model_update_limit_points_in_group ()
static void model_update_limit_points ()
static int model_last_use_except ()
static void model_start_update_pressure (struct model_pressure_group *group, int point, int pci, int delta)
static int model_update_pressure (struct model_pressure_group *group, int point, int pci, int delta)
static void model_recompute ()
static bool must_restore_pattern_p ()
static int model_spill_cost ()
static int model_excess_group_cost (struct model_pressure_group *group, int point, int pci, int delta)
static int model_excess_cost ()
static void model_dump_pressure_points ()
static void model_set_excess_costs ()
static int rank_for_schedule ()
static HAIFA_INLINE void swap_sort ()
static HAIFA_INLINE void queue_insn ()
static void queue_remove ()
rtxready_lastpos ()
static HAIFA_INLINE void ready_add ()
static HAIFA_INLINE rtx ready_remove_first ()
rtx ready_element ()
static HAIFA_INLINE rtx ready_remove ()
static void ready_remove_insn ()
void ready_sort ()
static HAIFA_INLINE void adjust_priority ()
void advance_state ()
static void update_register_pressure ()
static void setup_insn_max_reg_pressure ()
static void update_reg_and_insn_max_reg_pressure ()
void sched_setup_bb_reg_pressure_info ()
static void check_clobbered_conditions ()
static int model_classify_pressure ()
static int model_order_p ()
static void model_add_to_worklist_at (struct model_insn_info *insn, struct model_insn_info *prev)
static void model_remove_from_worklist ()
static void model_add_to_worklist (struct model_insn_info *insn, struct model_insn_info *prev, struct model_insn_info *next)
static void model_promote_insn ()
static void model_add_to_schedule ()
static void model_analyze_insns ()
static void model_init_pressure_group ()
static void model_record_pressure (struct model_pressure_group *group, int point, int pci, int pressure)
static void model_record_pressures ()
static void model_record_final_pressures ()
static void model_add_successors_to_worklist ()
static void model_promote_predecessors ()
static void model_choose_insn ()
static void model_reset_queue_indices ()
static void model_dump_pressure_summary ()
static void model_start_schedule ()
static void model_finalize_pressure_group ()
static void model_end_schedule ()
static int schedule_insn ()
void concat_note_lists ()
void remove_notes ()
static void mark_backtrack_feeds ()
static void save_backtrack_point (struct delay_pair *pair, struct sched_block_state sched_block)
static void toggle_cancelled_flags ()
static void undo_replacements_for_backtrack ()
static void unschedule_insns_until ()
static void restore_last_backtrack_point ()
static void free_topmost_backtrack_point ()
static void free_backtrack_queue ()
static void apply_replacement ()
static void restore_pattern ()
static void perform_replacements_new_cycle ()
static bool estimate_insn_tick ()
static int estimate_shadow_tick ()
static void resolve_dependencies ()
void get_ebb_head_tail ()
int no_real_insns_p ()
rtx restore_other_notes ()
static void undo_all_replacements ()
static void queue_to_ready ()
static bool ok_for_early_queue_removal ()
static int early_queue_to_ready ()
static void debug_ready_list ()
void reemit_notes ()
static void move_insn ()
static bool insn_finishes_cycle_p ()
int max_issue (struct ready_list *ready, int privileged_n, state_t state, bool first_cycle_insn_p, int *index)
static int choose_ready (struct ready_list *ready, bool first_cycle_insn_p, rtx *insn_ptr)
static void commit_schedule ()
static void prune_ready_list (state_t temp_state, bool first_cycle_insn_p, bool shadows_only_p, bool modulo_epilogue_p)
static struct haifa_saved_dataverify_shadows ()
bool schedule_block ()
int set_priorities ()
void setup_sched_dump ()
void sched_init ()
static void haifa_init_only_bb (basic_block, basic_block)
void haifa_sched_init ()
void haifa_sched_finish ()
void sched_finish ()
void free_delay_pairs ()
static void fix_inter_tick ()
int try_ready ()
static int fix_tick_ready ()
static void change_queue_index ()
void sched_extend_ready_list ()
void sched_finish_ready_list ()
static int haifa_luid_for_non_insn ()
static void generate_recovery_code ()
static void process_insn_forw_deps_be_in_spec ()
static void begin_speculative_block ()
static void haifa_init_insn (rtx)
static void add_to_speculative_block ()
void * xrecalloc ()
edge find_fallthru_edge_from ()
static void sched_extend_bb ()
void sched_init_bbs ()
static void init_before_recovery ()
basic_block sched_create_recovery_block ()
void sched_create_recovery_edges (basic_block first_bb, basic_block rec, basic_block second_bb)
static void create_check_block_twin ()
static void fix_recovery_deps ()
static bool haifa_change_pattern ()
int sched_speculate_insn ()
static int haifa_speculate_insn ()
static void dump_new_block_header ()
void unlink_bb_notes ()
static void restore_bb_notes ()
static void fix_jump_move ()
static void move_block_after_check ()
static void move_succs ()
static void sched_remove_insn ()
static void clear_priorities ()
static void calc_priorities ()
static void add_jump_dependencies ()
void sched_extend_luids ()
void sched_init_insn_luid ()
void sched_init_luids ()
void sched_finish_luids ()
int insn_luid ()
void sched_extend_target ()
static void init_h_i_d ()
void haifa_init_h_i_d ()
void haifa_finish_h_i_d ()
static void haifa_init_insn ()
static void haifa_init_only_bb ()
basic_block sched_split_block_1 ()
basic_block sched_create_empty_bb_1 ()
rtx sched_emit_insn ()
static rtx ready_remove_first_dispatch ()
int number_in_ready ()
rtx get_ready_element ()

Variables

int issue_rate
bool sched_no_dce
static int modulo_ii
static int modulo_max_stages
static int modulo_n_insns
static int modulo_insns_scheduled
static int modulo_iter0_max_uid
static int modulo_backtracks_left
static int modulo_last_stage
int sched_verbose = 0
FILE * sched_dump = 0
struct common_sched_info_defcommon_sched_info
rtx note_list
static struct spec_info_def spec_info_var
spec_info_t spec_info = NULL
static bool haifa_recovery_bb_recently_added_p
bool haifa_recovery_bb_ever_added_p
static int nr_begin_data
static int nr_be_in_data
static int nr_begin_control
static int nr_be_in_control
static rtxbb_header = 0
static basic_block before_recovery
basic_block after_recovery
bool adding_bb_to_current_region_p = true
static rtxinsn_queue
static int q_ptr = 0
static int q_size = 0
state_t curr_state
size_t dfa_state_size
char * ready_try = NULL
struct ready_list ready = {NULL, 0, 0, 0, 0}
static struct ready_listreadyp = &ready
static int clock_var
static int last_clock_var
static bool must_backtrack
int cycle_issued_insns
static vec< rtxscheduled_insns
struct common_sched_info_def haifa_common_sched_info
vec< int > sched_luids = vNULL
int sched_max_luid = 1
vec< haifa_insn_data_defh_i_d = vNULL
void(* sched_init_only_bb )(basic_block, basic_block)
basic_block(* sched_split_block )(basic_block, rtx)
basic_block(* sched_create_empty_bb )(basic_block)
static hash_table
< delay_i1_hasher
delay_htab
static hash_table
< delay_i2_hasher
delay_htab_i2
struct haifa_sched_infocurrent_sched_info
enum sched_pressure_algorithm sched_pressure
enum reg_class * sched_regno_pressure_class
static int curr_reg_pressure [N_REG_CLASSES]
static int saved_reg_pressure [N_REG_CLASSES]
static bitmap curr_reg_live
static bitmap saved_reg_live
static bitmap region_ref_regs
static vec< dep_tnext_cycle_replace_deps
static vec< int > next_cycle_apply
static rtx last_scheduled_insn
static rtx last_nondebug_scheduled_insn
static rtx nonscheduled_insns_begin
static vec< rtxmodel_schedule
static struct model_insn_infomodel_worklist
static struct model_insn_infomodel_insns
static int model_num_insns
static int model_curr_point
static struct model_pressure_group model_before_pressure
static unsigned int model_next_priority
static struct haifa_saved_databacktrack_queue
static struct choice_entrychoice_stack
int dfa_lookahead
static int max_lookahead_tries
static int cached_first_cycle_multipass_dfa_lookahead = 0
static int cached_issue_rate = 0
static int sched_ready_n_insns = -1

Typedef Documentation

typedef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DATA_T first_cycle_multipass_data_t

Function Documentation

void add_delay_dependencies ( )
Given an insn INSN, add a dependence on its delayed shadow if it
   has one.  Also try to find situations where shadows depend on each other
   and add dependencies to the real insns to limit the amount of backtracking
   needed.   

References add_dependence(), hash_table< Descriptor, Allocator >::find_with_hash(), delay_pair::i1, delay_pair::i2, hash_table< Descriptor, Allocator >::is_created(), pair_delay(), sched_dump, sched_verbose, and delay_pair::stages.

Referenced by add_deps_for_risky_insns().

static void add_jump_dependencies ( rtx  ,
rtx   
)
static

Referenced by fix_recovery_deps().

static void add_jump_dependencies ( )
static
Add dependences between JUMP and other instructions in the recovery
   block.  INSN is the first insn the recovery block.   

References dep_list_size(), init_dep(), sd_add_dep(), and sd_lists_empty_p().

static void add_to_speculative_block ( rtx  )
static

Referenced by generate_recovery_code().

static void adjust_priority ( rtx  )
static

Referenced by try_ready().

static HAIFA_INLINE void adjust_priority ( )
static
PREV is an insn that is ready to execute.  Adjust its priority if that
   will help shorten or lengthen register lifetimes as appropriate.  Also
   provide a hook for the target to tweak itself.   

References targetm.

static HAIFA_INLINE void advance_one_cycle ( )
static
Advance time on one cycle.   

References advance_state(), sched_dump, and sched_verbose.

Referenced by queue_to_ready(), and schedule_block().

void advance_state ( )
Advance DFA state STATE on one cycle.   

References targetm.

Referenced by advance_one_cycle(), and reset_sched_cycles_in_current_ebb().

static void apply_replacement ( dep_t  ,
bool   
)
static
static void apply_replacement ( )
static
Apply a replacement described by DESC.  If IMMEDIATELY is false, we
   may have to postpone the replacement until the start of the next cycle,
   at which point we will be called again with IMMEDIATELY true.  This is
   only done for machines which have instruction packets with explicit
   parallelism however.   

References fix_tick_ready(), dep_replacement::insn, dep_replacement::loc, dep_replacement::newval, reload_completed, haifa_saved_data::replace_apply, haifa_saved_data::replacement_deps, sched_dump, sched_verbose, targetm, update_insn_after_change(), and validate_change().

static void begin_speculative_block ( rtx  )
static

Referenced by generate_recovery_code().

static void begin_speculative_block ( )
static
Generates recovery code for BEGIN speculative INSN.   

References create_check_block_twin(), nr_begin_control, and nr_begin_data.

static void calc_priorities ( rtx_vec_t  )
static
static void calc_priorities ( )
static
Recompute priorities of instructions, whose priorities might have been
   changed.  ROOTS is a vector of instructions whose priority computation will
   trigger initialization of all cleared priorities.   

References priority().

static void calculate_reg_deaths ( rtx  insn,
int *  death 
)
static
For each pressure class CL, set DEATH[CL] to the number of registers
   in that class that die in INSN.   

References dying_use_p(), mark_regno_birth_or_death(), reg_use_data::next_insn_use, and reg_use_data::regno.

Referenced by model_classify_pressure(), model_excess_cost(), model_record_pressures(), and setup_insn_reg_pressure_info().

static void change_queue_index ( rtx  ,
int   
)
static
static void change_queue_index ( )
static
Move NEXT to the proper queue list with (DELAY >= 1),
   or add it to the ready list (DELAY == QUEUE_READY),
   or remove it from ready and queue lists at all (DELAY == QUEUE_NOWHERE).   

References haifa_sched_info::print_insn, q_ptr, queue_insn(), queue_remove(), ready_add(), ready_remove_insn(), sched_dump, and sched_verbose.

static void check_clobbered_conditions ( )
static
If doing predication while scheduling, verify whether INSN, which
   has just been scheduled, clobbers the conditions of any
   instructions that must be predicated in order to break their
   dependencies.  If so, remove them from the queues so that they will
   only be scheduled once their control dependency is resolved.   

References cond_clobbered_p(), DO_PREDICATION, find_all_hard_reg_sets(), haifa_sched_info::flags, insn_queue, ready_list::n_ready, q_ptr, queue_remove(), ready_element(), and ready_remove_insn().

Referenced by schedule_insn().

static int choose_ready ( struct ready_list ready,
bool  first_cycle_insn_p,
rtx insn_ptr 
)
static
The following function chooses insn from READY and modifies
   READY.  The following function is used only for first
   cycle multipass scheduling.
   Return:
   -1 if cycle should be advanced,
   0 if INSN_PTR is set to point to the desirable insn,
   1 if choose_ready () should be restarted without advancing the cycle.   

References change_queue_index(), dbg_cnt(), spec_info_def::flags, choice_entry::index, max_issue(), choice_entry::n, ready_list::n_ready, next_nonnote_insn(), nonscheduled_insns_begin, PREFER_NON_CONTROL_SPEC, PREFER_NON_DATA_SPEC, haifa_sched_info::print_insn, ready_element(), ready_remove(), ready_remove_first(), ready_remove_first_dispatch(), ready_remove_insn(), ready_try, recog_memoized(), sched_dump, sched_verbose, and targetm.

Referenced by schedule_block().

static void clear_priorities ( rtx  ,
rtx_vec_t  
)
static
static void clear_priorities ( )
static
Clear priorities of all instructions, that are forward dependent on INSN.
   Store in vector pointed to by ROOTS_PTR insns on which priority () should
   be invoked to initialize all cleared priorities.   

References clear_priorities(), contributes_to_priority_p(), and _dep::pro.

static void commit_schedule ( )
static
This function is called when we have successfully scheduled a
   block.  It uses the schedule stored in the scheduled_insns vector
   to rearrange the RTL.  PREV_HEAD is used as the anchor to which we
   append the scheduled insns; TAIL is the insn after the scheduled
   block.  TARGET_BB is the argument passed to schedule_block.   

References haifa_sched_info::advance_target_bb, bb_note(), haifa_sched_info::begin_move_insn, control_flow_insn_p(), dump_new_block_header(), last_scheduled_insn, move_insn(), next_real_insn(), haifa_sched_info::next_tail, reemit_notes(), and sched_verbose.

Referenced by schedule_block().

void concat_note_lists ( )
Functions for handling of notes.   
Add note list that ends on FROM_END to the end of TO_ENDP.   
static bool cond_clobbered_p ( )
static
Determine if INSN has a condition that is clobbered if a register
   in SET_REGS is modified.   

References haifa_change_pattern(), haifa_sched_info::print_insn, sched_dump, and sched_verbose.

Referenced by check_clobbered_conditions().

static bool contributes_to_priority_p ( )
static
Return 'true' if DEP should be included in priority calculations.   

References haifa_sched_info::contributes_to_priority, COUNT_SPEC_IN_CRITICAL_PATH, spec_info_def::flags, sched_deps_info_def::generate_spec_deps, and sched_deps_info.

Referenced by clear_priorities(), and priority().

static void create_check_block_twin ( rtx  ,
bool   
)
static
static void debug_ready_list ( struct ready_list )
static

Referenced by schedule_block().

static void debug_ready_list ( )
static
Print the ready list for debugging purposes.  Callable from debugger.   

References clock_var, ready_list::n_ready, haifa_sched_info::print_insn, ready_lastpos(), sched_dump, sched_pressure, and SCHED_PRESSURE_NONE.

int dep_cost ( )
Compute cost of dependence LINK.
   This is the number of cycles between instruction issue and
   instruction results.   

References dep_cost_1().

Referenced by create_ddg_dep_from_intra_loop_link(), create_ddg_dep_no_link(), estimate_insn_tick(), fix_tick_ready(), ok_for_early_queue_removal(), priority(), and rank_for_schedule().

int dep_cost_1 ( )
Compute cost of dependence LINK.
   This is the number of cycles between instruction issue and
   instruction results.
   ??? We also use this function to call recog_memoized on all insns.   

References alloc_INSN_LIST(), hash_table< Descriptor, Allocator >::find_with_hash(), free_INSN_LIST_node(), delay_pair::i1, dep_replacement::insn, insn_cost(), hash_table< Descriptor, Allocator >::is_created(), pair_delay(), recog_memoized(), and targetm.

Referenced by dep_cost().

static int dep_list_size ( )
static
Compute the number of nondebug deps in list LIST for INSN.   

References sd_lists_size().

Referenced by add_jump_dependencies(), model_analyze_insns(), priority(), and rank_for_schedule().

void discard_delay_pairs_above ( )
Discard all delay pairs which involve an insn with an UID higher
   than MAX_UID.   

References haifa_htab_i1_traverse(), haifa_htab_i2_traverse(), max_uid, and hash_table< Descriptor, Allocator >::traverse().

static void dump_new_block_header ( int  ,
basic_block  ,
rtx  ,
rtx   
)
static

Referenced by commit_schedule(), and schedule_block().

static void dump_new_block_header ( )
static
Print some information about block BB, which starts with HEAD and
   ends with TAIL, before scheduling it.
   I is zero, if scheduler is about to start with the fresh ebb.   

References basic_block_def::index, reload_completed, and sched_dump.

static bool dying_use_p ( )
static
Return TRUE if the register is dying after its USE.   

References reg_use_data::insn, and reg_use_data::next_regno_use.

Referenced by calculate_reg_deaths(), and update_register_pressure().

static int early_queue_to_ready ( state_t  ,
struct ready_list  
)
static

Referenced by schedule_block().

static int early_queue_to_ready ( )
static
Remove insns from the queue, before they become "ready" with respect
   to FU latency considerations.   

References dfa_state_size, free_INSN_LIST_node(), dep_replacement::insn, insn_queue, memcpy(), ok_for_early_queue_removal(), haifa_sched_info::print_insn, print_rtl_single(), q_ptr, q_size, ready_add(), recog_memoized(), sched_dump, and sched_verbose.

static bool estimate_insn_tick ( )
static
Compute INSN_TICK_ESTIMATE for INSN.  PROCESSED is a bitmap of
   instructions we've previously encountered, a set bit prevents
   recursion.  BUDGET is a limit on how far ahead we look, it is
   reduced on recursive calls.  Return true if we produced a good
   estimate, or false if we exceeded the budget.   

References bitmap_bit_p(), bitmap_set_bit(), and dep_cost().

Referenced by estimate_shadow_tick().

static int estimate_shadow_tick ( )
static
Examine the pair of insns in P, and estimate (optimistically, assuming
   infinite resources) the cycle in which the delayed shadow can be issued.
   Return the number of cycles that must pass before the real insn can be
   issued in order to meet this constraint.   

References bitmap_clear(), clock_var, estimate_insn_tick(), delay_pair::i2, pair_delay(), and processed.

Referenced by prune_ready_list().

static void extend_h_i_d ( void  )
static
The following functions are used to implement scheduling of data/control
   speculative instructions.   
Extend global scheduler structures (those, that live across calls to
   schedule_block) to include information about just emitted INSN.   

References get_max_uid(), and sched_extend_target().

Referenced by haifa_init_h_i_d(), and haifa_init_insn().

static void fix_inter_tick ( rtx  ,
rtx   
)
static

Referenced by schedule_block().

static void fix_inter_tick ( )
static
Fix INSN_TICKs of the instructions in the current block as well as
   INSN_TICKs of their dependents.
   HEAD and TAIL are the begin and the end of the current scheduled block.   

References bitmap_clear(), bitmap_set_bit(), clock_var, haifa_saved_data::next, processed, and tick.

static void fix_jump_move ( rtx  )
static

Referenced by move_insn().

static void fix_jump_move ( )
static
Helper function.
   Fix CFG after both in- and inter-block movement of
   control_flow_insn_p JUMP.   

References basic_block_def::next_bb, SCHED_EBB_PASS, common_sched_info_def::sched_pass_id, and update_bb_for_insn().

static void fix_recovery_deps ( basic_block  )
static

Referenced by schedule_insn().

static void fix_recovery_deps ( )
static
Removes dependency between instructions in the recovery block REC
   and usual region instructions.  It keeps inner dependences so it
   won't be necessary to recompute them.   

References add_jump_dependencies(), alloc_INSN_LIST(), bitmap_clear(), bitmap_set_bit(), free_INSN_LIST_list(), sd_delete_dep(), sd_iterator_cond(), sd_iterator_next(), sd_iterator_start(), and try_ready().

static int fix_tick_ready ( rtx  )
static

Referenced by apply_replacement(), and try_ready().

static int fix_tick_ready ( )
static
Calculate INSN_TICK of NEXT and add it to either ready or queue list.   

References change_queue_index(), clock_var, dep_cost(), sched_pressure, SCHED_PRESSURE_NONE, sd_lists_empty_p(), and tick.

static void free_backtrack_queue ( )
static
Free the entire backtrack queue.   

References free_topmost_backtrack_point().

Referenced by schedule_block().

void free_delay_pairs ( void  )
Free all delay_pair structures that were recorded.   

References hash_table< Descriptor, Allocator >::empty(), and hash_table< Descriptor, Allocator >::is_created().

static void free_topmost_backtrack_point ( )
static
Discard all data associated with the topmost entry in the backtrack
   queue.  If RESET_TICK is false, we just want to free the data.  If true,
   we are doing this because we discovered a reason to backtrack.  In the
   latter case, also reset the INSN_TICK for the shadow insn.   

References backtrack_queue, haifa_saved_data::be_saved_data, haifa_saved_data::curr_state, haifa_saved_data::delay_pair, haifa_saved_data::fe_saved_data, free(), free_INSN_LIST_list(), delay_pair::i2, haifa_saved_data::insn_queue, haifa_saved_data::next, delay_pair::next_same_i1, haifa_saved_data::ready, haifa_saved_data::replace_apply, haifa_saved_data::replacement_deps, haifa_sched_info::restore_state, targetm, undo_replacements_for_backtrack(), and ready_list::vec.

Referenced by free_backtrack_queue(), and schedule_block().

static void generate_recovery_code ( rtx  )
static

Referenced by schedule_block().

static void generate_recovery_code ( )
static
Generates recovery code for INSN.   

References add_to_speculative_block(), and begin_speculative_block().

rtx get_ready_element ( )
Get number of ready's in the ready list.   

References ready_element().

static bool haifa_change_pattern ( rtx  ,
rtx   
)
static
static bool haifa_change_pattern ( )
static
Change pattern of INSN to NEW_PAT.  Invalidate cached haifa
   instruction data.   

References update_insn_after_change(), and validate_change().

static int haifa_classify_rtx ( )
static
Classifies rtx X of an insn for the purpose of verifying that X can be
   executed speculatively (and consequently the insn can be moved
   speculatively), by examining X, returning:
   TRAP_RISKY: store, or risky non-load insn (e.g. division by variable).
   TRAP_FREE: non-load insn.
   IFREE: load from a globally safe location.
   IRISKY: volatile load.
   PFREE_CANDIDATE, PRISKY_CANDIDATE: load that need to be checked for
   being either PFREE or PRISKY.   

References IRISKY, len, may_trap_exp(), SET, TRAP_FREE, and TRAP_RISKY.

Referenced by haifa_classify_insn().

void haifa_finish_h_i_d ( void  )
int haifa_htab_i1_traverse ( )
Called through htab_traverse.  Walk the hashtable using I2 as
   index, and delete all elements involving an UID higher than
   that pointed to by *DATA.   

References hash_table< Descriptor, Allocator >::clear_slot(), first, delay_pair::i2, and delay_pair::next_same_i1.

Referenced by discard_delay_pairs_above().

int haifa_htab_i2_traverse ( )
Called through htab_traverse.  Walk the hashtable using I2 as
   index, and delete all elements involving an UID higher than
   that pointed to by *DATA.   

References hash_table< Descriptor, Allocator >::clear_slot(), delay_pair::i1, and delay_pair::i2.

Referenced by discard_delay_pairs_above().

void haifa_init_h_i_d ( )
Initialize haifa_insn_data for BBS.   

References extend_h_i_d(), and init_h_i_d().

Referenced by haifa_sched_init(), and sel_region_init().

static void haifa_init_insn ( rtx  )
static
static void haifa_init_only_bb ( basic_block  ,
basic_block   
)
static

Referenced by haifa_sched_init().

static void haifa_init_only_bb ( )
static
Init data for the new basic block BB which comes after AFTER.   

References common_sched_info_def::add_block, and sched_init_bbs().

static int haifa_luid_for_non_insn ( rtx  x)
static
Returns a class that insn with GET_DEST(insn)=x may belong to,
   as found by analyzing insn's expression.   
static int haifa_luid_for_non_insn ( )
static
static int haifa_speculate_insn ( rtx  ,
ds_t  ,
rtx  
)
static

Referenced by try_ready().

static int haifa_speculate_insn ( )
static
void increase_insn_priority ( )
Use this sel-sched.c friendly function in reorder2 instead of increasing
   INSN_PRIORITY explicitly.   

References sel_add_to_insn_priority(), and sel_sched_p().

static void init_before_recovery ( basic_block )
static
static void init_h_i_d ( rtx  )
static
static void init_h_i_d ( )
static
Initialize h_i_d entry of the INSN with default values.
   Values, that are not explicitly initialized here, hold zero.   
static void initiate_bb_reg_pressure_info ( )
static
Initiate current register pressure related info at the start of
   basic block BB.   

References bb_has_eh_pred(), bitmap_bit_p(), curr_reg_pressure, current_nr_blocks, df_get_live_in(), initiate_reg_pressure_info(), mark_regno_birth_or_death(), and setup_ref_regs().

Referenced by sched_setup_bb_reg_pressure_info().

static void initiate_reg_pressure_info ( )
static
Initiate current register pressure related info from living
   registers given by LIVE.   

References bitmap_bit_p(), bitmap_clear(), curr_reg_pressure, current_nr_blocks, mark_regno_birth_or_death(), sched_pressure, and SCHED_PRESSURE_MODEL.

Referenced by initiate_bb_reg_pressure_info(), and model_start_schedule().

int insn_cost ( )
Compute cost of executing INSN.
   This is the number of cycles between instruction issue and
   instruction results.   

References recog_memoized(), and sel_sched_p().

Referenced by debug_dependencies(), dep_cost_1(), noce_try_cmove_arith(), and priority().

static int insn_delay ( )
static
Return the number of cycles until INSN is expected to be ready.
   Return zero if it already is.   

References clock_var.

Referenced by model_excess_cost(), model_set_excess_costs(), and rank_for_schedule().

static bool insn_finishes_cycle_p ( )
static
Return true if scheduling INSN will finish current clock cycle.   

References haifa_sched_info::insn_finishes_block_p.

Referenced by max_issue().

static void mark_backtrack_feeds ( )
static
For every dependency of INSN, set the FEEDS_BACKTRACK_INSN bit according
   to SET_P.   

Referenced by restore_last_backtrack_point(), and save_backtrack_point().

static void mark_regno_birth_or_death ( )
inlinestatic
PRESSURE[CL] describes the pressure on register class CL.  Update it
   for the birth (if BIRTH_P) or death (if !BIRTH_P) of register REGNO.
   LIVE tracks the set of live registers; if it is null, assume that
   every birth or death is genuine.   

References bitmap_clear_bit(), bitmap_set_bit(), and sched_regno_pressure_class.

Referenced by calculate_reg_deaths(), initiate_bb_reg_pressure_info(), initiate_reg_pressure_info(), model_recompute(), and update_register_pressure().

int max_issue ( struct ready_list ready,
int  privileged_n,
state_t  state,
bool  first_cycle_insn_p,
int *  index 
)
The following function returns maximal (or close to maximal) number
   of insns which can be issued on the same cycle and one of which
   insns is insns with the best rank (the first insn in READY).  To
   make this function tries different samples of ready insns.  READY
   is current queue `ready'.  Global array READY_TRY reflects what
   insns are already issued in this try.  The function stops immediately,
   if it reached the such a solution, that all instruction can be issued.
   INDEX will contain index of the best insn in READY.  The following
   function is used only for first cycle multipass scheduling.

   PRIVILEGED_N >= 0

   This function expects recognized insns only.  All USEs,
   CLOBBERs, etc must be filtered elsewhere.   

References cached_first_cycle_multipass_dfa_lookahead, choice_stack, cycle_issued_insns, dfa_lookahead, dfa_state_size, choice_entry::index, insn_finishes_cycle_p(), issue_rate, max_lookahead_tries, memcpy(), choice_entry::n, ready_list::n_ready, ready_element(), ready_try, choice_entry::rest, choice_entry::state, choice_entry::target_data, and targetm.

Referenced by choose_best_insn(), and choose_ready().

static int may_trap_exp ( const_rtx  ,
int   
)
static

Referenced by haifa_classify_rtx(), and may_trap_exp().

static int may_trap_exp ( )
static
static void model_add_successors_to_worklist ( )
static
Update all successors of INSN, given that INSN has just been scheduled.   

References model_insn_info::depth, model_insn_info::insn, model_add_to_worklist(), model_promote_insn(), model_insn_info::next, and model_insn_info::unscheduled_preds.

Referenced by model_choose_insn().

static void model_add_to_schedule ( )
static
Add INSN to the end of the model schedule.   

Referenced by model_choose_insn().

static void model_add_to_worklist ( struct model_insn_info insn,
struct model_insn_info prev,
struct model_insn_info next 
)
static
Add INSN to the model worklist.  Start looking for a suitable position
   between neighbors PREV and NEXT, testing at most MAX_SCHED_READY_INSNS
   insns either side.  A null PREV indicates the beginning of the list and
   a null NEXT indicates the end.   

References count, model_add_to_worklist_at(), model_order_p(), model_insn_info::next, and model_insn_info::prev.

Referenced by model_add_successors_to_worklist(), model_analyze_insns(), and model_promote_predecessors().

static void model_add_to_worklist_at ( struct model_insn_info insn,
struct model_insn_info prev 
)
static
Add INSN to the model worklist immediately after PREV.  Add it to the
   beginning of the list if PREV is null.   

References model_insn_info::insn, model_worklist, model_insn_info::next, and model_insn_info::prev.

Referenced by model_add_to_worklist(), model_promote_insn(), and model_promote_predecessors().

static void model_analyze_insns ( )
static
Analyze the instructions that are to be scheduled, setting up
   MODEL_INSN_INFO (...) and model_num_insns accordingly.  Add ready
   instructions to model_worklist.   

References model_insn_info::alap, dep_list_size(), model_insn_info::insn, model_add_to_worklist(), model_num_insns, haifa_sched_info::next_tail, model_insn_info::old_queue, haifa_sched_info::prev_head, and model_insn_info::unscheduled_preds.

Referenced by model_start_schedule().

static int model_classify_pressure ( )
static
Return (in order):

   - positive if INSN adversely affects the pressure on one
     register class

   - negative if INSN reduces the pressure on one register class

   - 0 if INSN doesn't affect the pressure on any register class.   

References calculate_reg_deaths(), model_insn_info::insn, and reg_pressure_data::set_increase.

Referenced by model_choose_insn().

static void model_dump_pressure_points ( )
static
static void model_dump_pressure_summary ( )
static
We have calculated the model schedule and spill costs.  Print a summary
   to sched_dump.   

References model_pressure_group::limits, model_before_pressure, model_pressure_limit::pressure, reg_class_names, and sched_dump.

Referenced by model_start_schedule().

static void model_end_schedule ( )
static
Free the information created by model_start_schedule.   

References model_before_pressure, and model_finalize_pressure_group().

Referenced by schedule_block().

static int model_excess_cost ( )
static
Return baseECC (MODEL_INSN (INSN)).  Dump the costs to sched_dump
   if PRINT_P.   

References calculate_reg_deaths(), insn_delay(), model_before_pressure, model_excess_group_cost(), model_index(), reg_class_names, sched_dump, and reg_pressure_data::set_increase.

Referenced by model_set_excess_costs().

static int model_excess_group_cost ( struct model_pressure_group group,
int  point,
int  pci,
int  delta 
)
static
Return baseECC (ira_pressure_classes[PCI], POINT), given that
   P = curr_reg_pressure[ira_pressure_classes[PCI]] and that
   P' = P + DELTA.   

References curr_reg_pressure, model_pressure_group::limits, model_spill_cost(), model_pressure_limit::orig_pressure, model_pressure_limit::point, and model_pressure_limit::pressure.

Referenced by model_excess_cost().

static void model_finalize_pressure_group ( )
static
Free the information associated with GROUP.   

References model_pressure_group::model.

Referenced by model_end_schedule().

static int model_index ( )
static
Return INSN's index in the model schedule, or model_num_insns if it
   doesn't belong to that schedule.   

References model_num_insns.

Referenced by model_excess_cost(), model_last_use_except(), model_recompute(), model_record_pressures(), queue_to_ready(), rank_for_schedule(), and schedule_insn().

static void model_init_pressure_group ( )
static
The global state describes the register pressure at the start of the
   model schedule.  Initialize GROUP accordingly.   

References curr_reg_pressure, model_pressure_group::limits, model_pressure_group::model, model_num_insns, model_pressure_limit::point, and model_pressure_limit::pressure.

Referenced by model_start_schedule().

static int model_last_use_except ( )
static
Return the model_index of the last unscheduled use in chain USE
   outside of USE's instruction.  Return -1 if there are no other uses,
   or model_num_insns if the register is live at the end of the block.   

References reg_use_data::insn, last, model_index(), model_num_insns, and reg_use_data::next_regno_use.

Referenced by model_recompute().

static int model_order_p ( )
static
Return true if INSN1 should come before INSN2 in the model schedule.   

References model_insn_info::alap, model_insn_info::depth, model_insn_info::insn, and model_insn_info::model_priority.

Referenced by model_add_to_worklist(), and model_promote_insn().

static void model_promote_insn ( )
static
INSN may now have a higher priority (in the model_order_p sense)
   than before.  Move it up the worklist if necessary.   

References count, model_add_to_worklist_at(), model_order_p(), model_remove_from_worklist(), and model_insn_info::prev.

Referenced by model_add_successors_to_worklist().

static void model_promote_predecessors ( )
static
Give INSN a higher priority than any current instruction, then give
   unscheduled predecessors of INSN a higher priority still.  If any of
   those predecessors are not on the model worklist, do the same for its
   predecessors, and so on.   

References first, model_insn_info::insn, model_add_to_worklist(), model_add_to_worklist_at(), model_next_priority, model_insn_info::model_priority, model_remove_from_worklist(), model_insn_info::next, sched_dump, and sched_verbose.

Referenced by model_choose_insn().

static void model_record_final_pressures ( )
static
All instructions have been added to the model schedule.  Record the
   final register pressure in GROUP and set up all MODEL_MAX_PRESSUREs.   

References curr_reg_pressure, model_pressure_group::limits, model_num_insns, model_record_pressure(), model_pressure_limit::orig_pressure, and model_pressure_limit::pressure.

Referenced by model_start_schedule().

static void model_record_pressure ( struct model_pressure_group group,
int  point,
int  pci,
int  pressure 
)
static
Record that MODEL_REF_PRESSURE (GROUP, POINT, PCI) is PRESSURE.
   Update the maximum pressure for the whole schedule.   

References model_pressure_group::limits, model_pressure_limit::point, and model_pressure_limit::pressure.

Referenced by model_record_final_pressures(), and model_record_pressures().

static void model_record_pressures ( )
static
static void model_remove_from_worklist ( )
static
static void model_reset_queue_indices ( )
static
Restore all QUEUE_INDEXs to the values that they had before
   model_start_schedule was called.   

References model_insn_info::insn.

Referenced by model_start_schedule().

static void model_set_excess_costs ( )
static
Set INSN_REG_PRESSURE_EXCESS_COST_CHANGE for INSNS[0...COUNT-1].   

References count, insn_delay(), model_before_pressure, model_dump_pressure_points(), model_excess_cost(), priority(), sched_dump, and sched_verbose.

Referenced by ready_sort().

static int model_spill_cost ( )
static
model_spill_cost (CL, P, P') returns the cost of increasing the
   pressure on CL from P to P'.  We use this to calculate a "base ECC",
   baseECC (CL, X), for each pressure class CL and each instruction X.
   Supposing X changes the pressure on CL from P to P', and that the
   maximum pressure on CL in the current model schedule is MP', then:

   * if X occurs before or at the next point of maximum pressure in
     the model schedule and P' > MP', then:

       baseECC (CL, X) = model_spill_cost (CL, MP, P')

     The idea is that the pressure after scheduling a fixed set of
     instructions -- in this case, the set up to and including the
     next maximum pressure point -- is going to be the same regardless
     of the order; we simply want to keep the intermediate pressure
     under control.  Thus X has a cost of zero unless scheduling it
     now would exceed MP'.

     If all increases in the set are by the same amount, no zero-cost
     instruction will ever cause the pressure to exceed MP'.  However,
     if X is instead moved past an instruction X' with pressure in the
     range (MP' - (P' - P), MP'), the pressure at X' will increase
     beyond MP'.  Since baseECC is very much a heuristic anyway,
     it doesn't seem worth the overhead of tracking cases like these.

     The cost of exceeding MP' is always based on the original maximum
     pressure MP.  This is so that going 2 registers over the original
     limit has the same cost regardless of whether it comes from two
     separate +1 deltas or from a single +2 delta.

   * if X occurs after the next point of maximum pressure in the model
     schedule and P' > P, then:

       baseECC (CL, X) = model_spill_cost (CL, MP, MP' + (P' - P))

     That is, if we move X forward across a point of maximum pressure,
     and if X increases the pressure by P' - P, then we conservatively
     assume that scheduling X next would increase the maximum pressure
     by P' - P.  Again, the cost of doing this is based on the original
     maximum pressure MP, for the same reason as above.

   * if P' < P, P > MP, and X occurs at or after the next point of
     maximum pressure, then:

       baseECC (CL, X) = -model_spill_cost (CL, MAX (MP, P'), P)

     That is, if we have already exceeded the original maximum pressure MP,
     and if X might reduce the maximum pressure again -- or at least push
     it further back, and thus allow more scheduling freedom -- it is given
     a negative cost to reflect the improvement.

   * otherwise,

       baseECC (CL, X) = 0

     In this case, X is not expected to affect the maximum pressure MP',
     so it has zero cost.

   We then create a combined value baseECC (X) that is the sum of
   baseECC (CL, X) for each pressure class CL.

   baseECC (X) could itself be used as the ECC value described above.
   However, this is often too conservative, in the sense that it
   tends to make high-priority instructions that increase pressure
   wait too long in cases where introducing a spill would be better.
   For this reason the final ECC is a priority-adjusted form of
   baseECC (X).  Specifically, we calculate:

     P (X) = INSN_PRIORITY (X) - insn_delay (X) - baseECC (X)
     baseP = MAX { P (X) | baseECC (X) <= 0 }

   Then:

     ECC (X) = MAX (MIN (baseP - P (X), baseECC (X)), 0)

   Thus an instruction's effect on pressure is ignored if it has a high
   enough priority relative to the ones that don't increase pressure.
   Negative values of baseECC (X) do not increase the priority of X
   itself, but they do make it harder for other instructions to
   increase the pressure further.

   This pressure cost is deliberately timid.  The intention has been
   to choose a heuristic that rarely interferes with the normal list
   scheduler in cases where that scheduler would produce good code.
   We simply want to curb some of its worst excesses.   
Return the cost of increasing the pressure in class CL from FROM to TO.

   Here we use the very simplistic cost model that every register above
   ira_class_hard_regs_num[CL] has a spill cost of 1.  We could use other
   measures instead, such as one based on MEMORY_MOVE_COST.  However:

      (1) In order for an instruction to be scheduled, the higher cost
          would need to be justified in a single saving of that many stalls.
          This is overly pessimistic, because the benefit of spilling is
          often to avoid a sequence of several short stalls rather than
          a single long one.

      (2) The cost is still arbitrary.  Because we are not allocating
          registers during scheduling, we have no way of knowing for
          sure how many memory accesses will be required by each spill,
          where the spills will be placed within the block, or even
          which block(s) will contain the spills.

   So a higher cost than 1 is often too conservative in practice,
   forcing blocks to contain unnecessary stalls instead of spill code.
   The simple cost below seems to be the best compromise.  It reduces
   the interference with the normal list scheduler, which helps make
   it more suitable for a default-on option.   

Referenced by model_excess_group_cost().

static void model_start_update_pressure ( struct model_pressure_group group,
int  point,
int  pci,
int  delta 
)
static
An instruction with model_index POINT has just been scheduled, and it
   adds DELTA to the pressure on ira_pressure_classes[PCI] after POINT - 1.
   Update MODEL_REF_PRESSURE (GROUP, POINT, PCI) and
   MODEL_MAX_PRESSURE (GROUP, POINT, PCI) accordingly.   

References model_pressure_group::limits, model_num_insns, and model_pressure_limit::point.

Referenced by model_recompute().

static void model_update_limit_points ( )
static
Make sure that all register-pressure limits are up-to-date for the
   current position in the model schedule.   

References model_before_pressure, and model_update_limit_points_in_group().

Referenced by schedule_insn().

static void model_update_limit_points_in_group ( )
static
Make sure that GROUP->limits is up-to-date for the current point
   of the model schedule.   

References model_pressure_group::limits, model_curr_point, model_num_insns, model_pressure_limit::point, and model_pressure_limit::pressure.

Referenced by model_update_limit_points().

static int model_update_pressure ( struct model_pressure_group group,
int  point,
int  pci,
int  delta 
)
static
Record that scheduling a later instruction has changed the pressure
   at point POINT of the model schedule by DELTA (which might be 0).
   Update GROUP accordingly.  Return nonzero if these changes might
   trigger changes to previous points as well.   

References model_pressure_group::limits, model_pressure_limit::point, and model_pressure_limit::pressure.

Referenced by model_recompute().

static void move_block_after_check ( rtx  )
static

Referenced by move_insn().

static void move_block_after_check ( )
static
static void move_succs ( vec< edge, va_gc > **  ,
basic_block   
)
static

Referenced by move_block_after_check().

static void move_succs ( )
static
Helper function for move_block_after_check.
   This functions attaches edge vector pointed to by SUCCSP to
   block TO.   

References edge_def::src, and basic_block_def::succs.

static bool must_restore_pattern_p ( )
static
After DEP, which was cancelled, has been resolved for insn NEXT,
   check whether the insn's pattern needs restoring.   

References dep_replacement::insn, dep_replacement::loc, and dep_replacement::orig.

Referenced by schedule_insn().

int no_real_insns_p ( )
Return nonzero if there are no real insns in the range [ HEAD, TAIL ].   

Referenced by compute_priorities(), free_block_dependencies(), schedule_ebb(), schedule_region(), and sel_region_target_finish().

int number_in_ready ( void  )
Get number of ready insn in the ready list.   

References ready_list::n_ready.

static bool ok_for_early_queue_removal ( )
static
Used by early_queue_to_ready.  Determines whether it is "ok" to
   prematurely move INSN from the queue to the ready list.  Currently,
   if a target defines the hook 'is_costly_dependence', this function
   uses the hook to check whether there exist any dependences which are
   considered costly by the target, between INSN and other insns that
   have already been scheduled.  Dependences are checked up to Y cycles
   back, with default Y=1; The flag -fsched-stalled-insns-dep=Y allows
   controlling this value.
   (Other considerations could be taken into account instead (or in
   addition) depending on user flags and target hooks.   

References dep_cost(), sd_find_dep_between(), and targetm.

Referenced by early_queue_to_ready().

static int pair_delay ( )
static
For a pair P of insns, return the fixed distance in cycles from the first
   insn after which the second must be scheduled.   

References delay_pair::cycles, modulo_ii, and delay_pair::stages.

Referenced by add_delay_dependencies(), dep_cost_1(), estimate_shadow_tick(), save_backtrack_point(), and verify_shadows().

static void perform_replacements_new_cycle ( )
static
Perform pattern replacements that were queued up until the next
   cycle.   

References apply_replacement(), and restore_pattern().

Referenced by schedule_block().

static void print_curr_reg_pressure ( )
static
Print info about the current register pressure and its excess for
   each pressure class.   

References curr_reg_pressure, reg_class_names, and sched_dump.

Referenced by schedule_block(), and schedule_insn().

static int priority ( )
static
Compute the priority number for INSN.   

References contributes_to_priority_p(), dep_cost(), dep_list_size(), init_dep(), insn_cost(), priority(), and sel_sched_p().

static void process_insn_forw_deps_be_in_spec ( rtx  ,
rtx  ,
ds_t   
)
static
static void process_insn_forw_deps_be_in_spec ( )
static
Helper function.
   Tries to add speculative dependencies of type FS between instructions
   in deps_list L and TWIN.   

References ds_weak(), init_dep_1(), sched_insn_is_legitimate_for_speculation_p(), and sd_add_dep().

static void prune_ready_list ( state_t  temp_state,
bool  first_cycle_insn_p,
bool  shadows_only_p,
bool  modulo_epilogue_p 
)
static
Examine all insns on the ready list and queue those which can't be
   issued in this cycle.  TEMP_STATE is temporary scheduler state we
   can use as scratch space.  If FIRST_CYCLE_INSN_P is true, no insns
   have been issued for the current cycle, which means it is valid to
   issue an asm statement.

   If SHADOWS_ONLY_P is true, we eliminate all real insns and only
   leave those for which SHADOW_P is true.  If MODULO_EPILOGUE is true,
   we only leave insns which have an INSN_EXACT_TICK.   

References asm_noperands(), clock_var, dfa_state_size, estimate_shadow_tick(), hash_table< Descriptor, Allocator >::find_with_hash(), hash_table< Descriptor, Allocator >::is_created(), memcpy(), choice_entry::n, ready_list::n_ready, delay_pair::next_same_i1, queue_insn(), ready_element(), ready_remove(), recog_memoized(), sched_pressure, SCHED_PRESSURE_MODEL, and SCHED_PRESSURE_NONE.

Referenced by schedule_block().

static void queue_insn ( rtx  ,
int  ,
const char *   
)
static
static HAIFA_INLINE void queue_insn ( )
static
Add INSN to the insn queue so that it can be executed at least
   N_CYCLES after the currently executing insn.  Preserve insns
   chain for debugging purposes.  REASON will be printed in debugging
   output.   

References alloc_INSN_LIST(), clock_var, DO_BACKTRACKING, haifa_sched_info::flags, insn_queue, must_backtrack, haifa_sched_info::print_insn, q_ptr, q_size, sched_dump, and sched_verbose.

static void queue_remove ( )
static
static void queue_to_ready ( struct ready_list )
static

Referenced by schedule_block().

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

Referenced by swap_sort().

static int rank_for_schedule ( )
static
Returns a positive value if x is preferred; returns a negative value if
   y is preferred.  Should never return 0, since that will make the sort
   unstable.   

References clock_var, dep_cost(), dep_list_size(), DO_BACKTRACKING, ds_weak(), haifa_sched_info::flags, insn_delay(), last, last_nondebug_scheduled_insn, model_index(), haifa_sched_info::rank, sched_pressure, SCHED_PRESSURE_MODEL, SCHED_PRESSURE_NONE, and sd_find_dep_between().

static void ready_add ( struct ready_list ,
rtx  ,
bool   
)
static
Notes handling mechanism:
   =========================
   Generally, NOTES are saved before scheduling and restored after scheduling.
   The scheduler distinguishes between two types of notes:

   (1) LOOP_BEGIN, LOOP_END, SETJMP, EHREGION_BEG, EHREGION_END notes:
   Before scheduling a region, a pointer to the note is added to the insn
   that follows or precedes it.  (This happens as part of the data dependence
   computation).  After scheduling an insn, the pointer contained in it is
   used for regenerating the corresponding note (in reemit_notes).

   (2) All other notes (e.g. INSN_DELETED):  Before scheduling a block,
   these notes are put in a list (in rm_other_notes() and
   unlink_other_notes ()).  After scheduling the block, these notes are
   inserted at the beginning of the block (in schedule_block()).   

Referenced by change_queue_index(), early_queue_to_ready(), queue_to_ready(), and schedule_block().

static HAIFA_INLINE void ready_add ( )
static
Add an element INSN to the ready list so that it ends up with the
   lowest/highest priority depending on FIRST_P.   

References clock_var, ready_list::first, must_backtrack, ready_list::n_debug, ready_list::n_ready, ready_lastpos(), ready_list::vec, and ready_list::veclen.

rtx ready_element ( )
The following code implements multi-pass scheduling for the first
   cycle.  In other words, we will try to choose ready insn which
   permits to start maximum number of insns on the same cycle.   
Return a pointer to the element INDEX from the ready.  INDEX for
   insn with the highest priority is 0, and the lowest priority has
   N_READY - 1.   

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

Referenced by check_clobbered_conditions(), choose_ready(), get_ready_element(), invoke_dfa_lookahead_guard(), invoke_reorder_hooks(), max_issue(), prune_ready_list(), ready_remove_first_dispatch(), ready_remove_insn(), and schedule_block().

rtx* ready_lastpos ( )
Return a pointer to the bottom of the ready list, i.e. the insn
   with the lowest priority.   

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

Referenced by debug_ready_list(), invoke_reorder_hooks(), ready_add(), ready_sort(), restore_last_backtrack_point(), schedule_block(), and toggle_cancelled_flags().

static rtx ready_remove ( struct ready_list ,
int   
)
static
The following functions are used to implement multi-pass scheduling
   on the first cycle.   

Referenced by choose_ready(), prune_ready_list(), ready_remove_first_dispatch(), ready_remove_insn(), and schedule_block().

static HAIFA_INLINE rtx ready_remove ( )
static
Remove the element INDEX from the ready list and return it.  INDEX
   for insn with the highest priority is 0, and the lowest priority
   has N_READY - 1.   

References ready_list::first, ready_list::n_debug, ready_list::n_ready, ready_remove_first(), and ready_list::vec.

static rtx ready_remove_first ( struct ready_list )
static
static HAIFA_INLINE rtx ready_remove_first ( )
static
Remove the element with the highest priority from the ready list and
   return it.   

References ready_list::first, ready_list::n_debug, ready_list::n_ready, ready_list::vec, and ready_list::veclen.

static rtx ready_remove_first_dispatch ( struct ready_list ready)
static

Referenced by choose_ready().

static rtx ready_remove_first_dispatch ( )
static
This function returns a candidate satisfying dispatch constraints from
   the ready list.   

References active_insn_p(), reg_use_data::insn, ready_list::n_ready, ready_element(), ready_remove(), ready_remove_first(), and targetm.

static void ready_remove_insn ( rtx  )
static
static void ready_remove_insn ( )
static
Remove INSN from the ready list.   

References ready_list::n_ready, ready_element(), and ready_remove().

void ready_sort ( )
rtx real_insn_for_shadow ( )
Examine the delay pair hashtable to see if INSN is a shadow for another,
   and return the other insn if so.  Return NULL otherwise.   

References hash_table< Descriptor, Allocator >::find_with_hash(), delay_pair::i1, hash_table< Descriptor, Allocator >::is_created(), and delay_pair::stages.

Referenced by add_dependence(), and recompute_todo_spec().

static ds_t recompute_todo_spec ( )
static
Look at the remaining dependencies for insn NEXT, and compute and return
   the TODO_SPEC value we should use for it.  This is called after one of
   NEXT's dependencies has been resolved.
   We also perform pattern replacements for predication, and for broken
   replacement dependencies.  The latter is only done if FOR_BACKTRACK is
   false.   

References apply_replacement(), spec_info_def::data_weakness_cutoff, dbg_cnt(), DO_PREDICATION, ds_merge(), ds_weak(), find_all_hard_reg_sets(), haifa_sched_info::flags, haifa_change_pattern(), dep_replacement::insn, real_insn_for_shadow(), sched_get_reverse_condition_uncached(), sd_lists_empty_p(), and tick.

Referenced by restore_last_backtrack_point(), try_ready(), and unschedule_insns_until().

void record_delay_slot_pair ( )
This function can be called by a port just before it starts the final
   scheduling pass.  It records the fact that an instruction with delay
   slots has been split into two insns, I1 and I2.  The first one will be
   scheduled normally and initiates the operation.  The second one is a
   shadow which must follow a specific number of cycles after I1; its only
   purpose is to show the side effect that occurs at that cycle in the RTL.
   If a JUMP_INSN or a CALL_INSN has been split, I1 should be a normal INSN,
   while I2 retains the original insn type.

   There are two ways in which the number of cycles can be specified,
   involving the CYCLES and STAGES arguments to this function.  If STAGES
   is zero, we just use the value of CYCLES.  Otherwise, STAGES is a factor
   which is multiplied by MODULO_II to give the number of cycles.  This is
   only useful if the caller also calls set_modulo_params to enable modulo
   scheduling.   

References hash_table< Descriptor, Allocator >::create(), delay_pair::cycles, hash_table< Descriptor, Allocator >::find_slot_with_hash(), i1, delay_pair::i1, i2, delay_pair::i2, hash_table< Descriptor, Allocator >::is_created(), delay_pair::next_same_i1, and delay_pair::stages.

void reemit_notes ( )
Search INSN for REG_SAVE_NOTE notes and convert them back into insn
   NOTEs.  This is used for NOTE_INSN_EPILOGUE_BEG, so that sched-ebb
   replaces the epilogue note in the correct basic block.   

References emit_note_before(), dep_replacement::insn, last, and remove_note().

Referenced by commit_schedule().

void remove_notes ( )
Delete notes between HEAD and TAIL and put them in the chain
   of notes ended by NOTE_LIST.   

References add_reg_note(), dep_replacement::insn, note_list, remove_insn(), and sel_sched_p().

Referenced by schedule_ebb(), and schedule_region().

static void resolve_dependencies ( )
static
If INSN has no unresolved backwards dependencies, add it to the schedule and
   recursively resolve all its forward dependencies.   

References queue_remove(), sched_dump, sched_verbose, sd_iterator_cond(), sd_iterator_start(), sd_lists_empty_p(), and sd_resolve_dep().

Referenced by schedule_block().

static void restore_bb_notes ( basic_block  )
static

Referenced by schedule_block().

static void restore_bb_notes ( )
static
Restore basic block notes.
   FIRST is the first basic block in the ebb.   

References bb_header, free(), basic_block_def::index, and basic_block_def::next_bb.

rtx restore_other_notes ( )
Restore-other-notes: NOTE_LIST is the end of a chain of notes
   previously found among the insns.  Insert them just before HEAD.   

References bb_note(), and note_list.

Referenced by schedule_block().

static void restore_pattern ( dep_t  ,
bool   
)
static
static void restore_pattern ( )
static
We have determined that a pattern involved in DEP must be restored.
   If IMMEDIATELY is false, we may have to postpone the replacement
   until the start of the next cycle, at which point we will be called
   again with IMMEDIATELY true.   

References haifa_change_pattern(), dep_replacement::insn, dep_replacement::loc, dep_replacement::orig, reload_completed, haifa_saved_data::replace_apply, haifa_saved_data::replacement_deps, sched_dump, sched_verbose, sd_lists_empty_p(), targetm, tick, update_insn_after_change(), and validate_change().

static void restore_reg_pressure ( )
static
Restore saved register pressure related info.   

References bitmap_copy(), curr_reg_pressure, and saved_reg_pressure.

Referenced by setup_insn_max_reg_pressure().

static void save_reg_pressure ( )
static
Save current register pressure related info.   

References bitmap_copy(), curr_reg_pressure, and saved_reg_pressure.

Referenced by setup_insn_max_reg_pressure().

basic_block sched_create_empty_bb_1 ( )
A generic version of sched_create_empty_bb ().   

References create_empty_bb().

Referenced by haifa_sched_init().

void sched_create_recovery_edges ( basic_block  first_bb,
basic_block  rec,
basic_block  second_bb 
)
Create edges: FIRST_BB -> REC; FIRST_BB -> SECOND_BB; REC -> SECOND_BB
   and emit necessary jumps.   

References add_reg_note(), block_label(), CDI_DOMINATORS, dom_info_available_p(), emit_jump_insn_after(), make_edge(), make_single_succ_edge(), and set_immediate_dominator().

Referenced by create_check_block_twin().

rtx sched_emit_insn ( )
Insert PAT as an INSN into the schedule and update the necessary data
   structures to account for it.  

References haifa_sched_info::add_remove_insn, haifa_sched_info::begin_schedule_ready, emit_insn_before(), haifa_init_insn(), reg_use_data::insn, last_scheduled_insn, and nonscheduled_insns_begin.

static void sched_extend_bb ( )
static
Extend per basic block data structures.   

References emit_note_after(), and prev_nondebug_insn().

Referenced by init_before_recovery(), and sched_init_bbs().

void sched_extend_luids ( void  )
Extend data structures for logical insn UID.   

References get_max_uid().

Referenced by haifa_init_insn(), sched_init_luids(), schedule_block(), and sel_region_target_finish().

void sched_extend_target ( void  )
Extend per insn data in the target.   

References targetm.

Referenced by extend_h_i_d(), haifa_init_insn(), haifa_sched_init(), and sel_global_init().

void sched_finish ( void  )
void sched_finish_luids ( void  )
Free LUIDs.   

References sched_max_luid.

Referenced by haifa_sched_finish(), and sel_region_finish().

void sched_finish_ready_list ( void  )
Free per region data structures.   

References free(), ready_try, sched_ready_n_insns, targetm, ready_list::vec, and ready_list::veclen.

Referenced by schedule_ebb(), schedule_region(), and sel_region_finish().

void sched_init_bbs ( void  )
Init per basic block data structures.   

References sched_extend_bb().

Referenced by haifa_init_only_bb(), haifa_sched_init(), and sel_global_init().

void sched_init_insn_luid ( )
Initialize LUID for INSN.   

References common_sched_info_def::luid_for_non_insn, and sched_max_luid.

Referenced by haifa_init_insn(), and sched_init_luids().

void sched_init_luids ( )
Initialize luids for BBS.
   The hook common_sched_info->luid_for_non_insn () is used to determine
   if notes, labels, etc. need luids.   

References sched_extend_luids(), and sched_init_insn_luid().

Referenced by haifa_sched_init(), and sel_region_init().

void sched_init_region_reg_pressure_info ( void  )
Initiate register pressure relative info for scheduling the current
   region.  Currently it is only clearing register mentioned in the
   current region.   

References bitmap_clear().

Referenced by schedule_region().

static void sched_remove_insn ( rtx  )
static

Referenced by create_check_block_twin().

static void sched_remove_insn ( )
static
Remove INSN from the instruction stream.
   INSN should have any dependencies.   

References haifa_sched_info::add_remove_insn, change_queue_index(), delete_insn(), and sd_finish_insn().

void sched_setup_bb_reg_pressure_info ( )
Set up register pressure at the beginning of basic block BB whose
   insns starting after insn AFTER.  Set up also max register pressure
   for all insns of the basic block.   

References initiate_bb_reg_pressure_info(), sched_pressure, SCHED_PRESSURE_WEIGHTED, and setup_insn_max_reg_pressure().

Referenced by schedule_region().

int sched_speculate_insn ( )
-1 - can't speculate,
   0 - for speculation with REQUEST mode it is OK to use
   current instruction pattern,
   1 - need to change pattern for *NEW_PAT to be speculative.   

References DO_SPECULATION, haifa_sched_info::flags, spec_info_def::mask, sched_insn_is_legitimate_for_speculation_p(), and targetm.

Referenced by haifa_speculate_insn().

basic_block sched_split_block_1 ( )
A generic version of sched_split_block ().   

References edge_def::dest, split_block(), and edge_def::src.

Referenced by haifa_sched_init().

bool schedule_block ( )
Use forward list scheduling to rearrange insns of block pointed to by
   TARGET_BB, possibly bringing insns from subsequent blocks in the same
   region.   

References advance(), advance_one_cycle(), asm_noperands(), haifa_sched_info::begin_schedule_ready, sched_block_state::can_issue_more, haifa_sched_info::can_schedule_ready_p, choose_ready(), clock_var, commit_schedule(), cycle_issued_insns, dbg_cnt(), debug_ready_list(), haifa_saved_data::delay_pair, dfa_state_size, DONT_BREAK_DEPENDENCIES, dump_new_block_header(), early_queue_to_ready(), find_modifiable_mems(), hash_table< Descriptor, Allocator >::find_with_hash(), ready_list::first, sched_block_state::first_cycle_insn_p, fix_inter_tick(), haifa_sched_info::flags, free_backtrack_queue(), free_INSN_LIST_list(), free_INSN_LIST_node(), free_topmost_backtrack_point(), generate_recovery_code(), haifa_recovery_bb_recently_added_p, haifa_sched_info::head, delay_pair::i1, haifa_sched_info::init_ready_list, insn_queue, hash_table< Descriptor, Allocator >::is_created(), issue_rate, last_clock_var, last_nondebug_scheduled_insn, last_scheduled_insn, memcpy(), memset(), model_end_schedule(), model_start_schedule(), modulo_backtracks_left, sched_block_state::modulo_epilogue, modulo_ii, modulo_insns_scheduled, modulo_iter0_max_uid, modulo_last_stage, modulo_max_stages, modulo_n_insns, must_backtrack, ready_list::n_debug, ready_list::n_ready, next_nonnote_insn(), haifa_sched_info::next_tail, nonscheduled_insns_begin, perform_replacements_new_cycle(), haifa_sched_info::prev_head, print_curr_reg_pressure(), prune_ready_list(), q_ptr, q_size, queue_insn(), haifa_sched_info::queue_must_finish_empty, queue_to_ready(), ready_add(), ready_element(), ready_lastpos(), ready_remove(), ready_remove_first(), ready_sort(), recog_memoized(), reload_completed, resolve_dependencies(), restore_bb_notes(), restore_last_backtrack_point(), restore_other_notes(), save_backtrack_point(), sched_dump, sched_extend_luids(), sched_pressure, SCHED_PRESSURE_MODEL, SCHED_PRESSURE_NONE, SCHED_PRESSURE_WEIGHTED, sched_verbose, schedule_insn(), haifa_sched_info::schedule_more_p, sched_block_state::shadows_only_p, haifa_sched_info::tail, targetm, toggle_cancelled_flags(), undo_all_replacements(), unschedule_insns_until(), ready_list::veclen, and verify_shadows().

Referenced by schedule_ebb(), and schedule_region().

static int schedule_insn ( rtx  )
static

Referenced by schedule_block().

void schedule_insns ( void  )
In sched-rgn.c.   

Referenced by rest_of_handle_sched(), and rest_of_handle_sched2().

void set_modulo_params ( )
After the scheduler initialization function has been called, this function
   can be called to enable modulo scheduling.  II is the initiation interval
   we should use, it affects the delays for delay_pairs that were recorded as
   separated by a given number of stages.

   MAX_STAGES provides us with a limit
   after which we give up scheduling; the caller must have unrolled at least
   as many copies of the loop body and recorded delay_pairs for them.
   
   INSNS is the number of real (non-debug) insns in one iteration of
   the loop.  MAX_UID can be used to test whether an insn belongs to
   the first iteration of the loop; all of them have a uid lower than
   MAX_UID.   

References max_uid, modulo_backtracks_left, modulo_ii, modulo_iter0_max_uid, modulo_max_stages, and modulo_n_insns.

int set_priorities ( )
Set_priorities: compute priority of each insn in the block.   

References priority(), and haifa_sched_info::sched_max_insns_priority.

Referenced by compute_priorities(), and schedule_ebb().

static void setup_insn_max_reg_pressure ( )
static
Set up or update (if UPDATE_P) max register pressure (see its
   meaning in sched-int.h::_haifa_insn_data) for all current BB insns
   after insn AFTER.   

References curr_reg_pressure, reg_set_data::insn, restore_reg_pressure(), save_reg_pressure(), and update_register_pressure().

Referenced by sched_setup_bb_reg_pressure_info(), and update_reg_and_insn_max_reg_pressure().

static void setup_insn_reg_pressure_info ( )
static
Setup info about the current register pressure impact of scheduling
   INSN at the current scheduling point.   

References calculate_reg_deaths(), curr_reg_pressure, and reg_pressure_data::set_increase.

Referenced by ready_sort().

static void setup_ref_regs ( )
static
Mark registers in X as mentioned in the current region.   

References bitmap_set_bit(), and bitmap_set_range().

Referenced by initiate_bb_reg_pressure_info().

void setup_sched_dump ( void  )
Set dump and sched_verbose for the desired debugging output.  If no
   dump-file was specified, but -fsched-verbose=N (any N), print to stderr.
   For -fsched-verbose=N, N>=10, print everything to stderr.   

References dump_file, sched_dump, and sched_verbose.

Referenced by haifa_sched_init(), and sel_global_init().

static void swap_sort ( rtx ,
int   
)
static
static HAIFA_INLINE void swap_sort ( )
static
Resort the array A in which only element at index N may be out of order.   

References rank_for_schedule().

static void toggle_cancelled_flags ( )
static
Walk the ready list and all queues. If any insns have unresolved backwards
   dependencies, these must be cancelled deps, broken by predication.  Set or
   clear (depending on SET) the DEP_CANCELLED bit in DEP_STATUS.   

References first, insn_queue, ready_list::n_ready, q_ptr, and ready_lastpos().

Referenced by restore_last_backtrack_point(), and schedule_block().

int try_ready ( )
Check if NEXT is ready to be added to the ready or queue list.
   If "yes", add it to the proper list.
   Returns:
      -1 - is not ready yet,
       0 - added to the ready list,
   0 < N - queued for N cycles.   

References adjust_priority(), change_queue_index(), spec_info_def::dump, fix_tick_ready(), haifa_change_pattern(), haifa_speculate_insn(), haifa_sched_info::new_ready, haifa_sched_info::print_insn, recompute_todo_spec(), sched_dump, and sched_verbose.

Referenced by create_check_block_twin(), fix_recovery_deps(), init_ready_list(), and schedule_insn().

static void undo_all_replacements ( )
static
When we know we are going to discard the schedule due to a failed attempt
   at modulo scheduling, undo all replacements.   

References dep_replacement::insn, dep_replacement::loc, dep_replacement::orig, sd_iterator_cond(), sd_iterator_next(), sd_iterator_start(), and validate_change().

Referenced by schedule_block().

static void undo_replacements_for_backtrack ( )
static
Undo the replacements that have occurred after backtrack point SAVE
   was placed.   

References apply_replacement(), haifa_saved_data::replace_apply, haifa_saved_data::replacement_deps, and restore_pattern().

Referenced by free_topmost_backtrack_point(), and restore_last_backtrack_point().

void unlink_bb_notes ( )
Unlink basic block notes and labels and saves them, so they
   can be easily restored.  We unlink basic block notes in EBB to
   provide back-compatibility with the previous code, as target backends
   assume, that there'll be only instructions between
   current_sched_info->{head and tail}.  We restore these notes as soon
   as we can.
   FIRST (LAST) is the first (last) basic block in the ebb.
   NB: In usual case (FIRST == LAST) nothing is really done.   

References bb_header, basic_block_def::index, basic_block_def::next_bb, and basic_block_def::prev_bb.

Referenced by schedule_ebb(), and schedule_region().

static void unschedule_insns_until ( )
static
Pop entries from the SCHEDULED_INSNS vector up to and including INSN.
   Restore their dependencies to an unresolved state, and mark them as
   queued nowhere.   

References haifa_change_pattern(), last, modulo_ii, modulo_insns_scheduled, modulo_iter0_max_uid, recompute_todo_spec(), sd_iterator_cond(), sd_iterator_start(), sd_lists_empty_p(), sd_unresolve_dep(), and vNULL.

Referenced by schedule_block().

static void update_insn_after_change ( )
static
This function should be called after modifying the pattern of INSN,
   to update scheduler data structures as needed.   

References sd_iterator_cond(), sd_iterator_next(), and sd_iterator_start().

Referenced by apply_replacement(), haifa_change_pattern(), and restore_pattern().

static void update_reg_and_insn_max_reg_pressure ( )
static
Update the current register pressure after scheduling INSN.  Update
   also max register pressure for unscheduled insns of the current
   BB.   

References curr_reg_pressure, setup_insn_max_reg_pressure(), and update_register_pressure().

Referenced by schedule_insn().

static void update_register_pressure ( )
static
static struct haifa_saved_data* verify_shadows ( )
staticread
Called when we detect that the schedule is impossible.  We examine the
   backtrack queue to find the earliest insn that caused this condition.   

References clock_var, haifa_saved_data::delay_pair, i1, delay_pair::i1, i2, delay_pair::i2, haifa_saved_data::next, delay_pair::next_same_i1, pair_delay(), sched_dump, and sched_verbose.

Referenced by schedule_block().

void* xrecalloc ( )
Extends and fills with zeros (only the new part) array pointed to by P.   

References memset().

Referenced by fill_vec_av_set(), maybe_extend_reg_info_p(), and sched_extend_ready_list().


Variable Documentation

bool adding_bb_to_current_region_p = true
FALSE if we add bb to another region, so we don't need to initialize it.   

Referenced by haifa_init_insn(), and init_before_recovery().

basic_block after_recovery
Basic block just before the EXIT_BLOCK and after recovery, if we have
   created it.   

Referenced by sel_global_init().

struct haifa_saved_data* backtrack_queue
static
A record, in reverse order, of all scheduled insns which have delay slots
   and may require backtracking.   

Referenced by free_topmost_backtrack_point(), restore_last_backtrack_point(), and save_backtrack_point().

rtx* bb_header = 0
static
Array used in {unlink, restore}_bb_notes.   

Referenced by restore_bb_notes(), and unlink_bb_notes().

basic_block before_recovery
static
Basic block after which recovery blocks will be created.   

Referenced by init_before_recovery().

int cached_first_cycle_multipass_dfa_lookahead = 0
static
The following value is value of hook
   `first_cycle_multipass_dfa_lookahead' at the last call of
   `max_issue'.   

Referenced by max_issue(), and sched_init().

int cached_issue_rate = 0
static
The following value is value of `issue_rate' at the last call of
   `sched_init'.   

Referenced by sched_init().

struct choice_entry* choice_stack
static
The following array is used to implement a stack of choices used in
   function max_issue.   

Referenced by max_issue().

struct common_sched_info_def* common_sched_info
This is a placeholder for the scheduler parameters common
   to all schedulers.   

Referenced by haifa_find_rgns(), rgn_setup_common_sched_info(), schedule_ebbs_init(), setup_sched_infos(), and too_large().

bitmap curr_reg_live
static
Register living at given scheduling point.   
state_t curr_state
The following variable value refers for all current and future
   reservations of the processor units.   

Referenced by advance_one_cycle(), invoke_aftermath_hooks(), merge_states(), new_ready(), partition_equiv_class(), ps_has_conflicts(), reset_sched_cycles_in_current_ebb(), schedule_region(), and sel_dfa_new_cycle().

int cycle_issued_insns
The following variable value is number of essential insns issued on
   the current cycle.  An insn is essential one if it changes the
   processors state.   

Referenced by choose_best_insn(), max_issue(), restore_last_backtrack_point(), save_backtrack_point(), and schedule_block().

hash_table<delay_i1_hasher> delay_htab
static
Two hash tables to record delay_pairs, one indexed by I1 and the other
   indexed by I2.   
hash_table<delay_i2_hasher> delay_htab_i2
static
int dfa_lookahead
This holds the value of the target dfa_lookahead hook.   

Referenced by choose_best_insn(), max_issue(), and sched_init().

Haifa Instruction Data.   
struct common_sched_info_def haifa_common_sched_info
Initial value:
Haifa version of sched_info hooks common to all headers.   

Referenced by rgn_setup_common_sched_info(), schedule_ebbs_init(), and setup_sched_infos().

bool haifa_recovery_bb_ever_added_p
True, if recovery block was added during this scheduling pass.
   Used to determine if we should have empty memory pools of dependencies
   after finishing current region.   

Referenced by haifa_sched_init(), sched_create_recovery_block(), schedule_ebb(), and schedule_region().

bool haifa_recovery_bb_recently_added_p
static
True, if recovery block was added during scheduling of current block.
   Used to determine, if we need to fix INSN_TICKs.   

Referenced by sched_create_recovery_block(), and schedule_block().

rtx* insn_queue
static
Queues, etc.   
An instruction is ready to be scheduled when all insns preceding it
   have already been scheduled.  It is important to ensure that all
   insns which use its result will not be executed until its result
   has been computed.  An insn is maintained in one of four structures:

   (P) the "Pending" set of insns which cannot be scheduled until
   their dependencies have been satisfied.
   (Q) the "Queued" set of insns that can be scheduled when sufficient
   time has passed.
   (R) the "Ready" list of unscheduled, uncommitted insns.
   (S) the "Scheduled" list of insns.

   Initially, all insns are either "Pending" or "Ready" depending on
   whether their dependencies are satisfied.

   Insns move from the "Ready" list to the "Scheduled" list as they
   are committed to the schedule.  As this occurs, the insns in the
   "Pending" list have their dependencies satisfied and move to either
   the "Ready" list or the "Queued" set depending on whether
   sufficient time has passed to make them ready.  As time passes,
   insns move from the "Queued" set to the "Ready" list.

   The "Pending" list (P) are the insns in the INSN_FORW_DEPS of the
   unscheduled insns, i.e., those that are ready, queued, and pending.
   The "Queued" set (Q) is implemented by the variable `insn_queue'.
   The "Ready" list (R) is implemented by the variables `ready' and
   `n_ready'.
   The "Scheduled" list (S) is the new insn chain built by this pass.

   The transition (R->S) is implemented in the scheduling loop in
   `schedule_block' when the best insn to schedule is chosen.
   The transitions (P->R and P->Q) are implemented in `schedule_insn' as
   insns move from the ready list to the scheduled list.
   The transition (Q->R) is implemented in 'queue_to_insn' as time
   passes or stalls are introduced.   
Implement a circular buffer to delay instructions until sufficient
   time has passed.  For the new pipeline description interface,
   MAX_INSN_QUEUE_INDEX is a power of two minus one which is not less
   than maximal time of instruction execution computed by genattr.c on
   the base maximal time of functional unit reservations and getting a
   result.  This is the longest time an insn may be queued.   

Referenced by check_clobbered_conditions(), early_queue_to_ready(), queue_insn(), queue_remove(), queue_to_ready(), restore_last_backtrack_point(), save_backtrack_point(), schedule_block(), and toggle_cancelled_flags().

int issue_rate
@verbatim Instruction scheduling pass.

Copyright (C) 1992-2013 Free Software Foundation, Inc. Contributed by Michael Tiemann (tiema.nosp@m.nn@c.nosp@m.ygnus.nosp@m..com) Enhanced by, and currently maintained by, Jim Wilson (wilso.nosp@m.n@cy.nosp@m.gnus..nosp@m.com)

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/.

Instruction scheduling pass.  This file, along with sched-deps.c,
   contains the generic parts.  The actual entry point is found for
   the normal instruction scheduling pass is found in sched-rgn.c.

   We compute insn priorities based on data dependencies.  Flow
   analysis only creates a fraction of the data-dependencies we must
   observe: namely, only those dependencies which the combiner can be
   expected to use.  For this pass, we must therefore create the
   remaining dependencies we need to observe: register dependencies,
   memory dependencies, dependencies to keep function calls in order,
   and the dependence between a conditional branch and the setting of
   condition codes are all dealt with here.

   The scheduler first traverses the data flow graph, starting with
   the last instruction, and proceeding to the first, assigning values
   to insn_priority as it goes.  This sorts the instructions
   topologically by data dependence.

   Once priorities have been established, we order the insns using
   list scheduling.  This works as follows: starting with a list of
   all the ready insns, and sorted according to priority number, we
   schedule the insn from the end of the list by placing its
   predecessors in the list according to their priority order.  We
   consider this insn scheduled by setting the pointer to the "end" of
   the list to point to the previous insn.  When an insn has no
   predecessors, we either queue it until sufficient time has elapsed
   or add it to the ready list.  As the instructions are scheduled or
   when stalls are introduced, the queue advances and dumps insns into
   the ready list.  When all insns down to the lowest priority have
   been scheduled, the critical path of the basic block has been made
   as short as possible.  The remaining insns are then scheduled in
   remaining slots.

   The following list shows the order in which we want to break ties
   among insns in the ready list:

   1.  choose insn with the longest path to end of bb, ties
   broken by
   2.  choose insn with least contribution to register pressure,
   ties broken by
   3.  prefer in-block upon interblock motion, ties broken by
   4.  prefer useful upon speculative motion, ties broken by
   5.  choose insn with largest control flow probability, ties
   broken by
   6.  choose insn with the least dependences upon the previously
   scheduled insn, or finally
   7   choose the insn which has the most insns dependent on it.
   8.  choose insn with lowest UID.

   Memory references complicate matters.  Only if we can be certain
   that memory references are not part of the data dependency graph
   (via true, anti, or output dependence), can we move operations past
   memory references.  To first approximation, reads can be done
   independently, while writes introduce dependencies.  Better
   approximations will yield fewer dependencies.

   Before reload, an extended analysis of interblock data dependences
   is required for interblock scheduling.  This is performed in
   compute_block_backward_dependences ().

   Dependencies set up by memory references are treated in exactly the
   same way as other dependencies, by using insn backward dependences
   INSN_BACK_DEPS.  INSN_BACK_DEPS are translated into forward dependences
   INSN_FORW_DEPS the purpose of forward list scheduling.

   Having optimized the critical path, we may have also unduly
   extended the lifetimes of some registers.  If an operation requires
   that constants be loaded into registers, it is certainly desirable
   to load those constants as early as necessary, but no earlier.
   I.e., it will not do to load up a bunch of registers at the
   beginning of a basic block only to use them at the end, if they
   could be loaded later, since this may result in excessive register
   utilization.

   Note that since branches are never in basic blocks, but only end
   basic blocks, this pass will not move branches.  But that is ok,
   since we can use GNU's delayed branch scheduling pass to take care
   of this case.

   Also note that no further optimizations based on algebraic
   identities are performed, so this pass would be a good one to
   perform instruction splitting, such as breaking up a multiply
   instruction into shifts and adds where that is profitable.

   Given the memory aliasing analysis that this pass should perform,
   it should be possible to remove redundant stores to memory, and to
   load values from registers instead of hitting memory.

   Before reload, speculative insns are moved only if a 'proof' exists
   that no exception will be caused by this, and if no live registers
   exist that inhibit the motion (live registers constraints are not
   represented by data dependence edges).

   This pass must update information that subsequent passes expect to
   be correct.  Namely: reg_n_refs, reg_n_sets, reg_n_deaths,
   reg_n_calls_crossed, and reg_live_length.  Also, BB_HEAD, BB_END.

   The information in the line number notes is carefully retained by
   this pass.  Notes that refer to the starting and ending of
   exception regions are also carefully retained by this pass.  All
   other NOTE insns are grouped in their same relative order at the
   beginning of basic blocks and regions that have been scheduled.   
issue_rate is the number of insns that can be scheduled in the same
   machine cycle.  It can be defined in the config/mach/mach.h file,
   otherwise we set it to 1.   
int last_clock_var
static
Clock at which the previous instruction was issued.   

Referenced by restore_last_backtrack_point(), save_backtrack_point(), schedule_block(), and schedule_insn().

rtx last_nondebug_scheduled_insn
static
Pointer to the last nondebug instruction scheduled within the
   block, or the prev_head of the scheduling block.  Used by
   rank_for_schedule, so that insns independent of the last scheduled
   insn will be preferred over dependent instructions.   

Referenced by rank_for_schedule(), restore_last_backtrack_point(), save_backtrack_point(), and schedule_block().

rtx last_scheduled_insn
static
Pointer to the last instruction scheduled.   

Referenced by commit_schedule(), restore_last_backtrack_point(), save_backtrack_point(), sched_emit_insn(), and schedule_block().

int max_lookahead_tries
static
The following variable value is maximal number of tries of issuing
   insns for the first cycle multipass insn scheduling.  We define
   this value as constant*(DFA_LOOKAHEAD**ISSUE_RATE).  We would not
   need this constraint if all real insns (with non-negative codes)
   had reservations because in this case the algorithm complexity is
   O(DFA_LOOKAHEAD**ISSUE_RATE).  Unfortunately, the dfa descriptions
   might be incomplete and such insn might occur.  For such
   descriptions, the complexity of algorithm (without the constraint)
   could achieve DFA_LOOKAHEAD ** N , where N is the queue length.   

Referenced by max_issue().

struct model_pressure_group model_before_pressure
static
int model_curr_point
static
The index of the first instruction in model_schedule that hasn't yet been
   added to the main schedule, or model_num_insns if all of them have.   

Referenced by model_recompute(), model_start_schedule(), model_update_limit_points_in_group(), queue_to_ready(), ready_sort(), and schedule_insn().

struct model_insn_info* model_insns
static
Index I describes the instruction with INSN_LUID I.   
unsigned int model_next_priority
static
The first unused model_priority value (as used in model_insn_info).   

Referenced by model_promote_predecessors(), and model_start_schedule().

vec<rtx> model_schedule
static
Index POINT gives the instruction at point POINT of the model schedule.
   This array doesn't change during main scheduling.   
struct model_insn_info* model_worklist
static
The list of instructions in the model worklist, sorted in order of
   decreasing priority.   

Referenced by model_add_to_worklist_at(), and model_choose_insn().

int modulo_backtracks_left
static
The number of times we should attempt to backtrack when modulo scheduling.
   Decreased each time we have to backtrack.   

Referenced by schedule_block(), and set_modulo_params().

int modulo_ii
static
The current initiation interval used when modulo scheduling.   

Referenced by haifa_sched_init(), pair_delay(), schedule_block(), set_modulo_params(), and unschedule_insns_until().

int modulo_insns_scheduled
static
The current count of insns in the first iteration of the loop that have
   already been scheduled.   

Referenced by schedule_block(), and unschedule_insns_until().

int modulo_iter0_max_uid
static
The maximum uid of insns from the first iteration of the loop.   

Referenced by schedule_block(), set_modulo_params(), and unschedule_insns_until().

int modulo_last_stage
static
The stage in which the last insn from the original loop was
   scheduled.   

Referenced by schedule_block().

int modulo_max_stages
static
The maximum number of stages we are prepared to handle.   

Referenced by schedule_block(), and set_modulo_params().

int modulo_n_insns
static
The number of insns that exist in each iteration of the loop.  We use this
   to detect when we've scheduled all insns from the first iteration.   

Referenced by schedule_block(), and set_modulo_params().

bool must_backtrack
static
Set to true if, when queuing a shadow insn, we discover that it would be
   scheduled too late.   

Referenced by queue_insn(), ready_add(), and schedule_block().

vec<int> next_cycle_apply
static
vec<dep_t> next_cycle_replace_deps
static
Two VECs, one to hold dependencies for which pattern replacements
   need to be applied or restored at the start of the next cycle, and
   another to hold an integer that is either one, to apply the
   corresponding replacement, or zero to restore it.   
rtx nonscheduled_insns_begin
static
Pointer that iterates through the list of unscheduled insns if we
   have a dbg_cnt enabled.  It always points at an insn prior to the
   first unscheduled one.   

Referenced by choose_ready(), queue_to_ready(), sched_emit_insn(), and schedule_block().

rtx note_list
List of important notes we must keep around.  This is a pointer to the
   last element in the list.   

Referenced by remove_notes(), and restore_other_notes().

int nr_be_in_control
static
int nr_be_in_data
static
int nr_begin_control
static
int nr_begin_data
static
Counters of different types of speculative instructions.   

Referenced by begin_speculative_block(), haifa_sched_finish(), and haifa_sched_init().

char* ready_try = NULL
The following array is used to find the best insn from ready when
   the automaton pipeline interface is used.   

Referenced by calculate_privileged_insns(), choose_ready(), convert_vec_av_set_to_ready(), invoke_dfa_lookahead_guard(), max_issue(), sched_extend_ready_list(), and sched_finish_ready_list().

struct ready_list* readyp = &ready
static
The pointer to the ready list (to be removed).   
bitmap region_ref_regs
static
Registers mentioned in the current region.   
bitmap saved_reg_live
static
Saved value of the previous array.   
int saved_reg_pressure[N_REG_CLASSES]
static
Saved value of the previous array.   

Referenced by restore_reg_pressure(), and save_reg_pressure().

basic_block(* sched_create_empty_bb)(basic_block)
Create empty basic block after the specified block.   

Referenced by haifa_sched_finish(), haifa_sched_init(), and init_before_recovery().

vec<int> sched_luids = vNULL
Mapping from instruction UID to its Logical UID.   

Referenced by sel_dump_cfg_insn().

bool sched_no_dce
This can be set to true by a backend if the scheduler should not
   enable a DCE pass.   

Referenced by sched_init().

int sched_ready_n_insns = -1
static
enum reg_class* sched_regno_pressure_class
Map regno -> its pressure class.  The map defined only when
   SCHED_PRESSURE != SCHED_PRESSURE_NONE.   

Referenced by mark_hard_regno_death(), mark_insn_hard_regno_birth(), mark_insn_pseudo_birth(), mark_pseudo_death(), mark_regno_birth_or_death(), sched_finish(), and sched_init().

basic_block(* sched_split_block)(basic_block, rtx)
Split block function.  Different schedulers might use different functions
   to handle their internal data consistent.   

Referenced by create_block_for_bookkeeping(), create_check_block_twin(), haifa_sched_finish(), and haifa_sched_init().

int sched_verbose = 0
sched-verbose controls the amount of debugging output the
   scheduler prints.  It is controlled by -fsched-verbose=N:
   N>0 and no -DSR : the output is directed to stderr.
   N>=10 will direct the printouts to stderr (regardless of -dSR).
   N=1: same as -dSR.
   N=2: bb's probabilities, detailed ready list info, unit/insn info.
   N=3: rtl at abort point, control-flow, regions info.
   N=5: dependences info.   

Referenced by add_delay_dependencies(), add_dependence(), add_to_speculative_block(), advance_one_cycle(), advance_state_on_fence(), apply_replacement(), attempt_change(), calculate_new_fences(), calculate_privileged_insns(), change_queue_index(), choose_best_insn(), choose_ready(), code_motion_path_driver(), code_motion_process_successors(), commit_schedule(), compute_av_set_at_bb_end(), compute_av_set_inside_bb(), compute_av_set_on_boundaries(), compute_dom_prob_ps(), cond_clobbered_p(), create_block_for_bookkeeping(), create_check_block_twin(), early_queue_to_ready(), extend_rgns(), extract_new_fences_from(), fill_insns(), fill_vec_av_set(), find_best_expr(), find_ebb_boundaries(), find_inc(), find_mem(), find_modifiable_mems(), find_place_for_bookkeeping(), find_sequential_best_exprs(), generate_bookkeeping_insn(), get_ebb_head_tail(), implicit_clobber_conflict_p(), init_before_recovery(), init_ready_list(), invoke_aftermath_hooks(), invoke_dfa_lookahead_guard(), invoke_reorder_hooks(), model_choose_insn(), model_promote_predecessors(), model_recompute(), model_record_pressures(), model_set_excess_costs(), model_start_schedule(), move_cond_jump(), moveup_expr(), moveup_expr_cached(), moveup_set_inside_insn_group(), moving_insn_creates_bookkeeping_block_p(), ps_has_conflicts(), put_TImodes(), queue_insn(), queue_to_ready(), remove_insns_that_need_bookkeeping(), reset_sched_cycles_in_current_ebb(), resolve_dependencies(), restore_pattern(), sched_create_recovery_block(), sched_finish(), sched_init(), sched_rgn_finish(), sched_rgn_init(), schedule_block(), schedule_insn(), schedule_on_fences(), schedule_region(), sel_add_to_insn_priority(), sel_compute_priorities(), sel_dfa_new_cycle(), sel_region_init(), sel_region_target_finish(), sel_sched_region(), sel_sched_region_2(), sel_target_adjust_priority(), setup_sched_dump(), try_bitmap_cache(), try_ready(), try_transformation_cache(), undo_transformations(), update_boundaries(), update_fence_and_insn(), and verify_shadows().

vec<rtx> scheduled_insns
static
This records the actual schedule.  It is built up during the main phase
   of schedule_block, and afterwards used to reorder the insns in the RTL.   

Referenced by fill_insns(), and sel_sched_region_2().

spec_info_t spec_info = NULL
Description of the speculative part of the scheduling.
   If NULL - no speculation.   

Referenced by add_deps_for_risky_insns(), can_speculate_dep_p(), get_spec_check_type_for_insn(), new_ready(), process_spec_exprs(), sched_analyze_2(), and sel_rank_for_schedule().

struct spec_info_def spec_info_var
static

Referenced by sched_init().