toplev.c (no_new_pseudos): Define.
authorJeff Law <law@gcc.gnu.org>
Wed, 25 Nov 1998 10:31:24 +0000 (03:31 -0700)
committerJeff Law <law@gcc.gnu.org>
Wed, 25 Nov 1998 10:31:24 +0000 (03:31 -0700)
        * toplev.c (no_new_pseudos): Define.
        (rest_of_compilation):  Set no_new_pseudos as needed.
        * emit-rtl.c (gen_reg_rtx): Abort if we try to create a new pseudo
        if no_new_pseudos is set.
        * rtl.h (no_new_pseudos): Declare it.
        * reload1.c (reload): Update comments.
        * md.texi: Corresponding changes.
        * reload1.c (reg_used_in_insn): Renamed from reg_used_by_pseudo.
        (choose_reload_regs): Rename it here as well.  When computing it,
        also merge in used hardregs.

From-SVN: r23855

gcc/ChangeLog
gcc/emit-rtl.c
gcc/md.texi
gcc/reload1.c
gcc/rtl.h
gcc/toplev.c

index b5dbe8005a6c4fcfde6722745175439ab36303c6..fdf4b63c26eaa6e79d2b2714536a113e8348ce14 100644 (file)
@@ -1,3 +1,19 @@
+Wed Nov 25 11:26:19 1998  Jeffrey A Law  (law@cygnus.com)
+
+       * toplev.c (no_new_pseudos): Define.
+       (rest_of_compilation):  Set no_new_pseudos as needed.
+       * emit-rtl.c (gen_reg_rtx): Abort if we try to create a new pseudo
+       if no_new_pseudos is set.
+       * rtl.h (no_new_pseudos): Declare it.
+       * reload1.c (reload): Update comments.
+       * md.texi: Corresponding changes.
+
+Wed Nov 25 11:26:17 1998  Bernd Schmidt  <crux@pool.informatik.rwth-aachen.de>
+
+       * reload1.c (reg_used_in_insn): Renamed from reg_used_by_pseudo.
+       (choose_reload_regs): Rename it here as well.  When computing it,
+       also merge in used hardregs.
+
 1998-11-25 07:51 -0500  Zack Weinberg  <zack@rabi.phys.columbia.edu>
 
        * gcc.c: Split out Objective-C specs to...
