This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PIC_OFFSET_TABLE_SAVE_RTX in large stack frame


Here's a fix for a complication I found when compiling glibc.  I suspect
Dave's patch to move this code into pa.md requires something similar.

	* config/pa/pa.c (hppa_expand_prologue): Handle saves of pic
	register into the stack when offset from base is greater than 8k.

Alan Modra
-- 
Linuxcare.  Support for the Revolution.

--- egcs/gcc/config/pa/pa.c	Mon Jan 22 00:28:20 2001
+++ newegcs/gcc/config/pa/pa.c	Thu Jan 25 21:51:50 2001
@@ -3203,8 +3220,33 @@
   if (flag_pic
       && (GET_CODE (PIC_OFFSET_TABLE_SAVE_RTX) != REG
 	  || HARD_REGISTER_P (PIC_OFFSET_TABLE_SAVE_RTX)))
-    emit_move_insn (PIC_OFFSET_TABLE_SAVE_RTX,
-		    gen_rtx_REG (word_mode, PIC_OFFSET_TABLE_REGNUM));
+    {
+      rtx dest = PIC_OFFSET_TABLE_SAVE_RTX;
+
+      if (GET_CODE (dest) == MEM)
+	{
+	  rtx plus = XEXP (dest, 0);
+	  if (GET_CODE (plus) == PLUS)
+	    {
+	      rtx offset = XEXP (plus, 1);
+	      if (GET_CODE (offset) == CONST_INT
+		  && !VAL_14_BITS_P (INTVAL (offset)))
+		{
+		  /* The save into the stack is too far away from the
+		     frame/stack pointer to address it directly.  */
+		  rtx base, high, low;
+
+		  base = XEXP (plus, 0);
+		  high = gen_rtx_PLUS (Pmode, base,
+				       gen_rtx_HIGH (Pmode, offset));
+		  emit_move_insn (tmpreg, high);
+		  low = gen_rtx_LO_SUM (Pmode, tmpreg, offset);
+		  dest = gen_rtx_MEM (word_mode, low);
+		}
+	    }
+	}
+      emit_move_insn (dest, gen_rtx_REG (word_mode, PIC_OFFSET_TABLE_REGNUM));
+    }
 }
 
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]