OSDN Git Service

* Makefile.in (web.o): Depend on insn-config.h and $(RECOG_H).
[pf3gnuchains/gcc-fork.git] / gcc / web.c
index 7e15c2c..ff91733 100644 (file)
--- a/gcc/web.c
+++ b/gcc/web.c
@@ -48,6 +48,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "output.h"
 #include "df.h"
 #include "function.h"
+#include "insn-config.h"
+#include "recog.h"
 #include "timevar.h"
 #include "tree-pass.h"
 
@@ -85,6 +87,46 @@ unionfind_union (struct web_entry *first, struct web_entry *second)
   return false;
 }
 
+/* For INSN, union all defs and uses that are linked by match_dup.
+   FUN is the function that does the union.  */
+
+static void
+union_match_dups (rtx insn, struct web_entry *def_entry,
+                 struct web_entry *use_entry,
+                 bool (*fun) (struct web_entry *, struct web_entry *))
+{
+  struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
+  df_ref *use_link = DF_INSN_INFO_USES (insn_info);
+  df_ref *def_link = DF_INSN_INFO_DEFS (insn_info);
+  int i;
+
+  extract_insn (insn);
+
+  for (i = 0; i < recog_data.n_dups; i++)
+    {
+      int op = recog_data.dup_num[i];
+      enum op_type type = recog_data.operand_type[op];
+      df_ref *ref, *dupref;
+      struct web_entry *entry;
+
+      for (dupref = use_link; *dupref; dupref++)
+       if (DF_REF_LOC (*dupref) == recog_data.dup_loc[i])
+         break;
+
+      if (*dupref == NULL
+         || DF_REF_REGNO (*dupref) < FIRST_PSEUDO_REGISTER)
+       continue;
+
+      ref = type == OP_IN ? use_link : def_link;
+      entry = type == OP_IN ? use_entry : def_entry;
+      for (; *ref; ref++)
+       if (DF_REF_LOC (*ref) == recog_data.operand_loc[op])
+         break;
+
+      (*fun) (use_entry + DF_REF_ID (*dupref), entry + DF_REF_ID (*ref));
+    }
+}
+
 /* For each use, all possible defs reaching it must come in the same
    register, union them.
    FUN is the function that does the union.
@@ -101,7 +143,6 @@ union_defs (df_ref use, struct web_entry *def_entry,
 {
   struct df_insn_info *insn_info = DF_REF_INSN_INFO (use);
   struct df_link *link = DF_REF_CHAIN (use);
-  df_ref *use_link;
   df_ref *eq_use_link;
   df_ref *def_link;
   rtx set;
@@ -109,7 +150,6 @@ union_defs (df_ref use, struct web_entry *def_entry,
   if (insn_info)
     {
       rtx insn = insn_info->insn;
-      use_link = DF_INSN_INFO_USES (insn_info);
       eq_use_link = DF_INSN_INFO_EQ_USES (insn_info);
       def_link = DF_INSN_INFO_DEFS (insn_info);
       set = single_set (insn);
@@ -117,26 +157,12 @@ union_defs (df_ref use, struct web_entry *def_entry,
   else
     {
       /* An artificial use.  It links up with nothing.  */
-      use_link = NULL;
       eq_use_link = NULL;
       def_link = NULL;
       set = NULL;
     }
 
-  /* Some instructions may use match_dup for their operands.  In case the
-     operands are dead, we will assign them different pseudos, creating
-     invalid instructions, so union all uses of the same operand for each
-     insn.  */
-
-  if (use_link)
-    while (*use_link)
-      {
-       if (use != *use_link
-           && DF_REF_REAL_REG (use) == DF_REF_REAL_REG (*use_link))
-         (*fun) (use_entry + DF_REF_ID (use),
-                 use_entry + DF_REF_ID (*use_link));
-       use_link++;
-      }
+  /* Union all occurrences of the same register in reg notes.  */
 
   if (eq_use_link)
     while (*eq_use_link)
@@ -329,6 +355,7 @@ web_main (void)
       if (NONDEBUG_INSN_P (insn))
        {
          df_ref *use_rec;
+         union_match_dups (insn, def_entry, use_entry, unionfind_union);
          for (use_rec = DF_INSN_UID_USES (uid); *use_rec; use_rec++)
            {
              df_ref use = *use_rec;