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]
Other format: [Raw text]

Profiling code for sh-linux-gnu


Last year, I've implemented FUNCTION_PROFILER for sh-linux-gnu
(together with GNU C library's part), which is not yet included.

It has been tested for 3.0.4 for a while and works fine.

Here's updated version (change tab to \t) against
3_4-basic-improvements-branch.  Please include this.

2002-11-26  NIIBE Yutaka  <gniibe@m17n.org>

	* config/sh/linux.h (FUNCTION_PROFILER): Implemented.

Index: gcc/config/sh/linux.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/config/sh/linux.h,v
retrieving revision 1.9.8.2
diff -c -3 -p -r1.9.8.2 linux.h
*** gcc/config/sh/linux.h	19 Nov 2002 14:44:59 -0000	1.9.8.2
--- gcc/config/sh/linux.h	26 Nov 2002 08:37:47 -0000
*************** do { \
*** 88,93 ****
--- 88,123 ----
  			 %{!profile:crt1.o%s}}}} \
     crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
  
+ /* Output assembler code to STREAM to call the profiler.  */
+ 
+ #undef FUNCTION_PROFILER
+ #define FUNCTION_PROFILER(STREAM,LABELNO)				\
+   do {									\
+     if (flag_pic)							\
+       {									\
+ 	fprintf (STREAM, "\tmov.l\t3f,r1\n");				\
+ 	fprintf (STREAM, "\tmova\t3f,r0\n");				\
+ 	fprintf (STREAM, "\tadd\tr1,r0\n");				\
+ 	fprintf (STREAM, "\tmov.l\t1f,r1\n");				\
+ 	fprintf (STREAM, "\tmov.l\t@(r0,r1),r1\n");			\
+       }									\
+     else								\
+       fprintf (STREAM, "\tmov.l\t1f,r1\n");				\
+     fprintf (STREAM, "\tsts.l\tpr,@-r15\n");				\
+     fprintf (STREAM, "\tmova\t2f,r0\n");				\
+     fprintf (STREAM, "\tjmp\t@r1\n");					\
+     fprintf (STREAM, "\tlds\tr0,pr\n");					\
+     fprintf (STREAM, "\t.align\t2\n");					\
+     if (flag_pic)							\
+       {									\
+ 	fprintf (STREAM, "1:\t.long\tmcount@GOT\n");			\
+ 	fprintf (STREAM, "3:\t.long\t_GLOBAL_OFFSET_TABLE_\n");		\
+       }									\
+     else								\
+       fprintf (STREAM, "1:\t.long\tmcount\n");				\
+     fprintf (STREAM, "2:\tlds.l\t@r15+,pr\n");				\
+   } while (0)
+ 
  /* Do code reading to identify a signal frame, and set the frame
     state data appropriately.  See unwind-dw2.c for the structs.  */
  
-- 


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