From a330e73b144e71ac85ba571f643a1bbc19794d08 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 14 Dec 1999 13:47:01 +0100 Subject: [PATCH] sparc.h (SPARC_DEFAULT_CMODEL): Default to CM_32. * 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. From-SVN: r30916 --- gcc/ChangeLog | 13 +++++++++++++ gcc/config/sparc/linux64.h | 2 ++ gcc/config/sparc/sol2.h | 3 ++- gcc/config/sparc/sparc.c | 33 ++++++++++++++++++++------------- gcc/config/sparc/sparc.h | 14 +++++++------- 5 files changed, 44 insertions(+), 21 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a4423d0cf18..00190364344 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -26,6 +26,19 @@ Tue Dec 14 12:07:29 MET 1999 Jan Hubicka * config/sparc/linux-aout.h (TARGET_LIVE_G0, TARGET_BROKEN_SAVERESTORE): Likewise. + * 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. + 1999-12-14 Bernd Schmidt * combine.c (combine_simplify_rtx): Don't make shared rtl. diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h index e5b88d22708..1c6e62ab53a 100644 --- a/gcc/config/sparc/linux64.h +++ b/gcc/config/sparc/linux64.h @@ -356,6 +356,7 @@ do { \ #undef TARGET_BROKEN_SAVERESTORE #define TARGET_BROKEN_SAVERESTORE 0 +#if TARGET_ARCH32 /* Override MACHINE_STATE_{SAVE,RESTORE} because we have special traps available which can get and set the condition codes reliably. */ @@ -374,6 +375,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. */ diff --git a/gcc/config/sparc/sol2.h b/gcc/config/sparc/sol2.h index 72028fde2e7..0aecee2e198 100644 --- a/gcc/config/sparc/sol2.h +++ b/gcc/config/sparc/sol2.h @@ -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 */ diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 9c5380d574a..2877844b8ec 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -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); } } diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h index c949c3eea2d..ad8db75c7d8 100644 --- a/gcc/config/sparc/sparc.h +++ b/gcc/config/sparc/sparc.h @@ -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) @@ -1985,7 +1985,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)); @@ -2066,9 +2066,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