From 034e84c4a5d2e59e6a8313d5beccf8d541698c47 Mon Sep 17 00:00:00 2001 From: Michael Meissner Date: Wed, 26 Nov 1997 21:04:33 +0000 Subject: [PATCH] Fix System V profiling. From-SVN: r16756 --- gcc/ChangeLog | 8 ++++++++ gcc/config/rs6000/rs6000.c | 23 ++++++++++++++--------- gcc/config/rs6000/rs6000.h | 11 ++++++++--- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 608cb73af54..f60b9060a0f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +Wed Nov 26 15:47:30 1997 Michael Meissner + + * rs6000.c (output_function_profiler): Put label address in r0, and + store LR in 4(sp) for System V/eabi. + + * rs6000.h (ASM_OUTPUT_REG_{PUSH,POP}): Keep stack aligned to 16 + byte boundary, and maintain stack backchain. + Wed Nov 26 11:12:26 1997 Jason Merrill * toplev.c (main): Complain about -gdwarfn. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 4af7a75f803..ef627e87b49 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -4436,28 +4436,33 @@ output_function_profiler (file, labelno) if (flag_pic == 1) { fprintf (file, "\tbl _GLOBAL_OFFSET_TABLE_@local-4\n"); + fprintf (file, "\t%s %s,4(%s)\n", + (TARGET_NEW_MNEMONICS) ? "stw" : "st", + reg_names[0], reg_names[1]); fprintf (file, "\tmflr %s\n", reg_names[11]); fprintf (file, "\t%s %s,", (TARGET_NEW_MNEMONICS) ? "lwz" : "l", - reg_names[11]); + reg_names[0]); assemble_name (file, buf); fprintf (file, "@got(%s)\n", reg_names[11]); } #if TARGET_ELF else if (flag_pic > 1 || TARGET_RELOCATABLE) { - fprintf (file, "\tstw %s,4(%s)\n", reg_names[0], reg_names[1]); - fprintf (file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP); - assemble_name (file, buf); - fprintf (file, "X = .-.LCTOC1\n"); - fprintf (file, "\t.long "); - assemble_name (file, buf); - fputs ("\n\t.previous\n", file); + fprintf (file, "\t%s %s,4(%s)\n", + (TARGET_NEW_MNEMONICS) ? "stw" : "st", + reg_names[0], reg_names[1]); rs6000_pic_func_labelno = rs6000_pic_labelno; rs6000_output_load_toc_table (file, 11); fprintf (file, "\t%s %s,", (TARGET_NEW_MNEMONICS) ? "lwz" : "l", reg_names[11]); assemble_name (file, buf); fprintf (file, "X(%s)\n", reg_names[11]); + fprintf (file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP); + assemble_name (file, buf); + fprintf (file, "X = .-.LCTOC1\n"); + fprintf (file, "\t.long "); + assemble_name (file, buf); + fputs ("\n\t.previous\n", file); } #endif else if (TARGET_NEW_MNEMONICS) @@ -4466,7 +4471,7 @@ output_function_profiler (file, labelno) assemble_name (file, buf); fprintf (file, "@ha\n"); fprintf (file, "\tstw %s,4(%s)\n", reg_names[0], reg_names[1]); - fprintf (file, "\taddi %s,%s,", reg_names[11], reg_names[11]); + fprintf (file, "\taddi %s,%s,", reg_names[0], reg_names[11]); assemble_name (file, buf); fputs ("@l\n", file); } diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index 91242a8c35a..3e7b932ffb2 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -2904,12 +2904,17 @@ do { \ #define ASM_OUTPUT_ASCII(FILE, P, N) output_ascii ((FILE), (P), (N)) /* This is how to output code to push a register on the stack. - It need not be very fast code. */ + It need not be very fast code. + + On the rs6000, we must keep the backchain up to date. In order + to simplify things, always allocate 16 bytes for a push (System V + wants to keep stack aligned to a 16 byte boundary). */ #define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \ do { \ extern char *reg_names[]; \ - asm_fprintf (FILE, "\{tstu|stwu} %s,-4(%s)\n", reg_names[REGNO], \ + asm_fprintf (FILE, "\t{stu|stwu} %s,-16(%s)\n\t{st|stw} %s,8(%s)\n", \ + reg_names[1], reg_names[1], reg_names[REGNO], \ reg_names[1]); \ } while (0) @@ -2919,7 +2924,7 @@ do { \ #define ASM_OUTPUT_REG_POP(FILE,REGNO) \ do { \ extern char *reg_names[]; \ - asm_fprintf (FILE, "\t{l|lwz} %s,0(%s)\n\t{ai|addic} %s,%s,4\n", \ + asm_fprintf (FILE, "\t{l|lwz} %s,8(%s)\n\t{ai|addic} %s,%s,16\n", \ reg_names[REGNO], reg_names[1], reg_names[1], \ reg_names[1]); \ } while (0) -- 2.30.2