* i386-protos.h (x86_function_profiler): New function
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 15 Nov 2002 14:57:12 +0000 (14:57 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 15 Nov 2002 14:57:12 +0000 (14:57 +0000)
* i386.h (MCOUNT_NAME): New.
(PROFILE_COUNT_REGISTER): New.
(OUTPUT_FUNCTION_PROFILER): Move offline to ...
* i386.c (x86_function_profiler) ... here; fix 64bit support
* beos-elf.h (FUNCTION_PROFILER): Kill.
(MCOUNT_NAME): New.
* freebsd-aout.h (FUNCTION_PROFILER): Kill.
(MCOUNT_NAME): New.
(PROFILE_COUNT_REGISTER): New.
* linux.h (FUNCTION_PROFILER): Kill.
(MCOUNT_NAME): New.
* x86-64.h (FUNCTION_PROFILER): Kill.
(MCOUNT_NAME): New.
* freebsd.h (FUNCTION_PROFILER): Kill.
(MCOUNT_NAME): New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@59132 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/i386/beos-elf.h
gcc/config/i386/freebsd-aout.h
gcc/config/i386/freebsd.h
gcc/config/i386/i386-protos.h
gcc/config/i386/i386.c
gcc/config/i386/i386.h
gcc/config/i386/linux.h
gcc/config/i386/x86-64.h

index 0041b2a..c43ef69 100644 (file)
@@ -1,3 +1,22 @@
+Fri Nov 15 14:54:19 CET 2002  Jan Hubicka  <jh@suse.cz>
+
+       * i386-protos.h (x86_function_profiler): New function
+       * i386.h (MCOUNT_NAME): New.
+       (PROFILE_COUNT_REGISTER): New.
+       (OUTPUT_FUNCTION_PROFILER): Move offline to ...
+       * i386.c (x86_function_profiler) ... here; fix 64bit support
+       * beos-elf.h (FUNCTION_PROFILER): Kill.
+       (MCOUNT_NAME): New.
+       * freebsd-aout.h (FUNCTION_PROFILER): Kill.
+       (MCOUNT_NAME): New.
+       (PROFILE_COUNT_REGISTER): New.
+       * linux.h (FUNCTION_PROFILER): Kill.
+       (MCOUNT_NAME): New.
+       * x86-64.h (FUNCTION_PROFILER): Kill.
+       (MCOUNT_NAME): New.
+       * freebsd.h (FUNCTION_PROFILER): Kill.
+       (MCOUNT_NAME): New.
+
 2002-11-14  Jeroen Dobbelaere  <jeroen.dobbelaere@acunia.com>
 
        * config/arm/arm.h (EXPAND_BUILTIN_VA_ARG,
index 7f9c2e2..b84519f 100644 (file)
@@ -40,21 +40,8 @@ Boston, MA 02111-1307, USA.  */
 /* Output assembler code to FILE to increment profiler label # LABELNO
    for profiling a function entry.  */
 
-#undef FUNCTION_PROFILER
-#define FUNCTION_PROFILER(FILE, LABELNO)  \
-{                                                                      \
-  if (flag_pic)                                                                \
-    {                                                                  \
-      fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n",             \
-              LPREFIX, (LABELNO));                                     \
-      fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n");                   \
-    }                                                                  \
-  else                                                                 \
-    {                                                                  \
-      fprintf (FILE, "\tmovl $%sP%d,%%edx\n", LPREFIX, (LABELNO));     \
-      fprintf (FILE, "\tcall mcount\n");                               \
-    }                                                                  \
-}
+#undef MCOUNT_NAME
+#define MCOUNT_NAME "mcount"
 
 #undef SIZE_TYPE
 #define SIZE_TYPE "long unsigned int"
index d5fab7c..a2b616e 100644 (file)
@@ -94,22 +94,10 @@ Boston, MA 02111-1307, USA.  */
 \f
 /* Profiling routines, partially copied from i386/osfrose.h.  */
 
-/* Redefine this to use %eax instead of %edx.  */
-#undef FUNCTION_PROFILER
-#define FUNCTION_PROFILER(FILE, LABELNO)  \
-{                                                                      \
-  if (flag_pic)                                                                \
-    {                                                                  \
-      fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%eax\n",             \
-              LPREFIX, (LABELNO));                                     \
-      fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n");                   \
-    }                                                                  \
-  else                                                                 \
-    {                                                                  \
-      fprintf (FILE, "\tmovl $%sP%d,%%eax\n", LPREFIX, (LABELNO));     \
-      fprintf (FILE, "\tcall mcount\n");                               \
-    }                                                                  \
-}
+#undef MCOUNT_NAME
+#define MCOUNT_NAME "mcount"
+#undef PROFILE_COUNT_REGISTER
+#define PROFILE_COUNT_REGISTER "eax"
 
 /*
  * Some imports from svr4.h in support of shared libraries.
index f209a15..e0160b1 100644 (file)
@@ -47,14 +47,8 @@ Boston, MA 02111-1307, USA.  */
 
 /* Tell final.c that we don't need a label passed to mcount.  */
 
-#undef FUNCTION_PROFILER
-#define FUNCTION_PROFILER(FILE, LABELNO)  \
-{                                                                      \
-  if (flag_pic)                                                                \
-      fprintf ((FILE), "\tcall *.mcount@GOT(%%ebx)\n");                        \
-  else                                                                 \
-      fprintf ((FILE), "\tcall .mcount\n");                            \
-}
+#undef MCOUNT_NAME
+#define MCOUNT_NAME ".mcount"
 
 /* Make gcc agree with <machine/ansi.h>.  */
 
