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] Sparc block profiling fixes


On Sun, Dec 12, 1999 at 03:25:06PM -0500, Kaveh R. Ghazi wrote:
> 	Since about Nov 23rd, I haven't been able to bootstrap gcc on
> sparc-sun-solaris2.7 when using cc for stage1 and the native assembler.
> 
> The error occurs in stage1 when building the -m64 multilib libgcc.a.
> Here is the error I get:
...

Hi!

Hope this patch should fix it:

I finally chose %g4 register for sparc64 block profiling (together with
%g1), because that does not clash with static chain register (so we don't
have to save it like sparc32 has to) and block profiling is supported with
the medlow model only, so embmedany model is out of luck anyway.
This patch allows block profiling on 32bit code, which was broken with
BI_ARCH compilers (when passing -a -m32 it complained about block profiling
being supported on medlow only).

1999-12-13  Jakub Jelinek  <jakub@redhat.com>

	* config/sparc/sparc.h (SPARC_DEFAULT_CMODEL): Default to CM_32.
	(CONDITIONAL_REGISTER_USAGE): For block profiling fix %g4 on sparc64,
	not %g2.
	(MACHINE_STATE_SAVE, MACHINE_STATE_RESTORE): Use %g4 instead of %g2
	as sparc64 block profiling register.
	* config/sparc/sparc.c (sparc_override_options): Allow block
	profiling with -m32.
	(sparc_block_profiler): Use %g4 instead of %g2 as sparc64 block
	profiling register.

--- gcc/config/sparc/sparc.h.jj	Mon Dec 13 09:56:14 1999
+++ gcc/config/sparc/sparc.h	Mon Dec 13 12:11:09 1999
@@ -97,7 +97,7 @@ extern enum cmodel sparc_cmodel;
 #define TARGET_CM_MEDANY    (sparc_cmodel == CM_MEDANY)
 #define TARGET_CM_EMBMEDANY (sparc_cmodel == CM_EMBMEDANY)
 
-#define SPARC_DEFAULT_CMODEL CM_MEDLOW
+#define SPARC_DEFAULT_CMODEL CM_32
 
 /* This is call-clobbered in the normal ABI, but is reserved in the
    home grown (aka upward compatible) embedded ABI.  */
@@ -1077,10 +1077,10 @@ do								\
       }								\
     if (profile_block_flag)					\
       {								\
-	/* %g1 and %g2 must be fixed, because BLOCK_PROFILER	\
-	    uses them.  */					\
+	/* %g1 and %g2 (sparc32) resp. %g4 (sparc64) must be	\
+	   fixed, because BLOCK_PROFILER uses them.  */		\
 	fixed_regs[1] = 1;					\
-	fixed_regs[2] = 1;					\
+	fixed_regs[TARGET_ARCH64 ? 4 : 2] = 1;			\
       }								\
   }								\
 while (0)
@@ -1994,7 +1994,7 @@ LFLGNN"ID":"					\
 #define MACHINE_STATE_SAVE(ID)			\
   unsigned long ms_flags, ms_saveret;		\
   asm volatile(					\
-	"mov %%g2,%1\n\				\
+	"mov %%g4,%1\n\				\
 	rd %%ccr,%0"				\
 	: "=r"(ms_flags), "=r"(ms_saveret));
 
@@ -2075,9 +2075,9 @@ LFLGRET"ID":\n\
 #define MACHINE_STATE_RESTORE(ID)				\
   asm volatile (						\
 	"wr %0,0,%%ccr\n\
-	mov %1,%%g2"						\
+	mov %1,%%g4"						\
 	: : "r"(ms_flags), "r"(ms_saveret)			\
-	: "cc", "g2");
+	: "cc", "g4");
 
 #endif
 
