comparison gcc/haifa-sched.c @ 67:f6334be47118

update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
date Tue, 22 Mar 2011 17:18:12 +0900
parents b7f97abdc517
children 04ced10e8804
comparison
equal deleted inserted replaced
65:65488c3d617d 67:f6334be47118
126 126
127 #include "config.h" 127 #include "config.h"
128 #include "system.h" 128 #include "system.h"
129 #include "coretypes.h" 129 #include "coretypes.h"
130 #include "tm.h" 130 #include "tm.h"
131 #include "toplev.h" 131 #include "diagnostic-core.h"
132 #include "rtl.h" 132 #include "rtl.h"
133 #include "tm_p.h" 133 #include "tm_p.h"
134 #include "hard-reg-set.h" 134 #include "hard-reg-set.h"
135 #include "regs.h" 135 #include "regs.h"
136 #include "function.h" 136 #include "function.h"
137 #include "flags.h" 137 #include "flags.h"
138 #include "insn-config.h" 138 #include "insn-config.h"
139 #include "insn-attr.h" 139 #include "insn-attr.h"
140 #include "except.h" 140 #include "except.h"
141 #include "toplev.h"
142 #include "recog.h" 141 #include "recog.h"
143 #include "sched-int.h" 142 #include "sched-int.h"
144 #include "target.h" 143 #include "target.h"
145 #include "output.h" 144 #include "output.h"
146 #include "params.h" 145 #include "params.h"
147 #include "vecprim.h" 146 #include "vecprim.h"
148 #include "dbgcnt.h" 147 #include "dbgcnt.h"
149 #include "cfgloop.h" 148 #include "cfgloop.h"
150 #include "ira.h" 149 #include "ira.h"
150 #include "emit-rtl.h" /* FIXME: Can go away once crtl is moved to rtl.h. */
151 151
152 #ifdef INSN_SCHEDULING 152 #ifdef INSN_SCHEDULING
153 153
154 /* issue_rate is the number of insns that can be scheduled in the same 154 /* issue_rate is the number of insns that can be scheduled in the same
155 machine cycle. It can be defined in the config/mach/mach.h file, 155 machine cycle. It can be defined in the config/mach/mach.h file,
164 N=1: same as -dSR. 164 N=1: same as -dSR.
165 N=2: bb's probabilities, detailed ready list info, unit/insn info. 165 N=2: bb's probabilities, detailed ready list info, unit/insn info.
166 N=3: rtl at abort point, control-flow, regions info. 166 N=3: rtl at abort point, control-flow, regions info.
167 N=5: dependences info. */ 167 N=5: dependences info. */
168 168
169 static int sched_verbose_param = 0;
170 int sched_verbose = 0; 169 int sched_verbose = 0;
171 170
172 /* Debugging file. All printouts are sent to dump, which is always set, 171 /* Debugging file. All printouts are sent to dump, which is always set,
173 either to stderr, or to the dump listing file (-dRS). */ 172 either to stderr, or to the dump listing file (-dRS). */
174 FILE *sched_dump = 0; 173 FILE *sched_dump = 0;
175
176 /* fix_sched_param() is called from toplev.c upon detection
177 of the -fsched-verbose=N option. */
178
179 void
180 fix_sched_param (const char *param, const char *val)
181 {
182 if (!strcmp (param, "verbose"))
183 sched_verbose_param = atoi (val);
184 else
185 warning (0, "fix_sched_param: unknown param: %s", param);
186 }
187 174
188 /* This is a placeholder for the scheduler parameters common 175 /* This is a placeholder for the scheduler parameters common
189 to all schedulers. */ 176 to all schedulers. */
190 struct common_sched_info_def *common_sched_info; 177 struct common_sched_info_def *common_sched_info;
191 178
195 /* If INSN_TICK of an instruction is equal to INVALID_TICK, 182 /* If INSN_TICK of an instruction is equal to INVALID_TICK,
196 then it should be recalculated from scratch. */ 183 then it should be recalculated from scratch. */
197 #define INVALID_TICK (-(max_insn_queue_index + 1)) 184 #define INVALID_TICK (-(max_insn_queue_index + 1))
198 /* The minimal value of the INSN_TICK of an instruction. */ 185 /* The minimal value of the INSN_TICK of an instruction. */
199 #define MIN_TICK (-max_insn_queue_index) 186 #define MIN_TICK (-max_insn_queue_index)
200
201 /* Issue points are used to distinguish between instructions in max_issue ().
202 For now, all instructions are equally good. */
203 #define ISSUE_POINTS(INSN) 1
204 187
205 /* List of important notes we must keep around. This is a pointer to the 188 /* List of important notes we must keep around. This is a pointer to the
206 last element in the list. */ 189 last element in the list. */
207 rtx note_list; 190 rtx note_list;
208 191
529 unlink_other_notes ()). After scheduling the block, these notes are 512 unlink_other_notes ()). After scheduling the block, these notes are
530 inserted at the beginning of the block (in schedule_block()). */ 513 inserted at the beginning of the block (in schedule_block()). */
531 514
532 static void ready_add (struct ready_list *, rtx, bool); 515 static void ready_add (struct ready_list *, rtx, bool);
533 static rtx ready_remove_first (struct ready_list *); 516 static rtx ready_remove_first (struct ready_list *);
517 static rtx ready_remove_first_dispatch (struct ready_list *ready);
534 518
535 static void queue_to_ready (struct ready_list *); 519 static void queue_to_ready (struct ready_list *);
536 static int early_queue_to_ready (state_t, struct ready_list *); 520 static int early_queue_to_ready (state_t, struct ready_list *);
537 521
538 static void debug_ready_list (struct ready_list *); 522 static void debug_ready_list (struct ready_list *);
539 523
540 /* The following functions are used to implement multi-pass scheduling 524 /* The following functions are used to implement multi-pass scheduling
541 on the first cycle. */ 525 on the first cycle. */
542 static rtx ready_remove (struct ready_list *, int); 526 static rtx ready_remove (struct ready_list *, int);
543 static void ready_remove_insn (rtx); 527 static void ready_remove_insn (rtx);
544
545 static int choose_ready (struct ready_list *, rtx *);
546 528
547 static void fix_inter_tick (rtx, rtx); 529 static void fix_inter_tick (rtx, rtx);
548 static int fix_tick_ready (rtx); 530 static int fix_tick_ready (rtx);
549 static void change_queue_index (rtx, int); 531 static void change_queue_index (rtx, int);
550 532
711 /* Initiate current register pressure related info at the start of 693 /* Initiate current register pressure related info at the start of
712 basic block BB. */ 694 basic block BB. */
713 static void 695 static void
714 initiate_bb_reg_pressure_info (basic_block bb) 696 initiate_bb_reg_pressure_info (basic_block bb)
715 { 697 {
716 unsigned int i; 698 unsigned int i ATTRIBUTE_UNUSED;
717 rtx insn; 699 rtx insn;
718 700
719 if (current_nr_blocks > 1) 701 if (current_nr_blocks > 1)
720 FOR_BB_INSNS (bb, insn) 702 FOR_BB_INSNS (bb, insn)
721 if (NONDEBUG_INSN_P (insn)) 703 if (NONDEBUG_INSN_P (insn))
1120 enum reg_class cl; 1102 enum reg_class cl;
1121 struct reg_pressure_data *pressure_info; 1103 struct reg_pressure_data *pressure_info;
1122 int *max_reg_pressure; 1104 int *max_reg_pressure;
1123 struct reg_use_data *use; 1105 struct reg_use_data *use;
1124 static int death[N_REG_CLASSES]; 1106 static int death[N_REG_CLASSES];
1107
1108 gcc_checking_assert (!DEBUG_INSN_P (insn));
1125 1109
1126 excess_cost_change = 0; 1110 excess_cost_change = 0;
1127 for (i = 0; i < ira_reg_class_cover_size; i++) 1111 for (i = 0; i < ira_reg_class_cover_size; i++)
1128 death[ira_reg_class_cover[i]] = 0; 1112 death[ira_reg_class_cover[i]] = 0;
1129 for (use = INSN_REG_USE_LIST (insn); use != NULL; use = use->next_insn_use) 1113 for (use = INSN_REG_USE_LIST (insn); use != NULL; use = use->next_insn_use)
1497 rtx *first = ready_lastpos (ready); 1481 rtx *first = ready_lastpos (ready);
1498 1482
1499 if (sched_pressure_p) 1483 if (sched_pressure_p)
1500 { 1484 {
1501 for (i = 0; i < ready->n_ready; i++) 1485 for (i = 0; i < ready->n_ready; i++)
1502 setup_insn_reg_pressure_info (first[i]); 1486 if (!DEBUG_INSN_P (first[i]))
1487 setup_insn_reg_pressure_info (first[i]);
1503 } 1488 }
1504 SCHED_SORT (first, ready->n_ready); 1489 SCHED_SORT (first, ready->n_ready);
1505 } 1490 }
1506 1491
1507 /* PREV is an insn that is ready to execute. Adjust its priority if that 1492 /* PREV is an insn that is ready to execute. Adjust its priority if that
1560 static void 1545 static void
1561 update_register_pressure (rtx insn) 1546 update_register_pressure (rtx insn)
1562 { 1547 {
1563 struct reg_use_data *use; 1548 struct reg_use_data *use;
1564 struct reg_set_data *set; 1549 struct reg_set_data *set;
1550
1551 gcc_checking_assert (!DEBUG_INSN_P (insn));
1565 1552
1566 for (use = INSN_REG_USE_LIST (insn); use != NULL; use = use->next_insn_use) 1553 for (use = INSN_REG_USE_LIST (insn); use != NULL; use = use->next_insn_use)
1567 if (dying_use_p (use) && bitmap_bit_p (curr_reg_live, use->regno)) 1554 if (dying_use_p (use) && bitmap_bit_p (curr_reg_live, use->regno))
1568 mark_regno_birth_or_death (use->regno, false); 1555 mark_regno_birth_or_death (use->regno, false);
1569 for (set = INSN_REG_SET_LIST (insn); set != NULL; set = set->next_insn_set) 1556 for (set = INSN_REG_SET_LIST (insn); set != NULL; set = set->next_insn_set)
1681 pressure_info[i].set_increase, pressure_info[i].change); 1668 pressure_info[i].set_increase, pressure_info[i].change);
1682 } 1669 }
1683 fputc ('\n', sched_dump); 1670 fputc ('\n', sched_dump);
1684 } 1671 }
1685 1672
1686 if (sched_pressure_p) 1673 if (sched_pressure_p && !DEBUG_INSN_P (insn))
1687 update_reg_and_insn_max_reg_pressure (insn); 1674 update_reg_and_insn_max_reg_pressure (insn);
1688 1675
1689 /* Scheduling instruction should have all its dependencies resolved and 1676 /* Scheduling instruction should have all its dependencies resolved and
1690 should have been removed from the ready list. */ 1677 should have been removed from the ready list. */
1691 gcc_assert (sd_lists_empty_p (insn, SD_LIST_BACK)); 1678 gcc_assert (sd_lists_empty_p (insn, SD_LIST_BACK));
1790 1777
1791 /* This is the place where scheduler doesn't *basically* need backward and 1778 /* This is the place where scheduler doesn't *basically* need backward and
1792 forward dependencies for INSN anymore. Nevertheless they are used in 1779 forward dependencies for INSN anymore. Nevertheless they are used in
1793 heuristics in rank_for_schedule (), early_queue_to_ready () and in 1780 heuristics in rank_for_schedule (), early_queue_to_ready () and in
1794 some targets (e.g. rs6000). Thus the earliest place where we *can* 1781 some targets (e.g. rs6000). Thus the earliest place where we *can*
1795 remove dependencies is after targetm.sched.md_finish () call in 1782 remove dependencies is after targetm.sched.finish () call in
1796 schedule_block (). But, on the other side, the safest place to remove 1783 schedule_block (). But, on the other side, the safest place to remove
1797 dependencies is when we are finishing scheduling entire region. As we 1784 dependencies is when we are finishing scheduling entire region. As we
1798 don't generate [many] dependencies during scheduling itself, we won't 1785 don't generate [many] dependencies during scheduling itself, we won't
1799 need memory until beginning of next region. 1786 need memory until beginning of next region.
1800 Bottom line: Dependencies are removed for all insns in the end of 1787 Bottom line: Dependencies are removed for all insns in the end of
1911 1898
1912 if (LABEL_P (beg_head)) 1899 if (LABEL_P (beg_head))
1913 beg_head = NEXT_INSN (beg_head); 1900 beg_head = NEXT_INSN (beg_head);
1914 1901
1915 while (beg_head != beg_tail) 1902 while (beg_head != beg_tail)
1916 if (NOTE_P (beg_head) || BOUNDARY_DEBUG_INSN_P (beg_head)) 1903 if (NOTE_P (beg_head))
1917 beg_head = NEXT_INSN (beg_head); 1904 beg_head = NEXT_INSN (beg_head);
1905 else if (DEBUG_INSN_P (beg_head))
1906 {
1907 rtx note, next;
1908
1909 for (note = NEXT_INSN (beg_head);
1910 note != beg_tail;
1911 note = next)
1912 {
1913 next = NEXT_INSN (note);
1914 if (NOTE_P (note))
1915 {
1916 if (sched_verbose >= 9)
1917 fprintf (sched_dump, "reorder %i\n", INSN_UID (note));
1918
1919 reorder_insns_nobb (note, note, PREV_INSN (beg_head));
1920
1921 if (BLOCK_FOR_INSN (note) != beg)
1922 df_insn_change_bb (note, beg);
1923 }
1924 else if (!DEBUG_INSN_P (note))
1925 break;
1926 }
1927
1928 break;
1929 }
1918 else 1930 else
1919 break; 1931 break;
1920 1932
1921 *headp = beg_head; 1933 *headp = beg_head;
1922 1934
1924 end_head = beg_head; 1936 end_head = beg_head;
1925 else if (LABEL_P (end_head)) 1937 else if (LABEL_P (end_head))
1926 end_head = NEXT_INSN (end_head); 1938 end_head = NEXT_INSN (end_head);
1927 1939
1928 while (end_head != end_tail) 1940 while (end_head != end_tail)
1929 if (NOTE_P (end_tail) || BOUNDARY_DEBUG_INSN_P (end_tail)) 1941 if (NOTE_P (end_tail))
1930 end_tail = PREV_INSN (end_tail); 1942 end_tail = PREV_INSN (end_tail);
1943 else if (DEBUG_INSN_P (end_tail))
1944 {
1945 rtx note, prev;
1946
1947 for (note = PREV_INSN (end_tail);
1948 note != end_head;
1949 note = prev)
1950 {
1951 prev = PREV_INSN (note);
1952 if (NOTE_P (note))
1953 {
1954 if (sched_verbose >= 9)
1955 fprintf (sched_dump, "reorder %i\n", INSN_UID (note));
1956
1957 reorder_insns_nobb (note, note, end_tail);
1958
1959 if (end_tail == BB_END (end))
1960 BB_END (end) = note;
1961
1962 if (BLOCK_FOR_INSN (note) != end)
1963 df_insn_change_bb (note, end);
1964 }
1965 else if (!DEBUG_INSN_P (note))
1966 break;
1967 }
1968
1969 break;
1970 }
1931 else 1971 else
1932 break; 1972 break;
1933 1973
1934 *tailp = end_tail; 1974 *tailp = end_tail;
1935 } 1975 }
1939 int 1979 int
1940 no_real_insns_p (const_rtx head, const_rtx tail) 1980 no_real_insns_p (const_rtx head, const_rtx tail)
1941 { 1981 {
1942 while (head != NEXT_INSN (tail)) 1982 while (head != NEXT_INSN (tail))
1943 { 1983 {
1944 if (!NOTE_P (head) && !LABEL_P (head) 1984 if (!NOTE_P (head) && !LABEL_P (head))
1945 && !BOUNDARY_DEBUG_INSN_P (head))
1946 return 0; 1985 return 0;
1947 head = NEXT_INSN (head); 1986 head = NEXT_INSN (head);
1948 } 1987 }
1949 return 1; 1988 return 1;
1950 } 1989 }
1995 rtx skip_insn; 2034 rtx skip_insn;
1996 2035
1997 q_ptr = NEXT_Q (q_ptr); 2036 q_ptr = NEXT_Q (q_ptr);
1998 2037
1999 if (dbg_cnt (sched_insn) == false) 2038 if (dbg_cnt (sched_insn) == false)
2000 { 2039 /* If debug counter is activated do not requeue insn next after
2001 /* If debug counter is activated do not requeue insn next after 2040 last_scheduled_insn. */
2002 last_scheduled_insn. */ 2041 skip_insn = next_nonnote_nondebug_insn (last_scheduled_insn);
2003 skip_insn = next_nonnote_insn (last_scheduled_insn);
2004 while (skip_insn && DEBUG_INSN_P (skip_insn))
2005 skip_insn = next_nonnote_insn (skip_insn);
2006 }
2007 else 2042 else
2008 skip_insn = NULL_RTX; 2043 skip_insn = NULL_RTX;
2009 2044
2010 /* Add all pending insns that can be scheduled without stalls to the 2045 /* Add all pending insns that can be scheduled without stalls to the
2011 ready list. */ 2046 ready list. */
2389 return true; 2424 return true;
2390 2425
2391 return false; 2426 return false;
2392 } 2427 }
2393 2428
2429 /* Define type for target data used in multipass scheduling. */
2430 #ifndef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DATA_T
2431 # define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DATA_T int
2432 #endif
2433 typedef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DATA_T first_cycle_multipass_data_t;
2434
2394 /* The following structure describe an entry of the stack of choices. */ 2435 /* The following structure describe an entry of the stack of choices. */
2395 struct choice_entry 2436 struct choice_entry
2396 { 2437 {
2397 /* Ordinal number of the issued insn in the ready queue. */ 2438 /* Ordinal number of the issued insn in the ready queue. */
2398 int index; 2439 int index;
2400 int rest; 2441 int rest;
2401 /* The number of issued essential insns. */ 2442 /* The number of issued essential insns. */
2402 int n; 2443 int n;
2403 /* State after issuing the insn. */ 2444 /* State after issuing the insn. */
2404 state_t state; 2445 state_t state;
2446 /* Target-specific data. */
2447 first_cycle_multipass_data_t target_data;
2405 }; 2448 };
2406 2449
2407 /* The following array is used to implement a stack of choices used in 2450 /* The following array is used to implement a stack of choices used in
2408 function max_issue. */ 2451 function max_issue. */
2409 static struct choice_entry *choice_stack; 2452 static struct choice_entry *choice_stack;
2439 /* The following function returns maximal (or close to maximal) number 2482 /* The following function returns maximal (or close to maximal) number
2440 of insns which can be issued on the same cycle and one of which 2483 of insns which can be issued on the same cycle and one of which
2441 insns is insns with the best rank (the first insn in READY). To 2484 insns is insns with the best rank (the first insn in READY). To
2442 make this function tries different samples of ready insns. READY 2485 make this function tries different samples of ready insns. READY
2443 is current queue `ready'. Global array READY_TRY reflects what 2486 is current queue `ready'. Global array READY_TRY reflects what
2444 insns are already issued in this try. MAX_POINTS is the sum of points 2487 insns are already issued in this try. The function stops immediately,
2445 of all instructions in READY. The function stops immediately,
2446 if it reached the such a solution, that all instruction can be issued. 2488 if it reached the such a solution, that all instruction can be issued.
2447 INDEX will contain index of the best insn in READY. The following 2489 INDEX will contain index of the best insn in READY. The following
2448 function is used only for first cycle multipass scheduling. 2490 function is used only for first cycle multipass scheduling.
2449 2491
2450 PRIVILEGED_N >= 0 2492 PRIVILEGED_N >= 0
2451 2493
2452 This function expects recognized insns only. All USEs, 2494 This function expects recognized insns only. All USEs,
2453 CLOBBERs, etc must be filtered elsewhere. */ 2495 CLOBBERs, etc must be filtered elsewhere. */
2454 int 2496 int
2455 max_issue (struct ready_list *ready, int privileged_n, state_t state, 2497 max_issue (struct ready_list *ready, int privileged_n, state_t state,
2456 int *index) 2498 bool first_cycle_insn_p, int *index)
2457 { 2499 {
2458 int n, i, all, n_ready, best, delay, tries_num, max_points; 2500 int n, i, all, n_ready, best, delay, tries_num;
2459 int more_issue; 2501 int more_issue;
2460 struct choice_entry *top; 2502 struct choice_entry *top;
2461 rtx insn; 2503 rtx insn;
2462 2504
2463 n_ready = ready->n_ready; 2505 n_ready = ready->n_ready;
2472 for (i = 0; i < issue_rate; i++) 2514 for (i = 0; i < issue_rate; i++)
2473 max_lookahead_tries *= dfa_lookahead; 2515 max_lookahead_tries *= dfa_lookahead;
2474 } 2516 }
2475 2517
2476 /* Init max_points. */ 2518 /* Init max_points. */
2477 max_points = 0;
2478 more_issue = issue_rate - cycle_issued_insns; 2519 more_issue = issue_rate - cycle_issued_insns;
2479 2520 gcc_assert (more_issue >= 0);
2480 /* ??? We used to assert here that we never issue more insns than issue_rate.
2481 However, some targets (e.g. MIPS/SB1) claim lower issue rate than can be
2482 achieved to get better performance. Until these targets are fixed to use
2483 scheduler hooks to manipulate insns priority instead, the assert should
2484 be disabled.
2485
2486 gcc_assert (more_issue >= 0); */
2487
2488 for (i = 0; i < n_ready; i++)
2489 if (!ready_try [i])
2490 {
2491 if (more_issue-- > 0)
2492 max_points += ISSUE_POINTS (ready_element (ready, i));
2493 else
2494 break;
2495 }
2496 2521
2497 /* The number of the issued insns in the best solution. */ 2522 /* The number of the issued insns in the best solution. */
2498 best = 0; 2523 best = 0;
2499 2524
2500 top = choice_stack; 2525 top = choice_stack;
2501 2526
2502 /* Set initial state of the search. */ 2527 /* Set initial state of the search. */
2503 memcpy (top->state, state, dfa_state_size); 2528 memcpy (top->state, state, dfa_state_size);
2504 top->rest = dfa_lookahead; 2529 top->rest = dfa_lookahead;
2505 top->n = 0; 2530 top->n = 0;
2531 if (targetm.sched.first_cycle_multipass_begin)
2532 targetm.sched.first_cycle_multipass_begin (&top->target_data,
2533 ready_try, n_ready,
2534 first_cycle_insn_p);
2506 2535
2507 /* Count the number of the insns to search among. */ 2536 /* Count the number of the insns to search among. */
2508 for (all = i = 0; i < n_ready; i++) 2537 for (all = i = 0; i < n_ready; i++)
2509 if (!ready_try [i]) 2538 if (!ready_try [i])
2510 all++; 2539 all++;
2515 for (;;) 2544 for (;;)
2516 { 2545 {
2517 if (/* If we've reached a dead end or searched enough of what we have 2546 if (/* If we've reached a dead end or searched enough of what we have
2518 been asked... */ 2547 been asked... */
2519 top->rest == 0 2548 top->rest == 0
2520 /* Or have nothing else to try. */ 2549 /* or have nothing else to try... */
2521 || i >= n_ready) 2550 || i >= n_ready
2551 /* or should not issue more. */
2552 || top->n >= more_issue)
2522 { 2553 {
2523 /* ??? (... || i == n_ready). */ 2554 /* ??? (... || i == n_ready). */
2524 gcc_assert (i <= n_ready); 2555 gcc_assert (i <= n_ready);
2556
2557 /* We should not issue more than issue_rate instructions. */
2558 gcc_assert (top->n <= more_issue);
2525 2559
2526 if (top == choice_stack) 2560 if (top == choice_stack)
2527 break; 2561 break;
2528 2562
2529 if (best < top - choice_stack) 2563 if (best < top - choice_stack)
2543 { 2577 {
2544 best = top - choice_stack; 2578 best = top - choice_stack;
2545 /* This is the index of the insn issued first in this 2579 /* This is the index of the insn issued first in this
2546 solution. */ 2580 solution. */
2547 *index = choice_stack [1].index; 2581 *index = choice_stack [1].index;
2548 if (top->n == max_points || best == all) 2582 if (top->n == more_issue || best == all)
2549 break; 2583 break;
2550 } 2584 }
2551 } 2585 }
2552 2586
2553 /* Set ready-list index to point to the last insn 2587 /* Set ready-list index to point to the last insn
2554 ('i++' below will advance it to the next insn). */ 2588 ('i++' below will advance it to the next insn). */
2555 i = top->index; 2589 i = top->index;
2556 2590
2557 /* Backtrack. */ 2591 /* Backtrack. */
2558 ready_try [i] = 0; 2592 ready_try [i] = 0;
2593
2594 if (targetm.sched.first_cycle_multipass_backtrack)
2595 targetm.sched.first_cycle_multipass_backtrack (&top->target_data,
2596 ready_try, n_ready);
2597
2559 top--; 2598 top--;
2560 memcpy (state, top->state, dfa_state_size); 2599 memcpy (state, top->state, dfa_state_size);
2561 } 2600 }
2562 else if (!ready_try [i]) 2601 else if (!ready_try [i])
2563 { 2602 {
2576 else 2615 else
2577 top->rest--; 2616 top->rest--;
2578 2617
2579 n = top->n; 2618 n = top->n;
2580 if (memcmp (top->state, state, dfa_state_size) != 0) 2619 if (memcmp (top->state, state, dfa_state_size) != 0)
2581 n += ISSUE_POINTS (insn); 2620 n++;
2582 2621
2583 /* Advance to the next choice_entry. */ 2622 /* Advance to the next choice_entry. */
2584 top++; 2623 top++;
2585 /* Initialize it. */ 2624 /* Initialize it. */
2586 top->rest = dfa_lookahead; 2625 top->rest = dfa_lookahead;
2587 top->index = i; 2626 top->index = i;
2588 top->n = n; 2627 top->n = n;
2589 memcpy (top->state, state, dfa_state_size); 2628 memcpy (top->state, state, dfa_state_size);
2590
2591 ready_try [i] = 1; 2629 ready_try [i] = 1;
2630
2631 if (targetm.sched.first_cycle_multipass_issue)
2632 targetm.sched.first_cycle_multipass_issue (&top->target_data,
2633 ready_try, n_ready,
2634 insn,
2635 &((top - 1)
2636 ->target_data));
2637
2592 i = -1; 2638 i = -1;
2593 } 2639 }
2594 } 2640 }
2595 2641
2596 /* Increase ready-list index. */ 2642 /* Increase ready-list index. */
2597 i++; 2643 i++;
2598 } 2644 }
2645
2646 if (targetm.sched.first_cycle_multipass_end)
2647 targetm.sched.first_cycle_multipass_end (best != 0
2648 ? &choice_stack[1].target_data
2649 : NULL);
2599 2650
2600 /* Restore the original state of the DFA. */ 2651 /* Restore the original state of the DFA. */
2601 memcpy (state, choice_stack->state, dfa_state_size); 2652 memcpy (state, choice_stack->state, dfa_state_size);
2602 2653
2603 return best; 2654 return best;
2609 Return: 2660 Return:
2610 -1 if cycle should be advanced, 2661 -1 if cycle should be advanced,
2611 0 if INSN_PTR is set to point to the desirable insn, 2662 0 if INSN_PTR is set to point to the desirable insn,
2612 1 if choose_ready () should be restarted without advancing the cycle. */ 2663 1 if choose_ready () should be restarted without advancing the cycle. */
2613 static int 2664 static int
2614 choose_ready (struct ready_list *ready, rtx *insn_ptr) 2665 choose_ready (struct ready_list *ready, bool first_cycle_insn_p,
2666 rtx *insn_ptr)
2615 { 2667 {
2616 int lookahead; 2668 int lookahead;
2617 2669
2618 if (dbg_cnt (sched_insn) == false) 2670 if (dbg_cnt (sched_insn) == false)
2619 { 2671 {
2638 if (targetm.sched.first_cycle_multipass_dfa_lookahead) 2690 if (targetm.sched.first_cycle_multipass_dfa_lookahead)
2639 lookahead = targetm.sched.first_cycle_multipass_dfa_lookahead (); 2691 lookahead = targetm.sched.first_cycle_multipass_dfa_lookahead ();
2640 if (lookahead <= 0 || SCHED_GROUP_P (ready_element (ready, 0)) 2692 if (lookahead <= 0 || SCHED_GROUP_P (ready_element (ready, 0))
2641 || DEBUG_INSN_P (ready_element (ready, 0))) 2693 || DEBUG_INSN_P (ready_element (ready, 0)))
2642 { 2694 {
2643 *insn_ptr = ready_remove_first (ready); 2695 if (targetm.sched.dispatch (NULL_RTX, IS_DISPATCH_ON))
2696 *insn_ptr = ready_remove_first_dispatch (ready);
2697 else
2698 *insn_ptr = ready_remove_first (ready);
2699
2644 return 0; 2700 return 0;
2645 } 2701 }
2646 else 2702 else
2647 { 2703 {
2648 /* Try to choose the better insn. */ 2704 /* Try to choose the better insn. */
2718 for (i = 1; i < ready->n_ready; i++) 2774 for (i = 1; i < ready->n_ready; i++)
2719 if (!ready_try[i]) 2775 if (!ready_try[i])
2720 { 2776 {
2721 insn = ready_element (ready, i); 2777 insn = ready_element (ready, i);
2722 2778
2723 #ifdef ENABLE_CHECKING
2724 /* If this insn is recognizable we should have already 2779 /* If this insn is recognizable we should have already
2725 recognized it earlier. 2780 recognized it earlier.
2726 ??? Not very clear where this is supposed to be done. 2781 ??? Not very clear where this is supposed to be done.
2727 See dep_cost_1. */ 2782 See dep_cost_1. */
2728 gcc_assert (INSN_CODE (insn) >= 0 2783 gcc_checking_assert (INSN_CODE (insn) >= 0
2729 || recog_memoized (insn) < 0); 2784 || recog_memoized (insn) < 0);
2730 #endif
2731 2785
2732 ready_try [i] 2786 ready_try [i]
2733 = (/* INSN_CODE check can be omitted here as it is also done later 2787 = (/* INSN_CODE check can be omitted here as it is also done later
2734 in max_issue (). */ 2788 in max_issue (). */
2735 INSN_CODE (insn) < 0 2789 INSN_CODE (insn) < 0
2736 || (targetm.sched.first_cycle_multipass_dfa_lookahead_guard 2790 || (targetm.sched.first_cycle_multipass_dfa_lookahead_guard
2737 && !targetm.sched.first_cycle_multipass_dfa_lookahead_guard 2791 && !targetm.sched.first_cycle_multipass_dfa_lookahead_guard
2738 (insn))); 2792 (insn)));
2739 } 2793 }
2740 2794
2741 if (max_issue (ready, 1, curr_state, &index) == 0) 2795 if (max_issue (ready, 1, curr_state, first_cycle_insn_p, &index) == 0)
2742 { 2796 {
2743 *insn_ptr = ready_remove_first (ready); 2797 *insn_ptr = ready_remove_first (ready);
2744 if (sched_verbose >= 4) 2798 if (sched_verbose >= 4)
2745 fprintf (sched_dump, ";;\t\tChosen insn (but can't issue) : %s \n", 2799 fprintf (sched_dump, ";;\t\tChosen insn (but can't issue) : %s \n",
2746 (*current_sched_info->print_insn) (*insn_ptr, 0)); 2800 (*current_sched_info->print_insn) (*insn_ptr, 0));
2764 region. */ 2818 region. */
2765 2819
2766 void 2820 void
2767 schedule_block (basic_block *target_bb) 2821 schedule_block (basic_block *target_bb)
2768 { 2822 {
2769 int i, first_cycle_insn_p; 2823 int i;
2824 bool first_cycle_insn_p;
2770 int can_issue_more; 2825 int can_issue_more;
2771 state_t temp_state = NULL; /* It is used for multipass scheduling. */ 2826 state_t temp_state = NULL; /* It is used for multipass scheduling. */
2772 int sort_p, advance, start_clock_var; 2827 int sort_p, advance, start_clock_var;
2773 2828
2774 /* Head/tail info for this block. */ 2829 /* Head/tail info for this block. */
2800 ready.n_debug = 0; 2855 ready.n_debug = 0;
2801 2856
2802 /* It is used for first cycle multipass scheduling. */ 2857 /* It is used for first cycle multipass scheduling. */
2803 temp_state = alloca (dfa_state_size); 2858 temp_state = alloca (dfa_state_size);
2804 2859
2805 if (targetm.sched.md_init) 2860 if (targetm.sched.init)
2806 targetm.sched.md_init (sched_dump, sched_verbose, ready.veclen); 2861 targetm.sched.init (sched_dump, sched_verbose, ready.veclen);
2807 2862
2808 /* We start inserting insns after PREV_HEAD. */ 2863 /* We start inserting insns after PREV_HEAD. */
2809 last_scheduled_insn = prev_head; 2864 last_scheduled_insn = prev_head;
2810 2865
2811 gcc_assert ((NOTE_P (last_scheduled_insn) 2866 gcc_assert ((NOTE_P (last_scheduled_insn)
2812 || BOUNDARY_DEBUG_INSN_P (last_scheduled_insn)) 2867 || DEBUG_INSN_P (last_scheduled_insn))
2813 && BLOCK_FOR_INSN (last_scheduled_insn) == *target_bb); 2868 && BLOCK_FOR_INSN (last_scheduled_insn) == *target_bb);
2814 2869
2815 /* Initialize INSN_QUEUE. Q_SIZE is the total number of insns in the 2870 /* Initialize INSN_QUEUE. Q_SIZE is the total number of insns in the
2816 queue. */ 2871 queue. */
2817 q_ptr = 0; 2872 q_ptr = 0;
2970 ready_lastpos (&ready), 3025 ready_lastpos (&ready),
2971 &ready.n_ready, clock_var); 3026 &ready.n_ready, clock_var);
2972 else 3027 else
2973 can_issue_more = issue_rate; 3028 can_issue_more = issue_rate;
2974 3029
2975 first_cycle_insn_p = 1; 3030 first_cycle_insn_p = true;
2976 cycle_issued_insns = 0; 3031 cycle_issued_insns = 0;
2977 for (;;) 3032 for (;;)
2978 { 3033 {
2979 rtx insn; 3034 rtx insn;
2980 int cost; 3035 int cost;
3013 if (sort_p) 3068 if (sort_p)
3014 { 3069 {
3015 int res; 3070 int res;
3016 3071
3017 insn = NULL_RTX; 3072 insn = NULL_RTX;
3018 res = choose_ready (&ready, &insn); 3073 res = choose_ready (&ready, first_cycle_insn_p, &insn);
3019 3074
3020 if (res < 0) 3075 if (res < 0)
3021 /* Finish cycle. */ 3076 /* Finish cycle. */
3022 break; 3077 break;
3023 if (res > 0) 3078 if (res > 0)
3136 /* Update counters, etc in the scheduler's front end. */ 3191 /* Update counters, etc in the scheduler's front end. */
3137 (*current_sched_info->begin_schedule_ready) (insn, 3192 (*current_sched_info->begin_schedule_ready) (insn,
3138 last_scheduled_insn); 3193 last_scheduled_insn);
3139 3194
3140 move_insn (insn, last_scheduled_insn, current_sched_info->next_tail); 3195 move_insn (insn, last_scheduled_insn, current_sched_info->next_tail);
3196
3197 if (targetm.sched.dispatch (NULL_RTX, IS_DISPATCH_ON))
3198 targetm.sched.dispatch_do (insn, ADD_TO_DISPATCH_WINDOW);
3199
3141 reemit_notes (insn); 3200 reemit_notes (insn);
3142 last_scheduled_insn = insn; 3201 last_scheduled_insn = insn;
3143 3202
3144 if (memcmp (curr_state, temp_state, dfa_state_size) != 0) 3203 if (memcmp (curr_state, temp_state, dfa_state_size) != 0)
3145 { 3204 {
3162 if (advance == 0 && asm_p) 3221 if (advance == 0 && asm_p)
3163 advance = 1; 3222 advance = 1;
3164 if (advance != 0) 3223 if (advance != 0)
3165 break; 3224 break;
3166 3225
3167 first_cycle_insn_p = 0; 3226 first_cycle_insn_p = false;
3168 3227
3169 /* Sort the ready list based on priority. This must be 3228 /* Sort the ready list based on priority. This must be
3170 redone here, as schedule_insn may have readied additional 3229 redone here, as schedule_insn may have readied additional
3171 insns that will not be sorted correctly. */ 3230 insns that will not be sorted correctly. */
3172 if (ready.n_ready > 0) 3231 if (ready.n_ready > 0)
3275 clock_var value equal to 0 at the start of a basic block. 3334 clock_var value equal to 0 at the start of a basic block.
3276 Therefore we modify INSN_TICK here. */ 3335 Therefore we modify INSN_TICK here. */
3277 fix_inter_tick (NEXT_INSN (prev_head), last_scheduled_insn); 3336 fix_inter_tick (NEXT_INSN (prev_head), last_scheduled_insn);
3278 } 3337 }
3279 3338
3280 if (targetm.sched.md_finish) 3339 if (targetm.sched.finish)
3281 { 3340 {
3282 targetm.sched.md_finish (sched_dump, sched_verbose); 3341 targetm.sched.finish (sched_dump, sched_verbose);
3283 /* Target might have added some instructions to the scheduled block 3342 /* Target might have added some instructions to the scheduled block
3284 in its md_finish () hook. These new insns don't have any data 3343 in its md_finish () hook. These new insns don't have any data
3285 initialized and to identify them we extend h_i_d so that they'll 3344 initialized and to identify them we extend h_i_d so that they'll
3286 get zero luids. */ 3345 get zero luids. */
3287 sched_init_luids (NULL, NULL, NULL, NULL); 3346 sched_init_luids (NULL, NULL, NULL, NULL);
3310 int n_insn; 3369 int n_insn;
3311 int sched_max_insns_priority = 3370 int sched_max_insns_priority =
3312 current_sched_info->sched_max_insns_priority; 3371 current_sched_info->sched_max_insns_priority;
3313 rtx prev_head; 3372 rtx prev_head;
3314 3373
3315 if (head == tail && (! INSN_P (head) || BOUNDARY_DEBUG_INSN_P (head))) 3374 if (head == tail && ! INSN_P (head))
3316 gcc_unreachable (); 3375 gcc_unreachable ();
3317 3376
3318 n_insn = 0; 3377 n_insn = 0;
3319 3378
3320 prev_head = PREV_INSN (head); 3379 prev_head = PREV_INSN (head);
3360 /* Disable speculative loads in their presence if cc0 defined. */ 3419 /* Disable speculative loads in their presence if cc0 defined. */
3361 #ifdef HAVE_cc0 3420 #ifdef HAVE_cc0
3362 flag_schedule_speculative_load = 0; 3421 flag_schedule_speculative_load = 0;
3363 #endif 3422 #endif
3364 3423
3424 if (targetm.sched.dispatch (NULL_RTX, IS_DISPATCH_ON))
3425 targetm.sched.dispatch_do (NULL_RTX, DISPATCH_INIT);
3426
3365 sched_pressure_p = (flag_sched_pressure && ! reload_completed 3427 sched_pressure_p = (flag_sched_pressure && ! reload_completed
3366 && common_sched_info->sched_pass_id == SCHED_RGN_PASS); 3428 && common_sched_info->sched_pass_id == SCHED_RGN_PASS);
3429
3367 if (sched_pressure_p) 3430 if (sched_pressure_p)
3368 ira_setup_eliminable_regset (); 3431 ira_setup_eliminable_regset ();
3369 3432
3370 /* Initialize SPEC_INFO. */ 3433 /* Initialize SPEC_INFO. */
3371 if (targetm.sched.set_sched_flags) 3434 if (targetm.sched.set_sched_flags)
3436 if (reload_completed) 3499 if (reload_completed)
3437 df_clear_flags (DF_LR_RUN_DCE); 3500 df_clear_flags (DF_LR_RUN_DCE);
3438 3501
3439 regstat_compute_calls_crossed (); 3502 regstat_compute_calls_crossed ();
3440 3503
3441 if (targetm.sched.md_init_global) 3504 if (targetm.sched.init_global)
3442 targetm.sched.md_init_global (sched_dump, sched_verbose, 3505 targetm.sched.init_global (sched_dump, sched_verbose, get_max_uid () + 1);
3443 get_max_uid () + 1);
3444 3506
3445 if (sched_pressure_p) 3507 if (sched_pressure_p)
3446 { 3508 {
3447 int i, max_regno = max_reg_num (); 3509 int i, max_regno = max_reg_num ();
3448 3510
3563 BITMAP_FREE (saved_reg_live); 3625 BITMAP_FREE (saved_reg_live);
3564 BITMAP_FREE (curr_reg_live); 3626 BITMAP_FREE (curr_reg_live);
3565 } 3627 }
3566 free (curr_state); 3628 free (curr_state);
3567 3629
3568 if (targetm.sched.md_finish_global) 3630 if (targetm.sched.finish_global)
3569 targetm.sched.md_finish_global (sched_dump, sched_verbose); 3631 targetm.sched.finish_global (sched_dump, sched_verbose);
3570 3632
3571 end_alias_analysis (); 3633 end_alias_analysis ();
3572 3634
3573 regstat_free_calls_crossed (); 3635 regstat_free_calls_crossed ();
3574 3636
3610 3672
3611 tick = INSN_TICK (head); 3673 tick = INSN_TICK (head);
3612 gcc_assert (tick >= MIN_TICK); 3674 gcc_assert (tick >= MIN_TICK);
3613 3675
3614 /* Fix INSN_TICK of instruction from just scheduled block. */ 3676 /* Fix INSN_TICK of instruction from just scheduled block. */
3615 if (!bitmap_bit_p (&processed, INSN_LUID (head))) 3677 if (bitmap_set_bit (&processed, INSN_LUID (head)))
3616 { 3678 {
3617 bitmap_set_bit (&processed, INSN_LUID (head));
3618 tick -= next_clock; 3679 tick -= next_clock;
3619 3680
3620 if (tick < MIN_TICK) 3681 if (tick < MIN_TICK)
3621 tick = MIN_TICK; 3682 tick = MIN_TICK;
3622 3683
3632 3693
3633 if (tick != INVALID_TICK 3694 if (tick != INVALID_TICK
3634 /* If NEXT has its INSN_TICK calculated, fix it. 3695 /* If NEXT has its INSN_TICK calculated, fix it.
3635 If not - it will be properly calculated from 3696 If not - it will be properly calculated from
3636 scratch later in fix_tick_ready. */ 3697 scratch later in fix_tick_ready. */
3637 && !bitmap_bit_p (&processed, INSN_LUID (next))) 3698 && bitmap_set_bit (&processed, INSN_LUID (next)))
3638 { 3699 {
3639 bitmap_set_bit (&processed, INSN_LUID (next));
3640 tick -= next_clock; 3700 tick -= next_clock;
3641 3701
3642 if (tick < MIN_TICK) 3702 if (tick < MIN_TICK)
3643 tick = MIN_TICK; 3703 tick = MIN_TICK;
3644 3704
3841 static int 3901 static int
3842 fix_tick_ready (rtx next) 3902 fix_tick_ready (rtx next)
3843 { 3903 {
3844 int tick, delay; 3904 int tick, delay;
3845 3905
3846 if (!sd_lists_empty_p (next, SD_LIST_RES_BACK)) 3906 if (!DEBUG_INSN_P (next) && !sd_lists_empty_p (next, SD_LIST_RES_BACK))
3847 { 3907 {
3848 int full_p; 3908 int full_p;
3849 sd_iterator_def sd_it; 3909 sd_iterator_def sd_it;
3850 dep_t dep; 3910 dep_t dep;
3851 3911
3957 entry. */ 4017 entry. */
3958 choice_stack = XRESIZEVEC (struct choice_entry, choice_stack, 4018 choice_stack = XRESIZEVEC (struct choice_entry, choice_stack,
3959 new_sched_ready_n_insns + 1); 4019 new_sched_ready_n_insns + 1);
3960 4020
3961 for (; i <= new_sched_ready_n_insns; i++) 4021 for (; i <= new_sched_ready_n_insns; i++)
3962 choice_stack[i].state = xmalloc (dfa_state_size); 4022 {
4023 choice_stack[i].state = xmalloc (dfa_state_size);
4024
4025 if (targetm.sched.first_cycle_multipass_init)
4026 targetm.sched.first_cycle_multipass_init (&(choice_stack[i]
4027 .target_data));
4028 }
3963 4029
3964 sched_ready_n_insns = new_sched_ready_n_insns; 4030 sched_ready_n_insns = new_sched_ready_n_insns;
3965 } 4031 }
3966 4032
3967 /* Free per region data structures. */ 4033 /* Free per region data structures. */
3976 4042
3977 free (ready_try); 4043 free (ready_try);
3978 ready_try = NULL; 4044 ready_try = NULL;
3979 4045
3980 for (i = 0; i <= sched_ready_n_insns; i++) 4046 for (i = 0; i <= sched_ready_n_insns; i++)
3981 free (choice_stack [i].state); 4047 {
4048 if (targetm.sched.first_cycle_multipass_fini)
4049 targetm.sched.first_cycle_multipass_fini (&(choice_stack[i]
4050 .target_data));
4051
4052 free (choice_stack [i].state);
4053 }
3982 free (choice_stack); 4054 free (choice_stack);
3983 choice_stack = NULL; 4055 choice_stack = NULL;
3984 4056
3985 sched_ready_n_insns = -1; 4057 sched_ready_n_insns = -1;
3986 } 4058 }
4233 } 4305 }
4234 4306
4235 /* Helper function. 4307 /* Helper function.
4236 Find fallthru edge from PRED. */ 4308 Find fallthru edge from PRED. */
4237 edge 4309 edge
4238 find_fallthru_edge (basic_block pred) 4310 find_fallthru_edge_from (basic_block pred)
4239 { 4311 {
4240 edge e; 4312 edge e;
4241 edge_iterator ei;
4242 basic_block succ; 4313 basic_block succ;
4243 4314
4244 succ = pred->next_bb; 4315 succ = pred->next_bb;
4245 gcc_assert (succ->prev_bb == pred); 4316 gcc_assert (succ->prev_bb == pred);
4246 4317
4247 if (EDGE_COUNT (pred->succs) <= EDGE_COUNT (succ->preds)) 4318 if (EDGE_COUNT (pred->succs) <= EDGE_COUNT (succ->preds))
4248 { 4319 {
4249 FOR_EACH_EDGE (e, ei, pred->succs) 4320 e = find_fallthru_edge (pred->succs);
4250 if (e->flags & EDGE_FALLTHRU) 4321
4251 { 4322 if (e)
4252 gcc_assert (e->dest == succ); 4323 {
4253 return e; 4324 gcc_assert (e->dest == succ);
4254 } 4325 return e;
4326 }
4255 } 4327 }
4256 else 4328 else
4257 { 4329 {
4258 FOR_EACH_EDGE (e, ei, succ->preds) 4330 e = find_fallthru_edge (succ->preds);
4259 if (e->flags & EDGE_FALLTHRU) 4331
4260 { 4332 if (e)
4261 gcc_assert (e->src == pred); 4333 {
4262 return e; 4334 gcc_assert (e->src == pred);
4263 } 4335 return e;
4336 }
4264 } 4337 }
4265 4338
4266 return NULL; 4339 return NULL;
4267 } 4340 }
4268 4341
4300 { 4373 {
4301 basic_block last; 4374 basic_block last;
4302 edge e; 4375 edge e;
4303 4376
4304 last = EXIT_BLOCK_PTR->prev_bb; 4377 last = EXIT_BLOCK_PTR->prev_bb;
4305 e = find_fallthru_edge (last); 4378 e = find_fallthru_edge_from (last);
4306 4379
4307 if (e) 4380 if (e)
4308 { 4381 {
4309 /* We create two basic blocks: 4382 /* We create two basic blocks:
4310 1. Single instruction block is inserted right after E->SRC 4383 1. Single instruction block is inserted right after E->SRC
4444 } 4517 }
4445 else 4518 else
4446 edge_flags = 0; 4519 edge_flags = 0;
4447 4520
4448 make_single_succ_edge (rec, second_bb, edge_flags); 4521 make_single_succ_edge (rec, second_bb, edge_flags);
4522 if (dom_info_available_p (CDI_DOMINATORS))
4523 set_immediate_dominator (CDI_DOMINATORS, rec, first_bb);
4449 } 4524 }
4450 4525
4451 /* This function creates recovery code for INSN. If MUTATE_P is nonzero, 4526 /* This function creates recovery code for INSN. If MUTATE_P is nonzero,
4452 INSN is a simple check, that should be converted to branchy one. */ 4527 INSN is a simple check, that should be converted to branchy one. */
4453 static void 4528 static void
4753 4828
4754 if (BLOCK_FOR_INSN (consumer) != rec) 4829 if (BLOCK_FOR_INSN (consumer) != rec)
4755 { 4830 {
4756 sd_delete_dep (sd_it); 4831 sd_delete_dep (sd_it);
4757 4832
4758 if (!bitmap_bit_p (&in_ready, INSN_LUID (consumer))) 4833 if (bitmap_set_bit (&in_ready, INSN_LUID (consumer)))
4759 { 4834 ready_list = alloc_INSN_LIST (consumer, ready_list);
4760 ready_list = alloc_INSN_LIST (consumer, ready_list);
4761 bitmap_set_bit (&in_ready, INSN_LUID (consumer));
4762 }
4763 } 4835 }
4764 else 4836 else
4765 { 4837 {
4766 gcc_assert ((DEP_STATUS (dep) & DEP_TYPES) == DEP_TRUE); 4838 gcc_assert ((DEP_STATUS (dep) & DEP_TYPES) == DEP_TRUE);
4767 4839
5095 calc_priorities (rtx_vec_t roots) 5167 calc_priorities (rtx_vec_t roots)
5096 { 5168 {
5097 int i; 5169 int i;
5098 rtx insn; 5170 rtx insn;
5099 5171
5100 for (i = 0; VEC_iterate (rtx, roots, i, insn); i++) 5172 FOR_EACH_VEC_ELT (rtx, roots, i, insn)
5101 priority (insn); 5173 priority (insn);
5102 } 5174 }
5103 5175
5104 5176
5105 /* Add dependences between JUMP and other instructions in the recovery 5177 /* Add dependences between JUMP and other instructions in the recovery
5323 if (bbs != NULL) 5395 if (bbs != NULL)
5324 { 5396 {
5325 unsigned i; 5397 unsigned i;
5326 basic_block x; 5398 basic_block x;
5327 5399
5328 for (i = 0; VEC_iterate (basic_block, bbs, i, x); i++) 5400 FOR_EACH_VEC_ELT (basic_block, bbs, i, x)
5329 init_bb (x); 5401 init_bb (x);
5330 } 5402 }
5331 5403
5332 if (bb != NULL) 5404 if (bb != NULL)
5333 init_bb (bb); 5405 init_bb (bb);
5338 if (bbs != NULL) 5410 if (bbs != NULL)
5339 { 5411 {
5340 unsigned i; 5412 unsigned i;
5341 basic_block x; 5413 basic_block x;
5342 5414
5343 for (i = 0; VEC_iterate (basic_block, bbs, i, x); i++) 5415 FOR_EACH_VEC_ELT (basic_block, bbs, i, x)
5344 init_insns_in_bb (x); 5416 init_insns_in_bb (x);
5345 } 5417 }
5346 5418
5347 if (bb != NULL) 5419 if (bb != NULL)
5348 init_insns_in_bb (bb); 5420 init_insns_in_bb (bb);
5350 if (insns != NULL) 5422 if (insns != NULL)
5351 { 5423 {
5352 unsigned i; 5424 unsigned i;
5353 rtx x; 5425 rtx x;
5354 5426
5355 for (i = 0; VEC_iterate (rtx, insns, i, x); i++) 5427 FOR_EACH_VEC_ELT (rtx, insns, i, x)
5356 init_insn (x); 5428 init_insn (x);
5357 } 5429 }
5358 5430
5359 if (insn != NULL) 5431 if (insn != NULL)
5360 init_insn (insn); 5432 init_insn (insn);
5480 { 5552 {
5481 int i; 5553 int i;
5482 haifa_insn_data_t data; 5554 haifa_insn_data_t data;
5483 struct reg_use_data *use, *next; 5555 struct reg_use_data *use, *next;
5484 5556
5485 for (i = 0; VEC_iterate (haifa_insn_data_def, h_i_d, i, data); i++) 5557 FOR_EACH_VEC_ELT (haifa_insn_data_def, h_i_d, i, data)
5486 { 5558 {
5487 if (data->reg_pressure != NULL) 5559 if (data->reg_pressure != NULL)
5488 free (data->reg_pressure); 5560 free (data->reg_pressure);
5489 for (use = data->reg_use_list; use != NULL; use = next) 5561 for (use = data->reg_use_list; use != NULL; use = next)
5490 { 5562 {
5559 last_scheduled_insn = insn; 5631 last_scheduled_insn = insn;
5560 haifa_init_insn (insn); 5632 haifa_init_insn (insn);
5561 return insn; 5633 return insn;
5562 } 5634 }
5563 5635
5636 /* This function returns a candidate satisfying dispatch constraints from
5637 the ready list. */
5638
5639 static rtx
5640 ready_remove_first_dispatch (struct ready_list *ready)
5641 {
5642 int i;
5643 rtx insn = ready_element (ready, 0);
5644
5645 if (ready->n_ready == 1
5646 || INSN_CODE (insn) < 0
5647 || !INSN_P (insn)
5648 || !active_insn_p (insn)
5649 || targetm.sched.dispatch (insn, FITS_DISPATCH_WINDOW))
5650 return ready_remove_first (ready);
5651
5652 for (i = 1; i < ready->n_ready; i++)
5653 {
5654 insn = ready_element (ready, i);
5655
5656 if (INSN_CODE (insn) < 0
5657 || !INSN_P (insn)
5658 || !active_insn_p (insn))
5659 continue;
5660
5661 if (targetm.sched.dispatch (insn, FITS_DISPATCH_WINDOW))
5662 {
5663 /* Return ith element of ready. */
5664 insn = ready_remove (ready, i);
5665 return insn;
5666 }
5667 }
5668
5669 if (targetm.sched.dispatch (NULL_RTX, DISPATCH_VIOLATION))
5670 return ready_remove_first (ready);
5671
5672 for (i = 1; i < ready->n_ready; i++)
5673 {
5674 insn = ready_element (ready, i);
5675
5676 if (INSN_CODE (insn) < 0
5677 || !INSN_P (insn)
5678 || !active_insn_p (insn))
5679 continue;
5680
5681 /* Return i-th element of ready. */
5682 if (targetm.sched.dispatch (insn, IS_CMP))
5683 return ready_remove (ready, i);
5684 }
5685
5686 return ready_remove_first (ready);
5687 }
5688
5689 /* Get number of ready insn in the ready list. */
5690
5691 int
5692 number_in_ready (void)
5693 {
5694 return ready.n_ready;
5695 }
5696
5697 /* Get number of ready's in the ready list. */
5698
5699 rtx
5700 get_ready_element (int i)
5701 {
5702 return ready_element (&ready, i);
5703 }
5704
5564 #endif /* INSN_SCHEDULING */ 5705 #endif /* INSN_SCHEDULING */