This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: patch for support profiling for AIX 4.3 (fwd)





On Mon, 5 Feb 2001, Richard Henderson wrote:

> On Mon, Feb 05, 2001 at 04:56:40PM -0800, Chandra Chavva wrote:
> >   Here is the patch with this change which i am going to checkin.
> 
> Uh, no, this new patch is exactly the same as before.
> 
  Here is the patch. Bye mistake i sent the old patch.


Thanks
Chandra

        * 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.

Index: final.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/final.c,v
retrieving revision 1.155
diff -p -r1.155 final.c
*** final.c	2001/01/28 01:50:06	1.155
--- final.c	2001/02/06 00:27:26
*************** char regs_ever_live[FIRST_PSEUDO_REGISTE
*** 205,214 ****
  
  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;
--- 205,210 ----
cvs server: I know nothing about output.c
Index: function.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/function.c,v
retrieving revision 1.248
diff -p -r1.248 function.c
*** function.c	2001/01/20 13:40:23	1.248
--- function.c	2001/02/06 00:27:26
*************** expand_function_start (subr, parms_have_
*** 6471,6476 ****
--- 6471,6481 ----
  			 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.  */
Index: tm.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tm.texi,v
retrieving revision 1.168
diff -p -r1.168 tm.texi
*** tm.texi	2001/01/30 05:42:06	1.168
--- tm.texi	2001/02/06 00:27:27
*************** variable to be loaded into some register
*** 3677,3682 ****
--- 3677,3688 ----
  @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
Index: config/rs6000/rs6000.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.163
diff -p -r1.163 rs6000.c
*** rs6000.c	2001/02/05 19:42:13	1.163
--- rs6000.c	2001/02/06 00:27:27
*************** rs6000_gen_section_name (buf, filename, 
*** 7080,7085 ****
--- 7080,7111 ----
      *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
*************** output_function_profiler (file, labelno)
*** 7148,7207 ****
        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);
! 
        break;
      }
  }
  
--- 7174,7182 ----
        break;
  
      case ABI_AIX:
!       /* Don't do anything, done in output_profile_hook (). */
        break;
+ 
      }
  }
  
Index: config/rs6000/aix.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/rs6000/aix.h,v
retrieving revision 1.13
diff -p -r1.13 aix.h
*** aix.h	2001/01/25 20:12:30	1.13
--- aix.h	2001/02/06 00:27:27
*************** toc_section ()						\
*** 635,637 ****
--- 635,638 ----
     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)
Index: config/rs6000/rs6000-protos.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/rs6000/rs6000-protos.h,v
retrieving revision 1.14
diff -p -r1.14 rs6000-protos.h
*** rs6000-protos.h	2001/01/24 00:07:32	1.14
--- rs6000-protos.h	2001/02/06 00:27:27
*************** extern void output_ascii PARAMS ((FILE *
*** 157,162 ****
--- 157,163 ----
  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));


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]