(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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@64519
138bc75d-0d04-0410-961f-
82ee72b054a4
+2003-03-18 Alan Modra <amodra@bigpond.net.au>
+
+ * 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 <kazu@cs.umass.edu>
* config/h8300/h8300-protos.h: Add a prototype for
#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 \
{"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
/* 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
#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))
/* 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
output_profile_hook (labelno)
int labelno ATTRIBUTE_UNUSED;
{
+ if (TARGET_PROFILE_KERNEL)
+ return;
+
if (DEFAULT_ABI == ABI_AIX)
{
#ifdef NO_PROFILE_COUNTERS
char buf[100];
int save_lr = 8;
- ASM_GENERATE_INTERNAL_LABEL (buf, "LP", labelno);
switch (DEFAULT_ABI)
{
default:
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)
{
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;
}
}