OSDN Git Service

[gcc/ChangeLog]
[pf3gnuchains/gcc-fork.git] / gcc / cfglayout.c
index e887015..994ab45 100644 (file)
@@ -119,7 +119,7 @@ skip_insns_after_block (basic_block bb)
 
        case CODE_LABEL:
          if (NEXT_INSN (insn)
-             && GET_CODE (NEXT_INSN (insn)) == JUMP_INSN
+             && JUMP_P (NEXT_INSN (insn))
              && (GET_CODE (PATTERN (NEXT_INSN (insn))) == ADDR_VEC
                  || GET_CODE (PATTERN (NEXT_INSN (insn))) == ADDR_DIFF_VEC))
            {
@@ -149,7 +149,7 @@ skip_insns_after_block (basic_block bb)
   for (insn = last_insn; insn != BB_END (bb); insn = prev)
     {
       prev = PREV_INSN (insn);
-      if (GET_CODE (insn) == NOTE)
+      if (NOTE_P (insn))
        switch (NOTE_LINE_NUMBER (insn))
          {
          case NOTE_INSN_LOOP_END:
@@ -172,7 +172,7 @@ label_for_bb (basic_block bb)
 {
   rtx label = BB_HEAD (bb);
 
-  if (GET_CODE (label) != CODE_LABEL)
+  if (!LABEL_P (label))
     {
       if (dump_file)
        fprintf (dump_file, "Emitting label for block %d\n", bb->index);
@@ -195,7 +195,7 @@ record_effective_endpoints (void)
 
   for (insn = get_insns ();
        insn
-       && GET_CODE (insn) == NOTE
+       && NOTE_P (insn)
        && NOTE_LINE_NUMBER (insn) != NOTE_INSN_BASIC_BLOCK;
        insn = NEXT_INSN (insn))
     continue;
@@ -254,7 +254,7 @@ insn_locators_initialize (void)
   rtx insn, next;
   int loc = 0;
   int line_number = 0, last_line_number = 0;
-  char *file_name = NULL, *last_file_name = NULL;
+  const char *file_name = NULL, *last_file_name = NULL;
 
   prologue_locator = epilogue_locator = 0;
 
@@ -267,12 +267,38 @@ insn_locators_initialize (void)
 
   for (insn = get_insns (); insn; insn = next)
     {
+      int active = 0;
+      
       next = NEXT_INSN (insn);
 
-      if ((active_insn_p (insn)
-          && GET_CODE (PATTERN (insn)) != ADDR_VEC
-          && GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC)
-         || !NEXT_INSN (insn)
+      if (NOTE_P (insn))
+       {
+         switch (NOTE_LINE_NUMBER (insn))
+           {
+           case NOTE_INSN_BLOCK_BEG:
+           case NOTE_INSN_BLOCK_END:
+             abort ();
+             
+           default:
+             if (NOTE_LINE_NUMBER (insn) > 0)
+               {
+                 expanded_location xloc;
+                 NOTE_EXPANDED_LOCATION (xloc, insn);
+                 line_number = xloc.line;
+                 file_name = xloc.file;
+               }
+             break;
+           }
+       }
+      else
+       active = (active_insn_p (insn)
+                 && GET_CODE (PATTERN (insn)) != ADDR_VEC
+                 && GET_CODE (PATTERN (insn)) != ADDR_DIFF_VEC);
+      
+      check_block_change (insn, &block);
+
+      if (active
+         || !next
          || (!prologue_locator && file_name))
        {
          if (last_block != block)
@@ -293,54 +319,23 @@ insn_locators_initialize (void)
            {
              loc++;
              VARRAY_PUSH_INT (file_locators_locs, loc);
-             VARRAY_PUSH_CHAR_PTR (file_locators_files, file_name);
+             VARRAY_PUSH_CHAR_PTR (file_locators_files, (char *) file_name);
              last_file_name = file_name;
            }
+         if (!prologue_locator && file_name)
+           prologue_locator = loc;
+         if (!next)
+           epilogue_locator = loc;
+         if (active)
+           INSN_LOCATOR (insn) = loc;
        }
-      if (!prologue_locator && file_name)
-       prologue_locator = loc;
-      if (!NEXT_INSN (insn))
-       epilogue_locator = loc;
-      if (active_insn_p (insn))
-        INSN_LOCATOR (insn) = loc;
-      else if (GET_CODE (insn) == NOTE)
-       {
-         switch (NOTE_LINE_NUMBER (insn))
-           {
-           case NOTE_INSN_BLOCK_BEG:
-             if (cfun->dont_emit_block_notes)
-               abort ();
-             block = NOTE_BLOCK (insn);
-             delete_insn (insn);
-             break;
-           case NOTE_INSN_BLOCK_END:
-             if (cfun->dont_emit_block_notes)
-               abort ();
-             block = BLOCK_SUPERCONTEXT (block);
-             if (block && TREE_CODE (block) == FUNCTION_DECL)
-               block = 0;
-             delete_insn (insn);
-             break;
-           default:
-             if (NOTE_LINE_NUMBER (insn) > 0)
-               {
-                 line_number = NOTE_LINE_NUMBER (insn);
-                 file_name = (char *)NOTE_SOURCE_FILE (insn);
-               }
-             break;
-           }
-       }
-
-      if (cfun->dont_emit_block_notes)
-       check_block_change (insn, &block);
     }
 
   /* Tag the blocks with a depth number so that change_scope can find
      the common parent easily.  */
   set_block_levels (DECL_INITIAL (cfun->decl), 0);
 
-  if (cfun->dont_emit_block_notes)
-    free_block_changes ();
+  free_block_changes ();
 }
 
 /* For each lexical block, set BLOCK_NUMBER to the depth at which it is
@@ -659,7 +654,7 @@ fixup_reorder_chain (void)
          e_taken = e;
 
       bb_end_insn = BB_END (bb);
-      if (GET_CODE (bb_end_insn) == JUMP_INSN)
+      if (JUMP_P (bb_end_insn))
        {
          if (any_condjump_p (bb_end_insn))
            {
@@ -728,7 +723,8 @@ fixup_reorder_chain (void)
 
              /* If the "jumping" edge is a crossing edge, and the fall
                 through edge is non-crossing, leave things as they are.  */
-             else if (e_taken->crossing_edge && !e_fall->crossing_edge)
+             else if ((e_taken->flags & EDGE_CROSSING)
+                      && !(e_fall->flags & EDGE_CROSSING))
                continue;
 
              /* Otherwise we can try to invert the jump.  This will
@@ -798,11 +794,13 @@ fixup_reorder_chain (void)
          bb = nb;
          
          /* Make sure new bb is tagged for correct section (same as
-            fall-thru source).  */
-         e_fall->src->partition = bb->pred->src->partition;
-         if (flag_reorder_blocks_and_partition)
+            fall-thru source, since you cannot fall-throu across
+            section boundaries).  */
+         BB_COPY_PARTITION (e_fall->src, bb->pred->src);
+         if (flag_reorder_blocks_and_partition
+             && targetm.have_named_sections)
            {
-             if (bb->pred->src->partition == COLD_PARTITION)
+             if (BB_PARTITION (bb->pred->src) == BB_COLD_PARTITION)
                {
                  rtx new_note;
                  rtx note = BB_HEAD (e_fall->src);
@@ -816,9 +814,9 @@ fixup_reorder_chain (void)
                                           note);
                  NOTE_BASIC_BLOCK (new_note) = bb;
                }
-             if (GET_CODE (BB_END (bb)) == JUMP_INSN
+             if (JUMP_P (BB_END (bb))
                  && !any_condjump_p (BB_END (bb))
-                 && bb->succ->crossing_edge )
+                 && (bb->succ->flags & EDGE_CROSSING))
                REG_NOTES (BB_END (bb)) = gen_rtx_EXPR_LIST 
                  (REG_CROSSING_JUMP, NULL_RTX, REG_NOTES (BB_END (bb)));
            }
@@ -839,7 +837,7 @@ fixup_reorder_chain (void)
            fprintf (dump_file, "duplicate of %i ",
                     bb->rbi->original->index);
          else if (forwarder_block_p (bb)
-                  && GET_CODE (BB_HEAD (bb)) != CODE_LABEL)
+                  && !LABEL_P (BB_HEAD (bb)))
            fprintf (dump_file, "compensation ");
          else
            fprintf (dump_file, "bb %i ", bb->index);
@@ -885,7 +883,7 @@ update_unlikely_executed_notes (basic_block bb)
 
   for (cur_insn = BB_HEAD (bb); cur_insn != BB_END (bb); 
        cur_insn = NEXT_INSN (cur_insn)) 
-    if (GET_CODE (cur_insn) == NOTE
+    if (NOTE_P (cur_insn)
        && NOTE_LINE_NUMBER (cur_insn) == NOTE_INSN_UNLIKELY_EXECUTED_CODE)
       NOTE_BASIC_BLOCK (cur_insn) = bb;
 }
@@ -1042,8 +1040,6 @@ duplicate_insn_chain (rtx from, rtx to)
                 in first BB, we may want to copy the block.  */
            case NOTE_INSN_PROLOGUE_END:
 
-           case NOTE_INSN_LOOP_VTOP:
-           case NOTE_INSN_LOOP_CONT:
            case NOTE_INSN_LOOP_BEG:
            case NOTE_INSN_LOOP_END:
              /* Strip down the loop notes - we don't really want to keep
@@ -1112,6 +1108,7 @@ cfg_layout_duplicate_bb (basic_block bb)
                               insn ? get_last_insn () : NULL,
                               EXIT_BLOCK_PTR->prev_bb);
 
+  BB_COPY_PARTITION (new_bb, bb);
   if (bb->rbi->header)
     {
       insn = bb->rbi->header;
@@ -1143,11 +1140,15 @@ cfg_layout_duplicate_bb (basic_block bb)
   return new_bb;
 }
 \f
-/* Main entry point to this module - initialize the data structures for
-   CFG layout changes.  It keeps LOOPS up-to-date if not null.  */
+/* Main entry point to this module - initialize the datastructures for
+   CFG layout changes.  It keeps LOOPS up-to-date if not null.
+
+   FLAGS is a set of additional flags to pass to cleanup_cfg().  It should
+   include CLEANUP_UPDATE_LIFE if liveness information must be kept up
+   to date.  */
 
 void
-cfg_layout_initialize (void)
+cfg_layout_initialize (unsigned int flags)
 {
   basic_block bb;
 
@@ -1162,7 +1163,7 @@ cfg_layout_initialize (void)
 
   record_effective_endpoints ();
 
-  cleanup_cfg (CLEANUP_CFGLAYOUT);
+  cleanup_cfg (CLEANUP_CFGLAYOUT | flags);
 }
 
 /* Splits superblocks.  */