From ffcfcb5fd9058825f8a4be55adbd70c0841b0d22 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 18 Mar 2003 02:28:46 +0000 Subject: [PATCH] linux64.h (MASK_PROFILE_KERNEL): Define. * config/rs6000/linux64.h (MASK_PROFILE_KERNEL): Define. (TARGET_PROFILE_KERNEL): Define. (SUBTARGET_SWITCHES): Handle -mprofile-kernel. (PROFILE_BEFORE_PROLOGUE): Don't define. (PROFILE_KERNEL): Remove hacks. * config/rs6000/rs6000.c (TARGET_PROFILE_KERNEL): Define default. (rs6000_stack_info): No need to save lr if just for profiling when TARGET_KERNEL_PROFILE. (output_profile_hook): Output nothing when TARGET_KERNEL_PROFILE. (output_function_profiler): Localize label generation. Emit code for kernel profiling. From-SVN: r64519 --- gcc/ChangeLog | 14 ++++++++++++++ gcc/config/rs6000/linux64.h | 27 ++++++++++++++------------- gcc/config/rs6000/rs6000.c | 36 +++++++++++++++++++++++++++++++++--- 3 files changed, 61 insertions(+), 16 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f54a273..eaf0994 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2003-03-18 Alan Modra + + * config/rs6000/linux64.h (MASK_PROFILE_KERNEL): Define. + (TARGET_PROFILE_KERNEL): Define. + (SUBTARGET_SWITCHES): Handle -mprofile-kernel. + (PROFILE_BEFORE_PROLOGUE): Don't define. + (PROFILE_KERNEL): Remove hacks. + * config/rs6000/rs6000.c (TARGET_PROFILE_KERNEL): Define default. + (rs6000_stack_info): No need to save lr if just for profiling when + TARGET_KERNEL_PROFILE. + (output_profile_hook): Output nothing when TARGET_KERNEL_PROFILE. + (output_function_profiler): Localize label generation. Emit code + for kernel profiling. + 2003-03-17 Kazu Hirata * config/h8300/h8300-protos.h: Add a prototype for diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h index 14fa6ff..be03b3b 100644 --- a/gcc/config/rs6000/linux64.h +++ b/gcc/config/rs6000/linux64.h @@ -63,6 +63,15 @@ Boston, MA 02111-1307, USA. */ #undef TARGET_PROTOTYPE #define TARGET_PROTOTYPE 0 +/* Reuse sysv4 mask bits we made available above. */ +#define MASK_PROFILE_KERNEL 0x08000000 + +/* Non-standard profiling for kernels, which just saves LR then calls + _mcount without worrying about arg saves. The idea is to change + the function prologue as little as possible as it isn't easy to + account for arg save/restore code added just for _mcount. */ +#define TARGET_PROFILE_KERNEL (target_flags & MASK_PROFILE_KERNEL) + /* Override sysv4.h. */ #undef SUBTARGET_SWITCHES #define SUBTARGET_SWITCHES \ @@ -89,7 +98,11 @@ Boston, MA 02111-1307, USA. */ {"regnames", MASK_REGNAMES, \ N_("Use alternate register names") }, \ {"no-regnames", -MASK_REGNAMES, \ - N_("Don't use alternate register names") }, + N_("Don't use alternate register names") }, \ + {"profile-kernel", MASK_PROFILE_KERNEL, \ + N_("Call mcount for profiling before a function prologue") }, \ + {"no-profile-kernel", -MASK_PROFILE_KERNEL, \ + N_("Call mcount for profiling after a function prologue") }, #undef SUBTARGET_OPTIONS #define SUBTARGET_OPTIONS @@ -99,19 +112,7 @@ Boston, MA 02111-1307, USA. */ /* We use glibc _mcount for profiling. */ #define NO_PROFILE_COUNTERS 1 -#undef PROFILE_BEFORE_PROLOGUE - -/* Define this for kernel profiling, which just saves LR then calls - _mcount without worrying about arg saves. The idea is to change - the function prologue as little as possible as it isn't easy to - account for arg save/restore code added just for _mcount. */ -/* #define PROFILE_KERNEL 1 */ -#if PROFILE_KERNEL -#define PROFILE_BEFORE_PROLOGUE 1 -#undef PROFILE_HOOK -#else #define PROFILE_HOOK(LABEL) output_profile_hook (LABEL) -#endif /* We don't need to generate entries in .fixup. */ #undef RELOCATABLE_NEEDS_FIXUP diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 85730fc..4b7fefd 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -335,6 +335,9 @@ static const char alt_reg_names[][8] = #ifndef MASK_STRICT_ALIGN #define MASK_STRICT_ALIGN 0 #endif +#ifndef TARGET_PROFILE_KERNEL +#define TARGET_PROFILE_KERNEL 0 +#endif /* The VRSAVE bitmask puts bit %v0 as the most significant bit. */ #define ALTIVEC_REG_BIT(REGNO) (0x80000000 >> ((REGNO) - FIRST_ALTIVEC_REGNO)) @@ -9225,7 +9228,9 @@ rs6000_stack_info () /* Determine if we need to save the link register. */ if (rs6000_ra_ever_killed () - || (DEFAULT_ABI == ABI_AIX && current_function_profile) + || (DEFAULT_ABI == ABI_AIX + && current_function_profile + && !TARGET_PROFILE_KERNEL) #ifdef TARGET_RELOCATABLE || (TARGET_RELOCATABLE && (get_pool_size () != 0)) #endif @@ -12234,6 +12239,9 @@ void output_profile_hook (labelno) int labelno ATTRIBUTE_UNUSED; { + if (TARGET_PROFILE_KERNEL) + return; + if (DEFAULT_ABI == ABI_AIX) { #ifdef NO_PROFILE_COUNTERS @@ -12285,7 +12293,6 @@ output_function_profiler (file, labelno) char buf[100]; int save_lr = 8; - ASM_GENERATE_INTERNAL_LABEL (buf, "LP", labelno); switch (DEFAULT_ABI) { default: @@ -12301,6 +12308,7 @@ output_function_profiler (file, labelno) warning ("no profiling of 64-bit code for this ABI"); return; } + ASM_GENERATE_INTERNAL_LABEL (buf, "LP", labelno); fprintf (file, "\tmflr %s\n", reg_names[0]); if (flag_pic == 1) { @@ -12355,7 +12363,29 @@ output_function_profiler (file, labelno) case ABI_AIX: case ABI_DARWIN: - /* Don't do anything, done in output_profile_hook (). */ + if (!TARGET_PROFILE_KERNEL) + { + /* Don't do anything, done in output_profile_hook (). */ + } + else + { + if (TARGET_32BIT) + abort (); + + asm_fprintf (file, "\tmflr %s\n", reg_names[0]); + asm_fprintf (file, "\tstd %s,16(%s)\n", reg_names[0], reg_names[1]); + + if (current_function_needs_context) + { + asm_fprintf (file, "\tstd %s,24(%s)\n", + reg_names[STATIC_CHAIN_REGNUM], reg_names[1]); + fprintf (file, "\tbl %s\n", RS6000_MCOUNT); + asm_fprintf (file, "\tld %s,24(%s)\n", + reg_names[STATIC_CHAIN_REGNUM], reg_names[1]); + } + else + fprintf (file, "\tbl %s\n", RS6000_MCOUNT); + } break; } } -- 2.7.4