[multiple changes]
[platform/upstream/gcc.git] / gcc / resource.c
index 6acc718..a8b449f 100644 (file)
@@ -1,5 +1,5 @@
 /* Definitions for computing resource usage of specific insns.
-   Copyright (C) 1999-2014 Free Software Foundation, Inc.
+   Copyright (C) 1999-2015 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -20,12 +20,11 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
-#include "tm.h"
-#include "diagnostic-core.h"
+#include "backend.h"
 #include "rtl.h"
+#include "df.h"
+#include "diagnostic-core.h"
 #include "tm_p.h"
-#include "hard-reg-set.h"
-#include "function.h"
 #include "regs.h"
 #include "flags.h"
 #include "output.h"
@@ -33,7 +32,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "except.h"
 #include "insn-attr.h"
 #include "params.h"
-#include "df.h"
+#include "emit-rtl.h"
 
 /* This structure is used to record liveness information at the targets or
    fallthrough insns of branches.  We will most likely need the information
@@ -106,7 +105,7 @@ update_live_status (rtx dest, const_rtx x, void *data ATTRIBUTE_UNUSED)
   else
     {
       first_regno = REGNO (dest);
-      last_regno = END_HARD_REGNO (dest);
+      last_regno = END_REGNO (dest);
     }
 
   if (GET_CODE (x) == CLOBBER)
@@ -326,9 +325,8 @@ mark_referenced_resources (rtx x, struct resources *res,
          if (frame_pointer_needed)
            {
              SET_HARD_REG_BIT (res->regs, FRAME_POINTER_REGNUM);
-#if !HARD_FRAME_POINTER_IS_FRAME_POINTER
-             SET_HARD_REG_BIT (res->regs, HARD_FRAME_POINTER_REGNUM);
-#endif
+             if (!HARD_FRAME_POINTER_IS_FRAME_POINTER)
+               SET_HARD_REG_BIT (res->regs, HARD_FRAME_POINTER_REGNUM);
            }
 
          for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
@@ -384,11 +382,9 @@ mark_referenced_resources (rtx x, struct resources *res,
                          include_delayed_effects
                          ? MARK_SRC_DEST_CALL : MARK_SRC_DEST);
 
-#ifdef INSN_REFERENCES_ARE_DELAYED
       if (! include_delayed_effects
          && INSN_REFERENCES_ARE_DELAYED (as_a <rtx_insn *> (x)))
        return;
-#endif
 
       /* No special processing, just speed up.  */
       mark_referenced_resources (PATTERN (x), res, include_delayed_effects);
