OSDN Git Service

* except.c (expand_eh_region_start, expand_eh_region_end,
[pf3gnuchains/gcc-fork.git] / gcc / sched-deps.c
index 390ab3e..4432215 100644 (file)
@@ -44,8 +44,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "cselib.h"
 #include "df.h"
 
-extern char *reg_known_equiv_p;
-extern rtx *reg_known_value;
 
 static regset_head reg_pending_sets_head;
 static regset_head reg_pending_clobbers_head;
@@ -113,10 +111,12 @@ deps_may_trap_p (rtx mem)
 {
   rtx addr = XEXP (mem, 0);
 
-  if (REG_P (addr)
-      && REGNO (addr) >= FIRST_PSEUDO_REGISTER
-      && reg_known_value[REGNO (addr)])
-    addr = reg_known_value[REGNO (addr)];
+  if (REG_P (addr) && REGNO (addr) >= FIRST_PSEUDO_REGISTER)
+    {
+      rtx t = get_reg_known_value (REGNO (addr));
+      if (t)
+       addr = t;
+    }
   return rtx_addr_can_trap_p (addr);
 }
 \f
@@ -171,8 +171,8 @@ get_condition (rtx insn)
 static int
 conditions_mutex_p (rtx cond1, rtx cond2)
 {
-  if (GET_RTX_CLASS (GET_CODE (cond1)) == '<'
-      && GET_RTX_CLASS (GET_CODE (cond2)) == '<'
+  if (COMPARISON_P (cond1)
+      && COMPARISON_P (cond2)
       && GET_CODE (cond1) == reverse_condition (GET_CODE (cond2))
       && XEXP (cond1, 0) == XEXP (cond2, 0)
       && XEXP (cond1, 1) == XEXP (cond2, 1))
@@ -484,7 +484,7 @@ sched_analyze_1 (struct deps *deps, rtx x, rtx insn)
       dest = XEXP (dest, 0);
     }
 
-  if (GET_CODE (dest) == REG)
+  if (REG_P (dest))
     {
       regno = REGNO (dest);
 
@@ -523,10 +523,12 @@ sched_analyze_1 (struct deps *deps, rtx x, rtx insn)
          /* Pseudos that are REG_EQUIV to something may be replaced
             by that during reloading.  We need only add dependencies for
             the address in the REG_EQUIV note.  */
-         if (!reload_completed
-             && reg_known_equiv_p[regno]
-             && GET_CODE (reg_known_value[regno]) == MEM)
-           sched_analyze_2 (deps, XEXP (reg_known_value[regno], 0), insn);
+         if (!reload_completed && get_reg_known_equiv_p (regno))
+           {
+             rtx t = get_reg_known_value (regno);
+             if (MEM_P (t))
+               sched_analyze_2 (deps, XEXP (t, 0), insn);
+           }
 
          /* Don't let it cross a call after scheduling if it doesn't
             already cross one.  */
@@ -534,7 +536,7 @@ sched_analyze_1 (struct deps *deps, rtx x, rtx insn)
            add_dependence_list (insn, deps->last_function_call, REG_DEP_ANTI);
        }
     }
-  else if (GET_CODE (dest) == MEM)
+  else if (MEM_P (dest))
     {
       /* Writing memory.  */
       rtx t = dest;
@@ -659,10 +661,12 @@ sched_analyze_2 (struct deps *deps, rtx x, rtx insn)
            /* Pseudos that are REG_EQUIV to something may be replaced
               by that during reloading.  We need only add dependencies for
               the address in the REG_EQUIV note.  */
-           if (!reload_completed
-               && reg_known_equiv_p[regno]
-               && GET_CODE (reg_known_value[regno]) == MEM)
-             sched_analyze_2 (deps, XEXP (reg_known_value[regno], 0), insn);
+           if (!reload_completed && get_reg_known_equiv_p (regno))
+             {
+               rtx t = get_reg_known_value (regno);
+               if (MEM_P (t))
+                 sched_analyze_2 (deps, XEXP (t, 0), insn);
+             }
 
            /* If the register does not already cross any calls, then add this
               insn to the sched_before_next_call list so that it will still
@@ -1119,7 +1123,7 @@ sched_analyze_insn (struct deps *deps, rtx x, rtx insn, rtx loop_notes)
       tmp = SET_DEST (set);
       if (GET_CODE (tmp) == SUBREG)
        tmp = SUBREG_REG (tmp);
-      if (GET_CODE (tmp) == REG)
+      if (REG_P (tmp))
        dest_regno = REGNO (tmp);
       else
        goto end_call_group;
@@ -1127,7 +1131,13 @@ sched_analyze_insn (struct deps *deps, rtx x, rtx insn, rtx loop_notes)
       tmp = SET_SRC (set);
       if (GET_CODE (tmp) == SUBREG)
        tmp = SUBREG_REG (tmp);
-      if (GET_CODE (tmp) == REG)
+      if ((GET_CODE (tmp) == PLUS
+          || GET_CODE (tmp) == MINUS)
+         && REG_P (XEXP (tmp, 0))
+         && REGNO (XEXP (tmp, 0)) == STACK_POINTER_REGNUM
+         && dest_regno == STACK_POINTER_REGNUM)
+       src_regno = STACK_POINTER_REGNUM;
+      else if (REG_P (tmp))
        src_regno = REGNO (tmp);
       else
        goto end_call_group;
@@ -1135,13 +1145,21 @@ sched_analyze_insn (struct deps *deps, rtx x, rtx insn, rtx loop_notes)
       if (src_regno < FIRST_PSEUDO_REGISTER
          || dest_regno < FIRST_PSEUDO_REGISTER)
        {
-         set_sched_group_p (insn);
+         /* If we are inside a post-call group right at the start of the
+            scheduling region, we must not add a dependency.  */
+         if (deps->in_post_call_group_p == post_call_initial)
+           {
+             SCHED_GROUP_P (insn) = 1;
+             deps->in_post_call_group_p = post_call;
+           }
+         else
+           set_sched_group_p (insn);
          CANT_MOVE (insn) = 1;
        }
       else
        {
        end_call_group:
-         deps->in_post_call_group_p = false;
+         deps->in_post_call_group_p = not_post_call;
        }
     }
 }
