Lines Matching defs:ps

136 /* The minimum (absolute) cycle that a node of ps was scheduled in.  */
137 #define PS_MIN_CYCLE(ps) (((partial_schedule_ptr)(ps))->min_cycle)
139 /* The maximum (absolute) cycle that a node of ps was scheduled in. */
140 #define PS_MAX_CYCLE(ps) (((partial_schedule_ptr)(ps))->max_cycle)
145 /* The number of different iterations the nodes in ps span, assuming
149 /* The stage count of ps. */
150 #define PS_STAGE_COUNT(ps) (((partial_schedule_ptr)(ps))->stage_count)
276 /* The column of a node inside the ps. If nodes u, v are on the same row,
334 ps_reg_move (partial_schedule_ptr ps, int id)
336 gcc_checking_assert (id >= ps->g->num_nodes);
337 return &ps->reg_moves[id - ps->g->num_nodes];
343 ps_rtl_insn (partial_schedule_ptr ps, int id)
345 if (id < ps->g->num_nodes)
346 return ps->g->nodes[id].insn;
348 return ps_reg_move (ps, id)->insn;
357 ps_first_note (partial_schedule_ptr ps, int id)
359 gcc_assert (id < ps->g->num_nodes);
360 return ps->g->nodes[id].first_note;
366 ps_num_consecutive_stages (partial_schedule_ptr ps, int id)
368 if (id < ps->g->num_nodes)
371 return ps_reg_move (ps, id)->num_consecutive_stages;
488 extend_node_sched_params (partial_schedule_ptr ps)
490 node_sched_param_vec.safe_grow_cleared (ps->g->num_nodes
491 + ps->reg_moves.length ());
525 print_node_sched_params (FILE *file, int num_nodes, partial_schedule_ptr ps)
536 INSN_UID (ps_rtl_insn (ps, i)));
537 fprintf (file, " asap = %d:\n", NODE_ASAP (&ps->g->nodes[i]));
545 set_columns_for_row (partial_schedule_ptr ps, int row)
551 for (cur_insn = ps->rows[row]; cur_insn; cur_insn = cur_insn->next_in_row)
557 set_columns_for_ps (partial_schedule_ptr ps)
561 for (row = 0; row < ps->ii; row++)
562 set_columns_for_row (ps, row);
582 schedule_reg_move (partial_schedule_ptr ps, int i_reg_move,
593 move = ps_reg_move (ps, i_reg_move);
594 ii = ps->ii;
599 PS_MIN_CYCLE (ps));
627 this_insn = ps_rtl_insn (ps, move->def);
629 this_distance = distance1_uses && move->def < ps->g->num_nodes ? 1 : 0;
648 this_insn = ps_rtl_insn (ps, u);
680 psi = ps_add_node_check_conflicts (ps, i_reg_move, c,
684 update_node_sched_params (i_reg_move, ii, c, PS_MIN_CYCLE (ps));
711 schedule_reg_moves (partial_schedule_ptr ps)
713 ddg_ptr g = ps->g;
714 int ii = ps->ii;
778 first_move = ps->reg_moves.length ();
779 ps->reg_moves.safe_grow_cleared (first_move + nreg_moves);
780 extend_node_sched_params (ps);
783 first_move += ps->g->num_nodes;
789 ps_reg_move_info *move = ps_reg_move (ps, first_move + i_reg_move);
829 move = ps_reg_move (ps, first_move + dest_copy - 1);
838 if (!schedule_reg_move (ps, first_move + i_reg_move,
853 apply_reg_moves (partial_schedule_ptr ps)
858 FOR_EACH_VEC_ELT (ps->reg_moves, i, move)
865 replace_rtx (ps->g->nodes[i_use].insn, move->old_reg, move->new_reg);
866 df_insn_rescan (ps->g->nodes[i_use].insn);
875 reset_sched_times (partial_schedule_ptr ps, int amount)
878 int ii = ps->ii;
882 for (crr_insn = ps->rows[row]; crr_insn; crr_insn = crr_insn->next_in_row)
886 int new_min_cycle = PS_MIN_CYCLE (ps) - amount;
891 rtx_insn *insn = ps_rtl_insn (ps, u);
901 gcc_assert (SCHED_TIME (u) >= ps->min_cycle);
902 gcc_assert (SCHED_TIME (u) <= ps->max_cycle);
913 permute_partial_schedule (partial_schedule_ptr ps, rtx_insn *last)
915 int ii = ps->ii;
920 for (ps_ij = ps->rows[row]; ps_ij; ps_ij = ps_ij->next_in_row)
922 rtx_insn *insn = ps_rtl_insn (ps, ps_ij->id);
926 if (ps_ij->id < ps->g->num_nodes)
927 reorder_insns_nobb (ps_first_note (ps, ps_ij->id), insn,
968 optimize_sc (partial_schedule_ptr ps, ddg_ptr g)
970 int amount = PS_MIN_CYCLE (ps);
973 int ii = ps->ii;
979 stage_count = calculate_stage_count (ps, amount);
981 calculate_stage_count (ps, SCHED_TIME (g->closing_branch->cuid) - (ii - 1));
996 print_partial_schedule (ps, dump_file);
1000 reset_sched_times (ps, amount);
1001 rotate_partial_schedule (ps, amount);
1007 print_partial_schedule (ps, dump_file);
1020 if (get_sched_window (ps, g->closing_branch, sched_nodes, ii, &start,
1026 int row = SMODULO (branch_cycle, ps->ii);
1079 for (next_ps_i = ps->rows[row];
1084 min_cycle = PS_MIN_CYCLE (ps) - SMODULO (PS_MIN_CYCLE (ps), ps->ii);
1085 remove_node_from_ps (ps, next_ps_i);
1087 try_scheduling_node_in_cycle (ps, g->closing_branch->cuid, c,
1105 try_scheduling_node_in_cycle (ps, g->closing_branch->cuid,
1120 PS_MIN_CYCLE (ps));
1125 if (PS_MIN_CYCLE (ps) < min_cycle)
1126 reset_sched_times (ps, 0);
1138 duplicate_insns_of_cycles (partial_schedule_ptr ps, int from_stage,
1144 for (row = 0; row < ps->ii; row++)
1145 for (ps_ij = ps->rows[row]; ps_ij; ps_ij = ps_ij->next_in_row)
1157 u_insn = ps_rtl_insn (ps, u);
1163 last_u = first_u + ps_num_consecutive_stages (ps, u) - 1;
1166 if (u < ps->g->num_nodes)
1167 duplicate_insn_chain (ps_first_note (ps, u), u_insn);
1177 generate_prolog_epilog (partial_schedule_ptr ps, struct loop *loop,
1181 int last_stage = PS_STAGE_COUNT (ps) - 1;
1205 duplicate_insns_of_cycles (ps, 0, i, count_reg);
1219 duplicate_insns_of_cycles (ps, i + 1, last_stage, count_reg);
1397 partial_schedule_ptr ps;
1668 ps = sms_schedule_by_order (g, mii, maxii, node_order);
1670 if (ps)
1677 opt_sc_p = optimize_sc (ps, g);
1679 stage_count = calculate_stage_count (ps, 0);
1684 - (ps->ii - 1));
1689 stage_count = calculate_stage_count (ps, amount);
1718 int amount = SCHED_TIME (g->closing_branch->cuid) - (ps->ii - 1);
1720 reset_sched_times (ps, amount);
1721 rotate_partial_schedule (ps, amount);
1724 set_columns_for_ps (ps);
1726 min_cycle = PS_MIN_CYCLE (ps) - SMODULO (PS_MIN_CYCLE (ps), ps->ii);
1727 if (!schedule_reg_moves (ps))
1729 mii = ps->ii + 1;
1730 free_partial_schedule (ps);
1739 if (PS_MIN_CYCLE (ps) < min_cycle)
1741 reset_sched_times (ps, 0);
1746 gcc_checking_assert (stage_count == calculate_stage_count (ps, 0));
1747 PS_STAGE_COUNT (ps) = stage_count;
1755 ps->ii, stage_count);
1756 print_partial_schedule (ps, dump_file);
1779 permute_partial_schedule (ps, g->closing_branch->first_note);
1789 apply_reg_moves (ps);
1791 print_node_sched_params (dump_file, g->num_nodes, ps);
1793 generate_prolog_epilog (ps, loop, count_reg, count_init);
1797 free_partial_schedule (ps);
1903 get_sched_window (partial_schedule_ptr ps, ddg_node_ptr u_node,
1910 sbitmap psp = sbitmap_alloc (ps->g->num_nodes);
1911 sbitmap pss = sbitmap_alloc (ps->g->num_nodes);
2158 try_scheduling_node_in_cycle (partial_schedule_ptr ps,
2166 verify_partial_schedule (ps, sched_nodes);
2167 psi = ps_add_node_check_conflicts (ps, u, cycle, must_precede, must_follow);
2197 partial_schedule_ptr ps = create_partial_schedule (ii, g, DFA_HISTORY);
2213 ddg_node_ptr u_node = &ps->g->nodes[u];
2227 if (get_sched_window (ps, u_node, sched_nodes, ii, &start,
2250 try_scheduling_node_in_cycle (ps, u, c,
2258 verify_partial_schedule (ps, sched_nodes);
2271 verify_partial_schedule (ps, sched_nodes);
2272 reset_partial_schedule (ps, ii);
2273 verify_partial_schedule (ps, sched_nodes);
2283 ps->ii, u_node);
2286 ps->ii, u_node);
2288 ps_insert_empty_row (ps, split_row, sched_nodes);
2300 free_partial_schedule (ps);
2301 ps = NULL;
2311 return ps;
2318 ps_insert_empty_row (partial_schedule_ptr ps, int split_row,
2323 int ii = ps->ii;
2328 verify_partial_schedule (ps, sched_nodes);
2330 /* We normalize sched_time and rotate ps to have only non-negative sched
2332 split_row -= ps->min_cycle;
2337 reset_sched_times (ps, PS_MIN_CYCLE (ps));
2338 rotate_partial_schedule (ps, PS_MIN_CYCLE (ps));
2344 rows_new[row] = ps->rows[row];
2345 rows_length_new[row] = ps->rows_length[row];
2346 ps->rows[row] = NULL;
2365 rows_new[row + 1] = ps->rows[row];
2366 rows_length_new[row + 1] = ps->rows_length[row];
2367 ps->rows[row] = NULL;
2381 /* Updating ps. */
2382 ps->min_cycle = ps->min_cycle + ps->min_cycle / ii
2383 + (SMODULO (ps->min_cycle, ii) >= split_row ? 1 : 0);
2384 ps->max_cycle = ps->max_cycle + ps->max_cycle / ii
2385 + (SMODULO (ps->max_cycle, ii) >= split_row ? 1 : 0);
2386 free (ps->rows);
2387 ps->rows = rows_new;
2388 free (ps->rows_length);
2389 ps->rows_length = rows_length_new;
2390 ps->ii = new_ii;
2391 gcc_assert (ps->min_cycle >= 0);
2393 verify_partial_schedule (ps, sched_nodes);
2396 fprintf (dump_file, "min_cycle=%d, max_cycle=%d\n", ps->min_cycle,
2397 ps->max_cycle);
2460 verify_partial_schedule (partial_schedule_ptr ps, sbitmap sched_nodes)
2465 for (row = 0; row < ps->ii; row++)
2469 for (crr_insn = ps->rows[row]; crr_insn; crr_insn = crr_insn->next_in_row)
2475 /* ??? Test also that all nodes of sched_nodes are in ps, perhaps by
2476 popcount (sched_nodes) == number of insns in ps. */
2477 gcc_assert (SCHED_TIME (u) >= ps->min_cycle);
2478 gcc_assert (SCHED_TIME (u) <= ps->max_cycle);
2481 gcc_assert (ps->rows_length[row] == length);
2888 partial_schedule_ptr ps = XNEW (struct partial_schedule);
2889 ps->rows = (ps_insn_ptr *) xcalloc (ii, sizeof (ps_insn_ptr));
2890 ps->rows_length = (int *) xcalloc (ii, sizeof (int));
2891 ps->reg_moves.create (0);
2892 ps->ii = ii;
2893 ps->history = history;
2894 ps->min_cycle = INT_MAX;
2895 ps->max_cycle = INT_MIN;
2896 ps->g = g;
2898 return ps;
2904 free_ps_insns (partial_schedule_ptr ps)
2908 for (i = 0; i < ps->ii; i++)
2910 while (ps->rows[i])
2912 ps_insn_ptr ps_insn = ps->rows[i]->next_in_row;
2914 free (ps->rows[i]);
2915 ps->rows[i] = ps_insn;
2917 ps->rows[i] = NULL;
2924 free_partial_schedule (partial_schedule_ptr ps)
2929 if (!ps)
2932 FOR_EACH_VEC_ELT (ps->reg_moves, i, move)
2934 ps->reg_moves.release ();
2936 free_ps_insns (ps);
2937 free (ps->rows);
2938 free (ps->rows_length);
2939 free (ps);
2946 reset_partial_schedule (partial_schedule_ptr ps, int new_ii)
2948 if (!ps)
2950 free_ps_insns (ps);
2951 if (new_ii == ps->ii)
2953 ps->rows = (ps_insn_ptr *) xrealloc (ps->rows, new_ii
2955 memset (ps->rows, 0, new_ii * sizeof (ps_insn_ptr));
2956 ps->rows_length = (int *) xrealloc (ps->rows_length, new_ii * sizeof (int));
2957 memset (ps->rows_length, 0, new_ii * sizeof (int));
2958 ps->ii = new_ii;
2959 ps->min_cycle = INT_MAX;
2960 ps->max_cycle = INT_MIN;
2966 print_partial_schedule (partial_schedule_ptr ps, FILE *dump)
2970 for (i = 0; i < ps->ii; i++)
2972 ps_insn_ptr ps_i = ps->rows[i];
2977 rtx_insn *insn = ps_rtl_insn (ps, ps_i->id);
3006 remove_node_from_ps (partial_schedule_ptr ps, ps_insn_ptr ps_i)
3010 gcc_assert (ps && ps_i);
3012 row = SMODULO (ps_i->cycle, ps->ii);
3015 gcc_assert (ps_i == ps->rows[row]);
3016 ps->rows[row] = ps_i->next_in_row;
3017 if (ps->rows[row])
3018 ps->rows[row]->prev_in_row = NULL;
3027 ps->rows_length[row] -= 1;
3039 ps_insn_find_column (partial_schedule_ptr ps, ps_insn_ptr ps_i,
3051 row = SMODULO (ps_i->cycle, ps->ii);
3056 for (next_ps_i = ps->rows[row];
3076 && JUMP_P (ps_rtl_insn (ps, next_ps_i->id)))
3085 if (JUMP_P (ps_rtl_insn (ps, ps_i->id)))
3100 ps->rows[row] = ps_i;
3108 ps_i->next_in_row = ps->rows[row];
3112 ps->rows[row] = ps_i;
3131 ps_insn_advance_column (partial_schedule_ptr ps, ps_insn_ptr ps_i,
3137 if (!ps || !ps_i)
3140 row = SMODULO (ps_i->cycle, ps->ii);
3154 if (ps_i == ps->rows[row])
3155 ps->rows[row] = next;
3178 add_node_to_ps (partial_schedule_ptr ps, int id, int cycle,
3182 int row = SMODULO (cycle, ps->ii);
3184 if (ps->rows_length[row] >= issue_rate)
3191 if (! ps_insn_find_column (ps, ps_i, must_precede, must_follow))
3197 ps->rows_length[row] += 1;
3222 ps_has_conflicts (partial_schedule_ptr ps, int from, int to)
3235 for (crr_insn = ps->rows[SMODULO (cycle, ps->ii)];
3239 rtx_insn *insn = ps_rtl_insn (ps, crr_insn->id);
3276 ps_add_node_check_conflicts (partial_schedule_ptr ps, int n,
3285 if (! (ps_i = add_node_to_ps (ps, n, c, must_precede, must_follow)))
3288 has_conflicts = ps_has_conflicts (ps, c, c)
3289 || (ps->history > 0
3290 && ps_has_conflicts (ps,
3291 c - ps->history,
3292 c + ps->history));
3298 if (! ps_insn_advance_column (ps, ps_i, must_follow))
3300 has_conflicts = ps_has_conflicts (ps, c, c)
3301 || (ps->history > 0
3302 && ps_has_conflicts (ps,
3303 c - ps->history,
3304 c + ps->history));
3309 remove_node_from_ps (ps, ps_i);
3313 ps->min_cycle = MIN (ps->min_cycle, c);
3314 ps->max_cycle = MAX (ps->max_cycle, c);
3321 calculate_stage_count (partial_schedule_ptr ps, int rotation_amount)
3323 int new_min_cycle = PS_MIN_CYCLE (ps) - rotation_amount;
3324 int new_max_cycle = PS_MAX_CYCLE (ps) - rotation_amount;
3325 int stage_count = CALC_STAGE_COUNT (-1, new_min_cycle, ps->ii);
3329 stage_count += CALC_STAGE_COUNT (new_max_cycle, 0, ps->ii);
3337 rotate_partial_schedule (partial_schedule_ptr ps, int start_cycle)
3340 int last_row = ps->ii - 1;
3345 backward_rotates = SMODULO (start_cycle, ps->ii);
3350 ps_insn_ptr first_row = ps->rows[0];
3351 int first_row_length = ps->rows_length[0];
3355 ps->rows[row] = ps->rows[row + 1];
3356 ps->rows_length[row] = ps->rows_length[row + 1];
3359 ps->rows[last_row] = first_row;
3360 ps->rows_length[last_row] = first_row_length;
3363 ps->max_cycle -= start_cycle;
3364 ps->min_cycle -= start_cycle;