OSDN Git Service

* config/arm/lib1funcs.asm (ARM_FUNC_ALIAS): Also alias _L__name.
[pf3gnuchains/gcc-fork.git] / gcc / bb-reorder.c
index 022cb33..90c1454 100644 (file)
@@ -78,6 +78,7 @@
 #include "fibheap.h"
 #include "target.h"
 #include "function.h"
+#include "tm_p.h"
 #include "obstack.h"
 #include "expr.h"
 #include "regs.h"
    the .o file there will be an extra round.*/
 #define N_ROUNDS 5
 
+/* Stubs in case we don't have a return insn.
+   We have to check at runtime too, not only compiletime.  */  
+
+#ifndef HAVE_return
+#define HAVE_return 0
+#define gen_return() NULL_RTX
+#endif
+
+
 /* Branch thresholds in thousandths (per mille) of the REG_BR_PROB_BASE.  */
 static int branch_threshold[N_ROUNDS] = {400, 200, 100, 0, 0};
 
@@ -739,7 +749,7 @@ copy_bb (basic_block old_bb, edge e, basic_block bb, int trace)
 {
   basic_block new_bb;
 
-  new_bb = cfg_layout_duplicate_bb (old_bb, e);
+  new_bb = duplicate_block (old_bb, e);
   if (e->dest != new_bb)
     abort ();
   if (e->dest->rbi->visited)
@@ -891,7 +901,7 @@ connect_traces (int n_traces, struct trace *traces)
   last_trace = -1;
 
   /* If we are partitioning hot/cold basic blocks, mark the cold
-     traces as already connnected, to remove them from consideration
+     traces as already connected, to remove them from consideration
      for connection to the hot traces.  After the hot traces have all
      been connected (determined by "unconnected_hot_trace_count"), we
      will go back and connect the cold traces.  */
@@ -1149,6 +1159,7 @@ connect_traces (int n_traces, struct trace *traces)
     }
 
   FREE (connected);
+  FREE (cold_traces);
 }
 
 /* Return true when BB can and should be copied. CODE_MAY_GROW is true
@@ -1167,7 +1178,7 @@ copy_bb_p (basic_block bb, int code_may_grow)
     return false;
   if (!bb->pred || !bb->pred->pred_next)
     return false;
-  if (!cfg_layout_can_duplicate_bb_p (bb))
+  if (!can_duplicate_block_p (bb))
     return false;
 
   /* Avoid duplicating blocks which have many successors (PR/13430).  */
@@ -1295,8 +1306,8 @@ mark_bb_for_unlikely_executed_section (basic_block bb)
   
   for (cur_insn = BB_HEAD (bb); cur_insn != NEXT_INSN (BB_END (bb)); 
        cur_insn = NEXT_INSN (cur_insn))
-    if (GET_CODE (cur_insn) != NOTE
-       && GET_CODE (cur_insn) != CODE_LABEL)
+    if (!NOTE_P (cur_insn)
+       && !LABEL_P (cur_insn))
       {
        insert_insn = cur_insn;
        break;
@@ -1320,7 +1331,7 @@ mark_bb_for_unlikely_executed_section (basic_block bb)
 
 /* If any destination of a crossing edge does not have a label, add label;
    Convert any fall-through crossing edges (for blocks that do not contain
-   a jump) to unconditional jumps.   */
+   a jump) to unconditional jumps.  */
 
 static void 
 add_labels_and_missing_jumps (edge *crossing_edges, int n_crossing_edges)