--- gcc/config/sparc/sparc.c.jj	Fri Dec 10 22:08:06 1999
+++ gcc/config/sparc/sparc.c	Mon Dec 13 12:05:34 1999
@@ -343,7 +343,7 @@ sparc_override_options ()
   sparc_init_modes ();
 
   if ((profile_flag || profile_block_flag)
-      && sparc_cmodel != CM_MEDLOW)
+      && sparc_cmodel != CM_32 && sparc_cmodel != CM_MEDLOW)
     {
       error ("profiling does not support code models other than medlow");
     }
@@ -8077,32 +8077,33 @@ sparc_block_profiler(file, blockno)
      int blockno;
 {
   char LPBX[32];
+  int bbreg = TARGET_ARCH64 ? 4 : 2;
 
   if (profile_block_flag == 2)
     {
       ASM_GENERATE_INTERNAL_LABEL (LPBX, "LPBX", 0);
 
       fprintf (file, "\tsethi\t%%hi(%s__bb),%%g1\n", user_label_prefix);
-      fprintf (file, "\tsethi\t%%hi(%d),%%g2\n", blockno);
+      fprintf (file, "\tsethi\t%%hi(%d),%%g%d\n", blockno, bbreg);
       fprintf (file, "\tor\t%%g1,%%lo(%s__bb),%%g1\n", user_label_prefix);
-      fprintf (file, "\tor\t%%g2,%%lo(%d),%%g2\n", blockno);
+      fprintf (file, "\tor\t%%g%d,%%lo(%d),%%g%d\n", bbreg, blockno, bbreg);
 
-      fputs ("\tst\t%g2,[%g1]\n", file);
+      fprintf (file, "\tst\t%%g%d,[%%g1]\n", bbreg);
 
       fputs ("\tsethi\t%hi(", file);
       assemble_name (file, LPBX);
-      fputs ("),%g2\n", file);
+      fprintf (file, "),%%g%d\n", bbreg);
   
       fputs ("\tor\t%o2,%lo(", file);
       assemble_name (file, LPBX);
-      fputs ("),%g2\n", file);
+      fprintf (file, "),%%g%d\n", bbreg);
   
-      fputs ("\tst\t%g2,[%g1+4]\n", file);
-      fputs ("\tmov\t%o7,%g2\n", file);
+      fprintf (file, "\tst\t%%g%d,[%%g1+4]\n", bbreg);
+      fprintf (file, "\tmov\t%%o7,%%g%d\n", bbreg);
 
       fprintf (file, "\tcall\t%s__bb_trace_func\n\t nop\n", user_label_prefix);
 
-      fputs ("\tmov\t%g2,%o7\n", file);
+      fprintf (file, "\tmov\t%%g%d,%%o7\n", bbreg);
     }
   else if (profile_block_flag != 0)
     {
@@ -8114,13 +8115,19 @@ sparc_block_profiler(file, blockno)
 
       fputs ("\tld\t[%g1+%lo(", file);
       assemble_name (file, LPBX);
-      fprintf (file, "+%d)],%%g2\n", blockno*4);
+      if (TARGET_ARCH64 && USE_AS_OFFSETABLE_LO10)
+	fprintf (file, ")+%d],%%g%d\n", blockno*4, bbreg);
+      else
+	fprintf (file, "+%d)],%%g%d\n", blockno*4, bbreg);
 
-      fputs ("\tadd\t%g2,1,%g2\n", file);
+      fprintf (file, "\tadd\t%%g%d,1,%%g%d\n", bbreg, bbreg);
 
-      fputs ("\tst\t%g2,[%g1+%lo(", file);
+      fprintf (file, "\tst\t%%g%d,[%%g1+%%lo(", bbreg);
       assemble_name (file, LPBX);
-      fprintf (file, "+%d)]\n", blockno*4);
+      if (TARGET_ARCH64 && USE_AS_OFFSETABLE_LO10)
+	fprintf (file, ")+%d]\n", blockno*4);
+      else
+	fprintf (file, "+%d)]\n", blockno*4);
     }
 }
 

Cheers,
    Jakub
___________________________________________________________________
Jakub Jelinek | jakub@redhat.com | http://sunsite.mff.cuni.cz/~jj
Linux version 2.3.26 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________


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