comparison gcc/sched-rgn.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
47 47
48 #include "config.h" 48 #include "config.h"
49 #include "system.h" 49 #include "system.h"
50 #include "coretypes.h" 50 #include "coretypes.h"
51 #include "tm.h" 51 #include "tm.h"
52 #include "toplev.h" 52 #include "diagnostic-core.h"
53 #include "rtl.h" 53 #include "rtl.h"
54 #include "tm_p.h" 54 #include "tm_p.h"
55 #include "hard-reg-set.h" 55 #include "hard-reg-set.h"
56 #include "regs.h" 56 #include "regs.h"
57 #include "function.h" 57 #include "function.h"
58 #include "flags.h" 58 #include "flags.h"
59 #include "insn-config.h" 59 #include "insn-config.h"
60 #include "insn-attr.h" 60 #include "insn-attr.h"
61 #include "except.h" 61 #include "except.h"
62 #include "toplev.h"
63 #include "recog.h" 62 #include "recog.h"
64 #include "cfglayout.h" 63 #include "cfglayout.h"
65 #include "params.h" 64 #include "params.h"
66 #include "sched-int.h" 65 #include "sched-int.h"
67 #include "sel-sched.h" 66 #include "sel-sched.h"
235 static void compute_block_dependences (int); 234 static void compute_block_dependences (int);
236 235
237 static void schedule_region (int); 236 static void schedule_region (int);
238 static rtx concat_INSN_LIST (rtx, rtx); 237 static rtx concat_INSN_LIST (rtx, rtx);
239 static void concat_insn_mem_list (rtx, rtx, rtx *, rtx *); 238 static void concat_insn_mem_list (rtx, rtx, rtx *, rtx *);
240 static void propagate_deps (int, struct deps *); 239 static void propagate_deps (int, struct deps_desc *);
241 static void free_pending_lists (void); 240 static void free_pending_lists (void);
242 241
243 /* Functions for construction of the control flow graph. */ 242 /* Functions for construction of the control flow graph. */
244 243
245 /* Return 1 if control flow graph should not be constructed, 0 otherwise. 244 /* Return 1 if control flow graph should not be constructed, 0 otherwise.
352 351
353 /* Functions for the construction of regions. */ 352 /* Functions for the construction of regions. */
354 353
355 /* Print the regions, for debugging purposes. Callable from debugger. */ 354 /* Print the regions, for debugging purposes. Callable from debugger. */
356 355
357 void 356 DEBUG_FUNCTION void
358 debug_regions (void) 357 debug_regions (void)
359 { 358 {
360 int rgn, bb; 359 int rgn, bb;
361 360
362 fprintf (sched_dump, "\n;; ------------ REGIONS ----------\n\n"); 361 fprintf (sched_dump, "\n;; ------------ REGIONS ----------\n\n");
377 } 376 }
378 } 377 }
379 378
380 /* Print the region's basic blocks. */ 379 /* Print the region's basic blocks. */
381 380
382 void 381 DEBUG_FUNCTION void
383 debug_region (int rgn) 382 debug_region (int rgn)
384 { 383 {
385 int bb; 384 int bb;
386 385
387 fprintf (stderr, "\n;; ------------ REGION %d ----------\n\n", rgn); 386 fprintf (stderr, "\n;; ------------ REGION %d ----------\n\n", rgn);
484 RGN_HAS_REAL_EBB (nr_regions) = 0; 483 RGN_HAS_REAL_EBB (nr_regions) = 0;
485 484
486 for (bb = ebb_start; ; bb = bb->next_bb) 485 for (bb = ebb_start; ; bb = bb->next_bb)
487 { 486 {
488 edge e; 487 edge e;
489 edge_iterator ei;
490 488
491 rgn_bb_table[i] = bb->index; 489 rgn_bb_table[i] = bb->index;
492 RGN_NR_BLOCKS (nr_regions)++; 490 RGN_NR_BLOCKS (nr_regions)++;
493 CONTAINING_RGN (bb->index) = nr_regions; 491 CONTAINING_RGN (bb->index) = nr_regions;
494 BLOCK_TO_BB (bb->index) = i - RGN_BLOCKS (nr_regions); 492 BLOCK_TO_BB (bb->index) = i - RGN_BLOCKS (nr_regions);
496 494
497 if (bb->next_bb == EXIT_BLOCK_PTR 495 if (bb->next_bb == EXIT_BLOCK_PTR
498 || LABEL_P (BB_HEAD (bb->next_bb))) 496 || LABEL_P (BB_HEAD (bb->next_bb)))
499 break; 497 break;
500 498
501 FOR_EACH_EDGE (e, ei, bb->succs) 499 e = find_fallthru_edge (bb->succs);
502 if ((e->flags & EDGE_FALLTHRU) != 0)
503 break;
504 if (! e) 500 if (! e)
505 break; 501 break;
506 if (e->probability <= probability_cutoff) 502 if (e->probability <= probability_cutoff)
507 break; 503 break;
508 } 504 }
1592 free (edgelst_table); 1588 free (edgelst_table);
1593 } 1589 }
1594 1590
1595 /* Print candidates info, for debugging purposes. Callable from debugger. */ 1591 /* Print candidates info, for debugging purposes. Callable from debugger. */
1596 1592
1597 void 1593 DEBUG_FUNCTION void
1598 debug_candidate (int i) 1594 debug_candidate (int i)
1599 { 1595 {
1600 if (!candidate_table[i].is_valid) 1596 if (!candidate_table[i].is_valid)
1601 return; 1597 return;
1602 1598
1629 } 1625 }
1630 } 1626 }
1631 1627
1632 /* Print candidates info, for debugging purposes. Callable from debugger. */ 1628 /* Print candidates info, for debugging purposes. Callable from debugger. */
1633 1629
1634 void 1630 DEBUG_FUNCTION void
1635 debug_candidates (int trg) 1631 debug_candidates (int trg)
1636 { 1632 {
1637 int i; 1633 int i;
1638 1634
1639 fprintf (sched_dump, "----------- candidate table: target: b=%d bb=%d ---\n", 1635 fprintf (sched_dump, "----------- candidate table: target: b=%d bb=%d ---\n",
2140 &head, &tail); 2136 &head, &tail);
2141 src_next_tail = NEXT_INSN (tail); 2137 src_next_tail = NEXT_INSN (tail);
2142 src_head = head; 2138 src_head = head;
2143 2139
2144 for (insn = src_head; insn != src_next_tail; insn = NEXT_INSN (insn)) 2140 for (insn = src_head; insn != src_next_tail; insn = NEXT_INSN (insn))
2145 if (INSN_P (insn) && !BOUNDARY_DEBUG_INSN_P (insn)) 2141 if (INSN_P (insn))
2146 try_ready (insn); 2142 try_ready (insn);
2147 } 2143 }
2148 } 2144 }
2149 2145
2150 /* Called after taking INSN from the ready list. Returns nonzero if this 2146 /* Called after taking INSN from the ready list. Returns nonzero if this
2398 get_rgn_sched_max_insns_priority (void) 2394 get_rgn_sched_max_insns_priority (void)
2399 { 2395 {
2400 return rgn_sched_info.sched_max_insns_priority; 2396 return rgn_sched_info.sched_max_insns_priority;
2401 } 2397 }
2402 2398
2403 /* Determine if PAT sets a CLASS_LIKELY_SPILLED_P register. */ 2399 /* Determine if PAT sets a TARGET_CLASS_LIKELY_SPILLED_P register. */
2404 2400
2405 static bool 2401 static bool
2406 sets_likely_spilled (rtx pat) 2402 sets_likely_spilled (rtx pat)
2407 { 2403 {
2408 bool ret = false; 2404 bool ret = false;
2415 { 2411 {
2416 bool *ret = (bool *) data; 2412 bool *ret = (bool *) data;
2417 2413
2418 if (GET_CODE (pat) == SET 2414 if (GET_CODE (pat) == SET
2419 && REG_P (x) 2415 && REG_P (x)
2420 && REGNO (x) < FIRST_PSEUDO_REGISTER 2416 && HARD_REGISTER_P (x)
2421 && CLASS_LIKELY_SPILLED_P (REGNO_REG_CLASS (REGNO (x)))) 2417 && targetm.class_likely_spilled_p (REGNO_REG_CLASS (REGNO (x))))
2422 *ret = true; 2418 *ret = true;
2423 } 2419 }
2424 2420
2425 /* A bitmap to note insns that participate in any dependency. Used in 2421 /* A bitmap to note insns that participate in any dependency. Used in
2426 add_branch_dependences. */ 2422 add_branch_dependences. */
2445 cc0 setters remain at the end because they can't be moved away from 2441 cc0 setters remain at the end because they can't be moved away from
2446 their cc0 user. 2442 their cc0 user.
2447 2443
2448 COND_EXEC insns cannot be moved past a branch (see e.g. PR17808). 2444 COND_EXEC insns cannot be moved past a branch (see e.g. PR17808).
2449 2445
2450 Insns setting CLASS_LIKELY_SPILLED_P registers (usually return values) 2446 Insns setting TARGET_CLASS_LIKELY_SPILLED_P registers (usually return
2451 are not moved before reload because we can wind up with register 2447 values) are not moved before reload because we can wind up with register
2452 allocation failures. */ 2448 allocation failures. */
2453 2449
2454 while (tail != head && DEBUG_INSN_P (tail)) 2450 while (tail != head && DEBUG_INSN_P (tail))
2455 tail = PREV_INSN (tail); 2451 tail = PREV_INSN (tail);
2456 2452
2565 keep one `deps' structure for every basic block. Before analyzing the 2561 keep one `deps' structure for every basic block. Before analyzing the
2566 data dependences for a bb, its variables are initialized as a function of 2562 data dependences for a bb, its variables are initialized as a function of
2567 the variables of its predecessors. When the analysis for a bb completes, 2563 the variables of its predecessors. When the analysis for a bb completes,
2568 we save the contents to the corresponding bb_deps[bb] variable. */ 2564 we save the contents to the corresponding bb_deps[bb] variable. */
2569 2565
2570 static struct deps *bb_deps; 2566 static struct deps_desc *bb_deps;
2571 2567
2572 /* Duplicate the INSN_LIST elements of COPY and prepend them to OLD. */ 2568 /* Duplicate the INSN_LIST elements of COPY and prepend them to OLD. */
2573 2569
2574 static rtx 2570 static rtx
2575 concat_INSN_LIST (rtx copy, rtx old) 2571 concat_INSN_LIST (rtx copy, rtx old)
2576 { 2572 {
2577 rtx new_rtx = old; 2573 rtx new_rtx = old;
2578 for (; copy ; copy = XEXP (copy, 1)) 2574 for (; copy ; copy = XEXP (copy, 1))
2579 new_rtx = alloc_INSN_LIST (XEXP (copy, 0), new_rtx); 2575 {
2576 new_rtx = alloc_INSN_LIST (XEXP (copy, 0), new_rtx);
2577 PUT_REG_NOTE_KIND (new_rtx, REG_NOTE_KIND (copy));
2578 }
2580 return new_rtx; 2579 return new_rtx;
2581 } 2580 }
2582 2581
2583 static void 2582 static void
2584 concat_insn_mem_list (rtx copy_insns, rtx copy_mems, rtx *old_insns_p, 2583 concat_insn_mem_list (rtx copy_insns, rtx copy_mems, rtx *old_insns_p,
2599 *old_mems_p = new_mems; 2598 *old_mems_p = new_mems;
2600 } 2599 }
2601 2600
2602 /* Join PRED_DEPS to the SUCC_DEPS. */ 2601 /* Join PRED_DEPS to the SUCC_DEPS. */
2603 void 2602 void
2604 deps_join (struct deps *succ_deps, struct deps *pred_deps) 2603 deps_join (struct deps_desc *succ_deps, struct deps_desc *pred_deps)
2605 { 2604 {
2606 unsigned reg; 2605 unsigned reg;
2607 reg_set_iterator rsi; 2606 reg_set_iterator rsi;
2608 2607
2609 /* The reg_last lists are inherited by successor. */ 2608 /* The reg_last lists are inherited by successor. */
2658 } 2657 }
2659 2658
2660 /* After computing the dependencies for block BB, propagate the dependencies 2659 /* After computing the dependencies for block BB, propagate the dependencies
2661 found in TMP_DEPS to the successors of the block. */ 2660 found in TMP_DEPS to the successors of the block. */
2662 static void 2661 static void
2663 propagate_deps (int bb, struct deps *pred_deps) 2662 propagate_deps (int bb, struct deps_desc *pred_deps)
2664 { 2663 {
2665 basic_block block = BASIC_BLOCK (BB_TO_BLOCK (bb)); 2664 basic_block block = BASIC_BLOCK (BB_TO_BLOCK (bb));
2666 edge_iterator ei; 2665 edge_iterator ei;
2667 edge e; 2666 edge e;
2668 2667
2713 2712
2714 static void 2713 static void
2715 compute_block_dependences (int bb) 2714 compute_block_dependences (int bb)
2716 { 2715 {
2717 rtx head, tail; 2716 rtx head, tail;
2718 struct deps tmp_deps; 2717 struct deps_desc tmp_deps;
2719 2718
2720 tmp_deps = bb_deps[bb]; 2719 tmp_deps = bb_deps[bb];
2721 2720
2722 /* Do the analysis for this block. */ 2721 /* Do the analysis for this block. */
2723 gcc_assert (EBB_FIRST_BB (bb) == EBB_LAST_BB (bb)); 2722 gcc_assert (EBB_FIRST_BB (bb) == EBB_LAST_BB (bb));
2773 2772
2774 /* Print dependences for debugging starting from FROM_BB. 2773 /* Print dependences for debugging starting from FROM_BB.
2775 Callable from debugger. */ 2774 Callable from debugger. */
2776 /* Print dependences for debugging starting from FROM_BB. 2775 /* Print dependences for debugging starting from FROM_BB.
2777 Callable from debugger. */ 2776 Callable from debugger. */
2778 void 2777 DEBUG_FUNCTION void
2779 debug_rgn_dependencies (int from_bb) 2778 debug_rgn_dependencies (int from_bb)
2780 { 2779 {
2781 int bb; 2780 int bb;
2782 2781
2783 fprintf (sched_dump, 2782 fprintf (sched_dump,
3148 sched_emulate_haifa_p = 1; 3147 sched_emulate_haifa_p = 1;
3149 3148
3150 init_deps_global (); 3149 init_deps_global ();
3151 3150
3152 /* Initializations for region data dependence analysis. */ 3151 /* Initializations for region data dependence analysis. */
3153 bb_deps = XNEWVEC (struct deps, current_nr_blocks); 3152 bb_deps = XNEWVEC (struct deps_desc, current_nr_blocks);
3154 for (bb = 0; bb < current_nr_blocks; bb++) 3153 for (bb = 0; bb < current_nr_blocks; bb++)
3155 init_deps (bb_deps + bb, false); 3154 init_deps (bb_deps + bb, false);
3156 3155
3157 /* Initialize bitmap used in add_branch_dependences. */ 3156 /* Initialize bitmap used in add_branch_dependences. */
3158 insn_referenced = sbitmap_alloc (sched_max_luid); 3157 insn_referenced = sbitmap_alloc (sched_max_luid);