This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Sparc block profiling fixes (take 2)
- To: "David S. Miller" <davem at redhat dot com>
- Subject: [PATCH] Sparc block profiling fixes (take 2)
- From: Jakub Jelinek <jakub at redhat dot com>
- Date: Mon, 13 Dec 1999 13:31:18 +0100
- Cc: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>, gcc-patches at gcc dot gnu dot org
- References: <199912122025.PAA05718@caip.rutgers.edu> <19991213123413.E822@mff.cuni.cz>
> 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).
Oopsie. Sorry, forgot to include linux64.h and sol2.h diffs into the patch,
without which it does not work on 64bit Linux or Solaris. Here is the complete patch:
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.
* config/sparc/linux64.h (MACHINE_STATE_*): Only provide these
macros on TARGET_ARCH32. sparc.h has macros good enough for sparc64.
* config/sparc/sol2.h (MACHINE_STATE_*): Likewise.
--- 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);
}
}
--- gcc/config/sparc/linux64.h.jj Fri Dec 10 21:56:32 1999
+++ gcc/config/sparc/linux64.h Mon Dec 13 12:07:52 1999
@@ -350,6 +350,7 @@ do { \
/* #define DWARF_OFFSET_SIZE PTR_SIZE */
+#if TARGET_ARCH32
/* Override MACHINE_STATE_{SAVE,RESTORE} because we have special
traps available which can get and set the condition codes
reliably. */
@@ -368,6 +369,7 @@ do { \
"ta 0x21\n\t" \
: /* no outputs */ \
: "r" (ms_flags), "r" (ms_saveret));
+#endif /* sparc32 */
/* A C statement (sans semicolon) to output an element in the table of
global constructors. */
--- gcc/config/sparc/sol2.h.jj Mon Sep 20 12:08:10 1999
+++ gcc/config/sparc/sol2.h Mon Dec 13 12:09:27 1999
@@ -215,6 +215,7 @@ Boston, MA 02111-1307, USA. */
#undef TARGET_DEFAULT
#define TARGET_DEFAULT (MASK_EPILOGUE + MASK_FPU + MASK_V8PLUS)
+#if TARGET_ARCH32
/* Override MACHINE_STATE_{SAVE,RESTORE} because we have special
traps available which can get and set the condition codes
reliably. */
@@ -233,4 +234,4 @@ Boston, MA 02111-1307, USA. */
"ta 0x21\n\t" \
: /* no outputs */ \
: "r" (ms_flags), "r" (ms_saveret));
-
+#endif /* sparc32 */
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)
___________________________________________________________________