OSDN Git Service

* intrinsic.texi (STAT): Fixed a format typo in sample code.
[pf3gnuchains/gcc-fork.git] / gcc / sched-deps.c
index 0597d30..0cde4f2 100644 (file)
@@ -112,8 +112,6 @@ static void adjust_add_sorted_back_dep (rtx, rtx, rtx *);
 static void adjust_back_add_forw_dep (rtx, rtx *);
 static void delete_forw_dep (rtx, rtx);
 static dw_t estimate_dep_weak (rtx, rtx);
-static dw_t get_dep_weak (ds_t, ds_t);
-static ds_t ds_merge (ds_t, ds_t);
 #ifdef INSN_SCHEDULING
 #ifdef ENABLE_CHECKING
 static void check_dep_status (enum reg_note, ds_t, bool);
@@ -229,7 +227,7 @@ sched_insns_conditions_mutex_p (rtx insn1, rtx insn2)
 \f
 /* Add ELEM wrapped in an INSN_LIST with reg note kind DEP_TYPE to the
    LOG_LINKS of INSN, if it is not already there.  DEP_TYPE indicates the
-   type of dependence that this link represents.  DS, if non-zero,
+   type of dependence that this link represents.  DS, if nonzero,
    indicates speculations, through which this dependence can be overcome.
    MEM1 and MEM2, if non-null, corresponds to memory locations in case of
    data speculation.  The function returns a value indicating if an old entry
@@ -717,6 +715,78 @@ flush_pending_lists (struct deps *deps, rtx insn, int for_read,
   deps->pending_flush_length = 1;
 }
 \f
+/* Analyze a single reference to register (reg:MODE REGNO) in INSN.
+   The type of the reference is specified by REF and can be SET,
+   CLOBBER, PRE_DEC, POST_DEC, PRE_INC, POST_INC or USE.  */
+
+static void
+sched_analyze_reg (struct deps *deps, int regno, enum machine_mode mode,
+                  enum rtx_code ref, rtx insn)
+{
+  /* A hard reg in a wide mode may really be multiple registers.
+     If so, mark all of them just like the first.  */
+  if (regno < FIRST_PSEUDO_REGISTER)
+    {
+      int i = hard_regno_nregs[regno][mode];
+      if (ref == SET)
+       {
+         while (--i >= 0)
+           SET_REGNO_REG_SET (reg_pending_sets, regno + i);
+       }
+      else if (ref == USE)
+       {
+         while (--i >= 0)
+           SET_REGNO_REG_SET (reg_pending_uses, regno + i);
+       }
+      else
+       {
+         while (--i >= 0)
+           SET_REGNO_REG_SET (reg_pending_clobbers, regno + i);
+       }
+    }
+
+  /* ??? Reload sometimes emits USEs and CLOBBERs of pseudos that
+     it does not reload.  Ignore these as they have served their
+     purpose already.  */
+  else if (regno >= deps->max_reg)
+    {
+      enum rtx_code code = GET_CODE (PATTERN (insn));
+      gcc_assert (code == USE || code == CLOBBER);
+    }
+
+  else
+    {
+      if (ref == SET)
+       SET_REGNO_REG_SET (reg_pending_sets, regno);
+      else if (ref == USE)
+       SET_REGNO_REG_SET (reg_pending_uses, regno);
+      else
+       SET_REGNO_REG_SET (reg_pending_clobbers, regno);
+
+      /* 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 && 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.  */
+      if (REG_N_CALLS_CROSSED (regno) == 0)
+       {
+         if (ref == USE)
+           deps->sched_before_next_call
+             = alloc_INSN_LIST (insn, deps->sched_before_next_call);
+         else
+           add_dependence_list (insn, deps->last_function_call, 1,
+                                REG_DEP_ANTI);
+       }
+    }
+}
+
 /* Analyze a single SET, CLOBBER, PRE_DEC, POST_DEC, PRE_INC or POST_INC
    rtx, X, creating all dependencies generated by the write to the
    destination of X, and reads of everything mentioned.  */