@@ -1349,7 +1360,7 @@ add_labels_and_missing_jumps (edge *crossing_edges, int n_crossing_edges)
              
              if (src && (src != ENTRY_BLOCK_PTR)) 
                {
-                 if (GET_CODE (BB_END (src)) != JUMP_INSN)
+                 if (!JUMP_P (BB_END (src)))
                    /* bb just falls through.  */
                    {
                      /* make sure there's only one successor */
@@ -1399,7 +1410,7 @@ fix_up_fall_thru_edges (void)
   edge succ1;
   edge succ2;
   edge fall_thru;
-  edge cond_jump;
+  edge cond_jump = NULL;
   edge e;
   bool cond_jump_crosses;
   int invert_worked;
@@ -1461,7 +1472,7 @@ fix_up_fall_thru_edges (void)
                      && cur_bb->rbi->next == cond_jump->dest)
                    {
                      /* Find label in fall_thru block. We've already added
-                        any missing labels, so there must be one. */
+                        any missing labels, so there must be one.  */
                      
                      fall_thru_label = block_label (fall_thru->dest);
 
@@ -1543,16 +1554,16 @@ find_jump_block (basic_block jump_dest)
        
        /* Check each predecessor to see if it has a label, and contains
           only one executable instruction, which is an unconditional jump.
-          If so, we can use it.   */
+          If so, we can use it.  */
        
-       if (GET_CODE (BB_HEAD (src)) == CODE_LABEL)
+       if (LABEL_P (BB_HEAD (src)))
          for (insn = BB_HEAD (src); 
               !INSN_P (insn) && insn != NEXT_INSN (BB_END (src));
               insn = NEXT_INSN (insn))
            {
              if (INSN_P (insn)
                  && insn == BB_END (src)
-                 && GET_CODE (insn) == JUMP_INSN
+                 && JUMP_P (insn)
                  && !any_condjump_p (insn))
                {
                  source_bb = src;
@@ -1684,11 +1695,10 @@ fix_crossing_conditional_branches (void)
                                                       (old_label), 
                                                       BB_END (new_bb));
                    }
-#ifdef HAVE_return
-                 else if (GET_CODE (old_label) == RETURN)
+                 else if (HAVE_return
+                          && GET_CODE (old_label) == RETURN)
                    new_jump = emit_jump_insn_after (gen_return (), 
                                                     BB_END (new_bb));
-#endif
                  else
                    abort ();
                  
@@ -1753,7 +1763,7 @@ fix_crossing_unconditional_branches (void)
       /* Check to see if bb ends in a crossing (unconditional) jump.  At
          this point, no crossing jumps should be conditional.  */
 
-      if (GET_CODE (last_insn) == JUMP_INSN
+      if (JUMP_P (last_insn)
          && succ->crossing_edge)
        {
          rtx label2, table;
@@ -1771,7 +1781,7 @@ fix_crossing_unconditional_branches (void)
                 reference of label, as target for jump.  */
              
              label = JUMP_LABEL (last_insn);
-             label_addr = gen_rtx_LABEL_REF (VOIDmode, label);
+             label_addr = gen_rtx_LABEL_REF (Pmode, label);
              LABEL_NUSES (label) += 1;
              
              /* Get a register to use for the indirect jump.  */
@@ -1793,7 +1803,7 @@ fix_crossing_unconditional_branches (void)
                   cur_insn = NEXT_INSN (cur_insn))
                {
                  BLOCK_FOR_INSN (cur_insn) = cur_bb;
-                 if (GET_CODE (cur_insn) == JUMP_INSN)
+                 if (JUMP_P (cur_insn))
                    jump_insn = cur_insn;
                }
              
@@ -1823,7 +1833,7 @@ add_reg_crossing_jump_notes (void)
   FOR_EACH_BB (bb)
     for (e = bb->succ; e; e = e->succ_next)
       if (e->crossing_edge
-         && GET_CODE (BB_END (e->src)) == JUMP_INSN)
+         && JUMP_P (BB_END (e->src)))
        REG_NOTES (BB_END (e->src)) = gen_rtx_EXPR_LIST (REG_CROSSING_JUMP, 
                                                         NULL_RTX, 
                                                         REG_NOTES (BB_END 
@@ -1898,10 +1908,11 @@ fix_edges_for_rarely_executed_code (edge *crossing_edges,
   add_reg_crossing_jump_notes ();
 }
 
-/* Reorder basic blocks.  The main entry point to this file.  */
+/* Reorder basic blocks.  The main entry point to this file.  FLAGS is
+   the set of flags to pass to cfg_layout_initialize().  */
 
 void
-reorder_basic_blocks (void)
+reorder_basic_blocks (unsigned int flags)
 {
   int n_traces;
   int i;
@@ -1915,7 +1926,7 @@ reorder_basic_blocks (void)
 
   timevar_push (TV_REORDER_BLOCKS);
 
-  cfg_layout_initialize ();
+  cfg_layout_initialize (flags);
 
   set_edge_can_fallthru_flag ();
   mark_dfs_back_edges ();
@@ -1989,7 +2000,7 @@ partition_hot_cold_basic_blocks (void)
   
   crossing_edges = xcalloc (max_edges, sizeof (edge));
 
-  cfg_layout_initialize ();
+  cfg_layout_initialize (0);
   
   FOR_EACH_BB (cur_bb)
     if (cur_bb->index >= 0