@@ -433,7 +429,7 @@ find_dead_or_set_registers (rtx_insn *target, struct resources *res,
 
   for (insn = target; insn; insn = next_insn)
     {
-      rtx_insn *this_jump_insn = insn;
+      rtx_insn *this_insn = insn;
 
       next_insn = NEXT_INSN (insn);
 
@@ -481,8 +477,8 @@ find_dead_or_set_registers (rtx_insn *target, struct resources *res,
                 of a call, so search for a JUMP_INSN in any position.  */
              for (i = 0; i < seq->len (); i++)
                {
-                 this_jump_insn = seq->insn (i);
-                 if (JUMP_P (this_jump_insn))
+                 this_insn = seq->insn (i);
+                 if (JUMP_P (this_insn))
                    break;
                }
            }
@@ -491,14 +487,15 @@ find_dead_or_set_registers (rtx_insn *target, struct resources *res,
          break;
        }
 
-      if (JUMP_P (this_jump_insn))
+      if (rtx_jump_insn *this_jump_insn =
+           dyn_cast <rtx_jump_insn *> (this_insn))
        {
          if (jump_count++ < 10)
            {
              if (any_uncondjump_p (this_jump_insn)
                  || ANY_RETURN_P (PATTERN (this_jump_insn)))
                {
-                 rtx lab_or_return = JUMP_LABEL (this_jump_insn);
+                 rtx lab_or_return = this_jump_insn->jump_label ();
                  if (ANY_RETURN_P (lab_or_return))
                    next_insn = NULL;
                  else
@@ -571,10 +568,10 @@ find_dead_or_set_registers (rtx_insn *target, struct resources *res,
                  AND_COMPL_HARD_REG_SET (scratch, needed.regs);
                  AND_COMPL_HARD_REG_SET (fallthrough_res.regs, scratch);
 
-                 if (!ANY_RETURN_P (JUMP_LABEL (this_jump_insn)))
-                   find_dead_or_set_registers (JUMP_LABEL_AS_INSN (this_jump_insn),
-                                               &target_res, 0, jump_count,
-                                               target_set, needed);
+                 if (!ANY_RETURN_P (this_jump_insn->jump_label ()))
+                   find_dead_or_set_registers
+                         (this_jump_insn->jump_target (),
+                          &target_res, 0, jump_count, target_set, needed);
                  find_dead_or_set_registers (next_insn,
                                              &fallthrough_res, 0, jump_count,
                                              set, needed);
@@ -688,11 +685,9 @@ mark_set_resources (rtx x, struct resources *res, int in_dest,
        /* An insn consisting of just a CLOBBER (or USE) is just for flow
           and doesn't actually do anything, so we ignore it.  */
 
-#ifdef INSN_SETS_ARE_DELAYED
       if (mark_type != MARK_SRC_DEST_CALL
          && INSN_SETS_ARE_DELAYED (as_a <rtx_insn *> (x)))
        return;
-#endif
 
       x = PATTERN (x);
       if (GET_CODE (x) != USE && GET_CODE (x) != CLOBBER)
@@ -890,7 +885,6 @@ mark_target_live_regs (rtx_insn *insns, rtx target_maybe_return, struct resource
   unsigned int i;
   struct target_info *tinfo = NULL;
   rtx_insn *insn;
-  rtx jump_insn = 0;
   rtx jump_target;
   HARD_REG_SET scratch;
   struct resources set, needed;
@@ -1118,8 +1112,8 @@ mark_target_live_regs (rtx_insn *insns, rtx target_maybe_return, struct resource
   CLEAR_RESOURCE (&set);
   CLEAR_RESOURCE (&needed);
 
-  jump_insn = find_dead_or_set_registers (target, res, &jump_target, 0,
-                                         set, needed);
+  rtx_insn *jump_insn = find_dead_or_set_registers (target, res, &jump_target,
+                                                   0, set, needed);
 
   /* If we hit an unconditional branch, we have another way of finding out
      what is live: we can see what is live at the branch target and include
@@ -1181,9 +1175,9 @@ init_resource_info (rtx_insn *epilogue_insn)
   if (frame_pointer_needed)
     {
       SET_HARD_REG_BIT (end_of_function_needs.regs, FRAME_POINTER_REGNUM);
-#if !HARD_FRAME_POINTER_IS_FRAME_POINTER
-      SET_HARD_REG_BIT (end_of_function_needs.regs, HARD_FRAME_POINTER_REGNUM);
-#endif
+      if (!HARD_FRAME_POINTER_IS_FRAME_POINTER)
+       SET_HARD_REG_BIT (end_of_function_needs.regs,
+                         HARD_FRAME_POINTER_REGNUM);
     }
   if (!(frame_pointer_needed
        && EXIT_IGNORE_STACK
@@ -1196,11 +1190,7 @@ init_resource_info (rtx_insn *epilogue_insn)
                               &end_of_function_needs, true);
 
   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
-    if (global_regs[i]
-#ifdef EPILOGUE_USES
-       || EPILOGUE_USES (i)
-#endif
-       )
+    if (global_regs[i] || EPILOGUE_USES (i))
       SET_HARD_REG_BIT (end_of_function_needs.regs, i);
 
   /* The registers required to be live at the end of the function are