@@ -724,7 +794,6 @@ flush_pending_lists (struct deps *deps, rtx insn, int for_read,
 static void
 sched_analyze_1 (struct deps *deps, rtx x, rtx insn)
 {
-  int regno;
   rtx dest = XEXP (x, 0);
   enum rtx_code code = GET_CODE (x);
 
@@ -773,64 +842,21 @@ sched_analyze_1 (struct deps *deps, rtx x, rtx insn)
 
   if (REG_P (dest))
     {
-      regno = REGNO (dest);
+      int regno = REGNO (dest);
+      enum machine_mode mode = GET_MODE (dest);
+
+      sched_analyze_reg (deps, regno, mode, code, insn);
 
 #ifdef STACK_REGS
       /* Treat all writes to a stack register as modifying the TOS.  */
       if (regno >= FIRST_STACK_REG && regno <= LAST_STACK_REG)
        {
-         SET_REGNO_REG_SET (reg_pending_uses, FIRST_STACK_REG);
-         regno = FIRST_STACK_REG;
+         /* Avoid analyzing the same register twice.  */
+         if (regno != FIRST_STACK_REG)
+           sched_analyze_reg (deps, FIRST_STACK_REG, mode, code, insn);
+         sched_analyze_reg (deps, FIRST_STACK_REG, mode, USE, insn);
        }
 #endif
-
-      /* A hard reg in a wide mode may really be multiple registers.
-         If so, mark all of them just like the first.  */
-      if (regno < FIRST_PSEUDO_REGISTER)
-       {
-         int i = hard_regno_nregs[regno][GET_MODE (dest)];
-         if (code == SET)
-           {
-             while (--i >= 0)
-               SET_REGNO_REG_SET (reg_pending_sets, regno + i);
-           }
-         else
-           {
-             while (--i >= 0)
-               SET_REGNO_REG_SET (reg_pending_clobbers, regno + i);
-           }
-       }
-      /* ??? Reload sometimes emits USEs and CLOBBERs of pseudos that
-        it does not reload.  Ignore these as they have served their
-        purpose already.  */
-      else if (regno >= deps->max_reg)
-       {
-         gcc_assert (GET_CODE (PATTERN (insn)) == USE
-                     || GET_CODE (PATTERN (insn)) == CLOBBER);
-       }
-      else
-       {
-         if (code == SET)
-           SET_REGNO_REG_SET (reg_pending_sets, regno);
-         else
-           SET_REGNO_REG_SET (reg_pending_clobbers, regno);
-
-         /* 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 && 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.  */
-         if (REG_N_CALLS_CROSSED (regno) == 0)
-           add_dependence_list (insn, deps->last_function_call, 1,
-                                REG_DEP_ANTI);
-       }
     }
   else if (MEM_P (dest))
     {
@@ -937,51 +963,20 @@ sched_analyze_2 (struct deps *deps, rtx x, rtx insn)
     case REG:
       {
        int regno = REGNO (x);
+       enum machine_mode mode = GET_MODE (x);
+
+       sched_analyze_reg (deps, regno, mode, USE, insn);
 
 #ifdef STACK_REGS
       /* Treat all reads of a stack register as modifying the TOS.  */
       if (regno >= FIRST_STACK_REG && regno <= LAST_STACK_REG)
        {
-         SET_REGNO_REG_SET (reg_pending_sets, FIRST_STACK_REG);
-         regno = FIRST_STACK_REG;
+         /* Avoid analyzing the same register twice.  */
+         if (regno != FIRST_STACK_REG)
+           sched_analyze_reg (deps, FIRST_STACK_REG, mode, USE, insn);
+         sched_analyze_reg (deps, FIRST_STACK_REG, mode, SET, insn);
        }
 #endif
-
-       if (regno < FIRST_PSEUDO_REGISTER)
-         {
-           int i = hard_regno_nregs[regno][GET_MODE (x)];
-           while (--i >= 0)
-             SET_REGNO_REG_SET (reg_pending_uses, regno + i);
-         }
-       /* ??? Reload sometimes emits USEs and CLOBBERs of pseudos that
-          it does not reload.  Ignore these as they have served their
-          purpose already.  */
-       else if (regno >= deps->max_reg)
-         {
-           gcc_assert (GET_CODE (PATTERN (insn)) == USE
-                       || GET_CODE (PATTERN (insn)) == CLOBBER);
-         }
-       else
-         {
-           SET_REGNO_REG_SET (reg_pending_uses, regno);
-
-           /* 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 && 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
-              not cross calls after scheduling.  */
-           if (REG_N_CALLS_CROSSED (regno) == 0)
-             deps->sched_before_next_call
-               = alloc_INSN_LIST (insn, deps->sched_before_next_call);
-         }
        return;
       }
 
@@ -1777,19 +1772,35 @@ init_dependency_caches (int luid)
      what we consider "very high".  */
   if (luid / n_basic_blocks > 100 * 5)
     {
-      int i;
+      cache_size = 0;
+      extend_dependency_caches (luid, true);
+    }
+}
 
-      true_dependency_cache = XNEWVEC (bitmap_head, luid);
-      anti_dependency_cache = XNEWVEC (bitmap_head, luid);
-      output_dependency_cache = XNEWVEC (bitmap_head, luid);
+/* Create or extend (depending on CREATE_P) dependency caches to
+   size N.  */
+void
+extend_dependency_caches (int n, bool create_p)
+{
+  if (create_p || true_dependency_cache)
+    {
+      int i, luid = cache_size + n;
+
+      true_dependency_cache = XRESIZEVEC (bitmap_head, true_dependency_cache,
+                                         luid);
+      output_dependency_cache = XRESIZEVEC (bitmap_head,
+                                           output_dependency_cache, luid);
+      anti_dependency_cache = XRESIZEVEC (bitmap_head, anti_dependency_cache,
+                                         luid);
 #ifdef ENABLE_CHECKING
-      forward_dependency_cache = XNEWVEC (bitmap_head, luid);
+      forward_dependency_cache = XRESIZEVEC (bitmap_head,
+                                            forward_dependency_cache, luid);
 #endif
       if (current_sched_info->flags & DO_SPECULATION)
         spec_dependency_cache = XRESIZEVEC (bitmap_head, spec_dependency_cache,
                                            luid);
 
-      for (i = 0; i < luid; i++)
+      for (i = cache_size; i < luid; i++)
        {
          bitmap_initialize (&true_dependency_cache[i], 0);
          bitmap_initialize (&output_dependency_cache[i], 0);
@@ -2037,7 +2048,7 @@ delete_back_forw_dep (rtx insn, rtx elem)
 }
 
 /* Return weakness of speculative type TYPE in the dep_status DS.  */
-static dw_t
+dw_t
 get_dep_weak (ds_t ds, ds_t type)
 {
   ds = ds & type;
@@ -2074,7 +2085,7 @@ set_dep_weak (ds_t ds, ds_t type, dw_t dw)
 }
 
 /* Return the join of two dep_statuses DS1 and DS2.  */
-static ds_t
+ds_t
 ds_merge (ds_t ds1, ds_t ds2)
 {
   ds_t ds, t;
@@ -2173,7 +2184,7 @@ check_dep_status (enum reg_note dt, ds_t ds, bool relaxed_p)
          gcc_assert ((ds & DEP_TYPES) == DEP_TRUE);
        }
           
-      /* Check that true and anti depencies can't have other speculative 
+      /* Check that true and anti dependencies can't have other speculative 
         statuses.  */
       if (ds & DEP_TRUE)
        gcc_assert (ds & (BEGIN_DATA | BE_IN_SPEC));