index 64dc7b0..a594014 100644 (file)
@@ -184,6 +184,7 @@ extern void ix86_set_move_mem_attrs PARAMS ((rtx, rtx, rtx, rtx, rtx));
 extern void emit_i387_cw_initialization PARAMS ((rtx, rtx));
 extern bool ix86_fp_jump_nontrivial_p PARAMS ((enum rtx_code));
 extern void x86_order_regs_for_local_alloc PARAMS ((void));
+extern void x86_function_profiler PARAMS ((FILE *, int));
 
 
 #ifdef TREE_CODE
index b02fc4a..0ccb62c 100644 (file)
@@ -14297,6 +14297,46 @@ x86_field_alignment (field, computed)
   return computed;
 }
 
+/* Output assembler code to FILE to increment profiler label # LABELNO
+   for profiling a function entry.  */
+void
+x86_function_profiler (file, labelno)
+     FILE *file;
+     int labelno;
+{
+  if (TARGET_64BIT)
+    if (flag_pic)
+      {
+#ifndef NO_PROFILE_COUNTERS
+       fprintf (file, "\tleaq\t%sP%d@(%%rip),%%r11\n", LPREFIX, labelno);
+#endif
+       fprintf (file, "\tcall\t*%s@GOTPCREL(%%rip)\n", MCOUNT_NAME);
+      }
+    else
+      {
+#ifndef NO_PROFILE_COUNTERS
+       fprintf (file, "\tmovq\t$%sP%d,%%r11\n", LPREFIX, labelno);
+#endif
+       fprintf (file, "\tcall\t%s\n", MCOUNT_NAME);
+      }
+  else if (flag_pic)
+    {
+#ifndef NO_PROFILE_COUNTERS
+      fprintf (file, "\tleal\t%sP%d@GOTOFF(%%ebx),%%%s\n",
+              LPREFIX, labelno, PROFILE_COUNT_REGISTER);
+#endif
+      fprintf (file, "\tcall\t*%s@GOT(%%ebx)\n", MCOUNT_NAME);
+    }
+  else
+    {
+#ifndef NO_PROFILE_COUNTERS
+      fprintf (file, "\tmovl\t$%sP%d,%%$s\n", LPREFIX, labelno,
+              PROFILE_COUNT_REGISTER);
+#endif
+      fprintf (file, "\tcall\t%s\n", MCOUNT_NAME);
+    }
+}
+
 /* Implement machine specific optimizations.  
    At the moment we implement single transformation: AMD Athlon works faster
    when RET is not destination of conditional jump or directly preceeded
index 8e33176..ceba0b6 100644 (file)
@@ -1758,20 +1758,11 @@ typedef struct ix86_args {
 /* Output assembler code to FILE to increment profiler label # LABELNO
    for profiling a function entry.  */
 
-#define FUNCTION_PROFILER(FILE, LABELNO)                               \
-do {                                                                   \
-  if (flag_pic)                                                                \
-    {                                                                  \
-      fprintf ((FILE), "\tleal\t%sP%d@GOTOFF(%%ebx),%%edx\n",          \
-              LPREFIX, (LABELNO));                                     \
-      fprintf ((FILE), "\tcall\t*_mcount@GOT(%%ebx)\n");               \
-    }                                                                  \
-  else                                                                 \
-    {                                                                  \
-      fprintf ((FILE), "\tmovl\t$%sP%d,%%edx\n", LPREFIX, (LABELNO));  \
-      fprintf ((FILE), "\tcall\t_mcount\n");                           \
-    }                                                                  \
-} while (0)
+#define FUNCTION_PROFILER(FILE, LABELNO) x86_function_profiler (FILE, LABELNO)
+
+#define MCOUNT_NAME "_mcount"
+
+#define PROFILE_COUNT_REGISTER "edx"
 
 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
    the stack pointer does not matter.  The value is tested only in
index 54479d2..6b553cd 100644 (file)
@@ -53,14 +53,8 @@ Boston, MA 02111-1307, USA.  */
 
 #define NO_PROFILE_COUNTERS
 
-#undef FUNCTION_PROFILER
-#define FUNCTION_PROFILER(FILE, LABELNO)  \
-{                                                                      \
-  if (flag_pic)                                                                \
-    fprintf (FILE, "\tcall\t*mcount@GOT(%%ebx)\n");                    \
-  else                                                                 \
-    fprintf (FILE, "\tcall\tmcount\n");                                        \
-}
+#undef MCOUNT_NAME
+#define MCOUNT_NAME "mcount"
 
 /* The GLIBC version of mcount for the x86 assumes that there is a
    frame, so we cannot allow profiling without a frame pointer.  */
index 54efb81..7af95fe 100644 (file)
@@ -29,16 +29,8 @@ Boston, MA 02111-1307, USA.  */
 /* Output assembler code to FILE to call the profiler.  */
 #define NO_PROFILE_COUNTERS
 
-#undef FUNCTION_PROFILER
-#define FUNCTION_PROFILER(FILE, LABELNO)  \
-{                                                                      \
-  if (TARGET_64BIT && flag_pic)                                                \
-    fprintf (FILE, "\tcall\t*mcount@PLT\n");                           \
-  else if (flag_pic)                                                   \
-    fprintf (FILE, "\tcall\t*mcount@GOT(%%ebx)\n");                    \
-  else                                                                 \
-    fprintf (FILE, "\tcall\tmcount\n");                                        \
-}
+#undef MCOUNT_NAME
+#define MCOUNT_NAME mcount
 
 #undef SIZE_TYPE
 #define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")