Back to index

glibc  2.9
machine-gmon.h
Go to the documentation of this file.
00001 /* Machine-specific calling sequence for `mcount' profiling function.  MIPS
00002    Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004
00003        Free Software Foundation, Inc.
00004    This file is part of the GNU C Library.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #include <sgidefs.h>
00022 
00023 #define _MCOUNT_DECL(frompc,selfpc) \
00024 static void __attribute_used__ __mcount (u_long frompc, u_long selfpc)
00025 
00026 /* Call __mcount with the return PC for our caller,
00027    and the return PC our caller will return to.  */
00028 
00029 #if _MIPS_SIM == _ABIO32
00030 
00031 #ifdef __PIC__
00032 # define CPLOAD ".cpload $25;"
00033 # define CPRESTORE ".cprestore 44\n\t"
00034 #else
00035 # define CPLOAD
00036 # define CPRESTORE
00037 #endif
00038 
00039 #define MCOUNT asm(\
00040        ".globl _mcount;\n\t" \
00041        ".align 2;\n\t" \
00042        ".type _mcount,@function;\n\t" \
00043        ".ent _mcount\n\t" \
00044         "_mcount:\n\t" \
00045         ".frame $sp,44,$31\n\t" \
00046         ".set noreorder;\n\t" \
00047         ".set noat;\n\t" \
00048         CPLOAD \
00049        "subu $29,$29,48;\n\t" \
00050        CPRESTORE \
00051         "sw $4,24($29);\n\t" \
00052         "sw $5,28($29);\n\t" \
00053         "sw $6,32($29);\n\t" \
00054         "sw $7,36($29);\n\t" \
00055         "sw $2,40($29);\n\t" \
00056         "sw $1,16($29);\n\t" \
00057         "sw $31,20($29);\n\t" \
00058         "move $5,$31;\n\t" \
00059         "move $4,$1;\n\t" \
00060         "jal __mcount;\n\t" \
00061         "nop;\n\t" \
00062         "lw $4,24($29);\n\t" \
00063         "lw $5,28($29);\n\t" \
00064         "lw $6,32($29);\n\t" \
00065         "lw $7,36($29);\n\t" \
00066         "lw $2,40($29);\n\t" \
00067         "lw $31,20($29);\n\t" \
00068         "lw $1,16($29);\n\t" \
00069         "addu $29,$29,56;\n\t" \
00070         "j $31;\n\t" \
00071         "move $31,$1;\n\t" \
00072         ".set reorder;\n\t" \
00073         ".set at\n\t" \
00074         ".end _mcount");
00075 
00076 #else
00077 
00078 #ifdef __PIC__
00079 # define CPSETUP ".cpsetup $25, 88, _mcount;"
00080 # define CPRETURN ".cpreturn;"
00081 #else
00082 # define CPSETUP
00083 # define CPRETURN
00084 #endif
00085 
00086 #if _MIPS_SIM == _ABIN32
00087 # define PTR_ADDU_STRING "add" /* no u */
00088 # define PTR_SUBU_STRING "sub" /* no u */
00089 #elif _MIPS_SIM == _ABI64
00090 # define PTR_ADDU_STRING "daddu"
00091 # define PTR_SUBU_STRING "dsubu"
00092 #else
00093 # error "Unknown ABI"
00094 #endif
00095 
00096 #define MCOUNT asm(\
00097        ".globl _mcount;\n\t" \
00098        ".align 3;\n\t" \
00099        ".type _mcount,@function;\n\t" \
00100        ".ent _mcount\n\t" \
00101         "_mcount:\n\t" \
00102         ".frame $sp,88,$31\n\t" \
00103         ".set noreorder;\n\t" \
00104         ".set noat;\n\t" \
00105         PTR_SUBU_STRING " $29,$29,96;\n\t" \
00106         CPSETUP \
00107         "sd $4,24($29);\n\t" \
00108         "sd $5,32($29);\n\t" \
00109         "sd $6,40($29);\n\t" \
00110         "sd $7,48($29);\n\t" \
00111         "sd $8,56($29);\n\t" \
00112         "sd $9,64($29);\n\t" \
00113         "sd $10,72($29);\n\t" \
00114         "sd $11,80($29);\n\t" \
00115         "sd $2,16($29);\n\t" \
00116         "sd $1,0($29);\n\t" \
00117         "sd $31,8($29);\n\t" \
00118         "move $5,$31;\n\t" \
00119         "move $4,$1;\n\t" \
00120         "jal __mcount;\n\t" \
00121         "nop;\n\t" \
00122         "ld $4,24($29);\n\t" \
00123         "ld $5,32($29);\n\t" \
00124         "ld $6,40($29);\n\t" \
00125         "ld $7,48($29);\n\t" \
00126         "ld $8,56($29);\n\t" \
00127         "ld $9,64($29);\n\t" \
00128         "ld $10,72($29);\n\t" \
00129         "ld $11,80($29);\n\t" \
00130         "ld $2,16($29);\n\t" \
00131         "ld $31,8($29);\n\t" \
00132         "ld $1,0($29);\n\t" \
00133         CPRETURN \
00134         PTR_ADDU_STRING " $29,$29,96;\n\t" \
00135         "j $31;\n\t" \
00136         "move $31,$1;\n\t" \
00137         ".set reorder;\n\t" \
00138         ".set at\n\t" \
00139         ".end _mcount");
00140 
00141 #endif