diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5556e8385cd..6f9b17b0772 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2001-02-05 Chandrakala Chavva + + * final.c: Move the declaration profile_label_no to ... + * output.h: ... here. + * function.c (expand_function_start): Call PROFILE_HOOK. + * config/rs6000/aix.h: Define PROFILE_HOOK. + * config/rs6000/rs6000-protos.h: output_profile_hook new. + * config/rs6000/rs6000.c (output_profile_hook): Define. + (output_prolog): Do nothing for ABI_AIX as it is taken care by + output_profile_hook. + tm.texi : Explain new macro PROFILE_HOOK. + 2001-02-06 Hans-Peter Nilsson * extend.texi (Extended Asm): Do not say that semicolon is always diff --git a/gcc/config/rs6000/aix.h b/gcc/config/rs6000/aix.h index ae11b7187dc..3cead72e776 100644 --- a/gcc/config/rs6000/aix.h +++ b/gcc/config/rs6000/aix.h @@ -635,3 +635,4 @@ toc_section () \ So we have to squirrel it away with this. */ #define SETUP_FRAME_ADDRESSES() rs6000_aix_emit_builtin_unwind_init () +#define PROFILE_HOOK(LABEL) output_profile_hook (LABEL) diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h index 3f55fca7b17..846321a36ad 100644 --- a/gcc/config/rs6000/rs6000-protos.h +++ b/gcc/config/rs6000/rs6000-protos.h @@ -157,6 +157,7 @@ extern void output_ascii PARAMS ((FILE *, const char *, int)); extern void rs6000_gen_section_name PARAMS ((char **, const char *, const char *)); extern void output_function_profiler PARAMS ((FILE *, int)); +extern void output_profile_hook PARAMS ((int)); extern int rs6000_trampoline_size PARAMS ((void)); extern void toc_section PARAMS ((void)); extern void sdata_section PARAMS ((void)); diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index a3aba7ce935..9d8060bea2d 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -7080,6 +7080,32 @@ rs6000_gen_section_name (buf, filename, section_desc) *p = '\0'; } + +/* Emit profile function. */ +void +output_profile_hook (labelno) + int labelno; +{ + + if (profile_flag && DEFAULT_ABI == ABI_AIX) + { + char *buf; + int length = 0; + rtx fun; + + labelno += 1; + buf = permalloc (labelno+6); + + ASM_GENERATE_INTERNAL_LABEL (buf, "LP", labelno); + + fun = gen_rtx_SYMBOL_REF (Pmode, buf+1); + + emit_library_call (init_one_libfunc (RS6000_MCOUNT), 0, VOIDmode, 1, + fun, Pmode, Pmode); + + } +} + /* Write function profiler code. */ void @@ -7148,60 +7174,9 @@ output_function_profiler (file, labelno) break; case ABI_AIX: - /* Set up a TOC entry for the profiler label. */ - toc_section (); - ASM_OUTPUT_INTERNAL_LABEL (file, "LPC", labelno); - if (TARGET_MINIMAL_TOC) - { - fputs (TARGET_32BIT ? "\t.long " : "\t.llong ", file); - assemble_name (file, buf); - putc ('\n', file); - } - else - { - fputs ("\t.tc\t", file); - assemble_name (file, buf); - fputs ("[TC],", file); - assemble_name (file, buf); - putc ('\n', file); - } - text_section (); - - /* Figure out last used parameter register. The proper thing to do is - to walk incoming args of the function. A function might have live - parameter registers even if it has no incoming args. */ - - for (last_parm_reg = 10; - last_parm_reg > 2 && ! regs_ever_live [last_parm_reg]; - last_parm_reg--) - ; - - /* Save parameter registers in regs 23-30 and static chain in r22. - Don't overwrite reg 31, since it might be set up as the frame pointer. */ - - for (i = 3, j = 30; i <= last_parm_reg; i++, j--) - asm_fprintf (file, "\tmr %d,%d\n", j, i); - if (current_function_needs_context) - asm_fprintf (file, "\tmr %d,%d\n", j, STATIC_CHAIN_REGNUM); - - /* Load location address into r3, and call mcount. */ - - ASM_GENERATE_INTERNAL_LABEL (buf, "LPC", labelno); - asm_fprintf (file, TARGET_32BIT ? "\t{l|lwz} %s," : "\tld %s,", - reg_names[3]); - assemble_name (file, buf); - asm_fprintf (file, "(%s)\n\tbl %s\n\t", reg_names[2], RS6000_MCOUNT); - asm_fprintf (file, RS6000_CALL_GLUE); - putc('\n', file); - - /* Restore parameter registers and static chain. */ - - for (i = 3, j = 30; i <= last_parm_reg; i++, j--) - asm_fprintf (file, "\tmr %d,%d\n", i, j); - if (current_function_needs_context) - asm_fprintf (file, "\tmr %d,%d\n", STATIC_CHAIN_REGNUM, j); - + /* Don't do anything, done in output_profile_hook (). */ break; + } } diff --git a/gcc/final.c b/gcc/final.c index 3a2fc1537c5..18f3e90fe8b 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -205,10 +205,6 @@ char regs_ever_live[FIRST_PSEUDO_REGISTER]; int frame_pointer_needed; -/* Assign unique numbers to labels generated for profiling. */ - -int profile_label_no; - /* Number of unmatched NOTE_INSN_BLOCK_BEG notes we have seen. */ static int block_depth; diff --git a/gcc/function.c b/gcc/function.c index e6d56f01ba1..5421450c4a8 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -6471,6 +6471,11 @@ expand_function_start (subr, parms_have_cleanups) Pmode); } +#ifdef PROFILE_HOOK + if (profile_flag) + PROFILE_HOOK (profile_label_no); +#endif + /* After the display initializations is where the tail-recursion label should go, if we end up needing one. Ensure we have a NOTE here since some things (like trampolines) get placed before this. */ diff --git a/gcc/output.h b/gcc/output.h index ae0034f91ed..0cdb719174f 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -457,3 +457,6 @@ extern const char *user_label_prefix; #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \ (VAR) = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*')) #endif +/* Assign unique numbers to labels generated for profiling. */ + +int profile_label_no; diff --git a/gcc/tm.texi b/gcc/tm.texi index c67512b09c5..252c5c03099 100644 --- a/gcc/tm.texi +++ b/gcc/tm.texi @@ -3677,6 +3677,12 @@ variable to be loaded into some register. The name of this variable is @samp{LP} followed by the number @var{labelno}, so you would generate the name using @samp{LP%d} in a @code{fprintf}. +@findex PROFILE_HOOK +@item PROFILE_HOOK +A C statement or compound statement to output to @var{file} some assembly +code to call the profiling subroutine @code{mcount} even the target does +not support profiling. + @findex NO_PROFILE_COUNTERS @item NO_PROFILE_COUNTERS Define this macro if the @code{mcount} subroutine on your system does