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]
Other format: [Raw text]

[patch] h8300.c: Use r7/er7 instead of sp.


Hi,

Attached is a patch to make the h8 port use r7/er7 instead of sp in
code generation.

The reason for the change is that sp will not be used when we switch
from TARGET_ASM_FUNCTION_PROLOGUE/EPILOGUE to the RTL-based
prologue/epilogue.  By switching to r7/er7, the comparison of the
TARGET_ASM_FUNCTION_PROLOGUE/EPILOGUE-based code and the RTL-based
code will be easier.

Tested on h8300 port.  Committed.

Kazu Hirata

2002-12-02  Kazu Hirata  <kazu@cs.umass.edu>

	* config/h8300/h8300.c (dosize): Output r7/er7 instead of sp.
	(push): Likewise.
	(pop): Likewise.
	(h8300_output_function_prologue): Likewise.
	(h8300_output_function_epilogue): Likewise.

Index: h8300.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.c,v
retrieving revision 1.168
diff -u -p -r1.168 h8300.c
--- h8300.c	2 Dec 2002 02:02:43 -0000	1.168
+++ h8300.c	2 Dec 2002 16:50:17 -0000
@@ -418,16 +418,20 @@ dosize (file, op, size)
 	   amount > 0;
 	   amount /= 2)
 	{
+	  char insn[100];
+
+	  sprintf (insn, "\t%ss\t#%d,%s\n", op, amount,
+		   TARGET_H8300 ? "r7" : "er7");
 	  for (; size >= amount; size -= amount)
-	    fprintf (file, "\t%ss\t#%d,sp\n", op, amount);
+	    fputs (insn, file);
 	}
     }
   else
     {
       if (TARGET_H8300)
-	fprintf (file, "\tmov.w\t#%d,r3\n\t%s.w\tr3,sp\n", size, op);
+	fprintf (file, "\tmov.w\t#%d,r3\n\t%s.w\tr3,r7\n", size, op);
       else
-	fprintf (file, "\t%s.l\t#%d,sp\n", op, size);
+	fprintf (file, "\t%s.l\t#%d,er7\n", op, size);
     }
 }
 
@@ -471,7 +475,10 @@ push (file, rn)
      FILE *file;
      int rn;
 {
-  fprintf (file, "\t%s\t%s\n", h8_push_op, h8_reg_names[rn]);
+  if (TARGET_H8300)
+    fprintf (file, "\t%s\t%s,@-r7\n", h8_mov_op, h8_reg_names[rn]);
+  else
+    fprintf (file, "\t%s\t%s,@-er7\n", h8_mov_op, h8_reg_names[rn]);
 }
 
 /* Output assembly language code to pop register RN.  */
@@ -481,7 +488,10 @@ pop (file, rn)
      FILE *file;
      int rn;
 {
-  fprintf (file, "\t%s\t%s\n", h8_pop_op, h8_reg_names[rn]);
+  if (TARGET_H8300)
+    fprintf (file, "\t%s\t@r7+,%s\n", h8_mov_op, h8_reg_names[rn]);
+  else
+    fprintf (file, "\t%s\t@er7+,%s\n", h8_mov_op, h8_reg_names[rn]);
 }
 
 /* This is what the stack looks like after the prolog of
@@ -604,7 +614,7 @@ h8300_output_function_prologue (file, si
 	  if (n_regs == 1)
 	    push (file, regno);
 	  else
-	    fprintf (file, "\tstm.l\t%s-%s,@-sp\n",
+	    fprintf (file, "\tstm.l\t%s-%s,@-er7\n",
 		     h8_reg_names[regno],
 		     h8_reg_names[regno + (n_regs - 1)]);
 	}
@@ -670,7 +680,7 @@ h8300_output_function_epilogue (file, si
 	  if (n_regs == 1)
 	    pop (file, regno);
 	  else
-	    fprintf (file, "\tldm.l\t@sp+,%s-%s\n",
+	    fprintf (file, "\tldm.l\t@er7+,%s-%s\n",
 		     h8_reg_names[regno - (n_regs - 1)],
 		     h8_reg_names[regno]);
 	}


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