summaryrefslogtreecommitdiff
path: root/gcc/config/i386
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2002-11-15 15:57:12 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2002-11-15 14:57:12 +0000
commita5fa1ecdab781978f189f6fe7fff83ab04b4e6e0 (patch)
tree43591b0682e50da60e903e7c99507c3f031bfdad /gcc/config/i386
parentf7109dea6c8f8ebeda06c297487d71475bf54d99 (diff)
downloadgcc-a5fa1ecdab781978f189f6fe7fff83ab04b4e6e0.tar.gz
i386-protos.h (x86_function_profiler): New function
* 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. From-SVN: r59132
Diffstat (limited to 'gcc/config/i386')
-rw-r--r--gcc/config/i386/beos-elf.h17
-rw-r--r--gcc/config/i386/freebsd-aout.h20
-rw-r--r--gcc/config/i386/freebsd.h10
-rw-r--r--gcc/config/i386/i386-protos.h1
-rw-r--r--gcc/config/i386/i386.c40
-rw-r--r--gcc/config/i386/i386.h19
-rw-r--r--gcc/config/i386/linux.h10
-rw-r--r--gcc/config/i386/x86-64.h12
8 files changed, 58 insertions, 71 deletions
diff --git a/gcc/config/i386/beos-elf.h b/gcc/config/i386/beos-elf.h
index 7f9c2e2edec..b84519f4d67 100644
--- a/gcc/config/i386/beos-elf.h
+++ b/gcc/config/i386/beos-elf.h
@@ -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"
diff --git a/gcc/config/i386/freebsd-aout.h b/gcc/config/i386/freebsd-aout.h
index d5fab7c8f76..a2b616e700b 100644
--- a/gcc/config/i386/freebsd-aout.h
+++ b/gcc/config/i386/freebsd-aout.h
@@ -94,22 +94,10 @@ Boston, MA 02111-1307, USA. */
/* 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.
diff --git a/gcc/config/i386/freebsd.h b/gcc/config/i386/freebsd.h
index f209a151cf4..e0160b1e048 100644
--- a/gcc/config/i386/freebsd.h
+++ b/gcc/config/i386/freebsd.h
@@ -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>. */
diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
index 64dc7b0758d..a5940140937 100644
--- a/gcc/config/i386/i386-protos.h
+++ b/gcc/config/i386/i386-protos.h
@@ -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
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index b02fc4a2092..0ccb62c3213 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -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
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 8e331765847..ceba0b627ec 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -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
diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
index 54479d2c87f..6b553cd4cb5 100644
--- a/gcc/config/i386/linux.h
+++ b/gcc/config/i386/linux.h
@@ -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. */
diff --git a/gcc/config/i386/x86-64.h b/gcc/config/i386/x86-64.h
index 54efb8144f1..7af95fe8b3b 100644
--- a/gcc/config/i386/x86-64.h
+++ b/gcc/config/i386/x86-64.h
@@ -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")