index a8bbfe42318fb97fb1cf14a6f215645ef2c71d24..9a19de121da26a43498f7d4d66c3d3c9e98fe3c3 100644 (file)
@@ -505,11 +505,9 @@ gen_reg_rtx (mode)
 {
   register rtx val;
 
-  /* Don't let anything called by or after reload create new registers
-     (actually, registers can't be created after flow, but this is a good
-     approximation).  */
-
-  if (reload_in_progress || reload_completed)
+  /* Don't let anything called after initial flow analysis create new
+     registers.  */
+  if (no_new_pseudos)
     abort ();
 
   if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT
index f3f6cd6a3aae50d65bbfef8171858993f1aa3da7..6177ac2b55c7183e3eacb8297eaa56c3e4842646 100644 (file)
@@ -1746,14 +1746,20 @@ pseudo registers that did not get hard registers, while on other
 machines explicit memory references will get optional reloads.
 
 If a scratch register is required to move an object to or from memory,
-it can be allocated using @code{gen_reg_rtx} prior to reload.  But this
-is impossible during and after reload.  If there are cases needing
+it can be allocated using @code{gen_reg_rtx} prior to life analysis.
+
+If there are cases needing
 scratch registers after reload, you must define
 @code{SECONDARY_INPUT_RELOAD_CLASS} and perhaps also
 @code{SECONDARY_OUTPUT_RELOAD_CLASS} to detect them, and provide
 patterns @samp{reload_in@var{m}} or @samp{reload_out@var{m}} to handle
 them.  @xref{Register Classes}.
 
+@findex no_new_pseudos
+The global variable @code{no_new_pseudos} can be used to determine if it
+is unsafe to create new pseudo registers.  If this variable is nonzero, then
+it is unsafe to call @code{gen_reg_rtx} to allocate a new pseudo.
+
 The constraints on a @samp{mov@var{m}} must permit moving any hard
 register to any other hard register provided that
 @code{HARD_REGNO_MODE_OK} permits mode @var{m} in both registers and
index fb7e5cf5a828f38ee1837f33f3c0cec1b881c438..e4dee18247f7d3265dcb5a72ce1ce85a159f410a 100644 (file)
@@ -815,7 +815,9 @@ reload (first, global, dumpfile)
 #endif
   finish_spills (global, dumpfile);
 
-  /* From now on, we need to emit any moves without making new pseudos.  */
+  /* From now on, we may need to generate moves differently.  We may also
+     allow modifications of insns which cause them to not be recognized.
+     Any such modifications will be cleaned up during reload itself.  */
   reload_in_progress = 1;
 
   /* This loop scans the entire function each go-round
@@ -4487,9 +4489,9 @@ static HARD_REG_SET reload_reg_used_at_all;
    in the group.  */
 static HARD_REG_SET reload_reg_used_for_inherit;
 
-/* Records which hard regs are allocated to a pseudo during any point of the
-   current insn.  */
-static HARD_REG_SET reg_used_by_pseudo;
+/* Records which hard regs are used in any way, either as explicit use or
+   by being allocated to a pseudo during any point of the current insn.  */
+static HARD_REG_SET reg_used_in_insn;
 
 /* Mark reg REGNO as in use for a reload of the sort spec'd by OPNUM and
    TYPE. MODE is used to indicate how many consecutive regs are
@@ -5522,10 +5524,16 @@ choose_reload_regs (chain)
   CLEAR_HARD_REG_SET (reload_reg_used_in_insn);
   CLEAR_HARD_REG_SET (reload_reg_used_in_other_addr);
 
-  CLEAR_HARD_REG_SET (reg_used_by_pseudo);
-  compute_use_by_pseudos (&reg_used_by_pseudo, chain->live_before);
-  compute_use_by_pseudos (&reg_used_by_pseudo, chain->live_after);
-  
+  CLEAR_HARD_REG_SET (reg_used_in_insn);
+  {
+    HARD_REG_SET tmp;
+    REG_SET_TO_HARD_REG_SET (tmp, chain->live_before);
+    IOR_HARD_REG_SET (reg_used_in_insn, tmp);
+    REG_SET_TO_HARD_REG_SET (tmp, chain->live_after);
+    IOR_HARD_REG_SET (reg_used_in_insn, tmp);
+    compute_use_by_pseudos (&reg_used_in_insn, chain->live_before);
+    compute_use_by_pseudos (&reg_used_in_insn, chain->live_after);
+  }
   for (i = 0; i < reload_n_operands; i++)
     {
       CLEAR_HARD_REG_SET (reload_reg_used_in_output[i]);
@@ -5838,7 +5846,7 @@ choose_reload_regs (chain)
                                    (i, reload_opnum[r], reload_when_needed[r],
                                     reload_in[r], reload_out[r], r, 1))
                              /* Don't use it if we'd clobber a pseudo reg.  */
-                             || (TEST_HARD_REG_BIT (reg_used_by_pseudo, i)
+                             || (TEST_HARD_REG_BIT (reg_used_in_insn, i)
                                  && reload_out[r]
                                  && ! TEST_HARD_REG_BIT (reg_reloaded_dead, i))
                              /* Don't really use the inherited spill reg
index 6c47f2f9a1ccf6b61ab8c05e1e438d4715672320..c5b816d79dd517f9963ab9ae23f9b1b1aa5ed944 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -1222,6 +1222,10 @@ extern int reload_in_progress;
    the same indirect address eventually.  */
 extern int cse_not_expected;
 
+/* Set to nonzero before life analysis to indicate that it is unsafe to
+   generate any new pseudo registers.  */
+extern int no_new_pseudos;
+
 /* Indexed by pseudo register number, gives the rtx for that pseudo.
    Allocated in parallel with regno_pointer_flag.  */
 extern rtx *regno_reg_rtx;
index da28bda18623e8339c7f1d5c61f7aa091a506db5..5fa7f22df6eec61561caeb052976e047d85d095a 100644 (file)
@@ -242,6 +242,9 @@ char *main_input_filename;
 
 int lineno;
 
+/* Nonzero if it is unsafe to create any new pseudo registers.  */
+int no_new_pseudos;
+
 /* Stack of currently pending input files.  */
 
 struct file_stack *input_file_stack;
@@ -3862,6 +3865,10 @@ rest_of_compilation (decl)
        print_rtl_graph_with_bb (dump_base_name, ".flow", insns);
     }
 
+  /* The first life analysis pass has finished.  From now on we can not
+     generate any new pseudos.  */
+  no_new_pseudos = 1;
+
   /* If -opt, try combining insns through substitution.  */
 
   if (optimize > 0)
@@ -4170,6 +4177,7 @@ rest_of_compilation (decl)
 
   reload_completed = 0;
   flow2_completed = 0;
+  no_new_pseudos = 0;
 
   TIMEVAR (final_time,
           {