@@ -1156,8 +1174,17 @@ sched_analyze (struct deps *deps, rtx head, rtx tail)
   rtx loop_notes = 0;
 
   if (current_sched_info->use_cselib)
-    cselib_init ();
+    cselib_init (true);
 
+  /* Before reload, if the previous block ended in a call, show that
+     we are inside a post-call group, so as to keep the lifetimes of
+     hard registers correct.  */
+  if (! reload_completed && GET_CODE (head) != CODE_LABEL)
+    {
+      insn = prev_nonnote_insn (head);
+      if (insn && GET_CODE (insn) == CALL_INSN)
+       deps->in_post_call_group_p = post_call_initial;
+    }
   for (insn = head;; insn = NEXT_INSN (insn))
     {
       rtx link, end_seq, r0, set;
@@ -1249,7 +1276,7 @@ sched_analyze (struct deps *deps, rtx head, rtx tail)
          /* Before reload, begin a post-call group, so as to keep the
             lifetimes of hard registers correct.  */
          if (! reload_completed)
-           deps->in_post_call_group_p = true;
+           deps->in_post_call_group_p = post_call;
        }
 
       /* See comments on reemit_notes as to why we do this.
@@ -1299,8 +1326,8 @@ sched_analyze (struct deps *deps, rtx head, rtx tail)
          /* The sequence must start with a clobber of a register.  */
          && GET_CODE (insn) == INSN
          && GET_CODE (PATTERN (insn)) == CLOBBER
-          && (r0 = XEXP (PATTERN (insn), 0), GET_CODE (r0) == REG)
-         && GET_CODE (XEXP (PATTERN (insn), 0)) == REG
+          && (r0 = XEXP (PATTERN (insn), 0), REG_P (r0))
+         && REG_P (XEXP (PATTERN (insn), 0))
          /* The CLOBBER must also have a REG_LIBCALL note attached.  */
          && (link = find_reg_note (insn, REG_LIBCALL, NULL_RTX)) != 0
          && (end_seq = XEXP (link, 0)) != 0
@@ -1410,7 +1437,7 @@ init_deps (struct deps *deps)
   deps->last_pending_memory_flush = 0;
   deps->last_function_call = 0;
   deps->sched_before_next_call = 0;
-  deps->in_post_call_group_p = false;
+  deps->in_post_call_group_p = not_post_call;
   deps->libcall_block_tail_insn = 0;
 }