hppa-linux support 8

Alan Modra alan@linuxcare.com.au
Wed Apr 4 05:57:00 GMT 2001


This was a fix for a reload problem that I think no longer exists.  It may
still be worth applying for a small increase in speed due to not calling
gen_rtx_REG unnecessarily, and for the error checking.

	* pa.c (force_mode): New function.
	(emit_move_sequence): Use it instead of generating new rtx_REGs.

Alan Modra
-- 
Linuxcare

diff -urpN -xCVS -x*~ -x.#* gcc-current/gcc/config/pa/pa.c gcc-new/gcc/config/pa/pa.c
--- gcc-current/gcc/config/pa/pa.c	Wed Apr  4 09:46:54 2001
+++ gcc-new/gcc/config/pa/pa.c	Wed Apr  4 10:07:37 2001
@@ -53,6 +53,7 @@ Boston, MA 02111-1307, USA.  */
 static void pa_init_machine_status PARAMS ((struct function *));
 static void pa_mark_machine_status PARAMS ((struct function *));
 static void pa_free_machine_status PARAMS ((struct function *));
+static inline rtx force_mode PARAMS ((enum machine_mode, rtx));
 static void pa_combine_instructions PARAMS ((rtx));
 static int pa_can_combine_p PARAMS ((rtx, rtx, rtx, int, rtx, rtx, rtx));
 static int forward_branch_p PARAMS ((rtx));
@@ -1171,6 +1174,22 @@ hppa_address_cost (X)
   return 4;
 }
 
+/* Ensure mode of ORIG, a REG rtx, is MODE.  Returns either ORIG or a
+   new rtx with the correct mode.  */
+static inline rtx
+force_mode (mode, orig)
+     enum machine_mode mode;
+     rtx orig;
+{
+  if (mode == GET_MODE (orig))
+    return orig;
+
+  if (REGNO (orig) >= FIRST_PSEUDO_REGISTER)
+    abort ();
+
+  return gen_rtx_REG (mode, REGNO (orig));
+}
+
 /* Emit insns to move operands[1] into operands[0].
 
    Return 1 if we have written out everything that needs to be done to
@@ -1251,7 +1270,7 @@ emit_move_sequence (operands, mode, scra
       /* SCRATCH_REG will hold an address and maybe the actual data.  We want
 	 it in WORD_MODE regardless of what mode it was originally given
 	 to us.  */
-      scratch_reg = gen_rtx_REG (word_mode, REGNO (scratch_reg));
+      scratch_reg = force_mode (word_mode, scratch_reg);
 
       /* D might not fit in 14 bits either; for such cases load D into
 	 scratch reg.  */
@@ -1283,7 +1302,7 @@ emit_move_sequence (operands, mode, scra
       /* SCRATCH_REG will hold an address and maybe the actual data.  We want
 	 it in WORD_MODE regardless of what mode it was originally given
 	 to us.  */
-      scratch_reg = gen_rtx_REG (word_mode, REGNO (scratch_reg));
+      scratch_reg = force_mode (word_mode, scratch_reg);
 
       /* D might not fit in 14 bits either; for such cases load D into
 	 scratch reg.  */
@@ -1321,7 +1340,7 @@ emit_move_sequence (operands, mode, scra
       /* SCRATCH_REG will hold an address and maybe the actual data.  We want
 	 it in WORD_MODE regardless of what mode it was originally given
 	 to us.  */
-      scratch_reg = gen_rtx_REG (word_mode, REGNO (scratch_reg));
+      scratch_reg = force_mode (word_mode, scratch_reg);
 
       /* Force the constant into memory and put the address of the
 	 memory location into scratch_reg.  */
@@ -1352,7 +1371,7 @@ emit_move_sequence (operands, mode, scra
 	{
 	  /* We are reloading the address into the scratch register, so we
 	     want to make sure the scratch register is a full register.  */
-	  scratch_reg = gen_rtx_REG (word_mode, REGNO (scratch_reg));
+	  scratch_reg = force_mode (word_mode, scratch_reg);
 
 	  emit_move_insn (scratch_reg, XEXP (XEXP (operand1, 0), 1));	
 	  emit_move_insn (scratch_reg, gen_rtx_fmt_ee (GET_CODE (XEXP (operand1,
@@ -1366,8 +1385,8 @@ emit_move_sequence (operands, mode, scra
 	     we want to load it in the same width as the original MEM,
 	     which must be the same as the width of the ultimate destination,
 	     OPERAND0.  */
-	  scratch_reg = gen_rtx_REG (GET_MODE (operand0), REGNO (scratch_reg));
-	  
+	  scratch_reg = force_mode (GET_MODE (operand0), scratch_reg);
+
 	  emit_move_insn (scratch_reg, gen_rtx_MEM (GET_MODE (operand0),
 						    scratch_reg));
 	}
@@ -1375,7 +1394,8 @@ emit_move_sequence (operands, mode, scra
 	{
 	  /* We want to load the scratch register using the same mode as
 	     the ultimate destination.  */
-	  scratch_reg = gen_rtx_REG (GET_MODE (operand0), REGNO (scratch_reg));
+	  scratch_reg = force_mode (GET_MODE (operand0), scratch_reg);
+
 	  emit_move_insn (scratch_reg, operand1);
 	}
 
@@ -1462,7 +1482,7 @@ emit_move_sequence (operands, mode, scra
 		  /* SCRATCH_REG will hold an address and maybe the actual
 		     data.  We want it in WORD_MODE regardless of what mode it
 		     was originally given to us.  */
-		  scratch_reg = gen_rtx_REG (word_mode, REGNO (scratch_reg));
+		  scratch_reg = force_mode (word_mode, scratch_reg);
 		}
 	      else if (flag_pic)
 		scratch_reg = gen_reg_rtx (Pmode);
@@ -1520,7 +1540,7 @@ emit_move_sequence (operands, mode, scra
 		  /* TEMP will hold an address and maybe the actual
 		     data.  We want it in WORD_MODE regardless of what mode it
 		     was originally given to us.  */
-		  temp = gen_rtx_REG (word_mode, REGNO (temp));
+		  temp = force_mode (word_mode, temp);
 		}
 	      else
 		temp = gen_reg_rtx (Pmode);
@@ -1559,7 +1579,7 @@ emit_move_sequence (operands, mode, scra
 		  /* TEMP will hold an address and maybe the actual
 		     data.  We want it in WORD_MODE regardless of what mode it
 		     was originally given to us.  */
-		  temp = gen_rtx_REG (word_mode, REGNO (temp));
+		  temp = force_mode (word_mode, temp);
 		}
 	      else
 		temp = gen_reg_rtx (mode);




More information about the Gcc-patches mailing list