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]

[PATCH]: Fix ashlsi3/ashrsi3/lshrsi3 patterns for HC12 and -fomit-frame-pointer


Hi!

The ashlsi3/ashrsi3/lshrsi3 patterns have an alternative that
require pushing temporarily register Y before calling the
library routine.  For HC12, if the frame is eliminated, a
memory reference can use the stack pointer and due to the
temporary push, the memory address becomes wrong.  The patch
fixes that by adjusting it (+2).  The patch uses `adjust_address'
on 3_1 and `adj_offsetable_operand' on 3_0.

I've committed this on 3_1 and 3_0.

	Stephane

2001-07-05  Stephane Carrez  <Stephane.Carrez@worldnet.fr>

	* m68hc11.md ("*ashlsi3"): Operand 1 can be a memory reference
	using the stack pointer, adjust it since we push Y temporarily.
	("*ashrsi3"): Likewise.
	("*lshrsi3"): Likewise.
Index: config/m68hc11/m68hc11.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/m68hc11/m68hc11.md,v
retrieving revision 1.12
diff -u -p -r1.12 m68hc11.md
--- m68hc11.md	2001/06/11 22:11:02	1.12
+++ m68hc11.md	2001/07/05 20:58:37
@@ -4190,8 +4190,15 @@
      is true for 68hc11 only, we save temporary the value of Y.  */
   if (!Y_REG_P (operands[2]))
     {
+      rtx ops[1];
+
+      ops[0] = operands[1];
       output_asm_insn (\"pshy\", operands);
-      output_asm_insn (\"ldy\\t%1\", operands);
+      if (reg_mentioned_p (stack_pointer_rtx, operands[1]))
+	{
+	  ops[0] = adjust_address (operands[1], GET_MODE (operands[1]), 2);
+	}
+      output_asm_insn (\"ldy\\t%0\", ops);
       output_asm_insn (\"bsr\\t___ashlsi3\", operands);
       return \"puly\";
     }
@@ -4591,8 +4598,15 @@
      is true for 68hc11 only, we save temporary the value of Y.  */
   if (!Y_REG_P (operands[2]))
     {
+      rtx ops[1];
+
+      ops[0] = operands[1];
       output_asm_insn (\"pshy\", operands);
-      output_asm_insn (\"ldy\\t%1\", operands);
+      if (reg_mentioned_p (stack_pointer_rtx, operands[1]))
+	{
+	  ops[0] = adjust_address (operands[1], GET_MODE (operands[1]), 2);
+	}
+      output_asm_insn (\"ldy\\t%0\", ops);
       output_asm_insn (\"bsr\\t___ashrsi3\", operands);
       return \"puly\";
     }
@@ -4928,8 +4942,15 @@
      is true for 68hc11 only, we save temporary the value of Y.  */
   if (!Y_REG_P (operands[2]))
     {
+      rtx ops[1];
+
+      ops[0] = operands[1];
       output_asm_insn (\"pshy\", operands);
-      output_asm_insn (\"ldy\\t%1\", operands);
+      if (reg_mentioned_p (stack_pointer_rtx, operands[1]))
+	{
+	  ops[0] = adjust_address (operands[1], GET_MODE (operands[1]), 2);
+	}
+      output_asm_insn (\"ldy\\t%0\", ops);
       output_asm_insn (\"bsr\\t___lshrsi3\", operands);
       return \"puly\";
     }
Index: config/m68hc11/m68hc11.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/m68hc11/m68hc11.md,v
retrieving revision 1.3.4.11
diff -u -p -r1.3.4.11 m68hc11.md
--- m68hc11.md	2001/06/11 22:04:55	1.3.4.11
+++ m68hc11.md	2001/07/05 21:21:02
@@ -4190,8 +4190,15 @@
      is true for 68hc11 only, we save temporary the value of Y.  */
   if (!Y_REG_P (operands[2]))
     {
+      rtx ops[1];
+
+      ops[0] = operands[1];
       output_asm_insn (\"pshy\", operands);
-      output_asm_insn (\"ldy\\t%1\", operands);
+      if (reg_mentioned_p (stack_pointer_rtx, operands[1]))
+	{
+	  ops[0] = adj_offsettable_operand (operands[1], 2);
+	}
+      output_asm_insn (\"ldy\\t%0\", ops);
       output_asm_insn (\"bsr\\t___ashlsi3\", operands);
       return \"puly\";
     }
@@ -4591,8 +4598,15 @@
      is true for 68hc11 only, we save temporary the value of Y.  */
   if (!Y_REG_P (operands[2]))
     {
+      rtx ops[1];
+
+      ops[0] = operands[1];
       output_asm_insn (\"pshy\", operands);
-      output_asm_insn (\"ldy\\t%1\", operands);
+      if (reg_mentioned_p (stack_pointer_rtx, operands[1]))
+	{
+	  ops[0] = adj_offsettable_operand (operands[1], 2);
+	}
+      output_asm_insn (\"ldy\\t%0\", ops);
       output_asm_insn (\"bsr\\t___ashrsi3\", operands);
       return \"puly\";
     }
@@ -4928,8 +4942,15 @@
      is true for 68hc11 only, we save temporary the value of Y.  */
   if (!Y_REG_P (operands[2]))
     {
+      rtx ops[1];
+
+      ops[0] = operands[1];
       output_asm_insn (\"pshy\", operands);
-      output_asm_insn (\"ldy\\t%1\", operands);
+      if (reg_mentioned_p (stack_pointer_rtx, operands[1]))
+	{
+	  ops[0] = adj_offsettable_operand (operands[1], 2);
+	}
+      output_asm_insn (\"ldy\\t%0\", ops);
       output_asm_insn (\"bsr\\t___lshrsi3\", operands);
       return \"puly\";
     }

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