reload.c (reload_adjust_reg_for_mode): New function.
authorAlexandre Oliva <aoliva@redhat.com>
Tue, 4 Mar 2003 05:54:39 +0000 (05:54 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Tue, 4 Mar 2003 05:54:39 +0000 (05:54 +0000)
* reload.c (reload_adjust_reg_for_mode): New function.
(subst_reloads): Call it.
(operands_match_p): Adjust registers using HARD_REGNO_NREGS.
* reload.h (reload_adjust_reg_for_mode): Declare.
* reload1.c (emit_input_reload_insns, emit_output_reload_insns):
Call it.

From-SVN: r63766

gcc/ChangeLog
gcc/reload.c
gcc/reload.h
gcc/reload1.c

index 2dc5507dce0232dfbc3f585c405ef1db3b44aa14..fe99d98e98672a42a3979b434fb822616444c5a6 100644 (file)
@@ -1,3 +1,12 @@
+2003-03-04  Alexandre Oliva  <aoliva@redhat.com>
+
+       * reload.c (reload_adjust_reg_for_mode): New function.
+       (subst_reloads): Call it.
+       (operands_match_p): Adjust registers using HARD_REGNO_NREGS.
+       * reload.h (reload_adjust_reg_for_mode): Declare.
+       * reload1.c (emit_input_reload_insns, emit_output_reload_insns):
+       Call it.
+
 2003-03-03  James E Wilson  <wilson@tuliptree.org>
 
        * optabs.c (add_equal_note): Delete SUBREG_REG use.
index a2642aa7349973d080ff19a37fa9f5329de1cd52..de1b1a93e2506087e061b60bc98efe95301da285 100644 (file)
@@ -2137,10 +2137,10 @@ operands_match_p (x, y)
         (reg:SI 1) will be considered the same register.  */
       if (WORDS_BIG_ENDIAN && GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD
          && i < FIRST_PSEUDO_REGISTER)
-       i += (GET_MODE_SIZE (GET_MODE (x)) / UNITS_PER_WORD) - 1;
+       i += HARD_REGNO_NREGS (i, GET_MODE (x)) - 1;
       if (WORDS_BIG_ENDIAN && GET_MODE_SIZE (GET_MODE (y)) > UNITS_PER_WORD
          && j < FIRST_PSEUDO_REGISTER)
-       j += (GET_MODE_SIZE (GET_MODE (y)) / UNITS_PER_WORD) - 1;
+       j += HARD_REGNO_NREGS (j, GET_MODE (y)) - 1;
 
       return i == j;
     }
@@ -5954,7 +5954,7 @@ subst_reloads (insn)
             do the wrong thing if RELOADREG is multi-word.  RELOADREG
             will always be a REG here.  */
          if (GET_MODE (reloadreg) != r->mode && r->mode != VOIDmode)
-           reloadreg = gen_rtx_REG (r->mode, REGNO (reloadreg));
+           reloadreg = reload_adjust_reg_for_mode (reloadreg, r->mode);
 
          /* If we are putting this into a SUBREG and RELOADREG is a
             SUBREG, we would be making nested SUBREGs, so we have to fix
@@ -6934,6 +6934,26 @@ regno_clobbered_p (regno, insn, mode, sets)
   return 0;
 }
 
+/* Find the low part, with mode MODE, of a hard regno RELOADREG.  */
+rtx
+reload_adjust_reg_for_mode (reloadreg, mode)
+     rtx reloadreg;
+     enum machine_mode mode;
+{
+  int regno;
+
+  if (GET_MODE (reloadreg) == mode)
+    return reloadreg;
+
+  regno = REGNO (reloadreg);
+
+  if (WORDS_BIG_ENDIAN)
+    regno += HARD_REGNO_NREGS (regno, GET_MODE (reloadreg))
+      - HARD_REGNO_NREGS (regno, mode);
+
+  return gen_rtx_REG (mode, regno);
+}
+
 static const char *const reload_when_needed_name[] =
 {
   "RELOAD_FOR_INPUT",
index adc2984c0b36850766c3ac0fee70fe3932b173b5..7fc4f49da40b4d9aca3fd697242f1e741ec038d1 100644 (file)
@@ -1,6 +1,6 @@
 /* Communication between reload.c and reload1.c.
    Copyright (C) 1987, 1991, 1992, 1993, 1994, 1995, 1997, 1998,
-   1999, 2000, 2001 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2003 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -385,3 +385,7 @@ extern void cleanup_subreg_operands PARAMS ((rtx));
 /* Debugging support.  */
 extern void debug_reload_to_stream PARAMS ((FILE *));
 extern void debug_reload PARAMS ((void));
+
+/* Compute the actual register we should reload to, in case we're
+   reloading to/from a register that is wider than a word.  */
+extern rtx reload_adjust_reg_for_mode PARAMS ((rtx, enum machine_mode));
index 5a0886b40cdc1042da5f52fd9a6ee3479c304ff6..e4549478d38a872c8acedbf761dd6e50671de8cd 100644 (file)
@@ -6319,7 +6319,7 @@ emit_input_reload_insns (chain, rl, old, j)
      must always be a REG here.  */
 
   if (GET_MODE (reloadreg) != mode)
-    reloadreg = gen_rtx_REG (mode, REGNO (reloadreg));
+    reloadreg = reload_adjust_reg_for_mode (reloadreg, mode);
   while (GET_CODE (oldequiv) == SUBREG && GET_MODE (oldequiv) != mode)
     oldequiv = SUBREG_REG (oldequiv);
   if (GET_MODE (oldequiv) != VOIDmode
@@ -6568,8 +6568,8 @@ emit_input_reload_insns (chain, rl, old, j)
                        oldequiv = old, real_oldequiv = real_old;
                      else
                        second_reload_reg
-                         = gen_rtx_REG (new_mode,
-                                        REGNO (second_reload_reg));
+                         = reload_adjust_reg_for_mode (second_reload_reg,
+                                                       new_mode);
                    }
                }
            }
@@ -6691,7 +6691,7 @@ emit_output_reload_insns (chain, rl, j)
     }
 
   if (GET_MODE (reloadreg) != mode)
-    reloadreg = gen_rtx_REG (mode, REGNO (reloadreg));
+    reloadreg = reload_adjust_reg_for_mode (reloadreg, mode);
 
 #ifdef SECONDARY_OUTPUT_RELOAD_CLASS
 
@@ -6732,7 +6732,7 @@ emit_output_reload_insns (chain, rl, j)
                = rld[secondary_reload].secondary_out_icode;
 
              if (GET_MODE (reloadreg) != mode)
-               reloadreg = gen_rtx_REG (mode, REGNO (reloadreg));
+               reloadreg = reload_adjust_reg_for_mode (reloadreg, mode);
 
              if (tertiary_icode != CODE_FOR_nothing)
                {