hard-reg-set.h (losing_caller_save_reg_set): Declare.
authorJeff Law <law@gcc.gnu.org>
Mon, 1 Jan 1996 02:32:57 +0000 (19:32 -0700)
committerJeff Law <law@gcc.gnu.org>
Mon, 1 Jan 1996 02:32:57 +0000 (19:32 -0700)
        * hard-reg-set.h (losing_caller_save_reg_set): Declare.
        * regclass.c (losing_caller_save_reg_set): Define.
        (init_reg_sets_1): Initialize losing_caller_save_reg_set.
        * global.c (find_reg): Avoid caller-saving registers in
        LOSING_CALLER_SAVE_REGS if it's defined.
        * local-alloc.c (find_free_reg): Avoid caller-saving registers
        in losing_caller_save_reg_set.
        (CLASS_LIKELY_SPILLED_P): Delete definition.  Moved into regs.h.
        * regs.h (CLASS_LIKELY_SPILLED_P): Define if not already defined.

From-SVN: r10926

gcc/global.c
gcc/hard-reg-set.h
gcc/local-alloc.c
gcc/regclass.c
gcc/regs.h

index e9941e6d30fe3c1401588905418d12d2f607e766..78da99b99a8e6300a1b684b54d42e111ca6c85ae 100644 (file)
@@ -1085,7 +1085,14 @@ find_reg (allocno, losers, alt_regs_p, accept_call_clobbered, retrying)
          && CALLER_SAVE_PROFITABLE (allocno_n_refs[allocno],
                                     allocno_calls_crossed[allocno]))
        {
-         find_reg (allocno, losers, alt_regs_p, 1, retrying);
+         HARD_REG_SET new_losers;
+         if (! losers)
+           CLEAR_HARD_REG_SET (new_losers);
+         else
+           COPY_HARD_REG_SET (new_losers, losers);
+           
+         IOR_HARD_REG_SET(new_losers, losing_caller_save_reg_set);
+         find_reg (allocno, new_losers, alt_regs_p, 1, retrying);
          if (reg_renumber[allocno_reg[allocno]] >= 0)
            {
              caller_save_needed = 1;
index 084785e0e51b95a8eea0e86d337795ecf5639849..b2bec47012bc22e3d5d5c320b10e3990a6599348 100644 (file)
@@ -211,6 +211,9 @@ extern char call_used_regs[FIRST_PSEUDO_REGISTER];
 
 extern HARD_REG_SET call_used_reg_set;
   
+/* Registers that we don't want to caller save.  */
+extern HARD_REG_SET losing_caller_save_reg_set;
+
 /* Indexed by hard register number, contains 1 for registers that are
    fixed use -- i.e. in fixed_regs -- or a function value return register
    or STRUCT_VALUE_REGNUM or STATIC_CHAIN_REGNUM.  These are the
index 9d941fef162c006bf9185b5213753abf18106b86..20bcc1cc4b5c5244f25e031139c89d67dc917f25 100644 (file)
@@ -55,6 +55,10 @@ Boston, MA 02111-1307, USA.  */
    But this is currently disabled since tying in global_alloc is not
    yet implemented.  */
 
+/* Pseudos allocated here cannot be reallocated by global.c if the hard
+   register is used as a spill register.  So we don't allocate such pseudos
+   here if their preferred class is likely to be used by spills.  */
+
 #include <stdio.h>
 #include "config.h"
 #include "rtl.h"
@@ -66,17 +70,6 @@ Boston, MA 02111-1307, USA.  */
 #include "recog.h"
 #include "output.h"
 \f
-/* Pseudos allocated here cannot be reallocated by global.c if the hard
-   register is used as a spill register.  So we don't allocate such pseudos
-   here if their preferred class is likely to be used by spills.
-
-   On most machines, the appropriate test is if the class has one
-   register, so we default to that.  */
-
-#ifndef CLASS_LIKELY_SPILLED_P
-#define CLASS_LIKELY_SPILLED_P(CLASS) (reg_class_size[(int) (CLASS)] == 1)
-#endif
-
 /* Next quantity number available for allocation.  */
 
 static int next_qty;
@@ -2106,6 +2099,9 @@ find_free_reg (class, mode, qty, accept_call_clobbered, just_try_suggested,
   else
     COPY_HARD_REG_SET (used, call_used_reg_set);
 
+  if (accept_call_clobbered)
+    IOR_HARD_REG_SET(used, losing_caller_save_reg_set);
+
   for (ins = born_index; ins < dead_index; ins++)
     IOR_HARD_REG_SET (used, regs_live_at[ins]);
 
index 964cd59b68ee2f4a6253497f66b3883dadb3d50e..3147ba55fb39da568956795c28ae495cff30423f 100644 (file)
@@ -81,6 +81,9 @@ char call_used_regs[FIRST_PSEUDO_REGISTER];
 
 HARD_REG_SET call_used_reg_set;
 
+/* HARD_REG_SET of registers we want to avoid caller saving.  */
+HARD_REG_SET losing_caller_save_reg_set;
+
 /* Data for initializing the above.  */
 
 static char initial_call_used_regs[] = CALL_USED_REGISTERS;
@@ -390,6 +393,8 @@ init_reg_sets_1 ()
        SET_HARD_REG_BIT (call_used_reg_set, i);
       if (call_fixed_regs[i])
        SET_HARD_REG_BIT (call_fixed_reg_set, i);
+      if (CLASS_LIKELY_SPILLED_P (REGNO_REG_CLASS (i)))
+       SET_HARD_REG_BIT (losing_caller_save_reg_set, i);
     }
 }
 
index 17293d684970d6ed72258123802afcd42f6cd8bf..c26528d05742c4158cdefb4f01f040b6dd4cf612 100644 (file)
@@ -176,6 +176,12 @@ extern int caller_save_needed;
 #define CALLER_SAVE_PROFITABLE(REFS, CALLS)  (4 * (CALLS) < (REFS))
 #endif
 
+/* On most machines a register class is likely to be spilled if it
+   only has one register.  */
+#ifndef CLASS_LIKELY_SPILLED_P
+#define CLASS_LIKELY_SPILLED_P(CLASS) (reg_class_size[(int) (CLASS)] == 1)
+#endif
+
 /* Allocated in local_alloc.  */
 
 /* A list of SCRATCH rtl allocated by local-alloc.  */