Preliminary regrename patch for i386 ROP patch
authorBernd Schmidt <bernds@redhat.com>
Tue, 17 Nov 2015 21:32:14 +0000 (21:32 +0000)
committerBernd Schmidt <bernds@gcc.gnu.org>
Tue, 17 Nov 2015 21:32:14 +0000 (21:32 +0000)
* regrename.c (regrename_find_superclass): New function, code moved
from ...
(rename_chains): ... here.  Call it.
* regrename.h (regrename_find_superclass): Declare.

From-SVN: r230501

gcc/ChangeLog
gcc/regrename.c
gcc/regrename.h

index 4037505e4548dacc88ade05f1fac7f6292b0f9df..869685077c8b544fe9c1e80eeb82fc894f598bde 100644 (file)
@@ -1,5 +1,10 @@
 2015-11-17  Bernd Schmidt  <bschmidt@redhat.com>
 
+       * regrename.c (regrename_find_superclass): New function, code moved
+       from ...
+       (rename_chains): ... here.  Call it.
+       * regrename.h (regrename_find_superclass): Declare.
+
        * regrename.c (record_out_operands): Terminate earlyclobbered
        operands here.
 
index 4d6eb372ddd9834748ee8ded81cb60269a4db11c..1f11695c5db83fab74e46bcf59b7f08e614d6e08 100644 (file)
@@ -422,6 +422,33 @@ find_rename_reg (du_head_p this_head, enum reg_class super_class,
   return best_new_reg;
 }
 
+/* Iterate over elements in the chain HEAD in order to:
+   1. Count number of uses, storing it in *PN_USES.
+   2. Narrow the set of registers we can use for renaming, adding
+      unavailable registers to *PUNAVAILABLE, which must be
+      initialized by the caller.
+   3. Compute the superunion of register classes in this chain
+      and return it.  */
+reg_class
+regrename_find_superclass (du_head_p head, int *pn_uses,
+                          HARD_REG_SET *punavailable)
+{
+  int n_uses = 0;
+  reg_class super_class = NO_REGS;
+  for (du_chain *tmp = head->first; tmp; tmp = tmp->next_use)
+    {
+      if (DEBUG_INSN_P (tmp->insn))
+       continue;
+      n_uses++;
+      IOR_COMPL_HARD_REG_SET (*punavailable,
+                             reg_class_contents[tmp->cl]);
+      super_class
+       = reg_class_superunion[(int) super_class][(int) tmp->cl];
+    }
+  *pn_uses = n_uses;
+  return super_class;
+}
+
 /* Perform register renaming on the current function.  */
 static void
 rename_chains (void)
@@ -445,10 +472,8 @@ rename_chains (void)
     {
       int best_new_reg;
       int n_uses;
-      struct du_chain *tmp;
       HARD_REG_SET this_unavailable;
       int reg = this_head->regno;
-      enum reg_class super_class = NO_REGS;
 
       if (this_head->cannot_rename)
        continue;
@@ -462,23 +487,8 @@ rename_chains (void)
 
       COPY_HARD_REG_SET (this_unavailable, unavailable);
 
-      /* Iterate over elements in the chain in order to:
-        1. Count number of uses, and narrow the set of registers we can
-           use for renaming.
-        2. Compute the superunion of register classes in this chain.  */
-      n_uses = 0;
-      super_class = NO_REGS;
-      for (tmp = this_head->first; tmp; tmp = tmp->next_use)
-       {
-         if (DEBUG_INSN_P (tmp->insn))
-           continue;
-         n_uses++;
-         IOR_COMPL_HARD_REG_SET (this_unavailable,
-                                 reg_class_contents[tmp->cl]);
-         super_class
-           = reg_class_superunion[(int) super_class][(int) tmp->cl];
-       }
-
+      reg_class super_class = regrename_find_superclass (this_head, &n_uses,
+                                                        &this_unavailable);
       if (n_uses < 2)
        continue;
 
index 801e0d25278bbfb4e3fe96e92fbf1b38f8a4684d..c702835cfe2277071b264621d5ab3e80b0f902cf 100644 (file)
@@ -97,5 +97,7 @@ extern du_head_p regrename_chain_from_id (unsigned int);
 extern int find_rename_reg (du_head_p, enum reg_class, HARD_REG_SET *, int,
                            bool);
 extern bool regrename_do_replace (du_head_p, int);
+extern reg_class regrename_find_superclass (du_head_p, int *,
+                                           HARD_REG_SET *);
 
 #endif